Decoder Design
Parte de la sección Fundamentos del Journey de Verilog de Coddy. Lección 85 de 90.
Desafío
Un decoder toma un número binario como input y activa exactamente un output según ese número. El output que se activa se llama "one-hot" porque solo un bit está activo (1) y todos los demás están inactivos (0).
Tabla de verdad (decoder de 2 a 4)
| Entrada (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 |
Interfaz del module
| Puerto | Dirección | Ancho | Descripción |
|---|---|---|---|
in | input | 2 bits | Entrada binaria (0 a 3) |
out0 | output | 1 bit | Activo cuando in = 00 |
out1 | output | 1 bit | Activo cuando in = 01 |
out2 | output | 1 bit | Activo cuando in = 10 |
out3 | output | 1 bit | Activo cuando in = 11 |
Tu tarea es completar el module de abajo usando una instrucción case.
Qué hacer:
- Cuando
in = 2'b00,out0 = 1y todos los demásothersson 0 - Cuando
in = 2'b01,out1 = 1y todos los demásothersson 0 - Cuando
in = 2'b10,out2 = 1y todos los demásothersson 0 - Cuando
in = 2'b11,out3 = 1y todos los demásothersson 0
Pruébalo tú mismo
module decoder (
input [1:0] in,
output reg out0,
output reg out1,
output reg out2,
output reg out3
);
// TODO: Añade el bloque always @(*) con case (in)
// 2'b00: out0=1, otros 0
// 2'b01: out1=1, otros 0
// 2'b10: out2=1, otros 0
// 2'b11: out3=1, otros 0
endmoduleTodas las lecciones de Fundamentos
1Introducción
Qué es VerilogHardware frente a softwareTu primer móduloComentariosNiveles de abstracción del diseño4Operators 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 LogicPractica por tu cuenta: Compilador de Verilog online