본문 바로가기

Verilog/HDLbits

[HDLBits] Gates4

1. 문제 및 설명

4개의 입력 in[3:0]을 가지는 조합 논리 회로를 설계하세요.

출력은 3개입니다:

  • out_and: 4입력 AND 게이트의 출력
  • out_or: 4입력 OR 게이트의 출력
  • out_xor: 4입력 XOR 게이트의 출력

 

2. 모듈 정의

module top_module( 
    input [3:0] in,
    output out_and,
    output out_or,
    output out_xor
);

 

 

 

3. 답

module top_module( 
    input [3:0] in,
    output out_and,
    output out_or,
    output out_xor
);
    assign out_and = &in[3:0];
    assign out_or = |in[3:0];
    assign out_xor = ^in[3:0];

endmodule

'Verilog > HDLbits' 카테고리의 다른 글

[HDLBits] Vectorr  (0) 2025.09.08
[HDLBits] Vector3  (1) 2025.08.27
[HDLBits] Vectorgates  (0) 2025.08.27
[HDLBits] Vector2  (0) 2025.08.27
[HDLBits] Vector1  (0) 2025.08.27