# Generic sequence call on different sequencers

**URL:** <https://verificationacademy.com/forums/t/generic-sequence-call-on-different-sequencers/38324>\
**Category:** UVM\
**Tags:** sequncer, UVM, sequence, UVM-virtual\_sequences\
**Created:** [November 9, 2020, 2:17pm UTC](https://verificationacademy.com/forums/t/generic-sequence-call-on-different-sequencers/38324 "2020-11-09T14:17:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MichaelP](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@MichaelP](https://verificationacademy.com/forums/u/MichaelP)\
**Post date:** [November 9, 2020, 2:17pm UTC](https://verificationacademy.com/forums/t/generic-sequence-call-on-different-sequencers/38324/1 "2020-11-09T14:17:00Z")

</div>

Hi,

I need to implement new infrastructure, will describe the requirements.  
An associative array: key = string, value = name of sequence (string) - which represents the sequence name, which can run on a specific sequencer.  
The sequences will be running on different sequencers in the system (various IPs in the SoC).

How do you suggest implementing this?  
I need to write a task/function which for a given string, it takes the matching string from the associative array (sequence name) and runs it on the correct sequencer.

Though on using virtual sequencer or virtual sequence.  
But not sure how to re-create the proper sequence from it’s name, and launch it on the correct sequencer.

Thanks,

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [November 9, 2020, 7:05pm UTC](https://verificationacademy.com/forums/t/generic-sequence-call-on-different-sequencers/38324/2 "2020-11-09T19:05:24Z")

</div>

_In reply to [Michael54](https://verificationacademy.com/forums/t/generic-sequence-call-on-different-sequencers/38324):_  
[https://verificationacademy.com/forums/uvm/problem-parameterized-defines#reply-56243](https://verificationacademy.com/forums/uvm/problem-parameterized-defines#reply-56243)

You can use the UVM factory’s [create\_object\_by\_name()](https://verificationacademy.com/verification-methodology-reference/uvm/docs_1.2/html/files/base/uvm_factory-svh.html#uvm_factory.create_object_by_name) if you have the registered name of the sequence. If you have parameterized sequences, there is no registered string name, but you can create one with an associative array. It wasn’t clear if each sequence had a dedicated sequencer to run on or if the sequence here was selected when the task was called. I’m going to assume it’s passed to the task, but you could make another associative array to store the sequencers you want to select from.

```verilog
uvm_object_wrapper seq_array[string];
  seq_array["first_seq"] = first_seq::get_type();
  seq_array["second_seq"] = second_seq::get_type();
  seq_array["third_seq#(1,2)"] = third_seq#(1,2)::get_type();
  seq_array["third_seq#(3,4)"] = third_seq#(3,4)::get_type();

task runseq(string name, uvm_sequencer_base sqr);

     uvm_sequence#(your_item_type) seq;
     if ($cast(seq,seq_array[my_name].create_object("")) && seq != null)
         seq.start(sqr);
     else
         // something bad happened
 endtask

```

---

<div class="post-metadata">

**Author:** ![MichaelP](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@MichaelP](https://verificationacademy.com/forums/u/MichaelP)\
**Post date:** [November 10, 2020, 5:40am UTC](https://verificationacademy.com/forums/t/generic-sequence-call-on-different-sequencers/38324/3 "2020-11-10T05:40:49Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/generic-sequence-call-on-different-sequencers/38324/2):_

Thank you for the detailed answer Dave!

Was not familiar with the UVM Factory’s “create\_object\_by\_name”. However later in the task you used “create\_object”, is it the same?

I have edited my original post, and will elaborate more.  
The sequencer is not passed as an argument to the task.  
It is required to support “registering of sequence and sequencer” to this component database, based on possible scenarios of a specific test.  
Probably will be done before the run\_phase of the test.  
The component should be instantized in the ENV class.  
So when monitored specific events during the simulation run, it should start one of these registered sequences, using the API functions/tasks of this component.

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [November 10, 2020, 8:05am UTC](https://verificationacademy.com/forums/t/generic-sequence-call-on-different-sequencers/38324/4 "2020-11-10T08:05:11Z")

</div>

_In reply to [Michael54](https://verificationacademy.com/forums/t/generic-sequence-call-on-different-sequencers/38324/3):_

I provided a link to the definition of create\_object\_by\_name but no example since it is relatively straightforward. The uvm\_object\_wrapper::create\_object requires an extra step but accomplishes the same factory object creation. I prefer using the uvm\_object\_wrapper because it can be more efficient for repeated creation, and works for both parameterized and unparameterized classes. The UVM wrapper is known as a _proxy object_ or lightweight object for the actual class you want to create.

```verilog
  uvm_object_wrapper seq_array[string];
  uvm_sequencer_base sqr_array[string];
  seq_array["first_seq"] = first_seq::get_type();
  sqr_array["first_seq"] = first_sqr;
  seq_array["second_seq"] = second_seq::get_type();
  sqr_array["second_seq"] = second_sqr;
  seq_array["third_seq#(1,2)"] = third_seq#(1,2)::get_type();
  sqr_array["third_seq#(1,2)"] = third_seq;
  seq_array["third_seq#(3,4)"] = third_seq#(3,4)::get_type();
  sqr_array["third_seq#(3,4)"] = third_seq; // same sqr as 1,2

 
task runseq(string name);
 
     uvm_sequence#(your_item_type) seq;
     if ($cast(seq,seq_array[name].create_object("")) && seq != null)
         seq.start(sqr_array[name]);
     else
         // something bad happened
endtask

```
