Declare the
hls_float Data Type
hls_float
Data TypeThe
hls_float.hpp
header file provides support for arbitraryprecision floatingpoint numbers. The floatingpoint representation for
hls_float
data types adopts the same data layout as the IEEE 754 floatingpoint representation.
An
hls_float
variable carries an explicit sign bit and an arbitrary number of bits for the exponent and mantissa. Due to the differences in the internal math implementations and rounding errors, the results from
hls_float
operations might not always be bitaccurate compared to those produced by C++ native floatingpoint types with the same exponent and mantissa bit widths.
Perform the following steps to declare the
hls_float
data type:
 Include thehls_float.hppheader file as follows:#include <sycl/ext/intel/ac_types/hls_float.hpp>
 Declare yourhls_floatvariables as follows:ihc::hls_float<exponent_width, mantissa_width[,rounding_mode]>Where, the template attributes are defined as follows:
 : The bitwidth of the exponent and mantissa of the floatingpoint variable.,exponent_widthmantissa_widthThehls_float.hppheader file also provides aliases to declarebfloat16andbfloat19data types directly. Thehls_floatdata type supports the followingcombinations:exponent_width,mantissa_widthExponent and MantissaWidth Combinations Supported by thehls_floatData Type5, 108, 78, 108, 178, 238, 2610, 3511, 4411, 5215, 63Some of these width combinations map to some commonly used floatingpoint formats, as listed in the following table:Exponent and MantissaWidth Setting for Various Floatingpoint FormatsFloatingpoint Formatexponent_width,mantissa_widthSettingIEEE 754 halfprecision (binary16)5, 10bfloat16^{}8, 7bfloat198,10IEEE 754 singleprecision (binary32)8. 23IEEE 754 doubleprecision (binary64)11, 5280bit extended precision15, 63
 : Optional parameter to specify the IEEE 754 rounding mode used when converting between data types. Set the rounding mode with one of the following values:rounding_modeRounding Mode ValuesRounding ModeDescriptionihc::fp_config::FP_Round::RNERound to the nearest, tie break to even.This rounding mode is more accurate (0.5 ULP) but requires more FPGA area.ihc::fp_config::FP_Round::RZERORound towards zero.This rounding mode is less accurate (1 ULP) and requires less FPGA area.If you do not set therounding_modeparameter, theihc::FP_Round::RNErounding mode is used by default.
Math Functions Supported by
hls_float Data Type
hls_float
Data TypeThe
hls_float
data type supports all overloaded math operators and a limited set of the math functions provided by the
Intel® oneAPI
. For some math operators, you can control the output's precision by using templated versions of the functions.
DPC++/C++
CompilerDue to the differences in the internal math implementations and rounding errors, the results from
hls_float
operations might not always be bitaccurate when compared to those produced by C++ native floatingpoint types with the same exponent and mantissabit widths. However, these results are validated against the infinitely accurate results.
The following additional math functions are supported through the
hls_float_math.hpp
header file:
Function Type
 Math Function
 Comment


Exponential and logarithmic functions

 Supported only for
hls_float data types with exponent width less than or equal to 15 bits and mantissa width less than or equal to 63 bits.

 Supported only for
hls_float data types with exponent width less than or equal to 11 bits and mantissa width less than or equal to 52 bits.
 
Advanced functions

 
Power functions

 
Trigonometric functions

