You are on page 1of 29

CSEE 3827: Fundamentals of Computer Systems, Spring 2011 9.

Single Cycle MIPS Processor

Web: http://www.cs.columbia.edu/~martha/courses/3827/sp11/

Prof. Martha Kim (martha@cs.columbia.edu)

Outline (H&H 7.2-7.3)


Single Cycle MIPS Processor Datapath (functional blocks) Control (control signals) Single Cycle Performance

Microarchitecture
Microarchitecture: an implementation of a particular architecture Multiple implementations for a single architecture Single-cycle: Each instruction executes in a single cycle Multi-cycle: Each instruction is broken up into a series of shorter steps Pipelined: Each instruction is broken up into a series of steps; Multiple instructions execute at once

Copyright 2007 Elsevier

Our MIPS Processor


We consider a subset of MIPS instructions: R-type instructions: and, or, add, sub, slt Memory instructions: lw, sw Branch instructions: beq Later consider adding addi and j

Copyright 2007 Elsevier

Instruction Execution
PC instruction memory, fetch instruction Register numbers register le, read registers Depending on instruction class: Use ALU to calculate: Arithmetic or logical result Memory address for load/store Branch target address Access data for load/store PC target address or PC + 4

MIPS State Elements


Architectural state determines everything about a processor: PC, 32 registers, memory

Copyright 2007 Elsevier

Single-Cycle Datapath: lw fetch


First consider executing lw STEP 1: Fetch instruction

Copyright 2007 Elsevier

Single-Cycle Datapath: lw register read


STEP 2: Read source operands from register le

Copyright 2007 Elsevier

Single-Cycle Datapath: lw immediate


STEP 3: Sign-extend the immediate

Copyright 2007 Elsevier

Single-Cycle Datapath: lw address


STEP 4: Compute the memory address

Copyright 2007 Elsevier

10

Single-Cycle Datapath: lw memory read


STEP 5: Read data from memory and write it back to register le

Copyright 2007 Elsevier

11

Single-Cycle Datapath: lw PC increment


STEP 6: Determine the address of the next instruction

Copyright 2007 Elsevier

12

Single-Cycle Datapath: sw
Write data in rt to memory

Copyright 2007 Elsevier

13

Single-Cycle Datapath: R-type instructions


Read from rs and rt Write ALUResult to register le Write to rd (instead of rt)

Copyright 2007 Elsevier

14

Single-Cycle Datapath: beq


Determine whether values in rs and rt are equal Calculate branch target address: BTA = (sign-extended immediate)x4 + (PC+4)

Copyright 2007 Elsevier

15

Complete Single-Cycle Processor

Copyright 2007 Elsevier

16

Control Unit

Copyright 2007 Elsevier

17

ALU Interface and Implementation


F2:0
0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1

Function
A&B A|B A+B
not used

A & ~B A | ~B A-B SLT

Copyright 2007 Elsevier

18

Control Unit: ALU Decoder


ALUOp1:0 0 0 1 1 0 1 0 1

Meaning Add Subtract Look at Funct


not used

ALUOp1:0 0 0 x 1 1 x 1 x 1 x 1 x 1 x
Copyright 2007 Elsevier

Funct x x 100000 (add) 100010 (sub) 100100 (and) 100101 (or) 101010 (slt)

ALUControl2:0 010 (Add) 110 (Subtract) 010 (Add) 110 (Subtract) 000 (And) 001 (Or) 111 (SLT)
19

Control Unit: Main Decoder


Instruction R-type Op5:0 RegWrite RegDst AluSrc Branch MemWrite MemToReg ALUOp1:0

000000 100011 101011 000100

lw sw beq

Copyright 2007 Elsevier

20

Single-Cycle Datapath Example: or

Copyright 2007 Elsevier

21

Extended Functionality: addi


No change to datapath

Instruction R-type

Op5:0

RegWrite RegDst AluSrc Branch MemWrite MemToReg ALUOp1:0

lw sw beq addi

000000 100011 101011 000100 001000

1 1 0 0 1

1 0 x x 0

0 1 1 0 1

0 0 0 1 0

0 0 1 0 0

0 1 x x 0

1 0 0 0 0

0 0 0 1 0
22

Copyright 2007 Elsevier

Extended Functionality: j

Copyright 2007 Elsevier

23

Control Unit: Main Decoder with j


Instruction Op
5:0

RegWrite

RegDst

AluSrc

Branch

MemWrite

MemToReg

ALUOp

1:0

Jump

R-type

000000 100011 101011 000100 001000 000010

1 1 0 0 1 0

1 0 x x 0 x

0 1 1 0 1 x

0 0 0 1 0 x

0 0 1 0 0 0

0 1 x x 0 x

1 0 0 0 0 0 0 1 0 0 x x

0 0 0 0 0 1

lw sw beq addi j

Copyright 2007 Elsevier

24

Review: Processor Performance

Seconds Instructions Clock cycles Seconds = x x Program Program Instruction Clock cycle

25

Single-Cycle Performance
Seconds/cycle (or TC) is limited by the critical path (lw)

Copyright 2007 Elsevier

26

Single-Cycle Performance
Single-cycle critical path:

Tc = tpcq_PC + tmem + max(tRFread, tsext + tmux) + tALU + tmem + tmux + tRFsetup


In most implementations, limiting paths are: memory, ALU, register le

Tc = tpcq_PC + 2tmem + tRFread + tmux + tALU + tRFsetup

Copyright 2007 Elsevier

27

Single-Cycle Performance Example


Element
Register clock-to-Q Register setup

Parameter

Delay (ps) 30 20 25 200 250 150 20

Multiplexer ALU Memory read Register le read Register le setup

tpcq_PC tsetup tmux tALU tmem tRFread tRFsetup

Tc = tpcq_PC + 2tmem + tRFread + tmux + tALU + tRFsetup = [30 + 2(250) + 150 + 25 + 200 + 20] ps = 925 ps
Copyright 2007 Elsevier

28

Single-Cycle Performance Example


For a program with 100 billion instructions executing on a single-cycle MIPS processor, Execution Time = # instructions x CPI x TC = (100 109)(1)(925 10-12 s) = 92.5 seconds

Copyright 2007 Elsevier

29

You might also like