Verilog学习笔记HDLBits——Finding bugs in code

本文探讨了如何修复五个关键的编程练习案例:8位多路复用器的错误、三输入与非门问题、4选1多路复用器bug、带零标志的加减法器以及组合电路的键盘识别。通过实例演示和解决方案,帮助读者提升代码调试技巧。

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


前言

一、Finding bugs in code

1.Mux

Practice:This 8-bit wide 2-to-1 multiplexer doesn’t work. Fix the bug(s).
翻译:
这个8位宽的2对1多路复用器不能工作。修复bug

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

module top_module (
    input sel,
    input [7:0] a,
    input [7:0] b,
    output [7:0] out  );

    assign out = sel?a:b;

endmodule

Timing Diagram
在这里插入图片描述

2.NAND

Practice:This three-input NAND gate doesn’t work. Fix the bug(s).
You must use the provided 5-input AND gate:

module andgate ( output out, input a, input b, input c, input d, input e );

翻译:这个三输入与非门不能工作。修复bug

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

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

    wire nout;
    andgate inst1 ( nout, a, b, c, 1, 1 );
	assign out=~nout;
    
endmodule

Timing Diagram

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值