cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
hitpmpm@163.com
Participant
Participant
1,670 Views
Registered: ‎11-30-2017

how to set the port direction for HLS IP

Jump to solution

hello everyone

When I designing the my IP using the HLS, I want to have two outputs, one is the data of picture ,the other is the number of pixels named count, but the HLS set the count as in not out automatically , how to solve this problem?  thanks!

int hls_counter_color1(AXI_STREAM_IN& INPUT_STREAM1,
		AXI_STREAM_IN& INPUT_STREAM2, AXI_STREAM_OUT& OUTPUT_STREAM, int thr, int rows,
		int cols,int count) 
{
int temp = 0;

#pragma HLS INTERFACE axis port=INPUT_STREAM1
#pragma HLS INTERFACE axis port=INPUT_STREAM2
#pragma HLS INTERFACE axis port=OUTPUT_STREAM
#pragma HLS RESOURCE core=AXI_SLAVE variable=thr metadata="-bus_bundle CONTROL_BUS"
//#pragma HLS RESOURCE core=AXI_SLAVE variable=count metadata="-bus_bundle CONTROL_BUS"
#pragma HLS RESOURCE core=AXI_SLAVE variable=rows metadata="-bus_bundle CONTROL_BUS"
#pragma HLS RESOURCE core=AXI_SLAVE variable=cols metadata="-bus_bundle CONTROL_BUS"
//#pragma HLS RESOURCE core=AXI_SLAVE variable=flag metadata="-bus_bundle CONTROL_BUS"
//#pragma HLS RESOURCE core=AXI_SLAVE variable=return metadata="-bus_bundle CONTROL_BUS"

#pragma HLS INTERFACE ap_stable port=thr
#pragma HLS INTERFACE ap_stable port=rows
#pragma HLS INTERFACE ap_stable port=cols
0 Kudos
1 Solution

Accepted Solutions
u4223374
Advisor
Advisor
1,593 Views
Registered: ‎04-26-2015

Yes, just leave it as "int &". I think if you don't specify any interface type, HLS will do something sensible (ie a direct parallel port, with handshaking enabled).

View solution in original post

0 Kudos
9 Replies
oliviert
Xilinx Employee
Xilinx Employee
1,651 Views
Registered: ‎01-09-2008

In the code you wrote:

int hls_counter_color1(AXI_STREAM_IN& INPUT_STREAM1,
		AXI_STREAM_IN& INPUT_STREAM2, AXI_STREAM_OUT& OUTPUT_STREAM, int thr, int rows,
		int cols,int count) 

 The variable 'count' cannot be an output it's not a pointer nor a reference.

 

Turn it into:

int& count

And it should be OK.

==================================
Olivier Trémois
XILINX SW Marketing AI Engine Tools
Don't forget to reply, give kudos, and accept as solution.
u4223374
Advisor
Advisor
1,631 Views
Registered: ‎04-26-2015

To add to the excellent reply above - you will need to read up on "pass by value" (what you're doing now), "pass by address", and "pass by reference" (what was suggested above). These are crucial concepts in C, and if you do not understand them then you are going to spend a huge amount of time troubleshooting incredibly simple problems.

0 Kudos
hitpmpm@163.com
Participant
Participant
1,616 Views
Registered: ‎11-30-2017

@oliviert @u4223374 Thanks for your reply, I have changed the count into an arrary  like the following 

int hls_counter_color1(AXI_STREAM_IN& INPUT_STREAM1,
		AXI_STREAM_IN& INPUT_STREAM2, AXI_STREAM_OUT& OUTPUT_STREAM, int thr, int rows,
		int cols,int count[1]) 

 but I get into the trouble that which synethsis port can I set for count , fifo ?axis?or bram?  or others?  The count port is just a number of gray pixels, It decides the IP( behind this IP )whether works.

thanks! 

0 Kudos
u4223374
Advisor
Advisor
1,607 Views
Registered: ‎04-26-2015

hitpmpm@163.com  I've always used AXI Lite for talking to a Zynq PS. For direct fabric use, I'd use the suggestion from @oliviert and define it as "int & count", since that prevents HLS trying to use it as an array.

0 Kudos
hitpmpm@163.com
Participant
Participant
1,605 Views
Registered: ‎11-30-2017

thanks sir 

I want to let the count talk to PL, which port should I use? Do you stilll suggest use int&?

BEST WISHES!

0 Kudos
u4223374
Advisor
Advisor
1,594 Views
Registered: ‎04-26-2015

Yes, just leave it as "int &". I think if you don't specify any interface type, HLS will do something sensible (ie a direct parallel port, with handshaking enabled).

View solution in original post

0 Kudos
hitpmpm@163.com
Participant
Participant
1,589 Views
Registered: ‎11-30-2017

I make it!Thank you very very much!

0 Kudos
hitpmpm@163.com
Participant
Participant
1,585 Views
Registered: ‎11-30-2017

I found that the port is disigned as ap_vld port by HLS automatically, but I do not know how to make the ap_vld work?  or can you tell me which port maybe more easy to operate?

thanks!

0 Kudos
u4223374
Advisor
Advisor
1,565 Views
Registered: ‎04-26-2015

ap_vld should produce two ports: data and vld. When vld is 1, that means that the data port contains valid data and can be read safely. When vld is 0, that means that the block is processing and the data value may be invalid.

0 Kudos