EVENT trigger WAIT()

module event_m; 
event a; 

initial 
repeat(4) 
#20 -> a; 


always 
begin 
@a; 
$display(" ONE :: EVENT A is triggered "); 
end 

always 
begin 
wait(a.triggered); 
$display(" TWO :: EVENT A is triggered "); 

end 
endmodule 

after run
ONE :: EVENT A is triggered
TWO :: EVENT A is triggered
TWO :: EVENT A is triggered
TWO :: EVENT A is triggered
TWO :: EVENT A is triggered
TWO :: EVENT A is triggered



TWO :: EVENT A is triggered
Result reached the maximum of 5000 lines. Killing process.
Execution interrupted or reached maximum runtime.

why it is so? what is the remedy

In reply to suresh M:

Because your second always block becomes an infinite loop once
a.triggered
becomes true. There is no way for time to advance to allow it to go false. You would have the same problem if you waited for any expression to become true. You need some kind of delay or blocking statement to allow time to advance so you are not repeatedly seeing that it is still true.

always
begin
wait(a.triggered);
$display(" TWO :: EVENT A is triggered ");
wait(!a.triggered); // #1; would also work.
end

In reply to dave_59:

HI Dave,
I am trying to do this

class event_holder;
   event class_e;

   function new();
      $display(" pre trigger.");      
      ->$root.top.top_e;    //or even just ->top.top_e;
      $display(" post trigger.");      
   endfunction
endclass : event_holder


module top;
   event top_e;

   initial begin
      event_holder m_event_holder;
      $display(" Start ** ** **.");
      #1;  //B1
      m_event_holder=new();      
      #55;
      //->top_e;
   end

but in my module i am not able to see event getting triggered.
as i am triggereing event in class and waiting for it to occur in module so that i can assert a property but i am getting no_event_triggered error
can you please help.

In reply to dave_59:

In reply to suresh M:
Because your second always block becomes an infinite loop once
a.triggered
becomes true. There is no way for time to advance to allow it to go false. You would have the same problem if you waited for any expression to become true. You need some kind of delay or blocking statement to allow time to advance so you are not repeatedly seeing that it is still true.
always
begin
wait(a.triggered);
$display(" TWO :: EVENT A is triggered ");
wait(!a.triggered); // #1; would also work.
end

Why not just this?


    always begin
        @ (a);
        $display(" TWO :: EVENT A is triggered ");
    end 

In reply to #veriflearner:

Your code does not show what is eating for an event. You also do not show which line the error is pointing to.

In reply to dhrogoff:

That is exactly what always block ONE was doing. They wanted to know what was wrong with the way always block TWO was coded.

In reply to dave_59:

In reply to dhrogoff:
That is exactly what always block ONE was doing. They wanted to know what was wrong with the way always block TWO was coded.

OK - I see that now. He just wanted to know how to do it in a more complicated way :)

In reply to dave_59:

Hi Dave,

wait(!a.triggered); // #1; would also work.

#1step should help here? #1 means next timeunit(which could be lot more than 1 timestamp delay), I assume #1step would mean next timestamp.
Issue with wait(!a.triggered); could be if next timestamp has event getting triggered.

Thanks,
Kavish

In reply to shahkavish77:

Adding a delay in the loop creates horrible performing code. The use of 1step as a procedural delay is not recommend.