Search code examples
eventssystem-veriloguvm

Wait trigger data only catching the first event


I am using OVM

My code is triggering an ovm event in one place (I added a print to confirm). However, in another place I'm waiting for that trigger and it's only "caught" once (also here I added a print to confirm).

function void trigger_event_for_incoming_transaction(ovm_object txn);
    if (is_type_1(txn))
      type_1.trigger(txn);            
endfunction

And somewhere else:

    task look_for_type_1();    
      forever begin
        type_1.wait_trigger_data(my_obj);
      end
    endtask

I can't paste most of the code due to intelucatal property... But I registered event properly etc.


Solution

  • OVM/UVM's trigger and wait_trigger works the same as SystemVerilog's event trigger ->e and event control @e—the event control has to block waiting for the trigger before executing the trigger. You can use the triggered method of an event in wait(e.triggered()) which returns true from the point when the triggered until the end of the time step. Then the ordering between the trigger and the event control within the time step no longer matters; a persistent trigger.

    You can try using OVM's wait_ptrigger_data which uses this triggered method underneath.