# How to randomly generate unique dynamic array without using unique/foreach/queue?

**URL:** <https://verificationacademy.com/forums/t/how-to-randomly-generate-unique-dynamic-array-without-using-unique-foreach-queue/32571>\
**Category:** SystemVerilog\
**Tags:** unique-random-dynamic-array, SystemVerilog\
**Created:** [November 19, 2016, 8:16am UTC](https://verificationacademy.com/forums/t/how-to-randomly-generate-unique-dynamic-array-without-using-unique-foreach-queue/32571 "2016-11-19T08:16:44Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![ssureshgverifier](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/bcef8e/32.png) [@ssureshgverifier](https://verificationacademy.com/forums/u/ssureshgverifier)\
**Post date:** [December 2, 2016, 9:33pm UTC](https://verificationacademy.com/forums/t/how-to-randomly-generate-unique-dynamic-array-without-using-unique-foreach-queue/32571/3 "2016-12-02T21:33:38Z")

</div>

I assume you already know Chris Spear’s technique of using post-randomize with a randc variable to fill array with unique numbers…

Alternative way of doing is to actually implement an LFSR with a known polynomial

> **[Linear-feedback shift register](https://en.wikipedia.org/wiki/Linear-feedback_shift_register)**
>
> In computing, a linear-feedback shift register (LFSR) is a shift register whose input bit is a linear function of its previous state.
> The most commonly used linear function of single bits is exclusive-or (XOR). Thus, an LFSR is most often a shift register whose input bit is driven by the XOR of some bits of the overall shift register value.
> The initial value of the LFSR is called the seed, and because the operation of the register is deterministic, the stream of values produced by the registe...

in fact, simulators maybe internally using a variant of LFSR to generate rand…

---

_[View the full topic](https://verificationacademy.com/forums/t/how-to-randomly-generate-unique-dynamic-array-without-using-unique-foreach-queue/32571)._
