Packet Processing - Packet Processing - 2026.1 English - UG1603

AI Engine-ML Kernel and Graph Programming Guide (UG1603)

Document ID
UG1603
Release Date
2026-07-08
Version
2026.1 English

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.

Table 1. Packet Bit Fields
Bits Field
4-0 Packet ID
11-5 7'b0000000
14-12 Packet Type
15 1'b0
20-16 Source Row
27-21 Source Column
30-28 3'b000
31 Odd parity of bits[30:0]

The compiler uses routing requirements to assign the packet ID. 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-ML 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);

The 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-ML tile where this API is executed.

The 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 specification.

Important: PL kernels do not support the writeHeader() and getPacketid() APIs.
Important: The generateHeader API is deprecated. Use the writeHeader API instead.

Refer to Explicit Packet Switching for more details.