28
Mohamed Younis CMCS 411, Computer Architecture 1 CMSC 411-101 Computer Architecture Lecture 14 Single-cycle Control Unit March 14, 2001 www.csee.umbc.edu/~younis/CMSC411/ CMSC411.htm

Lecture’s Overview

  • Upload
    abby

  • View
    51

  • Download
    0

Embed Size (px)

DESCRIPTION

CMSC 411-101 Computer Architecture Lecture 14 Single-cycle Control Unit March 14, 2001 www.csee.umbc.edu/~younis/CMSC411/ CMSC411.htm. Lecture’s Overview. Previous Lecture: Processor design steps (ISA analysis, component selection, datapath assembly, control unit) Basic building blocks - PowerPoint PPT Presentation

Citation preview

Page 1: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 1

CMSC 411-101Computer Architecture

Lecture 14

Single-cycle Control Unit

March 14, 2001

www.csee.umbc.edu/~younis/CMSC411/ CMSC411.htm

Page 2: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 2

Lecture’s Overview Previous Lecture:

• Processor design steps (ISA analysis, component selection, datapath assembly, control unit)

• Basic building blocks (Register files, adders, multiplexers)

• Building a datapath (Instruction fetch, register transfer requirements)

This Lecture:

• Control unit design

• Single cycle processor

• Circuit implementation of control unit

Page 3: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 3

Summary of Previous Lecture

Processor

Computer

Control

Datapath

Memory Devices

Input

Output

Connections for Information flow

Coordination for proper operation

Last class

This class

Design Steps:1. Analyze instruction set => datapath requirements2. Select set of datapath components and establish clocking methodology3. Assemble datapath meeting the requirements

4. Analyze implementation of each instruction to determine setting of control points that effects the register transfer5. Assemble the control logic

Last class

This class

Page 4: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 4

Single-cycle Datapath

* Slide is courtesy of Dave Patterson

32

ALUctr

Clk

busW

RegWr

3232

busA

32busB

55 5

Rw Ra Rb32 32-bitRegisters

Rs

Rt

Rt

RdRegDst

Extender

Mux

Mux

3216imm16

ALUSrc

ExtOp

Mux

MemtoReg

Clk

Data InWrEn

32Adr

DataMemory

32

MemWr

ALU

InstructionFetch Unit

Clk

Zero

Instruction<31:0>

0

1

0

1

01

<21:25>

<16:20>

<11:15>

<0:15>

Imm16RdRsRt

nPC_sel

Today’s lecture will show you how to generate the control signals (underline)

Page 5: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 5

PC Ext

Adr

InstMemory

Adder

Adder

PC

Clk

00

Mux

4

nPC_sel

imm

16

Instruction<31:0>

Adr

InstMemory

Adder

Adder

PC

Clk

00

Mux

4

nPC_sel

imm

16

Instruction<31:0>

PC Ext

Instruction Fetch Unit

PC PC + 4same for all instructions except: Branch & Jump

Instruction mem[PC]same for all instructions

* Figures are courtesy of Dave Patterson

Page 6: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 6

Single Cycle Datapath during Add

ExtOp = x

R[rd] R[rs] + R[rt]

op rs rt rd shamt funct061116212631

32

ALUctr = Add

Clk

busW

RegWr = 1

3232

busA

32busB

55 5

Rw Ra Rb32 32-bitRegisters

Rs

Rt

Rt

RdRegDst = 1

Extender

Mux

Mux

3216imm16

ALUSrc = 0

Mux

MemtoReg = 0

Clk

Data InWrEn

32Adr

DataMemory

32

MemWr = 0A

LU

InstructionFetch Unit

Clk

Zero

Instruction<31:0>

0

1

0

1

01<21:25>

<16:20>

<11:15>

<0:15>

Imm16RdRsRt

nPC_sel= +4

* Slide is courtesy of Dave Patterson

Page 7: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 7

Datapath during Or Immediate

R[rt] R[rs] or ZeroExt[Imm16]

op rs rt immediate016212631

32

ALUctr =

Clk

busW

RegWr =

3232

busA

32busB

55 5

Rw Ra Rb32 32-bitRegisters

Rs

Rt

Rt

RdRegDst =

Extender

Mux

Mux

3216imm16

ALUSrc =

ExtOp =

Mux

MemtoReg =

Clk

Data InWrEn

32Adr

DataMemory

32

MemWr =

ALU

InstructionFetch Unit

Clk

Zero

Instruction<31:0>

0

1

0

1

01<21:25>

<16:20>

<11:15>

<0:15>

Imm16RdRsRt

nPC_sel =

* Slide is courtesy of Dave Patterson

Page 8: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 8

32

ALUctr = Or

Clk

busW

RegWr = 1

3232

busA

32busB

55 5

Rw Ra Rb32 32-bitRegisters

Rs

Rt

Rt

RdRegDst = 0

Extender

Mux

Mux

3216imm16

ALUSrc = 1

ExtOp = 0

Mux

MemtoReg = 0

Clk

Data InWrEn

32Adr

DataMemory

32

MemWr = 0A

LU

InstructionFetch Unit

Clk

Zero

Instruction<31:0>

0

1

0

1

01<21:25>

<16:20>

<11:15>

<0:15>

Imm16RdRsRt

op rs rt immediate016212631

nPC_sel= +4

Datapath during Or Immediate

R[rt] R[rs] or ZeroExt[Imm16]

* Slide is courtesy of Dave Patterson

Page 9: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 9

Single Cycle Datapath during Load

32

ALUctr = Add

Clk

busW

RegWr = 1

3232

busA

32busB

55 5

Rw Ra Rb32 32-bitRegisters

Rs

Rt

Rt

RdRegDst = 0

Extender

Mux

Mux

3216imm16

ALUSrc = 1

ExtOp = 1

Mux

MemtoReg = 1

Clk

Data InWrEn

32Adr

DataMemory

32

MemWr = 0

ALU

InstructionFetch Unit

Clk

Zero

Instruction<31:0>

0

1

0

1

01<21:25>

<16:20>

<11:15>

<0:15>

Imm16RdRsRt

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

op rs rt immediate016212631

nPC_sel= +4

* Slide is courtesy of Dave Patterson

Page 10: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 10

Single Cycle Datapath during Store

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

op rs rt immediate016212631

32

ALUctr =

Clk

busW

RegWr =

3232

busA

32busB

55 5

Rw Ra Rb32 32-bitRegisters

Rs

Rt

Rt

RdRegDst =

Extender

Mux

Mux

3216imm16

ALUSrc =

ExtOp =

Mux

MemtoReg =

Clk

Data InWrEn

32Adr

DataMemory

32

MemWr =

ALU

InstructionFetch Unit

Clk

Zero

Instruction<31:0>

0

1

0

1

01<21:25>

<16:20>

<11:15>

<0:15>

Imm16RdRsRt

nPC_sel =

* Slide is courtesy of Dave Patterson

Page 11: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 11

Single Cycle Datapath during Store

32

ALUctr = Add

Clk

busW

RegWr = 0

3232

busA

32busB

55 5

Rw Ra Rb32 32-bitRegisters

Rs

Rt

Rt

RdRegDst = x

Extender

Mux

Mux

3216imm16

ALUSrc = 1

ExtOp = 1

Mux

MemtoReg = x

Clk

Data InWrEn

32Adr

DataMemory

32

MemWr = 1A

LU

InstructionFetch Unit

Clk

Zero

Instruction<31:0>

0

1

0

1

01<21:25>

<16:20>

<11:15>

<0:15>

Imm16RdRsRt

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

op rs rt immediate016212631

nPC_sel= +4

* Slide is courtesy of Dave Patterson

Page 12: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 12

Single Cycle Datapath during Branch

32

ALUctr = Subtract

Clk

busW

RegWr = 0

3232

busA

32busB

55 5

Rw Ra Rb32 32-bitRegisters

Rs

Rt

Rt

RdRegDst = x

Extender

Mux

Mux

3216imm16

ALUSrc = 0

ExtOp = x

Mux

MemtoReg = x

Clk

Data InWrEn

32Adr

DataMemory

32

MemWr = 0A

LU

InstructionFetch Unit

Clk

Zero

Instruction<31:0>

0

1

0

1

01<21:25>

<16:20>

<11:15>

<0:15>

Imm16RdRsRt

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

op rs rt immediate016212631

nPC_sel= “Br”

* Slide is courtesy of Dave Patterson

Page 13: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 13

Instruction Fetch Unit at End of Branch

if (Zero == 1) then PC = PC + 4 +

SignExt[imm16]*4 ; else PC = PC + 4

op rs rt immediate016212631

Adr

InstMemory

Adder

Adder

PC

Clk

00Mux

4

nPC_sel

imm

16

Instruction<31:0>

PC Ext

* Slide is courtesy of Dave Patterson

Page 14: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 14

Step 4: Given Datapath: RTL Control

ALUctrRegDst ALUSrcExtOp MemtoRegMemWr Equal

Instruction<31:0>

<21:25>

<16:20>

<11:15>

<0:15>

Imm16RdRsRt

nPC_sel

Adr

InstMemory

DATA PATH

Control

Op

<21:25>

Fun

RegWr

* Slide is courtesy of Dave Patterson

Page 15: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 15

Value of Control Signalsinst Register TransferADD 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 + 4ALUsrc = 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 + 4nPC_sel = “Br”, ALUctr = “sub”

* Slide is courtesy of Dave Patterson

Page 16: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 16

A Summary of the Control Signals

op target address

op rs rt rd shamt funct061116212631

op rs rt immediate

R-type

I-type

J-type

add, sub

ori, lw, sw, beq

jump

add sub ori lw sw beq jumpRegDstALUSrcMemtoRegRegWriteMemWritenPCselJumpExtOpALUctr<2:0>

1001000x

Add

1001000x

Subtract

01010000

Or

01110001

Add

x1x01001

Add

x0x0010x

Subtract

xxx0001x

xxx

funcop 00 0000 00 0000 00 1101 10 0011 10 1011 00 0100 00 0010Appendix A

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

* Slide is courtesy of Dave Patterson

Page 17: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 17

The Concept of Local Decoding

R-type ori lw sw beq jumpRegDstALUSrcMemtoRegRegWriteMemWriteBranchJumpExtOpALUop<N:0>

1

0

0

1

0

0

0

x

“R-type”

0

1

0

1

0

0

0

0

Or

0

1

1

1

0

0

0

1

Add

x

1

x

0

1

0

0

1

Add

x

0

x

0

0

1

0

x

Subtract

x

x

x

0

0

0

1

x

xxx

op 00 0000 00 1101 10 0011 10 1011 00 0100 00 0010

MainControl

op6

ALUControl(Local)

func

N

6ALUop

ALUctr3

ALU

* Slide is courtesy of Dave Patterson

Page 18: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 18

Encoding of ALUop

In this exercise, ALUop has to be 2 bits wide to represent: (1) “R-type” instructions“I-type” instructions that require the ALU to perform:

(2) Or, (3) Add, and (4) Subtract To implement the full MIPS ISA, ALUop has to be 3 bits for:

(1) “R-type” instructions “I-type” instructions that require the ALU to perform:

(2) Or, (3) Add, (4) Subtract, and (5) And (Example: andi)

MainControl

op6

ALUControl(Local)

func

N

6ALUop

ALUctr3

R-type ori lw sw beq jumpALUop (Symbolic) “R-type” Or Add Add Subtract xxx

ALUop<2:0> 1 00 0 10 0 00 0 00 0 01 xxx

* Slide is courtesy of Dave Patterson

Page 19: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 19

Decoding of the “func” Field

R-type ori lw sw beq jumpALUop (Symbolic) “R-type” Or Add Add Subtract xxx

ALUop<2:0> 1 00 0 10 0 00 0 00 0 01 xxx

MainControl

op6

ALUControl(Local)

func

N

6ALUop

ALUctr3

op rs rt rd shamt funct061116212631

R-type

funct<5:0> Instruction Operation10 000010 001010 010010 010110 1010

addsubtractandorset-on-less-than

ALUctr<2:0> ALU Operation000001010110111

AddSubtract

AndOr

Set-on-less-than

ALUctr

ALU

* Slide is courtesy of Dave Patterson

Page 20: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 20

The Truth Table for ALUctr

R-type ori lw sw beqALUop(Symbolic) “R-type” Or Add Add Subtract

ALUop<2:0> 1 00 0 10 0 00 0 00 0 01

ALUop funcbit<2> bit<1> bit<0> bit<2> bit<1> bit<0>bit<3>

0 0 0 x x x x

ALUctrALUOperation

Add 0 1 0bit<2> bit<1> bit<0>

0 x 1 x x x x Subtract 1 1 00 1 x x x x x Or 0 0 11 x x 0 0 0 0 Add 0 1 01 x x 0 0 1 0 Subtract 1 1 01 x x 0 1 0 0 And 0 0 01 x x 0 1 0 1 Or 0 0 11 x x 1 0 1 0 Set on < 1 1 1

funct<3:0> Instruction Op.00000010010001011010

addsubtractandorset-on-less-than

* Slide is courtesy of Dave Patterson

Page 21: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 21

The Logic Equation for ALUctr

ALUctr<2> = !ALUop<2> & ALUop<0> + ALUop<2> & !func<2> & func<1> & !func<0>

Similarly:ALUctr<1> = !ALUop<2> & !ALUop<1> +

ALUop<2> & !func<2> & !func<0>

ALUctr<0> = !ALUop<2> & ALUop<0> + ALUop<2> & !func<3> & func<2> & !func<1> & func<0> + ALUop<2> & func<3> & !func<2> & func<1> & !func<0>

ALUop funcbit<2> bit<1> bit<0> bit<2> bit<1> bit<0>bit<3> ALUctr<2>

0 x 1 x x x x 11 x x 0 0 1 0 11 x x 1 0 1 0 1

This makes func<3> a don’t care

* Slide is courtesy of Dave Patterson

ALUControl(Local)

func

3

6

ALUop

ALUctr

3

Page 22: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 22

Step 5: Logic for each control signal nPC_sel if (OP == BEQ) then EQUAL else 0

ALUsrc if (OP == “Rtype”) then “regB” else “immed” ALUctr if (OP == “Rtype”) then funct

elseif (OP == ORi) then “OR” elseif (OP == BEQ) then “sub” else “add”

ExtOp

MemWr

MemtoReg

RegWr:

RegDst: if ((OP == Load) || (OP == ORi)) then 0 else 1

if ((OP == Store) || (OP == BEQ)) then 0 else 1

(OP == Load)

(OP == Store)

if (OP == ORi) then “zero” else “sign”

* Slide is courtesy of Dave Patterson

Page 23: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 23

“Truth Table” for the Main Control

R-type ori lw sw beq jumpRegDstALUSrcMemtoRegRegWriteMemWriteBranchJumpExtOpALUop (Symbolic)

1001000x

“R-type”

01010000

Or

01110001

Add

x1x01001

Add

x0x0010x

Subtract

xxx0001x

xxx

op 00 0000 00 1101 10 0011 10 1011 00 0100 00 0010

ALUop <2> 1 0 0 0 0 xALUop <1> 0 1 0 0 0 xALUop <0> 0 0 0 0 1 x

MainControl

op6

ALUControl(Local)

func

3

6

ALUop

ALUctr3

RegDstALUSrc

:

* Slide is courtesy of Dave Patterson

Page 24: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 24

The “Truth Table” for RegWrite

R-type ori lw sw beq jump

RegWrite 1 1 1 0 0 0

op 00 0000 00 1101 10 0011 10 1011 00 0100 00 0010

RegWrite = R-type + ori + lw= !op<5> & !op<4> & !op<3> & !op<2> & !op<1> & !op<0> (R-type) + !op<5> & !op<4> & op<3> & op<2> & !op<1> & op<0> (ori) + op<5> & !op<4> & !op<3> & !op<2> & op<1> & op<0> (lw)

op<0>

op<5>. .op<5>. .<0>

op<5>. .<0>

op<5>. .<0>

op<5>. .<0>

op<5>. .<0>

R-type ori lw sw beq jumpRegWrite

* Slide is courtesy of Dave Patterson

Page 25: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 25

Implementation of the Main Controlop<0>

op<5>. .op<5>. .<0>

op<5>. .<0>

op<5>. .<0>

op<5>. .<0>

op<5>. .<0>

R-type ori lw sw beq jumpRegWrite

ALUSrc

MemtoRegMemWrite

BranchJump

RegDst

ExtOp

ALUop<2>ALUop<1>ALUop<0>

* Slide is courtesy of Dave Patterson

Page 26: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 26

A Single Cycle Processor

32

ALUctr

Clk

busW

RegWr

3232

busA

32busB

55 5

Rw Ra Rb32 32-bitRegisters

Rs

Rt

Rt

RdRegDst

Extender

Mux

Mux

3216imm16

ALUSrc

ExtOp

Mux

MemtoReg

Clk

Data InWrEn

32Adr

DataMemory

32

MemWrA

LU

InstructionFetch Unit

Clk

Zero

Instruction<31:0>

0

1

0

1

01<21:25>

<16:20>

<11:15>

<0:15>

Imm16RdRsRt

MainControl

op6

ALUControlfunc

6

3ALUop

ALUctr3

RegDst

ALUSrc:

Instr<5:0>

Instr<31:26>

Instr<15:0>

nPC_sel

Page 27: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 27

Worst Case Timing (Load)Clk

PC

Rs, Rt, Rd,Op, Func

Clk-to-Q

ALUctr

Instruction Memoey Access Time

Old Value New Value

RegWr Old Value New Value

Delay through Control Logic

busARegister File Access Time

Old Value New Value

busB

ALU DelayOld Value New Value

Old Value New Value

New ValueOld Value

ExtOp Old Value New Value

ALUSrc Old Value New Value

MemtoReg Old Value New Value

Address Old Value New Value

busW Old Value New

Delay through Extender & Mux

RegisterWrite Occurs

Data Memory Access Time

Page 28: Lecture’s Overview

Mohamed Younis CMCS 411, Computer Architecture 28

Conclusion Summary

Control unit design (Steps of control design, register transfer logic)

Single cycle processor (Advantage and disadvantage, integration of datapath and control)

Circuit implementation of control unit (Logic equations, truth tables, combinational circuit)

Next Lecture Multi-cycle datapath Sequencer design Multi-cycle control

Reading assignment includes sections 5.3 in the text book