Question on $realtobits and $bitstoreal.

  • Thread starter Krishna Praveen
  • Start date
K

Krishna Praveen

Guest
Hello Everyone,

I have a question on "real" datatypes in verilog. I understand (please
correct me if I am wrong) that no synthesizer supports $realtobits and
$bitstoreal functions. So how is this problem usually overcome? Can I
write a synthesizable function (task-function kind of thing) in place
of these? I want all computation to be in fixed-point (and not
floating point) as I am doing a FPGA implementation for a DSP module.

Thank You!!
 
Krishna Praveen wrote:

I have a question on "real" datatypes in verilog. I understand (please
correct me if I am wrong) that no synthesizer supports $realtobits and
$bitstoreal functions. So how is this problem usually overcome? Can I
write a synthesizable function (task-function kind of thing) in place
of these? I want all computation to be in fixed-point (and not
floating point) as I am doing a FPGA implementation for a DSP module.
If all computation is in fixed point there should be no need for
$bitstoreal or $realtobits.

You might work with scaled fixed point values. (Where the binary
point is not immediately to the right of the ones digit.)

In most cases, the constants are supplied externally, so you don't
have to worry about them at all. If they need to be supplied in
verilog (initialize a ROM, for example) you should use verilog
operations to generate the appropriate constant expression.

If, for example, you want pi with 10 bits after the binary
point multiply 3.1415926*1024 and round to the nearest integer.

You can do that on a calculator and supply the result (3217)
to verilog, do it in verilog floating point but convert
the result (the synthesizer should do constant expression
evaluation), or use integer arithmetic (314159*1024+50000)/100000

Sometimes you have to be a little careful to avoid overflow, though.
(31415926*8+39062)/78125 rounded to 10 bits after the binary point.

-- glen
 

Welcome to EDABoard.com

Sponsor

Back
Top