pragma HLS occurrence - 2022.2 English

Vitis High-Level Synthesis User Guide (UG1399)

Document ID
UG1399
Release Date
2022-12-07
Version
2022.2 English

Description

When pipelining functions or loops, the OCCURRENCE pragma specifies that the code in a pipelined function call within the pipelined function or loop is executed less frequently than the code in the enclosing function or loop. This allows the pipelined call that is executed less often to be pipelined at a slower rate, thus potentially improving the resource sharing potential within the top-level pipeline. To determine the OCCURRENCE pragma, do the following:

  • A loop iterates <N> times.
  • However, part of the loop body is enabled by a conditional statement, and as a result only executes <M> times, where <N> is an integer multiple of <M>.
  • The conditional code has an occurrence that is N/M times slower than the rest of the loop body.

For example, in a loop that executes 10 times, a conditional statement within the loop only executes two times has an occurrence of 5 (or 10/2).

Identifying a region with the OCCURRENCE pragma allows the functions and loops in that region to be pipelined with a higher initiation interval that is slower than the enclosing function or loop.

Syntax

Place the pragma in the C source within a block of code that contains the pipelined function call(s).

#pragma HLS occurrence cycle=<int>

Where:

cycle=<int>
Specifies the occurrence N/M.
<N>
Number of times the enclosing function or loop is executed.
<M>
Number of times the conditional region is executed.
Important: <N> must be an integer multiple of <M>.

Examples

In this example, the call of subfunction within the if statement (but not the memory read and write, since they are not inside a pipelined function) has an occurrence of 4 (it executes at a rate four times less often than the surrounding code that contains it). Hence, while without the occurrence pragma it would be pipelined with the same II as the caller, with the occurrence pragma it will be pipelined with an II=4. This will expose more resource sharing oppportunities within it and with other functions.

void subfunction(...) {
#pragma HLS pipeline II=...
// Without the occurrence pragma, 
// this will be automatically pipelined with an II=1, 
// regardless of its own pipeline pragma, 
// since it is called in a pipeline with II=1
// With the pragma, it has an II=4.
  ...
}
for (int i = 0; i < 16; i++) {
#pragma HLS pipeline II=1
  if (i % 4 == 0) {
#pragma HLS occurrence cycle=4
    subfunction(...);
    a[i+1] = b[i];
  }
}