# Layered sequencers

**URL:** <https://verificationacademy.com/forums/t/layered-sequencers/36028>\
**Category:** UVM\
**Tags:** UVM, Layered-sequences\
**Created:** [April 28, 2019, 8:09pm UTC](https://verificationacademy.com/forums/t/layered-sequencers/36028 "2019-04-28T20:09:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shimonc](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/shimonc/32/1391_2.png) [@shimonc](https://verificationacademy.com/forums/u/shimonc)\
**Post date:** [April 28, 2019, 8:09pm UTC](https://verificationacademy.com/forums/t/layered-sequencers/36028/1 "2019-04-28T20:09:12Z")

</div>

Hi UVM forum,  
I have a layered sequencers architecture one:many.  
meaning that I have few lower sequences with a pointer to one upper sequencer.  
in the sequences I have the following code.

```verilog

class lower_seq_A extends uvm_sequence #(my_seq_item);
   upper_sequencer upper_seqr;
   ...
   task body();
      forever begin
         upper_seqr.get(req_up);
         start_item(req_lo);
         finish_item(req_lo);
      end
   endtask
endclass : lower_seq_A

```

There are scenarios that all the sequences request item from the upper sequencer at the same simulation time.  
so now new I have race condition, if one of the sequences get the request, the upper sequencer clean the fifo, and the other sequences get different items. in my application it is important that if few sequences request item at the same simulation time they must get the same item.  
How can I solve this issue?

---

<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:** [April 29, 2019, 3:04pm UTC](https://verificationacademy.com/forums/t/layered-sequencers/36028/2 "2019-04-29T15:04:37Z")

</div>

_In reply to [shimonc](https://verificationacademy.com/forums/t/layered-sequencers/36028):_

Unfortunately you do not show how your UVM structure looks like. But I guess you have one-to-one connections as always on the sequencer driving side. If you have more than one low level sequencers, you have to make a copy of the actual seq\_item and distribute it the all your low-level sequencers. This should solve your issue.

---

<div class="post-metadata">

**Author:** ![shimonc](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/shimonc/32/1391_2.png) [@shimonc](https://verificationacademy.com/forums/u/shimonc)\
**Post date:** [April 29, 2019, 6:34pm UTC](https://verificationacademy.com/forums/t/layered-sequencers/36028/3 "2019-04-29T18:34:16Z")

</div>

Hi chr sue  
My UVM structure is one:many. one upper sequencer and many lower sequencers.  
I did some experiments and I found out that for my application is best to have one:one layered sequencer connection and than from the lower sequence send the seq\_item to all other sequences.  
following is part of the code.

the one:one sequence structure

```verilog

virtual task body();
		uvm_event_pool ev_pool = uvm_event_pool::get_global_pool();
		uvm_event sync_event = ev_pool.get("sync_event");
		forever begin
			m_rtp_mng_sequencer.get(m_rtp_mng_seq_item);
                       ...
                       sync_event.trigger(m_rtp_util_seq_item);     
                end
endtask

```

one of the receiving sequences

```verilog

virtual task body();
		uvm_event_pool ev_pool = uvm_event_pool::get_global_pool();
		uvm_event sync_event = ev_pool.get("sync_event");
		forever begin
			sync_event.wait_trigger();
			$cast(m_rtp_util_seq_item, sync_event.get_trigger_data());
                        ...
                 // Start handshake with agent sequencer
			start_item(m_rtp_ind_seq_item);

			finish_item(m_rtp_ind_seq_item);
               end
endtask

```
