Visible to Intel only — GUID: skf1478551388209
Ixiasoft
Visible to Intel only — GUID: skf1478551388209
Ixiasoft
8. Arbitrary Precision Math Support
Some of these header files are based on the Algorithmic C (AC) data types that Mentor Graphics* provides under the Apache license. For more information about the Algorithmic C data types, refer to Mentor Graphics Algorithmic C (AC) Datatypes, which is available as a part of your Intel® HLS Compiler installation: <quartus_installdir>/hls/include/ref/ac_datatypes_ref.pdf.
The Intel® HLS Compiler also supports arbitrary-precision IEEE 754 compliant floating point data types that is not based on the AC data types.
Data Type | Intel Header File | Description |
---|---|---|
ac_int | HLS/ac_int.h | Arbitrary-width integer support
To learn more, review the following tutorials:
|
ac_fixed | HLS/ac_fixed.h | Arbitrary-precision fixed-point number support To learn more, review the tutorial: <quartus_installdir>/hls/examples/tutorials/ac_datatypes/ac_fixed_constructor |
HLS/ac_fixed_math.h | Support for some nonstandard math functions for arbitrary-precision fixed-point data types To learn more, review the tutorial: <quartus_installdir>/hls/examples/tutorials/ac_datatypes/ac_fixed_math_library |
|
ac_complex | HLS/ac_complex.h | Complex number support |
hls_float | HLS/hls_float.h | Arbitrary-precision floating-point number support |
HLS/hls_float_math.h | Support for commonly used exponential, logarithmic, power, and trigonometric functions.
To learn more, review the following tutorials:
|
- ac_fixed data type
Include the HLS/ac_fixed_math.h header file
- hls_float data type
Include the HLS/hls_float_math.h header file
Advantages of Arbitrary Precision Data Types
The arbitrary precision data types have the following advantages over using standard C/C++ data types in your components:
- You can achieve narrower data paths and processing elements for various operations in the circuit.
- The data types ensure that all operations are carried out in a size guaranteed not to lose any data. However, you can still lose data if you store data into a location where the data type is too narrow.
Limitations of AC Data Types
The AC data types have the following limitations:
- Multipliers are limited to generating 512-bit results.
- Dividers for ac_int data types are limited to a maximum of 128 bit unsigned or 127 bit signed.
- Dividers for ac_fixed data types are limited to a maximum of 64 bits (unsigned or signed).
- The FPGA-optimized header files provided by the Intel® HLS Compiler are not compatible with GCC or MSVC. When you use the Intel® HLS Compiler header files, you cannot use GCC or MSVC to compile your testbench. Both your component and testbench must be compiled with the Intel® HLS Compiler.
To compile AC data types with GCC or MSVC, use the reference AC data types headers also provided with he Intel® HLS Compiler. For details, see AC Data Types and Native Compilers.
- The bit_fill_hex utility function for ac_int data types is not supported on Cyclone® V devices.
Limitations of the Intel® HLS Compiler Arbitrary Precision Floating Point Data Type
- When you use the ihc_pown function, the exponent must be a signed type. If the exponent is an unsigned type, redefine the exponent to have a signed type and increase the bit width if needed.
If you use an unsigned type as the exponent, the results from the ihc_pown function are incorrect.
For example, the following code snippet generates incorrect results:// Sample Code: hls_float<8, 7> a = 2; ac_int<4, false> b = 12; … = ihc_pown(a , b); // !!! Produces incorrect result
The following code snippet generates correct results:// Workaround: hls_float<8, 7> a = 2; ac_int<5, true> b = 12; // Use a signed type for the exponent. // The bit width is increased from //4 bits to 5 bits … = ihc_pown(a , b); // Produces correct result
- Casting an hls_float datatype to an unsigned integer generates signed integer cast. Ensure that the hls_float value is cast into a signed integer that is large enough to contain the hls_float value being casted (for example, by using an ac_int datatype).
- Floating point optimization into constants performed for float and double data types is not done for the hls_float data type.
- A limited set of math functions is supported. For details, see Operators and Return Types Supported by the hls_float Data Type.
- The hls_float header files provided by the Intel® HLS Compiler are not compatible with GCC or Microsoft Visual Studio. When you use the Intel® HLS Compiler header files, you cannot use GCC or Microsoft Visual Studio to compile your testbench. Both your component and testbench must be compiled with the Intel® HLS Compiler. For details, refer to Compiler Interoperability.
- The high-level design reports do not show bit widths for the hls_float data type.
- Constant initialization works only with the round-towards-zero (RZERO) rounding mode.