Lab 5: Debugging
Lab 5: Debugging
VERSION 2.0
Lab 5: Debugging
Overview
This lab will give you a chance to explore different methods of debugging your project on
the FPGA board. It covers both the XPS and ISE flows. If you are using XPS look at parts
1 and 3 for hardware debugging, and part 4 for software debugging. If you are using ISE
look at parts 2 and 3 for hardware debugging.
Theory
ChipScope is the program we will use for hardware debugging. The main use of
ChipScope is for its ILA (Integrated Logic Analyzer) cores. Based on some trigger
condition the ILA will capture all the input data into an attached BRAM, and then feed
the data to the ChipScope program to be analyzed. You can have multiple ILA cores with
multiple inputs. The ILA cores feed into an ICON core that controls everything. There
are also VIO (virtual IO) cores for interacting with the FPGA internals.
For software debugging XPS provides a method of doing remote debugging of the CPU
using GDB. This allows the host to control the FPGA, stepping through and analyzing
instructions.
PAGE 1 OF 12
18-545
VERSION 2.0
There are monitors for the OPB and PLB bus (useful if your device is a bus master and
generates requests of its own). We are interested in the ILA which can monitor arbitrary
signals.
Now that the ILA has been added, specify signals for it to monitor. There are up to 16
trigger groups, each of which can monitor different signals and can trigger a capture.
Select TRIG0 and add slv_reg0 to it. Likewise for TRIG1 and slv_reg1 and the rest.
PAGE 2 OF 12
18-545
VERSION 2.0
For the number of signal samples, increase it as high as reasonable, keeping in mind
that our boards have only 136 BRAMS (there is a count of how many are used at the
bottom).
Note that the default trigger units can only match on == and !=. You can change
them to match on conditionals (<, >, <=, >=) and also ranges, but it takes more logic. To
change this select the Advanced tab, then Trigger Unit. For each Trigger Unit you can
change the Match Type from basic to extended (conditionals) or range.
PAGE 3 OF 12
18-545
VERSION 2.0
Now configure the ILA to meet your needs. First select the number of Input Trigger
Ports, and the size of each port. You can also select the type of matching that will happen
for that port.
PAGE 4 OF 12
18-545
VERSION 2.0
Next configure the Capture Parameters for the ILA. You want to have Data Same As
Trigger, and all of the trigger ports check to be used as data. The one thing to change is
the Data Depth of the capture. The more samples captured are better, but keep track of
the BRAM Count on the left (these boards have 136 BRAMs).
PAGE 5 OF 12
18-545
VERSION 2.0
Finally go to the Net Connections tab and select Modify Connections. First connect a
clock signal from the design on the left to the clock signal channel. Next connect up the
individual ports from the left to each of the channels on the right.
You can click on ICON on the left tree and select New ILA Unit to add another analyzer.
Once you are done click on Return to Project Navigator or File Save and then File
Exit.
Now when you recompile the design it will automatically create the ChipScope cores for
you and place them within the design. If you no longer want any ChipScope cores simply
delete the CDC file and recompile.
PAGE 6 OF 12
18-545
VERSION 2.0
Click Unblock if a Windows Firewall warning pops up. You should then see a screen
with information of what ChipScope is connected to. Click OK
You are now presented with 3 main screens you are interested in: A list of all the signals
on the left, Trigger setup on the top, and Waveforms on the bottom.
Useful trick to start: expand the Trigger Ports, hit F2 (for rename) and hold down enter.
This will rename the data ports to match the trigger ports, making them easier to use.
Next you can make busses out of the individual wires. Highlight the wires you want to
join into a bus, right click, select Add to Bus and New Bus.
PAGE 7 OF 12
18-545
VERSION 2.0
Now that you have busses defined right-click on the Waveform window under Bus/
Signal and select Clear All. Now drag your busses from the left into the Waveform
window.
PAGE 8 OF 12
18-545
VERSION 2.0
Next you selected the matches, you can select how to trigger based on those. Click on
TriggerCondition0. You can make an equation for triggering based on your matching
units or trigger after a sequence of matches happens.
You can have more than one trigger condition, but only 1 can be active at any time.
You will now have data in your waveform screen. The waveform screen is fairly similar
to any other waveform view, like in ModelSim. You can change the radix of each bus
(right-click on it). You have two cursors to move (O and X). you can expand a bus to see
individual wires. There are also the normal zoom controls on the top menu bar.
PAGE 9 OF 12
18-545
VERSION 2.0
If your project does not have the jtagppc_ctrl module, you will have to add it, a 2nd
ppc405 core, and wire up the JTAG to the external ports. Its probably easier to create a
new project selecting FPGA JTAG debugging and copy everything to the new project.
PAGE 10 OF 12
18-545
VERSION 2.0
Type help to see a list of options you can type on this prompt. While you can use the
shell, its not very friendly. An easier system to use is the graphical GDB environment.
To launch that go to Debug Launch Software Debugger. Note that XMD must be
started first.
PAGE 11 OF 12
18-545
VERSION 2.0
To connect go to Run Connect to Target. This will cause a breakpoint on the CPU
wherever it is currently executing. You can also select Run Run to re-download the
program and restart it from main(). By default it sets a breakpoint at main() so you can
step the program from the start.
Within this GUI you have a full GDB environment. You can walk the execution, go to a
gdb text console, view registers, the stack, set break and watch points, etc.
Part 5: Demonstration
We are going to trust that you have worked through this lab and learned lessons that will
be very helpful on your project. Simply tell a TA that you have completed the lab. The
TA may ask you a few questions, so be prepared.
PAGE 12 OF 12