Decoder Design
Teil des Abschnitts Grundlagen der Verilog-Journey von Coddy. Lektion 85 von 90.
Aufgabe
Ein decoder nimmt eine Binärzahl als input und schaltet basierend auf dieser Zahl genau einen output ein. Der eingeschaltete output wird als "one-hot" bezeichnet, weil nur ein Bit aktiv (1) und alle anderen kalt (0) sind.
Wahrheitstabelle (2-zu-4-Decoder)
| 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 |
Modulschnittstelle
| Port | Richtung | Breite | Beschreibung |
|---|---|---|---|
in | input | 2 Bits | Binärer input (0 bis 3) |
out0 | output | 1 Bit | Aktiv, wenn in = 00 |
out1 | output | 1 Bit | Aktiv, wenn in = 01 |
out2 | output | 1 Bit | Aktiv, wenn in = 10 |
out3 | output | 1 Bit | Aktiv, wenn in = 11 |
Deine Aufgabe besteht darin, das folgende Modul mithilfe einer case-Anweisung zu vervollständigen.
Aufgabe:
- Wenn
in = 2'b00,out0 = 1, alle others 0 - Wenn
in = 2'b01,out1 = 1, alle others 0 - Wenn
in = 2'b10,out2 = 1, alle others 0 - Wenn
in = 2'b11,out3 = 1, alle others 0
Probier es selbst
module decoder (
input [1:0] in,
output reg out0,
output reg out1,
output reg out2,
output reg out3
);
// TODO: Füge always @(*)-Block mit case (in) hinzu
// 2'b00: out0=1, andere 0
// 2'b01: out1=1, andere 0
// 2'b10: out2=1, andere 0
// 2'b11: out3=1, andere 0
endmoduleAlle Lektionen in Grundlagen
1Einführung
Was ist VerilogHardware vs. SoftwareIhr erstes ModulKommentareAbstraktionsebenen des Designs4Operators 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Übe selbstständig: Online-Verilog-Compiler