After completing this lab, you will be able to:
Open the lab4 project from the previous lab, and Save it as lab5 to the {labs} directory. Make sure that the Create Project Subdirectory and Include run results option is checked.
Open the Block Design. You may notice that the status changes to synthesis and implementation out-of-date as the project was saved as. Since the bitstream is already generated and will be in the exported directory, we can safely ignore any warning about this.
In Vivado, select Tools > Launch Vitis IDE
A warning pop-up window indicating that the design is out of date. Since we have not made any changes, we can ignore this.
Click Yes.
Terminal window output
Note: Setting the DIP switches and push buttons will change the results displayed. Flip the DIP switches and verify that the LEDs light with corresponding delay according to the switch settings. Also notice in the Terminal window, the previous and current switch settings are displayed whenever you flip switches.
Right-click on the lab5 project in the Explorer and select Debug as > 1 Launch Hardware (Single Application Debug). Click OK to relaunch the session if prompted.
Double-click in the left margin to set a breakpoint on various lines in lab5.c shown below. A breakpoint has been set when a “tick” and blue circle appear in the left margin beside the line when the breakpoint was set. (The line numbers may be slightly different in your file.)
The first breakpoint is where count is initialized to 0. The second breakpoint is to catch if the timer initialization fails. The third breakpoint is when the program is about to read the dip switch settings. The fourth breakpoint is when the program is about to terminate due to pressing of center push button. The fifth breakpoint is when the timer has expired and about to write to LED.
Setting breakpoints
Click on the Resume button or press F8 to continue executing the program up until the first breakpoint is reached.
In the Variables tab you will notice that the count variable may have value other than 0.
Click the plus sign to add a Memory Monitor
Monitor memory location
Enter the address for the private counter load register (0xF8F00600), and click OK.
Monitoring a Memory Address
You can find the address by looking at the xparameters.h file entry to get the base address (# XPAR_PS7XPAR_PS7_SCUTIMER_0_BASEADDR1
), and find the load offset double-clicking on the xscutimer.h in the outline window followed by double-clicking on the xscutimer_hw.h and then selecting XSCUTIMER_LOAD_OFFSET.
Make sure the DIP Switches are not set to “0000” and click on the Step Over button to execute one statement which will load the timer register.
Notice that the address 0xF8F00604 has become red colored as the content has changed. Verify that the content is same as the value: dip_check_prev*32500000. You will see hexadecimal equivalent (displaying bytes in the order 0 -> 3).
E.g. for dip_check_prev = 1; the value is 0x01EFE920; (reversed: 0x20E9EF01)
Click on the Resume button to continue execution of the program. The program will stop at the writing to the LED port (skipping fourth breakpoint as center push button as has not occurred).
Notice that the value of the counter register is changed from the previous one as the timer was started and the countdown had begun.
Generate linker script
Observe the Vitis Serial Terminal window as the program executes. Play with dip switches and observe the LEDs. Notice that the system is relatively slow in displaying the message and the LED blinks much slower as the stack and heap are from a non-cached BRAM memory.
This lab led you through developing software that utilized CPU’s private timer function calls and achieved the desired functionality. You verified the functionality in hardware. Additionally, you used the Vitis debugger to view the content of variables and memory, and stepped through various part of the code. If needed, you can use a linker script to target various segments in various memories. When the application is too big to fit in the internal BRAM, you can download the application in external memory and then execute the program.