Why does Loop Streaming not work for my nested loop when generating HDL Code?
조회 수: 5 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2018년 10월 9일
편집: MathWorks Support Team
2024년 3월 1일
I would like to decrease hardware resource usage in my FPGA design by applying Loop Streaming optimization. In the Check Report provided after HDL code generation, I can see a warning that streaming failed:
"Could not apply coder.hdl.loopspec pragma with the 'stream' option. This could be because the 'stream' option
was applied on a loop containing a nested loop with a streaming factor that is not equal to the number of iterations,
or because the 'stream' option was applied in a System Object."
My loop indeed contains a nested loop, but the streaming factor is accurate. Also, I have closely followed the requirements and limitations given in the documentation which can be accessed by running the following command in the MATLAB R2018b:
web(fullfile(docroot, 'hdlcoder/ug/loop-optimization-1.html'))
Why is streaming still failing?
Please follow the below link to search for the required information regarding the current release:
채택된 답변
MathWorks Support Team
2024년 1월 18일
편집: MathWorks Support Team
2024년 3월 1일
Besides the points mentioned on the documentation page, nested loops are only supported for streaming when the loop body resides in the nested loop alone, i.e. loop over rows in outer loop and columns in inner loop for some element-wise operations on a matrix.
If the loop body almost solely lives in the outer loop, it cannot be streamed as it is. In this case, in order to do loop streaming on the outer loop, this nested loop could be unrolled. This can be done by using a second loopspec pragma and specifying 'unroll' in it at the nested loop:
coder.hdl.loopspec('stream')
for i = 1:N
%...
%...
%...
%...
%...
%...
%...
coder.hdl.loopspec('unroll')
for j = 1:M
%...
end
%...
end
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!