Static File-scoped Tables - 2022.1 English

Versal ACAP AI Engine Programming Environment User Guide (UG1076)

Document ID
Release Date
2022.1 English

Kernel functions can use private, read-only data structures that are accessed as file-scoped variables. The compiler allocates a limited amount of static heap space for such data. As an example, consider the following header file (user_parameter.h).


#include <adf.h>

static int32 lutarray[8] = {1,2,3,4,5,6,0,0} ; 


This header file can be included in the kernel source file and the look-up table can be accessed inside a kernel function directly. The static modifier ensures that the array definition is local to this file. The AI Engine compiler then allocates this array in static heap space for the processor where this kernel is used.

#include <aie_api/aie.hpp>
#include <aie_api/aie_adf.hpp>
#include "user_parameter.h"

void simple_lut(input_window<int32> * in, output_window<int32> * out){
  aie::vector<int32,16> sbuff;
  aie::accum<acc80,4> acc;
  aie::vector<int32,8> coeffs=aie::load_v<8>((int32*)lutarray);

  window_readincr_v<16>(in, sbuff);
  acc = aie::sliding_mul<4,8>(coeffs, 0, sbuff, 0);
  window_writeincr(out, acc.template to_vector(0));