To utilize Direct I/O in your High-Level Synthesis (HLS) code, you must first include the necessary header file that provides the Direct I/O functionality. Begin by adding the following line at the top of your source file.
#include "hls_directio.h"
Once the header file is included, you can define Direct I/O objects by selecting an appropriate port level protocol. These protocols determine how the Direct I/O streams will interact with other components in the system design. You can then use blocking or non-blocking calls to read from or write to these streams. The Blocking and Non-blocking APIs are explained in detail in the next section.
Example Definition and Usage
In the following example, two Direct I/O stream variables are defined, reset_value
and reset_my_counter
, using the ap_vld
handshake protocol with an integer data type:
#include "hls_directio.h"
hls::ap_vld<int> &reset_value,
hls::ap_vld<int> &reset_myCounter
Given a Direct I/O stream specified as hls::ap_vld<T>
, the type T can
be:
- Any C++ native data type
- A Vitis HLS arbitrary precision type (for example, ap_int<>, ap_ufixed<>)
- A user-defined struct containing either of the above types
Direct I/O Streaming examples are provided in the Vitis-HLS-Introductory-Examples repository on GitHub.