# Randomize function returning same value each time I run my test

**URL:** <https://verificationacademy.com/forums/t/randomize-function-returning-same-value-each-time-i-run-my-test/31032>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, Randomize, same-function\
**Created:** [September 16, 2015, 6:10pm UTC](https://verificationacademy.com/forums/t/randomize-function-returning-same-value-each-time-i-run-my-test/31032 "2015-09-16T18:10:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ammu4392](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/919ad9/32.png) [@Ammu4392](https://verificationacademy.com/forums/u/Ammu4392)\
**Post date:** [September 16, 2015, 6:10pm UTC](https://verificationacademy.com/forums/t/randomize-function-returning-same-value-each-time-i-run-my-test/31032/1 "2015-09-16T18:10:07Z")

</div>

virtual task body();  
a.randomize();  
txns = a.no\_transactions;  
obj = new[txns];

```
   for(int i=0; i<txns; i=i+1)begin
    `ovm_create(obj[i])
         a.randomize();
     obj[i].core = this.a.core_id; 
     obj[i].addr = 'h0000080;
    `ovm_send(obj[i])
      obj[i].print();
       end   
endtask : body

```

Each time I run the test, I’m getting the same set of values. Can anybody help me with this

---

<div class="post-metadata">

**Author:** ![bmorris](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/bmorris/32/2097_2.png) [@bmorris](https://verificationacademy.com/forums/u/bmorris)\
**Post date:** [September 16, 2015, 6:54pm UTC](https://verificationacademy.com/forums/t/randomize-function-returning-same-value-each-time-i-run-my-test/31032/2 "2015-09-16T18:54:27Z")

</div>

Unless you change your randomization seed, you’ll always get the same “random” value. This is a good thing; it allows you to reproduce errors.

---

<div class="post-metadata">

**Author:** ![Ammu4392](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/919ad9/32.png) [@Ammu4392](https://verificationacademy.com/forums/u/Ammu4392)\
**Post date:** [September 16, 2015, 9:14pm UTC](https://verificationacademy.com/forums/t/randomize-function-returning-same-value-each-time-i-run-my-test/31032/3 "2015-09-16T21:14:59Z")

</div>

_In reply to [bmorris](https://verificationacademy.com/forums/t/randomize-function-returning-same-value-each-time-i-run-my-test/31032/2):_

where do I give my randomization seed? and how?

---

<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:** [September 16, 2015, 9:18pm UTC](https://verificationacademy.com/forums/t/randomize-function-returning-same-value-each-time-i-run-my-test/31032/4 "2015-09-16T21:18:29Z")

</div>

_In reply to [Ammu4392](https://verificationacademy.com/forums/t/randomize-function-returning-same-value-each-time-i-run-my-test/31032/3):_

This is going to be tool dependent. Look for a command line option when you run your simulator.
