由于组合逻辑电路中前面的部分过于简单,这里不做介绍。给出更多逻辑门(链接:Gates - HDLBits (01xz.net)的代码:
module top_module(
input a, b,
output out_and,
output out_or,
output out_xor,
output out_nand,
output out_nor,
output out_xnor,
output out_anotb
);
assign out_and = a&b;//与门
assign out_or = a|b;//非门
assign out_xor = a^b;//异或门
assign out_nand = !(a & b);//先与后非门
assign out_nor = !(a|b);//先或后非门
assign out_xnor = !(a^b);//同或门
assign out_anotb = a&!b;b输入取非再与a&
endmodule
7400系列集成电路是一系列数字芯片,每个芯片有几个门。7420 是一款具有两个 4 输入 NAND 门的芯片。
创建一个与 7420 芯片具有相同功能的模块。它有8个输入和2个输出。
代码如下:
module top_module (
input p1a, p1b, p1c, p1d,
output p1y,
input p2a, p2b, p2c, p2d,
output p2y );
assign p1y = !(p1a&p1b&p1c&p1d);
assign p2y = !(p2a&p2b&p2c&p2d);
endmodule
仿真结果如下:
由仿真结果可知,7420芯片中的输出p1y和p2y只有当输入全为1时才能取到1。