# Randomization Question

**URL:** <https://verificationacademy.com/forums/t/randomization-question/42546>\
**Category:** UVM\
**Tags:** UVM, System-Verilog, uvm-sv-constraints\
**Created:** [October 10, 2023, 5:32pm UTC](https://verificationacademy.com/forums/t/randomization-question/42546 "2023-10-10T17:32:41Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![jyoveda](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@jyoveda](https://verificationacademy.com/forums/u/jyoveda)\
**Post date:** [October 10, 2023, 9:27pm UTC](https://verificationacademy.com/forums/t/randomization-question/42546/3 "2023-10-10T21:27:10Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/randomization-question/42546/2):_

1.Yes,  
2.Yes,  
3.Yes

I put something like this, but I can’t get the unique index part down.

```verilog
rand int n;
rand int elements[];

constraint_c {
        n inside {[1:6]};
        elements.size == n;
        foreach(elements[i]){
                                if(i>0) {
                                         elements[i] > elements[i-1];
                                         elements[i] - elements[i-1] <5;
                                         }
                             }
}

```

---

_[View the full topic](https://verificationacademy.com/forums/t/randomization-question/42546)._
