Convert the Directives into Pragmas - 2022.2 English

Vitis Tutorials: Getting Started (XD098)

Document ID
XD098
Release Date
2022-11-07
Version
2022.2 English

Now that you have your optimized design, you can transfer the directives from a Tcl script, which the Vitis HLS tool runs, to pragmas in the source code which can be shared to other users or design teams, and used within the Vitis unified software platform. Select the directives in the Directive view, and change them to pragmas using the following process.

  1. Select the dct.cpp tab to make the Code Editor active, or open the source code if needed.

  2. Scroll through the Directives view, right-click any directives you see, and select the Modify Directive. This displays the Vitis HLS Directive Editor.

  3. In the Directive Editor, change the Destination to Source File, and click OK. This changes the directive to a pragma written to the source code files, which you can see displayed in the dct.cpp source file.

    When you change the ARRAY_PARTITION directive for the col_inbuf variable, the tool will return a Warning indicating that it cannot find the col_inbuf variable, and will insert the pragma at the first line of the function. Select OK to insert the pragma as indicated.

    You must manually correct the placement of the pragma by cutting and pasting the #pragma HLS ARRAY_PARTITION... line into the dct.cpp file after the definition of the col_inbuf variable on line 42. The pragma must be defined after the variable in order to be associated correctly by the compiler. If this is not done, Vitis HLS will return an error when trying to compile the code.

    With the directives converted to pragmas, the dct.cpp code is now portable and carries the optimizations you have completed within the code.

  4. To save the dct.cpp file with the pragmas into the ./vitis_hls_analysis/reference-files folder, select File > Save As. You can use the file in the next lab.