02/10/06eecs150 lab lecture #41 debugging eecs150 spring 2006 – lab lecture #4 philip godoy greg...

30
02/10/06 EECS150 Lab Lecture #4 1 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

Post on 22-Dec-2015

216 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 1

Debugging

EECS150 Spring 2006 – Lab Lecture #4

Philip GodoyGreg Gibeling

Page 2: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 2

Today (1)

Lab #2 Solution Simulation vs Hardware Debugging

Goals Tips Algorithm

Administrative Info

Page 3: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 3

Today (2)

Lab #4 Bottom Up Testing (Peak Detector) Designing Test Hardware (Broken

Adder) Exhaustive FSM Testing (Broken FSM)

Page 4: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 4

module Accumulator(In, Out, Enable, Clock, Reset);input [7:0] In;output [7:0] Out;

input Enable;

input Clock, Reset;

reg [7:0] Out;

always @ (posedge Clock) beginif (Reset) Out <= 8'h00; else if (Enable) Out <= Out + In;

endendmodule

Lab #2 Solution (1)

Page 5: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 5

Lab #2 Solution (2)

and1

not1

or1

In0

In1

EqualIn

GreaterIn

GreaterOut

and2

xor1 not3

not2

EqualOut

Page 6: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 6

Lab #2 Solution (3) Accumulator

Simple, easy to build What is the actual circuit?

Get used to answering this in your head RTL View from Lab #1 (Section 4.3

Synthesis) Peak Detector

Hard to build Minute control of hardware Tools couldn’t optimize though!!

Page 7: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 7

Simulation vs. Hardware (1) Debugging in Simulation

Slow Running Time Fast Debugging

Waveforms Text messages

Full Visibility Can examine any signal

Easy to Fix A few minutes to compile and resimulate

Page 8: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 8

Simulation vs. Hardware (2)

Debugging in Hardware Fast Running Time

Full speed in fact Slow Debugging

Synthesis can take hours Little or No Visibility

Very hard to probe signals Maybe Impossible to Fix (ASICs)

Page 9: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 9

Simulation vs. Hardware (3) Simulation

Functional Testing & Verification Test everything at least minimally Fully Verify what you can

This will save you many sleepless nights

Hardware Debugging

Treat this as a last resort It is painful

Page 10: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 10

Debugging (1)

Debugging Algorithm Hypothesis: What’s broken? Control: Give it controlled test inputs Expected Output: What SHOULD it

do? Observe: Did it work right? If it broke: THAT’S GREAT!

If we can’t break anything like this then the project must be working…

Page 11: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 11

Debugging (2)

First, check for Verilog syntax errors Run Synthesis on the module View Synthesis report to see errors

Don’t debug randomly Just changing things at random often

makes things look fixed It won’t really help Debug systematically Your first design may be the best

Page 12: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 12

Debugging (3)

High Level Debugging Localize the problem

N64? SDRAM? Video? Test Patterns

Lets you easily isolate the broken component

If you know exactly what’s going in you can check what’s coming out

Page 13: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 13

Debugging (4)

Simulate the broken component(s) Writing test benches takes less time

than sitting around wondering why its broken

Everyone hates writing testbenches (Even the TA’s) You will hate hardware debugging more Get used to it

Page 14: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 14

Debugging (5) Your best debugging tool is logic

If 3 out of 4 components work, what’s broken?

Question all your assumptions! Just because you think its true doesn’t

mean it is 90% of debugging time is wasted

debugging the wrong problem otherwise

Given solutions and modules may not work the way you expect!

Page 15: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 15

Debugging (6)

Before you change anything Understand exactly what the problem is Find an efficient solution Evaluate alternative solutions

After the change Fixes may make things worse

sometimes May uncover a second bug May be an incorrect fix

Repeat the debugging process

Page 16: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 16

Debugging (7)

Ask around Someone else may have had the same

bug They’ll probably at least know about

where the problem is Different bugs may produce the same

results TAs

The TAs know common problems We’re here to help, not solve it for you

Page 17: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 17

Administrative Info Midterm I

Thursday 02/16, 2-3:30pm, Room 125 Cory Review Session TBA, 125 Cory

Partners You MUST have one for this week

Try someone other than your best friend Restrictions

You can change partners until the project starts You must be in the same lab

Project in 2 weeks

Page 18: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 18

Part1: Bottom Up Testing (1)

What if EqualOut = 1’b0 and GreaterOut = 1’b0?

Lab4Comp1

EqualIni+1

GreaterIni+1

Ai

Bi

EqualOuti

GreaterOuti

A=B

A<B

Page 19: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 19

Part1: Bottom Up Testing (2) Exhaustive Testing

Ideal Testing Method Circuit is 100% tested!

Requires us to test a LOT! Can we do it here? (24 possible inputs)

Method Make a truth table Have the testbench generate all inputs Make sure outputs match truth table

Page 20: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 20

Part1: Bottom Up Testing (3)

Equ

alO

ut[3

]G

reat

erO

ut[3

]

Equ

alO

ut[2

]G

reat

erO

ut[2

]

Equ

alO

ut[1

]G

reat

erO

ut[1

]A[0] B[0]

GreaterEqual

Lab4Comp4

Lab4Comp1Lab4Comp1Lab4Comp1Lab4Comp1

A[1] B[1]A[2] B[2]A[3] B[3]

Page 21: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 21

Part1: Bottom Up Testing (4)

Exhaustive Testing? 28 = 256 Possible Inputs

Method Use a for loop to generate all inputs

Loops allowed only in testbenches They will not synthesize

Compare against a “>=“ Print a message if they differ

Page 22: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 22

Part1: Bottom Up Testing (5)

Register

Lab4PeakDetector

In

Clock

Out

Reset

≥4

4

4

4

Page 23: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 23

Part1: Bottom Up Testing (6)

Exhaustive Testing? 24 = 16 Possible Inputs 24 = 16 Possible States 16*16 = 256 combinations We could do it in this case

Can’t exhaustively test FSMs Too many state/input combinations Must rely on directed testing

Page 24: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 24

initial begin

end

Part1: Bottom Up Testing (7)

integer i;

reg [3:0] TestValues[1:16];

$readmemh("TestValues.txt", TestValues);

for(i = 1; i <= 16; i = i + 1) begin#(`Cycle);In = TestValues[i]; $display("In = %d, Peak = %d", In, Peak);

end

Page 25: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 25

Part1: Bottom Up Testing (8)

Read Test Vectors from a File Designing Test Vectors

Make sure to cover most cases We want 95%+ coverage

Designing test vectors is a “black art” $ Processes

Not synthesizeable More information in IEEE Verilog

Reference

Page 26: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 26

Part2: Test Hardware (1)

Lab4 Part2 Adder

Test

Control

ABSum

A

B

Sum

Error

Running

Go

Reset

Lab4Part2Tester

Page 27: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 27

Part2: Test Hardware (2)

Test Procedure Hit Reset (SW1) Hit Go (SW2) Record an error

DD1-8 show {A, B} SW10[1] selects the sum on DD4-8

Hit Go Repeat until the tester stops

Page 28: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 28

Part2: Test Hardware (3)

The Broken Adder 16bit Adder

232 ≈4 Billion Test Vectors Can’t simulate this much 2:40 to test this at 27MHz

Fail Modes 0: No Errors 2: Will claim 1 + 1 = 3 1-3: Can have anywhere from 0 to 4 errors

Page 29: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 29

Part3: FSM Testing (1)

Exhaustive Testing Again! Check every arc Check every output

You don’t need to correct this one… We’re not giving you the source code

Boring (and Easy) You will have FSM bugs Get used to debugging them

Page 30: 02/10/06EECS150 Lab Lecture #41 Debugging EECS150 Spring 2006 – Lab Lecture #4 Philip Godoy Greg Gibeling

02/10/06 EECS150 Lab Lecture #4 30

Part3: FSM Testing (2)

S0

S1 S4

S2 S5

1 1 0

S3[Output 1'b1]

S6

0 1

1

0

0

0 1

0 1

X