Intel® High Level Synthesis Compiler Pro Edition: Best Practices Guide
Visible to Intel only — GUID: fkr1550767758400
Ixiasoft
Visible to Intel only — GUID: fkr1550767758400
Ixiasoft
6.1. Reuse Hardware By Calling It In a Loop
Loops are a useful way to reuse hardware. If your component function calls another function, the called function will be the top-level component. Calling a function multiple times results in hardware duplication.
int foo(int a) { return 4 + sqrt(a) / } component void myComponent() { ... int x = x += foo(0); x += foo(1); x += foo(2); ... }
component void myComponent() { ... int x = 0; #pragma unroll 1 for (int i = 0; i < 3; i++) { x += foo(i); } ... }
component void myComponent() { ... int x = 0; #pragma unroll 1 for (int i = 0; i < 3; i++) { int val = 0; switch(i) { case 0: val = 3; break; case 1: val = 6; break; case 2: val = 1; break; } x += foo(val); } ... }
You can learn more about reusing hardware and minimizing inlining be reviewing the resource sharing tutorial available in <quartus_installdir>/hls/examples/tutorials/best_practices/resource_sharing_filter.