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
Observer kratsas
Observer
7,921 Views
Registered: ‎10-01-2008

Seeing no effect when inserting directives in Vivado HLS

Jump to solution

I have been experimenting with HLS. I am most interested in understanding how to use directives to constain the design in very specific ways. I have been trying to apply several types of directives to loops but really see no effect of the directives after I run C synthesis.

 

Here is a very basic example of the issue. I have the following code (MAX_NUM_NODES = 16):

 

for(int index = 0; index < MAX_NUM_NODES; index++){

result[index] = (score[index] > 5000) ? value1[index] : value2[index];

}

 

Because they are all independent, the desired result would be for all of these assignments to occur in parallel in one cycle. By default, the results of C Synthesis are:

Estimated Clock Period: 4.7

Latency: 49

Loop trip count: 16

Loop Latency: 48

 

I have tried applying several directives with no change in results. I've tried:

 

set_directive_loop_merge

 

set_directive_latency (with a conservative max of 8)

 

set_directive_loop_tripcount (with a max of 1), in this case I got the following warning messages:

@W [XFORM-561] Updating loop upper bound from 1 to 16 for loop 'testLoop_label1' (testloop.cpp:17)in function 'testLoop'. testloop:solution1 Apr 11, 2013 2:13:57 PM

@W [XFORM-561] Updating loop lower bound from 0 to 16 for loop 'testLoop_label1' (testloop.cpp:17)in function 'testLoop'. testloop:solution1 Apr 11, 2013 2:13:57 PM

 

I have tried both using the directive.tcl file and inserting the directives directly into the source code.

 

Am I missing something fundamental in how the directives should be used? Any assistance would be greatly appreciated.

 

Thanks!

 

0 Kudos
1 Solution

Accepted Solutions
Adventurer
Adventurer
12,118 Views
Registered: ‎12-18-2012

Re: Seeing no effect when inserting directives in Vivado HLS

Jump to solution

I think it is better to try to use the uroll or pipeline directive in the loop. Or maybe both. Try and see what you get. the tripcount directive is used for loops with non-fixed number of passes to help the tool estimate latency. That is why in a fixed loop count it gives you this warning. 

 

Plus it would never take 1 cycle anyway. If the arrays are implemented as blockrams you will need 3-4 cycles for each loop pass. In your code each loop pass seems to take 3 cycles if i am not mistaken.  Also ckeck the scheduling after synthesis and see what the scheduler does and has the for loop run sequentially. It might give you some hints. 

 

George

 

 

 

 

 

0 Kudos
4 Replies
Observer kratsas
Observer
7,920 Views
Registered: ‎10-01-2008

Re: Seeing no effect when inserting directives in Vivado HLS

Jump to solution
Sorry...forgot to mention...I'm using Vivado 2012.4.
0 Kudos
Adventurer
Adventurer
12,119 Views
Registered: ‎12-18-2012

Re: Seeing no effect when inserting directives in Vivado HLS

Jump to solution

I think it is better to try to use the uroll or pipeline directive in the loop. Or maybe both. Try and see what you get. the tripcount directive is used for loops with non-fixed number of passes to help the tool estimate latency. That is why in a fixed loop count it gives you this warning. 

 

Plus it would never take 1 cycle anyway. If the arrays are implemented as blockrams you will need 3-4 cycles for each loop pass. In your code each loop pass seems to take 3 cycles if i am not mistaken.  Also ckeck the scheduling after synthesis and see what the scheduler does and has the for loop run sequentially. It might give you some hints. 

 

George

 

 

 

 

 

0 Kudos
Observer kratsas
Observer
7,885 Views
Registered: ‎10-01-2008

Re: Seeing no effect when inserting directives in Vivado HLS

Jump to solution

Thanks for the response. It seems that the UNROLL directive will be helpful. It did have an effect on the results bringing the overall latency to 9. 

 

The intention is to NOT use block RAMS for the arrays for that very issue that I want all of the elements to be accessible simultaneously. I'm currently looking into the other directives that affect how arrays are implemented.

 

Thanks again!

0 Kudos
Observer kratsas
Observer
7,878 Views
Registered: ‎10-01-2008

Re: Seeing no effect when inserting directives in Vivado HLS

Jump to solution

To follow-up for anyone reading this thread,applying this full set of directives:

 

set_directive_unroll "testLoop/testLoop_label1"
set_directive_array_partition -type complete -dim 1 "testLoop" score
set_directive_array_partition -type complete -dim 1 "testLoop" value1
set_directive_array_partition -type complete -dim 1 "testLoop" value2
set_directive_array_partition -type complete -dim 1 "testLoop" result
set_directive_interface -mode ap_hs -register "testLoop" score
set_directive_interface -mode ap_hs -register "testLoop" value1
set_directive_interface -mode ap_hs -register "testLoop" value2
set_directive_interface -mode ap_hs -register "testLoop" result

 

to the following code:

 

#include "testloop.h"


void testLoop(

short score [MAX_NUM_NODES],
char value1 [MAX_NUM_NODES],
char value2 [MAX_NUM_NODES],
char result [MAX_NUM_NODES]

){

testLoop_label1:for(int index = 0; index < MAX_NUM_NODES; index++){

result[index] = (score[index] > 500) ? value1[index] : value2[index];

}

}

 

...the resulting overall latency becomes 2 (as compared to the default result of 49 cycles before any directives were applied).

0 Kudos