Visible to Intel only — GUID: lro1432139592968
Ixiasoft
Visible to Intel only — GUID: lro1432139592968
Ixiasoft
6.6.2. Floating Point Hardware 2 Conversions
The FPH2 component provides functions for conversion between signed integer types (C short, int and long types) and 32-bit single-precision floating point types (C float type). The Nios II GCC compiler infers these hardware functions when compiled code converts data between these types, for example in C casting.
The FPH2 component does not provide functions for conversion between unsigned integer types and floating point. When converting between unsigned integer types and float types, the compiler implements software emulation. Therefore conversion to and from unsigned integers is much slower than conversion to and from signed integers.
If you do not need the extra range of positive values obtained when converting a float to an unsigned integer directly, you can use the FPH2 and avoid using the software emulation if you modify your C code to first cast the float type to an int type or long type and then cast to the desired unsigned integer type.
float f;
unsigned int s = (unsigned int)f; // Software emulation
float f;
unsigned int s = (unsigned int)(int)f; // FPH2
- fixsi
- round
The round operation performs Nearest Rounding (tie-rounds-away) when converting a float to a signed integer. For example, round converts 4.8 to 5 and -1.5 to -2. Software can invoke the round operation by calling the custom instruction directly, or by using the #define provided in system.h, which replaces the newlib lroundf() function.