Packet Switching Graph Constructs - 2020.2 English

Versal ACAP AI Engine Programming Environment User Guide (UG1076)

Document ID
UG1076
Release Date
2020-11-24
Version
2020.2 English
Packet-switched streams are essentially multiplexed data streams that carry different types of data at different times. Packet-switched streams do not provide deterministic latency due to the potential for resource contention with other packet-switched streams. The multiplexed data flows in units of packets with a 32-bit packet header and a variable number of payload words. A header word needs to be sent before the actual payload data and the TLAST signal is required on the last word of the packet. Two new data types called input_pktstream and output_pktstream are introduced to represent the multiplexed data streams as input to or output from a kernel, respectively. More details on the packet headers and data types can be found in Packet Stream Operations.
Note: By convention, packets originating in the programmable logic are initialized with row, column to be -1,-1.

To explicitly control the multiplexing and de-multiplexing of packets, two new templated node classes are added to the ADF graph library: pktsplit<n> and pktmerge<n>. A node instance of class pktmerge<n> is a n:1 multiplexer of n packet streams producing a single packet stream. A node instance of class pktsplit<n> is a 1:n de-multiplexer of a packet stream producing n different packet streams. The maximum number of allowable packet streams is four on a single physical channel (n≤4). See Adaptive Data Flow Graph Specification Reference for more details.

A kernel can receive packets of data either as windows of data or as input_pktstream and output_pktstream. To connect a packet stream to a window of data meant for an AI Engine kernel use the following graph construct:
connect<pktstream, window<32>>
To connect a window of data from an AI Engine kernel to a packet stream use the following graph construct:
connect<window<32>, pktstream>
To connect a packet split to an AI Engine kernel use the following graph construct:
connect<pktstream, pktstream>
To connect a packet stream from an AI Engine kernel to a packet merge use the following graph construct:
connect<pktstream, pktstream>

To connect a stream of data from/to a PLIO connection use the following graph construct:

connect<input_port, pktstream>
connect<pktstream, output_port>

When a kernel receives packets of data as a window of data, the header and TLAST are dropped prior to the kernel receiving the window of data. If the kernel writes an output window of data, the packet header and TLAST are automatically inserted.

However if the kernel receives input_pktstream of data, the kernel needs to process the packer header and TLAST, in addition to the packet data. Similarly if the kernel sends an output_pktstream of data, the kernel needs to insert the packer header and TLAST, in addition to the packet data into the output stream.
Note: If a kernel is receiving packet data as an input window of data you need to ensure the length of data per packet matches the window size.

These concepts are illustrated in the following example:

class ExplicitPacketSwitching: public adf::graph {
  private: 
    adf:: kernel core[4]; 
    adf:: pktsplit<4> sp; 
    adf:: pktmerge<4> mg;
  public: 
    adf::port in; 
    adf::port 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"; 
    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, adf::window<32> > (sp.out[i], core[i].in[0]);
       adf::connect<adf::window<32>, adf::pktstream > (core[i].out[0], mg.in[i]);
    }
    adf::connect (in, sp.in[0]); 
    adf::connect (mg.out[0], out); 
  }
};

The graph has one input PLIO port and one output PLIO port. The input packet stream from the PL is split four ways and input to four different AI Engine kernels. The output streams from the four AI Engine kernels are merged into one packet stream which is output to the PL. The Vitis analyzer Graph view of the code is shown as follows.

Figure 1. Graph View