hls::stream<> objects in your
code include the header file hls_stream.h as shown
below. Streaming data objects are defined by specifying the type and variable name. In this
example, a 128-bit unsigned integer type is defined and used to create a stream variable
#include "ap_int.h" #include "hls_stream.h" typedef ap_uint<128> uint128_t; // 128-bit user defined type hls::stream<uint128_t> my_wide_stream; // A stream declaration
Streams must use scoped naming. Xilinx
recommends using the scoped
hls:: naming shown in the
example above. However, if you want to use the
namespace, you can rewrite the preceding example as:
#include <ap_int.h> #include <hls_stream.h> using namespace hls; typedef ap_uint<128> uint128_t; // 128-bit user defined type stream<uint128_t> my_wide_stream; // hls:: no longer required
Given a stream specified as
hls::stream<T>, the type T can be:
- Any C++ native data type
- A Vitis HLS arbitrary precision type
- A user-defined struct containing either of the above types
A stream can also be specified as
hls::stream<Type, Depth>, where Depth indicates the depth of the FIFO
needed in the verification adapter that the HLS tool creates for RTL co-simulation.
Streams can be optionally named. Providing a name for the stream allows the name to be used in reporting. For example, Vitis HLS automatically checks to ensure all elements from an input stream are read during simulation. Given the following two streams:
hls::stream<uint8_t> bytestr_in1; hls::stream<uint8_t> bytestr_in2("input_stream2");
Any warning on elements of the streams are reported as follows, where it is
input_stream2 refers to
WARNING: Hls::stream 'hls::stream<unsigned char>.1' contains leftover data, which may result in RTL simulation hanging. WARNING: Hls::stream 'input_stream2' contains leftover data, which may result in RTL simulation hanging.
When streams are passed into and out of functions, they must be passed-by-reference as in the following example:
void stream_function ( hls::stream<uint8_t> &strm_out, hls::stream<uint8_t> &strm_in, uint16_t strm_len )
Streaming examples are provided in the Vitis-HLS-Introductory-Examples repository on GitHub, under Interface/Streaming. Additional design examples using streams are provided in the Vitis_Accel_Examples also on GitHub.
Vitis HLS also supports both blocking
and non-blocking access methods for
hls::stream objects, as described in
the following sections.