Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Random Number Generation

Reply
Thread Tools

Random Number Generation

 
 
dpi
Guest
Posts: n/a
 
      03-13-2006
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.

 
Reply With Quote
 
 
 
 
Mike Treseler
Guest
Posts: n/a
 
      03-13-2006
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
 
Reply With Quote
 
 
 
 
Amal
Guest
Posts: n/a
 
      03-13-2006
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

 
Reply With Quote
 
Amal
Guest
Posts: n/a
 
      03-13-2006
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

 
Reply With Quote
 
vipinlal vipinlal is offline
Member
Join Date: Feb 2010
Posts: 39
 
      03-26-2010
The package you are using is not synthesizable.you can use this code instead:
vhdlguru.blogspot.com/2010/03/random-number-generator-in-vhdl.html
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Math.random() and Math.round(Math.random()) and Math.floor(Math.random()*2) VK Javascript 15 05-02-2010 03:43 PM
random.random(), random not defined!? globalrev Python 4 04-20-2008 08:12 AM
Need Help With Random Number Generation Between Upper and Lower Bound ANM Java 2 03-07-2004 07:18 AM
Random number generation in array Artyom C++ 5 02-08-2004 02:58 AM
random number generation and Monte Carlo simulation in C++ mescaline C++ 4 09-10-2003 09:01 PM



Advertisments