Article ID: 000075459 Content Type: Troubleshooting Last Reviewed: 09/11/2012

Are floating point constants compiled as single precision or double precision when the floating point custom instruction is used ?

Environment

  • Floating Point
  • BUILT IN - ARTICLE INTRO SECOND COMPONENT
    Description

    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
    * FP CI hardware will not be used for the double precision operation

    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

    Related Products

    This article applies to 1 products

    Intel® Programmable Devices