//`timescale 10ps/1fs
module time_presion();
timeunit 100ps/10ps; //If We change this to 100ns/10ps it works fine
parameter p=11.49;
int a;
initial begin
$monitor("%t ,My values Changes %d",$time,a);
#p a = 10;
#p a = 30;
#p a = 40;
//#100us;
#p a = 50;
#1 $finish(1);
end
endmodule
Run Code Online (Sandbox Code Playgroud)
当我运行此代码时,我得到错误
file: time_prcision.sv
timeunit 100ps/10ps;
|
ncvlog: *E,TUSERR (time_prcision.sv,4|11): timeunit is smaller than the specified time precision [IEEE Std 1800-2009].
module worklib.time_presion:sv
errors: 1, warnings: 0
Run Code Online (Sandbox Code Playgroud)
如果我将时间单位更改为100ns/10ps,那么代码可以正确运行上面代码中的错误
从SystemVerilog LRM 1800-2012,第3.14.2.2节:
时间单位和精度可以分别由timeunit和timeprecision关键字声明,并设置为时间字面值(见5.8).
行timeunit 100ps/10ps;定义了时间单元中的电流的模块,程序,包或接口,本地.
如果指定,则timeunit和timeprecision声明应位于当前时间范围内的任何其他项之前.
的时间单位是说,当你给#1延迟(例如),其延迟的单元.如果我们选择100ps时间单位,那么提供#1延迟将导致100ps延迟.
在时间精度告诉最小的 延迟,你可以在给定的时间单元配置.精度表示相对于时间单位使用的精度小数点数.例如:
timescale 100ps/10ps shall have a #1 delay of 100ps
while you can give #0.1 as the smallest delay i.e. of 10ps.
timescale 1ns/1ps shall have `#1` as 1ns and `#0.001`
as 1ps as the smallest delay.
Run Code Online (Sandbox Code Playgroud)
在代码中,timescale 10ps/1fs应代表#1的10马力延迟,#0.0001是最小可测量的延迟.现在,出现错误:
timeunit is smaller than the specified time precision
Run Code Online (Sandbox Code Playgroud)
直觉上,可以说时间单位决不能小于时间精度.这在上述错误中说明.
时间刻度100ps/10ps应在小数点后一位舍入每个延迟.提供11.49应四舍五入到11.5并乘以时间精度然后显示.
简而言之,使用timescale 1ns/1ps延迟被解释为以纳秒为单位,并且任何分数都被舍入到最接近的皮秒.我$realtime在display语句中使用,输出如下.显示115是由于时间(time*timeunit/timeprecision)格式的默认时间缩放.
0 ,My values Changes 0
115 ,My values Changes 10
230 ,My values Changes 30
345 ,My values Changes 40
460 ,My values Changes 50
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请参阅timeunit,时间单位和时间精度之间的差异以及时间尺度教程链接.
| 归档时间: |
|
| 查看次数: |
13711 次 |
| 最近记录: |