Decoder Design
Часть раздела Основы путешествия по Verilog на Coddy. Урок 85 из 90.
Задание
decoder принимает двоичное число в качестве input и включает ровно один output на основе этого числа. Включённый output называется "one-hot", потому что только один бит является активным (1), а все others неактивны (0).
Таблица истинности (decoder 2-to-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 бита | Двоичный input (от 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Все уроки раздела Основы
1Введение
Что такое VerilogАппаратное обеспечение и программное обеспечениеВаш первый модульКомментарииУровни абстракции проектирования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