pragma HLS loop_tripcount
Description
TRIPCOUNT
pragma can be applied to a loop to manually specify the total number of iterations performed by a loop.
TRIPCOUNT
pragma is for analysis only, and does not impact the results of synthesis.
Vivado HLS reports the total latency of each loop, which is the number of clock cycles to execute all iterations of the loop. The loop latency is therefore a function of the number of loop iterations, or tripcount.
The tripcount can be a constant value. It may depend on the value of variables used in the loop expression (for example,x
- Input arguments, or
- Variables calculated by dynamic operation.
In cases where the loop latency is unknown or cannot be calculate, theTRIPCOUNT
pragma lets you specify minimum and maximum iterations for a loop. This lets the tool analyze how the loop latency contributes to the total design latency in the reports, and helps you determine appropriate optimizations for the design.
Syntax
Place the pragma in the C source within the body of the loop:
#pragma HLS loop_tripcount min= max= avg=
Where:
max=
: Specifies the maximum number of loop iterations.min=
: Specifies the minimum number of loop iterations.avg=
: Specifies the average number of loop iterations.
Examples
In this exampleloop_1
in functionfoo
is specified to have a minimum tripcount of 12 and a maximum tripcount of 16:
void foo (num_samples, ...) { int i; ... loop_1: for(i=0;i< num_samples;i++) { #pragma HLS loop_tripcount min=12 max=16 ... result = a + b; } }
See Also
- Vivado Design Suite User Guide: High-Level Synthesis(UG902)