Accumulation - 2024.2 English - UG1399

Vitis High-Level Synthesis User Guide (UG1399)

Document ID
UG1399
Release Date
2024-11-13
Version
2024.2 English

The accumulation functionality, on REG_P, is supported via an hls::dsp(48e1|48e2|58)::acc<> class.

  • That can be instantiated to infer different DSP accumulator instances (just one in the example below).
  • Has two methods mul_acc (P = A * B + P) and add_mul_acc (P = (A + D) * B + P).
    • Performs an accumulation and returns its result (i.e. register P).
    • If the initialization condition is true (in the case below when iteration variable is 0), reset register P to 0.

This is a simple example computing a FIR filter, using the namespace hls::dsp48e2 to expose the acc<> class and the REG_P and REG_M symbols:

#include "hls_dsp_builtins.h"
using namespace hls::dsp48e2;
...
long test_mul_acc(long delay[N], long coeff[N])
{
    acc<REG_P|REG_M> my_acc;
    C_t res;
    for (int i=0; i<N; i++) {
       res = my_acc.mul_acc(delay[i], coeff[i], /* init condition */ i==0);
    }
    return res;
}