C. floating point custom instructions, Appendix c. floating point custom instructions – Altera Nios II Custom User Manual
Page 47

January 2011
Altera Corporation
Nios II Custom Instruction User Guide
C. Floating Point Custom Instructions
If you add a floating point custom instruction to your system, conflicts could arise in
the software build process. This appendix describes how to handle these conflicts.
Both Qsys and SOPC Builder offer a predefined Floating Point Hardware component
that you can add to your system. When you add this component to your system, a
parameter editor displays, and you can turn on an option to include a floating point
divider. The parameter editor notifies you that the component generates
single-precision floating point hardware.
When you add the floating point custom instruction to your system and run the
software build process, flags are added to your
nios2-elf-gcc
command line. These
flags specify the opcode extensions of the custom instructions that are called by the
software and select the appropriate library.
One of the following two flags appears:
■
-mcustom-fpu-cfg=60-1
■
-mcustom-fpu-cfg=60-2
The flag value
60-1
indicates your system does not include a custom instruction
floating point divider, and the flag value
60-2
indicates your system includes a
custom instruction floating point divider.
The
-mcustom-fpu-cfg
flags forces the use of single-precision constants. To allow
double-precision constants, you must remove the
-mcustom-fpu-cfg
flag and replace
it with different individual compiler flags, depending on the flag value.
To enable double-precision floating point constants, follow one of these steps:
■
Replace the command-line option string
-mcustom-fpu-cfg=60-1
with the
following command-line option string:
-mcustom-fmuls=252,-mcustom-fadds=253,-mcustom-fsubs=254
■
Replace the command-line option string
-mcustom-fpu-cfg=60-2
with the
following command-line option string:
-mcustom-fmuls=252,-mcustom-fadds=253,-mcustom-fsubs=254,-mcustom-fdivs=255
1
Change the flags only if required. Replacing the
-mcustom-fpu-cfg
flag disables
floating point custom instruction support in your library calls, forcing the system to
use the emulated or slower version of the instruction instead.