Adding Pragmas and Directives - 2023.2 English

Vitis High-Level Synthesis User Guide (UG1399)

Document ID
UG1399
Release Date
2023-12-18
Version
2023.2 English

HLS pragmas and directives let you configure the synthesis results for your code.

  • HLS Pragmas are added to the source code to enable the optimization or change in the original source code. Every time the code is synthesized, it is implemented according to the specified pragmas.
  • HLS Optimization Directives can be specified as HLS configuration file commands that are associated with the HLS component. The config files can be reused across multiple HLS components, allowing you to customize the synthesis results for the same code base across different components.
Important: In some cases where pragmas or directives conflict with other pragmas or directives, the synthesis process returns an error until you resolve the conflict. However, in some cases the first pragma or directive encountered takes precedence over the second pragma or directive, and the second is ignored. This information should be reported in the log file or console window.

To add pragmas or directives to your project:

  1. In the Vitis Component Explorer open a Source file of the HLS component by selecting it under the Sources folder.
  2. With the Source file opened, select the HLS Directive command () from the far right toolbar menu of the Vitis unified IDE to open the HLS Directive editor, as shown in the following figure.
    Figure 1. HLS Directive Editor
  3. The HLS Directive editor displays a hierarchy of the current source code and lets you add a directive or pragma to the design; directives go into the config file and pragmas go into the source file. In the preceding figure, the entry that is added to the config file is:
    syn.directive.array_partition=dct_2d in_block factor=8 type=cyclic
    After selecting OK, you will see it added to the Config File editor.
  4. Select the Add Directive command from the HLS Directive editor by selecting the function or loop or variable you want to add a directive to and select the '+' on the right side as shown in the following figure.

    Modify an existing directive by selecting the Edit Directive command next to the directive.