FPGA学习笔记:面向验证和仿真的行为描述语句(1)
来源:互联网 发布:万达成本优化流程图 编辑:程序博客网 时间:2024/06/06 04:13
面向验证和仿真的行为描述语句:
1、延时控制语句
(1)语法格式:#<延迟时间> 行为语句 OR #<延迟时间>
其中“#”是延时控制的关键字符,“<延迟时间>”以多个仿真时间单位的形式给出。
使用编译指令将时间单位与物理时间相关联,编译指令需要在模块描述前定义:timescale 1ns /100ps(延迟时间为1ns,时间精度为0.1ns)
(2)实际的仿真中,延时控制语句可以出现在任何赋值语句中,主要有三类:
#<延迟时间常量> 行为语句
仿真进程遇到这条语句后,并不会立即执行行为语句制定的操作,而是要等到<延迟时间值>所指定的时间过去后,才开始执行行为语句的操作。比如:
'timescale 1ns /1psmodule delay_demo1(q0_out,q1_out,q2_out);output [7:0] q0_out,q1_out,q2_out;reg [7:0] q0_out,q1_out,q2_out;initial begin q0_out=0; //循环体 repeat(100) begin #5 q0_out=1;//延迟语句1 #5 q0_out=2;//延迟语句2 end endinitial fork //循环体2 repeat(100) begin # 5 q1_out=3;//延迟语句3 # 5 q1_out=4;//延迟语句4 end //循环体3 repeat(100) begin # 5 q2_out=5;//延迟语句5 # 5 q2_out=6;//延迟语句6 end joinendmodule
注:三个循环体同时并行执行。
#<延迟时间常量> 行为语句
仿真进程遇到该语句后,也不进行任何操作,而是进入等待状态,等过了延迟时间后,再继续执行后续语句。并行fork…join语句块和串行begin…end语句块进入仿真等待状态的影响是不同的,因此各自产生的作用也不同。比如:
'timescale 1ns/1psmodule delay_demo2(q0_out,q1_out);output [7:0] q0_out,q1_out;reg [7:0] q0_out,q1_out;initial begin q0_out=0; #100 q0_out=1; #100; #100 q0_out=10; #300 q0_out=20; endinitial fork q1_out=0; #100 q1_out=1; #100; #200 q1_out=10; #300 q1_out=20; joinendmodule
注:注意串/并行执行的区别。
#<延迟表达式> 行为语句
延迟时间是一个变量或者表达式,极大地增强了仿真程序的可移植性。如果对应的值出现负值或者“x”、“z”等,将其按照0来处理。比如:
'timescale 1ns/1psmodule delay_demo3(q0_out,q1_out);output [7:0] q0_out,q1_out;reg [7:0] q0_out,q1_out;parameter delay_time=100;initial begin q0_out=0; #delay_time q0_out=1; #(delay_time/2); #(delay_time*2) q0_out=10; #300 q0_out=20; endinitial begin q1_out=0; #100; #(delay_time-5'bxxxxx) q1_out=1; #100; #100 q1_out=10; #50; #(delay_time-200) q1_out=20; endendmodule
注:仿真验证通过ModelSim仿真工具。
阅读全文
0 0
- FPGA学习笔记:面向验证和仿真的行为描述语句(1)
- FPGA学习笔记:面向验证和仿真的行为描述语句(2)
- FPGA学习笔记:面向验证和仿真的行为描述语句(3)
- xilinx fpga 学习笔记6:行为仿真
- Verilog HDL常用的行为仿真描述语句(一)
- Verilog HDL常用的行为仿真描述语句(二)
- Verilog HDL常用的行为仿真描述语句(三)
- Verilog HDL常用的行为仿真描述语句(四)
- Verilog HDL常用的行为仿真描述语句(五)
- Verilog HDL常用的行为仿真描述语句(六)
- Verilog HDL常用的行为仿真描述语句
- FPGA编程基础(二)--常用行为仿真描述
- FPGA仿真--前仿真和后仿真
- FPGA仿真--前仿真和后仿真
- FPGA学习笔记 Verilog HDL语句(基础)
- FPGA学习笔记1
- FPGA学习(第8节)-Verilog设计电路的时序要点及时序仿真
- FPGA开发之modelsim和ISE的联合仿真
- 机器学习实战笔记(一):KNN
- FINEBI迁移几点注意事项
- javascript的e.keycode对应键盘值大全
- 矩阵覆盖问题
- 个人网站选择支付宝api
- FPGA学习笔记:面向验证和仿真的行为描述语句(1)
- hdu 5813 Elegant Construction 贪心构造
- maven读取环境变量
- 请求重定向与请求转发
- struts2标签和jstl标签混合使用
- 线段树:扫面线专题
- 删除子串——KMP
- 关于jboss log4j如何编程添加自定义的日志输出
- python机器学习(1:K_means聚类算法)