cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Newbie
Newbie
390 Views
Registered: ‎11-20-2020

How do I use hls_stream write?

Jump to solution

Heya, I'm trying to write to a stream as defined in hls_stream.h

I'm just confused about how to use the write operator. Write seems to be defined as:



void operator << (const __STREAM_T__& wdata) {
    write(wdata);
}

 

I tried this, but technically there's two operands here, right? strm_in and bla.

 

stream<in_strm> strm_in;
stream<out_strm> strm_out;
int input_size = 5;
int bla = 123;

strm_in << bla;

 

So I end up with this error:


../../../test_src.cpp: In function 'int main()':
../../../test_src.cpp:25:10: error: no match for 'operator<<' (operand types are 'hls::stream<in_strm>' and 'int')
strm_in << bla;
~~~~~~~~^~~~~~
In file included from ../../../Compressor/Huffman_Encoder.h:4:0,
from ../../../test_src.cpp:3:
E:/Xilinx/Vivado/2020.1/include/hls_stream.h:157:10: note: candidate: void hls::stream<__STREAM_T__, 0>::operator<<(const __STREAM_T__&) [with __STREAM_T__ = in_strm]
void operator << (const __STREAM_T__& wdata) {

 

The candidate it suggests is actually the one I wanna use. How can I actually use this?

0 Kudos
Reply
1 Solution

Accepted Solutions
Xilinx Employee
Xilinx Employee
374 Views
Registered: ‎09-04-2017

@Huichelaar   The types are different that you have for stream and what you are writing.

Take a look at this simple usage

include "hls_stream.h"
typedef hls::stream<int> in_t;
void top(in_t &out)
{
int a = 4;
 out << a;
}

View solution in original post

1 Reply
Xilinx Employee
Xilinx Employee
375 Views
Registered: ‎09-04-2017

@Huichelaar   The types are different that you have for stream and what you are writing.

Take a look at this simple usage

include "hls_stream.h"
typedef hls::stream<int> in_t;
void top(in_t &out)
{
int a = 4;
 out << a;
}

View solution in original post