Csci 136 Computer Architecture II - PowerPoint PPT Presentation

About This Presentation
Title:

Csci 136 Computer Architecture II

Description:

Reg/Dec: Registers Fetch and Instruction Decode. Exec: Calculate the memory address ... Registers Fetch and Instruction Decode. Exec: compares the two register ... – PowerPoint PPT presentation

Number of Views:213
Avg rating:3.0/5.0
Slides: 50
Provided by: xiuzhe
Category:

less

Transcript and Presenter's Notes

Title: Csci 136 Computer Architecture II


1
Csci 136 Computer Architecture II A Pipelined
Datapath
  • Xiuzhen Cheng
  • cheng_at_gwu.edu

2
Announcement
  • 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

3
Topics
  • 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 )

4
Graphically 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

5
Pipelined Datapath
6
Single Cycle Datapath
7
Multi Cycle Datapath
8
The 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
9
Single-Cycle Pipeline Datagram
  • What do we need to add to split the datapath into
    stages?

10
Pipelined Datapath
64
128
64
97
  • how many bits stored in each pipeline register?

11
Observations
  • 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

12
Pipelining 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

13
The 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

14
Pipelining 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

15
Important 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

16
Solution 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!

17
Solution 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
18
The 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

19
The 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

20
Pipelined Execution of Load Instruction
21
Pipelined Execution of Load Instruction
22
Pipelined Execution of Load Instruction
23
Pipelined Execution of Load Instruction
24
Pipelined Execution of Load Instruction
25
Pipelined Execution of Store Instruction
26
Pipelined Execution of Store Instruction
27
Observations 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?

28
Modified Datapath For Basic R-Type, LW/SW, and
BEQ
29
Pipelined Execution for Multiple Instructions
30
Pipelined Execution for Multiple Instructions
31
Pipelined Execution for Multiple Instructions
32
Pipelined Execution for Multiple Instructions
33
Pipelined Execution for Multiple Instructions
34
Pipelined Execution for Multiple Instructions
35
Pipelined Datapath Control
36
Overview on Datapath Control
  • For the subset of instructions under
    consideration, N1.
  • ALUOp 00 for Add, 01 for Sub, and 10 for R-type

37
Observations
  • 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?

38
Pass Control Signals
  • Extend the pipeline registers to include control
    information

39
The Complete Pipelined Datapath
40
Example 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!

41
Clock1
42
Clock2
43
Clock3
44
Clock4
45
Clock5
46
Clock6
47
Clock7
48
Clock8
49
Clock9
50
Questions?
Write a Comment
User Comments (0)
About PowerShow.com