Systemverilog 属性 或 (||) 的含义未按预期工作?
Systemverilog property implication with or (||) is not working as expected?
我正在尝试编写 sytemverilog 断言以确定时钟周期 (140MHz),任意 + 或 - 值为 0.001ns,在此 systemverilog 属性 中使用 "or" 运算符 (||) +/- deviations/changes 的时间段,但输出不符合预期,谁能解释这是什么原因?对于 clk_prd 的任何值,断言都会断言,这与预期不符,还请提及最佳解决方案是什么?
下面的代码片段,
module clock_gen();
timeunit 1ns;
timeprecision 100ps;
bit clk;
realtime clk_prd =1000/340.0ns; //2.9411764
//realtime clk_prd =1000/140.0ns; //7.1428571
property SVA_clk(real clk_prd);
time current_time;
(('1,current_time=$realtime) |=>
(clk_prd <= $realtime-(current_time - 0.001ns)) ||
(clk_prd >= $realtime-(current_time + 0.001ns)));
endproperty
assert_period:assert property (@(posedge clk)SVA_clk(clk_prd))
$display("clk pass : %0t ",$realtime);
else
$warning("clk fail : %0t",$realtime);
initial forever #7.1428 clk=!clk;
initial begin
repeat(15) @(posedge clk);
$finish;
end
endmodule : clock_gen
当前输出:
clk pass : 213
clk pass : 355
clk pass : 497
clk pass : 639
clk pass : 781
clk pass : 923
clk pass : 1065
clk pass : 1207
clk pass : 1349
clk pass : 1491
clk pass : 1633
clk pass : 1775
clk pass : 1917
预期产出
clk fail : 213
clk fail : 355
clk fail : 497
clk fail : 639
clk fail : 781
clk fail : 923
clk fail : 1065
clk fail : 1207
clk fail : 1349
clk fail : 1491
clk fail : 1633
clk fail : 1775
clk fail : 1917
(参考自 link)
你的代码有很多问题
- 对于编写的代码,
timeprecision
应该在 1ps
中
current_time
应声明为 realtime
- 你的时钟发生器周期是14.2,但你应该写成
#(7.1428ns/2)
- 您要么
+/-
逆转,要么 <=/>=
逆转。
我正在尝试编写 sytemverilog 断言以确定时钟周期 (140MHz),任意 + 或 - 值为 0.001ns,在此 systemverilog 属性 中使用 "or" 运算符 (||) +/- deviations/changes 的时间段,但输出不符合预期,谁能解释这是什么原因?对于 clk_prd 的任何值,断言都会断言,这与预期不符,还请提及最佳解决方案是什么?
下面的代码片段,
module clock_gen();
timeunit 1ns;
timeprecision 100ps;
bit clk;
realtime clk_prd =1000/340.0ns; //2.9411764
//realtime clk_prd =1000/140.0ns; //7.1428571
property SVA_clk(real clk_prd);
time current_time;
(('1,current_time=$realtime) |=>
(clk_prd <= $realtime-(current_time - 0.001ns)) ||
(clk_prd >= $realtime-(current_time + 0.001ns)));
endproperty
assert_period:assert property (@(posedge clk)SVA_clk(clk_prd))
$display("clk pass : %0t ",$realtime);
else
$warning("clk fail : %0t",$realtime);
initial forever #7.1428 clk=!clk;
initial begin
repeat(15) @(posedge clk);
$finish;
end
endmodule : clock_gen
当前输出:
clk pass : 213
clk pass : 355
clk pass : 497
clk pass : 639
clk pass : 781
clk pass : 923
clk pass : 1065
clk pass : 1207
clk pass : 1349
clk pass : 1491
clk pass : 1633
clk pass : 1775
clk pass : 1917
预期产出
clk fail : 213
clk fail : 355
clk fail : 497
clk fail : 639
clk fail : 781
clk fail : 923
clk fail : 1065
clk fail : 1207
clk fail : 1349
clk fail : 1491
clk fail : 1633
clk fail : 1775
clk fail : 1917
(参考自 link)
你的代码有很多问题
- 对于编写的代码,
timeprecision
应该在1ps
中 current_time
应声明为realtime
- 你的时钟发生器周期是14.2,但你应该写成
#(7.1428ns/2)
- 您要么
+/-
逆转,要么<=/>=
逆转。