Menu
Coddy logo textTech

Decoder Design

Coddy Verilog 여정의 기초 섹션에 포함된 레슨. 90개 중 85번째.

challenge icon

챌린지

decoder는 이진수를 input으로 받아 그 숫자에 해당하는 정확히 하나의 output을 켭니다. 켜지는 output을 "one-hot"이라고 부르는 이유는 비트 하나만 뜨겁고(1), 나머지는 모두 차갑기(0) 때문입니다.

진리표 (2-to-4 decoder)

input (in)out0out1out2out3
001000
010100
100010
110001

module 인터페이스

포트방향너비설명
ininput2비트이진 input (0~3)
out0output1비트in = 00일 때 활성화
out1output1비트in = 01일 때 활성화
out2output1비트in = 10일 때 활성화
out3output1비트in = 11일 때 활성화

여러분의 과제는 아래의 module을 case 문을 사용하여 완성하는 것입니다.

할 일:

  1. in = 2'b00일 때 out0 = 1이고, 나머지 others는 0
  2. in = 2'b01일 때 out1 = 1이고, 나머지 others는 0
  3. in = 2'b10일 때 out2 = 1이고, 나머지 others는 0
  4. 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: case (in)이 있는 always @(*) 블록 추가
  // 2'b00: out0=1, 나머지 0
  // 2'b01: out1=1, 나머지 0
  // 2'b10: out2=1, 나머지 0
  // 2'b11: out3=1, 나머지 0

endmodule

기초의 모든 레슨

직접 연습해 보세요: 온라인 Verilog 컴파일러