$time $stime $realtime
1,$time
The $time system function returns an integer that is a 64-bit time, scaled to the timescale unit of the module that invoked it.
1 `timescale 10 ns / 1 ns 2 module test; 3 reg set; 4 parameter p = 1.55; 5 initial begin 6 $monitor($time,,"set=",set); 7 #p set = 0; 8 #p set = 1; 9 end 10 endmodule
结果:
0 set=x 2 set=0 3 set=1 V C S S i m u l a t i o n R e p o r t Time: 32 ns
分析:
a) The simulation times 16 ns and 32 ns are scaled to 1.6 and 3.2 because the time unit for the module is 10 ns; therefore, time values reported by this module are multiples of 10 ns.
b) The value 1.6 is rounded to 2, and 3.2 is rounded to 3 because the $time system function returns an integer. The time precision does not cause rounding of these values
因为精度是1ns,1.55*10=15.5ns,四舍五入,取16ns
假如将精度设置为
`timescale 10 ns / 1ps 那么,结果将是15.5和31
2,$stime
The $stime system function returns an unsigned integer that is a 32-bit time, scaled to the timescale unit of the module that invoked it. If the actual simulation time does not fit in 32 bits, the low order 32 bits of the current simulation time are returned.
对于$time的example,$stime和$time是一样的。
3,$realtime
The $realtime system function returns a real number time that, like $time, is scaled to the time unit of the module that invoked it.
将上述example改为$realtime之后,结果如下所示:
0 set=x 1.6 set=0 3.2 set=1 V C S S i m u l a t i o n R e p o r t Time: 32 ns
其他运行结果相同
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)