Non-Blocking Reads
This 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 Reads with Empty Check
Non-blocking behavior can also be modeled using non-blocking read with a check for an empty stream, as described in 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);
}