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.
译:
在[3:0]中建立一个有四个输入的组合电路。
有3个输出:
out_and: 四输入与门的输出。
out_or:四输入或门输出。
out_xor:四输入异或门输出。
要查看与、或和异或运算符,请参阅AND gate、norgate和xnorgate。
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
说明: 异或计算符 " ^ "
时序图如下: