Nios II Custom Instruction User Guide

ID 683242
Date 4/27/2020
Public
Document Table of Contents
Give Feedback

6.4. Floating Point Hardware 2 Operations

The table below provides a detailed summary of the FPH2 operations. The values “a” and “b” are assumed to be single-precision floating point values. The following list provides detailed information about each column:
  • Operation 8—Provides the name of the floating point operation. The names match the names of the corresponding GCC floating point command-line options except for “round”, which has no GCC support.
  • N—Provides the 8-bit fixed custom instruction N value for the operation. FPH2 component uses fixed N values that occupy the top 32 Nios II custom instruction N values (224 to 255). The FPH1 also use fixed N values (252 to 255) and the FPH2 assign the same operations to those N values to maintain compatibility.
  • Cycle 9—Specifies the number of cycles it takes to execute the instruction. A combinatorial custom instruction takes 1 cycle. A multi-cycle custom instruction always requires at least 2 cycles. An N-cycle custom instruction has N-2 register stages inside the custom instruction because the Nios II registers the result from the custom instruction and also allows another cycle for g wire delays in the source operand bypass multiplexers. The Cycle column does not include the extra cycles (maximum of 2) required because the Nios II/f processor stalls the instruction following the multi-cycle custom instruction if that instruction uses the result within 2 cycles. These extra cycles are required because multi-cycle instructions are late-result instructions.
  • Result—Describes the computation performed by the operation.
  • Subnormal—Describes how the operation treats subnormal inputs and subnormal outputs.
  • Rounding 10—Describes how the FPH2 component rounds the result. The possible choices are Nearest, Truncation, Faithful, and none.
  • GCC Inference—Shows the C code from which GCC infers the custom instruction operation.
Table 15.  FPH2 Operation Summary
Operation N Cycles Result Subnormal Rounding GCC Inference
fdivs 255 16 a/b flush-to-0 Nearest a/b
fsubs 254 5 a-b flush-to-0 Faithful a-b
fadds 253 5 a+b flush-to-0 Faithful a+b
fmuls 252 4 a*b flush-to-0 Faithful a*b
fsqrts 251 8 sqrt(a) flush-to-0 Faithful sqrtf()
floatis 250 4 int_to_float(a) Does not apply Does not apply Casting
fixsi 249 2 float_to_int(a) flush-to-0 Truncation Casting
round 248 2 float_to_int(a) flush-to-0 Nearest lroundf()11
reserved 234 to 247 Undefined undefined      
fmins 233 1 (a<b) ? a : b supported None fminf()11
fmaxs 232 1 (a<b) ? b : a supported None fmaxf()11
fcmplts 231 1 (a<b) ? 1 : 0 supported None a<b
fcmples 230 1 (a≤b) ? 1 : 0 supported None a<=b
fcmpgts 229 1 (a>b) ? 1 : 0 supported None a>b
fcmpges 228 1 (a≥b) ? 1 : 0 supported None a>=b
fcmpeqs 227 1 (a=b) ? 1 : 0 supported None a==b
fcmpnes 226 1 (a≠b) ? 1 : 0 supported None a!=b
fnegs 225 1 -a supported None -a
fabss 224 1 |a| supported None fabsf()
8 For more information, refer to "-mcustom-<operation>".
9 For more information, refer to the Nios II Processor Reference Guide.
10 For more information, refer to "Rounding Schemes". A rounding of “none” means that the result does not need to be rounded.
11 Nios II GCC cannot reliably replace calls to these newlib floating point functions with the equivalent custom instruction. For information about using these functions, refer to "C Macros for round(), fmins(), and fmaxs()".