floating number

D

Dkthechamp

Hi,

I am implementing a random number generator and need to muliply a
std_logic_vector by 2.3283064365e-10 value. Please suggest a
synthesizable method to do this multiplications.

Tools used:
Simulation: Modelsim 6.2
Synthesize: Xilinx ISE Web pack.

Thanks,
Deepak GUPTA
 
M

Mike Treseler

Dkthechamp said:
I am implementing a random number generator and need to muliply a
std_logic_vector by 2.3283064365e-10 value. Please suggest a
synthesizable method to do this multiplications.

There are easier ways to make a pseudo-random sequence,
but to answer your question, let's click up a calculator.

That's a pretty small fraction, so let's scale 1.0
as the roll-over count of a 64 bit register.
So for your example, the vector version of your fraction
would be 2**64 * 2.3283064365e-10 = 4294967295.9
Round off to an unsigned value: 4294967296 = x"0000040000000000"
Hmmm. That's a nice fraction.
Feels like a homework problem.
Unsigned multiplication is synthesizable, but you
will have to keep track of the scaling/decimal point manually.
Note that a multiply by a power of two is just a shift.

-- Mike Treseler
 
P

Paul Uiterlinden

Mike said:
There are easier ways to make a pseudo-random sequence,
but to answer your question, let's click up a calculator.

That's a pretty small fraction, so let's scale 1.0
as the roll-over count of a 64 bit register.
So for your example, the vector version of your fraction
would be 2**64 * 2.3283064365e-10 = 4294967295.9
Round off to an unsigned value: 4294967296 = x"0000040000000000"
Hmmm. That's a nice fraction.

Nice catch!

However, your conversion to hex is not correct, it should be 0x100000000
(2**32 decimal)

Using bc on the Unix command line:
% bc -l
obase=16
4294967296
100000000
 
M

Mike Treseler

Paul said:
Nice catch!
However, your conversion to hex is not correct, it should be 0x100000000

Nice catch also.
But now the correct answer is revealed :)

-- Mike Treseler
 

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

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top