Intel® High Level Synthesis Compiler Pro Edition: Reference Manual

ID 683349
Date 10/02/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

8.2. Declaring ac_fixed Data Types

The HLS compiler package includes an ac_fixed.h header file for arbitrary precision fixed-point support.
  1. Include the ac_fixed.h header file in your component in the following manner:
    #ifdef __INTELFPGA_COMPILER__ 
    #include "HLS/ac_fixed.h" 
    #else 
    #include "ref/ac_fixed.h" 
    #endif
  2. After you include the header file, declare your ac_fixed variables as follows:
    • ac_fixed<N, I, true, Q, O> var_name; //Signed fixed-point number
    • ac_fixed<N, I, false, Q, O> var_name; //Unsigned fixed-point number
    Where the template attributes are defined as follows:
    N
    The total length of the fixed-point number in bits.
    I
    The number of bits used to represent the integer value of the fixed-point number.

    The difference of NI determines how many bits represent the fractional part of the fixed-point number.

    Q
    The quantization mode that determines how to handle values where the generated precision (number of decimal places) exceeds the number of bits available in the variable to represent the fractional part of the number.

    For a list of quantization modes and their descriptions, see "2.1. Quantization and Overflow" in Mentor Graphics Algorithmic C (AC) Datatypes, which is available in the following file: <quartus_installdir>/hls/include/ref/ac_datatypes_ref.pdf.

    O
    The overflow mode that determines how to handle values where the generated value has more bits than the number of bits available in the variable.

    For a list of overflow modes and their descriptions, , see "2.1. Quantization and Overflow" in Mentor Graphics Algorithmic C (AC) Datatypes, which is available in the following file: <quartus_installdir>/hls/include/ref/ac_datatypes_ref.pdf.

For a list of supported operators and their return types, see "Chapter 2: Arbitrary-Length Bit-Accurate Integer and Fixed-Point Datatypes" in Mentor Graphics Algorithmic C (AC) Datatypes, which is available in the following file: <quartus_installdir>/hls/include/ref/ac_datatypes_ref.pdf.

Additional math functions are supported by the HLS/ac_fixed_math.h header file. For details, see Math Functions Provided by the ac_fixed_math.h Header File.

Important: Due to the differences in the internal math implementations, the results from operations with ac_fixed data types might be different between simulation and emulation. The maximum difference will be within a few ULPs.