Nios® V Processor Reference Manual

ID 683632
Date 10/07/2024
Public
Document Table of Contents

4.3.4.2. Floating Point Operations

The table below provides a detailed summary of the FPU operations.
Table 66.  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.
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.