Nios II Custom Instruction User Guide

ID 683242
Date 4/27/2020
Document Table of Contents

7.6. Hardware Divide Considerations with FPH1

The FPH1 division hardware requires more resources than the other instructions, so you might opt to omit it if your Nios II application does not make heavy use of floating point division.

In some cases, you can rewrite your code to minimize or even eliminate divide operations. For example, if your algorithm requires division by a constant value, you can precalculate its inverse and use a multiply operation in the speed-critical section of your code.

The table below indicates which math library functions use floating point, and of those, which use floating point division. If a function uses floating point, it runs faster with floating point hardware. If a function uses floating point division, it runs even faster with floating point division hardware.

Table 16.  Math Library Floating Point Usage

Math Function

Uses Floating Point

Uses Floating Point Division

acos() Yes Yes
asin() Yes Yes
atan() Yes Yes
atan2() Yes Yes
cos() Yes No
cosh() Yes Yes
sin() Yes No
sinh() Yes Yes
tan() Yes Yes
tanh() Yes Yes
exp() Yes Yes
frexp() Yes No
ldexp() Yes No
log() Yes Yes
log10() Yes Yes
modf() Yes No
pow() Yes Yes
sqrt() Yes Yes
ceil() Yes No
fabs() No No
floor() Yes No
fmod() Yes Yes

When you omit the FPH1 divide instruction, the Nios II SBT for Eclipse implements floating point division in software.