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. 在Apache Cassandra数据库软件中报告高严重性RCE安全漏洞

    研究人员披露了ApacheCassandra一个现已修补的高严重性安全漏洞的细节,如果这个漏洞得不到解决,可能会被滥用来获取受影响安装的远程代码执行(RCE). DevOps公司JFrog的安全研究员 ...

  2. 如何高效解决 C++内存问题,Apache Doris 实践之路|技术解析

    导读:Apache Doris 使用 C++ 语言实现了执行引擎,C++ 开发过程中,影响开发效率的一个重要因素是指针的使用,包括非法访问.泄露.强制类型转换等.本文将会通过对 Sanitizer 和 ...

  3. 为什么Index Only Scan却还需要访问表

    在实际SQL优化工作中,我们经常会发现SQL 执行计划明明是 "Index Only Scan",但执行计划后面却有 "Heap Fetches: x" ,也就 ...

  4. KingbaseES 实现MYSQL hex/unhex 函数

    MySQL 的hex 和 unhex 函数类似于KingbaseES 的encode 和 decoding,实现字符与16进制之间的转换. 一.先看MySQL例子 mysql> select h ...

  5. QT学习(五)----360界面制作(2终结)

    继续上一章的360新特性界面.源代码:http://download.csdn.net/detail/zhangyang1990828/5241242 上一章中实现了整个界面的纯UI设计,这次我们让它 ...

  6. Kubernetes 部署 Nacos 1.4 集群

    文章转载自:http://www.mydlq.club/article/104/ 系统环境: Nacos 版本:1.4.1 Mysql 版本:8.0.19 Kubernetes 版本:1.20.1 一 ...

  7. 5.第四篇 Etcd存储组件高可用部署

    文章转载自:https://mp.weixin.qq.com/s?__biz=MzI1MDgwNzQ1MQ==&mid=2247483792&idx=1&sn=b991443c ...

  8. Elasticsearch:反向代理及负载均衡在 Elasticsearch 中的应用

    文章转载自:https://elasticstack.blog.csdn.net/article/details/108365746

  9. 2_Servlet

    一. 引言 1.1 C/S架构和B/S架构 C/S 和B/S是软件发展过程中出现的两种软件架构方式 1.2 C/S架构(Client/Server 客户端/服务器) 特点: 必须在客户端安装特定软件 ...

  10. 关于使用git传输文件到GitHub

    git status(查看本地git仓库情况) git add "文件名(精确到文件拓展名)" git commit -m "说明"(提交到上传缓存区域) gi ...