Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

27
Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014 http://csg.csail.mit.edu/6.175 T01-1

Transcript of Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

Page 1: Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

Constructive Computer Architecture

Tutorial 3

Debugging BSVAndy Wright6.175 TA

September12, 2014 http://csg.csail.mit.edu/6.175 T01-1

Page 2: Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

Review

Last Tutorial: Scheduling Typeclasses

Recent Lectures: SMIPS ISA

September12, 2014 L03-2http://csg.csail.mit.edu/6.175

Page 3: Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

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

Page 4: Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

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

Page 5: Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

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

Page 6: Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

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

Page 7: Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

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”

Page 8: Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

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

Page 9: Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

BSV Debugging Example

Using the Bluespec GUI and the GTKWave waveform viewer

September12, 2014 L03-9http://csg.csail.mit.edu/6.175

Page 10: Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

Step 1

Generate VCD FileRun ./simTestName -V test.vcd

September12, 2014 L03-10http://csg.csail.mit.edu/6.175

Page 11: Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

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

Page 12: Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

Step 3

Set top module nameOpen project options

September12, 2014 L03-12http://csg.csail.mit.edu/6.175

Page 13: Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

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

Page 14: Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

Step 4

Open Module Viewer

September12, 2014 L03-14http://csg.csail.mit.edu/6.175

Page 15: Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

Step 4

Open Module Viewer

September12, 2014 L03-15http://csg.csail.mit.edu/6.175

Page 16: Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

Step 5

Open Wave Viewer

September12, 2014 L03-16http://csg.csail.mit.edu/6.175

Page 17: Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

Step 5

Open Wave Viewer

September12, 2014 L03-17http://csg.csail.mit.edu/6.175

Page 18: Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

September12, 2014 L03-18http://csg.csail.mit.edu/6.175

Step 6

Open Wave Viewer

Page 19: Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

Step 6

Add Some Signals

September12, 2014 L03-19http://csg.csail.mit.edu/6.175

Page 20: Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

Step 6

Add Some Signals

September12, 2014 L03-20http://csg.csail.mit.edu/6.175

Module Hierarchy

Signals

Page 21: Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

Step 7

Look at the Waveforms

September12, 2014 L03-21http://csg.csail.mit.edu/6.175

Page 22: Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

Step 7

Look at the Waveforms

September12, 2014 L03-22http://csg.csail.mit.edu/6.175

Types Human readable value names

Page 23: Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

Step 7

Look at the Waveforms

September12, 2014 L03-23http://csg.csail.mit.edu/6.175

Page 24: Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

Step 8

Add Some More Signals

September12, 2014 L03-24http://csg.csail.mit.edu/6.175

Page 25: Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

Step 8

Add Some More Signals

September12, 2014 L03-25http://csg.csail.mit.edu/6.175

Page 26: Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

Step 9

Add Rules Too

September12, 2014 L03-26http://csg.csail.mit.edu/6.175

Page 27: Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright 6.175 TA September12, 2014.

Step 9

Add Rules Too

September12, 2014 L03-27http://csg.csail.mit.edu/6.175