I want to solve equation that have integer & floating point variables so I want to convert from floating point to fixed point .
Can any one help me?
Asked
Active
Viewed 1,972 times
2 Answers
4
Multiply by your scale factor, convert to integer, rescale. Done.
1
Assuming that you are using VHDL 2008's fixed_pkg and float_pkg, or the mostly backwards-compatible equivalents from http://www.vhdl.org/fphdl/, look at the to_ufixed, to_sfixed, and to_float functions which provide these conversions.
For example:
signal my_fixed : sfixed(15 downto -7);
signal my_float : float(5 downto -13);
...
my_fixed <= to_sfixed(my_float, 15, -7);

wjl
- 7,519
- 2
- 32
- 41