Seed Number - muneeb-mbytes/computerArchitectureCourse GitHub Wiki

SEED NUMBER

  • Seed number is the value given while randomization saying that for particular seed the values of randomize variables should not change.

  • No matter how many times you compile and run the file ,same random values are given .

There are 2 ways to set the random seed number

  1. Pass the seed into the first $urandom(seed) or $random(seed) call.

  2. Using the simulator's command-line.

    • In case of Mentor Graphics Questa it is -sv_seed

    • In case of Synopsys VCS this is +ntb_random_seed

Example:

module ran_seed;
integer d;
bit [5:0] e;
initial begin   
  repeat(3)begin
    d = $random(25); // assign seed value 
    e = $urandom(5); // assign seed value 
    $display(" $random(seed) - assign some seed value, it will display 32 bit ");
    $display ("signed random value for the given seed value ");
    $display ("d = $random(25) - Seed value =25");
    $display ("Random value of d = %0d",d );
    $display ("---------------------------------------------------------------------------");

    $display ("$urandom(seed) - assign the seed value ");
    $display ("unsigned random value for the given seed value ");
    $display ("e = $urandom(5) - Seed value = 5;");
    $display ("Random value of e = %0d", e);
    $display ("-----------------------------------------------------------------------------");    
  end 
end                                   
endmodule

Output:

Screenshot 2023-12-14 112353

⚠️ **GitHub.com Fallback** ⚠️