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
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…
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.
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.
“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.