Using the Debug Environment - 2021.1 English

Versal ACAP AI Engine Programming Environment User Guide (UG1076)

Document ID
UG1076
Release Date
2021-07-19
Version
2021.1 English

The Vitis IDE debug environment has many features found in traditional GUI-based debug environments, such as GDB. You can add break points to the code, step over or step into specific lines of codes, loops, or functions, and examine the state of variables and force them to specific values. These are just a few of the features in the Vitis IDE debug environment.

After you have launched the Debug perspective, you will see several windows or views displayed, such as the Debug view in the upper left of the display, as shown in the following figure. During the debug process, several windows show the debug state that include code at break point, step over states, break-points view, variables view, registers view, disassemble view, and pipeline view (single kernel only).

The Debug view shows states of cores that are under debug. It shows where (which file and which line of source code of the file) debugger stops at and with what action it is taking (breakpoint/step over/…) as shown in the following figure.

Figure 1. Debug View

The following figure shows the Breakpoints information with current setup breakpoints. The square with a check mark indicates the breakpoint is enabled. Click on the check mark to clear the check mark and disable breakpoint during debugging. This lets you manage breakpoints without having to remove them or add them back into the code.

Figure 2. Breakpoints View

Important: Each AI Engine tile supports four breakpoints when debugging on the AI Engine simulator, or co-simulation. The TCF framework stops at the AI Engine kernel main() by default. Breakpoints attached to a while statement consume two breakpoint resources. A workaround is to attach the breakpoint inside the while loop. This only consumes one breakpoint.

The Variables view shows the kernel variables values. Depending on variable type, clicking on a variable shows its type, value, and the address of the variable. For array/structure variables, click on the arrow of the variable expands array/structure content of the array.

Figure 3. Variables View

Click on a variable to obtain address information and then click on the + from the Memory view and enter the memory address of the variable. The value of that variable shows up along with other memory content. Variable values can be changed by click on variable’s value field, enter new value and enter again to set the value of the variable.

You can specify the format of the data presented in the Memory window by clicking on the New Renderings tab, specifying the format of the data to present, and click Add Rendering(s).

Tip: You can export the contents of the Memory window by selecting the Copy to Clipboard command from the right-click menu to copy and paste the contents into a text editor and save to a file.
Figure 4. Registers View

In the Registers view, the values are updated during the debug process and are highlighted in the Vitis IDE.

Figure 5. Disassembly View

The Disassembly view displays machine code and assembly code. C/C++ source code is also embedded between the lines for source code referencing. In the Explorer window, select the AI Engine project and right-click and select Open Disassembly View. It will bring up the following screenshot where you will be able to select the core you want to see disassembled code.
Figure 6. Select Core

Note: In the Disassembly view, NOP instructions are skipped by default. To step the debugger though the NOP instructions, click the Instruction Stepping Mode icon, circled in the following image.
Figure 7. Step Through NOP Instructions
Figure 8. Debugging Controls

The debug control commands let you step into/over/return from the source code. Other commands let you resume, stop, terminate, or disconnect the debugger from the Vitis IDE.

The Vitis IDE supports multi-kernel debug and multi-domain (PS and AI Engine) debug. Depending on the application, there can be hundreds of kernels being debugged. Having granular control of each core as well as all cores within one domain is important. Select one core from the Vitis IDE and click the Resume icon to resume debug execution for the core only. Select one level above all cores within the AI Engine domain, and click the Resume icon to resume all AI Engine core executions. Resuming execution for all the kernels in the graph is dependent on a variety of conditions such as the availability of data to each of the kernels to avoid stalls, or the setup of individual kernel breakpoints. You should also ensure that the kernels not being debugged are free to run.

Figure 9. Selection to Resume Multiple AI Engine Debug

Figure 10. Debug Perspective

Note: The main() function is created automatically by the AI Engine compiler for each core that wraps around the kernel implementation. The Debug view displays the complete source code including the inserted portion.