By default, when the custom instruction is used, floating point constants are compiled as single precision and single precision floating point operations are implemented in hardware. The following workarounds will force floating point constants to be compiled as double precision and double precision floating point operations are implemented in software.
You can use either of the following workarounds :
Option 1 - Modify your software by adding the postfix "L" to double precision floating point constants to ensure the constants do not get converted to single precision.
The following table shows example code and floating point custom instruction hardware usage, precision and whether the implementation is in hardware or software.
Example Code | FP CI Usage | Precision | Implementation |
b= a * 4.67 | Yes | Single | Hardware |
b = a * 4.67 | No | Double | Software |
b = a * 4.67f | Yes | Single | Hardware |
b = a * 4.67f | No | Single | Software |
b = a * 4.67L | don't care* | Double | Software |
Option 2 - In public.mk , manually remove the -mcustom-fpu-config flag and replace with the individual compiler flags, but omit the -fsingle-precision-constant flag.
"-mcustom-fpu-config=60-1" to "-mcustom-fmuls=252 –mcustom-fadds=253 –mcustom-fsubs=254" or
"-mcustom-fpu-config=60-2" to "-mcustom-fmuls=252 –mcustom-fadds=253 –mcustom-fsubs=254 –mcustom-divs=255"
Please note that the difference between 60-1 and 60-2 is that 60-1 does not have the –mcustom-divs flag.
For further details, refer to Appendix D in http://www.altera.com/literature/ug/ug_nios2_custom_instruction.pdf