1 Finding bugs in code

1.1 Bugs mux2

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

1.2 Bugs nand3

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

    wire out_0;

    andgate inst1 (out_0, a, b, c, 1'b1 , 1'b1);

    assign out = ~out_0;

endmodule

1.3 Bugs mux4

module top_module (
input [1:0] sel,
input [7:0] a,
input [7:0] b,
input [7:0] c,
input [7:0] d,
output [7:0] out ); // wire [7:0] mux0;
wire [7:0] mux1;
mux2 U1 ( sel[0], a, b, mux0 );
mux2 U2 ( sel[0], c, d, mux1 );
mux2 U3 ( sel[1], mux0, mux1, out ); endmodule

1.4 Bugs addsubz

// synthesis verilog_input_version verilog_2001
module top_module (
input do_sub,
input [7:0] a,
input [7:0] b,
output reg [7:0] out,
output reg result_is_zero
);// always @(*) begin
case (do_sub)
0: out <= a+b;
1: out <= a-b;
endcase if (out==0)
result_is_zero = 1;
else
result_is_zero = 0;
end endmodule

1.5 Bugs case

module top_module (
input [7:0] code,
output reg [3:0] out,
output reg valid );// always @(*)begin
case (code)
8'h45:begin
out <= 0;
valid <= 1;
end
8'h16:begin
out <= 1;
valid <= 1;
end
8'h1e:begin
out <= 2;
valid <= 1;
end
8'h26:begin
out <= 3;
valid <= 1;
end
8'h25:begin
out <= 4;
valid <= 1;
end
8'h2e:begin
out <= 5;
valid <= 1;
end
8'h36:begin
out <= 6;
valid <= 1;
end
8'h3d:begin
out <= 7;
valid <= 1;
end
8'h3e:begin
out <= 8;
valid <= 1;
end
8'h46:begin
out <= 9;
valid <= 1;
end
default:begin
valid <= 0;
out <= 0;
end
endcase
end endmodule

2 Build a circuit from a simulationwaveform

2.1 Sim/circuit1

module top_module (
input a,
input b,
output q );// assign q = a&b; // Fix me endmodule

2.2 Sim/circuit2

module top_module (
input a,
input b,
input c,
input d,
output q );// assign q = ~a & ~b & ~c & ~d | ~a & ~b & c & d | ~a & b & ~c & d | ~a & b & c & ~d |
a & b & ~c & ~d | a & b & c & d | a & ~b & ~c & d | a & ~b & c & ~d; endmodule

2.3 Sim/circuit3

module top_module (
input a,
input b,
input c,
input d,
output q );// assign q = b & d | b & c | a & d | a & c; // Fix me endmodule

2.4 Sim/circuit4

module top_module (
input a,
input b,
input c,
input d,
output q );// assign q = b|c; // Fix me endmodule

2.5 Sim/circuit5

module top_module (
input [3:0] a,
input [3:0] b,
input [3:0] c,
input [3:0] d,
input [3:0] e,
output [3:0] q ); always@(*)begin
case(c)
4'd0:q<=b;
4'd1:q<=e;
4'd2:q<=a;
4'd3:q<=d;
default:q<=4'hf;
endcase
end endmodule

2.6 Sim/circuit6

module top_module (
input [2:0] a,
output [15:0] q ); always@(*)begin
case(a)
3'd0:q<=16'h1232;
3'd1:q<=16'haee0;
3'd2:q<=16'h27d4;
3'd3:q<=16'h5a0e;
3'd4:q<=16'h2066;
3'd5:q<=16'h64ce;
3'd6:q<=16'hc526;
3'd7:q<=16'h2f19;
endcase
end endmodule

2.7 Sim/circuit7

module top_module (
input clk,
input a,
output q ); always@(posedge clk)begin
q <= ~a;
end endmodule

2.8 Sim/circuit8

module top_module (
input clock,
input a,
output p,
output q ); always@(*)begin
if(clock)
p <= a;
else
p <= p;
end always@(negedge clock)begin
q <= p;
end endmodule

2.9 Sim/circuit9

module top_module (
input clk,
input a,
output [3:0] q ); always@(posedge clk)begin
if(a)begin
q <= 4'd4;
end
else if(q == 4'd6)begin
q <= 4'd0;
end
else begin
q <= q + 1'b1;
end
end endmodule

2.10 Sim/circuit10

module top_module (
input clk,
input a,
input b,
output q,
output state ); always @(posedge clk) state <= state ? a|b : a&b;
assign q = a^b^state; endmodule

HDLBits答案——Verification: Reading Simulations的更多相关文章

  1. Cracking Digital VLSI Verification Interview 第三章

    目录 Programming Basics Basic Programming Concepts Object Oriented Programming Concepts UNIX/Linux Pro ...

  2. Greedy:Jessica's Reading Problem(POJ 3320)

    Jessica's Reading Problem 题目大意:Jessica期末考试临时抱佛脚想读一本书把知识点掌握,但是知识点很多,而且很多都是重复的,她想读最少的连续的页数把知识点全部掌握(知识点 ...

  3. 解决Lost connection to MySQL server at 'reading initial communication packet', 的方法

    今天用heidsql连接mysql时出了问题,提示:Lost connection to MySQL server at 'reading initial communication packet 网 ...

  4. Cummins INSITE locked and ask for verification code

    Some Cummins INSITE users turn to our engineer with a same question: INSITE has detected an invalid ...

  5. 验证(Verification)与确认(Validation)的差别

    验证(Verification)与确认(Validation)的差别 说法一: (2)“验证(Verification)”的涵义 通过提供客观证据对规定要求已得到满足的认定. (2)“确认(Valid ...

  6. c++ primer plus 习题答案(1)

    c++ primer plus 习题答案用的是第五版,IDE仍然是vs2013.我只标注了题号,具体的题目找下书上对应内容吧. p110.8 #include<iostream> #inc ...

  7. 论文选读二:Multi-Passage Machine Reading Comprehension with Cross-Passage Answer Verification

    论文选读二:Multi-Passage Machine Reading Comprehension with Cross-Passage Answer Verification 目前,阅读理解通常会给出 ...

  8. linux环境,通过rpm删除mysql包,报错:error reading information on service mysqld: Invalid argument

    问题描述: 今天在做saltstack的练习,想要通过sls的方式,在远程进行mysql数据库的安装,发现无法通过service的方式启动数据库,然后就想给删除了重新进行安装,在通过rpm -e进行删 ...

  9. 200个最常见的JAVA面试问题(附答案)

    本文内容: 20个最常见的JAVA面试问题(附答案) 13个单例模式JAVA面试问题(附答案) 说说JVM和垃圾收集是如何工作的(附答案) 说说如何避免JAVA线程死锁(附答案) Java中HashS ...

  10. nginx error: upstream prematurely closed connection while reading response header from upstream

    本篇文章由:http://xinpure.com/nginx-error-upstream-prematurely-closed-connection-while-reading-response-h ...

随机推荐

  1. MySQL InnoDB缓存

    1. 背景 对于各种用户数据.索引数据等各种数据都是需要持久化存储到磁盘,然后以"页"为单位进行读写. 相对于直接读写缓存,磁盘IO的成本相当高昂. 对于读取的页面数据,并不是使用 ...

  2. 跟我学Python图像处理丨关于图像金字塔的图像向下取样和向上取样

    摘要:本文讲述图像金字塔知识,了解专门用于图像向上采样和向下采样的pyrUp()和pyrDown()函数. 本文分享自华为云社区<[Python图像处理] 二十一.图像金字塔之图像向下取样和向上 ...

  3. 基于electron+vue+element构建项目模板之【创建项目篇】

    1.概述 electron:使用javascript.css.html构建跨平台的桌面应用程序 vue:数据驱动视图中的一款渐进式的javascript框架 element:基于vue的桌面端UI组件 ...

  4. 如何使用DBeaver连接Hive

    1 DBeaver介绍 DBeaver是一个通用的数据库管理工具和 SQL 客户端,支持多种兼容 JDBC 的数据库.DBeaver 提供一个图形界面用来查看数据库结构.执行SQL查询和脚本,浏览和导 ...

  5. 在 CentOS 8 上使用 FirewallD 设置防火墙

    简介 一个 Linux 防火墙可用于保护您的工作站或服务器免受不需要的流量干扰.您可以设置规则来阻止或允许流量通过.CentOS 8 带有一个动态的.可定制的基于主机的防火墙和一个 D-Bus 接口. ...

  6. Elastic:用 Docker 部署 Elastic Stack

    文章转载自:https://elasticstack.blog.csdn.net/article/details/100919273 前提条件 首选需要在主机上安装好docker和docker-com ...

  7. Linux恢复误删除的文件或者目录

    文章转载自:https://www.jianshu.com/p/662293f12a47 linux不像windows有个回收站,使用rm -rf *基本上文件是找不回来的. 那么问题来了: 对于li ...

  8. 1.在 Kubernetes 在快速安装 Harbor

    网址:https://www.qikqiak.com/post/harbor-quick-install/ 安装 Harbor Harbor 支持多种安装方式,源码目录下面默认有一个安装脚本(make ...

  9. FastDFS 分布式文件系统的安装与使用---两台服务器搭建FastDFS环境

    写在前面 有不少小伙伴在实际工作中,对于如何存储文件(图片.视频.音频等)没有一个很好的解决思路.都明白不能将文件存储在单台服务器的磁盘上,也知道需要将文件进行副本备份.如果自己手动写文件的副本机制, ...

  10. 换工作?试试远程工作「GitHub 热点速览 v.22.40」

    近日,潜在某个技术交流群的我发现即将毕业的小伙伴在焦虑实习.校招,刚好本周 GitHub 热榜有个远程工作项目.不妨大家换个思路,"走"出去也许有更多的机会.当然,除了全球的远程工 ...