Top Banner
1 Processor: Datapath and Control Single cycle processor Datapath and Control Multicycle processor Datapath and Control Microprogramming Vertical and Horizontal Microcodes
64

1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

Jan 29, 2016

Download

Documents

Morgan Doyle
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

1

Processor: Datapath and Control

• Single cycle processor– Datapath and Control

• Multicycle processor– Datapath and Control

• Microprogramming– Vertical and Horizontal Microcodes

Page 2: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

2

Processor Design

• Processor design

– datapath and control unit design

– processor design determines

» clock cycle time

» clock cycles per instruction

• Performance of a machine is determined by

– Instruction count

– clock cycle time

– clock cycles per instruction

Page 3: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

3

Review: THE Performance Equation• Our basic performance equation is then

CPU time = Instruction_count x CPI x clock_cycle

Instruction_count x CPI

clock_rate CPU time = -----------------------------------------------

or

• These equations separate the three key factors that affect performance

– Can measure the CPU execution time by running the program

– The clock rate is usually given in the documentation

– Can measure instruction count by using profilers/simulators without knowing all of the implementation details

– CPI varies by instruction type and ISA implementation for which we must know the implementation details

Page 4: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

4

How to Design a Processor: step-by-step

1. Analyze instruction set => datapath requirements

the meaning of each instruction is given by the register transfers

datapath must include storage element for ISA registers

possibly more

datapath must support each register transfer

2. Select set of datapath components and establish clocking methodology

3. Assemble datapath meeting the requirements

4. Analyze implementation of each instruction to determine setting of control points that effects the register transfer.

5. Assemble the control logic

Page 5: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

5

Single Cycle Processor• Single cycle processor

– Pros: one clock cycle per instruction

– Cons: too long cycle time, too low clocking frequency

• Design a processor

– analyze instruction set (the meaning of each instruction is given by the register transfers)

– timing of each instruction

– datapath support each register transfer

– select datapath components and establish clocking methodology

– analyze implementation of each instruction to determine setting of control points that affect register transfer

– assemble control logic and datapath components

Page 6: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

6

Clocking Methodology

• Edge-triggered clock

• setup time

• hold time

• all storage elements clocked by the same clock

• combinational logic block:

– inputs are updated at each clock tick

– all outputs must be stable before the next clock tick

Page 7: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

7

Clocked Logic Timing

Page 8: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

8

Timing Analysis, Logic Delay

Worst case CL delay limits T.

What is the smallest T that produces correct

operation?

Page 9: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

9

Flip Flop delays:

D Q

clk-to-Q ?

CLK == 0

Sense D, but Qoutputs old value.

CLK 0->1

Capture D, passvalue to Q

CLK

setup ?

hold ?

clk-to-Q

setup

hold

Page 10: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

10

Flip Flops have internal delays

D Q

CLK

Value of D is sampled on positive clock edge.

D

Q

t_setup

t_clk-to-Q

CLK

Q outputs sampled value for rest of cycle.

Page 11: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

11

Combinational Logic

ALU “time budget”

Page 12: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

12

CLKd

Cycle Time = CLK-to-Q + Longest Delay Path + Setup + Clock Skew

(CLK-to-Q + Shortest Delay Path - Clock Skew) > Hold Time

Page 13: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

13

D

t_setup

CLK

t_hold

D must stay

stable here

D Q

CLK

Does flip-flop hold time affect operation of this circuit? Under what conditions? t_clk-to-Q + t_inv > t_hold

t_inv

What is the intended function of this circuit?

Page 14: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

14

The MIPS Instruction Formats

• All MIPS instructions are 32 bits long. The three instruction formats:

– R-type

– I-type

– J-type

• The different fields are:

– op: operation of the instruction

– rs, rt, rd: the source and destination register specifiers

– shamt: shift amount

– funct: selects the variant of the operation in the “op” field

– address / immediate: address offset or immediate value

– target address: target address of the jump instruction

op target address02631

6 bits 26 bits

op rs rt rd shamt funct061116212631

6 bits 6 bits5 bits5 bits5 bits5 bits

op rs rt immediate016212631

6 bits 16 bits5 bits5 bits

Page 15: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

15

Register Transfers

• add $1, $2, $3; rs = $2, rt = $3, rd = $1

R[rd] <- R[rs] + R[rt} PC <- PC + 4

• sub $1, $2, $3; rs = $2, rt = $3, rd = $1

R[rd] <- R[rs] - R[rt] PC <- PC + 4

• ori $1, $2, 20; rs = $2, rt = $1

R[rt] <- R[rs] + zero_ext(imm16) PC <- PC + 4

• lw $1, 200($2); rs = $2, rt = $1

R[rt] <- MEM{R[rs] + sign_ext(imm16)} PC <- PC + 4

• sw $1, 200($2); rs = $2, rt = $1

MEM{R[rs] + sign_ext(imm16)} <- R[rt] PC <- PC + 4

Page 16: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

16

Components

Memory: hold instruction and data

Registers: 32 32-bit registers– read rs

– read rt

– write rd

– write rt

Program counter

Extender

Add and Sub registers or extended immediates

Add 4 to PC or Add extended immediate to PC (jump inst)

Page 17: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

17

Combinational Logic Elements

• Adder

• MUX(multi-plexor)

• ALU

32

32

A

B32

Sum

Carry

32

32

A

B32

Result

OP

32A

B32

Y32

Select

Ad

der

MU

XA

LU

CarryIn(to add values)

(to chose between values)

(to do add, subtract, or)

Page 18: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

18

Storage Element: Register (Basic Building Block)

• Register– Similar to the D Flip Flop

except

» N-bit input and output

» Write Enable input

– Write Enable:

» negated (0): Data Out will not change

» asserted (1): Data Out will become Data In

Clk

Data In

Write Enable

N N

Data Out

Page 19: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

19

Sequential Logic Elements

• Registers: n-bit input and output, D F/F, write enable

• rs, rt, rd : register specifiers

registers

readregister1

read register2writeregisterwritedata

readdata1

readdata2

Page 20: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

20

Fetching Instructions• Fetching instructions involves

– reading the instruction from the Instruction Memory

– updating the PC to hold the address of the next instruction

ReadAddress

Instruction

InstructionMemory

Add

PC

4

– PC is updated every cycle, so it does not need an explicit write control signal

– Instruction Memory is read every cycle, so it doesn’t need an explicit read control signal

Page 21: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

21

Decoding Instructions• Decoding instructions involves

– sending the fetched instruction’s opcode and function field bits to the control unit

Instruction

Write Data

Read Addr 1

Read Addr 2

Write Addr

Register

File

Read Data 1

Read Data 2

ControlUnit

– reading two values from the Register File» Register File addresses are contained in the instruction

Write Data

Read Addr 1

Read Addr 2

Write Addr

Register

File

Read Data 1

Read Data 2

Page 22: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

22

Executing R Format Operations• R format operations (add, sub, slt, and, or)

– perform the (op and funct) operation on values in rs and rt

– store the result back into the Register File (into location rd)

Instruction

Write Data

Read Addr 1

Read Addr 2

Write Addr

Register

File

Read Data 1

Read Data 2

ALU

overflowzero

ALU controlRegWrite

R-type:

31 25 20 15 5 0

op rs rt rd functshamt

10

– The Register File is not written every cycle (e.g. sw), so we need an explicit write control signal for the Register File

Page 23: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

23

Executing Load and Store Operations• Load and store operations involves

– compute memory address by adding the base register (read from the Register File during decode) to the 16-bit signed-extended offset field in the instruction

– store value (read from the Register File during decode) written to the Data Memory

– load value, read from the Data Memory, written to the Register File

Instruction

Write Data

Read Addr 1

Read Addr 2

Write Addr

Register

File

Read Data 1

Read Data 2

ALU

overflowzero

ALU controlRegWrite

DataMemory

Address

Write Data

Read Data

SignExtend

MemWrite

MemRead

16 32

Page 24: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

24

Executing Branch Operations• Branch operations involves

– compare the operands read from the Register File during decode for equality (zero ALU output)

– compute the branch target address by adding the updated PC to the 16-bit signed-extended offset field in the

instr

Instruction

Write Data

Read Addr 1

Read Addr 2

Write Addr

Register

File

Read Data 1

Read Data 2

ALU

zero

ALU control

SignExtend16 32

Shiftleft 2

Add

4 Add

PC

Branchtargetaddress

(to branch control logic)

Page 25: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

25

Executing Jump Operations• Jump operation involves

– replace the lower 28 bits of the PC with the lower 26 bits of the fetched instruction shifted left by 2 bits

ReadAddress

Instruction

InstructionMemory

Add

PC

4

Shiftleft 2

Jumpaddress

26

4

28

Page 26: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

26

Creating a Single Datapath from the Parts

• Assemble the datapath segments and add control lines and multiplexors as needed

• Single cycle design – fetch, decode and execute each instructions in one clock cycle

– no datapath resource can be used more than once per instruction, so some must be duplicated (e.g., separate Instruction Memory and Data Memory, several adders)

– multiplexors needed at the input of shared elements with control lines to do the selection

– write signals to control writing to the Register File and Data Memory

• Cycle time is determined by length of the longest path

Page 27: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

27

Fetch, R, and Memory Access Portions

MemtoReg

ReadAddress

Instruction

InstructionMemory

Add

PC

4

Write Data

Read Addr 1

Read Addr 2

Write Addr

Register

File

Read Data 1

Read Data 2

ALU

ovfzero

ALU controlRegWrite

DataMemory

Address

Write Data

Read Data

MemWrite

MemReadSign

Extend16 32

ALUSrc

Page 28: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

28

Adding the Control• Selecting the operations to perform (ALU, Register File and

Memory read/write)

• Controlling the flow of data (multiplexor inputs)

I-Type: op rs rt address offset

31 25 20 15 0

R-type:

31 25 20 15 5 0

op rs rt rd functshamt

10

• Observations– op field always

in bits 31-26

– addr of registers

to be read are always specified by the rs field (bits 25-21) and rt field (bits 20-16); for lw and sw rs is the base register

– addr. of register to be written is in one of two places – in rt (bits 20-16) for lw; in rd (bits 15-11) for R-type instructions

– offset for beq, lw, and sw always in bits 15-0

J-type:31 25 0

op target address

Page 29: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

29

Single Cycle Datapath with Control Unit

ReadAddress

Instr[31-0]

InstructionMemory

Add

PC

4

Write Data

Read Addr 1

Read Addr 2

Write Addr

Register

File

Read Data 1

Read Data 2

ALU

ovf

zero

RegWrite

DataMemory

Address

Write Data

Read Data

MemWrite

MemRead

SignExtend16 32

MemtoReg

ALUSrc

Shiftleft 2

Add

PCSrc

RegDst

ALUcontrol

1

1

1

00

0

0

1

ALUOp

Instr[5-0]

Instr[15-0]

Instr[25-21]

Instr[20-16]

Instr[15 -11]

ControlUnit

Instr[31-26]

Branch

Page 30: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

30

R-type Instruction Data/Control Flow

ReadAddress

Instr[31-0]

InstructionMemory

Add

PC

4

Write Data

Read Addr 1Read Addr 2

Write Addr

Register

File

Read Data 1

Read Data 2

ALU

ovf

zero

RegWrite

DataMemory

Address

Write Data

Read Data

MemWrite

MemRead

SignExtend16 32

MemtoReg

ALUSrc

Shiftleft 2

Add

PCSrc

RegDst

ALUcontrol

1

1

1

00

0

0

1

ALUOp

Instr[5-0]

Instr[15-0]

Instr[25-21]

Instr[20-16]

Instr[15 -11]

ControlUnit

Instr[31-26]

Branch

Page 31: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

31

Load Word Instruction Data/Control Flow

ReadAddress

Instr[31-0]

InstructionMemory

Add

PC

4

Write Data

Read Addr 1

Read Addr 2

Write Addr

Register

File

Read Data 1

Read Data 2

ALU

ovf

zero

RegWrite

DataMemory

Address

Write Data

Read Data

MemWrite

MemRead

SignExtend16 32

MemtoReg

ALUSrc

Shiftleft 2

Add

PCSrc

RegDst

ALUcontrol

1

1

1

00

0

0

1

ALUOp

Instr[5-0]

Instr[15-0]

Instr[25-21]

Instr[20-16]

Instr[15 -11]

ControlUnit

Instr[31-26]

Branch

Page 32: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

32

Load Word Instruction Data/Control Flow

ReadAddress

Instr[31-0]

InstructionMemory

Add

PC

4

Write Data

Read Addr 1

Read Addr 2

Write Addr

Register

File

Read Data 1

Read Data 2

ALU

ovf

zero

RegWrite

DataMemory

Address

Write Data

Read Data

MemWrite

MemRead

SignExtend16 32

MemtoReg

ALUSrc

Shiftleft 2

Add

PCSrc

RegDst

ALUcontrol

1

1

1

00

0

0

1

ALUOp

Instr[5-0]

Instr[15-0]

Instr[25-21]

Instr[20-16]

Instr[15 -11]

ControlUnit

Instr[31-26]

Branch

Page 33: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

33

Branch Instruction Data/Control Flow

ReadAddress

Instr[31-0]

InstructionMemory

Add

PC

4

Write Data

Read Addr 1

Read Addr 2

Write Addr

Register

File

Read Data 1

Read Data 2

ALU

ovf

zero

RegWrite

DataMemory

Address

Write Data

Read Data

MemWrite

MemRead

SignExtend16 32

MemtoReg

ALUSrc

Shiftleft 2

Add

PCSrc

RegDst

ALUcontrol

1

1

1

00

0

0

1

ALUOp

Instr[5-0]

Instr[15-0]

Instr[25-21]

Instr[20-16]

Instr[15 -11]

ControlUnit

Instr[31-26]

Branch

Page 34: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

34

Branch Instruction Data/Control Flow

ReadAddress

Instr[31-0]

InstructionMemory

Add

PC

4

Write Data

Read Addr 1

Read Addr 2

Write Addr

Register

File

Read Data 1

Read Data 2

ALU

ovf

zero

RegWrite

DataMemory

Address

Write Data

Read Data

MemWrite

MemRead

SignExtend16 32

MemtoReg

ALUSrc

Shiftleft 2

Add

PCSrc

RegDst

ALUcontrol

1

1

1

00

0

0

1

ALUOp

Instr[5-0]

Instr[15-0]

Instr[25-21]

Instr[20-16]

Instr[15 -11]

ControlUnit

Instr[31-26]

Branch

Page 35: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

35

Adding the Jump Operation

ReadAddress

Instr[31-0]

InstructionMemory

Add

PC

4

Write Data

Read Addr 1

Read Addr 2

Write Addr

Register

File

Read Data 1

Read Data 2

ALU

ovf

zero

RegWrite

DataMemory

Address

Write Data

Read Data

MemWrite

MemRead

SignExtend16 32

MemtoReg

ALUSrc

Shiftleft 2

Add

PCSrc

RegDst

ALUcontrol

1

1

1

00

0

0

1

ALUOp

Instr[5-0]

Instr[15-0]

Instr[25-21]

Instr[20-16]

Instr[15 -11]

ControlUnit

Instr[31-26]

Branch

Shiftleft 2

0

1

Jump

32Instr[25-0]

26PC+4[31-28]

28

Page 36: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

36

Single Cycle Control Unit: ALU control

controlunitInstr[31-26]

ALUOpALU

controlto ALU

operation

Instr[5-0]

On page 302, Operation has 4 bits with the first bit always zero

addsub.

addsub.andor

seton lessthan

Page 37: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

37

Page 38: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

38

ALU Control Implementation

Page 39: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

39

On page 301, ALU control lines = Operation

ALU control lines Function 0000 AND0001 OR0010 add0110 subtract0111 set on less than1100 NOR

Page 40: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

40

instruction

opcode

ALUOP Instruction

operation

Funct

field

Desired

ALU action

ALU control input, i.e., Operation

LW 00 load word xxxxxx add 0010

SW 00 store word xxxxxx add 0010

Branch

equal

01 branch

equal

xxxxxx subtract 0110

R type 10 add 100000 add 0010

R type 10 subtract 100010 subtract 0110

R type 10 AND 100100 and 0000

R type 10 OR 100101 or 0001

R type 10 set on less than

101010 set on less than

0111

Page 41: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

41

Setting of the control signals

Instru-ction

RegDst ALUSrc Memto

Reg

Reg

Write

Mem

Read

Mem

Write

Branch ALU

Op1

ALU

Op0

R type 1 0 0 1 0 0 0 1 0

lw 0 1 1 1 1 0 0 0 0

sw x 1 x 0 0 1 0 0 0

beq x 0 x 0 0 0 1 0 1

Page 42: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

42

Page 43: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

43

Control Unit PLA Implementation

Page 44: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

44

Single Cycle Disadvantages & Advantages• Uses the clock cycle inefficiently – the clock cycle must be

timed to accommodate the slowest instruction– especially problematic for more complex instructions like

floating point multiply

• May be wasteful of area since some functional units (e.g., adders) must be duplicated since they can not be shared during a clock cycle

but• Is simple and easy to understand

Clk

lw sw Waste

Cycle 1 Cycle 2

Page 45: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

45

Multicycle Datapath Approach• Let an instruction take more than 1 clock cycle to complete

– Break up instructions into steps where each step takes a cycle while trying to

» balance the amount of work to be done in each step

» restrict each cycle to use only one major functional unit

– Not every instruction takes the same number of clock cycles

• In addition to faster clock rates, multicycle allows functional units that can be used more than once per instruction as long as they are used on different clock cycles, as a result

– only need one memory – but only one memory access per cycle

– need only one ALU/adder – but only one ALU operation per cycle

Page 46: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

46

Multicycle Datapath Approach• Let an instruction take more than 1 clock cycle to complete

– Break up instructions into steps where each step takes a cycle while trying to

» balance the amount of work to be done in each step

» restrict each cycle to use only one major functional unit

– Not every instruction takes the same number of clock cycles

• In addition to faster clock rates, multicycle allows functional units that can be used more than once per instruction as long as they are used on different clock cycles, as a result

– only need one memory – but only one memory access per cycle

– need only one ALU/adder – but only one ALU operation per cycle

Page 47: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

47

• At the end of a cycle– Store values needed in a later cycle by the current instruction in an internal

register (not visible to the programmer). All (except IR) hold data only between a pair of adjacent clock cycles (no write control signal needed)

IR – Instruction Register MDR – Memory Data Register

A, B – regfile read data registers ALUout – ALU output register

Multicycle Datapath Approach, con’t

Address

Read Data(Instr. or Data)

Memory

PC

Write Data

Read Addr 1

Read Addr 2

Write Addr

Register

File

Read Data 1

Read Data 2

ALU

Write Data

IRM

DR

AB A

LU

ou

t

– Data used by subsequent instructions are stored in programmer visible registers (i.e., register file, PC, or memory)

Page 48: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

48

The Multicycle Datapath with Control Signals

Address

Read Data(Instr. or Data)

Memory

PC

Write Data

Read Addr 1

Read Addr 2

Write Addr

Register

File

Read Data 1

Read Data 2

ALU

Write Data

IRM

DR

AB

AL

Uo

ut

SignExtend

Shiftleft 2 ALU

control

Shiftleft 2

ALUOpControl

IRWriteMemtoReg

MemWriteMemRead

IorD

PCWrite

PCWriteCond

RegDstRegWrite

ALUSrcAALUSrcB

zero

PCSource

1

1

1

1

1

10

0

0

0

0

0

2

2

3

4

Instr[5-0]

Instr[25-0]

PC[31-28]

Instr[15-0]

Instr[3

1-2

6]

32

28

Page 49: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

49

• Multicycle datapath control signals are not determined solely by the bits in the instruction

– e.g., op code bits tell what operation the ALU should be doing, but not what instruction cycle is to be done next

• Must use a finite state machine (FSM) for control

– a set of states (current state stored in State Register)

– next state function (determined by current state and the input)

– output function (determined by current state and the input)

Multicycle Control Unit

Combinationalcontrol logic

State RegInst

Opcode

Datapathcontrolpoints

Next State

. . .. . .

. . .

Page 50: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

50

The Five Steps of the Load Instruction

• IFetch: Instruction Fetch and Update PC

• Dec: Instruction Decode, Register Read, Sign Extend Offset

• Exec: Execute R-type; Calculate Memory Address; Branch Comparison; Branch and Jump Completion

• Mem: Memory Read; Memory Write Completion; R-type Completion (RegFile write)

• WB: Memory Read Completion (RegFile write)

Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5

IFetch Dec Exec Mem WBlw

INSTRUCTIONS TAKE FROM 3 - 5 CYCLES!

Page 51: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

51

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 state register overhead

Page 52: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

52

Page 53: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

53

Page 54: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

54

Page 55: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

55

Page 56: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

56

Page 57: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

57

Page 58: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

58

Page 59: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

59

Page 60: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

60

Page 61: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

61

Page 62: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

62

Page 63: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

63

Page 64: 1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.

64