Scaling data

F

FPGA

Hello All,

I am using the UNIFORM procedure in VHDL to generate random numbers.
UNIFORM generates random numbers in the range 0.1 to 0.99999. I wish
to generate random signed and unsigned numbers of variable
widths(integer range). I would like to get some ideas on how I should
scale this data? Right now, when i convert the real output from real
to integer to signed, it just gives me an output of wither 0 or 1 .
Your comments would be appreciated

Thank you
 
C

Chris Maryan

Hello All,

I am using the UNIFORM procedure in VHDL to generate random numbers.
UNIFORM generates random numbers in the range 0.1 to 0.99999. I wish
to generate random signed and unsigned numbers of variable
widths(integer range). I would like to get some ideas on how I should
scale this data? Right now, when i convert the real output from real
to integer to signed, it just gives me an output of wither 0 or 1 .
Your comments would be appreciated

Thank you

Try multiplying it by a scaling factor before you convert it to
integer.
 
S

sudhi

Try multiplying it by a scaling factor before you convert it to
integer.

Let the real random number you generated be "my_random_number". Let
the random integer (my_random_integer) you want to generate be in the
range "my_range_low" to "my_range_high". Then after using UNIFORM on
"my_random_number", you would do

my_random_integer <= my_range_low + my_random_number*(my_range_high -
my_range_low)

- Sudheendra Kadri
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top