|
When I used
$random(seed) the seed value also changing for repeated calls. But for $urandom(seed)
why seed value is not changing. I am using questasim 6.2b. See the program
below. module
Tb(); integer
numr,numu,seedr,seedu,i,j; initial begin seedr =
2;seedu =
2;numr =
10;numu =
10; for(j = 0;j<2
;j=j+1) begin $display("
seed for urandom = %d seed for random = %d ",seedu,seedr); for(i =
0;i < 6; i=i+1) begin $display("Iteration
%d",i); numu =
$urandom(seedu) % 10; numr =
$random(seedr) % 10; $write("|
seed(urandom) = %2d num(urandom)=%2d \nseed(random) = %2d num(random)=%2d
|\n",seedu,numu,seedr,numr); end display("
"); end end endmodule OUTPUT: # seed for urandom
= 2 seed for random = 2 # Iteration
0 # | seed(urandom) = 2
num(urandom)= 7 # seed(random) = 138139
num(random)=-8 | # Iteration
1 # | seed(urandom) = 2
num(urandom)= 7 # seed(random) =
951188000 num(random)=-5 | # Iteration
2 # | seed(urandom) = 2
num(urandom)= 7 # seed(random) =
1784212385 num(random)=-6 | # Iteration
3 # | seed(urandom) = 2
num(urandom)= 7 # seed(random) =
-1731404562 num(random)= 5 | # Iteration
4 # | seed(urandom) = 2
num(urandom)= 7 # seed(random) =
-1607270249 num(random)= 0 | # Iteration
5 # | seed(urandom) = 2
num(urandom)= 7 # seed(random) =
-529128468 num(random)= 8 |
If u observe the
output, when I used the $random(seed) function the internal seed value and
number is also automatically changing. But with $urandom the seed value is not
changing, so number is also not changing. Can u get back to me how I can use
seed with $urandom. |