Decoder Design
جزء من قسم الأساسيات في رحلة Verilog على Coddy. الدرس 85 من 90.
التحدي
يأخذ decoder رقمًا ثنائيًا كـ input ويُشغّل output واحدًا بالضبط استنادًا إلى ذلك الرقم. يُسمّى الـ output الذي يتم تشغيله "one-hot" لأن بتًا واحدًا فقط يكون ساخنًا (1)، بينما تكون جميع others باردة (0).
جدول الحقيقة (decoder من 2 إلى 4)
| Input (in) | out0 | out1 | out2 | out3 |
|---|---|---|---|---|
| 00 | 1 | 0 | 0 | 0 |
| 01 | 0 | 1 | 0 | 0 |
| 10 | 0 | 0 | 1 | 0 |
| 11 | 0 | 0 | 0 | 1 |
واجهة module
| المنفذ | الاتجاه | العرض | الوصف |
|---|---|---|---|
in | input | 2 بت | إدخال ثنائي (من 0 إلى 3) |
out0 | output | 1 بت | نشط عندما يكون in = 00 |
out1 | output | 1 بت | نشط عندما يكون in = 01 |
out2 | output | 1 بت | نشط عندما يكون in = 10 |
out3 | output | 1 بت | نشط عندما يكون in = 11 |
مهمتك هي إكمال module أدناه باستخدام تعليمة case.
ما يجب فعله:
- عندما يكون
in = 2'b00، اجعلout0 = 1، وجميع others تساوي 0 - عندما يكون
in = 2'b01، اجعلout1 = 1، وجميع others تساوي 0 - عندما يكون
in = 2'b10، اجعلout2 = 1، وجميع others تساوي 0 - عندما يكون
in = 2'b11، اجعلout3 = 1، وجميع others تساوي 0
جرّب بنفسك
module decoder (
input [1:0] in,
output reg out0,
output reg out1,
output reg out2,
output reg out3
);
// TODO: أضف كتلة always @(*) مع case (in)
// 2'b00: out0=1، الباقي 0
// 2'b01: out1=1، الباقي 0
// 2'b10: out2=1، الباقي 0
// 2'b11: out3=1، الباقي 0
endmoduleجميع دروس الأساسيات
4Operators Part 1
Arithmetic OperatorsModulo OperatorComparison OperatorsRecap - Simple MathBitwise Operators7Assign And Gates
Continuous AssignmentAssign With OperatorsBuilt In Gate PrimitivesAND OR NOT GatesXOR XNOR GatesRecap - Logic Gate Circuit10Decision Making
If StatementIf - ElseRecap - Simple ComparatorCase StatementCasex And CasezRecap - ALU Design5Operators Part 2
Logical OperatorsReduction OperatorsShift OperatorsConcatenation OperatorConditional OperatorRecap - Operator Challenge3Number System
Binary RepresentationSized NumbersUnsized NumbersNegative NumbersSpecial Values X And ZRecap - Number Formats6Modules
Module StructureInput And Output PortsInout PortsModule InstantiationPort Mapping By NamePort Mapping By OrderRecap - Build A Module9Procedural Blocks
Always BlockInitial BlockSensitivity ListBlocking AssignmentNon Blocking AssignmentRecap - Always vs Initial15Traffic Light Controller
Defining The StatesState Machine Logicتدرّب بنفسك: مترجم Verilog عبر الإنترنت