Stephen Williams <
[email protected]> wrote in message news:<
[email protected] servers.com>...
> FGreen wrote:
> > I'm trying to generate random numbers in my test bench in the
> > following manner.
> >
> > for (i = 0; i < 10; i=i+1 ) begin
> > rand = $random($time);
> >
> > ...
> >
> > end
> >
> > The good thing is, I get a different 'rand' for each loop count, but
> > when I run the test the next time, I get the same set of 10 random
> > numbers. $display of $time shows that it's not the wall clock as in,
> > but the simulation clock (duh...).
> >
> > How do I get the wall clock in Windows environment for this?
> >
> > Or, is there a better way to get random numbers that'll differ from
> > one test run to next, as well as one loop count to another?
>
> Use a $plusargs value to initialize your seed register, then use
> whatever external means to wish to choose a seed.
Hi, thanks for the response.
My question actually is how to choose a seed externally.
I'm in running modelsim from the DOS prompt, and doing
%vsim +SEED='date' ... doesn't work.
integer rand_seed;
if (!($value$plusargs("SEED=%d", rand_seed))) begin
$display ("Setting rand_seed to default");
rand_seed = 0;
end
else begin
$display ("Using rand_seed = %d", rand_seed);
end
Returns Using rand_seed = 0
What am I doing wrong?