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.1. Declaring ac_int Data Types

The HLS compiler package includes an ac_int.h header file to provide arbitrary precision integer support in your component.
  1. Include the ac_int.h header file in your component in the following manner:
    #ifdef __INTELFPGA_COMPILER__ 
    #include "HLS/ac_int.h" 
    #else 
    #include "ref/ac_int.h" 
    #endif
  2. After you include the header file, declare your ac_int variables in one of the following ways:
    • Template-based declaration
      • ac_int<N, true> var_name; //Signed N bit integer
      • ac_int<N, false> var_name; //Unsigned N bit integer
    • Predefined types up to 63 bits
      • intN var_name; //Signed N bit integer
      • uintN var_name; //Unsigned N bit integer
    Where N is the total length of the integer in bits.
    Restriction:

    If you want to initialize an ac_int variable to a value larger than 64 bits, you must use the bit_fill or bit_fill_hex utility function. For details see "2.3.14 Methods to Fill Bits" in Mentor Graphics Algorithmic C (AC) Datatypes, which is available as <quartus_installdir>/hls/include/ref/ac_datatypes_ref.pdf.

    The following code example shows the use of the bit_fill or bit_fill_hex utility functions:
    typedef ac_int<80,false> i80_t;
    i80_t x;
    x.bit_fill_hex(“a9876543210fedcba987”); // member funtion
    x = ac::bit_fill_hex<i80_t>(“a9876543210fedcba987”); // global function
    int vec[] = { 0xa987, 0x6543210f, 0xedcba987 };
    x.bit_fill(vec); // member function
    x = bit_fill<i80_t>(vec); // global function
    // inlining the constant array
    x.bit_fill( (int [3]) { 0xa987,0x6543210f,0xedcba987 } ); // member function
    x = bit_fill<i80_t>( (int [3]) { 0xa987,0x6543210f,0xedcba987 } ); // global function
    

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.