coder.hdl.loopspec
Unroll or stream loops in generated HDL and High-Level Synthesis (HLS) code
Syntax
Description
For HDL Code Generation:
coder.hdl.loopspec('unroll')
fully unrolls a
loop in the generated HDL code. Instead of a loop statement, the generated code
contains multiple instances of the loop body, with one loop body instance per
loop iteration.
The coder.hdl.loopspec
pragma does not affect
MATLAB® simulation behavior.
Note
If you specify the coder.unroll
pragma, this
pragma takes precedence over coder.hdl.loopspec
.
coder.hdl.loopspec
has
no
effect.
For HDL Code Generation:
coder.hdl.loopspec('unroll',
unrolls a loop by the specified unrolling factor,
unroll_factor
)unroll_factor
, in the generated HDL code.
The generated HDL code is a loop statement that contains
unroll_factor
instances of the original loop body. The
number of loop iterations in the generated code is
(original_loop_iterations
/
unroll_factor
). If
(original_loop_iterations
/
unroll_factor
) has a remainder, the remaining
iterations are fully unrolled as loop body instances outside the loop.
This pragma does not affect MATLAB simulation behavior.
For HDL Code Generation:
coder.hdl.loopspec('stream')
generates a single
instance of the loop body in the HDL code. Instead of using a loop statement,
the generated code implements local oversampling and added logic to match the
functionality of the original loop.
You can specify this pragma for loops at the top level of your MATLAB design.
This pragma does not affect MATLAB simulation behavior.
For HDL Code Generation:
coder.hdl.loopspec('stream',
unrolls the loop with stream_factor
)unroll_factor
set to
original_loop_iterations
/
stream_factor
rounded down to the nearest integer, and
also oversamples the loop. If
(original_loop_iterations
/
stream_factor
) has a remainder, the remainder loop body
instances outside the loop are not oversampled, and run at the original
rate.
You can specify this pragma for loops at the top level of your MATLAB design.
This pragma does not affect MATLAB simulation behavior.
For HLS Code Generation:
coder.hdl.loopspec('unroll')
fully unrolls the
for
-loop in the generated HLS code during synthesis. You
must insert this pragma at the first line of the for
-loop
body in your MATLAB code.
This pragma does not affect MATLAB simulation behavior.
For HLS Code Generation:
coder.hdl.loopspec('unroll',
unrolls a unroll_factor
)for
-loop by the specified unrolling factor,
unroll_factor
, in the generated HLS code during
synthesis. You must insert this pragma at the first line of the
for
-loop body in your MATLAB code.
This pragma does not affect MATLAB simulation behavior.
For HLS Code Generation:
coder.hdl.loopspec('pipeline')
pipelines the
for
-loop with the initiation interval of 1, in the
generated HLS code. You must insert this pragma before the
for
-loop to be pipelined.
This pragma does not affect MATLAB simulation behavior.
For HLS Code Generation:
coder.hdl.loopspec('pipeline',
pipelines the initiation_interval
)for
-loop by the specified initiation interval,
initiation_interval
, in the generated HLS code. You must
insert the pragma before the for
-loop to be pipelined. The
initiation_interval
represents the number of clock cycles
before the start of the next iteration of the
for
-loop.
This pragma does not affect MATLAB simulation behavior.