By default, array variables are implemented as RAM:
- Top-level function array parameters are implemented as a RAM interface port.
- General arrays are implemented as RAMs for read-write access.
- Arrays involved in sub-functions, or loop-based DATAFLOW optimizations are implemented as a RAM ping pong buffer channel.
If the data stored in the array is consumed or produced in a sequential manner, a more efficient communication mechanism is to use streaming data as specified by the STREAM pragma, where FIFOs are used instead of RAMs.
ap_fifo, the array is automatically implemented as streaming. See Defining Interfaces for more information.
Place the pragma in the C source within the boundaries of the required location.
#pragma HLS stream variable=<variable> type=<type> depth=<int>
- Specifies the name of the array to implement as a streaming interface.
- Relevant only for array streaming in DATAFLOW channels. By default,
the depth of the FIFO implemented in the RTL is the same size as the array specified in
the C code. This option lets you modify the size of the FIFO to specify a different
When the array is implemented in a DATAFLOW region, it is common to use the
depthoption to reduce the size of the FIFO. For example, in a DATAFLOW region when all loops and functions are processing data at a rate of II=1, there is no need for a large FIFO because data is produced and consumed in each clock cycle. In this case, the
depthoption can be used to reduce the FIFO size to 1 to substantially reduce the area of the RTL design.Tip: The
config_dataflow -depthcommand provides the ability to stream all arrays in a DATAFLOW region. The
depthoption specified in the STREAM pragma overrides the
config_dataflow -depthsetting for the specified
- Specify a mechanism to select between FIFO, PIPO, synchronized shared
shared), and un-synchronized shared (
unsync). The supported types include:
fifo: A FIFO buffer with the specified
pipo: A regular Ping-Pong buffer, with as many “banks” as the specified depth (default is 2).
shared: A shared channel, synchronized like a regular Ping-Pong buffer, with depth, but without duplicating the array data. Consistency can be ensured by setting the depth small enough, which acts as the distance of synchronization between the producer and consumer.Tip: The default depth for shared is 1.
unsync: Does not have any synchronization except for individual memory reads and writes. Consistency (read-write and write-write order) must be ensured by the design itself.
The following example specifies array
A to be streaming, and implemented as a FIFO.
#pragma HLS STREAM variable=A
In this example, array
B is set to
streaming with a FIFO depth of 12.
#pragma HLS STREAM variable=B depth=12 type=fifo
C has streaming implemented as a
#pragma HLS STREAM variable=C type=pipo