The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl
Design Languages >> Verilog-AMS >> How to chose seed?
https://designers-guide.org/forum/YaBB.pl?num=1163658055

Message started by neoflash on Nov 15th, 2006, 10:20pm

Title: How to chose seed?
Post by neoflash on Nov 15th, 2006, 10:20pm

How we choose the value of seed, of random number generator and how it affects?
Does this number play any role, besides specify a determistic start point? What if I chose seed=111?

Title: Re: How to chose seed?
Post by neoflash on Nov 15th, 2006, 10:21pm

attach the sample usage here: dT = jitter*$rdist_normal(seed,0,1);

Title: Re: How to chose seed?
Post by Geoffrey_Coram on Nov 16th, 2006, 11:24am

As far as I know, it's just a start point in the sequence of pseudo-random numbers.

Title: Re: How to chose seed?
Post by neoflash on Nov 16th, 2006, 5:03pm

I have attached one sample code from this website, why author chose seed=286, not other number?

module osc2 (out);

output out; voltage out;                  // output signal
parameter real freq=1 from (0:inf);            // output frequency
parameter real vl=-1;                        // high output voltage
parameter real vh=1;                        // low output voltage
parameter real tt=0.01/freq from (0:inf);      // transition time of output
parameter real jitter=0 from [0:0.1/freq);      // white period jitter
integer n, seed;
real next, dT;

analog begin
   @(initial_step) begin
     seed = 286;
     next = 0.5/freq + $abstime;
   end
   @(timer(next)) begin
     n = !n;
     dT = jitter*$rdist_normal(seed,0,1);
     next = next + 0.5/freq + `M_SQRT1_2*dT;
   end
   V(out) <+ transition(n ? vh : vl, 0, tt);
end
endmodule

Title: Re: How to chose seed?
Post by Ken Kundert on Nov 16th, 2006, 7:20pm

It was a completely arbitrary choice. The only criteria I used was to use a different seed for each rdist function present in the system. If you give the same seed to two different rdist functions they will produce an identical sequence of random numbers.

-Ken

Title: Re: How to chose seed?
Post by Geoffrey_Coram on Nov 17th, 2006, 5:54am


Ken Kundert wrote on Nov 16th, 2006, 7:20pm:
It was a completely arbitrary choice. The only criteria I used was to use a different seed for each rdist function present in the system. If you give the same seed to two different rdist functions they will produce an identical sequence of random numbers.


By "two different rdist functions" Ken does not mean to say that $rdist_normal() and $rdist_uniform will give the same sequence of random numbers.  I am fairly sure he meant "give the same seed to two different calls of the same rdist function":

Modifying the example:

integer n, seed, seed2;
real next, dT, dT2;

analog begin
 @(initial_step) begin
   seed = 286;
   seed2 = 286;
   next = 0.5/freq + $abstime;
 end
 @(timer(next)) begin
   n = !n;
   dT = jitter*$rdist_normal(seed,0,1);
   dT2 = jitter*$rdist_normal(seed2,0,1); // will have the same sequence of values as dT
  next = next + 0.5/freq + `M_SQRT1_2*dT;
 end
 V(out) <+ transition(n ? vh : vl, 0, tt);
end

dT2 will have the exact same sequence of random values as dT.  Also, seed and seed2 are changed by the $rdist function calls, and the sequence of their values will be the same.

I wonder: if you did
 rn1 = $rdist_normal(seed,0,1);
 rn2 = $rdist_uniform(seed2,-1,1);

will "seed" and "seed2" have the same sequence of (integer) values?  I guess you might or might not, since the LRM doesn't say.

-Geoffrey

The Designer's Guide Community Forum » Powered by YaBB 2.2.2!
YaBB © 2000-2008. All Rights Reserved.