Intel® High Level Synthesis Compiler Pro Edition: Reference Manual

ID 683349
Date 12/04/2023
Public
Document Table of Contents
Give Feedback

8. Arbitrary Precision Math Support

The Intel® HLS Compiler Pro Edition supports a range of FPGA-optimized arbitrary-precision data types that are defined in header files that you can include in your designs.

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.

The Intel® HLS Compiler supports the following arbitrary precision data types:
Table 18.  Arbitrary Precision Data Types Supported by the Intel® HLS Compiler Pro Edition
Data Type Intel Header File Description
ac_int HLS/ac_int.h Arbitrary-width integer support
To learn more, review the following tutorials:
  • <quartus_installdir>/hls/examples/tutorials/ac_datatypes/ac_int_basic_ops
  • <quartus_installdir>/hls/examples/tutorials/ac_datatypes/ac_int_overflow
  • <quartus_installdir>/hls/examples/tutorials/best_practices/struct_interfaces
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:
  • <quartus_installdir>/hls/examples/tutorials/hls_float/1_reduced_doubl
  • <quartus_installdir>/hls/examples/tutorials/hls_float/2_explicit_arithmetic
  • <quartus_installdir>/hls/examples/tutorials/hls_float/3_conversions
The Intel® HLS Compiler also supports some nonstandard math functions for the following data types when you include an additional header file:
  • 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

The hls_float data type has the following limitations:
  • 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.
  • 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.