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. TheALLOCATION
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 functionfoo_sub
, theALLOCATION
pragma can ensure that there is only one instance offoo_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 theALLOCATION
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 theconfig_bind
command to globally minimize operators throughout the design.
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=
\ 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 the
pragma HLS inline
, or theset_directive_inline
command, or - Inlined automatically by Vivado HLS.
- Inlined by the
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 theALLOCATION
pragma.
core
: Specifies that theALLOCATION
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 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 offoo
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 functionmy_func
to 1. This limit does not apply to any multipliers outside ofmy_func
, or multipliers that might reside in sub-functions ofmy_func
.
my_func
.
void my_func(data_t angle) { #pragma HLS allocation instances=mul limit=1 operation ... }
See Also
- pragma HLS function_instantiate
- pragma HLS inline
- Vivado Design Suite User Guide: High-Level Synthesis(UG902)