In reply to Farhad:
When used with the @ construct, @(event_name) and @(event_name.triggered()) have the same behavior in certain cases. But saying they are equivalent is misleading. It’s like saying the expression (1’b1) is equivalent to expression ('h139295 < 'h139395), but why would I ever want to write the latter if I just meant to write 1’b1.
A named event is a valueless variable that generates an event using the → or ->> operators. An event control construct @() blocks the current process until a generated named event, or the change of the value of any expression.
The triggered() method of an event variable is a function that returns 1’b1 or 1’b0 as Ben explains. When you put any expression in an event control, that expression gets evaluated whenever any operand changes, and if the expression changes value, the event control resumes the process. When using @(event_name.triggered), the generated event causes the triggered() method to get evaluated. The first time this happens in a time step, the value of the expression changes from 1’b0 to 1’b1. But the second time, there is no change. Note that the event control never sees the change of the triggered() result going from 1’b1 to 1’b0 because there is no operand changing to cause reevaluation of the expression.
Try this little example:
module top;
event event_name;
initial begin
#10
-> event_name;
->>event_name; // race condition if I just used ->
#10
-> event_name;
->>event_name; // race condition if I just used ->
end
always @(event_name) $display($time,,"@(event_name)");
always @(event_name.triggered) $display($time,,"@(event_name.triggered)");
endmodule