Exams/ece241 2014 q4经验
总结:模块命名注意不能与内置模块同名
Given the finite state machine circuit as shown, assume that the D flip-flops are initially reset to zero before the machine begins.
Build this circuit.
方法一:模块实例化
1)当按端口名称进行端口对应实例化时,success。
module top_module (
input clk,
input x,
output z
);
/*第一部分的连接*/
wire q0 ;
wire d0 ;
assign d0 = q0 ^ x;
dff dff_module_inst0(.clk(clk),.d(d0),.q(q0));
/*第二部分的连接*/
wire q1 ;
wire d1 ;
assign d1 = ~q1 & x;
dff dff_module_inst1(.clk(clk),.d(d1),.q(q1));
/*第三部分的连接*/
wire q2 ;
wire d2 ;
assign d2 = ~q2 | x;
dff dff_module_inst2(.clk(clk),.d(d2),.q(q2));
/*最后的输出结果*/
assign z = ~(q0 | q1 | q2);
endmodule
/*D触发器模块*/
module dff(input clk,input d,output reg q);
always@(posedge clk) begin
q <= d;
end
endmodule
2)当按端口位置实例化时,结果不正确。
代码仅在实例化语句处作更改。
module top_module (
input clk,
input x,
output z
);
/*第一部分的连接*/
wire q0 ;
wire d0 ;
assign d0 = q0 ^ x;
dff dff_module_inst0(clk,d0,q0); //
/*第二部分的连接*/
wire q1 ;
wire d1 ;
assign d1 = ~q1 & x;
dff dff_module_inst1(clk,d1,q1); //
/*第三部分的连接*/
wire q2 ;
wire d2 ;
assign d2 = ~q2 | x;
dff dff_module_inst2(clk,d2,q2); //
/*最后的输出结果*/
assign z = ~(q0 | q1 | q2);
endmodule
/*D触发器模块*/
module dff(input clk,input d,output reg q);
always@(posedge clk) begin
q <= d;
end
endmodule
编译成功,但结果错误。
Status: Incorrect
Compile and simulation succeeded, but the circuit's output wasn't entirely correct. The hints below may help.
# Hint: Output 'z' has 94 mismatches. First mismatch occurred at time 10. # Hint: Total mismatched samples is 94 out of 115 samples
原因查明为d触发器模块名称为内置模块名称,所引起冲突,造成错误。
Warning (12018): Entity "dff" will be ignored because it conflicts with Quartus Prime primitive name File: /home/h/work/hdlbits.3688841/top_module.v Line: 28
Quartus has a number of built-in "primitive" modules. Don't give any of your modules the same name as a primitive. This message warns you that you are instantiating the built-in primitive instead of your module.
将dff修改为mydff后,success
module top_module (
input clk,
input x,
output z
);
/*第一部分的连接*/
wire q0 ;
wire d0 ;
assign d0 = q0 ^ x;
mydff dff_module_inst0(clk,d0,q0);
/*第二部分的连接*/
wire q1 ;
wire d1 ;
assign d1 = ~q1 & x;
mydff dff_module_inst1(clk,d1,q1);
/*第三部分的连接*/
wire q2 ;
wire d2 ;
assign d2 = ~q2 | x;
mydff dff_module_inst2(clk,d2,q2);
/*最后的输出结果*/
assign z = ~(q0 | q1 | q2);
endmodule
/*D触发器模块*/
module mydff(input clk,input d,output reg q);
always@(posedge clk) begin
q <= d;
end
endmodule
再改变一下排版,依旧success
module top_module (
input clk,
input x,
output z
);
wire d0,d1,d2;
wire q0,q1,q2;
assign d0 = q0 ^ x;
assign d1 = ~q1 & x;
assign d2 = ~q2 | x;
mydff mydff_inst0(clk,d0,q0);
mydff mydff_inst1(clk,d1,q1);
mydff mydff_inst2(clk,d2,q2);
assign z = ~(q0 | q1 | q2);
endmodule
module mydff (input clk,input d,output reg q);
always @(posedge clk) begin
q <= d;
end
endmodule
方法二:
module top_module (
input clk,
input x,
output z
);
wire q0,q1,q2;
always @(posedge clk) begin
q0 <= x ^ q0;
q1 <= x & ~q1;
q2 <= x | ~q2;
end
assign z = ~(q0 | q1 | q2);
endmodule
Exams/ece241 2014 q4经验相关推荐
- 【小罗的hdlbits刷题笔记2】补码运算中溢出的问题(Exams/ece241 2014 q1c)
关于补码运算中进位溢出的问题及延伸,hdlbits中Exams/ece241 2014 q1c给出了很好的解释,首先来看问题: Assume that you have two 8-bit 2's c ...
- Verilog刷题HDLBits——Exams/ece241 2014 q7a
Verilog刷题HDLBits--Exams/ece241 2014 q7a 题目描述 代码 结果 题目描述 Design a 1-12 counter with the following inp ...
- HDLBits Exams/ece241 2013 q4 水库题
题目和简述 题目内容翻译: 大型水库可为多个用户提供服务.为了使水位足够高,三个传感器以5英寸的间隔垂直放置.当水位高于最高传感器(S3)时,输入流量应为零.当液位低于最低传感器(S1)时,流量应最大 ...
- Exams/ece241 2014 q5b_HDLbits
1.The following diagram is a Mealy machine implementation of the 2's complementer. Implement using o ...
- HDLBits-Exams/ece241 2013 q4、Lemmings1、Lemmings2、Lemmings3、Lemmings4
目录 Exams/ece241 2013 q4 Lemmings1 Lemmings2 Lemmings3 Lemmings4 Exams/ece241 2013 q4 题目见网页图片. module ...
- 中国科学技术大学 2014 计算机 复试方案,中科大2014复试经验 - 中国科学技术大学 - 王道论坛,专注于计算机考研的点点滴滴! - Powered by Discuz!...
本帖最后由 Tsinghua_2013 于 2014-4-7 22:08 编辑 中科大2014复试经验 谨以此文献给在考研过程中给过我资料.经验.希望.力量的王道论坛,希望王道能越办越好.并希望此文能 ...
- 【verilog学习23】HDLBits:Circuits_Sequential Logic_Finite State Machines
[HDLBits]Circuits_Sequential Logic_Finite State Machines I FSM 1 (asynchronous reset) (Fsm1) 1.代码编写 ...
- verilog练习:hdlbits网站上的做题笔记(6)
前言 之前的文章<如何学习verilog,如何快速入门?>中提到了verilog学习,推荐了一个可以练习的网站:hdlbits网站,那自己也玩玩这个网站. 这篇文章,是接着<veri ...
- verilog 简单module_HDLBits:在线学习 Verilog (二十九 · Problem 140-144)
本系列文章将和读者一起巡礼数字逻辑在线学习网站 HDLBits 的教程与习题,并附上解答和一些作者个人的理解,相信无论是想 7 分钟精通 Verilog,还是对 Verilog 和数电知识查漏补缺的同 ...
最新文章
- 为什么大家都说 SELECT * 效率低?
- 关于rxjs里operators filter和map的详细讨论
- 2018年python薪资_2018年国内就业薪资高的7大编程语言排行
- 安卓mysql插入数据_Android批量插入数据到SQLite数据库的方法
- python模块相互引用_python中如何相互引用两个包中的模块
- android 弹幕礼物,Android B站开源的弹幕库的用法以及坑
- gimp中文版教程_GIMP中文详细教程.pdf
- 【软件相关】win10自带软件“画图”的妙用
- 小程序上传图片/上传视频
- Xshell下载过期怎么办
- 单选/复选框中点击文字能选择该选项
- 计算机技术能力校本培训总结,计算机、网络技术校本培训总结.doc
- 为什么时钟信号比数据信号更容易引起辐射超标
- 交换机端口的PVID
- 记录Unity设置Fullscreen Mode 为Exclusive Fullscreen时失去焦点最小化的问题
- day14_雷神_前端02
- 深度学习实战---猫狗大战(pytorch实现)
- 2017中招计算机考试,计算机一级考试试题操作题
- python生成随机数组_python3.x 生成3维随机数组实例
- cissp证书含金量如何(hcip证书含金量高吗)