Intel® High Level Synthesis Compiler Pro Edition: Best Practices Guide
A newer version of this document is available. Customers should click here to go to the newest version.
Visible to Intel only — GUID: qxe1506087470699
Ixiasoft
Visible to Intel only — GUID: qxe1506087470699
Ixiasoft
5.8. Declare Variables in the Deepest Scope Possible
To reduce the FPGA hardware resources necessary for implementing a variable, declare the variable just before you use it in a loop. Declaring variables in the deepest scope possible minimizes data dependencies and FPGA hardware usage because the Intel® HLS Compiler Pro Edition does not need to preserve the variable data across loops that do not use the variables.
Consider the following example:
int a[N];
for (int i = 0; i < m; ++i)
{
int b[N];
for (int j = 0; j < n; ++j)
{
// statements
}
}
The array a requires more resources to implement than the array b. To reduce hardware usage, declare array a outside the inner loop unless it is necessary to maintain the data through iterations of the outer loop.