亿迅智能制造网
工业4.0先进制造技术信息网站!
首页 | 制造技术 | 制造设备 | 工业物联网 | 工业材料 | 设备保养维修 | 工业编程 |
home  MfgRobots >> 亿迅智能制造网 >  >> Industrial programming >> Verilog

掌握 Verilog $timeformat:精度控制与显示格式化

Verilog `timescale 指令指定仿真时间单位和精度。

Verilog $timeformat 系统函数控制显示语句(如 $display、$strobe)中 %t 格式说明符的报告风格。

语法

 $timeformat(<unit_number>, <precision>, <suffix_string>, <minimum field width>); 
单位编号时间单位
-31ms
-61us
-91ns
-121ps
-151fs

示例 1:1ns/1ps

展示 $timeformat 如何影响时间单位显示格式。

 `timescale 1ns/1ps module tb; bit a; initial begin #10.512351; $display("[T=%0t] a=%0b", $realtime, a); $timeformat(-9, 2, " ns"); $display("[T=%0t] a=%0b", $realtime, a); $timeformat(-9, 5, "ns"); $display("[T=%0t] a=%0b", $realtime, a); $timeformat(-12, 3, " ns"); $display("[T=%0t] a=%0b", $realtime, a); $timeformat(-12, 2, " ps"); $display("[T=%0t] a=%0b", $realtime, a); end endmodule 

仿真日志

 xcelium> run [T=10512] a=0 [T=10.51 ns] a=0 [T=10.51200ns] a=0 [T=10512.000 ns] a=0 [T=10512.00 ps] a=0 xmsim: *W,RNQUIE: Simulation is complete. 

示例 2:1ns/100ps

同上例,仅 timescale 改为 1ns/100ps。

 `timescale 1ns/100ps 

仿真日志

 xcelium> run [T=105] a=0 [T=10.50 ns] a=0 [T=10.50000ns] a=0 [T=10500.000 ns] a=0 [T=10500.00 ps] a=0 xmsim: *W,RNQUIE: Simulation is complete. 

示例 3:100ns/1ns

 `timescale 100ns/1ns 

#1 代表 100ns,故 #10 得 1000ns。

仿真日志

 xcelium> run [T=1051] a=0 [T=1051.00 ns] a=0 [T=1051.00000ns] a=0 [T=1051000.000 ns] a=0 [T=1051000.00 ps] a=0 xmsim: *W,RNQUIE: Simulation is complete. 

Verilog

  1. Verilog 入门:数字电路设计完整教程
  2. 掌握 Verilog 拼接操作:实用指南
  3. 深入理解 Verilog 赋值语句:类型、语法与最佳实践
  4. Verilog阻塞与非阻塞赋值:关键区别详解
  5. 掌握Verilog函数:高效RTL设计的复用利器
  6. 理解Verilog任务:函数vs任务、语法与用法全解析
  7. Verilog 门级设计实战:与/或/非门与 2x1 多路选择器
  8. Verilog 时钟发生器设计与实现指南
  9. 掌握 Verilog 数学函数:高效硬件设计的利器
  10. 理解与打印 Verilog 任意作用域下的 Timescale
  11. 掌握 Verilog 文件 I/O:打开、读取、写入和关闭
  12. Verilog 入门指南:Hello World 示例