Decoder Design
Coddy Verilog 여정의 기초 섹션에 포함된 레슨. 90개 중 85번째.
챌린지
decoder는 이진수를 input으로 받아 그 숫자에 해당하는 정확히 하나의 output을 켭니다. 켜지는 output을 "one-hot"이라고 부르는 이유는 비트 하나만 뜨겁고(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일 때 활성화 |
여러분의 과제는 아래의 module을 case 문을 사용하여 완성하는 것입니다.
할 일:
in = 2'b00일 때out0 = 1이고, 나머지 others는 0in = 2'b01일 때out1 = 1이고, 나머지 others는 0in = 2'b10일 때out2 = 1이고, 나머지 others는 0in = 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: case (in)이 있는 always @(*) 블록 추가
// 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 컴파일러