A Multicycle Data Path Implementation

A Multicycle Data Path Implementation Alvin R. Lebeck CPS 104 Lecture 15 cps 104 1 ©GK Spring 1997 Outline of Today’s Lecture ° Review Finite Stat...
35 downloads 0 Views 125KB Size
A Multicycle Data Path Implementation

Alvin R. Lebeck CPS 104 Lecture 15

cps 104 1

©GK Spring 1997

Outline of Today’s Lecture ° Review Finite State Machines ° Review Single Cycle Processor ° Introduction to the Concept of Multiple Cycle Processor ° Multiple Cycle Implementation of R-type Instructions ° What is a Multiple Cycle Delay Path and Why is it Bad? ° Multiple Cycle Implementation of Or Immediate ° Multiple Cycle Implementation of Load and Store ° Putting it all Together ° Exceptions and Interrupts.

cps 104 2

©GK Spring 1997

FSM State Diagram Example: Traffic light Controller I= (-- ; NC)

NG I = (--;C)

O = (G;R)

EY NY

O = (R;Y)

O = (Y;R)

O = (R;G)

I = (C; --)

EG I = (NC; --)

cps 104 3

©GK Spring 1997

Example: Traffic Light Controller

I 01 01--0 -1 --

S 01 00 00 01 10 10 11

cps 104 4

NS 01 00 01 10 10 11 00

OT 012345 100001 100001 010001 001100 001100 001010

NS1 = = NS0 = = OT0 = OT1 = OT2 = OT3 = OT4 = OT5 =

S0’*S1’*I0+S0*S1’*I1 S1’*(S0’I0+S0*I1) S0’*S1+S0*S1’*I1’+S0*S1’*I1 S0’*S1+S0*S1’ S0’*S1’ S0’*S1 S0*S1’+S0*S1= S0 S0*S1’ S0*S1 S0’*S1’+S0’*S1= S0’

©GK Spring 1997

Traffic Controller FSM implementation S0

S1 D

D

I0*s0’

D

S1 DFF

Q

OT3 DFF

Q

S0 DFF

Q

OT1 DFF

Q

OT1

OT4 DFF

Q

OT4

OT0 DFF

Q

OT0

OT5 DFF

Q

OT5

OT2

OT3

C

I1 s0*s1’

Q

C

I0 I1*s0

OT2 DFF C

D

C

s0’*s1 D

C

s0*s1 D

C

s0’*s1’ D

C

D

C

Clock

cps 104 5

©GK Spring 1997

A Single Cycle Processor ALUop op 6 Instr

Main Control

ALUSrc

:

ALU Control

func Instr 6

Extender

16

Zero

1 32

Rs

Rd

MemtoReg

MemWr 0

32 32 WrEn Adr

Data In 32 Clk

Imm16

Mux

busA Rw Ra Rb 32 32 32-bit Registers busB 0 32

imm16 Instr

Rt

ALUctr

Mux

32 Clk

Rt 5

ALU

busW

Rs 5



RegWr 5



1 Mux 0



Instruction Fetch Unit

Jump Clk

Rt

ALUctr 3

Instruction

Branch



Rd RegDst

3

RegDst

1

Data Memory

ALUSrc ExtOp cps 104 6

©GK Spring 1997

Instruction Fetch Unit

30 30

PC

“00”

Target 4 Instruction 26 Adder

30

imm16 Instruction 16

Mux

SignExt

Clk

Instruction Memory

0

0 30 Adder

“1”

1 Mux

PC

30

Addr Addr

32

Jump

1

Instruction

30

30

Branch

Zero

cps 104 7

©GK Spring 1997

The Main Control

..

op

..

op



R-type

..

op



ori

..

op



lw

..

op



sw



beq

..

op

jump

op

RegWrite ALUSrc RegDst MemtoReg MemWrite Branch Jump ExtOp ALUop ALUop ALUop

cps 104 8

©GK Spring 1997

Drawbacks of this Single Cycle Processor

° Long cycle time: • Cycle time must be long enough for the load instruction: -

PC’s Clock -to-Q + Instruction Memory Access Time +

-

Register File Access Time + ALU Delay (address calculation) +

-

Data Memory Access Time + Register File Setup Time +

-

Clock Skew

° Cycle time is much longer than needed for all other instructions. Examples: • R-type instructions do not require data memory access • Jump does not require ALU operation nor data memory access

cps 104 9

©GK Spring 1997

Multiple Cycle Processor ° The root of the single cycle processor’s problems: • The cycle time has to be long enough for the slowest instruction ° Solution: • Break the instruction into smaller steps • Execute each step (instead of the entire instruction) in 1 clock cycle -

Cycle time: time it takes to execute the longest step Try to make all the steps have similar length

• This is the essence of the multiple cycle processor ° The advantages of the multiple cycle processor: • Cycle time is much shorter • Different instructions take different number of cycles to complete -

Load takes five cycles Jump only takes three cycles

• Allows a functional unit to be used more than once per instruction cps 104 10

©GK Spring 1997

Multicycle Processor

° How should we design a multicycle processor? ° What are the smaller steps for each instruction? ° What if goal is to minimize HW resources?

cps 104 11

©GK Spring 1997

The Five Steps of a Load Instruction Instruction Fetch

Instr Decode / Reg Fetrch

Address

Data Memory

Reg Wr

Clk PC

Old Value

Clk-to-Q New Value Instruction Memory Access Time New Value

Rs, Rt, Rd, Op, Func

Old Value

ALUctr

Old Value

ExtOp

Old Value

New Value

ALUSrc

Old Value

New Value

RegWr

Old Value

New Value

busB

Register File Access Time New Value

Old Value Delay through Extender & Mux Old Value

New Value ALU Delay

Address

Old Value

New Value Data Memory Access Time

busW cps 104 12

Old Value

New ©GK Spring 1997

Register File Write Time

busA

Delay through Control Logic New Value

Multiple Cycle Datapath PCWr

RegDst

ALUSelA

RegWr

1

WrAdr 32 Din Dout

32

32

32

Rt Rt 0

5

Rd

Ra Rb

busA

Reg File

Mux

Ideal Memory

5

Beq Rtype Ori Memory

Op

Control

Func

6

4

0

32

1

busW busB 32

1

32

2 3

Suggest Documents