The header file ap_int.h defines
the arbitrary precision integer data type for the C++ ap_[u]int
data types. To use arbitrary precision integer data types in
a C++ function:
- Add header file ap_int.h to the source code.
- Change the bit types to
ap_int<N>
for signed types orap_uint<N>
for unsigned types, whereN
is a bit-size from 1 to 1024.
The following example shows how the header file is added and two variables implemented to use 9-bit integer and 10-bit unsigned integer types:
#include "ap_int.h"
void foo_top (…) {
ap_int<9> var1; // 9-bit
ap_uint<10> var2; // 10-bit unsigned
Important: One disadvantage
of AP data types is that arrays are not automatically initialized with a value of 0.
You must manually initialize the array if desired.