Title: Csci 136 Computer Architecture II
1Csci 136 Computer Architecture II A Pipelined
Datapath
- Xiuzhen Cheng
- cheng_at_gwu.edu
2Announcement
- Homework assignment 9, Due time Before class,
April 05. - Readings Sections 6.1 6.3
- Problems 6.1-6.4, 6.13-6.14
- Project 3 is due on April 10, 2005
3Topics
- Two pipelined datapath representations
- Single cycle
- Multiple cycle
- Five functional units for pipelined datapath
- Each can be used only within a single pipeline
stage. Why? -
- Comparison of single cycle datapath, multi cycle
datapath and pipelined datapath - From one to another
- Sharing of functional unit
- Number of clock cycles
- Clock cycle time
- Temporary registers pass information
- Complexity of control design ( hazards )
4Graphically Representing Pipelines
- multiple-clock-cycle pipeline datagrams
- Can help with answering questions like
- how many cycles does it take to execute this
code? - what is the ALU doing during cycle 4?
- use this representation to help understand
datapaths
5Pipelined Datapath
6Single Cycle Datapath
7Multi Cycle Datapath
8The Big Picture Where are We Now?
- The Five Classic Components of a Computer
- Current Topics
- Pipelining is an implementation technique in
which multiple instructions are overlapped in
execution
Processor
Input
Control
Memory
Datapath
Output
9Single-Cycle Pipeline Datagram
- What do we need to add to split the datapath into
stages?
10Pipelined Datapath
64
128
64
97
- how many bits stored in each pipeline register?
11Observations
- 5-stage pipeline
- IF, ID, EX, MEM, WB
- Left-to-right flow of instructions
- Instructions and data move generally from left to
right - Two exceptions WB stage and the selection of PC
- May lead to data hazards and control hazards
- Why there is no pipeline register at the end of
the WB stage? - Last stage must update either register file, or
memory, or PC
12Pipelining the Load Instruction
Cycle 1
Cycle 2
Cycle 3
Cycle 4
Cycle 5
Cycle 6
Cycle 7
Clock
2nd lw
3rd lw
- The five independent functional units in the
pipeline datapath are - Instruction Memory for the Ifetch stage
- Register Files Read ports (busA and busB) for
the Reg/Dec stage - ALU for the Exec stage
- Data Memory for the Mem stage
- Register Files Write port (bus W) for the Wr
stage
13The Four Stages of R-type
Cycle 1
Cycle 2
Cycle 3
Cycle 4
R-type
- Ifetch Instruction Fetch
- Fetch the instruction from the Instruction Memory
- Reg/Dec Registers Fetch and Instruction Decode
- Exec
- ALU operates on the two register operands
- Wr Write the ALU output back to the register file
14Pipelining the R-type and Load Instruction
Cycle 1
Cycle 2
Cycle 3
Cycle 4
Cycle 5
Cycle 6
Cycle 7
Cycle 8
Cycle 9
Clock
Oops! We have a problem!
R-type
R-type
Load
R-type
R-type
- We have pipeline conflict or structural hazard
- Two instructions try to write to the register
file at the same time! - Only one write port
15Important Observation
- Each functional unit can only be used once per
instruction - Each functional unit must be used at the same
stage for all instructions - Load uses Register Files Write Port during its
5th stage - R-type uses Register Files Write Port during its
4th stage
- 2 ways to solve this pipeline hazard
16Solution 1 Insert Bubble into the Pipeline
Cycle 1
Cycle 2
Cycle 3
Cycle 4
Cycle 5
Cycle 6
Cycle 7
Cycle 8
Cycle 9
Clock
Load
R-type
Pipeline
R-type
R-type
Bubble
- Insert a bubble into the pipeline to prevent 2
writes at the same cycle - The control logic can be complex
- Lose instruction fetch and issue opportunity
- No instruction is started in Cycle 6!
17Solution 2 Delay R-types Write by One Cycle
- Delay R-types register write by one cycle
- Now R-type instructions also use Reg Files write
port at Stage 5 - Mem stage is a NOOP stage nothing is being done
4
1
2
3
5
Exec
Mem
R-type
Cycle 1
Cycle 2
Cycle 3
Cycle 4
Cycle 5
Cycle 6
Cycle 7
Cycle 8
Cycle 9
Clock
R-type
R-type
Load
R-type
R-type
18The Four Stages of Store
Cycle 1
Cycle 2
Cycle 3
Cycle 4
Store
Wr
- Ifetch Instruction Fetch
- Fetch the instruction from the Instruction Memory
- Reg/Dec Registers Fetch and Instruction Decode
- Exec Calculate the memory address
- Mem Write the data into the Data Memory
19The Three Stages of Beq
Cycle 1
Cycle 2
Cycle 3
Cycle 4
Mem
Beq
Wr
- Ifetch Instruction Fetch
- Fetch the instruction from the Instruction Memory
- Reg/Dec
- Registers Fetch and Instruction Decode
- Exec
- compares the two register operand,
- select correct branch target address
- latch into PC
20Pipelined Execution of Load Instruction
21Pipelined Execution of Load Instruction
22Pipelined Execution of Load Instruction
23Pipelined Execution of Load Instruction
24Pipelined Execution of Load Instruction
25Pipelined Execution of Store Instruction
26Pipelined Execution of Store Instruction
27Observations from Load and Store
- Pass information needed from an earlier stage to
a latter stage - Each logical component of the datapath such as
IM, Reg read ports, ALU, DM, Reg write port can
be used only within a single pipeline stage.
Otherwise, we would have structural hazard - A bug in the pipelined datapath for load. Can you
tell?
28Modified Datapath For Basic R-Type, LW/SW, and
BEQ
29Pipelined Execution for Multiple Instructions
30Pipelined Execution for Multiple Instructions
31Pipelined Execution for Multiple Instructions
32Pipelined Execution for Multiple Instructions
33Pipelined Execution for Multiple Instructions
34Pipelined Execution for Multiple Instructions
35Pipelined Datapath Control
36Overview on Datapath Control
- For the subset of instructions under
consideration, N1. - ALUOp 00 for Add, 01 for Sub, and 10 for R-type
37Observations
- No write control for all pipeline registers and
PC since they are updated at every clock cycle. - To specify the control for the pipeline, set the
control values during each pipeline stage. - Control lines can be divided into 5 groups
- IF NONE
- ID NONE
- ALU RegDst, ALUOp, ALUSrc
- MEM Branch, MemRead, MemWrite
- WB MemtoReg, RegWrite
- Group these nine control lines into 3 subsets
- ALUControl, MEMControl, WBControl
- Control signals are generated at ID stage, how to
pass them to other stages?
38Pass Control Signals
- Extend the pipeline registers to include control
information
39The Complete Pipelined Datapath
40Example Pipeline Execution
- Show the five instructions going through the
pipeline lw 10, 20(1) sub 11, 2,
3 and 12, 4, 5 or 13, 6, 7 - add 14, 8, 9
- Note that these instructions are independent with
each other!
41Clock1
42Clock2
43Clock3
44Clock4
45Clock5
46Clock6
47Clock7
48Clock8
49Clock9
50Questions?