Description
The loop tripcount is the total number of iterations performed by a loop. Vitis HLS reports the total latency of each loop (the number of cycles to execute all iterations of the loop). This loop latency is therefore a function of the tripcount (number of loop iterations).
syn.directive.loop_tripcount is for analysis only, and does
not impact the results of synthesis.The tripcount can be a constant value. It can depend on the value of
variables used in the loop expression (for example, x<y) or control statements used inside the loop.
Vitis HLS cannot determine the tripcount in some cases. These cases include, for example, those in which the variables used to determine the tripcount are:
- Input arguments, or
- Variables calculated by dynamic operation
In the following example, the value of input num_samples determines the maximum iteration of the for-loop. The
value of num_samples is not defined in the C
function, but comes into the function from the outside.
void foo (num_samples, ...) {
int i;
...
loop_1: for(i=0;i< num_samples;i++) {
...
result = a + b;
}
}
syn.directive.loop_tripcount allows
you to specify minimum, maximum, and average iterations for a loop if the loop
latency is unknown. The tool can analyze how the loop latency contributes to the
total design latency in reports, helping you determine appropriate design
optimizations.
Syntax
syn.directive.loop_tripcount=[OPTIONS] <location>
-
<location>is the location of the loop (in the formatfunction[/label]) at which the tripcount is specified.
Options
-
avg=<integer> - Specifies the average number of iterations.
-
max=<integer> - Limits the maximum number of iterations.
-
min=<integer> - Limits the minimum number of iterations.
Examples
loop_1 in function foo has a minimum tripcount of 12, and a maximum
tripcount of 16:
syn.directive.loop_tripcount=min=12 max=16 avg=14 foo/loop_1