jeudi 1 février 2018

Should `$srandom` apply to seed for `$urandom_range`?

Using ModelSim it looks like the seed random call with $srandom does not apply to subsequent random value generation with $urandom_range.

Running the process:

initial
  begin
  $srandom(42);
  $display("1: %0d, %0d, %0d", $urandom_range(1, 10), $urandom_range(1, 10), $urandom_range(1, 10));
  $srandom(42);
  $display("2: %0d, %0d, %0d", $urandom_range(1, 10), $urandom_range(1, 10), $urandom_range(1, 10));
  $srandom(42);
  $display("3: %0d, %0d, %0d", $urandom_range(1, 10), $urandom_range(1, 10), $urandom_range(1, 10));
  end

the output is:

# 1: 3, 1, 7
# 2: 9, 7, 2
# 3: 6, 4, 8

However, I had expected that line 1, 2 and 3 where identical, since $srandom was called be fore with same seed value.

Why are the generated values not the same?




Aucun commentaire:

Enregistrer un commentaire