3.5.2.2 Loop Unrolling
(Ask a Question)SmartHLS™ allows the user to specify a loop to be unrolled through the use of a pragma, #pragma HLS loop unroll
(see Unroll Loop ).
#pragma HLS loop unroll
for (i = 0; i < N; i++) {
...
}
This unrolls the loop completely. Unrolling a loop can improve performance as the hardware units for the loop body are replicated, but it also increases area. You may also specify a loop to be partially unrolled, to prevent the area from increasing too much.
#pragma HLS loop unroll factor(2) for (i = 0; i < N; i++) { ... }
This unrolls the loop two times (i.e., the number of loop iteration is halved and the loop body is doubled). You may also prevent a loop from being unrolled. SmartHLS automatically unrolls small loops, but you may not want the loop to be unrolled due to area constraints or to pipeline the loop. If the loop is completely unrolled, the loop disappears, hence you cannot pipeline the loop.
This prevents the loop from being unrolled.
#pragma HLS loop unroll factor(1) for (i = 0; i < N; i++) { ... }