timescale的理解

来源:互联网 发布:网页翻译软件手机版 编辑:程序博客网 时间:2024/04/29 05:47

其实对于timescale的理解应该是最基础的要求。但是工作了这么多年,由于现在数字电路设计部分一般都要求designer不写timescale,不在design里面加delay。而验证平台又一直用UVM,在env里面都是统一用一个timescale,避免了很多timescale引起的麻烦,所以对这一部分概念有些淡化了。

以前接触PHY, DDR这些design里面基本都会有自己的timescale,所以造成了很多麻烦,虽然当时都迷迷糊糊解决了,最近又碰到这个问题,下决心把这个好好梳理一下。

在编译过程中,`timescale指令影响这一编译器指令后面所有模块中的时延值,直至遇到另一个`timescale指令或`resetall指令。
这里要特别注意,timescale的作用域以编译顺序来的,而不是instance 层次结构。
例如:


timescale_a和timescale_b的timescale 分别是10ps/1ps,  1ps/1ps,同样的initial。
1.如果编译顺序为timescale_a, timescale_b, timescale_top,我们会发现最终的结果是:
t_a.a在50ps拉起,t_b.a在5ps拉起,top.a在5ns拉起。
2.如果在1的基础上,注释掉timescale_b的timescale,发现timesclae_b的行为为timescale_a的一样,而不是instrance他的top一样。
3.在2基础上,我们把编译顺序换为timescale_a, timescale_top, timescale_b,我们会发现,timescale_b的行为和to一样了

模拟器总是定位在所有模块的最小时延精度上,并且所有时延都相应地换算为最小时延精度
这里要注意,只是把单位换算成了最小时间精度,但每个模块的时间精度是不会变的。比如在top时的最小精度是1ns, b延迟了工0.1ns,虽然前面最小时间精度已经变成了1ps,但是他在自己的作用域内已经超过了自己的精度,所以0.1ns变成了0ns再换算成了000ps


timeformat
$timeformat [ ( units_number , precision_number , suffix_string ,minimum_field_width ) ] ;
关于第一个参数和第三个参数:真正控制时间单位的是units_number,而suffix_string只是说数据后面跟的字符。
比如$timeformat(-9,5,"ns",10),  和
$timeformat(-9,5,"ps",10),  比如同样的#5ns.
前者打印结果是5.00000ns,后者结果是5.00000ps,  其实后者的单位是错了的,因为他打印出的是你给的那个"ps"字符。

$timeforma一般t只是用来控制打印时间的单位,而不是去影响整个的仿真的时间单位和精度
The $timeformat system task performs the following two functions:
— It specifies how the %t format specification reports time information for the $write, $display,
$strobe, $monitor, $fwrite, $fdisplay, $fstrobe, and $fmonitor group of system tasks.
—It sets the time unit for all later-entered delays entered interactively(不太明白,不过确实通过实验发现,他没办法改timescale定义的时间单位)

1 0
原创粉丝点击