+ All Categories
Home > Documents > Dealing with Hazards Mite 3

Dealing with Hazards Mite 3

Date post: 04-Jan-2016
Category:
Upload: emerald-orr
View: 28 times
Download: 0 times
Share this document with a friend
Description:
Dealing with Hazards Mite 3. Ellen Spertus MCS 111 November 13, 2003. Review: Hazards. What’s a control hazard? What’s a data hazard?. Stages IF ID(RR) EX MEM WB. Sample code. sub $2 , $1, $3 and $12, $2 , $5 or $13, $6, $2 add $14, $2, $2 sw $15, 100( $2 ). - PowerPoint PPT Presentation
Popular Tags:
20
Dealing with Hazards Mite 3 Ellen Spertus MCS 111 November 13, 2003
Transcript
Page 1: Dealing with Hazards Mite 3

Dealing with HazardsMite 3

Ellen Spertus

MCS 111

November 13, 2003

Page 2: Dealing with Hazards Mite 3

2

Review: Hazards

• What’s a control hazard?

• What’s a data hazard?

Stages– IF– ID(RR)– EX– MEM– WB

Page 3: Dealing with Hazards Mite 3

3

Sample code

sub $2, $1, $3

and $12, $2, $5

or $13, $6, $2

add $14, $2, $2

sw $15, 100($2)

Page 4: Dealing with Hazards Mite 3

4

Page 5: Dealing with Hazards Mite 3

5

Interpreting the diagram

• Time axis

• Instruction axis

• Stages

• What does it mean when– a colored line goes to the right?– a colored line goes straight down?– a colored line goes to the left?

Page 6: Dealing with Hazards Mite 3

6

How can we run sample code?

• Inserting nops (“no operation”s)– sll $0, $0, 0–

• Adding new datapaths to speed value to where it is needed

Page 7: Dealing with Hazards Mite 3

7

sub $2,$1,$3and $12,$2,$5

$5

$2

25

lw $5, 3($0)

Figure 6.43 (p. 488)

Page 8: Dealing with Hazards Mite 3

8

Summary: Forwarding

• Hazards that forwarding can solve

• Hazards that can’t be solved by forwarding

Page 9: Dealing with Hazards Mite 3

9

Hazard requiring stalling

Figure 6.44 (p. 489)

Page 10: Dealing with Hazards Mite 3

10

What should happen on a stall?

• Instructions further through the pipeline should keep going

• The stalled instruction should stay at the same stage

• Instructions earlier in the pipeline should

Page 11: Dealing with Hazards Mite 3

11From Figure 6.47 (p. 493)

Page 12: Dealing with Hazards Mite 3

12

Page 13: Dealing with Hazards Mite 3

13

Dealing with hazards

• Data hazards– Reordering code– Forwarding or bypassing– Stalling

• Control hazards

Page 14: Dealing with Hazards Mite 3

14

Control hazards

Reg

Reg

CC 1

Time (in clock cycles)

40 beq $1, $3, 7

Programexecutionorder(in instructions)

IM Reg

IM DM

IM DM

IM DM

DM

DM Reg

Reg Reg

Reg

Reg

RegIM

44 and $12, $2, $5

48 or $13, $6, $2

52 add $14, $2, $2

72 lw $4, 50($7)

CC 2 CC 3 CC 4 CC 5 CC 6 CC 7 CC 8 CC 9

Reg

Page 15: Dealing with Hazards Mite 3

15

Dealing with control hazards

• Add hardware to determine earlier whether a branch is taken

• Static prediction– Assume branch not taken– Assume branch taken

• Dynamic prediction

• Branch delay slots

Page 16: Dealing with Hazards Mite 3

16

Branch delay slots

b = c + d;

if (a == 0) ...

add $s1, $s2, $s3

beq $s0, $r0, foo

Page 17: Dealing with Hazards Mite 3

17

Mite 3

• Add conditional branch• New instruction format:

• LS163 functionality– reset– enable (count)– load

Format i7 i6 i5 i4 i3 i2 i1 i0 Meaning ALU 0 f3 f2 f1 f0 c’ m LD0 Perform the specified ALU function CONST 1 0 c4 c3 c2 c1 c0 LD0 Load the sign-extension of c4..c0 BEQ 1 1 b5 b4 b3 b2 b1 b0 If a=b, jump to the address in b5..b0

Page 18: Dealing with Hazards Mite 3

18

LS163: 4-bit synchronous counter

• If reset’, set outputs (Q3..Q1) to zero

• If load’, set outputs to inputs (P3..P1)

• If enable and Cin, increment outputs

enable

Cin

load'

reset'

P3 P0P2 P1

Q3 Q0Q2 Q1

Cout

1

2

7

6 5 4 3

9

10

1411 12 13

15

LS163counter

Page 19: Dealing with Hazards Mite 3

19

Lab 6

• Design (pages 1-3) due at beginning of class Thursday, Nov. 20.

• Lab due 5 PM, Tuesday, Dec. 2.

Page 20: Dealing with Hazards Mite 3

20


Recommended