All arrays are implemented by default as ping-pong to enable random access. These buffers can also be re-sized if needed. For example, in some circumstances, such as when a task is being bypassed, performance degradation is possible. To mitigate this effect on performance, you can give more slack to the producer and consumer by increasing the size of these buffers by using the STREAM pragma or directive as shown below.
void top ( ... ) {
#pragma HLS dataflow
int A[1024];
#pragma HLS stream type=pipo variable=A depth=3
producer(A, B, …); // producer writes A and B
middle(B, C, ...); // middle reads B and writes C
consumer(A, C, …); // consumer reads A and C
In the interface, arrays are automatically specified as streaming if an array on the
top-level function interface is set the following interface types:
ap_fifo/axis
.
Inside the design, an array must be specified as streaming using the STREAM pragma/directive if a FIFO is desired for the implementation.
-depth
option can be used to specify the size of the FIFO.The STREAM directive is also used to change any arrays in a DATAFLOW region from the
default implementation specified by the config_dataflow
configuration.
-
If the
config_dataflow
default_channel
is set as ping-pong, any array can still be implemented as a FIFO by applying the STREAM directive to the array.Tip: To use a FIFO implementation, the array must be accessed in sequential order (and not in random access order). - If the
config_dataflow
default_channel
is set to FIFO, any array can still be implemented as a ping-pong implementation by applying the STREAM directive to the array with thetype=pipo
option.
volatile
qualifier. In this case the HLS tool generates a warning if it
cannot determine that access to the array is sequential.When an array in a DATAFLOW region is specified as streaming and implemented as
a FIFO, the FIFO is typically not required to hold the same number of elements as the
original array. The tasks in a DATAFLOW region consume each data sample as soon as it
becomes available. The depth of the FIFO can be specified using the config_dataflow -fifo_depth
option or the STREAM pragma or
directive with the -depth
option. This can be used to
set the size of the FIFO to ensure the flow of data never stalls.
If the -type=pipo
option is selected,
the -depth
option sets the depth (number of blocks) of
the PIPO. The depth should be at least 2.