Decoder Design
CoddyのVerilogジャーニー「基礎」セクションの一部。レッスン 85/90。
チャレンジ
decoderはバイナリ番号をinputとして受け取り、その番号に基づいて正確にoutputを1つだけオンにします。オンになるoutputは「one-hot」と呼ばれます。これは、1つのビットだけがホット(1)で、その他すべてがコールド(0)だからです。
真理値表(2-to-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 |
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のときアクティブ |
あなたの課題は、case文を使って以下のmoduleを完成させることです。
行うこと:
in = 2'b00のとき、out0 = 1、その他すべては0in = 2'b01のとき、out1 = 1、その他すべては0in = 2'b10のとき、out2 = 1、その他すべては0in = 2'b11のとき、out3 = 1、その他すべては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オンラインコンパイラ