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: 
Participant valato
Participant
684 Views
Registered: ‎09-29-2017

How to preserve instructions order

Jump to solution

I need to set an interface variable at the end of IP processing to be able to synchronize the next IP.

Here is my code snippet:

void top(ap_uint<64> * image, ap_uint<6> ptr_in, ap_uint<6> * ptr_out /* ... other parameters */) {
#pragma HLS INTERFACE m_axi port=image
#pragma HLS INTERFACE ap_none port=ptr_in
#pragma HLS INTERFACE ap_none port=ptr_out
ap_uint<6> cur_frame = ptr_in;
/* some long processing */
/* write result to image */
*ptr_out = cur_frame;
}

My problem is that HLS optimizes instructions order and I have found out that ptr_out value changes many cycles before IP signals  ap_done. It results in a problem that the following IP starts working with frame that is not fully preprocessed by previous IP.

How to force HLS to perform ptr_out assignment after all write instructions to image? I undestand that HLS sees no data dependency between these instructions and it can schedule ptr_out assignment even immediately after the first line (cur_frame = ptr_in).

Is it a solution to encapsulate it in different submodules with INLINE OFF? Will HLS always preserve a call order of these submodules?

----- Please mark the post as an answer "Accept as solution" in case it helped to solve your problem. Give kudos in case the post guided you to the solution.
0 Kudos
1 Solution

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

Re: How to preserve instructions order

Jump to solution

You can use ap_wait(). HLS will complete everything before ap_wait() before starting anything after it.

0 Kudos
2 Replies
Scholar u4223374
Scholar
930 Views
Registered: ‎04-26-2015

Re: How to preserve instructions order

Jump to solution

You can use ap_wait(). HLS will complete everything before ap_wait() before starting anything after it.

0 Kudos
Participant valato
Participant
629 Views
Registered: ‎09-29-2017

Re: How to preserve instructions order

Jump to solution
This was exactly what I needed. Thanks.
In documentation it is only mentioned that it can be used in region marked as PROTOCOL. But this cannot be used because HLS complains about multi-cycle operation inside region that require multiple ap_waits. But still it works even outside this region.
----- Please mark the post as an answer "Accept as solution" in case it helped to solve your problem. Give kudos in case the post guided you to the solution.
0 Kudos