AXI4-Stream Interfaces - 2020.2 English

Vitis High-Level Synthesis User Guide (UG1399)

Document ID
UG1399
Release Date
2021-03-22
Version
2020.2 English

An AXI4-Stream interface can be applied to any input argument and any array or pointer output argument. Because an AXI4-Stream interface transfers data in a sequential streaming manner, it cannot be used with arguments that are both read and written. In terms of data layout, the data type of the AXI4-Stream is aligned to the next byte. For example, if the size of the data type is 12 bits, it will be extended to 16 bits. Depending on whether a signed/unsigned interface is selected, the extended bits are either sign-extended or zero-extended. If the stream data type is a user-defined struct, the struct is aggregated and aligned to the size of the largest data element within the struct.

The following code examples show how the packed alignment depends on your struct type. If the struct contains only char type, as shown in the following example, then it will be packed with alignment of one byte. Total size of the struct will be two bytes:

struct A {
  char foo;
  char bar;
};

However, if the struct has elements with different data types, as shown below, then it will be packed and aligned to the size of the largest data element, or four bytes in this example. Element bar will be padded with three bytes resulting in a total size of eight bytes for the struct:

struct A {
  int foo;
  char bar;
};

By default, user-defined structs in streams are aggregated. However, you can disaggregate the struct and infer a stream for each element of the struct, using the following steps:

  1. Specify the DISAGGREGATE pragma or directive for the struct.
  2. Specify the AXI4-Stream INTERFACE pragma or directive for each element of the disaggregated struct.

The result will be one AXI4-Stream for every member of the struct in the interface.