Verilog学习笔记 HDLBits——Basic Gates

本文详细介绍了基本逻辑门(如NOR、AND、XOR等)的实现,真值表的应用,以及如何通过电路设计解决实际问题,如7420芯片功能模拟、电路组合和特定功能电路如计数器和逻辑判断。通过实例演示和逻辑关系理解,提升组合逻辑设计能力。

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档


前言

在前面的练习中,我们使用了简单的逻辑门和几个逻辑门的组合。这些电路是组合电路的例子。组合意味着电路的输出是其输入的函数(在数学意义上)。这意味着对于任何给定的输入值,只有一个可能的输出值。因此,描述组合函数行为的一种方法是显式列出输入的每个可能值的输出。这是真值表。
在这里插入图片描述

对于一个有N个输入的布尔函数,有2^N
种可能的输入组合。真值表的每一行列出一个输入组合,所以总有(2^N)行。输出列显示了每个输入值的输出。上面的真值表适用于三输入一输出的函数。对于8种可能的输入组合,每一种都有8行,还有一个输出列。有四种输入组合,其中输出为1,还有四种输出为0。

一、Basic Gates

1.wire

Practice:Implement the following circuit:
翻译:实现如图的电路
在这里插入图片描述

Solution(不唯一,仅供参考):

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


2.GND

Practice:Implement the following circuit:
翻译:实现以下电路
在这里插入图片描述

Solution(不唯一,仅供参考):

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

3.NOR

Practice:Implement the following circuit:
翻译:实现以下电路
在这里插入图片描述

Solution(不唯一,仅供参考):

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

4.Another gate

Practice:Implement the following circuit:
翻译:实现以下电路
在这里插入图片描述

Solution(不唯一,仅供参考):

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

5.Two gates

Practice:Implement the following circuit:
翻译:实现以下电路
在这里插入图片描述

Solution(不唯一,仅供参考):

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

6.More logic gates

Practice:building several logic gates at the same time. Build a combinational circuit with two inputs, a and b.
翻译:构建几个逻辑门
在这里插入图片描述

Solution(不唯一,仅供参考):

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

Timing Diagram
在这里插入图片描述

7.7420 chip

Practice:Create a module with the same functionality as the 7420 chip. It has 8 inputs and 2 outputs.
翻译:创建一个功能与7420芯片相同的模块。它有8个输入2个输出,如下图。
在这里插入图片描述

Solution(不唯一,仅供参考):

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

Timing Diagram
在这里插入图片描述

8.Truth tables

Practice:Create a combinational circuit that implements the above truth table.
翻译:创建一个实现上述真值表的组合电路。

在这里插入图片描述

Solution(不唯一,仅供参考):
使用generate语句(具体使用看总结)

module top_module( 
    input x3,
    input x2,
    input x1,  // three inputs
    output f   // one output
);
    always @(*)begin
        case(
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值