Docsity

Implementing MIPS: A Single-Cycle Datapath, Slides of Computer Architecture and Organization

Partial preview of the text

Download Implementing MIPS: A Single-Cycle Datapath and more Slides Computer Architecture and Organization in PDF only on Docsity!

CSE 311

Computer Organization

Mostafa I. Soliman

Professor of Computer Engineering

CSE Department

[email protected]

[email protected]

Lecture 9

Implementing MIPS

Lecture 9

Implementing MIPS

Implementing MIPS

**- Reviewing MIPS Instruction Set

  • Implementing MIPS: Fetch/Execute Cycle
  • Processor Implementation Styles
  • Register File
  • Single-cycle Implementation of MIPS** - Datapath: Instruction Store/Fetch & PC Increment - Datapath: R-Type Instruction - Datapath: Load/Store Instruction **- Datapath: Branch Instruction
  • Put All Together:**

MIPS Datapath

Simplicity is an exact

medium between too little

and too much.

Sir Joshua Reynolds ope.

  • High-level abstract view of fetch/execute implementation
    • use the program counter (PC) to read instruction

address

  • (^) fetch the instruction from memory and increment PC
  • (^) use fields of the instruction to select registers to read
  • (^) execute depending on the instruction
  • (^) repeat…

Implementing MIPS:

the Fetch/Execute Cycle

Registers

Register

Data

Register

Data

memory

Address

Data

Register

PC Instruction ALU

Instruction

memory

Address

Overview: Processor

Implementation Styles

  • (^) Single Cycle
    • (^) perform each instruction in 1 clock cycle
    • (^) clock cycle must be long enough for slowest instruction
    • disadvantage: only as fast as slowest instruction
  • (^) Multi-Cycle
    • (^) break fetch/execute cycle into multiple steps
    • (^) perform 1 step in each clock cycle
    • advantage: each instruction uses only as many cycles as it

needs

  • (^) Pipelined
    • (^) execute each instruction in multiple steps
    • (^) perform 1 step / instruction in each clock cycle
    • (^) process multiple instructions in parallel – assembly line
  • (^) Registers are implemented with arrays of D-flipflops

State Elements on the Datapath:

Register File

Register file with two read ports and one write

port

Read register

number 1 Read

data 1

Read

data 2

Read register

number 2

Register file

Write

register

Write

data Write

Clock

bits 5

bits 5

bits 5

bits 32

bits 32

bits 32

Control signal

  • (^) Port implementation:
n-to- 1
decoder
Register 0
Register 1
Register n – 1
C
C
D
D
Register n
C
C
D
D
Register number
Write
Register data
n – 1
n
M
u
x
Register 0
Register 1
Register n – 1
Register n
M
u
x
Read data 1
Read data 2
Read register
number 1
Read register
number 2

Read ports are implemented

with a pair of multiplexors

5-bit multiplexors for 32 registers

Write port is implemented using

a decoder

5-to-32 decoder for 32 registers

Clock is relevant to write as

register state may change

only at clock edge

Clock Clock

State Elements on the Datapath:

Register File

Datapath: Instruction Store/Fetch &

PC Increment

PC

Instruction

memory

Instruction

address

Instruction

a. Instruction memory b. Program counter

Add Sum

c. Adder

PC
Instruction
memory
Read
address
Instruction
Add

Three elements used to store

and fetch instructions and

increment the PC

Datapath

Animating the Datapath

Instruction <- MEM[PC]

PC <- PC + 4

RD

Memory

ADDR

PC

Instruction

ADD

Animating the Datapath

add rd, rs, rt

; R[rd] <- R[rs] + R[rt]

RD

RD

RN1 RN2 WN

WD

RegWrite

Register File

op rs rt rd shamt funct

Operation

ALU

Zero

Instruction

Datapath:

Load/Store Instruction

16 32 Sign

extend

b. Sign-extension unit

MemRead

MemWrite

Data

memory

Write

data

Read

data

a. Data memory unit

Address

Instruction

16 32

Registers

Write

register

Read

data 1

Read

data 2

Read

register 1

Read

register 2

Data

memory

Write

data

Read

data

Write

data

Sign

extend

ALU

result

Zero

ALU

Address

MemRead

MemWrite

RegWrite

ALU operation 3

Two additional elements used

To implement load/stores

Datapath

Animating the Datapath

op rs rt offset/immediate

RD

RD

RN1 RN2 WN

WD

RegWrite

Register File

Operation

ALU

3 E X T N D

Zero

WD RD

MemRead

Memory

ADDR

MemWrite

sw rt, offset(rs)

MEM[R[rs] + sign_extend(offset)] <- R[rt]

Datapath: Branch Instruction

Sign
extend
ALU Zero
Sum
Shift
left 2
To branch
control logic
Branch target
PC + 4 from instruction datapath
Instruction
Add
Registers
Write
register
Read
data 1
Read
data 2
Read
register 1
Read
register 2
Write
data
RegWrite
ALU operation

Datapath

: No shift hardware required

simply connect wires from

input to output, each shifted

left 2 bits

op rs rt offset

MIPS Datapath I: Single-Cycle

Input is either register (R-type) or sign-extended

lower half of instruction (load/store)

Combining the datapaths for R-type instructions

and load/stores using two multiplexors

Data is either

from ALU (R-type)

or memory (load)

Animating the Datapath:

R-type Instruction

add rd,rs,rt

RD

RD

RN1 RN2 WN

WD

RegWrite

Register File

Operation

ALU

3 E X T N D

Zero

RD

WD

MemRead

Data

Memory

ADDR

MemWrite

Instruction

M U X M U X

ALUSrc

MemtoReg