Non-Blocking Read - 2024.1 English

Vitis High-Level Synthesis User Guide (UG1399)

Document ID
UG1399
Release Date
2024-05-30
Version
2024.1 English

The hls::stream.read_nb() method attempts to read a value from the stream, returning true if successful. Otherwise, false is returned and the queue is unaffected.

// Usage of bool read_nb(const T & wdata)

hls::stream<int> my_stream;
int dst_var;

if (my_stream.read_nb(dst_var)) {
 // Perform standard operations
 ...
} else {
 // Read did not occur
 return;
}

Non-blocking behavior can also be modeled using blocking read with a check for an empty stream, as described in hls::stream.empty() Method. This can lead to non-deterministic behavior and should be verified in RTL simulation with a sophisticated test bench.

READ_ONLY_LOOP:
while (check != 0) {
   if ( !addr_strm.empty() )
   {
      addr_strm.read_nb(addr_for_HBM);
      hbm[addr_for_HBM] = some_data;
      check[0] = 1;
      ...
   }
   ...
   ...
   check = (check << 1);
   }