Docsity

Multiple Cycle Processor - Introduction to Computer Architecture | ECE 154, Study notes of Electrical and Electronics Engineering

Toggle sidebar
bg1
ECE154
Computer Architecture
Lecture 10
Multiple Cycle Processor II
October 31, 2006
Ryan Kastner
Electrical and Computer Engineering
University of California, Santa Barbara
Review: Partitioning the CPI=1 Datapath
Add registers between smallest steps
1. Place so that balances length of clock cycle
•Logic delays about the same between registers
2. Place to save information needed later in instruction
execution
PC
Next PC
Operand
Fetch
Exec
Reg.
File
Mem
Access
Data
Mem
Instruction
Fetch
Result Store
ALUctr
RegDst
ALUSrc
ExtOp
MemWr
nPC_sel
RegWr
MemWr
MemRd
Equal
Review: Multicycle Datapath
Critical Path ?
PC
Next PC
Operand
Fetch
Instruction
Fetch
nPC_sel
IR
Reg
File
Ext
ALU
Reg.
File
Mem
Access
Data
Mem
Result Store
RegDst
RegWr
MemWr
MemRd
S
M
MemToReg
Equal
ALUctr
ALUSrc
ExtOp
A
B
E
Recall: Step-by-step Processor Design
Step 1: ISA => Logical Register Transfers
Step 2: Components of the Datapath
Step 3: RTL + Components => Datapath
Step 4: Datapath + Logical RTs => Physical RTs
Step 5: Physical RTs => Control
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Multiple Cycle Processor - Introduction to Computer Architecture | ECE 154 and more Study notes Electrical and Electronics Engineering in PDF only on Docsity!

ECE

Computer Architecture

Lecture 10

Multiple Cycle Processor II

October 31, 2006

Ryan Kastner

Electrical and Computer Engineering

University of California, Santa Barbara

Review: Partitioning the CPI=1 Datapath

™ Add registers between smallest steps

1. Place so that balances length of clock cycle

• Logic delays about the same between registers

2. Place to save information needed later in instruction

execution

PC

Next PC

Operand

Fetch

Exec Reg.File MemAccess

DataMem

Instruction

Fetch

Result Store

ALUctr

RegDst nPC_sel ExtOpALUSrc MemWr MemRdMemWr RegWr

Equal

Review: Multicycle Datapath

™ Critical Path?

PC

Next PC

Operand

Fetch

Instruction

Fetch

nPC_sel

IR

Reg File ExtALU Reg.File

MemAccess

DataMem

Result Store

RegDstRegWr MemRdMemWr

S

M

MemToReg

Equal

ExtOpALUSrcALUctr

A

B

E

Recall: Step-by-step Processor Design

Step 1: ISA => Logical Register Transfers

Step 2: Components of the Datapath

Step 3: RTL + Components => Datapath

Step 4: Datapath + Logical RTs => Physical RTs

Step 5: Physical RTs => Control

Step 4 : Store

™ Logical Register Transfer

™ Physical Register Transfers

inst Logical Register Transfers SW MEM[R[rs] + SExt(Im16)] <= R[rt]; PC <= PC + 4

inst Physical Register Transfers IR <= MEM[pc] SW A<= R[rs]; B <= R[rt] S <= A + SExt(Im16); MEM[S] <= B PC <= PC + 4

Exec

Reg.File

Mem Access

DataMem

S

M

RegFile PC

Next PC

IR

Inst. Mem

A

B

E

Time

Step 4 : Branch

™ Logical Register Transfer

™ Physical Register Transfers

inst Logical Register Transfers BEQ if R[rs] == R[rt] then PC <= PC + 4+{SExt(Im16), 2’b00} else PC <= PC + 4

Exec

Reg.File

Mem Access

DataMem

S

M

RegFile PC

Next PC

IR

Inst. Mem

inst Physical Register Transfers IR <= MEM[pc] BEQ E<= (R[rs] = R[rt]) if (!E) PC <= PC + 4; else PC <=PC+4+{SExt(Im16),2’b0}

A

B

E

Time

Our Control Model

™ State specifies control points for Register Transfer

™ Transfer occurs upon exiting state (same clock edge)

Control State

Next State Logic

Output Logic

inputs (conditions)

outputs (control points)

State X

Register Transfer Control Points

Depends on Input

Step 4 ⇒ Control Spec for multicycle proc

IR <= MEM[PC]

R-type

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

S <= A fun B

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

S <= A | ZX

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

ORi

S <= A + SX

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

M <= MEM[S]

LW

S <= A + SX

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

BEQ

PC <= Next(PC,Equal)

SW

“instruction fetch”

“decode / operand fetch”

Execute

Memory

Write-back

“Finite State Diagram”

Detailed Control Specs

0001 BEQ x 0011 1 1 1

0001 R-type x 0100 1 1 1

0001 ORI x 0110 1 1 1

0001 LW x 1000 1 1 1

0001 SW x 1011 1 1 1

0011 xxxxxx 0 0000 1 0 x 0 x

0011 xxxxxx 1 0000 1 1 x 0 x

0100 xxxxxx x 0101 0 1 fun 1

0101 xxxxxx x 0000 1 0 0 1 1

0110 xxxxxx x 0111 0 0 or 1

0111 xxxxxx x 0000 1 0 0 1 0

1000 xxxxxx x 1001 1 0 add 1

1001 xxxxxx x 1010 1 0 1

1010 xxxxxx x 0000 1 0 1 1 0

1011 xxxxxx x 1100 1 0 add 1

1100 xxxxxx x 0000 1 0 0 1 0

State Op field Eq Next IR PC Ops Exec Mem Write-Back en sel A B E Ex Sr ALU S R W M M-R Wr Dst

R:

ORi:

LW:

SW:

-all same in Moore machine

BEQ:

Instruction Set and Control Options

™ 7-instruction subset MIPS easy to implement

FSM by hand

™ Full MIPS instruction set > 100 instructions,

inclucing *, /,

Floating Point +, -, *, /

™ Need to use Verilog, CAD tools

™ Full IA-32 instruction set?

™ > 500 instructions, including copy and edit, save/

restore state, setup for key-like memory protection,

Announcements

™Homework #4 due Thursday

™Quiz

™November 7

th

in class

™Old quizzes at: http://hkn.ece.ucsb.edu/exams.php

™Quiz

™Moved to November 30 in class

™Schedule rearranged (see webpage)

Controller Design

™ The state diagrams that arise define the controller for an instruction

set processor are highly structured

™ Use this structure to construct a simple “microsequencer”

™ Control reduces to programming this very simple device

⇒ microprogramming

op-code

Map ROM

Micro-PC

Z I L

datapath control

taken

Adding the Dispatch ROM

™Sequencer-based control

™ 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

μAddress

Select

Logic

Adder

ROM

Mux

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

sequencer control

micro-PC

μ-sequencer: fetch,dispatch, sequential

Dispatch ROM

Opcode

Inputs

Microprogramming

μ-Code ROM

To DataPath

Decode Decode

datapath control

microinstruction (μ)

Microprogramming

™ Microprogramming is a convenient method for

implementing structured control state diagrams:

™ Random logic replaced by microPC sequencer and ROM

™ Each line of ROM called a microinstruction :

contains sequencer control + values for control points

™ To reduce confusion, normal instruction

(e.g., MIPS addu ) called “macroinstruction”

™ limited state transitions:

branch to zero, next sequential,

branch to μinstruction address from dispatch ROM

™ Control design reduces to Microprogramming

™ Part of the design process is to develop a “language” that

describes control and is easy for humans to understand

“Macroinstruction” Interpretation

Main Memory

execution unit

control CPU memory

ADD

SUB

AND

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 is mapped into one of these

Legend of Fields and Symbolic Names

Field Name Values for Field Function of Field with Specific Value

ALU Add ALU adds

Subt. ALU subtracts

Func code ALU does function code

Or ALU does logical OR

SRC1 PC 1st ALU input = PC

rs 1st ALU input = Reg[rs]

SRC2 4 2nd ALU input = 4

Extend 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 addr

Write ALU Write memory using ALUout for addr

Memory register IR IR = Mem

PC write ALU PC = ALU

ALUoutCond IF ALU Zero then PC = ALUout

Sequencing Seq Go to sequential μinstruction

Fetch Go to the first microinstruction

Dispatch Dispatch using ROM.

Quick check: what do these fieldnames mean?

Code Name RegWrite MemToReg RegDest

00 --- 0 X X

01 rd ALU 1 0 1

10 rt ALU 1 0 0

11 rt MEM 1 1 0

Code Name ALUSelB ExtOp

000 --- X X

001 4 00 X

010 rt 01 X

011 ExtShft 10 1

100 Extend 11 1

111 Extend0 11 0

Destination :

SRC2:

Specific Sequencer from before

Sequencer-based control unit from last lecture

™ Called “microPC” or “μPC” vs. state register

Code Name Effect

00 fetch Next μaddress = 0

01 dispatch Next μaddress = dispatch ROM

10 seq Next μaddress = μaddress + 1

ROM:

Opcode

microPC

μAddress

Select

Logic

Adder

ROM

Mux

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

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

– Control unit in same chip as data path, so can’t replace ROM

– ROM not faster than RAM (so not much faster than 1st level

instruction cache), PLA smaller and therefore faster than ROM

– Simpler instruction sets popular now

– CAD tools + fast computers allows simulation => correct control

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

Thought: 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? (microprogramming is overkill when

ISA matches datapath 1-1)

Conclusion

™ Disadvantages of the Single Cycle Processor

™ Long cycle time

™ Cycle time is too long for all instructions except the Load

™ Multiple Cycle Processor:

™ Divide the instructions into smaller steps

™ Execute each step (instead of the entire instruction) in one cycle

™ Partition datapath into equal size chunks to minimize cycle

time

™ ~10 levels of logic between latches

™ Follow same 5-step method for designing “real” processor

Conclusion

™ Control is specified by finite state diagram

™ Specialize state-diagrams easily captured by microsequencer

™ simple increment & “branch” fields

™ datapath control fields

™ Control design reduces to Microprogramming

™ Control is more complicated with:

™ complex instruction sets

™ restricted datapaths (see the book)

™ Simple Instruction set and powerful datapath ⇒ simple

control

™ could try to reduce hardware (see the book)

™ rather go for speed => many instructions at once!