Declare the
ac_int Data Type
ac_int
Data TypePerform the following steps to declare the
ac_int
data type:
- Include theac_int.hppheader file as follows:#include <sycl/ext/intel/ac_types/ac_int.hpp>
- Declare yourac_intvariables in one of the following ways:
- Template-based declaration:ac_int<N, true> var_name; //Signed N-bit integerac_int<N, false> var_name; //Unsigned N-bit integer
- Predefined types up to 63 bits:ac_intN::intN var_name; //Signed N-bit integerac_intN::uintN var_name; //Unsigned N-bit integer
Where,is the total length of the integer in bits.NTheac_intdata type has several API calls. For more information about the Algorithmic C data types, refer to https://github.com/hlslibs/ac_types/blob/v3.7/pdfdocs/ac_datatypes_ref.pdf.
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, refer to the section
Methods to Fill Bits
in the documentation provided in
https://github.com/hlslibs/ac_types/blob/v3.7/pdfdocs/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
Debugging the
ac_int Data Type Use
ac_int
Data Type UseThe
ac_int.hpp
header file provides tools to help you check
ac_int
data type operations and assignments for overflow.
Currently, you can debug
ac_int
data type operations and assignments for overflow only in the emulation flow and only for non-kernel code.
- When you useDEBUG_AC_INT_WARNINGandDEBUG_AC_INT_ERRORmacros, you cannot declareconstexpr ac_intvariables orconstexpr ac_intarrays.MacroDescriptionDEBUG_AC_INT_WARNINGEmits a warning for each detected overflow.DEBUG_AC_INT_ERROREmits a message for the first overflow that is detected and then exits the code with an error.
- Within your code, you must declare the macros before you include theac_int.hppheader file.