Verilog语言编程巩固

本文详细介绍了使用Verilog语言进行门电路设计,包括与门、或非门、XNOR门及7458芯片的应用。接着深入探讨了组合电路,如半加器、全加器和3位二进制加法器的实现。最后,讨论了时序电路,涵盖了D触发器、边缘捕捉寄存器和DFF的Verilog编程方法。
摘要由CSDN通过智能技术生成

一、门电路实例

(一)与门

模块声明:

module top_module( 
    input a, 
    input b, 
    output out );

endmodule

时序图:
在这里插入图片描述

(二)或非门

创建一个实现“或非”门的模块。或非门是其输出取反的或门
模块声明:

module top_module( 
    input a, 
    input b, 
    output out );

endmodule

时序图
在这里插入图片描述

(三)XNOR门

模块声明:

module top_module( 
    input a, 
    input b, 
    output out );

endmodule

时序图:
在这里插入图片描述

(四)7458芯片

模块声明:

module top_module ( 
    input p1a, p1b, p1c, p1d, p1e, p1f,
    output p1y,
    input p2a, p2b, p2c, p2d,
    output p2y );


endmodule

时序图:
在这里插入图片描述

二、组合电路

(一)半加法器

模块声明:

module top_module( 
    input a, b,
    output cout, sum );

endmodule

在这里插入图片描述

(二)全加器

module top_module( 
    input a, b, cin,
    output cout, sum );

endmodule

在这里插入图片描述

(三)3位二进制加法器

模块声明:

module top_module( 
    input [2:0] a, b,
    input cin,
    output [2:0] cout,
    output [2:0] sum );

endmodule

在这里插入图片描述

三、时序电路

(一)D触发器

模块声明:

module top_module (
    input clk,    // Clocks are used in sequential circuits
    input d,
    output reg q );//

    // Use a clocked always block
    //   copy d to q at every positive edge of clk
    //   Clocked always blocks should use non-blocking assignments

endmodule

在这里插入图片描述

(二)边缘捕捉寄存器

模块:

module top_module (
    input clk,
    input reset,
    input [31:0] in,
    output [31:0] out
);

endmodule

在这里插入图片描述

(三)DFF

模块声明:

module top_module (
    input clk,
    input d, 
    input ar,   // asynchronous reset
    output q);

endmodule

在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值