verilog changing random seed

12,993

You can change the seed using a flag like this:

irun -seed seed_number

Or you can use a random seed:

irun -seed random

I'm pretty sure every tool (Questa and VCS) has an option to do this. If you don't set a seed, it will default to 1.

Share:
12,993

Related videos on Youtube

Rudy01
Author by

Rudy01

Updated on June 04, 2022

Comments

  • Rudy01
    Rudy01 almost 2 years

    How do I change the seed for $urandom_range every time I am starting a new simulation. I tried so many things non worked.

    always@(posedge tb_rd_clkh)
      begin
        $random(9);
        tbo9_ready_toggle_q <= $urandom_range(0, 1);
      end
    
    • dave_59
      dave_59 almost 9 years
      What do you think $random(9); is supposed to mean?
    • dolphus333
      dolphus333 almost 9 years
      Are you asking how to get a different seed for each simulation?
  • Rudy01
    Rudy01 almost 9 years
    Thanks, but how come it is not working in always statement? I did the same thing like below, but it didn't work: always@(posedge tb_rd_clkh) begin seed <= 3; rand_gen <= $urandom(seed); tbo9_ready_toggle_q <= $urandom_range(0, 1); end
  • Emman
    Emman almost 9 years
    A different approach needs to be followed for always block, you can use the method mentioned in the updated answer