UVM_EVENT from one agent to another?

Hi,

I have two agents in my testbench. The first is driving its interface and its monitor is issueing analysis transactions and events. The events are used in another agents driver to synchonize bus transactions on the second interface based on the first one.

I can’t use the transactions of the first agent because they are issued after the bus transaction. I need to have the second agents sycnhronized a bit earlier. So I want to use the events for this.

Can I generate uvm_events in the first agents monitor and wait for those events in the second agents driver?
I assume I need to use the global event pool. But I can’t find any code examples. Can someone be of any help?


Ok, I found that the event pool is local to the component.
So I defined a global event pool in the env and put the reference in the config objects of the two agents.

It seems that agent2 is picking up the same uvm_event as agent1 alright. Agent2 arrives at the wait_ptrigger() before agent1 triggers the event. But agent2 still doesn’t see the trigger.

Am I still doing something wrong?


class env ....
  ...
  function void build_phase ( ....
    ...
    uvm_event_pool evt_pool = uvm_event_pool :: get_global_pool();
    ...
    cfg_agent1.event_pool = evt_pool;
    ...
    cfg_agent2.event_pool = evt_pool;
    ...
  endfunction
  ...
endclass
    
class agent1_monitor ....
  ...
  function void build_phase ( ....
    ...
    // get the config object from the config_db
    m_config = ....
    ...
  endfunction

  task run_phase ( ....
    uvm_event some_event = m_config.event_pool.get("some_event");
    ...
    some_event.trigger();
    ...
  endtask
endclass

class agent2_driver ...
  ...
  function void build_phase ( ....
    ...
    // get the config object from the config_db
    m_config = ....
    ...
  endfunction

  task run_phase ( ...
    uvm_event some_event = m_config.event_pool.get("some_event");
    ...
    some_event.wait_ptrigger();
    ...
  endtask
endclass

Best regards,
Ronald

One argument I have against what you are trying to accomplish is that you break the basic tenet that agents are independent components with no reliance on any other component. By attempting to utilize event pools from outside the agent, you have created dependencies which will be difficult to resolve when reusing the agent.

I would recommend that you coordinate the agent sequences at the virtual sequence level. Sequences are bi-directional and can be utilized to pass data from the driver to the sequence as well as the sequence to the driver. By executing a sequence on one agent and getting the required response from that agent’s driver, you can then generate a sequence for the second agent based on that response.

In reply to cgales:

How would this mechanism be implemented?
Is it by using the pre_do callbacks in the sequences to start other sequences synchronized?