UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Adventurer
Adventurer
228 Views
Registered: ‎04-19-2018

Reading more than one value from a stream

Jump to solution

To read single values from a stream, I use:

if(!streamIn.empty())
    x = streamIn.read()

and that is fine. Now I'd like to read pairs of values. I tried:

if(streamIn.size()>1){
    x = streamIn.read();
    y = streamIn.read();

but fails miserably as it's not synthesizable... then I used something like that:

if(!streamIn.empty()){
    x = streamIn.read();
    if (!streamIn.empty()){
        y = streamIn.read();
        // ...  pair process...

and that works but for a larger number that will be clumsy... is there a neater way of checking if there are N items in a stream queue?

0 Kudos
1 Solution

Accepted Solutions
Scholar u4223374
Scholar
175 Views
Registered: ‎04-26-2015

Re: Reading more than one value from a stream

Jump to solution

How about just turning your last version into a loop? That at least is fairly neat.

There's no way to check that a stream contains N elements - the data provided with the stream only tells you whether it contains no elements or at least one element.

 

My preference is to just read N elements without checking for emptiness first. HLS will automatially wait until the data is available.

2 Replies
Scholar u4223374
Scholar
176 Views
Registered: ‎04-26-2015

Re: Reading more than one value from a stream

Jump to solution

How about just turning your last version into a loop? That at least is fairly neat.

There's no way to check that a stream contains N elements - the data provided with the stream only tells you whether it contains no elements or at least one element.

 

My preference is to just read N elements without checking for emptiness first. HLS will automatially wait until the data is available.

Adventurer
Adventurer
155 Views
Registered: ‎04-19-2018

Re: Reading more than one value from a stream

Jump to solution

I wanted to prevent the function from being blocked waiting for data to come and do something in the meantime, but if there isn't data there is nothing to do as well, so it can be the right thing to do not worry that much.

0 Kudos