Knowledge Base Article

Why do I get incorrect results when using the ALTFP_CONVERT megacore to perform floating-point to fixed-point conversions?

Description

Due to a problem with the Quartus® II software, if the input of the ALTFP_CONVER is smaller than the smallest representable number for the chosen output format, the output will give erroneous results.

For example, when doing a floating to fixed point conversion using 32.16 (that is 32 bit width of which 16 bits are the fraction), the smallest representable number is -1.5258789E-5 (0xb7800000).  If one inputs

-0.00000762939453125 (0xb7000000), the result will show -2147483648 (0xcf000000) which is incorrect.

Resolution

Altera recommends to use the new ALTERA_FP_FUNCTIONS megacore for future designs, where the functionality is correct.

Otherwise you will need to range check your inputs an subsitute a full scale output whenever the input falls below the smallest representable value.

This will not be fixed in a future version of Quartus.

Updated 3 months ago
Version 2.0
No CommentsBe the first to comment