Docsity

Single-Cycle CPU Implementation: Design and Performance - Prof. Kirk Cameron, Study notes of Computer Architecture and Organization

Partial preview of the text

Download Single-Cycle CPU Implementation: Design and Performance - Prof. Kirk Cameron and more Study notes Computer Architecture and Organization in PDF only on Docsity!

Single clock implementation

• Execute all instructions in one clock cycle

• No data path resource can be used more than once

• Memory for instructions separate from data

• Anywhere we want to choose a signal from two paths we

use mux + selector

Combined R-type + Load/Store

ALUSrc: 1 bit selector of

a) data from rt (R-type)

b) sign extended immediate (Load/Store)

MemtoReg: 1 bit selector of

a) data found at calculated address in memory (Load)

b) ALU result from two register ALU operation

Adding branches

Shift

left 2

sum

M U X

ALU

PCSrc

ALU control

  • Our latest version of ALU needs 3-bits to control Mux’s
    • Binvert: 1-bit control to operate on B or B-inverse (sub)
    • Operation: 2-bit control to perform AND, OR, add, slt

ALU

a

b

carryout

zero

result

overflow

ALU operation

111 Set on less than

110 SUB

010 ADD

001 OR

000 AND

ALU operation Function

Combine Binvert and Operation into set of 3 control lines

What function should ALU perform?

  • Determined by instruction
  • Op-code + function code => ALUop
  • Observation: There are 3 possibilities => 2 bits
    • Load/store uses ALU to add (always)
    • BEQ uses ALU to subtract (always)
    • R-type uses ALU to perform 1 of 5 operations
  • Use the function-field and a 2-bit control field (ALUOp) as input to

produce 3-bit ALU (operation) control

Determining ALU control bits

I-type instructions

Based on op-code: generated by main control unit

Input signal to ALU

Shift left 2

ALU

sum

M U X

PCSrc

[25-21] rs

[20-16] rt

[15-11] rd

[15-0] addr

[5-0] funct

ALU control ALUOp

ALU Control Unit

Instruction bits

0 rs rt rd func

[31-26] [25-21] [20-16] [15-11] [5-0]

35 or 43 rs rd immediate

[31-26] [25-21] [20-16] [15-0]

4 rs rd immediate

[31-26] [25-21] [20-16] [15-0]

2 immediate

[31-26] [25-0]

All R-type

I-type Load/Store

I-type Branch

Jump

shamt

[10-6]

Shift left 2

ALU^ sum

M U X

PCSrc

[25-21] rs

[20-16] rt

[15-11] rd

[15-0] addr

[5-0] funct

ALU control ALUOp

ALU Control Unit

What about write register?

For R-type use bits [15-11] For I-type use bits [20-16]

[15-11] rd

M U X

RegDst

Single-cycle Instruction execution

  • R-type
    • Fetch instruction and increment PC
    • Read two source registers from register file (set control)
    • Perform ALU operation on register operands
  • Store/Load
    • Fetch instruction and increment PC
    • Read one register value from register file (set control)
    • ALU computes sum of immediate and register value
    • ALU result used as address to memory
    • Data from memory written back to register (Load only)
  • Branch
    • Fetch instruction and increment PC
    • Read two source registers from register file (set control)
    • ALU performs subtract on register operands (target addr computed)
    • Zero result from ALU determines PC

Data path and control

Read/write Enabler

Data path control Mux’s

Designing Main control logic (R-type)

ALUOp

ALUOp

Branch

MemWrite

R-type 1 0 0 1 0

RegDstALUSrcMemToRegRegWriteMemRead Instr type

RegDst: Destination register is determined by [15-11] Ë 1 ALUSrc: ALU input 2 is from register fileË 0 MemtoReg: ALU result written to register Ë 0 RegWrite: Write to register allowed Ë 1 MemRead: Read to mem not needed (no effect) Ë 0 MemWrite: Write to mem not needed (no effect) Ë 0 Branch: This is not a branch (PCSrcË0) Ë 0 ALUOp1: TBD by function code Ë 1 (sets ALU control) ALUOp0: TBD by function code Ë 0 (sets ALU control)

Designing Main control logic (Store)

Store X 1 X 0 0 1 0 0 0

Load 0 1 1 1 1 0 0 0 0

ALUOp

ALUOp

Branch

MemWrite

R-type 1 0 0 1 0

ALUSrcMemToRegRegWriteMemRead RegDst Instr type

RegDst: Don’t care b/c no storage to regs (RegWrite=0) ËX

ALUSrc: ALU input 2 is from sign extended immediateË 1

MemtoReg: Don’t care b/c no storage to regs (RegWrite=0) ËX

RegWrite: Write to register not allowed Ë 0

MemRead: Read to mem not needed (no effect) Ë 0

MemWrite: Allow mem to be written Ë 1

Branch: This is not a branch (PCSrcË0) Ë 0

ALUOp1: TBD by function code Ë 0 (sets ALU control)

ALUOp0: TBD by function code Ë 0 (sets ALU control)

Designing Main control logic (BEQ)

BEQ X 0 X 0 0 0 1 0 1

Store X 1 X 0 0 1 0 0 0

Load 0 1 1 1 1 0 0 0 0

ALUOp

ALUOp

Branch

MemWrite

R-type 1 0 0 1 0

RegDstALUSrcMemToRegRegWriteMemRead Instr type

RegDst: Don’t care b/c no storage to regs (RegWrite=0) ËX

ALUSrc: ALU input 2 is from register fileË 0

MemtoReg: Don’t care b/c no storage to regs (RegWrite=0) ËX

RegWrite: Write to register not allowed Ë 0

MemRead: Read to mem not needed (no effect) Ë 0

MemWrite: Write to mem not needed (no effect) Ë 0

Branch: This is a branch (PCSrc=(zero AND Branch)) Ë 1

ALUOp1: TBD by function code Ë 0 (sets ALU control)

ALUOp0: TBD by function code Ë 1 (sets ALU control)

What about Jump?