Verilog编程初步习题

目录

一、门电路

1、和门

​2、无门

​3、XNOR门

二、组合电路

1、半加器全加器

2、7420芯片

​3、全加器

​三、时序电路

1、D触发器

​2、8位D触发器

​3、四位二进制计数器


一、门电路


1、和门


模块代码:

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


实验结果:


2、无门


模块代码

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


实验结果:


3、XNOR门


模块代码:

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


实验结果:

二、组合电路


1、半加器全加器


模块代码:

module top_module( 
    input a, b,
    output cout, sum );
assign cout=a&b;
assign sum=a^b;
endmodule


实验结果:


2、7420芯片


模块代码:

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


实验结果:


3、全加器


模块代码:

module top_module( 
    input a, b, cin,
    output cout, sum );
   assign sum  = a^b^cin;
   assign cout = (a&b)|(a&cin)|(b&cin);
endmodule


实验结果:


三、时序电路


1、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


实验结果:


2、8位D触发器


模块代码:

module top_module (
    input clk,
    input [7:0] d,
    output [7:0] q
);
always@(posedge clk) begin
        q <= d;
    end
endmodule


实验结果:


3、四位二进制计数器


模块代码:

module top_module (
    input clk,
    input reset,      // Synchronous active-high reset
    output [3:0] q);
 
endmodule


实验结果:

  • 19
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值