Inside constraint

randc bit [4:0] wb_adr_i;
constraint adr_range{
wb_adr_i inside{0,4,12,16,20,24};}

Through this constraint only the values mentioned inside should be selected ie 0,4,12,16,20,24
The display in transcript is showing address values to be 10 and 18 also while 20 and 24 are not seen even once.
Why 10 and 18 are also coming. Can anyone explain

In reply to rakhimittal:

Constraint code seems perfect. Please check whether the display is in hex format. `h10, h18. Display it in decimal format and check.

hi rakhi
As per my understanding variables declared as randc can not be constrained.please use rand and check.

regards
Rajiv

In reply to RKCH:

No Rajiv. The values {0,4,12,16,20,24} are constrainted atleast once in a cycle incase of “randc”. After repetition, it repeats the same values. Randc will work…

In reply to srvm:

rand
Variables declared with the rand keyword are standard random variables. Their values are uniformly distributed over their range.

randc
Variables declared with the randc keyword are random-cyclic variables that cycle through all the values in a random permutation of their declared range. Random-cyclic variables can only be reg or enumerated types, and are limited to a maximum size of 16 bits, so the maximum range for any randc variable is 0 to 65535.

The basic idea is that randc randomly iterates over all the values in the range and that no value is repeated within an iteration. When the iteration is finished, a new iteration is automatically started.

As you see from the defination of RANDC,constaints are not possible for randc variable,like the way you have applied.Please refer LRM for confirmation.

In reply to srvm:

Hi Rakhi,

I checked the above scenario and ran it in VCS/dve and observed that the randc variable does support the “inside” constraint.

The code was displaying the number mentioned within the constraint block.
Which simulator are you using?
I believe there is an issue in your display format specifier.
Do check it and let us know.

Regards,
Aswin.

In reply to RKCH:

“randc” variables are supported inside constraints. constraints reduce the solution space. “randc” will make sure that the all possible values are covered before repeating the sequence. All possible value means the values after applying constraints.

In reply to Naven8:

Yes Naven. Randc will cover all constrained values once, then go for repetition.