Importing AI Engine Graphs - 2022.2 English

Vitis Model Composer User Guide (UG1483)

Document ID
Release Date
2022.2 English

As discussed in AI Engine Graphs, a graph is a connection of different compute kernel functions. Unlike when importing kernels, where a kernel function is imported as a block into Vitis Model Composer, in this case, graph code is imported as a block. To import the graph as block into Vitis Model Composer, you need to select the AIE Graph block from the AI Engine library (shown in the following figure).

Figure 1. AIE Graph

Vitis Model Composer allows connection between the AIE Graph block and the AIE Kernel block so that the whole design can be simulated in the Simulink environment.

Important: It is assumed that your kernel code is already developed and that the associated kernels are properly organized.

The AIE Graph block supports importing the AI Engine graph into Vitis Model Composer using the header file (*.h).

Using the Header File

To import the graph using the header file (.h), double-click the AIE Graph block. Specify the graph header file, class, search path, and preprocessor options as shown in the following figure.

Figure 2. AIE Graph Block Parameters Dialog Box

The following table provides further details including names and descriptions of each parameter.

Table 1. AIE Graph Block Parameters
Parameter Name Parameter Type Criticality Description
Graph application file (*.h) String Mandatory Specify the file (.h), where the application graph class is defined and the Adaptive Data Flow (ADF) header (adf.h), kernel function prototypes are included.
Graph class String Mandatory Specify the name of the graph class.
Graph Search paths Vector of strings Mandatory Specify search paths where header files, kernels, and other include files can be found and included for simulation. The search path $XILINX_VITIS/adf/include (where adf.h is defined) is included by default and does not need to be specified.
Preprocessor options   Optional Optional preprocessor arguments for downstream compilation with specific preprocessor options. The following preprocessor option formats are accepted and multiple can be selected: ‘-D<name>’ and ‘-D<name>=<definition>’. That is, the optional argument must begin with the '-D' string and if the optional <definition> value is not provided, it is assumed to be 1.


#ifndef __XMC_PROJ_H__
#define __XMC_PROJ_H__
#include <adf.h>
#include "simple.h"
class Proj_base : public adf::graph {
   adf::kernel AIE_Kernel;
   adf::input_port In1, In2;
   adf::output_port Out1, Out2;
   Proj_base() {
      // create kernel AIE_Kernel
      AIE_Kernel = adf::kernel::create(simple_comp_1);
      adf::source(AIE_Kernel) = "";
      // create kernel constraints AIE_Kernel
      adf::runtime<ratio>( AIE_Kernel ) = 0.9;
      // create nets to specify connections
      adf::connect< adf::stream > net0 (In1,[0]);
      adf::connect< adf::stream > net1 (In2,[1]);
      adf::connect< adf::stream > net2 (AIE_Kernel.out[0], Out1);
      adf::connect< adf::stream > net3 (AIE_Kernel.out[1], Out2);
class Proj : public adf::graph {
   Proj_base mygraph;
   adf::input_plio In1, In2;
   adf::output_plio Out1, Out2;
   Proj() {
      In1 = adf::input_plio::create("In1",
      In2 = adf::input_plio::create("In2",
      Out1 = adf::output_plio::create("Out1",
      Out2 = adf::output_plio::create("Out2",
      adf::connect< > (In1.out[0], mygraph.In1);
      adf::connect< > (In2.out[0], mygraph.In2);
      adf::connect< > (mygraph.Out1,[0]);
      adf::connect< > (mygraph.Out2,[0]);
#endif // __XMC_PROJ_H__
Note: It is not allowed to import the graph class that has PLIO attributes specified. Model Composer will throw an appropriate error if you try to do so. In this case, use the Proj_base class to import the graph.

When the GUI parameters are updated, click the Import button.

The Block Parameters dialog box updates as shown in the following figure. This contains the port direction and type.

Figure 3. Block Parameters Dialog Box

Parameters such as the Graph Port Name, Data Type etc. are automatically updated from the graph code.

The AIE Graph block GUI interface with input and output ports is as shown in the following figure.

Figure 4. AIE Graph Block

In the General tab, the Import button changes to Update, enabling further update of block parameters.

Figure 5. Update Button