$urandom_range() will only return a 32 bit unsigned integer. If you want to get a larger value, you will need to make several calls to the $urandom_range() function.
The problem is the argument types and return value type of $urandom_range are 32-bit unsigned ints. I can’t explain the results you are getting, but the proper way to code this would be
randomize(val) with { val inside {[0,96’hffffffffffffffffffffffff]};};
Thanks for your answers.
In fact I see now that my code was “correct”. It generates random 96 bits value but the distribution is not got. It was 50% 0x0 and 0xFF…F and 50% real random value.
In anyway I will use the solution of cgales to fix the distribution.
initial begin
obj = new();
repeat(10) begin
if(obj.randomize with { val inside {[0,96’hffffffffffffff];}};) begin
$display(“randomized value val = %0d”,val);
end
end
end
now even if you run for 10 different seeds you will see the same value.
every tool takes a different seed for new simulation, right? I even tried passing a different time as runtime option - but result stays same 2. did you tried simulating the code?
No, unless you pass the random seed run-time switch. Have you checked the seed used for each run ? Unless you pass the run-time switch, the seed remains the same
It’s possible that different seeds give the same output
Yes, I tested it on EDA. I do observe both values on each tool ( depending on seed )
It is exactly doing what it should do because the randomization has to be repeatable. If the randomization would generate always differnt values you could never debug a failing testcase.