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. TheALLOCATIONpragma 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 functionfoo_sub, theALLOCATIONpragma can ensure that there is only one instance offoo_subin 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 theALLOCATIONpragma. 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_opargument of theconfig_bindcommand to globally minimize operators throughout the design.

Tip:For more information refer to "Controlling Hardware Resources" and config_bindin 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=\ limit=

Where:

  • instances=: Specifies the names of functions, operators, or cores.
  • limit=: Optionally specifies the limit of instances to be used in the kernel.
  • : 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 theinstances=list. The function can be any function in the original C or C++ code that has NOT been:
      • Inlined by thepragma HLS inline, or theset_directive_inlinecommand, or
      • Inlined automatically by Vivado HLS.
    • operation: Specifies that the allocation applies to the operations listed in theinstances=list. Refer toVivado Design Suite User Guide: High-Level Synthesis(UG902) for a complete list of the operations that can be limited using theALLOCATIONpragma.
    • core: Specifies that theALLOCATIONapplies 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 theinstances=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 functionfoo, this example limits the number of instances offooin 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 functionmy_functo 1. This limit does not apply to any multipliers outside ofmy_func, or multipliers that might reside in sub-functions ofmy_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