Using Directives in Scripts vs. Pragmas in Code - 2023.2 English

Vitis High-Level Synthesis User Guide (UG1399)

Document ID
Release Date
2023.2 English

In the HLS Directive editor you can specify either of the following Destination settings:

Source File
The Vitis unified IDE inserts the directive directly into the C source file as a pragma.
Config File
The IDE inserts the directive into the HLS config file.

The following table describes the advantages and disadvantages of both approaches.

Table 1. Config File Directive versus HLS Pragma
Directive Format Advantages Disadvantages
HLS Config File

The Source code remains unchanged, while design exploration is handled through the config file entries. This approach is ideal for design exploration.

If the C source files are transferred to a third-party or archived, the directives.tcl file must be included.

The directives.tcl file is required if the results are to be re-created.

Source Code Pragma

The optimization directives are embedded into the C source code.

Ideal when the C sources files are shipped to a third-party as C IP. No other files are required to recreate the same results.

Useful approach for directives that are unlikely to change, such as TRIPCOUNT and INTERFACE.

If the optimization directives are embedded in the code, they are automatically applied to every HLS component that references that source code.
Tip: You can use directives to develop different design possibilities, but you might want to convert your final directives to HLS pragmas when finalized. This allows the optimization pragmas to be carried as part of the source code for the design.

When specifying values for pragma arguments, you can use literal values (for example, 1, 55, 3.14), or pass a macro using #define. The following example shows a pragma with literal values:

#pragma HLS ARRAY_PARTITION variable=k_matrix_val  type=cyclic factor=5

This example uses defined macros:

#define E 5
#pragma HLS ARRAY_PARTITION variable=k_matrix_val  type=cyclic factor=E