Kernel Class with Default Constructor - 2022.2 English

Vitis Model Composer User Guide (UG1483)

Document ID
Release Date
2022.2 English

As an example, to import the C++ class kernel with the default constructor, consider the following simple.h header file that defines the kernel class simple_class with the default constructor.


#include "adf.h"
class simple_class
    int16 val;
    int16 numSamples;
    void mulBytwo(input_window_int16* in, output_window_int16* out);
    static void registerKernelClass()

It is necessary to register the kernel function using the registerKernelClass() method. More than one class kernel can be declared in a header file and each class should contain separate registerKernelClass() methods. Only one function can be registered per class and Vitis Model Composer can import only functions that are registered using REGISTER_FUNCTION().

The Kernel function is defined in simple.cpp as shown below.


#include "simple.h"
    val = 24;
    numSamples = 8;
void simple_class::mulBytwo(input_window_int16* in, output_window_int16* out)
    for (int i=0; i<numSamples; i++)
        int16 value = window_readincr(in);
        window_writeincr(out, (in*2)+val);

To import the mulBytwo function as a block in a Vitis Model Composer design, double click the AIE Class Kernel block and update the parameters as follows.

Kernel header file
Kernel class
Kernel function
Kernel source file
Kernel search path
Leave empty
Preprocessor options
Leave empty

Click the Import button in the Block Parameters dialog box. After successful import, the Function tab displays. This provides user-editable configuration parameters as shown in the following figure.

Figure 1. AIE Class Kernel: Block Parameters

After entering the appropriate values in the Function tab, click Apply to see the updated interface of the AIE Class Kernel block GUI as shown.

Figure 2. AIE Class Kernel after Update

You can quickly review the function declaration of the imported kernel function and the port names with directions, from the Function tab.

Click the Kernel Class tab to observe the class declaration as shown in the following figure.

Figure 3. Kernel Class Tab: Class Declaration