The first 32-bit word of a packet must always be a packet header, which encodes several bit fields as shown in the following table.
|31||Odd parity of bits[30:0]|
The packet ID is assigned by the compiler based on routing requirements. The packet type can be any 3-bit pattern that you want to insert to identify the type of packet. The source row and column denote the AI Engine tile coordinates from where the packet originated. By convention, source row and column for packets originating in the programmable logic (PL) is -1,-1.
It is your responsibility to construct and send an appropriate packet header at the beginning of every packet. On the receive side, the packet header needs to be received and decoded before reading the data.
The following operations help to assemble or disassemble the packet header in the AI Engine kernel.
void writeHeader(output_pktstream *str, unsigned int pcktType, unsigned int ID); void writeHeader(output_pktstream *str, unsigned int pcktType, unsigned int ID, bool tlast); uint32 getPacketid(input_pktstream *w, int index); uint32 getPacketid(output_pktstream *w, int index);
writeHeader API allows a packet header
to be assembled with a given packet ID and packet type. The source row and column
are inserted automatically using the coordinates of the AI Engine tile where this API is executed.
getPacketid API allows the compiler assigned
packet ID to be queried on the input or output packet stream data structure. The
index argument refers to the split or merge branch edge in the graph
getPacketid()APIs are not supported in PL kernels.
generateHeaderAPI has been deprecated and replaced with the
See Explicit Packet Switching for more details.