# Where does the random variables in the sequencer are randomized?

**URL:** <https://verificationacademy.com/forums/t/where-does-the-random-variables-in-the-sequencer-are-randomized/38991>\
**Category:** UVM\
**Tags:** uvm--sequence, UVM\
**Created:** [April 19, 2021, 7:22pm UTC](https://verificationacademy.com/forums/t/where-does-the-random-variables-in-the-sequencer-are-randomized/38991 "2021-04-19T19:22:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![srshan\_rocks](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@srshan\_rocks](https://verificationacademy.com/forums/u/srshan_rocks)\
**Post date:** [April 19, 2021, 7:22pm UTC](https://verificationacademy.com/forums/t/where-does-the-random-variables-in-the-sequencer-are-randomized/38991/1 "2021-04-19T19:22:44Z")

</div>

Say i have a basic sequence like this where i want to randomize the mode in the sequence in my test. Please note I am ignoring boiler plate code for brevity. I am very particular that i want to start my sequence this way. I have embedded my questions in the code using comments. Please clarify.

```verilog

class foo_seq extends uvm_sequence #(my_seq_item);
    rand bit [3:0] mode;
    task body();
        case (mode)
           0 : //do mode 0 specific randomization in the sequence item
           1 : //do mode 1 specific randomization in the sequence item
               //so on so forth
        endcase
    endtask
endclass
class test extends uvm_test;
   task run_phase();
      //now when i want to start my sequence like below. 
      //Does mode get randomized automatically? If so in which part of start() it gets randomized()?
      //Or do I need to call my_foo_seq.randomize() first before calling my_foo_seq.start(...)
      //note that i am particular about randomizing this mode variable in my sequence.
      my_foo_seq.start(my_foo_seqr);
   endtask
endclass

```

---

<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 20, 2021, 4:55pm UTC](https://verificationacademy.com/forums/t/where-does-the-random-variables-in-the-sequencer-are-randomized/38991/2 "2021-04-20T16:55:54Z")

</div>

_In reply to [srshan\_rocks](https://verificationacademy.com/forums/t/where-does-the-random-variables-in-the-sequencer-are-randomized/38991):_

When you are starting your sequence without randomizing it mode will not be randomized.

---

<div class="post-metadata">

**Author:** ![srshan\_rocks](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@srshan\_rocks](https://verificationacademy.com/forums/u/srshan_rocks)\
**Post date:** [April 20, 2021, 5:23pm UTC](https://verificationacademy.com/forums/t/where-does-the-random-variables-in-the-sequencer-are-randomized/38991/3 "2021-04-20T17:23:48Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/where-does-the-random-variables-in-the-sequencer-are-randomized/38991/2):_  
Thanks. That explains it!

---

<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:** [April 20, 2021, 5:35pm UTC](https://verificationacademy.com/forums/t/where-does-the-random-variables-in-the-sequencer-are-randomized/38991/4 "2021-04-20T17:35:28Z")

</div>

_In reply to [srshan\_rocks](https://verificationacademy.com/forums/t/where-does-the-random-variables-in-the-sequencer-are-randomized/38991/3):_  
You can also put the call to randomize in the new or body methods of foo\_seq, as well as using randcase.
