Constructive Computer Architecture
Tutorial 3
Debugging BSVAndy Wright6.175 TA
September12, 2014 http://csg.csail.mit.edu/6.175 T01-1
Review
Last Tutorial: Scheduling Typeclasses
Recent Lectures: SMIPS ISA
September12, 2014 L03-2http://csg.csail.mit.edu/6.175
Software DebuggingPrint Statements
See a bug, not sure what causes itAdd print statementsRecompileRunStill see bug, but you have narrowed it down to a smaller portion of codeRepeat with more print statements…Find bug, fix bug, and remove print statements
September12, 2014 L03-3http://csg.csail.mit.edu/6.175
BSV DebuggingDisplay Statements
See a bug, not sure what causes itAdd display statementsRecompileRunStill see bug, but you have narrowed it down to a smaller portion of codeRepeat with more display statements…Find bug, fix bug, and remove display statements
September12, 2014 L03-4http://csg.csail.mit.edu/6.175
BSV Display Statements
The $display() command is an action that prints statements to the simulation consoleExamples: $display(“Hello World!”); $display(“The value of x is %d”, x); $display(“The value of y is “, fshow(y));
September12, 2014 L03-5http://csg.csail.mit.edu/6.175
Ways to Display ValuesFormat Specifiers
%d – decimal%b – binary%o – octal%h – hexadecimal%0d, %0b, %0o, %0h Show value without extra whitespace
padding
September12, 2014 L03-6http://csg.csail.mit.edu/6.175
Ways to Display Valuesfshow
fshow is a function in the FShow typeclassIt can be derived for enumerations and structuresExample:
typedef emun {Red, Blue} Colors deriving(FShow);Color c = Red;$display(“c is “, fshow(c));
September12, 2014 L03-7http://csg.csail.mit.edu/6.175
Prints “c is Red”
BSV DebuggingWaveform Viewer
Simulation executables can dump VCD waveforms ./simMyTest –V test.vcd
Produces test.vcd containing the values of all the signals used in the simulator Not the same as normal BSV signals
VCD files can be viewed by a waveform viewer Such as gtkwave
The signal names and values in test.vcd can be hard to understand Especially for structures and enumerations
September12, 2014 L03-8http://csg.csail.mit.edu/6.175
BSV Debugging Example
Using the Bluespec GUI and the GTKWave waveform viewer
September12, 2014 L03-9http://csg.csail.mit.edu/6.175
Step 1
Generate VCD FileRun ./simTestName -V test.vcd
September12, 2014 L03-10http://csg.csail.mit.edu/6.175
Step 2
Open Bluespec GUIRun “bluespec fifo.bspec”
September12, 2014 L03-11http://csg.csail.mit.edu/6.175
Note, to run the GUI remotely, you need to SSH into the servers with the “ssh –X” command
For the fifo lab, fifo.bspec can be found in
Step 3
Set top module nameOpen project options
September12, 2014 L03-12http://csg.csail.mit.edu/6.175
Step 3
Set top module nameSet the top module name to match the compiled module in TestBench.bsv
September12, 2014 L03-13http://csg.csail.mit.edu/6.175
Step 4
Open Module Viewer
September12, 2014 L03-14http://csg.csail.mit.edu/6.175
Step 4
Open Module Viewer
September12, 2014 L03-15http://csg.csail.mit.edu/6.175
Step 5
Open Wave Viewer
September12, 2014 L03-16http://csg.csail.mit.edu/6.175
Step 5
Open Wave Viewer
September12, 2014 L03-17http://csg.csail.mit.edu/6.175
September12, 2014 L03-18http://csg.csail.mit.edu/6.175
Step 6
Open Wave Viewer
Step 6
Add Some Signals
September12, 2014 L03-19http://csg.csail.mit.edu/6.175
Step 6
Add Some Signals
September12, 2014 L03-20http://csg.csail.mit.edu/6.175
Module Hierarchy
Signals
Step 7
Look at the Waveforms
September12, 2014 L03-21http://csg.csail.mit.edu/6.175
Step 7
Look at the Waveforms
September12, 2014 L03-22http://csg.csail.mit.edu/6.175
Types Human readable value names
Step 7
Look at the Waveforms
September12, 2014 L03-23http://csg.csail.mit.edu/6.175
Step 8
Add Some More Signals
September12, 2014 L03-24http://csg.csail.mit.edu/6.175
Step 8
Add Some More Signals
September12, 2014 L03-25http://csg.csail.mit.edu/6.175
Step 9
Add Rules Too
September12, 2014 L03-26http://csg.csail.mit.edu/6.175
Step 9
Add Rules Too
September12, 2014 L03-27http://csg.csail.mit.edu/6.175