HDL—Circuits—Combinational Logic—Basic Gates(1)

1、Wire

module top_module (
    input in,
    output out);
    assign out = in;

endmodule

2、GND

module top_module (
    output out);
    assign out = 1'b0;
endmodule

3、NOR

module top_module (
    input in1,
    input in2,
    output out);
    assign out = ~(in1|in2);
endmodule

4、another gare

module top_module (
    input in1,
    input in2,
    output out);
    assign out = in1&(~in2);
endmodule

5、Two gates

module top_module (
    input in1,
    input in2,
    input in3,
    output out);
    assign out = (~(in1^in2))^in3;       
endmodule

6、More logic gates

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);
endmodule

7、7420 chips

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

8、Truthtable1

计算出最小的运算方式然后直接写就可以了,具体运算方法叫卡诺图

module top_module(
    input logic x3,
    input logic x2,
    input logic x1,  // three inputs
    output logic f   // one output
);
    assign f = x3 & x1 | x2 & x1 | ~x3 & x2;
endmodule

9、Two-bit equality

创建一个有两个2位输入 A [1:0]和 B [1:0]的电路,并产生一个输出 z。

如果 A = B,则 z 的值应为1,否则 z 应为0。

module top_module ( input [1:0] A, input [1:0] B, output z );
    assign z = A==B?1'b1:1'b0;
endmodule

10、Simple circuit A

模块 A 应该实现函数 z = (x ^ y) & x。

module top_module (input x, input y, output z);
    assign z = (x^y)&x;
endmodule

11、Simple circuit B

module top_module ( input x, input y, output z );
    assign z = x==y?1'b1:1'b0;
endmodule

12、Combine circuits A and B

有关此处使用的子模块,请参见 10 和 11。顶层设计由两个子电路 A 和 B 的实例组成,如下所示。

module top_module (input x, input y, output z);
    assign z = (((x ^ y) & x) | (x ~^ y)) ^ (((x ^ y) & x) & (x ~^ y));
endmodule

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值