# Query Regarding Sequence Layering Management

**URL:** <https://verificationacademy.com/forums/t/query-regarding-sequence-layering-management/29571>\
**Category:** UVM\
**Tags:** get\_response, UVM, Multiple-Sequences, Sequence-Layering\
**Created:** [June 10, 2014, 1:39pm UTC](https://verificationacademy.com/forums/t/query-regarding-sequence-layering-management/29571 "2014-06-10T13:39:06Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![vadivelan014](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/v/35a633/32.png) [@vadivelan014](https://verificationacademy.com/forums/u/vadivelan014)\
**Post date:** [June 10, 2014, 1:39pm UTC](https://verificationacademy.com/forums/t/query-regarding-sequence-layering-management/29571/1 "2014-06-10T13:39:06Z")

</div>

1. How to Connect multiple sequencers in one lower sequence which is connected with Driver??  
i.e. I am having Sqr1(higher), Sqr2(higher), SeqL(Lower). SqrL is lower one which is running lower sequence, it is connected with Lower Driver which is communicating with DUT pin wiggles. I want to connect Sqr1 and Sqr2 into the Sqr3.
2. How to connect one higher level sequencer into multiple lower level sequences?  
i.e. I am having one higher sequencer (SqrH), it is connected with two lower level Sequences (seqL1 and seqL2). When i start the higher sequence, these data should be get by any one of the lower sequences depend on my higher sequence logic. But the problem is i couldn’t get the higher layer packets in any of the lower sequencers.

_Code Snippet for Question 2:_  
// Higher Sequence  
class high\_sequence extends uvm\_sequence#(high\_packet);  
…  
high\_packet h\_pkt;  
task body();  
h\_pkt.Low\_seq1\_en = 1;  
endtask  
endclass

// Lower Sequence 1  
class Low\_sequence1 extends uvm\_sequence#(low\_packet1);  
…  
uvm\_sequencer #(high\_packet) SqrH;  
high\_packet h\_pkt;  
low\_packet1 l\_pkt1;  
task body();  
sqrH.get(h\_pkt); // I am not able to get higher layer packet  
start\_item(l\_pkt1);  
finish\_item(l\_pkt1);  
…  
sqrH.put(rsp);  
endtask  
endclass

// Lower Sequence 2  
class Low\_sequence2 extends uvm\_sequence#(low\_packet2);  
…  
uvm\_sequencer #(high\_packet) SqrH;  
high\_packet h\_pkt;  
low\_packet2 l\_pkt2;  
task body();  
sqrH.get(h\_pkt); // I am not able to get higher layer packet  
start\_item(l\_pkt2);  
finish\_item(l\_pkt2);  
…  
sqrH.put(rsp);  
endtask  
endclass

If both Lower sequences are trying to get higher layer packets at same time (Sqr.get(item)), which lower sequence will get the higher packets and How to do that?

---

<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:** [June 10, 2014, 2:52pm UTC](https://verificationacademy.com/forums/t/query-regarding-sequence-layering-management/29571/2 "2014-06-10T14:52:12Z")

</div>

You should definitely check out [the Cookbook](https://verificationacademy.com/cookbook/sequences/layering) and the [Advanced UVM video](https://verificationacademy.com/sessions/layered-sequences) for more information on layered sequences. As to your specific questions:

> 1. How to Connect multiple sequencers in one lower sequence which is connected with Driver??  
> i.e. I am having Sqr1(higher), Sqr2(higher), SeqL(Lower). SqrL is lower one which is running lower sequence, it is connected with Lower Driver which is communicating with DUT pin wiggles. I want to connect Sqr1 and Sqr2 into the Sqr3.

As I understand it, you have two upstream sequencers, each of which presumably is running one (or more) sequence(s). If SqrL (the sequencer) is connected to your driver, then you need to have two translator sequences running on SqrL, each to communicate with one of the upstream sequencers. Each of these translator sequences will get a transaction from the upstream sequencer and convert it into a “lower\_transaction” which is the type that the Lower Driver is expecting. The type of the upstream transactions can be different, as long as each translator sequence is paramterized appropriately.

> 1. How to connect one higher level sequencer into multiple lower level sequences?  
> i.e. I am having one higher sequencer (SqrH), it is connected with two lower level Sequences (seqL1 and seqL2). When i start the higher sequence, these data should be get by any one of the lower sequences depend on my higher sequence logic. But the problem is i couldn’t get the higher layer packets in any of the lower sequencers.

The important thing to remember about sequence layering is that each layer needs to look like it is communicating with a driver at the lower level. So, when you have

```verilog
// Higher Sequence
 class high_sequence extends uvm_sequence#(high_packet);
 ....
 high_packet h_pkt;
 task body();
   h_pkt.Low_seq1_en = 1;
 endtask
 endclass

```

there is no way for the high\_sequence to pass a high\_packet sequence\_item to anybody, since you’ve neglected the start\_item()/finish\_item() calls.  
The other problem you have is that the lower-level sequences are each trying to call get() on the high\_sequencer, and the handshakes will get confused. You could implement a semaphore/mutex in high\_sequence and have each lower-level translator sequence get the semaphore before calling get, but that makes the translator sequences less reusable.

Please explain why you think you need two lower-level sequences to communicate to a single high\_sequence. Are these two lower-level sequences running on the same lower-level sequencer or are they running on different sequencers?

---

<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:** [June 11, 2014, 3:47pm UTC](https://verificationacademy.com/forums/t/query-regarding-sequence-layering-management/29571/3 "2014-06-11T15:47:53Z")

</div>

_In reply to [vadivelan014](https://verificationacademy.com/forums/t/query-regarding-sequence-layering-management/29571/2):_

The way you’ve written your higher\_default\_sequence:

```verilog
class higher_default_sequence extends uvm_sequence #(higher_packet); 
 `uvm_sequence_utils(higher_default_sequence, higher_sequencer); 
.....

 higher_sequence1 h_seq1;
 higher_sequence2 h_seq2;
 higher_sequence3 h_seq3;
 higher_sequence4 h_seq4;

 task body();
 `uvm_do(h_seq1);
 `uvm_do(h_seq2);
 `uvm_do(h_seq3);
 `uvm_do(h_seq4);
 endtask
 endclass

```

shows the four sequences running serially (that is, h\_seq2 starts after h\_seq1 completes, etc.). If that’s all you want to do, then I think you may be overthinking things a bit. It appears that each of your h\_seq sequences generates a single h\_pkt that the lower\_sequences (actually translator sequences, as defined in the [Cookbook](https://verificationacademy.com/cookbook/Sequences/Layering)) use to generate a corresponding lower\_packet. Since each h\_pkt includes the enable logic for either L1 or L2, it makes no sense to have the two lower\_sequences each trying to get from the higher\_sequence simultaneously, since it screws up the handshake as you’ve seen.  
Instead, you would be better off actually treating higher\_default\_sequence as a virtual sequence:

```verilog
class higher_default_sequence extends uvm_sequence #(higher_packet); 
 `uvm_object_utils(higher_default_sequence, higher_sequencer); 
.....
 lower_sequencer1 Lsqr1;
 lower_sequencer2 Lsqr2;

 higher_sequence1 h_seq1;
 higher_sequence2 h_seq2;
 higher_sequence3 h_seq3;
 higher_sequence4 h_seq4;

 task body();
   h_seq1.start(Lsqr1, this);
   h_seq2.start(Lsqr2, this);
   h_seq3.start(Lsqr1, this);
   h_seq4.start(Lsqr2, this);
 endtask
 endclass

```

Please see the UVM Cookbook for more details on [virtual sequences](https://verificationacademy.com/cookbook/sequences/virtual). Notice that we’re not using a virtual sequence\*\*_r_\*\*, which is unnecessary since you can put the lower\_sequencer pointers directly in the virtual sequence.  
You’d have to change the definitions of h\_seq[1,2,3,4] since they are now running on the lower\_sequencers. These now become what we call “worker sequences” (see the [Cookbook](https://verificationacademy.com/cookbook/Sequences/Hierarchy)) which will call the lower\_sequence with the appropriate values.  
By starting the four sequences one-at-a-time on the lower\_sequencers, you should avoid the handshake problem. The downstream layering low sqr1 ↔ low sqr 1a ↔ low sqr 1b ↔ driver ↔ DUT should remain unchanged.  
Remember, the key to layering is to make each layer appear that it’s just a sequence/sequencer/driver connection. Since you can’t connect a single sequence to multiple drivers, you can’t have multiple translator sequences talking to the same sequence either.

Other comments on your code:  
You’ll notice that I replace `uvm_sequence_utils with `uvm\_object\_utils. The sequence utils has been deprecated, as has `uvm_update_sequence_lib_and_item. If you really think you need to use a sequence library, please see the [Cookbook](https://verificationacademy.com/cookbook/sequences/sequencelibrary) to learn how to do it, but I don't think you do. You'll also notice that I replaced the `uvm\_do macros with sequence.start(). The `uvm_do macros are evil and we recommend against using them. In your original approach, you would replace the `uvm\_do macro with

```verilog
h_seq1.start(m_sequencer, this);

```

if you really wanted to start h\_seq1 on the higher\_sequencer. Using my approach, you would have had to change `uvm_do to `uvm\_do\_on (I think - I can never keep those macros straight).

Hope this helps.

---

<div class="post-metadata">

**Author:** ![vadivelan014](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/v/35a633/32.png) [@vadivelan014](https://verificationacademy.com/forums/u/vadivelan014)\
**Post date:** [June 12, 2014, 6:06am UTC](https://verificationacademy.com/forums/t/query-regarding-sequence-layering-management/29571/4 "2014-06-12T06:06:34Z")

</div>

_In reply to [tfitz](https://verificationacademy.com/forums/t/query-regarding-sequence-layering-management/29571/3):_

Thanks for reply tfitz…  
I am having one higher level sequencer(SqrH). It is connected with two lower level sequences(seqL1,seqL2). The two lower level sequences are running in different sequencer (SqrL1, SqrL2). In my case i am having only one interface (lets assume 2 i/p signals and 2 o/p signals).  
Lets assume 4 sequences are running in higher sequencer. These 4 sequences will be started by one default sequence in higher sequencer(According to UVM LRM). when i am using one Lower sequencer with that higher sequencer, it is working fine. but when i introduce two lower level sequencers, both lower sequencers are trying to get sequence from higher sequencer. I thing that’s why i couldn’t get the packets in any one of the lower sequencer. Will it be solved by Virtual sequencer?

_Code Snippet:_

//////////////////////////////////////////////////  
// Higher layer packet  
//////////////////////////////////////////////////

class higher\_packet extends uvm\_sequence\_item;  
…

```
rand bit en_L1;
rand bit en_L2;

.....

```

endclass

//////////////////////////////////////////////////  
// Higher layer sequence1  
//////////////////////////////////////////////////

class higher\_sequence1 extends uvm\_sequence #(higher\_packet);  
…

```
task body();
	higher_packet h_pkt, rsp_pkt;
	....
	start_item(h_pkt);
	assert(h_pkt.randomize() with {h_pkt.en_L1 == 1;
                                       h_pkt.en_L2 == 0; });
	finish_item(h_pkt);

	get_response(rsp_pkt);
endtask

```

endclass

//////////////////////////////////////////////////  
// Higher layer sequence2  
//////////////////////////////////////////////////

class higher\_sequence2 extends uvm\_sequence #(higher\_packet);  
…

```
task body();
	higher_packet h_pkt, rsp_pkt;
	....
	start_item(h_pkt);
	assert(h_pkt.randomize() with {h_pkt.en_L1 == 0;
                                       h_pkt.en_L2 == 1; });
	finish_item(h_pkt);

	get_response(rsp_pkt);
endtask

```

endclass

//////////////////////////////////////////////////  
// Higher layer sequence3  
//////////////////////////////////////////////////

class higher\_sequence3 extends uvm\_sequence #(higher\_packet);  
…

```
task body();
	higher_packet h_pkt, rsp_pkt;
	....
	start_item(h_pkt);
	assert(h_pkt.randomize() with {h_pkt.en_L1 == 1;
                                       h_pkt.en_L2 == 0; });
	finish_item(h_pkt);

	get_response(rsp_pkt);
endtask

```

endclass

//////////////////////////////////////////////////  
// Higher layer sequence4  
//////////////////////////////////////////////////

class higher\_sequence4 extends uvm\_sequence #(higher\_packet);  
…

```
task body();
	higher_packet h_pkt, rsp_pkt;
	....
	start_item(h_pkt);
	assert(h_pkt.randomize() with {h_pkt.en_L1 == 0;
                                       h_pkt.en_L2 == 1; });
	finish_item(h_pkt);

	get_response(rsp_pkt);
endtask

```

endclass

//////////////////////////////////////////////////  
// Higher layer default sequence  
//////////////////////////////////////////////////

class higher\_default\_sequence extends uvm\_sequence #(higher\_packet);   
/\* I configured this default class in test class build phase by using set\_config\_string(“hsqr”, “default\_sequence”, "higher\_default\_sequence ") and running it in top module using hsqr.start\_default\_sequence() \*/

```
   `uvm_sequence_utils(higher_default_sequence, higher_sequencer);  
.....

higher_sequence1	h_seq1;
higher_sequence2	h_seq2;
higher_sequence3	h_seq3;
higher_sequence4	h_seq4;

task body();
	`uvm_do(h_seq1);
	`uvm_do(h_seq2);
	`uvm_do(h_seq3);
	`uvm_do(h_seq4);
endtask

```

endclass

//////////////////////////////////////////////////  
// Higher layer sequencer  
//////////////////////////////////////////////////

class higher\_sequencer extends uvm\_sequencer #(higher\_packet);  
`uvm\_sequencer\_utils(higher\_sequencer);

```
function new(string name = "higher_sequencer", uvm_component parent);
	super.new(name, parent);
	`uvm_update_sequence_lib_and_item(higher_packet) // Sequence Library Updatation (Default Sequence)
endfunction

```

endclass

//////////////////////////////////////////////////  
// Lower layer 1 packet  
//////////////////////////////////////////////////

class lower\_packet1 extends uvm\_sequence\_item;  
…  
endclass

//////////////////////////////////////////////////  
// Lower layer 1 sequence  
//////////////////////////////////////////////////

class lower\_sequence1 extends uvm\_sequence #(lower\_packet1);  
…

```
uvm_sequencer #(higher_packet) hsqr;
higher_packet hpkt, rsp_pkt;

task body();
	lower_packet1 lpkt1;
	.....
	hsqr.get(hpkt);
	start_item(lpkt1);
	
	if(hpkt.en_L1 == 1)
	begin
		assert(lpkt1.randomize());
		.......
	end

	finish_item(lpkt1);

	get_response(rsp);

	......

	hsqr.put(rsp_pkt);
endtask

```

endclass

//////////////////////////////////////////////////  
// Lower layer 1 sequencer  
//////////////////////////////////////////////////

class lower\_sequencer1 extends uvm\_sequencer #(lower\_packet1);  
…  
endclass

//////////////////////////////////////////////////  
// Lower layer 2 packet  
//////////////////////////////////////////////////

class lower\_packet2 extends uvm\_sequence\_item;  
…  
endclass

//////////////////////////////////////////////////  
// Lower layer 2 sequence  
//////////////////////////////////////////////////

class lower\_sequence2 extends uvm\_sequence #(lower\_packet2);  
…

```
uvm_sequencer #(higher_packet) hsqr;
higher_packet hpkt, rsp_pkt;

task body();
	lower_packet2 lpkt2;
	.....
	hsqr.get(hpkt);
	start_item(lpkt2);
	
	if(hpkt.en_L2 == 1)
	begin
		assert(lpkt1.randomize());
		.......
	end

	finish_item(lpkt2);

	get_response(rsp);

	......

	hsqr.put(rsp_pkt);
endtask

```

endclass

//////////////////////////////////////////////////  
// Lower layer 2 sequencer  
//////////////////////////////////////////////////

class lower\_sequencer2 extends uvm\_sequencer #(lower\_packet2);  
…  
endclass

And finally this lower sequncer 1 will be connected to low sqr 1a , then low sqr 1a will be connected to low sqr 1b which is connected with driver. Lower level sequencer 2 will be connected with low sqr 1b.  
when hseq1 or hseq3 is running it should reach the driver through the following path :  
hsqr ↔ low sqr1 ↔ low sqr 1a ↔ low sqr 1b ↔ driver ↔ DUT

when hseq2 or hseq4 is running it should reach the driver through the following path :  
hsqr ↔ low sqr2 ↔ low sqr 1b ↔ driver ↔ DUT

How can i achieve it? will it possible with virtual sequencer and how??  
Thanks…

---

<div class="post-metadata">

**Author:** ![vadivelan014](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/v/35a633/32.png) [@vadivelan014](https://verificationacademy.com/forums/u/vadivelan014)\
**Post date:** [June 12, 2014, 8:32am UTC](https://verificationacademy.com/forums/t/query-regarding-sequence-layering-management/29571/5 "2014-06-12T08:32:22Z")

</div>

_In reply to [tfitz](https://verificationacademy.com/forums/t/query-regarding-sequence-layering-management/29571/4):_

Thanks for reply tfitz. I tried your idea, making default sequence as a virtual sequence. but i am getting Fatal Error “default\_seq.h\_seq1 Error casting p\_sequencer, please verify that this sequence/sequence item is intended to execute on this type of sequencer”. How to solve this error?? Here default\_seq is instance of higher\_default\_sequence in test class.

As per your idea, in virtual sequence,

class higher\_default\_sequence extends uvm\_sequence #(higher\_packet);  
`uvm\_object\_utils(higher\_default\_sequence, higher\_sequencer);  
…  
lower\_sequencer1 Lsqr1;  
lower\_sequencer2 Lsqr2;

higher\_sequence1 h\_seq1;  
higher\_sequence2 h\_seq2;  
higher\_sequence3 h\_seq3;  
higher\_sequence4 h\_seq4;

task body();  
**h\_seq1.start(Lsqr1, this);  
h\_seq2.start(Lsqr2, this);  
h\_seq3.start(Lsqr1, this);  
h\_seq4.start(Lsqr2, this);**  
endtask  
endclass

Here, h\_seq1 will try to start in Lower sequencer 1, how it is possible?? Because h\_seq1 and higher sequencer has same sequence item(h\_pkt) but Lower sequencer1 or Lower sequencer2 is having different sequence item (lpkt1 or lpkt2)…I think due to this, I am getting above mentioned error. Please give some to idea to solve this bug…I am having one idea to do it, that is making two agents,  
one agent will contain hsqr ↔ low sqr1 ↔ low sqr 1a ↔ low sqr 1b ↔ driver ↔ DUT  
and Another agent will contain hsqr ↔ low sqr2 ↔ low sqr 1b ↔ driver ↔ DUT  
Now i hope i can control higher sequences using virtual sequence in test.

Is this correct idea or any other easier way is there to do it??  
Thank you.

---

<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:** [June 12, 2014, 2:29pm UTC](https://verificationacademy.com/forums/t/query-regarding-sequence-layering-management/29571/6 "2014-06-12T14:29:19Z")

</div>

_In reply to [vadivelan014](https://verificationacademy.com/forums/t/query-regarding-sequence-layering-management/29571/5):_

That’s exactly the problem. You can’t run h\_seq\* parameterized by h\_pkt on a sequencer that is expecting lower\_pkt. The issue is that this is no longer a standard layering. h\_seq1 and h\_seq3 should be parameterized with lpkt1 and h\_seq2 and h\_seq4 should be parameterized with lpkt2. You’ll need to make sure that these sequences call the lower\_sequences rather than expecting the lower\_sequences to call get().

---

<div class="post-metadata">

**Author:** ![vadivelan014](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/v/35a633/32.png) [@vadivelan014](https://verificationacademy.com/forums/u/vadivelan014)\
**Post date:** [June 12, 2014, 6:34pm UTC](https://verificationacademy.com/forums/t/query-regarding-sequence-layering-management/29571/7 "2014-06-12T18:34:29Z")

</div>

_In reply to [tfitz](https://verificationacademy.com/forums/t/query-regarding-sequence-layering-management/29571/6):_

Hi tfitz,  
I got the source of error, so we cant run sequence in sequencer which is not the same parameterized item (\* extends uvm\_sequence#( **h\_pkt** ) as well as \* extends uvm\_sequencer #( **h\_pkt** )).  
And I am not understanding the last line in your previous comment which is “You’ll need to make sure that these sequences call the lower\_sequences rather than expecting the lower\_sequences to call get().”… can u explain this?? Thank you.

---

<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:** [June 12, 2014, 6:55pm UTC](https://verificationacademy.com/forums/t/query-regarding-sequence-layering-management/29571/8 "2014-06-12T18:55:00Z")

</div>

_In reply to [vadivelan014](https://verificationacademy.com/forums/t/query-regarding-sequence-layering-management/29571/7):_

You want your h\_seq sequences to behave as “worker sequences” [see the [Cookbook](https://verificationacademy.com/cookbook/Sequences/Hierarchy)] when running on the lower\_sequencers. That means they’ll set values of things in the lower\_sequences and call

```verilog
lower_sequence.start(m_sequencer, this);

```

In your original design, the lower sequences were “translator sequences” [see the [Cookbook](https://verificationacademy.com/cookbook/Sequences/Layering)] which called the get() methods of the higher\_sequencer (which isn’t there anymore) to appear as a driver to the h\_seqs.

---

<div class="post-metadata">

**Author:** ![vadivelan014](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/v/35a633/32.png) [@vadivelan014](https://verificationacademy.com/forums/u/vadivelan014)\
**Post date:** [June 13, 2014, 1:34pm UTC](https://verificationacademy.com/forums/t/query-regarding-sequence-layering-management/29571/9 "2014-06-13T13:34:57Z")

</div>

_In reply to [tfitz](https://verificationacademy.com/forums/t/query-regarding-sequence-layering-management/29571/8):_

Finally my sequence layering works finely with “Worker Sequence & Virtual Sequence”. Thanks a lot tfitz, for your timely help.

---

<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:** [June 13, 2014, 1:58pm UTC](https://verificationacademy.com/forums/t/query-regarding-sequence-layering-management/29571/10 "2014-06-13T13:58:34Z")

</div>

_In reply to [vadivelan014](https://verificationacademy.com/forums/t/query-regarding-sequence-layering-management/29571/9):_

You’re welcome.  
Glad I could help.
