Step 2: Running Software Emulation
This step shows you how to run Software Emulation for a design, by setting Run Configuration settings, opening reports, and showing how to launch Debug. You can find details about reports and Debug in the SDAccel Environment User Guide.
-
To run CPU Emulation, go to Application Project Settings and ensure that Active build configuration is set to Emulation-SW.
Figure: SDx Project Settings
-
From the Github example, an accelerator already exists for the design. To add a hardware function to a design that does not have one, start by clicking on the Add Hardware Function button:
. This analyzes the C/C++ code and determines functions that can be used for acceleration.
-
Click the Run button:
to run Software Emulation. This builds the project before running the emulation.
Note: In some cases, the design may need some command line inputs to function properly. To set these arguments, changes must be made in the Run Configurations dialog. -
Go to the Run menu and select Run Configurations.
-
Under the Arguments tab, there is a section that allows you to add command line flags and switches. In this tutorial, no command line arguments are needed for the design to function.
-
Click the Profile tab, and notice that Generate timeline report and Collect device data have dropdown menus. Click each one and note what type of reports are generated, and make sure Default is set. Close the window without changing anything.Note: If you make changes, you need to re-run the current emulation step in order to see the changes. You can do this by clicking the Run button.
-
The Console window should now show TEST PASSED.
-
After the emulation run is complete, you can review the Profile Summary and Application Timeline reports for details on further optimizations. In the Reports window, double-click Profile Summary. Here, you can view operations, execution time, bandwidth, and other useful data that you can use to optimize the design. Note that your summary numbers may vary from the following figure.
Figure: Emulation-SW Profile Summary
-
To view the Application Timeline report, in the Reports window, double-click Application Timeline. This shows a breakdown of the host code and the kernel code, and execution time for each. To zoom into a specific area, click and drag the mouse to the right.
Figure: Application Timeline Report
- The Profile Summary and Application Timeline present data on how the host code and kernel communicate and process kernel information. Using the Debug feature can help you to step through host-kernel processing to pinpoint issues. In the Project Explorer window double-click the host.cpp (located in the Explorer > src directory) to open the file in the editor.
-
To run in Debug, you need to set a breakpoint. Setting breakpoints at key points in the execution helps identify problems. To pause the host code right before kernel debug begins, right-click on line 70 in the blue area (see figure below) on the
outBufVec.push_back(buffer_C)
and select Toggle Breakpoint.Figure: Setting Breakpoint
-
To run Debug, click the Debug icon:
. A dialog box opens up asking you to switch to that perspective. Click Yes.
-
Using Eclipse debugging, you can examine the host and kernel code in more detail. All the controls with which to do step-by-step debugging are in the Run menu.
Figure: Eclipse Debugging
-
The debugger has an automatic breakpoint at the first line of
main
. In the Runs Configuration dialog, there is an option to stop on themain
function (see the following figure). This is helpful in case of a problematic function in need of more thorough debugging. Press F8 to resume to the next breakpoint or from the Run menu select Resume.Figure: Run Configuration
-
After resuming debugging, SDx launches another gdb instance for the kernel code, and it also has a breakpoint at the beginning of the function. This allows for detailed analysis of the kernel and how the data looks being read into the function, and written out to memory. Once the kernel execution is done in gdb, that instance is terminated and you return to the main debugging thread. Press F8 to continue.Note: The console view still shows the kernel debug outputs. Click the icon
to go back to the vadd.exe console and see the output from the host code.
-
Close the Debug Perspective by going to the upper-right of the window where it shows the Debug
button, right-click, and select Close.
- Once back into the main SDx Perspective, close all tabs except the SDx Project Settings window.