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: 
Highlighted
Visitor mledwon
Visitor
1,160 Views
Registered: ‎01-12-2018

How to access a struct within hls:stream class?

Jump to solution

Hello. I am trying to figure out how to access a struct within an hls::stream and I cannot seem to figure it out.

If I have a struct like so:

typedef struct{
    char A[16]
} data_strm;

And my stream is:

hls::stream<data_strm> strm_name;

How can I access member A within the stream class?

strm_name.????.A[0] = '1';
0 Kudos
1 Solution

Accepted Solutions
Scholar hbucher
Scholar
1,727 Views
Registered: ‎03-22-2016

Re: How to access a struct within hls:stream class?

Jump to solution

@mledwon Same thing, you are supposed to call write() on the stream with a struct. 

Look at page 264 on UG902,

https://www.xilinx.com/support/documentation/sw_manuals/xilinx2014_2/ug902-vivado-high-level-synthesis.pdf

In particular, "Blocking write methods" on page 266

In summary, you create a struct of data_strm type, fill it and then call stream.write( my_struct )

vitorian.com --- We do this for fun. Always give kudos. Accept as solution if your question was answered.
I will not answer to personal messages - use the forums instead.
7 Replies
Scholar hbucher
Scholar
1,148 Views
Registered: ‎03-22-2016

Re: How to access a struct within hls:stream class?

Jump to solution

@mledwon  You are supposed to call read() on the stream to get the next value.

vitorian.com --- We do this for fun. Always give kudos. Accept as solution if your question was answered.
I will not answer to personal messages - use the forums instead.
0 Kudos
Visitor mledwon
Visitor
1,138 Views
Registered: ‎01-12-2018

Re: How to access a struct within hls:stream class?

Jump to solution

In this example I am trying to write to the stream, not read from it.

EDIT: When I try using strm_name.write();  It gives me the error message:

Invalid arguments '
Candidates are:
void write(const {struct_test_tb.cpp:25} &)'

 

It looks like it's expecting a constant. I need to figure out how to tell it I want to write to struct member A, not the stream class itself.

0 Kudos
Scholar hbucher
Scholar
1,728 Views
Registered: ‎03-22-2016

Re: How to access a struct within hls:stream class?

Jump to solution

@mledwon Same thing, you are supposed to call write() on the stream with a struct. 

Look at page 264 on UG902,

https://www.xilinx.com/support/documentation/sw_manuals/xilinx2014_2/ug902-vivado-high-level-synthesis.pdf

In particular, "Blocking write methods" on page 266

In summary, you create a struct of data_strm type, fill it and then call stream.write( my_struct )

vitorian.com --- We do this for fun. Always give kudos. Accept as solution if your question was answered.
I will not answer to personal messages - use the forums instead.
Scholar hbucher
Scholar
1,119 Views
Registered: ‎03-22-2016

Re: How to access a struct within hls:stream class?

Jump to solution

@mledwon Try this

 

data_strm obj;
for ( int j=0; j<16; ++j ) obj.A[j] = j;
stream.write( obj );

The "const" in the call means that the write() call will not modify the object passed.

vitorian.com --- We do this for fun. Always give kudos. Accept as solution if your question was answered.
I will not answer to personal messages - use the forums instead.
Visitor mledwon
Visitor
1,117 Views
Registered: ‎01-12-2018

Re: How to access a struct within hls:stream class?

Jump to solution

Ah yes. I've figured it out now. The error message it was giving me was confusing me. I was trying to write the individual members of the array within the struct within the stream. I followed your advice and wrote to a struct outside the stream and then wrote that to the stream as follows:

hls::stream<data_strm> strm_name;
data_strm temp;
for(int i=0; i<16; i++){
    temp.A[i] = i;
}
strm_name.write(temp);

This works now. Thanks for the help!

Scholar hbucher
Scholar
1,109 Views
Registered: ‎03-22-2016

Re: How to access a struct within hls:stream class?

Jump to solution

@mledwon  Remember you have to pass the actual stream as a reference through the top function. You should not create it in the stack as you did. 

vitorian.com --- We do this for fun. Always give kudos. Accept as solution if your question was answered.
I will not answer to personal messages - use the forums instead.
0 Kudos
Visitor mledwon
Visitor
1,106 Views
Registered: ‎01-12-2018

Re: How to access a struct within hls:stream class?

Jump to solution
Yes, that is correct. I just wrote this quick test code to figure out this problem. I've worked with hls::stream before, just never using structs.