Docsity

Pipelining - Intro to Computer Architecture - Lecture Slides, Slides of Computer Architecture and Organization

Partial preview of the text

Download Pipelining - Intro to Computer Architecture - Lecture Slides and more Slides Computer Architecture and Organization in PDF only on Docsity!

RISC Pipelining

RISC Pipelining

Classic five stage instruction

Fetch – fetch instruction from memory

Decode – determine what action is required

Execute – execute instruction

Memory – data cache access

Writeback – write result to register

Arm

Nintendo DS

5 Stage Pipeline

1)Fetch instruction from instruction register(IR)

2)Determine what action to take 3)Execute the instruction

4)Access cache if needed

5)Write result in register

Example: MOV Reg1, Mem 1)fetch instruction(MOV Reg1, Mem1) 2)decided it is a move instruction from memory to register 3)fetch address of memory to be move 4)fetch data from memory 5)write data to Reg

RISC Pipelining

 FI - fetch instruction  DI - decode instruction  EX - execute instruction  MEM – data cache access  WB - write back

Instruction (^1 2 3 4 5 6 7 8 )

1 FI DI EX MEM WB

2 FI DI EX MEM WB

3 FI DI EX MEM WB

4 FI DI EX MEM WB

5 FI DI EX MEM WB

Pipeline Delay

FI DI EX MEM WB

FI DI EX MEM WB

MOV Reg1,Mem

MOV Reg2,(Reg1)

MOV Reg1,Mem

MOV Reg2,(Reg1)

FI DI EX MEM WB

FI DI EX MEM WB

Write data from Mem1 into Reg

Must wait for data to be loaded into Reg

Stall(bubble)

  1. move data from Mem1 to Reg

  2. move data from Reg1 to Reg

(b)Data dependency delay

Pipeline Delay

FI DI EX MEM WB

FI DI EX MEM WB

FI DI EX MEM WB

MOV Reg1,Mem

NOP

MOV Reg2,(Reg1)

  1. move data from Mem1 to Reg

  2. no operation perform

  3. move data from Reg1 to Reg

Add a NOP(no operation perform) to fill the gap

FI DI EX MEM WB

FI DI EX MEM WB

FI DI EX MEM WB

FI DI EX MEM WB

101 ADD Reg3, Reg2, Reg

102 NOP

103 BEQ Reg3 ,Reg4, 106

104 MOV Mem1, Reg

105 ADD Reg4, Reg1, Reg

106 MOV Mem1, Reg

(c)Control dependency delay

Reg3 = Reg4, jump to 106, no time wasted

At this point Reg3 equal Reg2 + Reg1, and line 103 can compare Reg3 to Reg4 and decide jumping to 106 or not

101 add Reg2 to Reg1 and put in Reg

102 no operation perform

103 if Reg3 = Reg4, jump to 106 else 104

104 move Reg3 to Mem

105 add Reg2 to Reg1 and put in Reg

106 move Reg4 to Mem

Data dependency delay

Guess branch will happen

FI DI EX MEM WB

FI DI EX MEM WB

FI DI EX MEM WB

FI DI EX

FI DI

FI DI FI

FI

101 ADD Reg3, Reg2, Reg

102 NOP

103 BEQ Reg3 ,Reg4, 106

104 MOV Mem1, Reg

105 ADD Reg4, Reg1, Reg

106 MOV Mem1, Reg

107 MOV Reg2, Mem

(c)Control dependency delay

Reg3 not= Reg4, clear and fetch 104 next

At this point Reg3 equal Reg2 + Reg1, and line 103 can compare Reg3 to Reg4 and decide jumping to 106 or not

Data dependency delay

Guess wrong can lead to wasted time

Pure RISC Pipeline

 Register to register cycle

1) F: instruction fetch from register

2) E: execute , perform ALU operations

with register input and output

 Load and Store cycle

1) F: instruction fetch from register

2) E: execute, calculates memory address

3) W: memory, register to memory, memory to

register operations

Pure RISC Pipeline

Instruction (^1 2 3 4 5 6 )

1 F E W

2 F E

3 F E

4 F

5 F E W

100 move Mem1 to Reg

101 add 1 to Reg

102 Jump to 105

103 add Reg1 to Reg

105 move Reg1 to Mem

100 MOVE Reg1, Mem

101 ADD 1, Reg

102 JUMP 105

103 ADD Reg1, Reg

105 MOVE Mem2, Reg

a) Traditional pipeline

Jump execute and 103 is cleared from the pipeline, 105 is fetch

F – fetch E – execute W – write back

Pure RISC Pipeline

Instruction (^1 2 3 4 5 6 )

1 F E W

2 F E

3 F E

4 F E W

100 move Mem1 to Reg

101 Jump to 105

102 add Reg1 to Reg

105 move Reg1 to Mem

100 MOVE Reg1, Mem

101 JUMP 105

102 ADD 1, Reg

105 MOVE Mem2, Reg

a) Reversed instructions

Delayed branch When a branch occur, delay the execution and fetch the next instruction first. ex) fetch 102 before executing JUMP to 105, this way 102 can execute at the same time 105 is fetch

F – fetch E – execute W – write back

Superpipeline

A B C D E F G H I J K L

A B C D E F G H I J K

A B C D E F G H I J

A B C D E F G H I

A B C D E F G H

A B C D E F G

A B C D E F

A B C D E

A B C D

A B C

A B

A

A B C D E F G H

In theory, more and shorter stages could allow more instructions to be process at the same time. But a branch could lead to wasted cycles.

Branch executed and pipeline is clear

RISC Pipelining

Arm Cortex A8(IPhone3GS, Samsung Galaxy S)

13 Stage pipeline

Fetch Instruction(2 stages)

Decode(5 stages)

Execute, Memory, Writeback(6 stages)

Dynamic Branch Prediction 95% accuracy

I7(Nehalem)Superpipeline

14 Stages

Fetch

Decode

Execute

Memory, Writeback