# 3 Agents in UVM Env

**URL:** <https://verificationacademy.com/forums/t/3-agents-in-uvm-env/36832>\
**Category:** UVM\
**Tags:** UVM, multiple-agents\
**Created:** [November 21, 2019, 8:17pm UTC](https://verificationacademy.com/forums/t/3-agents-in-uvm-env/36832 "2019-11-21T20:17:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dvuvmsv](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/d/a4c791/32.png) [@dvuvmsv](https://verificationacademy.com/forums/u/dvuvmsv)\
**Post date:** [November 21, 2019, 8:17pm UTC](https://verificationacademy.com/forums/t/3-agents-in-uvm-env/36832/1 "2019-11-21T20:17:59Z")

</div>

Hello,

How do you implement this scenario in UVM Testbench ?

Assuming, UVM environment has 3 different agents having scope to their own interfaces.  
On driving wrong stimuli on agent1, there will be error pin asserted on interface3  
monitor of agent2 sees this). Soon after error-pin assertion, there should be a read transaction from agent2.  
How do you make sure your agent2 drives a read transaction on every wrong stimulus from agent1?

Need help from UVM Experts…

Thanks  
JeffD

---

<div class="post-metadata">

**Author:** ![kddholak](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/kddholak/32/1363_2.png) [@kddholak](https://verificationacademy.com/forums/u/kddholak)\
**Post date:** [November 21, 2019, 9:29pm UTC](https://verificationacademy.com/forums/t/3-agents-in-uvm-env/36832/2 "2019-11-21T21:29:38Z")

</div>

_In reply to [dvuvmsv](https://verificationacademy.com/forums/t/3-agents-in-uvm-env/36832):_  
if your agent2 is not implemented as reactive agent then you will have to add uvm\_event in monitor to generate the event(event.trigger()). and your sequence will be running in forever loop ,will be blocked by the event.wait\_trigger() function. whenever the sequence see the event it will automatically start executing read\_sequence on agent2

---

<div class="post-metadata">

**Author:** ![dvuvmsv](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/d/a4c791/32.png) [@dvuvmsv](https://verificationacademy.com/forums/u/dvuvmsv)\
**Post date:** [November 22, 2019, 12:49am UTC](https://verificationacademy.com/forums/t/3-agents-in-uvm-env/36832/3 "2019-11-22T00:49:47Z")

</div>

Thanks for your reply.  
I think in the agent2 monitor run\_phase, I should add the code to wait for the error on signal and create the event as you mentioned. I believe the agent2 driver should sample the event  
like env.agent2.mon.event.wait\_trigger() and start the read sequence.

If you can give an example code that would be great.

JeffD

---

<div class="post-metadata">

**Author:** ![kddholak](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/kddholak/32/1363_2.png) [@kddholak](https://verificationacademy.com/forums/u/kddholak)\
**Post date:** [November 22, 2019, 1:04am UTC](https://verificationacademy.com/forums/t/3-agents-in-uvm-env/36832/4 "2019-11-22T01:04:30Z")

</div>

_In reply to [dvuvmsv](https://verificationacademy.com/forums/t/3-agents-in-uvm-env/36832/3):_

```verilog

class monitor extends uvm_monitor 

uvm_event ev_read ;
virtual function void build_phase(uvm_phase phase);
  ev_read = uvm_event_pool::get_global("ev_read"); 
endfunction 

virtual task run_phase();
     forever begin 
      .......
      ev_read.trigger();
     end 
endtask 

endclass // monitor 

class sequence extends base_sequence ;
  uvm_event ev_read ;
   
function new (strint name);
  super.new(name);
  ev_read = uvm_event_pool::get_global("ev_read"); 
endfunction 
  
task body ();
    forever begin 
      ev_read.wait_trigger();
      // execute your sequence  
    end 
endtask 

endclass 

```
