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).
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.
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.
The following table provides further details including names and descriptions of each parameter.
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. |
graph.h
#ifndef __XMC_PROJ_H__
#define __XMC_PROJ_H__
#include <adf.h>
#include "simple.h"
class Proj_base : public adf::graph {
public:
adf::kernel AIE_Kernel;
public:
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) = "simple.cc";
// create kernel constraints AIE_Kernel
adf::runtime<ratio>( AIE_Kernel ) = 0.9;
// create nets to specify connections
adf::connect< adf::stream > net0 (In1, AIE_Kernel.in[0]);
adf::connect< adf::stream > net1 (In2, AIE_Kernel.in[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 {
public:
Proj_base mygraph;
public:
adf::input_plio In1, In2;
adf::output_plio Out1, Out2;
Proj() {
In1 = adf::input_plio::create("In1",
adf::plio_32_bits,
"./data/input/In1.txt");
In2 = adf::input_plio::create("In2",
adf::plio_32_bits,
"./data/input/In2.txt");
Out1 = adf::output_plio::create("Out1",
adf::plio_32_bits,
"Out1.txt");
Out2 = adf::output_plio::create("Out2",
adf::plio_32_bits,
"Out2.txt");
adf::connect< > (In1.out[0], mygraph.In1);
adf::connect< > (In2.out[0], mygraph.In2);
adf::connect< > (mygraph.Out1, Out1.in[0]);
adf::connect< > (mygraph.Out2, Out2.in[0]);
}
};
#endif // __XMC_PROJ_H__
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.
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.
In the General tab, the Import button changes to Update, enabling further update of block parameters.