how to use random in verilog

L

Lung Sheng

Guest
as title
i write a task to generate random information.
but i find if i don't use seed, then i have the same
random value when program re-retry to the same task.
Hence i need to set seed = $time

Is any method to fix this problem without using seed

thanks a lot
Lung Sheng
 
This is how $random task works. Why is that you don't like setting a seed?

Jim Wu
jimwu88NOOOSPAM@yahoo.com
http://www.geocities.com/jimwu88/chips/index.html

"Lung Sheng" <br882571@cs.nthu.edu.tw> wrote in message
news:biheik$f73$1@thccy25.nthu.edu.tw...
as title
i write a task to generate random information.
but i find if i don't use seed, then i have the same
random value when program re-retry to the same task.
Hence i need to set seed = $time

Is any method to fix this problem without using seed

thanks a lot
Lung Sheng
 
"Lung Sheng" <br882571@cs.nthu.edu.tw> wrote in message news:<biheik$f73$1@thccy25.nthu.edu.tw>...
as title
i write a task to generate random information.
but i find if i don't use seed, then i have the same
random value when program re-retry to the same task.
Hence i need to set seed = $time

Is any method to fix this problem without using seed

thanks a lot
Lung Sheng
There is no problem to fix here as this is the way $random
works.

BTW, using $time as seed does not really fix your problem
if you want to use a different sequence of randoms each
time you run the simulation. This is because $time will
be the same every time you invoke $random($time) at the
same simulation time resulting in the same sequence.
People usually use the wall clock time or some variation
of it as seed. The important point to note here is that
you should always save the seed so that sequence can be
reproduced later.

HTH.
- Swapnajit.

=-=-= 100% pure Verilog PLI - go, get it ! =-=-=
Principles of Verilog PLI -By- Swapnajit Mittra
Kluwer Academic Publishers. ISBN: 0-7923-8477-6
http://www.angelfire.com/ca/verilog/
 

Welcome to EDABoard.com

Sponsor

Back
Top