Folks,
I have been beating my head over this for over a day now and am just exhausted looking at this code. What I basically want to do is to split a number into 1:63 chunks. This is what I am doing.
int unsigned pld_size;
// var: sample_size
rand int unsigned sample_size[];
constraint pc_rgx_stim_flow_base_sample_size_cnstr {
sample_size.size() >= 1;
sample_size.size() <= 63;
sample_size.sum() == pld_size;
foreach (sample_size[i]) {
sample_size[i] >= 1;
sample_size[i] <= pld_size;
}
}
function gen_payload_val();
for (int i=0;i<20;i++) begin
pld_size = $urandom_range(10,100);
randomize(sample_size);
end
endfunction
I ensured that
(1) Everything is unsigned and no negative numbers screw up the math
(2) I also made sure that none of the individual elements of the array end up being negative numbers
(3) To bound the sum(), I made sure that the sum does not exceed the pld_size too
Here is what I observe - For the first 5 or 6 iterations(sometimes it fails after the 8th iteration), things are fine. But after a few iterations, the randomization fails and I get the following :
ncsim: *W,SVRNDF (base.sv,156|12): The randomize method call failed. The unique id of the failed randomize call is 4569.
Observed simulation time : 403501 PS + 16
ncsim: *W,RNDOCS: These constraints contribute to the set of conflicting constraints:
sample_size.sum() == pld_size; (base.sv,217)
ncsim: *W,RNDOCS: These variables contribute to the set of conflicting constraints:
state variables:
sample_size[1] (1) base.sv, 369] rand_mode(0)
pld_size (10) [base.sv, 365]
I don’t understand why there is a rand_mode(0) on the sample_size. I am not turning off any constraints anywhere. So what is wrong with my constraints.