Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - Random Number Generation

 
Thread Tools Search this Thread
Old 03-13-2006, 04:58 PM   #1
Default Random Number Generation


Hello,

I am using the UNIFORM function <UNIFORM(seed1, seed2, rand)> in my
VHDL code to generate random numbers.

Whether the seed are initialised to a particular number or left
uninitialised, for both cases, same sequence of random number are
generated every time I restart the simulation.

I suppose if I could start from an unknown, random state (generate a
random seed at the start of simulation), I could avoid this repetition
problem. In other languages, I have seen time of the day (which is
w.r.t. some date in the past) being used for this purpose. Do you know
how I could do it in VHDL??

Thanks in advance.



dpi
  Reply With Quote
Old 03-13-2006, 06:20 PM   #2
Mike Treseler
 
Posts: n/a
Default Re: Random Number Generation
dpi wrote:

> I am using the UNIFORM function <UNIFORM(seed1, seed2, rand)> in my
> VHDL code to generate random numbers.
> Whether the seed are initialised to a particular number or left
> uninitialised, for both cases, same sequence of random number are
> generated every time I restart the simulation.


Yes, that's how it works.

> I suppose if I could start from an unknown, random state (generate a
> random seed at the start of simulation), I could avoid this repetition
> problem. In other languages, I have seen time of the day (which is
> w.r.t. some date in the past) being used for this purpose. Do you know
> how I could do it in VHDL??


Your vhdl testbench read the last seed values from a file,
then calculate and save different values.

-- Mike Treseler


Mike Treseler
  Reply With Quote
Old 03-13-2006, 07:34 PM   #3
Amal
 
Posts: n/a
Default Re: Random Number Generation
If you are using Modelsim, you can use the TCL build-in command rand()
to get a random number and use it as the seed. Or use [clock second]
or your own function to get a seed and pass it as a generic to your
VHDL.

quietly set seed1 [expr {int(1 + 2147483562*rand())}]; # [1,
2147483562]
quietly set seed2 [expr {int(1 + 2147483398*rand())}]; # [1,
2147483398]

quietly set options ""

eval vsim $options -GgSEED1=$seed1 -GgSEED2=$seed2
ClockErrorCorrection_tb

-- Amal



Amal
  Reply With Quote
Old 03-13-2006, 07:34 PM   #4
Amal
 
Posts: n/a
Default Re: Random Number Generation
If you are using Modelsim, you can use the TCL build-in command rand()
to get a random number and use it as the seed. Or use [clock second]
or your own function to get a seed and pass it as a generic to your
VHDL.

quietly set seed1 [expr {int(1 + 2147483562*rand())}]; # [1,
2147483562]
quietly set seed2 [expr {int(1 + 2147483398*rand())}]; # [1,
2147483398]

quietly set options ""

eval vsim $options -GgSEED1=$seed1 -GgSEED2=$seed2 top_tb

-- Amal



Amal
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with code for random number generation sandeep_sp7 Hardware 0 04-12-2007 04:59 PM
This is incredible! jc_ice DVD Video 1 08-13-2006 10:47 AM
As growth slows, Hollywood faces a DVD standoff. Allan DVD Video 0 07-11-2005 02:10 PM
Second Generation Blu-ray Products To Be Rolled Out At Year's End. Allan DVD Video 0 03-16-2005 10:18 AM
Re: 38,000 U.S. KILLED & WOUNDED IN IRAQ & dvd's JA DVD Video 0 03-06-2005 01:16 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46