Graph Code - 2022.2 English

Vitis Tutorials: AI Engine Development

Document ID
Release Date
2022.2 English
#ifndef __GRAPH_H__			// include guard to prevent multiple inclusion

	#define __GRAPH_H__

	#include <adf.h>		// Adaptive DataFlow header

	#include "kernel.hpp"

	using namespace adf;

	// dataflow graph declaration
	class the_graph : public graph {	// inherit all properties of the adaptive     dataflow graph

			input_plio pl_in;
			output_plio pl_out;

			kernel section1;
			input_port cmtx_e;	// input port for SIMD matrix coefficients (even columns)
			input_port cmtx_o;	// input port for SIMD matrix coefficients (odd columns)

			// constructor
			the_graph() {

				// associate the kernel with the function to be executed
				section1 = kernel::create(SecondOrderSection<1>);

				pl_in = input_plio::create("Input", plio_32_bits, "data/input.dat");
				pl_out = output_plio::create("Output", plio_32_bits, "output.dat");

				const unsigned num_bytes = 8 * sizeof(float) * burst_cnt;

				// establish connections

				connect<parameter>(cmtx_e, adf::async([1]));
				connect<parameter>(cmtx_o, adf::async([2]));

				connect<window<num_bytes>> (pl_in.out[0],[0]);				// window size in bytes
				connect<window<num_bytes>> (section1.out[0],[0]);

				// specify which source code file contains the kernel function
				source(section1) = "kernel.cpp";

				// !!! temporary value: assumes this kernel dominates the AI engine tile !!!
				runtime<ratio>(section1) = 1.0;

			} // end the_graph()

	}; // end class the_graph

#endif // __GRAPH_H__

Note that the graph uses the enhanced programming model (see UG1076 (v2021.2)) which eliminates the need for a global simulation::platform variable.