Docsity

Understanding the Control Signals in a MIPS Processor, Slides of Computer Science

Partial preview of the text

Download Understanding the Control Signals in a MIPS Processor and more Slides Computer Science in PDF only on Docsity!

CS152: Computer Architecture

and Engineering

Lecture 9

Designing Single Cycle Control

Recap: Summary from last time

 5 steps to design a processor

    1. Analyze instruction set => datapath requirements
    1. Select set of datapath components & establish clock methodology
    1. Assemble datapath meeting the requirements
    1. Analyze implementation of each instruction to determine setting

of control points that effects the register transfer.

    1. Assemble the control logic

 MIPS makes it easier

  • Instructions same size
  • Source registers always in same place
  • Immediates same size, location
  • Operations always on registers/immediates

 Single cycle datapath ⇒ CPI=1, Cycle Time = long!

An Abstract View of the Implementation

Data Out

Clk

Rw Ra Rb 32 32-bit Registers

Rd

ALU

Clk

Data In

Data Address Ideal Data Memory

Instruction

Instruction Address

Ideal Instruction Memory

Clk

PC

Rs 5

Rt

A
B

Next Address

Control

Datapath

Control Signals (^) Conditions

Recap: A Single Cycle Datapath

 Rs, Rt, Rd and Imed16 hardwired into datapath from Fetch Unit

 We have everything except control signals (underline)

  • Today’s lecture will show you how to generate the control signals

ALUctr

Clk

busW

RegWr

busA

busB

Rw Ra Rb 32 32-bit Registers

Rs

Rt

Rt

Rd RegDst

Extender

Mux

Mux

imm16 16 32

ALUSrc

ExtOp

Mux

MemtoReg

Clk

Data In

WrEn 32

Adr Data Memory

MemWr ALU

Instruction Fetch Unit Clk

Zero

Instruction<31:0>

Rt Rs Rd Imm

nPC_sel

Recap: Meaning of the Control Signals

 ExtOp: “zero”, “sign”

 ALUsrc: 0 ⇒ regB; 1 ⇒ immed

 ALUctr: “add”, “sub”, “or”

 MemWr: 1 ⇒ write memory
 MemtoReg: 0 ⇒ ALU; 1 ⇒ Mem
 RegDst: 0 ⇒ “rt”; 1 ⇒ “rd”
 RegWr: 1 ⇒ write register

ALUctr

Clk

busW

RegWr

busA

busB

Rw Ra Rb 32 32-bit Registers

Rs

Rt

Rt

Rd

RegDst

Extender

Mux

imm16 16 32

ExtOp ALUSrc

Mux

MemtoReg

Clk

Data In

(^32) WrEnAdr

Data Memory

MemWr

ALU

Equal

RTL: The Add Instruction

 add rd, rs, rt

  • mem[PC] Fetch the instruction

from memory

  • R[rd] <- R[rs] + R[rt] The actual operation
  • PC <- PC + 4 Calculate the next

instruction’s address

op rs rt rd shamt funct

6 bits 5 bits 5 bits 5 bits 5 bits 6 bits

The Single Cycle Datapath During Add

ALUctr = Add

Clk

busW

RegWr = 1

busA

busB

Rw Ra Rb 32 32-bit Registers

Rs

Rt

Rt

Rd RegDst = 1

Extender

Mux

Mux

imm16 16 32

ALUSrc = 0

ExtOp = x

Mux

MemtoReg = 0

Clk

Data In

WrEn 32

Adr Data Memory

MemWr = 0 ALU

Instruction Fetch Unit Clk

Zero

Instruction<31:0>

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

Rt Rs Rd Imm

op rs rt rd shamt funct

nPC_sel= +

Instruction Fetch Unit at the End of Add

 PC <- PC + 4

  • This is the same for all instructions except: Branch and Jump

Adr

Inst Memory

Adder

Adder

PC

Clk

Mux^00

nPC_MUX_sel

imm

Instruction<31:0>

The Single Cycle Datapath During Load

ALUctr = Add

Clk

busW

RegWr = 1

busA

busB

Rw Ra Rb 32 32-bit Registers

Rs

Rt

Rt

Rd RegDst = 0

Extender

Mux

Mux

imm16 16 32

ALUSrc = 1

ExtOp = 1

Mux

MemtoReg = 1

Clk

Data In

WrEn 32

Adr Data Memory

MemWr = 0 ALU

Instruction Fetch Unit Clk

Zero

Instruction<31:0>

Rt Rs Rd Imm

 R[rt] <- Data Memory {R[rs] + SignExt[imm16]}

op rs rt immediate

nPC_sel= +

The Single Cycle Datapath During Store

 Data Memory {R[rs] + SignExt[imm16]} <- R[rt]

op rs rt immediate

ALUctr =

Clk

busW

RegWr =

busA

busB

Rw Ra Rb 32 32-bit Registers

Rs

Rt

Rt

Rd RegDst =

Extender

Mux

Mux

imm16 16 32

ALUSrc =

ExtOp =

Mux

MemtoReg =

Clk

Data In

WrEn 32

Adr Data Memory

MemWr = ALU

Instruction Fetch Unit Clk

Zero

Instruction<31:0>

Rt Rs Rd Imm

nPC_sel =

The Single Cycle Datapath During Branch

ALUctr =Sub

Clk

busW

RegWr = 0

busA

busB

Rw Ra Rb 32 32-bit Registers

Rs

Rt

Rt

Rd RegDst = x

Extender

Mux

Mux

imm16 16 32

ALUSrc = 0

ExtOp = x

Mux

MemtoReg = x

Clk

Data In

WrEn 32

Adr Data Memory

MemWr = 0 ALU

Instruction Fetch Unit Clk

Zero

Instruction<31:0>

Rt Rs Rd Imm

 if (R[rs] - R[rt] == 0) then Zero <- 1 ; else Zero <- 0

op rs rt immediate

nPC_sel= “Br”

Instruction Fetch Unit at the End of Branch

 if (Zero == 1) then PC = PC + 4 + SignExt[imm16]*4; else PC = PC + 4

op rs rt immediate

 What is encoding of nPC_sel?

  • Direct MUX select?
  • Branch / not branch

 Let’s choose second option

nPC_sel zero? MUX 0 x 0 1 0 0 1 1 1

Adr

Inst Memory

Adder

Adder

PC

Clk

Mux

nPC_sel

imm

Instruction<31:0>

Zero

nPC_MUX_sel

Summary of Control Signals

inst Register Transfer

ADD R[rd] <– R[rs] + R[rt]; PC <– PC + 4

ALUsrc = RegB, ALUctr = “add”, RegDst = rd, RegWr, nPC_sel = “+4”

SUB R[rd] <– R[rs] – R[rt]; PC <– PC + 4

ALUsrc = RegB, ALUctr = “sub”, RegDst = rd, RegWr, nPC_sel = “+4” ORi R[rt] <– R[rs] + zero_ext(Imm16); PC <– PC + 4

ALUsrc = Im, Extop = “Z”, ALUctr = “or”, RegDst = rt, RegWr, nPC_sel = “+4”

LOAD R[rt] <– MEM[ R[rs] + sign_ext(Imm16)]; PC <– PC + 4

ALUsrc = Im, Extop = “Sn”, ALUctr = “add”, MemtoReg, RegDst = rt, RegWr, nPC_sel = “+4”

STORE MEM[ R[rs] + sign_ext(Imm16)] <– R[rs]; PC <– PC + 4

ALUsrc = Im, Extop = “Sn”, ALUctr = “add”, MemWr, nPC_sel = “+4”

BEQ if ( R[rs] == R[rt] ) then PC <– PC + sign_ext(Imm16)] || 00 else PC <– PC + 4 nPC_sel = “Br”, ALUctr = “sub”

Summary of the Control Signals

add sub ori lw sw beq jump RegDst ALUSrc MemtoReg RegWrite MemWrite nPCsel Jump ExtOp ALUctr<2:0>

1 0 0 1 0 0 0 x

Add

1 0 0 1 0 0 0 x

Sub

Or

Add

x 1 x 0 1 0 0 1

Add

x 0 x 0 0 1 0 x

Sub

x x x 0 0 0 1 x

xxx

op target address

op rs rt rd shamt funct

op rs rt immediate

R-type

I-type

J-type

add, sub

ori, lw, sw, beq

jump

func Appendix A op (^) 00 0000 00 0000 00 1101 10 0011 10 1011 00 0100 00 0010

See 10 000010 0010 We Don’t Care :-)