When we write Verilog code that takes multiple events in one always block, the code is like Code0, shown below. I want to do the same thing in SystemVerilog using named events and tried to write “Code1”. Are there any problems in “Code1”? ( It worked as expected, but I do not have confidence in the code because I could not find such examples in LRM nor google search…)
In code1, the forever loop is blocked by multiple events(ev_001 and ev_002), and when unblocked, the different operation takes place depending on the triggered event.
[Code0(Verilog)]
bit ev_001, ev_002;
always @(ev_001 or ev_002) begin
if(ev_01)
out = 1;
if(ev_02)
out = 2;
end
[Code1(SystemVerilog)]
module tb();
event ev_001;
event ev_002;
initial begin
forever begin
@(ev_001 or ev_002);
if(ev_001.triggered)
$display("001 event triggered @%t", $time);
if(ev_002.triggered)
$display("002 event triggered @%t", $time);
end
end
endmodule
Regards