Converting real to integer...

K

kb33

Guest
Hi ,

Is there a "Synthesizable" way of converting a real number to an
integer and vice versa in Verilog?

Thanks
kb33
 
Do you have a synthesis tool that will even accept reals at all? That
would be the first requirement.
 
kb33 wrote:
Is there a "Synthesizable" way of converting a real number to an
integer and vice versa in Verilog?
Not sure if this is what you mean, but real numbers are typically
represented in digital hardware as a mantissa and an exponent. The
mantissa is the integer part, and the exponent is a small integer that
essentially tells you how many bit positions to shift the mantissa to
obtain an approximate fixed point representation.

Some of the device vendors have free math designs, and OpenCores at
http://www.opencores.org/ has quite a bit of free material.

-- Ron
 
Hello,

I think you are trying to make a digitally-synthesizable model from a
analog behavioral description, because in practice real numbers are
mostly used for analog modelling.

There is a trick I have done. It works, but consumes hardware.

Generate a list of samples, which shows the range of your input real
variable. A real number is 64 bit.

64'hfea21ffffff.... // for +0.01
64'hfeaa45dd.. // for +0.02
etc..

now apply this list to your design. Your design must produce output,
also as a list.
Save it like the previous list.

Now create a case statement from both files. For each input value (from
input file), there must be another output value (from output file).
Synthesize this statement into a Verilog netlist.

The less resolution you have, the less bits you need in real number,
because a resolution of 0.005 consumes mores bits in a real number than
a resolution of 0.5. The less resolution, the less synthesizable
hardware (the less logic depth).

Your trade-off is hardware versus resolution.

Please note that it is not a LUT, it is a kind of multiplexer logic
with high depth.
It is mostly practically impossible/very difficult to create LUTs for
analog modelling.
In other words, an analog model can be modelled with a very complex
digital hardware.

Hope this helps.
Utku.
 

Welcome to EDABoard.com

Sponsor

Back
Top