Hi
I need to generate a unique integer number which should not match any elements in a pre-defined array.
We can use unique keyword.
any other way it can be done?
Thanks
Hi
I need to generate a unique integer number which should not match any elements in a pre-defined array.
We can use unique keyword.
any other way it can be done?
Thanks
In reply to ruchi_puri2001:
What do you mean by unique? With respect to what other numbers?
If you want to generate a random number that does not match a list other numbers, you can do
int pre_defined_array[] = {25,6,4}; // list to be excluded
rand int number;
constraint c_excluded { unique {number, pre_defined_array}; }
You could also do
constraint c_excluded { !(number inside {pre_defined_array}); }