1 四输入门
作业:
构建一个具有四个输入的组合电路in[3:0]。
有3个输出:
out_and:4 输入与门的输出。
out_or:4 输入或门的输出。
out_xor:4 输入异或门的输出。
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
module top_module(
input [3:0] in,
output out_and,
output out_or,
output out_xor
);
assign out_and = & in;
assign out_or = | in;
assign out_xor = ^ in;
endmodule