pragma HLS allocation

Description

Specifies instance restrictions to limit resource allocation in the implemented kernel. This defines, and can limit, the number of RTL instances and hardware resources used to implement specific functions, loops, operations or cores. The ALLOCATION pragma is specified inside the body of a function, a loop, or a region of code.

For example, if the C source has four instances of a function foo_sub, the ALLOCATION pragma can ensure that there is only one instance of foo_sub in the final RTL. All four instances of the C function are implemented using the same RTL block. This reduces resources utilized by the function, but negatively impacts performance.

The operations in the C code, such as additions, multiplications, array reads, and writes, can be limited by the ALLOCATION pragma. Cores, which operators are mapped to during synthesis, can be limited in the same manner as the operators. Instead of limiting the total number of multiplication operations, you can choose to limit the number of combinational multiplier cores, forcing any remaining multiplications to be performed using pipelined multipliers (or vice versa).

The ALLOCATION pragma applies to the scope it is specified within: a function, a loop, or a region of code. However, you can use the -min_op argument of the config_bind command to globally minimize operators throughout the design.

Tip: For more information refer to "Controlling Hardware Resources" and config_bind in Vivado Design Suite User Guide: High-Level Synthesis (UG902).

Syntax

Place the pragma inside the body of the function, loop, or region where it will apply.

#pragma HLS allocation instances=<list> \
limit=<value> <type>

Where:

  • instances=<list>: Specifies the names of functions, operators, or cores.
  • limit=<value>: Optionally specifies the limit of instances to be used in the kernel.
  • <type>: Specifies that the allocation applies to a function, an operation, or a core (hardware component) used to create the design (such as adders,multipliers, pipelined multipliers, and block RAM). The type is specified as one of the following::
    • function: Specifies that the allocation applies to the functions listed in the instances= list. The function can be any function in the original C or C++ code that has NOT been:
      • Inlined by the pragma HLS inline, or the set_directive_inline command, or
      • Inlined automatically by Vivado HLS.
    • operation: Specifies that the allocation applies to the operations listed in the instances= list. Refer to Vivado Design Suite User Guide: High-Level Synthesis (UG902) for a complete list of the operations that can be limited using the ALLOCATION pragma.
    • core: Specifies that the ALLOCATION applies to the cores, which are the specific hardware components used to create the design (such as adders, multipliers, pipelined multipliers, and block RAM). The actual core to use is specified in the instances= option. In the case of cores, you can specify which the tool should use, or you can define a limit for the specified core.

Example 1

Given a design with multiple instances of function foo, this example limits the number of instances of foo in the RTL for the hardware kernel to 2.

#pragma HLS allocation instances=foo limit=2 function

Example 2

Limits the number of multiplier operations used in the implementation of the function my_func to 1. This limit does not apply to any multipliers outside of my_func, or multipliers that might reside in sub-functions of my_func.

Tip: To limit the multipliers used in the implementation of any sub-functions, specify an allocation directive on the sub-functions or inline the sub-function into function my_func.
void my_func(data_t angle) {
#pragma HLS allocation instances=mul limit=1 operation
...
}

See Also