Hi,
Is there a reason why this code returns the same value in all its loop iterations ?
initial begin
repeat(1000) begin
int v = $urandom_range(400,0);
$display(v);
end
end
If I modify it to this code , then the value returned is different in each loop iteration :
initial begin
repeat(1000) begin
int v ;
v = $urandom_range(400,0);
$display(v);
end
end
nhp
2
In reply to karthikmaniv28:
The correct syntax is $urandom_range(min, max) the way you wanted;
In reply to karthikmaniv28:
The first example you wrote is illegal. It should have generated an error preventing the problem you just ran into.
See https://verificationacademy.com/forums/systemverilog/function-arguments-not-initializing-variable-inside-body#reply-54684
You need to change your code so that the call to $uramdom_range happens on each iteration of the loop as it does in the second example