hdlbits-Gates4

Gates4

Build a combinational circuit with four inputs, in[3:0].

There are 3 outputs:

  • out_and: output of a 4-input AND gate.
  • out_or: output of a 4-input OR gate.
  • out_xor: output of a 4-input XOR gate.

solution

1
2
3
4
5
6
7
8
9
10
11
module top_module( 
input [3:0] in,
output out_and,
output out_or,
output out_xor
);
assign out_and = in[0] & in[1] & in[2] & in[3];
assign out_or = in[0] | in[1] | in[2] | in[3];
assign out_xor = in[0] ^ in[1] ^ in[2] ^ in[3];
endmodule


hdlbits-Gates4
http://456-xiao.github.io/2024/08/03/hdlbits-Gates4/
作者
xyh
发布于
2024年8月3日
许可协议