four-input gates

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.
To review the AND, OR, and XOR operators, see andgate, norgate, and xnorgate.

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

 

posted @ 2023-04-18 18:14  江左子固  阅读(33)  评论(0)    收藏  举报