# Randomization of array without using rand or any randomize methods

**URL:** <https://verificationacademy.com/forums/t/randomization-of-array-without-using-rand-or-any-randomize-methods/33080>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, array-randomization, systemverilog-Arrays\
**Created:** [April 26, 2017, 7:40pm UTC](https://verificationacademy.com/forums/t/randomization-of-array-without-using-rand-or-any-randomize-methods/33080 "2017-04-26T19:40:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sk9](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/e79b87/32.png) [@sk9](https://verificationacademy.com/forums/u/sk9)\
**Post date:** [April 26, 2017, 7:40pm UTC](https://verificationacademy.com/forums/t/randomization-of-array-without-using-rand-or-any-randomize-methods/33080/1 "2017-04-26T19:40:54Z")

</div>

Hi, I am trying to solve the below question.

How to generate an array of unique values without using randomize method or rand.  
Please help me with the solution.

Thanks,  
Sruthi.

---

<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 26, 2017, 8:08pm UTC](https://verificationacademy.com/forums/t/randomization-of-array-without-using-rand-or-any-randomize-methods/33080/2 "2017-04-26T20:08:15Z")

</div>

_In reply to [sruthikrapa](https://verificationacademy.com/forums/t/randomization-of-array-without-using-rand-or-any-randomize-methods/33080):_  
This appears to be a homework question based on the fact you have used randomize() in your other questions. So I’ll help but not give you a solution

What you need to do create a loop that generate a random value and pushes it onto a queue. Before pushing the value into the queue, you need to check if the value does not already exist inside the queue. If it does , you need to generate a new random value and try again.

---

<div class="post-metadata">

**Author:** ![sbellock](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/f4b2a3/32.png) [@sbellock](https://verificationacademy.com/forums/u/sbellock)\
**Post date:** [April 26, 2017, 9:24pm UTC](https://verificationacademy.com/forums/t/randomization-of-array-without-using-rand-or-any-randomize-methods/33080/3 "2017-04-26T21:24:14Z")

</div>

_In reply to [sruthikrapa](https://verificationacademy.com/forums/t/randomization-of-array-without-using-rand-or-any-randomize-methods/33080/2):_

You could:

1. Implement your own pseudo-random number generator algorithm, such as a simple [linear feedback shift register](https://en.wikipedia.org/wiki/Linear-feedback_shift_register).
2. Use an older Verilog randomization function, such as $urandom.
3. Obtain a hardware random number generator, such as [TrueRNG](http://ubld.it/truerng_v3). Note that using a hardware RNG for verification is oftentimes a bad idea since the random number patterns are almost always unique.
