# Sending data from monitor to sequence

**URL:** <https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417>\
**Category:** UVM\
**Tags:** UVM\
**Created:** [December 5, 2018, 8:37am UTC](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417 "2018-12-05T08:37:41Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![SV\_UVM\_Learner1](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@SV\_UVM\_Learner1](https://verificationacademy.com/forums/u/SV_UVM_Learner1)\
**Post date:** [December 5, 2018, 8:37am UTC](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417/1 "2018-12-05T08:37:41Z")

</div>

Hi,

I’ve two agents in a ENV. one agent is active and another agent is passive. I need to send transactions captured in passive agent’s monitor to Active agent’s sequence, such that active agent’s driver need to drive the next stimulus accordingly.  
I know that via peek method and p\_sequencer, it’s possible to send transactions from one agent’s monitor to that corresponding agent’s sequence.  
But, in my case, I need to send transactions from one agent’s monitor to another agent’s sequence !!  
Please let me know, how to approach in this scenario.

---

<div class="post-metadata">

**Author:** ![tfitz](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/tfitz/32/3025_2.png) [@tfitz](https://verificationacademy.com/forums/u/tfitz)\
**Post date:** [December 5, 2018, 4:29pm UTC](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417/2 "2018-12-05T16:29:38Z")

</div>

_In reply to [nani9483](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417):_

Use the analysis\_port of the monitor to send the transaction(s) to another uvm\_subscriber - probably with a tlm\_fifo in it. If you build a get\_port into it (or whatever meets your needs), then you just have to pass that handle to your sequence.

---

<div class="post-metadata">

**Author:** ![SV\_UVM\_Learner1](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@SV\_UVM\_Learner1](https://verificationacademy.com/forums/u/SV_UVM_Learner1)\
**Post date:** [December 6, 2018, 5:27am UTC](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417/3 "2018-12-06T05:27:14Z")

</div>

Hi tfitz,

Thanks a lot for your quick response.  
uvm\_subscriber should be visible to both agents. So, obviously that uvm\_subscriber should be in my ENV, which is having my two agents. Am I correct ??

---

<div class="post-metadata">

**Author:** ![SV\_UVM\_Learner1](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@SV\_UVM\_Learner1](https://verificationacademy.com/forums/u/SV_UVM_Learner1)\
**Post date:** [December 6, 2018, 6:11am UTC](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417/4 "2018-12-06T06:11:30Z")

</div>

Hi tfitz,

Please let me know the syntax for passing tlm fifio handle to sequence.

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [December 6, 2018, 7:42am UTC](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417/5 "2018-12-06T07:42:44Z")

</div>

_In reply to [nani9483](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417/4):_

> Hi,  
> I’ve two agents in a ENV. one agent is active and another agent is passive. I need to send transactions captured in passive agent’s monitor to Active agent’s sequence, such that active agent’s driver need to drive the next stimulus accordingly.  
> I know that via peek method and p\_sequencer, it’s possible to send transactions from one agent’s monitor to that corresponding agent’s sequence.  
> But, in my case, I need to send transactions from one agent’s monitor to another agent’s sequence !!  
> Please let me know, how to approach in this scenario.

For me it is not clear why you need the 2 agents. Are they connected to the same virtual interface.  
There is an easy way to pass responses back from the driver to the sequence you are just executing using item\_done(rsp). In the sequence you have to execute get\_response to retrive the sequnce from the seuqnce fifo.

---

<div class="post-metadata">

**Author:** ![SV\_UVM\_Learner1](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@SV\_UVM\_Learner1](https://verificationacademy.com/forums/u/SV_UVM_Learner1)\
**Post date:** [December 6, 2018, 8:56am UTC](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417/6 "2018-12-06T08:56:12Z")

</div>

Hi chr\_sue,

Two agents are connected to two different virtual interfaces.  
Please let me know the syntax for passing handle from tlm fifo to uvm\_sequence, as tfitz said.

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [December 6, 2018, 9:09am UTC](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417/7 "2018-12-06T09:09:01Z")

</div>

_In reply to [nani9483](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417/6):_

I believe your story might be more complicated than you are saying. If you need such a cross connection then you have to synchronize the agents in some way. Right?

---

<div class="post-metadata">

**Author:** ![SV\_UVM\_Learner1](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@SV\_UVM\_Learner1](https://verificationacademy.com/forums/u/SV_UVM_Learner1)\
**Post date:** [December 6, 2018, 9:30am UTC](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417/8 "2018-12-06T09:30:50Z")

</div>

Yes chr\_sue. We need to synchronize the two agents. I want the data collected in passive agent monitor in my active\_agent’s sequence (as discussed in my first question) and also in active\_agent’s monitor. Please suggest a good plan to achieve this scenario.

---

<div class="post-metadata">

**Author:** ![tfitz](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/tfitz/32/3025_2.png) [@tfitz](https://verificationacademy.com/forums/u/tfitz)\
**Post date:** [December 6, 2018, 2:38pm UTC](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417/9 "2018-12-06T14:38:15Z")

</div>

First, I’ll answer your question to me. Then I’ll comment on the other responses.  
Assuming you build a subscriber with a tlm\_fifo or [analysis\_fifo](https://verificationacademy.com/cookbook/analysisport) in it (actually, an analysis\_fifo may be all you need), then you simply declare a get\_port with the appropriate type parameter in your sequence. Then, after creating the instance of your sequence, you assign its get\_port to the analysis\_fifo.get\_port and then your sequence can call get\_port.get() to get the transaction out of the fifo.

There is still the question of synchronization. Assuming that each transaction being driven depends on a transaction being received, then you can use a fifo of depth one. Except for the first transaction being driven, of course.

I think a better explanation of why you think you need such a setup would be helpful. There may be better ways of accomplishing what you think you need.

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [December 7, 2018, 10:11am UTC](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417/10 "2018-12-07T10:11:30Z")

</div>

_In reply to [nani9483](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417/9):_

> Yes chr\_sue. We need to synchronize the two agents. I want the data collected in passive agent monitor in my active\_agent’s sequence (as discussed in my first question) and also in active\_agent’s monitor. Please suggest a good plan to achieve this scenario.

If you really need to send data from 1 agent to another one you could use the uvm\_event\_pool and passing the constraints along with the trigger.

---

<div class="post-metadata">

**Author:** ![SV\_UVM\_Learner1](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@SV\_UVM\_Learner1](https://verificationacademy.com/forums/u/SV_UVM_Learner1)\
**Post date:** [December 8, 2018, 6:41am UTC](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417/11 "2018-12-08T06:41:58Z")

</div>

Hi chr\_sue and Tfitz,

As per your inputs, how to pass data using uvm\_event\_pool and how to get that data using uvm\_event\_pool ??

If this happens means, I’ll pass the data in my passive agent using uvm\_event\_pool.  
I’ll get that data in my active agent’s sequence and also in my active agent’s monitor.

Please let me know the syntax for passing and getting data using uvm\_event\_pool.

Thanks.

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [December 8, 2018, 12:35pm UTC](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417/12 "2018-12-08T12:35:18Z")

</div>

_In reply to [nani9483](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417/11):_

Please try this.  
In your monitor:

```verilog
class monitor extends uvm_monitor;
  my_transaction req;
  uvm_event_pool ev_pool = uvm_event_pool::get_global_pool();
  ...
  task run_phase(uvm_phase phase);
    req = my_transaction::type_id::create("req");
    req.<data_members>; //assemble your transaction

    uvm_event ev = ev_pool.get("mon_ev");
    ev.trigger(req);
   .....
  endtask
endclass

```

In your sequence:

```verilog
class my_sequence extends uvm_sequence #(my_transaction);
  uvm_event_pool ev_pool = uvm_event_pool::get_global_pool();
  ...
  task body();
    my_transaction req;
    req = my_transaction::type_id::create("req");
    uvm_event ev = ev_pool.get("mon_ev");
    ev.wait_trigger();
    $cast(req, ev.get_trigger_data()); 
   ....
  endtask

```

---

<div class="post-metadata">

**Author:** ![SV\_UVM\_Learner1](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@SV\_UVM\_Learner1](https://verificationacademy.com/forums/u/SV_UVM_Learner1)\
**Post date:** [December 10, 2018, 4:47am UTC](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417/13 "2018-12-10T04:47:22Z")

</div>

Hi chr\_sue,

Thanks a lot for your quick response. I’ll try this code once the DUT is ready.  
Can I use the same procedure to send data from passive monitor to active monitor via uvm\_event\_pool??

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [December 13, 2018, 8:13am UTC](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417/14 "2018-12-13T08:13:38Z")

</div>

_In reply to [SV\_UVM\_Learner](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417/13):_

This works for any component you want to send data.

---

<div class="post-metadata">

**Author:** ![SV\_UVM\_Learner1](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@SV\_UVM\_Learner1](https://verificationacademy.com/forums/u/SV_UVM_Learner1)\
**Post date:** [December 13, 2018, 9:02am UTC](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417/15 "2018-12-13T09:02:53Z")

</div>

Okay chr\_sue,

Thanks a lot.

---

<div class="post-metadata">

**Author:** ![SV\_UVM\_Learner1](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@SV\_UVM\_Learner1](https://verificationacademy.com/forums/u/SV_UVM_Learner1)\
**Post date:** [December 17, 2018, 12:39pm UTC](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417/16 "2018-12-17T12:39:56Z")

</div>

Hi chr\_sue,

I tried this logic in my passive monitor and my sequence. In my passive monitor, I kept a display message after triggering the data, and I’m getting that display message. I tried the same logic in my sequence too. But my simulation is blocking, after getting the display message from my passive monitor. Please help me.

I’ve a doubt. Do we need to use the same transaction class handle in both monitor and sequence (in this case, it’s “req”), while using this event\_pool ??

---

<div class="post-metadata">

**Author:** ![SV\_UVM\_Learner1](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@SV\_UVM\_Learner1](https://verificationacademy.com/forums/u/SV_UVM_Learner1)\
**Post date:** [December 17, 2018, 1:35pm UTC](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417/17 "2018-12-17T13:35:05Z")

</div>

// --------------------- monitor run phase method ------------------------ //

```
task run_phase(uvm_phase phase);
	//forever
		begin
			txn = rx_txn ::type_id::create("txn");
                            txn.array = {10,20,30,40,50}; //assigning some dummy data to my transaction class, as DUT is not yet ready!
		
	 `uvm_info("RX_MON_DATA", $sformatf("DATA sending from RX MONITOR is : [%p] \n", txn.array),UVM_LOW) // data {10,20,30,40,50} is printing
            ev = ev_pool.get("mon_ev");
            //uvm_event ev = ev_pool.get("mon_ev");
                ev.trigger(txn);
              `uvm_info("TRIGGER_DATA", $sformatf("DATA triggered in RX Monitor"),UVM_LOW) //This display is printing , after that simulation is getting blocked/hanged!! 

		end
endtask : run_phase

```

// --------------------- sequence ------------------------ //

class rx\_reset\_seq extends rx\_base\_seq;  
uvm\_event\_pool ev\_pool = uvm\_event\_pool::get\_global\_pool();  
uvm\_event ev;

```
`uvm_object_utils(rx_reset_seq)

function new(string name = "rx_reset_seq");
	super.new(name);
            ev=new("ev");
endfunction

task body();
	req = rx_txn ::type_id::create("req");
            //uvm_event ev = ev_pool.get("mon_ev");
            ev = ev_pool.get("mon_ev");
           	start_item(req);
	assert(req.randomize());
	finish_item(req);
            ev.wait_trigger();
            $cast(req, ev.get_trigger_data());

```

// How to print my data here ?? ie., how can I print my sent data here ?? ie., {10,20,30,40,50}  
endtask : body

## endclass

Hi chr\_sue,  
Please see my code, and help me, if I’m doing wrong …  
Do we need to create a separate class for uvm\_event by extending from uvm\_object ?? or not necessary ??  
Anticipating a favourable reply from you at the earliest.

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [December 17, 2018, 2:52pm UTC](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417/18 "2018-12-17T14:52:57Z")

</div>

_In reply to [SV\_UVM\_Learner](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417/17):_

Please try this code. It is only slidely modified:

```verilog
// --------------------- monitor run phase method ------------------------ //
class driver extends uvm_driver #(txn);

  ....
  uvm_event_pool ev_pool = uvm_event_pool::get_global_pool();

task run_phase(uvm_phase phase);
//forever
  begin
    txn = rx_txn ::type_id::create("txn");
    txn.array = {10,20,30,40,50}; //assigning some dummy data to my transaction class, as DUT is not yet ready!

    `uvm_info("RX_MON_DATA", $sformatf("DATA sending from RX MONITOR is : [%p] \n", txn.array),UVM_LOW) // data {10,20,30,40,50} is printing
    uvm_event ev = ev_pool.get("mon_ev"); //creates the event "mon_event" 
    ev.trigger(txn);
    `uvm_info("TRIGGER_DATA", $sformatf("DATA triggered in RX Monitor"),UVM_LOW) //This display is printing , after that simulation is getting blocked/hanged!!

  end
endtask : run_phase

// --------------------- sequence ------------------------ //

class rx_reset_seq extends rx_base_seq;
  uvm_event_pool ev_pool = uvm_event_pool::get_global_pool();
  uvm_event ev;

  `uvm_object_utils(rx_reset_seq)

  function new(string name = "rx_reset_seq");
    super.new(name);
  endfunction

task body();
  req = rx_txn ::type_id::create("req");
  //uvm_event ev = ev_pool.get("mon_ev");
  ev = ev_pool.get("mon_ev");
  start_item(req);
  assert(req.randomize());
  finish_item(req);
  ev.wait_trigger();
  $cast(req, ev.get_trigger_data());
  `uvm_info("DATA FROM MON", $sformatf("DATA received from RX MONITOR is : [%p] \n", req.array),UVM_LOW) 
endtask : body

endclass

```

---

<div class="post-metadata">

**Author:** ![SV\_UVM\_Learner1](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@SV\_UVM\_Learner1](https://verificationacademy.com/forums/u/SV_UVM_Learner1)\
**Post date:** [December 17, 2018, 3:06pm UTC](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417/19 "2018-12-17T15:06:48Z")

</div>

Thanks a lot for your quick response.  
Can we use different transaction class handles in monitor and sequence?? Like here, txn in monitor and req in sequence??

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [December 17, 2018, 3:34pm UTC](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417/20 "2018-12-17T15:34:18Z")

</div>

_In reply to [SV\_UVM\_Learner](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417/19):_

txn and req are only the names. We have to use the same types.

[Next page](https://verificationacademy.com/forums/t/sending-data-from-monitor-to-sequence/35417.md?page=2)
