Can I trigger an event in one agent and after triggered, do something inside another agent?

1.I have agent A and agent B within a single environment.
2.When certain things happen inside agent A, an event E is triggered.
3.When E is triggered in agent A, agent B should do certain things.
Is there any way to do this in UVM ? If possible can anybody show me an example ?

Hi Ahmed,

You can use uvm_event and uvm_event_pool.

Agent 1
uvm_event_pool p1 = p1.get_global_pool();
uvm_event e1 = p1.get(“ABC”);
p1.trigger();

Agent 2:

uvm_event_pool p1 = p1.get_global_pool();
uvm_event e1 = p1.get(“ABC”);
p1.wait_trigger();
p1.reset();

Regards,
Chetan Shah

In reply to cashah85:

Hello Chetan
Thanks for your reply. I get error messages saying that “trigger is not a class item”, “wait_trigger() is not a class item”.

I have two more questions.
1.Can I do the same thing between two drivers(in different agents).

Driver 1
uvm_event_pool p1 = p1.get_global_pool();
uvm_event e1 = p1.get("ABC");
p1.trigger();

Driver 2:

uvm_event_pool p1 = p1.get_global_pool();
uvm_event e1 = p1.get("ABC");
p1.wait_trigger();
p1.reset();
  1. Where should I place these event declarations. I have seen in an example where event is declared in run_phase.

Thanks and Regards

In reply to Shakerin Ahmed:

Hi Ahmed,

You can refer below example for event declarations. You can use event in any task.

class agent1 extends uvm_agent
uvm_event XYZ

function void build_phase ( …

XYZ = uvm_event_pool :: get_global_pool(“XYZ”);

endfunction

task run_phase ( …

XYZ.trigger();

endtask
endclass

class agent2 extends uvm_agent
uvm_event XYZ

function void build_phase ( …

XYZ = uvm_event_pool :: get_global_pool("XYZ");
...
...

endfunction

task run_phase ( …
uvm_event some_event = m_config.event_pool.get(“some_event”);

XYZ.wait_ptrigger();

endtask
endclass

For question 1, Can you please tell me your requirement. If you want to pass transaction between two drivers, I recommend to use TLM port for synchronization.

Best Regards,
Chetan Shah
Sr. ASIC Verification Engineer

Product Engineering Services
Software | Embedded | Semiconductor
www.einfochips.com
Frost & Sullivan Company of the Year 2013-14

The problem with trying to use events between drivers is that you are now creating a dependency between drivers which prevents reuse, a cornerstone of a well designed UVM environment.

If you want to coordinate actions between agents, you should utilize virtual sequences.

In reply to cgales:

Thanks for your reply. Let me clarify what I am trying to do:

  1. I have two agents.agent A and agent B.
  2. Agent A has driver Ad and Sequencer As and sequence Ase.
  3. Agent B has driver Bd and Sequencer Bs and sequence Bse.
    4.When driver Ad gets the sequence items using get_sequence_item() few signals are driven through interface.
  4. Based on those driven signals, few other signals in Agent B has to be generated or driven.
  5. I was trying to do this using event_pool.

In reply to cashah85:

Hello Chetan
Thanks for your reply. I get the error message “E`TOOMAC”. That means there is some constructor problem with event or event_pool.
What I am trying to do is:
1. I have two agents.agent A and agent B.
2. Agent A has driver Ad and Sequencer As and sequence Ase.
3. Agent B has driver Bd and Sequencer Bs and sequence Bse.
4.When driver Ad gets the sequence items using get_sequence_item() few signals are driven through interface.
5. Based on those driven signals, few other signals in Agent B has to be generated or driven.
6. I was trying to do this using event_pool.
Do you think it is a good approach ?

Thanks

In reply to Shakerin Ahmed:

Hello Chetan
It is working now. What I have done her is:


Agent1 Driver:
class driver1 ......
uvm_event_pool p1;
uvm_event e1;

build_phase:
p1=uvm_event_pool::get_global_pool();
e1=p1.get("p1");

run_phase:
e1.trigger();



Agent2 Driver:
class driver2 ......
uvm_event_pool p1;
uvm_event e1;

build_phase:
p1=uvm_event_pool::get_global_pool();
e1=p1.get("p1");

run_phase:
e1.wait_trigger();

It seems to be working. But I want to know if it is a good practice to use event in such situation.
Regards

In reply to Shakerin Ahmed:

Hi,

As suggested by cgales on below comment, The problem with trying to use events between drivers is that you are now creating a dependency between drivers which prevents reuse, a cornerstone of a well designed UVM environment.

If you want to coordinate actions between agents, you should utilize virtual sequences.

I had gave the answer of your question and to achieve synchronization you can use uvm_event.

Best Regards,
Chetan Shah
Sr. ASIC Verification Engineer

Product Engineering Services
Software | Embedded | Semiconductor
www.einfochips.com
Frost & Sullivan Company of the Year 2013-14

In reply to cashah85:

Ok. Thanks.
I will try to implement same thing using virtual sequence now.
Regards

In reply to cgales:

Hi Cgales,

I am a beginner in UVM.

I am clear with the explanation you provided about the UVM events.

I have a question about virtual sequence, According to the UVM cook book page no :191 it is defined as:

"A virtual sequence is a sequence that can start sub-sequences on multiple sequencers. ".
To my knowledge, it runs multiple sequences on multiple sequencers parallely.

So, My question is How synchronization happens between agents by using Virtual sequence.

I mean , How actions between agents are coordinated using Virtual sequence.

Please, correct me If my understanding is wrong.

Thanks in advance
durga

In reply to durga:

The agents are synchronized by the virtual sequence sending sequence items to each agent’s sequencer as required. It will send an item to one agent, and when it completes, it will send an item to the other sequencer. Or, it can send an item to both agents to each sequencer at the same time. There are a lot of different ways you can do this depending on your requirements.

In reply to cgales:

Thank you cgales

In reply to cgales:

Hi,

Thank you cgales for the reply . I am clear with the explanation.

According to the UVM cookbook
There are two ways of running virtual sequence :

  1. Without Virtual Sequencer
  2. With Virtual Sequencer

Is there any advantage of running virtual sequence on Virtual Sequencer ? If Yes ?

What is the advantage of having a virtual sequencer in the environment ?

Thanks in advance
durga

In reply to durga:

There is no benefit using a virtual sequencer. There are 2 Options to reach the same goal, running a virtual sequence.