首页 > 代码库 > systemverilog中event使用方法
systemverilog中event使用方法
event是静态对象,通过"->"操作符触发,进程总是等待一个"@"操作符的事件被触发。"@"操作符是边沿敏感。
initial begin
$display("@ %0t: 1 :before trigger",$time);
->e1;
@e2;
$display("@ %0t: 1 :after trigger",$time);
end
initial begin
$display("@ %0t: 2 :before trigger",$time);
->e2;
@e1;
$display("@ %0t: 2 :after trigger",$time);
end
输出结果:
# @ 0: 1 :before trigger
# @ 0: 2 :before trigger
# @ 0: 1 :after trigger
原因:->e1是一个零脉冲,第二个线程会错过而被锁住
使用wait(.triggered());
initial begin
$display("@ %0t: 1 :before trigger",$time);
->e1;
wait(e2.triggered());
$display("@ %0t: 1 :after trigger",$time);
end
initial begin
$display("@ %0t: 2 :before trigger",$time);
->e2;
wait(e1.triggered());
$display("@ %0t: 2 :after trigger",$time);
end
结果:
# @ 0: 1 :before trigger
# @ 0: 2 :before trigger
# @ 0: 2 :after trigger
# @ 0: 1 :after trigger
原因:wait()是电平敏感
systemverilog中event使用方法