SlideShare a Scribd company logo
1 of 25
CSE431 L06 Basic MIPS Pipelining.1 Irwin, PSU, 2005
CSE 431
Computer Architecture
Fall 2005
Lecture 06: Basic MIPS Pipelining Review
Mary Jane Irwin ( www.cse.psu.edu/~mji )
www.cse.psu.edu/~cg431
[Adapted from Computer Organization and Design,
Patterson & Hennessy, © 2005, UCB]
CSE431 L06 Basic MIPS Pipelining.2 Irwin, PSU, 2005
Review: Single Cycle vs. Multiple Cycle Timing
Clk Cycle 1
Multiple Cycle Implementation:
IFetch Dec Exec Mem WB
Cycle 2 Cycle 3 Cycle 4 Cycle 5 Cycle 6 Cycle 7 Cycle 8 Cycle 9Cycle 10
IFetch Dec Exec Mem
lw sw
IFetch
R-type
Clk
Single Cycle Implementation:
lw sw Waste
Cycle 1 Cycle 2
multicycle clock
slower than 1/5th of
single cycle clock
due to stage register
overhead
CSE431 L06 Basic MIPS Pipelining.3 Irwin, PSU, 2005
How Can We Make It Even Faster?
 Split the multiple instruction cycle into smaller and
smaller steps
 There is a point of diminishing returns where as much time is
spent loading the state registers as doing the work
 Start fetching and executing the next instruction before
the current one has completed
 Pipelining – (all?) modern processors are pipelined for
performance
 Remember the performance equation:
CPU time = CPI * CC * IC
 Fetch (and execute) more than one instruction at a time
 Superscalar processing – stay tuned
CSE431 L06 Basic MIPS Pipelining.4 Irwin, PSU, 2005
A Pipelined MIPS Processor
 Start the next instruction before the current one has
completed
 improves throughput - total amount of work done in a given time
 instruction latency (execution time, delay time, response time -
time from the start of an instruction to its completion) is not
reduced
Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5
IFetch Dec Exec Mem WB
lw
Cycle 7
Cycle 6 Cycle 8
sw IFetch Dec Exec Mem WB
R-type IFetch Dec Exec Mem WB
- clock cycle (pipeline stage time) is limited by the slowest stage
- for some instructions, some stages are wasted cycles
CSE431 L06 Basic MIPS Pipelining.5 Irwin, PSU, 2005
Single Cycle, Multiple Cycle, vs. Pipeline
Multiple Cycle Implementation:
Clk
Cycle 1
IFetch Dec Exec Mem WB
Cycle 2 Cycle 3 Cycle 4 Cycle 5 Cycle 6 Cycle 7 Cycle 8 Cycle 9Cycle 10
IFetch Dec Exec Mem
lw sw
IFetch
R-type
lw IFetch Dec Exec Mem WB
Pipeline Implementation:
IFetch Dec Exec Mem WB
sw
IFetch Dec Exec Mem WB
R-type
Clk
Single Cycle Implementation:
lw sw Waste
Cycle 1 Cycle 2
CSE431 L06 Basic MIPS Pipelining.6 Irwin, PSU, 2005
MIPS Pipeline Datapath Modifications
 What do we need to add/modify in our MIPS datapath?
 State registers between each pipeline stage to isolate them
Read
Address
Instruction
Memory
Add
PC
4
Write Data
Read Addr 1
Read Addr 2
Write Addr
Register
File
Read
Data 1
Read
Data 2
16 32
ALU
Shift
left 2
Add
Data
Memory
Address
Write Data
Read
Data
IFetch/Dec
Dec/Exec
Exec/Mem
Mem/WB
IF:IFetch ID:Dec EX:Execute MEM:
MemAccess
WB:
WriteBack
System Clock
Sign
Extend
CSE431 L06 Basic MIPS Pipelining.7 Irwin, PSU, 2005
Pipelining the MIPS ISA
 What makes it easy
 all instructions are the same length (32 bits)
- can fetch in the 1st stage and decode in the 2nd stage
 few instruction formats (three) with symmetry across formats
- can begin reading register file in 2nd stage
 memory operations can occur only in loads and stores
- can use the execute stage to calculate memory addresses
 each MIPS instruction writes at most one result (i.e.,
changes the machine state) and does so near the end of the
pipeline (MEM and WB)
 What makes it hard
 structural hazards: what if we had only one memory?
 control hazards: what about branches?
 data hazards: what if an instruction’s input operands depend
on the output of a previous instruction?
CSE431 L06 Basic MIPS Pipelining.8 Irwin, PSU, 2005
Graphically Representing MIPS Pipeline
 Can help with answering questions like:
 How many cycles does it take to execute this code?
 What is the ALU doing during cycle 4?
 Is there a hazard, why does it occur, and how can it be fixed?
ALU
IM Reg DM Reg
CSE431 L06 Basic MIPS Pipelining.9 Irwin, PSU, 2005
Why Pipeline? For Performance!
I
n
s
t
r.
O
r
d
e
r
Time (clock cycles)
Inst 0
Inst 1
Inst 2
Inst 4
Inst 3
ALU
IM Reg DM Reg
ALU
IM Reg DM Reg
ALU
IM Reg DM Reg
ALU
IM Reg DM Reg
ALU
IM Reg DM Reg
Once the
pipeline is full,
one instruction
is completed
every cycle, so
CPI = 1
Time to fill the pipeline
CSE431 L06 Basic MIPS Pipelining.10 Irwin, PSU, 2005
Can Pipelining Get Us Into Trouble?
 Yes: Pipeline Hazards
 structural hazards: attempt to use the same resource by two
different instructions at the same time
 data hazards: attempt to use data before it is ready
- An instruction’s source operand(s) are produced by a prior
instruction still in the pipeline
 control hazards: attempt to make a decision about program
control flow before the condition has been evaluated and the
new PC target address calculated
- branch instructions
 Can always resolve hazards by waiting
 pipeline control must detect the hazard
 and take action to resolve hazards
CSE431 L06 Basic MIPS Pipelining.11 Irwin, PSU, 2005
I
n
s
t
r.
O
r
d
e
r
Time (clock cycles)
lw
Inst 1
Inst 2
Inst 4
Inst 3
ALU
Mem Reg Mem Reg
ALU
Mem Reg Mem Reg
ALU
Mem Reg Mem Reg
ALU
Mem Reg Mem Reg
ALU
Mem Reg Mem Reg
A Single Memory Would Be a Structural Hazard
Reading data from
memory
Reading instruction
from memory
 Fix with separate instr and data memories (I$ and D$)
CSE431 L06 Basic MIPS Pipelining.13 Irwin, PSU, 2005
How About Register File Access?
I
n
s
t
r.
O
r
d
e
r
Time (clock cycles)
Inst 1
Inst 2 ALU
IM Reg DM Reg
ALU
IM Reg DM Reg
ALU
IM Reg DM Reg
ALU
IM Reg DM Reg
Fix register file
access hazard by
doing reads in the
second half of the
cycle and writes in
the first half
add $1,
add $2,$1,
clock edge that controls
register writing
clock edge that controls
loading of pipeline state
registers
CSE431 L06 Basic MIPS Pipelining.15 Irwin, PSU, 2005
Register Usage Can Cause Data Hazards
ALU
IM Reg DM Reg
ALU
IM Reg DM Reg
ALU
IM Reg DM Reg
ALU
IM Reg DM Reg
ALU
IM Reg DM Reg
 Dependencies backward in time cause hazards
add $1,
sub $4,$1,$5
and $6,$1,$7
xor $4,$1,$5
or $8,$1,$9
 Read before write data hazard
CSE431 L06 Basic MIPS Pipelining.16 Irwin, PSU, 2005
Loads Can Cause Data Hazards
I
n
s
t
r.
O
r
d
e
r
lw $1,4($2)
sub $4,$1,$5
and $6,$1,$7
xor $4,$1,$5
or $8,$1,$9
ALU
IM Reg DM Reg
ALU
IM Reg DM Reg
ALU
IM Reg DM Reg
ALU
IM Reg DM Reg
ALU
IM Reg DM Reg
 Dependencies backward in time cause hazards
 Load-use data hazard
CSE431 L06 Basic MIPS Pipelining.17 Irwin, PSU, 2005
stall
stall
One Way to “Fix” a Data Hazard
I
n
s
t
r.
O
r
d
e
r
add $1,
ALU
IM Reg DM Reg
sub $4,$1,$5
and $6,$1,$7
ALU
IM Reg DM Reg
ALU
IM Reg DM Reg
Can fix data
hazard by
waiting – stall –
but impacts CPI
CSE431 L06 Basic MIPS Pipelining.19 Irwin, PSU, 2005
Another Way to “Fix” a Data Hazard
ALU
IM Reg DM Reg
ALU
IM Reg DM Reg
ALU
IM Reg DM Reg
Fix data hazards
by forwarding
results as soon as
they are available
to where they are
needed
ALU
IM Reg DM Reg
ALU
IM Reg DM Reg
I
n
s
t
r.
O
r
d
e
r
add $1,
sub $4,$1,$5
and $6,$1,$7
xor $4,$1,$5
or $8,$1,$9
CSE431 L06 Basic MIPS Pipelining.21 Irwin, PSU, 2005
Forwarding with Load-use Data Hazards
ALU
IM Reg DM Reg
ALU
IM Reg DM Reg
ALU
IM Reg DM Reg
ALU
IM Reg DM Reg
ALU
IM Reg DM Reg
 Will still need one stall cycle even with forwarding
I
n
s
t
r.
O
r
d
e
r
lw $1,4($2)
sub $4,$1,$5
and $6,$1,$7
xor $4,$1,$5
or $8,$1,$9
CSE431 L06 Basic MIPS Pipelining.22 Irwin, PSU, 2005
Branch Instructions Cause Control Hazards
I
n
s
t
r.
O
r
d
e
r
lw
Inst 4
Inst 3
beq
ALU
IM Reg DM Reg
ALU
IM Reg DM Reg
ALU
IM Reg DM Reg
ALU
IM Reg DM Reg
 Dependencies backward in time cause hazards
CSE431 L06 Basic MIPS Pipelining.23 Irwin, PSU, 2005
stall
stall
stall
One Way to “Fix” a Control Hazard
I
n
s
t
r.
O
r
d
e
r
beq
ALU
IM Reg DM Reg
lw
ALU
IM Reg DM Reg
ALU
Inst 3
IM Reg DM
Fix branch
hazard by
waiting –
stall – but
affects CPI
CSE431 L06 Basic MIPS Pipelining.25 Irwin, PSU, 2005
Corrected Datapath to Save RegWrite Addr
 Need to preserve the destination register address in
the pipeline state registers
Read
Address
Instruction
Memory
Add
PC
4
Write Data
Read Addr 1
Read Addr 2
Write Addr
Register
File
Read
Data 1
Read
Data 2
16 32
ALU
Shift
left 2
Add
Data
Memory
Address
Write Data
Read
Data
IF/ID
Sign
Extend
ID/EX EX/MEM
MEM/WB
CSE431 L06 Basic MIPS Pipelining.26 Irwin, PSU, 2005
MIPS Pipeline Control Path Modifications
 All control signals can be determined during Decode
 and held in the state registers between pipeline stages
Read
Address
Instruction
Memory
Add
PC
4
Write Data
Read Addr 1
Read Addr 2
Write Addr
Register
File
Read
Data 1
Read
Data 2
16 32
ALU
Shift
left 2
Add
Data
Memory
Address
Write Data
Read
Data
IF/ID
Sign
Extend
ID/EX
EX/MEM
MEM/WB
Control
CSE431 L06 Basic MIPS Pipelining.27 Irwin, PSU, 2005
Other Pipeline Structures Are Possible
 What about the (slow) multiply operation?
 Make the clock twice as slow or …
 let it take two cycles (since it doesn’t use the DM stage)
ALU
IM Reg DM Reg
MUL
ALU
IM Reg DM1 Reg
DM2
 What if the data memory access is twice as slow as
the instruction memory?
 make the clock twice as slow or …
 let data memory access take two cycles (and keep the same
clock rate)
CSE431 L06 Basic MIPS Pipelining.28 Irwin, PSU, 2005
Sample Pipeline Alternatives
 ARM7
 StrongARM-1
 XScale
ALU
IM1 IM2 DM1 Reg
DM2
IM Reg EX
PC update
IM access
decode
reg
access
ALU op
DM access
shift/rotate
commit result
(write back)
ALU
IM Reg DM Reg
Reg SHFT
PC update
BTB access
start IM access
IM access
decode
reg 1 access
shift/rotate
reg 2 access
ALU op
start DM access
exception
DM write
reg write
CSE431 L06 Basic MIPS Pipelining.29 Irwin, PSU, 2005
Summary
 All modern day processors use pipelining
 Pipelining doesn’t help latency of single task, it helps
throughput of entire workload
 Potential speedup: a CPI of 1 and fast a CC
 Pipeline rate limited by slowest pipeline stage
 Unbalanced pipe stages makes for inefficiencies
 The time to “fill” pipeline and time to “drain” it can impact
speedup for deep pipelines and short code runs
 Must detect and resolve hazards
 Stalling negatively affects CPI (makes CPI less than the ideal
of 1)
CSE431 L06 Basic MIPS Pipelining.30 Irwin, PSU, 2005
Next Lecture and Reminders
 Next lecture
 Overcoming data hazards
- Reading assignment – PH, Chapter 6.4-6.5
 Reminders
 HW2 due September 29th
 SimpleScalar tutorials scheduled
- Thursday, Sept 22, 5:30-6:30 pm in 218 IST
 Evening midterm exam scheduled
- Tuesday, October 18th , 20:15 to 22:15, Location 113 IST
- You should have let me know by now if you have a conflict

More Related Content

Similar to 2 ppt.pptx

Pipeline & Nonpipeline Processor
Pipeline & Nonpipeline ProcessorPipeline & Nonpipeline Processor
Pipeline & Nonpipeline ProcessorSmit Shah
 
Advanced Techniques for Exploiting ILP
Advanced Techniques for Exploiting ILPAdvanced Techniques for Exploiting ILP
Advanced Techniques for Exploiting ILPA B Shinde
 
DESIGN AND ANALYSIS OF A 32-BIT PIPELINED MIPS RISC PROCESSOR
DESIGN AND ANALYSIS OF A 32-BIT PIPELINED MIPS RISC PROCESSORDESIGN AND ANALYSIS OF A 32-BIT PIPELINED MIPS RISC PROCESSOR
DESIGN AND ANALYSIS OF A 32-BIT PIPELINED MIPS RISC PROCESSORVLSICS Design
 
DESIGN AND ANALYSIS OF A 32-BIT PIPELINED MIPS RISC PROCESSOR
DESIGN AND ANALYSIS OF A 32-BIT PIPELINED MIPS RISC PROCESSORDESIGN AND ANALYSIS OF A 32-BIT PIPELINED MIPS RISC PROCESSOR
DESIGN AND ANALYSIS OF A 32-BIT PIPELINED MIPS RISC PROCESSORVLSICS Design
 
Design and Analysis of A 32-bit Pipelined MIPS Risc Processor
Design and Analysis of A 32-bit Pipelined MIPS Risc ProcessorDesign and Analysis of A 32-bit Pipelined MIPS Risc Processor
Design and Analysis of A 32-bit Pipelined MIPS Risc ProcessorVLSICS Design
 
Design pipeline architecture for various stage pipelines
Design pipeline architecture for various stage pipelinesDesign pipeline architecture for various stage pipelines
Design pipeline architecture for various stage pipelinesMahmudul Hasan
 
Chapter7_InputOutputStorageSystems.pptx
Chapter7_InputOutputStorageSystems.pptxChapter7_InputOutputStorageSystems.pptx
Chapter7_InputOutputStorageSystems.pptxJanethMedina31
 
Pipelining 16 computers Artitacher pdf
Pipelining   16 computers Artitacher  pdfPipelining   16 computers Artitacher  pdf
Pipelining 16 computers Artitacher pdfMadhuGupta99385
 
High Performance Computer Architecture
High Performance Computer ArchitectureHigh Performance Computer Architecture
High Performance Computer ArchitectureSubhasis Dash
 
Van jaconson netchannels
Van jaconson netchannelsVan jaconson netchannels
Van jaconson netchannelsSusant Sahani
 
11-Serial_vs_Pipelined.pptx
11-Serial_vs_Pipelined.pptx11-Serial_vs_Pipelined.pptx
11-Serial_vs_Pipelined.pptxDanyMerhej1
 
Pipelining of Processors Computer Architecture
Pipelining of  Processors Computer ArchitecturePipelining of  Processors Computer Architecture
Pipelining of Processors Computer ArchitectureHaris456
 
Basics of plc programming
Basics of plc programmingBasics of plc programming
Basics of plc programmingSergio Barrios
 
Basics of plc_programming
Basics of plc_programmingBasics of plc_programming
Basics of plc_programminghamza239523
 

Similar to 2 ppt.pptx (20)

3 Pipelining
3 Pipelining3 Pipelining
3 Pipelining
 
Pipeline & Nonpipeline Processor
Pipeline & Nonpipeline ProcessorPipeline & Nonpipeline Processor
Pipeline & Nonpipeline Processor
 
Advanced Techniques for Exploiting ILP
Advanced Techniques for Exploiting ILPAdvanced Techniques for Exploiting ILP
Advanced Techniques for Exploiting ILP
 
DESIGN AND ANALYSIS OF A 32-BIT PIPELINED MIPS RISC PROCESSOR
DESIGN AND ANALYSIS OF A 32-BIT PIPELINED MIPS RISC PROCESSORDESIGN AND ANALYSIS OF A 32-BIT PIPELINED MIPS RISC PROCESSOR
DESIGN AND ANALYSIS OF A 32-BIT PIPELINED MIPS RISC PROCESSOR
 
DESIGN AND ANALYSIS OF A 32-BIT PIPELINED MIPS RISC PROCESSOR
DESIGN AND ANALYSIS OF A 32-BIT PIPELINED MIPS RISC PROCESSORDESIGN AND ANALYSIS OF A 32-BIT PIPELINED MIPS RISC PROCESSOR
DESIGN AND ANALYSIS OF A 32-BIT PIPELINED MIPS RISC PROCESSOR
 
Design and Analysis of A 32-bit Pipelined MIPS Risc Processor
Design and Analysis of A 32-bit Pipelined MIPS Risc ProcessorDesign and Analysis of A 32-bit Pipelined MIPS Risc Processor
Design and Analysis of A 32-bit Pipelined MIPS Risc Processor
 
pipelining
pipeliningpipelining
pipelining
 
Design pipeline architecture for various stage pipelines
Design pipeline architecture for various stage pipelinesDesign pipeline architecture for various stage pipelines
Design pipeline architecture for various stage pipelines
 
Pipelining in computer architecture
Pipelining in computer architecturePipelining in computer architecture
Pipelining in computer architecture
 
Chapter7_InputOutputStorageSystems.pptx
Chapter7_InputOutputStorageSystems.pptxChapter7_InputOutputStorageSystems.pptx
Chapter7_InputOutputStorageSystems.pptx
 
Pipelining In computer
Pipelining In computer Pipelining In computer
Pipelining In computer
 
Pipelining 16 computers Artitacher pdf
Pipelining   16 computers Artitacher  pdfPipelining   16 computers Artitacher  pdf
Pipelining 16 computers Artitacher pdf
 
High Performance Computer Architecture
High Performance Computer ArchitectureHigh Performance Computer Architecture
High Performance Computer Architecture
 
Pipelining
PipeliningPipelining
Pipelining
 
Van jaconson netchannels
Van jaconson netchannelsVan jaconson netchannels
Van jaconson netchannels
 
11-Serial_vs_Pipelined.pptx
11-Serial_vs_Pipelined.pptx11-Serial_vs_Pipelined.pptx
11-Serial_vs_Pipelined.pptx
 
06 pipeline
06 pipeline06 pipeline
06 pipeline
 
Pipelining of Processors Computer Architecture
Pipelining of  Processors Computer ArchitecturePipelining of  Processors Computer Architecture
Pipelining of Processors Computer Architecture
 
Basics of plc programming
Basics of plc programmingBasics of plc programming
Basics of plc programming
 
Basics of plc_programming
Basics of plc_programmingBasics of plc_programming
Basics of plc_programming
 

More from kalai75

Python ppt.pdf
Python ppt.pdfPython ppt.pdf
Python ppt.pdfkalai75
 
ppt final.pptx
ppt final.pptxppt final.pptx
ppt final.pptxkalai75
 
R Programming.pptx
R Programming.pptxR Programming.pptx
R Programming.pptxkalai75
 
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptxQ-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptxkalai75
 
Lec1cgu13updated.ppt
Lec1cgu13updated.pptLec1cgu13updated.ppt
Lec1cgu13updated.pptkalai75
 
Cloud and Bid data Dr.VK.pdf
Cloud and Bid data Dr.VK.pdfCloud and Bid data Dr.VK.pdf
Cloud and Bid data Dr.VK.pdfkalai75
 
COA Precourse.docx
COA Precourse.docxCOA Precourse.docx
COA Precourse.docxkalai75
 
print.pptx
print.pptxprint.pptx
print.pptxkalai75
 
Linear algebra
Linear algebraLinear algebra
Linear algebrakalai75
 
Applications of data mining in bioinformatics
Applications of data mining in bioinformaticsApplications of data mining in bioinformatics
Applications of data mining in bioinformaticskalai75
 
Atal trivandrum academy
Atal trivandrum academyAtal trivandrum academy
Atal trivandrum academykalai75
 
Atal trivandrum academy
Atal trivandrum academyAtal trivandrum academy
Atal trivandrum academykalai75
 

More from kalai75 (13)

Python ppt.pdf
Python ppt.pdfPython ppt.pdf
Python ppt.pdf
 
ppt final.pptx
ppt final.pptxppt final.pptx
ppt final.pptx
 
R Programming.pptx
R Programming.pptxR Programming.pptx
R Programming.pptx
 
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptxQ-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
 
Lec1cgu13updated.ppt
Lec1cgu13updated.pptLec1cgu13updated.ppt
Lec1cgu13updated.ppt
 
Cloud and Bid data Dr.VK.pdf
Cloud and Bid data Dr.VK.pdfCloud and Bid data Dr.VK.pdf
Cloud and Bid data Dr.VK.pdf
 
COA Precourse.docx
COA Precourse.docxCOA Precourse.docx
COA Precourse.docx
 
print.pptx
print.pptxprint.pptx
print.pptx
 
Linear algebra
Linear algebraLinear algebra
Linear algebra
 
Ppt1
Ppt1Ppt1
Ppt1
 
Applications of data mining in bioinformatics
Applications of data mining in bioinformaticsApplications of data mining in bioinformatics
Applications of data mining in bioinformatics
 
Atal trivandrum academy
Atal trivandrum academyAtal trivandrum academy
Atal trivandrum academy
 
Atal trivandrum academy
Atal trivandrum academyAtal trivandrum academy
Atal trivandrum academy
 

Recently uploaded

UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdfSuman Jyoti
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...SUHANI PANDEY
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spaintimesproduction05
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfRagavanV2
 

Recently uploaded (20)

UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spain
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 

2 ppt.pptx

  • 1. CSE431 L06 Basic MIPS Pipelining.1 Irwin, PSU, 2005 CSE 431 Computer Architecture Fall 2005 Lecture 06: Basic MIPS Pipelining Review Mary Jane Irwin ( www.cse.psu.edu/~mji ) www.cse.psu.edu/~cg431 [Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005, UCB]
  • 2. CSE431 L06 Basic MIPS Pipelining.2 Irwin, PSU, 2005 Review: Single Cycle vs. Multiple Cycle Timing Clk Cycle 1 Multiple Cycle Implementation: IFetch Dec Exec Mem WB Cycle 2 Cycle 3 Cycle 4 Cycle 5 Cycle 6 Cycle 7 Cycle 8 Cycle 9Cycle 10 IFetch Dec Exec Mem lw sw IFetch R-type Clk Single Cycle Implementation: lw sw Waste Cycle 1 Cycle 2 multicycle clock slower than 1/5th of single cycle clock due to stage register overhead
  • 3. CSE431 L06 Basic MIPS Pipelining.3 Irwin, PSU, 2005 How Can We Make It Even Faster?  Split the multiple instruction cycle into smaller and smaller steps  There is a point of diminishing returns where as much time is spent loading the state registers as doing the work  Start fetching and executing the next instruction before the current one has completed  Pipelining – (all?) modern processors are pipelined for performance  Remember the performance equation: CPU time = CPI * CC * IC  Fetch (and execute) more than one instruction at a time  Superscalar processing – stay tuned
  • 4. CSE431 L06 Basic MIPS Pipelining.4 Irwin, PSU, 2005 A Pipelined MIPS Processor  Start the next instruction before the current one has completed  improves throughput - total amount of work done in a given time  instruction latency (execution time, delay time, response time - time from the start of an instruction to its completion) is not reduced Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 IFetch Dec Exec Mem WB lw Cycle 7 Cycle 6 Cycle 8 sw IFetch Dec Exec Mem WB R-type IFetch Dec Exec Mem WB - clock cycle (pipeline stage time) is limited by the slowest stage - for some instructions, some stages are wasted cycles
  • 5. CSE431 L06 Basic MIPS Pipelining.5 Irwin, PSU, 2005 Single Cycle, Multiple Cycle, vs. Pipeline Multiple Cycle Implementation: Clk Cycle 1 IFetch Dec Exec Mem WB Cycle 2 Cycle 3 Cycle 4 Cycle 5 Cycle 6 Cycle 7 Cycle 8 Cycle 9Cycle 10 IFetch Dec Exec Mem lw sw IFetch R-type lw IFetch Dec Exec Mem WB Pipeline Implementation: IFetch Dec Exec Mem WB sw IFetch Dec Exec Mem WB R-type Clk Single Cycle Implementation: lw sw Waste Cycle 1 Cycle 2
  • 6. CSE431 L06 Basic MIPS Pipelining.6 Irwin, PSU, 2005 MIPS Pipeline Datapath Modifications  What do we need to add/modify in our MIPS datapath?  State registers between each pipeline stage to isolate them Read Address Instruction Memory Add PC 4 Write Data Read Addr 1 Read Addr 2 Write Addr Register File Read Data 1 Read Data 2 16 32 ALU Shift left 2 Add Data Memory Address Write Data Read Data IFetch/Dec Dec/Exec Exec/Mem Mem/WB IF:IFetch ID:Dec EX:Execute MEM: MemAccess WB: WriteBack System Clock Sign Extend
  • 7. CSE431 L06 Basic MIPS Pipelining.7 Irwin, PSU, 2005 Pipelining the MIPS ISA  What makes it easy  all instructions are the same length (32 bits) - can fetch in the 1st stage and decode in the 2nd stage  few instruction formats (three) with symmetry across formats - can begin reading register file in 2nd stage  memory operations can occur only in loads and stores - can use the execute stage to calculate memory addresses  each MIPS instruction writes at most one result (i.e., changes the machine state) and does so near the end of the pipeline (MEM and WB)  What makes it hard  structural hazards: what if we had only one memory?  control hazards: what about branches?  data hazards: what if an instruction’s input operands depend on the output of a previous instruction?
  • 8. CSE431 L06 Basic MIPS Pipelining.8 Irwin, PSU, 2005 Graphically Representing MIPS Pipeline  Can help with answering questions like:  How many cycles does it take to execute this code?  What is the ALU doing during cycle 4?  Is there a hazard, why does it occur, and how can it be fixed? ALU IM Reg DM Reg
  • 9. CSE431 L06 Basic MIPS Pipelining.9 Irwin, PSU, 2005 Why Pipeline? For Performance! I n s t r. O r d e r Time (clock cycles) Inst 0 Inst 1 Inst 2 Inst 4 Inst 3 ALU IM Reg DM Reg ALU IM Reg DM Reg ALU IM Reg DM Reg ALU IM Reg DM Reg ALU IM Reg DM Reg Once the pipeline is full, one instruction is completed every cycle, so CPI = 1 Time to fill the pipeline
  • 10. CSE431 L06 Basic MIPS Pipelining.10 Irwin, PSU, 2005 Can Pipelining Get Us Into Trouble?  Yes: Pipeline Hazards  structural hazards: attempt to use the same resource by two different instructions at the same time  data hazards: attempt to use data before it is ready - An instruction’s source operand(s) are produced by a prior instruction still in the pipeline  control hazards: attempt to make a decision about program control flow before the condition has been evaluated and the new PC target address calculated - branch instructions  Can always resolve hazards by waiting  pipeline control must detect the hazard  and take action to resolve hazards
  • 11. CSE431 L06 Basic MIPS Pipelining.11 Irwin, PSU, 2005 I n s t r. O r d e r Time (clock cycles) lw Inst 1 Inst 2 Inst 4 Inst 3 ALU Mem Reg Mem Reg ALU Mem Reg Mem Reg ALU Mem Reg Mem Reg ALU Mem Reg Mem Reg ALU Mem Reg Mem Reg A Single Memory Would Be a Structural Hazard Reading data from memory Reading instruction from memory  Fix with separate instr and data memories (I$ and D$)
  • 12. CSE431 L06 Basic MIPS Pipelining.13 Irwin, PSU, 2005 How About Register File Access? I n s t r. O r d e r Time (clock cycles) Inst 1 Inst 2 ALU IM Reg DM Reg ALU IM Reg DM Reg ALU IM Reg DM Reg ALU IM Reg DM Reg Fix register file access hazard by doing reads in the second half of the cycle and writes in the first half add $1, add $2,$1, clock edge that controls register writing clock edge that controls loading of pipeline state registers
  • 13. CSE431 L06 Basic MIPS Pipelining.15 Irwin, PSU, 2005 Register Usage Can Cause Data Hazards ALU IM Reg DM Reg ALU IM Reg DM Reg ALU IM Reg DM Reg ALU IM Reg DM Reg ALU IM Reg DM Reg  Dependencies backward in time cause hazards add $1, sub $4,$1,$5 and $6,$1,$7 xor $4,$1,$5 or $8,$1,$9  Read before write data hazard
  • 14. CSE431 L06 Basic MIPS Pipelining.16 Irwin, PSU, 2005 Loads Can Cause Data Hazards I n s t r. O r d e r lw $1,4($2) sub $4,$1,$5 and $6,$1,$7 xor $4,$1,$5 or $8,$1,$9 ALU IM Reg DM Reg ALU IM Reg DM Reg ALU IM Reg DM Reg ALU IM Reg DM Reg ALU IM Reg DM Reg  Dependencies backward in time cause hazards  Load-use data hazard
  • 15. CSE431 L06 Basic MIPS Pipelining.17 Irwin, PSU, 2005 stall stall One Way to “Fix” a Data Hazard I n s t r. O r d e r add $1, ALU IM Reg DM Reg sub $4,$1,$5 and $6,$1,$7 ALU IM Reg DM Reg ALU IM Reg DM Reg Can fix data hazard by waiting – stall – but impacts CPI
  • 16. CSE431 L06 Basic MIPS Pipelining.19 Irwin, PSU, 2005 Another Way to “Fix” a Data Hazard ALU IM Reg DM Reg ALU IM Reg DM Reg ALU IM Reg DM Reg Fix data hazards by forwarding results as soon as they are available to where they are needed ALU IM Reg DM Reg ALU IM Reg DM Reg I n s t r. O r d e r add $1, sub $4,$1,$5 and $6,$1,$7 xor $4,$1,$5 or $8,$1,$9
  • 17. CSE431 L06 Basic MIPS Pipelining.21 Irwin, PSU, 2005 Forwarding with Load-use Data Hazards ALU IM Reg DM Reg ALU IM Reg DM Reg ALU IM Reg DM Reg ALU IM Reg DM Reg ALU IM Reg DM Reg  Will still need one stall cycle even with forwarding I n s t r. O r d e r lw $1,4($2) sub $4,$1,$5 and $6,$1,$7 xor $4,$1,$5 or $8,$1,$9
  • 18. CSE431 L06 Basic MIPS Pipelining.22 Irwin, PSU, 2005 Branch Instructions Cause Control Hazards I n s t r. O r d e r lw Inst 4 Inst 3 beq ALU IM Reg DM Reg ALU IM Reg DM Reg ALU IM Reg DM Reg ALU IM Reg DM Reg  Dependencies backward in time cause hazards
  • 19. CSE431 L06 Basic MIPS Pipelining.23 Irwin, PSU, 2005 stall stall stall One Way to “Fix” a Control Hazard I n s t r. O r d e r beq ALU IM Reg DM Reg lw ALU IM Reg DM Reg ALU Inst 3 IM Reg DM Fix branch hazard by waiting – stall – but affects CPI
  • 20. CSE431 L06 Basic MIPS Pipelining.25 Irwin, PSU, 2005 Corrected Datapath to Save RegWrite Addr  Need to preserve the destination register address in the pipeline state registers Read Address Instruction Memory Add PC 4 Write Data Read Addr 1 Read Addr 2 Write Addr Register File Read Data 1 Read Data 2 16 32 ALU Shift left 2 Add Data Memory Address Write Data Read Data IF/ID Sign Extend ID/EX EX/MEM MEM/WB
  • 21. CSE431 L06 Basic MIPS Pipelining.26 Irwin, PSU, 2005 MIPS Pipeline Control Path Modifications  All control signals can be determined during Decode  and held in the state registers between pipeline stages Read Address Instruction Memory Add PC 4 Write Data Read Addr 1 Read Addr 2 Write Addr Register File Read Data 1 Read Data 2 16 32 ALU Shift left 2 Add Data Memory Address Write Data Read Data IF/ID Sign Extend ID/EX EX/MEM MEM/WB Control
  • 22. CSE431 L06 Basic MIPS Pipelining.27 Irwin, PSU, 2005 Other Pipeline Structures Are Possible  What about the (slow) multiply operation?  Make the clock twice as slow or …  let it take two cycles (since it doesn’t use the DM stage) ALU IM Reg DM Reg MUL ALU IM Reg DM1 Reg DM2  What if the data memory access is twice as slow as the instruction memory?  make the clock twice as slow or …  let data memory access take two cycles (and keep the same clock rate)
  • 23. CSE431 L06 Basic MIPS Pipelining.28 Irwin, PSU, 2005 Sample Pipeline Alternatives  ARM7  StrongARM-1  XScale ALU IM1 IM2 DM1 Reg DM2 IM Reg EX PC update IM access decode reg access ALU op DM access shift/rotate commit result (write back) ALU IM Reg DM Reg Reg SHFT PC update BTB access start IM access IM access decode reg 1 access shift/rotate reg 2 access ALU op start DM access exception DM write reg write
  • 24. CSE431 L06 Basic MIPS Pipelining.29 Irwin, PSU, 2005 Summary  All modern day processors use pipelining  Pipelining doesn’t help latency of single task, it helps throughput of entire workload  Potential speedup: a CPI of 1 and fast a CC  Pipeline rate limited by slowest pipeline stage  Unbalanced pipe stages makes for inefficiencies  The time to “fill” pipeline and time to “drain” it can impact speedup for deep pipelines and short code runs  Must detect and resolve hazards  Stalling negatively affects CPI (makes CPI less than the ideal of 1)
  • 25. CSE431 L06 Basic MIPS Pipelining.30 Irwin, PSU, 2005 Next Lecture and Reminders  Next lecture  Overcoming data hazards - Reading assignment – PH, Chapter 6.4-6.5  Reminders  HW2 due September 29th  SimpleScalar tutorials scheduled - Thursday, Sept 22, 5:30-6:30 pm in 218 IST  Evening midterm exam scheduled - Tuesday, October 18th , 20:15 to 22:15, Location 113 IST - You should have let me know by now if you have a conflict