Docsity

Microprogramming - Computer Architecture and Assembly Language | 332 331, Study notes of Electrical and Electronics Engineering

Partial preview of the text

Download Microprogramming - Computer Architecture and Assembly Language | 332 331 and more Study notes Electrical and Electronics Engineering in PDF only on Docsity!

Fall 2006

Computer Architecture and Assembly Language

Fall 2006

Week 11: Microprogramming

[Adapted from Dave Patterson’s UCB CS152 slides and

Mary Jane Irwin’s PSU CSE331 slides]

Fall 2006

Simplifying Control Design ‰

For an implementation of the full MIPS ISA

z

instructions can take from 1 clock cycle to 20 clockcycles

z

resulting in finite state machines with hundreds tothousands of states with even

more

arcs (state

sequences)

Graphical representations become impossiblycomplex

Instead, represent the set of control signals thatare asserted during a state as a low-level control“instruction” to be executed by the datapath

microinstructions

“Executing” the microinstruction is equivalent toasserting the control signals specified by themicroinstruction

Fall 2006

Defining a Microinstruction Format ‰

Format – the fields of the microinstruction and thecontrol signals that are affected by each field

z

control signals specified by a field usually have functionsthat are related

z

format is chosen to simplify the representation and tomake it difficult to write inconsistent microinstructions

i.e., that allow a given control signal be set to two differentvalues

Make each field of the microinstructionresponsible for specifying a nonoverlapping set ofcontrol signals

z

signals that are never asserted simultaneously may sharethe same field

z

seven fields for our simple machine

ALU control; SRC1; SRC2; Register control; Memory;PCWrite control; Sequencing

Fall 2006

Review: Multicycle Data and Control Path

Address

Read Data(Instr. or Data)

Memory

PC

Read Addr 1Read Addr 2Write Addr Write Data

Register

File

Read Data 1

Read Data 2

ALU

Write Data

IR MDR

A B

ALUout

Sign Extend

Shiftleft 2

ALU Shiftleft 2 control

ALUOp

Control

FSM

IRWrite

MemtoReg

MemWrite

MemRead

IorD

PCWrite

PCWriteCond

RegDst

RegWrite

ALUSrcA

ALUSrcB

zero

PCSource

1

1 1

1

1

0 1

0

0

0 0

0

2

2

3

4

Instr[5-0]

Instr[25-0]

PC[31-28]

Instr[15-0]

Instr[31-26]

32

28

Fall 2006

Our Microinstruction Format

Field

Value

Signal setting

Comments

Read

Read RegFile using rs and rt fields of IR asread addr’s; p

u

t data into A and B

Write ALU

RegWrite,RegDst = 1,MemtoReg = 0

Write RegFile using rd field of IR as write addrand ALUOut as write data

Write MDR

RegWrite,RegDst = 0,MemtoReg = 1

Write RegFile using rt field of IR as write addrand MDR as write data

Registercontrol

Add

ALUOp = 00

Cause ALU to add

Subt

ALUOp = 01

Cause ALU to subtract (compare op for beq)

Func code

ALUOp = 10

Use IR function code to determine ALU control

PC

ALUSrcA = 0

Use PC as top ALU input

A

ALUSrcA = 1

Use reg A as top ALU input

B

ALUSrcB = 00

Use reg B as bottom ALU input

4

ALUSrcB = 01

Use 4 as bottom ALU input

Extend

ALUSrcB = 10

Use sign extension output as bottom ALU input

Extshft

ALUSrcB = 11

Use shift-by-two output as bottom ALU input

ALUcontrol SRC1 SRC

Fall 2006

Our Microinstruction Format, con’t

Field

Value

Signal setting

Comments

Seq

AddrCtl = 11

Choose next microinstruction sequentially

Fetch

AddrCtl = 00

Jump to the first microinstruction (i.e., Fetch)to begin a new instruction

Dispatch 1

AddrCtl = 01

Branch using PLA_

Sequen-cing

Dispatch 2

AddrCtl = 10

Branch using PLA_

Read PC

MemRead,

IorD

= 0,IRWrite

Read memory using PC as addr; write resultinto IR (and MDR)

Read ALU

MemRead,

lorD

= 1

Read memory using ALUOut as addr; writeresults into MDR

Write ALU

MemWrite,

IorD

= 1

Write memory using ALUOut as addr and Bas write data

ALU

PCSource = 00PCWrite

Write PC with output of ALU

ALUOut-cond

PCSource = 01,PCWriteCond

If Zero output of ALU is true, write PC withthe contents of ALUOut

PC writecontrol

Jumpaddress

PCSource = 10,PCWrite

Write PC with IR jump address after shift-by-two

Memory

Fall 2006

Creating the Microprogram

Fetch microinstruction

Label(Addr)

ALUcontrol

SRC

SRC

Regcontrol

Memory

PCWritecontrol

Seq’ing

Fetch (0)

Add

PC

Read PC

ALU

Seq

compute PC + 4

fetch instr

into IR

write ALUoutput into

PC

go to

μ

instr 1

Label field represents the state (address) of themicroinstruction

Fetch microinstruction assigned state (address) 0

Fall 2006

Creating the Microprogram, con’t

Decode microinstruction

Label(Addr)

ALUcontrol

SRC
SRC

Regcontrol

Memory

PCWrite control

Seq’ing

Decode (1)

Decode microinstruction assigned state (address) 1

Fall 2006

Creating the Microprogram, con’t

Memory-reference (lw & sw) microinstructions

Label(Addr)

ALUcontrol

SRC
SRC

Regcontrol

Memory

PCWrite control

Seq’ing

Maddr Memlw Memwb Memsw

Assigned states (addresses) 2, 3, 4, and 5

Fall 2006

Creating the Microprogram, con’t

Memory-reference (lw & sw) microinstructions

Label(Addr)

ALUcontrol

SRC

SRC

Reg control

Memory

PCWritecontrol

Seq’ing

Memlw (3)

Read

ALU

Seq

Memwb (4)

Write MDR

Fetch

Memsw (5)

Write ALU

Fetch

Maddr (2)

Add

A

Extend

Disp

2

compute memory

address (RegFile(rs) +sign_ext(IR[15-0])) and

store it in ALUOut

on lw – first read memory at ALUOutand store output in

on sw – write Binto memory at

address in

ALUOut

MDR; then write MDR

into RegFile at rt

Assigned states (addresses) 2, 3, 4, and 5

Fall 2006

Creating the Microprogram, con’t

R-type instruction microinstructions

Label(Addr)

ALUcontrol

SRC

SRC

Regcontrol

Memory

PCWritecontrol

Seq’ing

Rwb (7)

WriteALU

Fetch

Rexec (6)

Funccode

A
B

Seq

perform the ALU

operation specified inthe instr. function field using contents of A and

B and store the result

in ALUOut

when done, go

to fetch cycle

for next instruction

write ALUOut in the

RegFile at rd

Assigned states (addresses) 6 and 7

Fall 2006

Creating the Microprogram, con’t

Branch (beq) and jump microinstructions

Label(Addr)

ALUcontrol

SRC

SRC

Regcontrol

Memory

PCWritecontrol

Seq’ing

Beq Jump

Assigned states (addresses) 8 and 9

Fall 2006

The Entire Control Microprogram Addr

ALUcontrol

SRC

SRC

Regcontrol

Memory

PCWritecontrol

Seq’ing

Add

PC

Ext shft

Read

Disp 1

Jumpaddress

Fetch

Add

A

Extend

Disp 2

Read ALU

Seq

WriteMDR

Fetch

WriteALU

Fetch

F

unc code

A
B

Seq

WriteALU

Fetch

Subt

A
B

ALUOut-cond

Fetch

Add

PC

Read PC

ALU

Seq

Fall 2006

Microprogram to Microcode ‰

A microassember is used to convert the mnemonicmicroprogram into the actual control signals (0’sand 1’) or microcode, for example

Label(Addr)

ALUcontrol

SRC

SRC

Regcontrol

Memory

PCWritecontrol

Seq’ing

Fetch (0)

Add

PC

Read PC

ALU

Seq

Label(Addr)

ALUcontrol

SRC

SRC

Regcontrol

Memory

PCWritecontrol

Seq’ing

ALUOp

ALUSrcA

ALUSrcB

RegWrite,RegDst,MemtoReg

MemRead,MemWrite,IRWrite, IorD

PCSource,PCWrite,PCWriteCond

AddrCtl

0,X,X
00, 1, X