FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > Verilog

Verilog comp.lang.verilog newsgroup / usenet

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-26-2004, 07:28 PM
FGreen
Guest
 
Posts: n/a
Default Random number generation in Windows - how to use wall clock?

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?

Of course, I'll save/print the seed value so I can reproduce the
problem.

Thank you.
Reply With Quote
  #2 (permalink)  
Old 10-26-2004, 08:18 PM
Stephen Williams
Guest
 
Posts: n/a
Default Re: Random number generation in Windows - how to use wall clock?

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.


--
Steve Williams "The woods are lovely, dark and deep.
steve at icarus.com But I have promises to keep,
http://www.icarus.com and lines to code before I sleep,
http://www.picturel.com And lines to code before I sleep."

Reply With Quote
  #3 (permalink)  
Old 10-27-2004, 03:40 PM
FGreen
Guest
 
Posts: n/a
Default Re: Random number generation in Windows - how to use wall clock?

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?
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
comp.unix.cray,comp.windows.garnet,comp.os.ms-windows.programmer.winhelp,comp.os.ms-windows.networking.tcp-ip,comp.lang.verilog . Verilog 0 06-19-2004 09:15 AM
Test of Random Number for Icarus Verilog Stephen Williams Verilog 1 06-10-2004 03:23 PM
psedo random number generator krs Verilog 15 05-02-2004 08:57 AM
sdf generation primetime kris Verilog 2 02-02-2004 04:11 PM
sdf generation from dpsf kris Verilog 0 01-27-2004 03:04 AM


All times are GMT +1. The time now is 07:22 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved