40
10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz Lec10.1 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October 3, 2001 John Kubiatowicz (http.cs.berkeley.edu/~kubitron) lecture slides: http://www- inst.eecs.berkeley.edu/~cs152/

CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

  • View
    214

  • Download
    0

Embed Size (px)

Citation preview

Page 1: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.1

CS 152 Computer Architecture and Engineering

Lecture 10

Multicycle Controller Design (Continued)

October 3, 2001

John Kubiatowicz (http.cs.berkeley.edu/~kubitron)

lecture slides: http://www-inst.eecs.berkeley.edu/~cs152/

Page 2: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.2

Partitioning the CPI=1 Datapath° Add registers between smallest steps

° Place enables on all registers

PC

Nex

t P

C

Ope

rand

Fet

ch Exec Reg

. F

ile

Mem

Acc

ess

Dat

aM

em

Inst

ruct

ion

Fet

ch

Res

ult

Sto

re

ALU

ctr

Reg

Dst

ALU

Src

Ext

Op

Mem

Wr

nPC

_sel

Reg

Wr

Mem

Wr

Mem

Rd

Equ

al

Page 3: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.3

Recap: Example Multicycle Datapath

° Critical Path ?

PC

Nex

t P

C

Ope

rand

Fet

ch

Inst

ruct

ion

Fet

ch

nPC

_sel

IRRegFile E

xtA

LU Reg

. F

ile

Mem

Acc

ess

Dat

aM

em

Res

ult

Sto

reR

egD

stR

egW

r

Mem

Wr

Mem

Rd

S

M

Mem

ToR

eg

Equ

al

ALU

ctr

ALU

Src

Ext

Op

A

B

E

Page 4: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.4

Recap: FSM specification

IR <= MEM[PC]

R-type

A <= R[rs]B <= R[rt]

S <= A fun B

R[rd] <= SPC <= PC + 4

S <= A or ZX

R[rt] <= SPC <= PC + 4

ORi

S <= A + SX

R[rt] <= MPC <= PC + 4

M <= MEM[S]

LW

S <= A + SX

MEM[S] <= BPC <= PC + 4

BEQ

PC <= Next(PC)

SW

“instruction fetch”

“decode”

0000

0001

0100

0101

0110

0111

1000

1001

1010

00111011

1100

Exe

cute

Mem

ory

Writ

e-ba

ck

Page 5: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.5

Sequencer-based control unit: Statemachine ++

Opcode

State Reg

Inputs

Outputs

Control Logic MulticycleDatapath

Types of “branching”• Set state to 0• Dispatch (state 1)• Use incremented state number

1

Adder

Address Select Logic

Page 6: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.6

Recap: Micro-controller Design

° The state digrams that arise define the controller for an instruction set processor are highly structured

° Use this structure to construct a simple “microsequencer”

• Each state in previous diagram becomes a “microinstruction”

• Microinstructions often taken sequentially

° Control reduces to programming this device

sequencercontrol

datapath control

micro-PCsequencer

microinstruction ()

Page 7: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.7

Recap: Specific Sequencer from last lecture

°Sequencer-based control unit from last lecture• Called “microPC” or “µPC” vs. state register

Control Value Effect 00 Next µaddress = 0 01 Next µaddress = dispatch ROM 10 Next µaddress = µaddress + 1

ROM:

Opcode

microPC

1

µAddressSelectLogic

Adder

ROM

Mux

0012

R-type 000000 0100BEQ 000100 0011ori 001101 0110LW 100011 1000SW 101011 1011

Page 8: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.8

Recap: Microprogram Control Specification

0000 ? inc 10001 0 load0001 1 inc0010 x zero 1 10011 x zero 1 00100 x inc 0 1 fun 10101 x zero 1 0 0 1 10110 x inc 0 0 or 10111 x zero 1 0 0 1 01000 x inc 1 0 add 11001 x inc 1 0 11010 x zero 1 0 1 1 01011 x inc 1 0 add 11100 x zero 1 0 0 1

µPC Taken Next IR PC Ops Exec Mem Write-Backen sel A B Ex Sr ALU S R W M M-R Wr Dst

R:

ORi:

LW:

SW:

BEQ

Page 9: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.9

Recap: Overview of Control

° Control may be designed using one of several initial representations. The choice of sequence control, and how logic is represented, can then be determined independently; the control can then be implemented with one of several methods using a structured logic technique.

Initial Representation Finite State Diagram Microprogram

Sequencing Control Explicit Next State Microprogram counter Function + Dispatch ROMs

Logic Representation Logic Equations Truth Tables

Implementation PLA ROM Technique

“hardwired control” “microprogrammed control”

Page 10: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.10

The Big Picture: Where are We Now?

° The Five Classic Components of a Computer

° Today’s Topics: • Microprogramed control

• Administrivia

• Microprogram it yourself

• Exceptions

Control

Datapath

Memory

Processor

Input

Output

Page 11: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.11

Microprogramming (Maurice Wilkes)° Control is the hard part of processor design

° Datapath is fairly regular and well-organized

° Memory is highly regular

° Control is irregular and global

Microprogramming:

-- A Particular Strategy for Implementing the Control Unit of a processor by "programming" at the level of register transfer operations

Microarchitecture:

-- Logical structure and functional capabilities of the hardware as seen by the microprogrammer

Historical Note:

IBM 360 Series first to distinguish between architecture & organizationSame instruction set across wide range of implementations, each with different cost/performance

Page 12: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.12

“Macroinstruction” Interpretation

MainMemory

executionunit

controlmemory

CPU

ADDSUBAND

DATA

.

.

.

User program plus Data

this can change!

AND microsequence

e.g., Fetch Calc Operand Addr Fetch Operand(s) Calculate Save Answer(s)

one of these ismapped into oneof these

Page 13: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.13

Variations on Microprogramming

° “Horizontal” Microcode

– control field for each control point in the machine

° “Vertical” Microcode

– compact microinstruction format for each class of microoperation

– local decode to generate all control points (remember ALU?)branch: µseq-op µaddexecute: ALU-op A,B,Rmemory: mem-op S, D

µseq µaddr A-mux B-mux bus enables register enables

HorizontalVertical

Page 14: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.14

Extreme Horizontal

inputselectN3 N2 N1 N0. . .

13

Incr PCALU control

1 bit for each loadable register enbMAR enbAC . . .

Depending on bus organization, many potential control combinations simply wrong, i.e., implies transfers that can never happen at the same time.

Makes sense to encode fields to save ROM space

Example: mem_to_reg and ALU_to_reg should never happen simultaneously; => encode in single bit which is decoded rather than two separate bits

NOTE: the encoding should be only wide enough so that parallel actions that the datapath supports should still be specifiable in a single microinstruction

Page 15: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.15

More Vertical Formatsrc dst

DEC

DEC

other control fields next states inputs

MUX

Some of these may havenothing to do with registers!

Multiformat Microcode:1 3 6

1 3 3 3

0 cond next address

1 dst src alu

DEC

DEC

Branch Jump

Register Xfer Operation

Page 16: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.16

Hybrid Control

Not all critical control information is derived from control logic

E.g., Instruction Register (IR) contains useful control information, such as register sources, destinations, opcodes, etc.

RegisterFile

RS1

DEC

RS2

DEC

RD

DEC

op rs1 rs2 rdIR

tocontrol

enablesignalsfromcontrol

Page 17: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.17

Vax MicroinstructionsVAX Microarchitecture:

96 bit control store, 30 fields, 4096 µinstructions for VAX ISAencodes concurrently executable "microoperations"

USHF UALU USUB UJMP

11 063656895 87 84

001 = left010 = right . . .101 = left3

010 = A-B-1100 = A+B+1

00 = Nop01 = CALL10 = RTN

JumpAddress

SubroutineControl

ALUControl

ALU ShifterControl

Current intel architecture: 80-bit microcode, 8192 instructions

Page 18: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.18

Horizontal vs. Vertical Microprogramming

NOTE: previous organization is not TRUE horizontal microprogramming; register decoders give flavor of encoded microoperations

Most microprogramming-based controllers vary between:

horizontal organization (1 control bit per control point)

vertical organization (fields encoded in the control memory and must be decoded to control something)

Horizontal

+ more control over the potential parallelism of operations in the datapath

- uses up lots of control store

Vertical

+ easier to program, not very different from programming a RISC machine in assembly language

- extra level of decoding may slow the machine down

Page 19: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.19

Administration° Midterm on Wednesday (10/10) from 5:30 - 8:30 in

277 Cory Hall• No class on that day

° Pizza and Refreshments afterwards at LaVal’s on Euclid

• I’ll Buy the pizza

• LaVal’s has an interesting history

° Review Session: • Sunday (10/7), 7:00 PM in 306 Soda????

• Material through this Friday

° Look over Lab 4 soon! • Must email breakdown to your TA by Friday night at midnight

Page 20: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.20

How Effectively are we utilizing our hardware?

° Example: memory is used twice, at different times• Ave mem access per inst = 1 + Flw + Fsw ~ 1.3

• if CPI is 4.8, imem utilization = 1/4.8, dmem =0.3/4.8

° We could reduce HW without hurting performance• extra control

IR <- Mem[PC]

A <- R[rs]; B<– R[rt]

S <– A + B

R[rd] <– S;PC <– PC+4;

S <– A + SX

M <– Mem[S]

R[rd] <– M;PC <– PC+4;

S <– A or ZX

R[rt] <– S;PC <– PC+4;

S <– A + SX

Mem[S] <- B

PC <– PC+4; PC < PC+4; PC < PC+SX;

Page 21: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.21

“Princeton” Organization

° Single memory for instruction and data access • memory utilization -> 1.3/4.8

° Sometimes, muxes replaced with tri-state buses• Difference often depends on whether buses are internal to chip

(muxes) or external (tri-state)

° In this case our state diagram does not change• several additional control signals

• must ensure each bus is only driven by one source on each cycle

RegFile

A

B

A-BusB Bus

IR S

W-Bus

PC

nextPC ZX SX

Mem

Page 22: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.22

Today: Alternative datapath (book)

° Miminizes Hardware: 1 memory, 1 adder

IdealMemoryWrAdrDin

RAdr

32

32

32Dout

MemWr

32

AL

U

3232

ALUOp

ALUControl

32

IRWr

Instru

ction R

eg

32

Reg File

Ra

Rw

busW

Rb5

5

32busA

32busB

RegWr

Rs

Rt

Mu

x

0

1

Rt

Rd

PCWr

ALUSelA

Mux 01

RegDst

Mu

x

0

1

32

PC

MemtoReg

Extend

ExtOp

Mu

x

0

132

0

1

23

4

16Imm 32

<< 2

ALUSelB

Mu

x1

0

32

Zero

ZeroPCWrCond PCSrc

32

IorD

Mem

Data R

eg

AL

U O

ut

B

A

Page 23: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.23

New Finite State Machine (FSM) Spec

IR <= MEM[PC]PC <= PC + 4

R-type

ALUout <= A fun B

R[rd] <= ALUout

ALUout <= A or ZX

R[rt] <= ALUout

ORi

ALUout <= A + SX

R[rt] <= M

M <= MEM[ALUout]

LW

ALUout <= A + SX

MEM[ALUout] <= B

SW

“instruction fetch”

“decode”

Exe

cute

Mem

ory

Writ

e-ba

ck

0000

0001

0100

0101

0110

0111

1000

1001

1010

1011

1100

BEQ

0010

0011

If A = B then PC <= ALUout

ALUout <= PC +SX

Q: How improveto do something instate 0001?

Page 24: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.24

Finite State Machine (FSM) Spec

IR <= MEM[PC]PC <= PC + 4

R-type

ALUout <= A fun B

R[rd] <= ALUout

ALUout <= A or ZX

R[rt] <= ALUout

ORi

ALUout <= A + SX

R[rt] <= M

M <= MEM[ALUout]

LW

ALUout <= A + SX

MEM[ALUout] <= B

SW

“instruction fetch”

“decode”

0000

0001

0100

0101

0110

0111

1000

1001

1010

1011

1100

BEQ

0010

If A = B then PC <= ALUout

ALUout <= PC +SX

Exe

cute

Mem

ory

Writ

e-ba

ck

Page 25: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.25

Designing a Microinstruction Set

1) Start with list of control signals

2) Group signals together that make sense (vs. random): called “fields”

3) Place fields in some logical order (e.g., ALU operation & ALU operands first and microinstruction sequencing last)

4) Create a symbolic legend for the microinstruction format, showing name of field values and how they set the control signals

• Use computers to design computers

5) To minimize the width, encode operations that will never be used at the same time

Page 26: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.26

1&2) Start with list of control signals, grouped into fields

Signal name Effect when deasserted Effect when assertedALUSelA 1st ALU operand = PC 1st ALU operand = Reg[rs]RegWrite None Reg. is written MemtoReg Reg. write data input = ALU Reg. write data input = memory RegDst Reg. dest. no. = rt Reg. dest. no. = rdMemRead None Memory at address is read,

MDR <= Mem[addr]MemWrite None Memory at address is written IorD Memory address = PC Memory address = SIRWrite None IR <= MemoryPCWrite None PC <= PCSourcePCWriteCond None IF ALUzero then PC <= PCSourcePCSource PCSource = ALU PCSource = ALUoutExtOp Zero Extended Sign Extended

Sin

gle

Bit

Con

trol

Signal name Value Effect ALUOp 00 ALU adds 01 ALU subtracts 10 ALU does function code

11 ALU does logical OR ALUSelB 00 2nd ALU input = 4 01 2nd ALU input = Reg[rt] 10 2nd ALU input = extended,shift left 2 11 2nd ALU input = extended

Mu

ltip

le B

it C

ontr

ol

Page 27: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.27

Start with list of control signals, cont’d

° For next state function (next microinstruction address), use Sequencer-based control unit from last lecture

• Called “microPC” or “µPC” vs. state register

Signal Value Effect Sequen 00 Next µaddress = 0 -cing 01 Next µaddress = dispatch ROM

10 Next µaddress = µaddress + 1

° Could even include “branch” option which changes microPC by adding offset when certain control signals are true.

Opcode

microPC

1

µAddressSelectLogic

Adder

ROM

Mux

0012

Page 28: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.28

3) Microinstruction Format: unencoded vs. encoded fields

Field Name Width Control Signals Set

wide narrow

ALU Control 4 2 ALUOp

SRC1 2 1 ALUSelA

SRC2 5 3 ALUSelB, ExtOp

ALU Destination 3 2 RegWrite, MemtoReg, RegDst

Memory 3 2 MemRead, MemWrite, IorD

Memory Register 1 1 IRWrite

PCWrite Control 3 2 PCWrite, PCWriteCond, PCSource

Sequencing 3 2 AddrCtl

Total width 24 15 bits

Page 29: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.29

4) Legend of Fields and Symbolic Names

Field Name Values for Field Function of Field with Specific ValueALU Add ALU adds

Subt. ALU subtractsFunc code ALU does function codeOr ALU does logical OR

SRC1 PC 1st ALU input = PCrs 1st ALU input = Reg[rs]

SRC2 4 2nd ALU input = 4Extend 2nd ALU input = sign ext. IR[15-0]Extend0 2nd ALU input = zero ext. IR[15-0] Extshft 2nd ALU input = sign ex., sl IR[15-0]rt 2nd ALU input = Reg[rt]

destination rd ALU Reg[rd] = ALUout rt ALU Reg[rt] = ALUout

rt Mem Reg[rt] = Mem Memory Read PC Read memory using PC

Read ALU Read memory using ALUout for addrWrite ALU Write memory using ALUout for addr

Memory register IR IR = MemPC write ALU PC = ALU

ALUoutCond IF ALU Zero then PC = ALUoutSequencing Seq Go to sequential µinstruction

Fetch Go to the first microinstructionDispatch Dispatch using ROM.

Page 30: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.30

Quick check: what do these fieldnames mean?

Code Name RegWrite MemToRegRegDest

00 --- 0 X X01 rd ALU 1 0 110 rt ALU 1 0 011 rt MEM 1 1 0

Code Name ALUSelB ExtOp000 --- X X001 4 00 X010 rt 01 X011 ExtShft 10 1100 Extend 11 1111 Extend0 11 0

Destination:

SRC2:

Page 31: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.31

Alternative datapath (book): Multiple Cycle Datapath

° Miminizes Hardware: 1 memory, 1 adder

IdealMemoryWrAdrDin

RAdr

32

32

32Dout

MemWr

32

AL

U

3232

ALUOp

ALUControl

32

IRWr

Instru

ction R

eg

32

Reg File

Ra

Rw

busW

Rb5

5

32busA

32busB

RegWr

Rs

Rt

Mu

x

0

1

Rt

Rd

PCWr

ALUSelA

Mux 01

RegDst

Mu

x

0

1

32

PC

MemtoReg

Extend

ExtOp

Mu

x

0

132

0

1

23

4

16Imm 32

<< 2

ALUSelB

Mu

x1

0

32

Zero

ZeroPCWrCond PCSrc

32

IorD

Mem

Data R

eg

AL

U O

ut

B

A

Page 32: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.32

Microprogram it yourself!

Label ALU SRC1 SRC2 ALU Dest. Memory Mem. Reg. PC Write Sequencing

Fetch: Add PC 4 Read PC IR ALU Seq

Page 33: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.33

Microprogram it yourself!

Label ALU SRC1 SRC2 Dest. Memory Mem. Reg. PC Write SequencingFetch: Add PC 4 Read PC IR ALU Seq

Add PC Extshft Dispatch

Rtype: Func rs rt Seqrd ALU Fetch

Ori: Or rs Extend0 Seqrt ALU Fetch

Lw: Add rs Extend SeqRead ALU Seq

rt MEM Fetch

Sw: Add rs Extend SeqWrite ALU Fetch

Beq: Subt. rs rt ALUoutCond. Fetch

Page 34: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.34

Legacy Software and Microprogramming

° IBM bet company on 360 Instruction Set Architecture (ISA): single instruction set for many classes of machines

• (8-bit to 64-bit)

° Stewart Tucker stuck with job of what to do about software compatibility

° If microprogramming could easily do same instruction set on many different microarchitectures, then why couldn’t multiple microprograms do multiple instruction sets on the same microarchitecture?

° Coined term “emulation”: instruction set interpreter in microcode for non-native instruction set

° Very successful: in early years of IBM 360 it was hard to know whether old instruction set or new instruction set was more frequently used

Page 35: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.35

Microprogramming Pros and Cons° Ease of design

° Flexibility• Easy to adapt to changes in organization, timing, technology

• Can make changes late in design cycle, or even in the field

° Can implement very powerful instruction sets (just more control memory)

° Generality• Can implement multiple instruction sets on same machine.

• Can tailor instruction set to application.

° Compatibility• Many organizations, same instruction set

° Costly to implement

° Slow

Page 36: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.36

An Alternative MultiCycle DataPath

° In each clock cycle, each Bus can be used to transfer from one source

° µ-instruction can simply contain B-Bus and W-Dst fields

RegFile

A

B

A-Bus

B Bus

IR S mem

W-Bus

PC

instmem

nextPC ZX SX

Page 37: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.37

What about a 2-Bus Microarchitecture (datapath)?

RegFile

A

B

A-BusB Bus

IR SPC

nextPC ZXSX

Mem

RegFile

A

BIR SP

CnextPC ZXSX

Mem

Instruction Fetch

Decode / Operand Fetch

M

M

Page 38: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.38

Load

° What about 1 bus ? 1 adder? 1 Register port?

RegFile

A

BIR SP

CnextPC ZXSX

Mem

RegFile

A

BIR SP

CnextPC ZXSX

Mem

RegFile

A

BIR SP

CnextPC ZXSX

Mem

Execute

addr

M

M

M

Mem

Write-back

Page 39: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.39

Summary

° Specialize state-diagrams easily captured by microsequencer

• simple increment & “branch” fields

• datapath control fields

° Most microprogramming-based controllers vary between:

• horizontal organization (1 control bit per control point)

• vertical organization (fields encoded in the control memory and must be decoded to control something)

° Steps:

• identify control signals, group them, develop “mini language”, then microprogram

° Control design reduces to Microprogramming

• Arbitrarily complicated instructions possible

Page 40: CS152 / Kubiatowicz Lec10.1 10/03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October

10/03/01 ©UCB Fall 2001 CS152 / Kubiatowicz

Lec10.40

Summary: Microprogramming one inspiration for RISC

° If simple instruction could execute at very high clock rate…

° If you could even write compilers to produce microinstructions…

° If most programs use simple instructions and addressing modes…

° If microcode is kept in RAM instead of ROM so as to fix bugs …

° If same memory used for control memory could be used instead as cache for “macroinstructions”…

° Then why not skip instruction interpretation by a microprogram and simply compile directly into lowest language of machine?