hls::axis
(and
ap_axiu
/ap_axis
) is limited to interfaces of the top-level
function as it is the programmatic method to support AXI4-Stream with side channels. hls::axis
cannot be used on
internal functions or variables as the AXI4-Stream protocol
is not supported for an internal stream. For internal streams you must use
hls::stream
objects.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 an user-defined struct, the default procedure is
to keep the struct aggregated and align the struct to the size of the largest data element to
the nearest byte. The only exception to this rule is if the struct contains a hls::stream
object. In this special case, the struct will be
disaggregated and an axi stream will be created for each member element of 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;
};