# Generate unique elements in an array

**URL:** <https://verificationacademy.com/forums/t/generate-unique-elements-in-an-array/28350>\
**Category:** UVM\
**Tags:** UVM\
**Created:** [February 6, 2013, 5:03pm UTC](https://verificationacademy.com/forums/t/generate-unique-elements-in-an-array/28350 "2013-02-06T17:03:29Z")\
**Posts on this page:** 1\
**Showing post:** 29

<div class="post-metadata">

**Author:** ![Kuma](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/k/a587f6/32.png) [@Kuma](https://verificationacademy.com/forums/u/Kuma)\
**Post date:** [June 21, 2016, 6:57am UTC](https://verificationacademy.com/forums/t/generate-unique-elements-in-an-array/28350/29 "2016-06-21T06:57:22Z")

</div>

This is about specifying the hard coded values in unique constrains as shown in below.

class nibbleset;  
rand bit [3:0] nibbles[10];  
const rand bit [3:0] excludes = {0,15};  
rand bit[3:0] excluded;  
**constraint uniq {unique {nibbles, excludes,7};}**  
//constraint uniq {unique {nibbles, excludes,excluded};}  
constraint exclusion { excluded==1; }  
endclass

We are seeing the error as shown in below for the above code snippet(uncommitted line ).

Error-[CSTR-NET] Non-equivalent type  
customer\_test.sv, 18

**If I replace the value 7 with an identifier(excluded) the test case is passing.**

The following blog was mentioning about the hard coded values in the unique constraints is allowed .

> **[Verification Horizons - Siemens Software](https://blogs.sw.siemens.com/verificationhorizons/)**
>
> Siemens Software

**Is this valid to mention the hardcoded values in the unique constraint list ( constraint uniq {unique {nibbles, excludes,7};}**

---

_[View the full topic](https://verificationacademy.com/forums/t/generate-unique-elements-in-an-array/28350)._
