Associative array of event

Hi all,

module
  initial begin
    event event_aa[int];
    event e1;
        
    fork
      begin
        #10ns;
        event_aa[1] = e1;
      end
      forever begin
         #1ns;
         $display("xxx %0d", event_aa.num());
      end
      begin
        wait(event_aa.num() != 0);
        $display("yyy %0d", event_aa.num());
      end
    join_any
    #10ns;
    $finish;
  end
endmodule

When I used the code snippet above, I found that the wait method is not triggered, but when I printed the output, I saw that event_aa.num() was equal to 1 at 10 ns. Why? The same situation applies to queues as well.

However, when I change the storage type to something else, such as int, everything goes back to normal (wait is triggered).

BR

You’ve encountered a tool-specific issue. This code works correctly on one tool on edaplayground.com, but it fails to compile on another. In SystemVerilog, assignments to event variables are handled in a unique way. The LRM explains that they merge the variables instead of actually writing a handle to a variable. The expression inside a wait statement is supposed to wake up and get evaluated whenever a write to an array occurs. However, since the LRM didn’t use the word “write”, it might be ambiguous here.