Nios® V Processor Reference Manual

ID 683632
Date 1/27/2025
Public
Document Table of Contents

4.3.4.2. Floating Point Operations

The table below provides a detailed summary of the FPU operations.
Table 93.  Floating Point Operation Summary
Category Operation Cycles2 Result Subnormal Rounding3 GCC Inference
Arithmetic FDIV.S 14 a ÷ b Flush-to-0 RNE a / b
FSUB.S 1 a - b Flush-to-0 RNE a - b
FADD.S 1 a + b Flush-to-0 RNE a + b
FMUL.S 2 a x b Flush-to-0 RNE a * b
FSQRT.S 12 √a Flush-to-0 Faithful 4 sqrt(a)
FMIN.S 2 (a < b) ? a : b Supported RNE fminf()
FMAX.S 2 (a < b) ? b : a Supported RNE fmaxf()
Fused Arithmetic5 FMADD.S 3 (a x b) + c Flush-to-0 RNE (a * b) + c
FMSUB.S 3 (a x b) – c Flush-to-0 RNE (a * b) - c
FNMSUB.S 3 -(a x b) + c Flush-to-0 RNE -(a * b) + c
FNMADD.S 3 -(a x b) - c Flush-to-0 RNE -(a * b) - c
Conversion FCVT.S.W / FCVT.S.WU 3 int_to_float(a) Supported None Casting
FCVT.W.S / FCVT.WU.S 3 float_to_int(a) Supported Round towards Zero Casting
Round to Nearest, ties to Max Magnitude roundf(a)
Compare FLT.S 1 (a < b) ? 1 : 0 Flush-to-0 RNE a < b
FLE.S 1 (a ≤ b) ? 1 : 0 Flush-to-0 RNE a <= b
FEQ.S 1 (a = b) ? 1 : 0 Flush-to-0 RNE a == b
Sign Injection FSGNJN.S (FNEG.S) 1 -a Supported RNE -a
FSGNJX.S (FABS.S) 1 |a| Supported RNE fabsf(a)
Classification FCLASS.S 2 Refer to topic Floating Point Classification. Supported None fpclassify(a)
Note: Assume a, b, and c as single-precision floating point values. Nios® V Processor Fused Arithmetic has a rounding stage between the multiplier and addition.
The following list describes the header in the table above:
  • Operation —Provides the name of the floating-point operation. The names match the names of the corresponding RISC-V floating-point instructions.
  • Cycle —Specifies the number of cycles it takes to execute the instruction.
  • Result—Describes the computation performed by the operation.
  • Subnormal—Describes how the operation treats subnormal inputs and subnormal outputs. Subnormals are numbers with a magnitude less than approximately 1.17549435082e-38.
  • Rounding —Describes how the FPU rounds the result.
  • GCC Inference—Shows the C code from which GCC infers the instruction operation.

When optimizing a Floating Point Unit (FPU) within a processor, the FSQRT (floating-point square root) and FDIV (floating-point division) operations are critical components. Because of their complexity and longer execution time, they can influence the maximum frequency (Fmax) of the FPU. Refer to the following guidelines to help you decide whether to enable or disable the FSQRT and FDIV.

Table 94.  Recommendations to Enable or Disable the FSQRT and FDIV
Action Guidelines
Enable Enable the FQSRT and FDIV:
  • If your application frequently performs floating-point square root and floating-point division calculations
  • To prioritize the number of instructions executed per cycle
Disable Disable the FQSRT and FDIV:
  • If your application rarely or never uses floating-point square root and floating-point division calculations
  • To prioritize logic utilization and achieve a higher Fmax
  • If you're using the Nios® V processor in a MAX® 10 FPGA

In summary, deciding whether to enable or disable FSQRT and FDIV in a Floating Point Unit (FPU) is a choice between two main goals. You can aim for a higher maximum frequency (Fmax) and lower logic usage, or you can focus on improving performance for floating-point operations. This decision should depend on the specific needs and limits of your application.

2 Preliminary results.
3 Round-to-Nearest, ties to Even (RNE).
4 Faithful rounding has a maximum error of 1 Unit of Least Precision (ULP) as compared to the 0.5 ULP in RNE. Faithful rounding is employed to save area and reduce the latency of FSQRT.S.
5 GCC toolchain infers Fused Arithmetic when the optimization level is -O3 or higher.