为什么我会得到如下所示的结果?我期望多次触发update_ev事件应该会导致显示“Main Loop,..”被执行两次。但它只执行一次。Systemverilog - 多个进程触发相同的事件
program multiple_trigger();
initial begin
event update_ev;
bit orResult, prev_orResult, A, B;
// Multiple trigg logic
fork
begin : threadDisplay
forever begin
prev_orResult = orResult;
// Update status
@(update_ev);
// Compute A OR B
orResult = A | B;
$display("\n Main Loop , %0t A=%0b, B=%0b orResult=%0b",$time(), A, B, orResult);
if (prev_orResult != orResult) begin
$display("\n In the IF condition, %0t A=%0b, B=%0b orResult=%0b",$time(), A, B, orResult);
end
end // forever
end : threadDisplay
// 10 A=0
begin : threadA
#10;
A = 1'b0;
->update_ev;
end : threadA
// 10 B=1'b1
begin : threadB
#10;
B = 1'b1;
->update_ev;
end : threadB
join_none
#100;
end
endprogram
// Actual Result----------------------------------------
Main Loop , 10 A=0, B=1 orResult=1
In the IF condition , 10 A=0, B=1 orResult=1
//-----------------------------------------------------
// Expected Result----------------------------------------
Main Loop , 10 A=0, B=0 orResult=0
Main Loop , 10 A=0, B=1 orResult=1
In the IF condition , 10 A=0, B=1 orResult=1
// -------------------------------------------------------
HI Greg,谢谢你的回复。我打算在我的验证环境中使用它。假设解决多个进程(thread_A,thread_B ....)的目的,试图通知一个听力进程(disp_thread)关于共享变量的一些变化。听证过程应该决定,与线程执行的顺序无关,最终结果与前一个结果相同或不同。你认为 - >>应该解决目的吗? –
' - >>'应该在这种情况下工作。另一个选择是在@(update_ev)之后放一点点延迟;假设是否有一点延迟是可以接受的。 – Greg
我永远不会建议在测试台中放一点点延迟。一旦你开始在整个地方推迟延迟来定义排序,你可以结束事情变得难以管理。 –