template class xf::dsp::aie::fir::resampler::fir_resampler_graph - 2023.2 English

Vitis Libraries

Release Date
2023-12-20
Version
2023.2 English
#include "fir_resampler_graph.hpp"

Overview

fir_resampler is a generic asymmetric FIR filter that can do fractional and integer interpolation and decimation.

These are the templates to configure the generic FIR class.

Parameters:

TT_DATA

describes the type of individual data samples input to and output from the filter function. This is a typename and must be one of the following:

int16, cint16, int32, cint32, float, cfloat.

TT_COEFF

describes the type of individual coefficients of the filter taps.

It must be one of the same set of types listed for TT_DATA and must also satisfy the following rules:

  • Complex types are only supported when TT_DATA is also complex.
  • TT_COEFF must be an integer type if TT_DATA is an integer type
  • TT_COEFF must be a float type if TT_DATA is a float type.
TP_FIR_LEN is an unsigned integer which describes the number of taps in the filter.
TP_INTERPOLATE_FACTOR is an unsigned integer which describes the interpolation factor of the filter. TP_INTERPOLATE_FACTOR must be in the range 3 to 16.
TP_DECIMATE_FACTOR is an unsigned integer which describes the decimation factor of the filter. TP_DECIMATE_FACTOR must be in the range 2 to 16.
TP_SHIFT

describes power of 2 shift down applied to the accumulation of FIR terms before output.

TP_SHIFT must be in the range 0 to 61.

TP_RND

describes the selection of rounding to be applied during the shift down stage of processing. Although, TP_RND accepts unsigned integer values descriptive macros are recommended where

  • rnd_floor = Truncate LSB, always round down (towards negative infinity).

  • rnd_ceil = Always round up (towards positive infinity).

  • rnd_sym_floor = Truncate LSB, always round towards 0.

  • rnd_sym_ceil = Always round up towards infinity.

  • rnd_pos_inf = Round halfway towards positive infinity.

  • rnd_neg_inf = Round halfway towards negative infinity.

  • rnd_sym_inf = Round halfway towards infinity (away from zero).

  • rnd_sym_zero = Round halfway towards zero (away from infinity).

  • rnd_conv_even = Round halfway towards nearest even number.

  • rnd_conv_odd = Round halfway towards nearest odd number.

    No rounding is performed on ceil or floor mode variants.

    Other modes round to the nearest integer. They differ only in how they round for values of 0.5.

    Note: Rounding modes rnd_sym_floor and rnd_sym_ceil are only supported on AIE-ML device.

TP_INPUT_WINDOW_VSIZE

describes the number of samples processed by the graph in a single iteration run.

When TP_API is set to 0, samples are buffered and stored in a ping-pong window buffer mapped onto Memory Group banks.

As a results, maximum number of samples processed by the graph is limited by the size of Memory Group.

When TP_API is set to 1, samples are processed directly from the stream inputs and no buffering takes place.

In such case, maximum number of samples processed by the graph is limited to 32-bit value (4.294B samples per iteration).

TP_INPUT_WINDOW_VSIZE must be an integer multiple of TP_DECIMATE_FACTOR. The number of values in the output window will be TP_INPUT_WINDOW_VSIZE multipled by TP_INTERPOLATE_FACTOR and divided by TP_DECIMATE_FACTOR.

The resulting output window size must be a multiple of 256bits.

Note: Margin size should not be included in TP_INPUT_WINDOW_VSIZE.

TP_CASC_LEN

describes the number of AIE processors to split the operation over.

This allows resource to be traded for higher performance. TP_CASC_LEN must be in the range 1 (default) to 40.

TP_USE_COEFF_RELOAD

allows the user to select if runtime coefficient reloading should be used.

When defining the parameter:

  • 0 = static coefficients, defined in filter constructor,

  • 1 = reloadable coefficients, passed as argument to runtime function.

    Note: when used, async port: port_conditional_array<input, (TP_USE_COEFF_RELOAD == 1), TP_SSR> coeff; will be added to the FIR.

    Note: the size of the port array is equal to the total number of output paths (TP_SSR).

    Each port should contain the same taps array content, i.e. each additional port must be a duplicate of the coefficient array.

TP_NUM_OUTPUTS

sets the number of ports over which the output is sent.

This can be 1 or 2. It is set to 1 by default.

Depending on TP_API, additional output ports functionality differs. For Windows API, additional output provides flexibility in connecting FIR output with multiple destinations. Additional output out2 is an exact copy of the data of the output port out .

With Stream API, the additional output port increases the FIR’s throughput.

Data is sent in a 128-bit interleaved pattern, e.g. :

  • samples 0-3 is sent over stream0 for cint16 data type,

  • samples 4-7 is sent over stream1 for cint16 data type.

    Note: when used, optional port: port<output> out2; will be added to the FIR.

TP_DUAL_IP

allows 2 stream inputs to be connected to FIR, increasing available throughput.

When set to 0, single stream will be connected as FIRs input.

When set to 1, two stream inputs will be connected.

In such case data should be organized in 128-bit interleaved pattern, e.g.:

  • samples 0-3 to be sent over stream0 for cint16 data type,
  • samples 4-7 to be sent over stream1 for cint16 data type.
TP_API

specifies if the input/output interface should be window-based or stream-based.

The values supported are 0 (window API) or 1 (stream API).

TP_SSR

specifies the number of parallel input paths where samples are interleaved between paths, giving an overall higher throughput.

An SSR of 1 means just one input path, and is the backwards compatible option. SSR Decomposition is currently unavailable. Please set TP_SSR to 1 and use TP_PARA_INTERP_POLY/TP_PARA_DECI_POLY for Super Sample operation modes.

TP_PARA_INTERP_POLY

sets the number of interpolator polyphases over which the coefficients will be split to enable parallel computation of the outputs.

The polyphases are executed in parallel, output data is produced by each polyphase directly.

TP_PARA_INTERP_POLY does not affect the number of input data paths.

There will be TP_SSR input phases irrespective of the value of TP_PARA_INTERP_POLY.

TP_PARA_INTERP_POLY = TP_INTERPOLATE_FACTOR will result in an interpolate factor of polyphases, where each polyphase is a single rate filters.

TP_PARA_INTERP_POLY < TP_INTERPOLATE_FACTOR will result in the kernels in the polyphase branches operating as interpolators.

The number of AIEs used is given by TP_PARA_INTERP_POLY * TP_SSR^2 * TP_CASC_LEN.

TP_PARA_DECI_POLY

specifies the number of decimator polyphases that will be split up and executed in a series of pipelined cascade stages, resulting in additional input paths.

A TP_PARA_DECI_POLY of 1 means just one input leg, and is the backwards compatible option.

TP_PARA_DECI_POLY = TP_DECIMATE_FACTOR will result in an decimate factor of polyphases, operating as independent single rate filters connected by cascades. The number of AIEs used is given by TP_PARA_DECI_POLY * TP_SSR^2 * TP_CASC_LEN.

TP_SAT

describes the selection of saturation to be applied during the shift down stage of processing. TP_SAT accepts unsigned integer values, where:

  • 0: none = No saturation is performed and the value is truncated on the MSB side.
  • 1: saturate = Default. Saturation rounds an n-bit signed value in the range [- ( 2^(n-1) ) : +2^(n-1) - 1 ].
  • 3: symmetric = Controls symmetric saturation. Symmetric saturation rounds an n-bit signed value in the range [- ( 2^(n-1) -1 ) : +2^(n-1) - 1 ].
template <
    typename TT_DATA,
    typename TT_COEFF,
    unsigned int TP_FIR_LEN,
    unsigned int TP_INTERPOLATE_FACTOR,
    unsigned int TP_DECIMATE_FACTOR,
    unsigned int TP_SHIFT,
    unsigned int TP_RND,
    unsigned int TP_INPUT_WINDOW_VSIZE,
    unsigned int TP_CASC_LEN = 1,
    unsigned int TP_USE_COEFF_RELOAD = 0,
    unsigned int TP_NUM_OUTPUTS = 1,
    unsigned int TP_DUAL_IP = 0,
    unsigned int TP_API = 0,
    unsigned int TP_SSR = 1,
    unsigned int TP_PARA_INTERP_POLY = 1,
    unsigned int TP_PARA_DECI_POLY = 1,
    unsigned int TP_SAT = 1
    >
class fir_resampler_graph: public graph

// structs

template <int dim>
struct ssr_params

template <unsigned int CL>
struct tmp_ssr_params

// fields

static constexpr unsigned int IN_SSR
static constexpr unsigned int OUT_SSR
kernel m_firKernels[TP_CASC_LEN *TP_SSR *TP_SSR *TP_PARA_DECI_POLY *TP_PARA_INTERP_POLY]
port_array <input, IN_SSR> in
port_array <output, OUT_SSR> out
port_conditional_array <input, (TP_DUAL_IP==1), IN_SSR> in2
port_conditional_array <input, (TP_USE_COEFF_RELOAD==1), TP_SSR*TP_PARA_INTERP_POLY> coeff
port_conditional_array <output, (TP_NUM_OUTPUTS==2), OUT_SSR> out2

Fields

static constexpr unsigned int IN_SSR

Size of the Input port array in SSR operation mode

static constexpr unsigned int OUT_SSR

OUT_SSR defines the number of output paths, equal to TP_SSR * TP_PARA_INTERP_POLY .

kernel m_firKernels [TP_CASC_LEN *TP_SSR *TP_SSR *TP_PARA_DECI_POLY *TP_PARA_INTERP_POLY]

The array of kernels that will be created and mapped onto AIE tiles. Number of kernels ( TP_CASC_LEN * TP_SSR ) will be connected with each other by cascade interface.

port_array <input, IN_SSR> in

The input data to the function. This input is either a window API of samples of TT_DATA type or stream API (depending on TP_API). Note: Margin is added internally to the graph, when connecting input port with kernel port. Therefore, margin should not be added when connecting graph to a higher level design unit. Margin size (in Bytes) equals to TP_FIR_LEN rounded up to a nearest multiple of 32 bytes.

port_array <output, OUT_SSR> out

The output data from the function. This output is either a window API of samples of TT_DATA type or stream API (depending on TP_API). Number of output samples is determined by interpolation & decimation factors (if present).

port_conditional_array <input, (TP_DUAL_IP==1), IN_SSR> in2

The conditional input data to the function. This input is (generated when TP_DUAL_IP == 1) either a window API of samples of TT_DATA type or stream API (depending on TP_API).

port_conditional_array <input, (TP_USE_COEFF_RELOAD==1), TP_SSR*TP_PARA_INTERP_POLY> coeff

The conditional array of input async ports used to pass run-time programmable (RTP) coeficients. This port_conditional_array is (generated when TP_USE_COEFF_RELOAD == 1) an array of input ports, which size is defined by TP_SSR. Each port in the array holds a duplicate of the coefficient array, required to connect to each SSR input path.

port_conditional_array <output, (TP_NUM_OUTPUTS==2), OUT_SSR> out2

The output data from the function. This output is (generated when TP_NUM_OUTPUTS == 2) either a window API of samples of TT_DATA type or stream API (depending on TP_API). Number of output samples is determined by interpolation & decimation factors (if present).

Methods

getKernels

getKernels overload (1)

kernel* getKernels ()

Access function to get pointer to kernel (or first kernel in a chained configuration).

getKernels overload (2)

kernel* getKernels (int cascadePosition)

Access function to get pointer to an indexed kernel.

Parameters:

cascadePosition an index to the kernel’s position in the cascade.

getInNet

getInNet overload (1)

connect <stream, stream>* getInNet (
    int cascadePosition,
    int ssrInPhaseIndex,
    int ssrOutPathIndex,
    int paraDeciPolyIndex,
    int paraInterpPolyIndex
    )

Access function to get pointer to net of the in port. Nets only get assigned when streaming interface is being broadcast, i.e. nets only get used when TP_API == 1 and TP_CASC_LEN > 1

Parameters:

cascadePosition an index to the kernel’s position in the cascade.
ssrOutPathIndex an index to the output data SSR Path.
ssrInPhaseIndex an index to the input data SSR Phase
paraDeciPolyIndex an index to the input data Parallel Decimation Polyphase
paraInterpPolyIndex an index to the input data Parallel Interpolation Polyphase

getIn2Net

getIn2Net overload (1)

connect <stream, stream>* getIn2Net (
    int cascadePosition,
    int ssrInPhaseIndex,
    int ssrOutPathIndex,
    int paraDeciPolyIndex,
    int paraInterpPolyIndex
    )

Access function to get pointer to net of the in2 port, when port is being generated, i.e. when TP_DUAL_IP == 1. Nets only get assigned when streaming interface is being broadcast, i.e. nets only get used when TP_API == 1 and TP_CASC_LEN > 1

Parameters:

cascadePosition an index to the kernel’s position in the cascade.
ssrOutPathIndex an index to the output data SSR Path.
ssrInPhaseIndex an index to the input data SSR Phase
paraDeciPolyIndex an index to the input data Parallel Decimation Polyphase
paraInterpPolyIndex an index to the input data Parallel Interpolation Polyphase

getKernelArchs

unsigned int getKernelArchs ()

Access function to get kernel’s architecture (or first kernel’s architecture in a chained configuration).

getPolyphaseLaneAlias

unsigned int getPolyphaseLaneAlias ()

Access function to get kernels PoliphaseLaneAlias.

fir_resampler_graph

fir_resampler_graph overload (1)

fir_resampler_graph (const std::vector <TT_COEFF>& taps)

This is the constructor function for the FIR graph with static coefficients.

Parameters:

taps a reference to the std::vector array of taps values of type TT_COEFF.

fir_resampler_graph overload (2)

fir_resampler_graph ()

This is the constructor function for the FIR graph with reloadable coefficients.

getMinCascLen

template <
    int T_FIR_LEN,
    int T_API,
    typename T_D,
    typename T_C,
    unsigned int T_IF,
    unsigned int T_DF,
    unsigned int SSR = 1
    >
static constexpr unsigned int getMinCascLen ()

Access function to get Graphs minimum cascade length for a given configuration.

Parameters:

T_FIR_LEN tap length of the fir filter
T_API interface type : 0 - window, 1 - stream
T_D data type
T_C coeff type
T_IF interpolation factor
T_DF decimation factor
SSR Super Sample Rate operation - defaults to: 1.

getOptCascLen

template <
    int T_FIR_LEN,
    typename T_D,
    typename T_C,
    int T_API,
    int T_PORTS,
    unsigned int T_IF,
    unsigned int T_DF
    >
static constexpr unsigned int getOptCascLen ()

Access function to get graph’s cascade length to obtain maximum performance for streaming configurations.

Parameters:

T_FIR_LEN tap length of the fir filter
T_D data type
T_C coeff type
T_API interface type : 0 - window, 1 - stream
T_PORTS single/dual input and output ports. 1 : single, 2 : dual
T_IF interpolation factor
T_DF decimation factor