(筆記) 如何使用$width? (SOC) (Verilog)
Abstract
$width是Verilog所提供的專門用來做timing check的system task,可以檢查一個edge transition到另外一個相反的edge transition的時間長度是否符合規格需求,若pulse width小於我們所指定的需求,將產生violation warning。
Introduction
使用環境:NC-Verilog 5.4 + Debussy 5.4
如下圖所示,若pulse width小於limit時,將產生violation warning。
Testbench
width_tb.v / Verilog
1 /*
2 (C) OOMusou 2009 http://oomusou.cnblogs.com
3
4 Filename : width_tb.v
5 Compiler : NC-Verilog 5.4 + debussy 5.4
6 Description : $width demo
7 Release : 07/15/2009 1.0
8 */
9
10 `timescale 1ns/1ns
11
12 module width_tb;
13
14 reg reg_a;
15 wire wire_a;
16
17 assign wire_a = reg_a;
18
19 initial begin
20 $fsdbDumpfile("width_tb.fsdb");
21 $fsdbDumpvars(0, width_tb);
22 #50;
23 $finish;
24 end
25
26 initial begin
27 reg_a = 1'b0;
28 #10;
29 reg_a = 1'b1;
30 #5;
31 reg_a = 1'b0;
32 end
33
34 specify
35 $width(posedge wire_a, 6); /* 4 is ok */
36 endspecify
37
38 endmodule
2 (C) OOMusou 2009 http://oomusou.cnblogs.com
3
4 Filename : width_tb.v
5 Compiler : NC-Verilog 5.4 + debussy 5.4
6 Description : $width demo
7 Release : 07/15/2009 1.0
8 */
9
10 `timescale 1ns/1ns
11
12 module width_tb;
13
14 reg reg_a;
15 wire wire_a;
16
17 assign wire_a = reg_a;
18
19 initial begin
20 $fsdbDumpfile("width_tb.fsdb");
21 $fsdbDumpvars(0, width_tb);
22 #50;
23 $finish;
24 end
25
26 initial begin
27 reg_a = 1'b0;
28 #10;
29 reg_a = 1'b1;
30 #5;
31 reg_a = 1'b0;
32 end
33
34 specify
35 $width(posedge wire_a, 6); /* 4 is ok */
36 endspecify
37
38 endmodule
NC-Verilog產生Timing violation的warning
pulse width為5 ns
29行
reg_a = 1'b1;
#5;
#5;
故意產生pulse width為5ns的波形
34行
specify
$width(posedge wire_a, 6); /* 4 is ok */
endspecify
$width(posedge wire_a, 6); /* 4 is ok */
endspecify
使用$width檢察timing,以上表示從posedge wire_a開始檢察,若pulse width小於6,將產生timing violation warning。此外,Verilog規定timing check類的system task,一定要放在specify block內。
完整程式碼下載
s_width.7z
Reference
Verilog延時specify
Cadence NC-Verilog Simulator Help
See Also
(筆記) 如何使用$skew? (SOC) (Verilog)