Beruflich Dokumente
Kultur Dokumente
October 1, 2009
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell
Data Hazards in ALU Instructions
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 2
Dependencies & Forwarding
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 3
Detecting the Need to Forward
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 4
Detecting the Need to Forward
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 5
Forwarding Paths
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 6
Forwarding Conditions
EX hazard
if (EX/MEM.RegWrite and (EX/MEM.RegisterRd 0)
and (EX/MEM.RegisterRd = ID/EX.RegisterRs))
ForwardA = 10
if (EX/MEM.RegWrite and (EX/MEM.RegisterRd 0)
and (EX/MEM.RegisterRd = ID/EX.RegisterRt))
ForwardB = 10
MEM hazard
if (MEM/WB.RegWrite and (MEM/WB.RegisterRd 0)
and (MEM/WB.RegisterRd = ID/EX.RegisterRs))
ForwardA = 01
if (MEM/WB.RegWrite and (MEM/WB.RegisterRd 0)
and (MEM/WB.RegisterRd = ID/EX.RegisterRt))
ForwardB = 01
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 7
Double Data Hazard
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 8
Revised Forwarding Condition
MEM hazard
if (MEM/WB.RegWrite and (MEM/WB.RegisterRd 0)
and not (EX/MEM.RegWrite and (EX/MEM.RegisterRd 0)
and (EX/MEM.RegisterRd = ID/EX.RegisterRs))
and (MEM/WB.RegisterRd = ID/EX.RegisterRs))
ForwardA = 01
if (MEM/WB.RegWrite and (MEM/WB.RegisterRd 0)
and not (EX/MEM.RegWrite and (EX/MEM.RegisterRd 0)
and (EX/MEM.RegisterRd = ID/EX.RegisterRt))
and (MEM/WB.RegisterRd = ID/EX.RegisterRt))
ForwardB = 01
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 9
Datapath with Forwarding
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 10
Load-Use Data Hazard
Need to stall
for one cycle
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 11
Load-Use Hazard Detection
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 12
How to Stall the Pipeline
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 13
Stall/Bubble in the Pipeline
Stall inserted
here
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 14
Stall/Bubble in the Pipeline
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 15
Datapath with Hazard Detection
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 16
Stalls and Performance
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 17
Branch Hazards
Flush these
instructions
(Set control
values to 0)
PC
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 18
Reducing Branch Delay
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 19
Example: Branch Taken
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 20
Example: Branch Taken
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 21
Data Hazards for Branches
IF ID EX MEM WB
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 22
Data Hazards for Branches
beq stalled IF ID
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 23
Data Hazards for Branches
beq stalled IF ID
beq stalled ID
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 24
Dynamic Branch Prediction
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 25
1-Bit Predictor: Shortcoming
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 26
2-Bit Predictor
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 27
Calculating the Branch Target
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 28
Exceptions and Interrupts
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 29
Handling Exceptions
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 30
An Alternate Mechanism
Vectored Interrupts
Handler address determined by the cause
Example:
Undefined opcode: C000 0000
Overflow: C000 0020
: C000 0040
Instructions either
Deal with the interrupt, or
Jump to real handler
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 31
Handler Actions
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 32
Exceptions in a Pipeline
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 33
Pipeline with Exceptions
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 34
Exception Properties
Restartable exceptions
Pipeline can flush the instruction
Handler executes, then returns to the instruction
Refetched and executed from scratch
PC saved in EPC register
Identifies causing instruction
Actually PC + 4 is saved
Handler must adjust
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 35
Exception Example
Exception on add in
40 sub $11, $2, $4
44 and $12, $2, $5
48 or $13, $2, $6
4C add $1, $2, $1
50 slt $15, $6, $7
54 lw $16, 50($7)
Handler
80000180 sw $25, 1000($0)
80000184 sw $26, 1004($0)
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 36
Exception Example
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 37
Exception Example
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 38
Multiple Exceptions
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 39
Imprecise Exceptions
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 40
Fallacies
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 41
Pitfalls
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell 42