Adding Pragmas and Directives - 2021.2 English

Vitis High-Level Synthesis User Guide (UG1399)

Document ID
Release Date
2021.2 English

Vitis 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.
  • Optimization Directives, or the set_directive commands, can be specified as Tcl commands that are associated with a specific solution, or set of solutions. Allowing you to customize the synthesis results for the same code base across different solutions.
Important: In cases where pragmas or directives conflict with other pragmas or directives, the synthesis process returns an error until the conflict is resolved. For example, assigning ARRAY_PARTITION and ARRAY_RESHAPE pragmas to the same array variable will result in an error.

To add pragmas or directives to your project:

  1. In the Explorer view of the Vitis HLS IDE, double-click the code file under the Source folder to open the Code Editor dialog box, the Outline view, and the Directive view.
  2. Use the Directive view to add pragmas to your source code. This view helps you add and manage pragmas and directives for your project, and it ensures that the pragmas are correct and applied in the proper location. To use this view:
    1. With your source code open, select the Directive view tab to locate the function, loop, or feature of the code to add a pragma or directive to.

      Vitis HLS applies directives to the appropriate scope for the object currently selected in the Directive view.

    2. Right-click an object in the Directive view to use the Insert Directive command. The Vitis HLS Directive Editor opens, as shown in the following figure:

    3. Review the Vitis HLS Directive Editor dialog box. It includes the following sections:
      Specifies the directive or pragma to apply. This is a drop-down menu that lets you choose from the list of available directives.
      Specifies that a pragma should be added to the source file, or that a set_directive command should be added to a Tcl script, the directive file, associated with the active solution.
      Tip: If your project only has one solution then it is always active. However, if you have multiple solutions you will need to ensure the desired solution is active in the project. Right-click the solution in the Explorer view of the project and click the Set Active Solution command. Refer to Creating Additional Solutions for details on adding solutions.
      Lists various configurable options associated with the currently selected directive.
    4. Click OK to apply the pragma or directive.
    Note: To view information related to a selected directive, click Help.