9.3Functional mode
This section describes how to build, run, and debug the spm_demo project testbench module in functional mode.
9.3.1Build
To build the testbench module in functional mode:
-
Select architecture sp16 and mode Functional on the toolbar.
-
Click the arrow to the right of the build icon (the hammer) and select spm_demo from the drop down options. The IDE displays build commands in the Console view as it runs the build (Figure 9). New folders Binaries, Includes, and build appear in the Stream Projects view.
Figure 9: Functional Mode Build
9.3.2Run on host
After successfully building the module, you must create a run configuration to allow you to run it. For the spm_demo testbench module, the run configuration specifies the locations of the bitmap input and output files.
-
Click the arrow next to the Run button on the toolbar and select Run Configurations...
-
In the Run Configurations window, right-click on Stream Application and select New. [Alternatively, click on Stream Application, then click on the New icon on the toolbar.]
-
Enter testbench as the Name of the run configuration.
-
Pull down testbench as the Primary module (Figure 10). Do not hit Run yet, as you still must enter the arguments for the run configuration.
Figure 10: Run Configuration
-
Click on the Arguments tab.
-
Enter the program arguments. The testbench arguments are the input file and the output file: src/data/sample.bmp src/data/result.bmp (Figure 11). Pathnames must be relative to the project directory. When you run an executable under the IDE, the IDE’s current working directory is the project’s directory within the IDE workspace, not the directory from which you invoked the IDE.
Figure 11: Run Configuration Arguments
-
Hit Apply, then hit Run. The IDE runs the testbench functional mode executable on the host and displays the program output in the Console view (Figure 12).
Figure 12: Run
9.3.3Debug
To begin debugging the functional mode program, pull down the arrow next to the debug icon and select testbench. The IDE builds a debug executable and prompts you to confirm a switch to the Debug perspective. It starts program execution, stopping at the beginning of spi_main in source file spimain.c, as displayed in the spimain.c editor view (Figure 13).
Figure 13: Debug Perspective
The debug perspective contains several additional views, including Variables (program variables), Breakpoints (debugging breakpoints), Streams (stream contents), Vectors (kernel vector variables), and Modules (program modules).
The Run menu shows the available program control options, including function keys F5 (Step Into), F6 (Step Over), F7 (Step Return), and F8 (Resume).
-
Hit F6 four times and watch the spimain.c source view highlighting change as the debugger steps through the program.
-
Hit F5 to step into gsr_pipeline; the source view switches to Stream source file gsr_pipeline.sc.
-
Click in the source window, then scroll up and set a breakpoint at the beginning of kernel gsr_compute_average by double-clicking on the left of the source view (Figure 14).
Figure 14: Set Breakpoint
-
Hit F8 to run to the breakpoint.
-
Click in the Variables pane and scroll to find variable cond. Since cond is a vector variable, it has a different value in each lane of the stream processor.
-
Expand cond to see its uninitialized value in each lane.
-
Hit F6 to step past the assignment to variable cond:
cond = (spi_laneid() == 0);
This sets the value of cond to 1 in lane 0 and 0 in all other lanes. The Variables pane shows the new values, with the changed values highlighted (Figure 15).
Figure 15: Variables View
You should continue to step through the program and set breakpoints to become familiar with the operation of the IDE. You can use the stop button on the console toolbar to stop a running program.
9.3.4Fast functional mode
Like functional mode, fast functional mode simulates a program functionally on the host; it does not accurately simulate stream processor performance. It gives better performance than functional mode, but the generated program may be more difficult to debug because of optimization. For example, stepping through a program may jump to an unexpected location in the source, or the values of variables may change in unexpected ways.
To build and run a program in fast functional mode, pull down arrow next to the mode on the IDE toolbar and select functional_fast, then follow the instructions for functional mode above.
Share with your friends: |