Construct Graph for Packet Stream Kernels - 2023.1 English

Vitis Tutorials: AI Engine Development

Document ID
Release Date
2023.1 English

Review how the graph is constructed in aie/graph.h.

	using namespace adf;
	class mygraph: public adf::graph {
	  adf:: kernel core[4];
	  adf:: pktsplit<4> sp;
	  adf:: pktmerge<4> mg;
	  adf::input_plio  in;
	  adf::output_plio  out;
	  mygraph() {
	    core[0] = adf::kernel::create(aie_core1);
	    core[1] = adf::kernel::create(aie_core2);
	    core[2] = adf::kernel::create(aie_core3);
	    core[3] = adf::kernel::create(aie_core4);
	    adf::source(core[0]) = "aie_core1.cpp";
	    adf::source(core[1]) = "aie_core2.cpp";
	    adf::source(core[2]) = "aie_core3.cpp";
	    adf::source(core[3]) = "aie_core4.cpp";
		in=input_plio::create("Datain0", plio_32_bits,  "data/input.txt");
		out=output_plio::create("Dataout0", plio_32_bits,  "data/output.txt");
	    sp = adf::pktsplit<4>::create();
	    mg = adf::pktmerge<4>::create();
	    for(int i=0;i<4;i++){
	    	adf::runtime<ratio>(core[i]) = 0.9;
	    	adf::connect<adf::pktstream > (sp.out[i], core[i].in[0]);
	        adf::connect<adf::pktstream > (core[i].out[0],[i]);
	    adf::connect<adf::pktstream> (in.out[0],[0]);
	    adf::connect<adf::pktstream> (mg.out[0],[0]);

Note that the connection type for the input_pktstream and output_pktstream interfaces are adf::pktstream. So, it uses adf::connect<adf::pktstream> to connect the AI Engine kernel and pktsplit.out /

Note that input_pktstream is read as integer input. It needs to be reinterpret_cast to other types, if needed.