Lecture 5 and 6. ICS 152 Computer Systems Architecture. Prof. Juan Luis Aragón

Similar documents
Systems Architecture I

CPE 335. Basic MIPS Architecture Part II

CC 311- Computer Architecture. The Processor - Control

The Processor: Datapath & Control

Processor: Multi- Cycle Datapath & Control

Multicycle Approach. Designing MIPS Processor

CSE 2021 COMPUTER ORGANIZATION

CSE 2021 COMPUTER ORGANIZATION

ECE369. Chapter 5 ECE369

LECTURE 6. Multi-Cycle Datapath and Control

Lets Build a Processor

Chapter 4 The Processor (Part 2)

Multiple Cycle Data Path

ENE 334 Microprocessors

ﻪﺘﻓﺮﺸﻴﭘ ﺮﺗﻮﻴﭙﻣﺎﻛ يرﺎﻤﻌﻣ MIPS يرﺎﻤﻌﻣ data path and ontrol control

Topic #6. Processor Design

ALUOut. Registers A. I + D Memory IR. combinatorial block. combinatorial block. combinatorial block MDR

Implementing the Control. Simple Questions

Mapping Control to Hardware

Chapter 5: The Processor: Datapath and Control

EECE 417 Computer Systems Architecture

Inf2C - Computer Systems Lecture 12 Processor Design Multi-Cycle

RISC Processor Design

Alternative to single cycle. Drawbacks of single cycle implementation. Multiple cycle implementation. Instruction fetch

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Data Paths and Microprogramming

Points available Your marks Total 100

Microprogrammed Control Approach

Multicycle conclusion

Lecture 8: Control COS / ELE 375. Computer Architecture and Organization. Princeton University Fall Prof. David August

Chapter 5 Solutions: For More Practice

Note- E~ S. \3 \S U\e. ~ ~s ~. 4. \\ o~ (fw' \i<.t. (~e., 3\0)

Computer Science 141 Computing Hardware

Initial Representation Finite State Diagram. Logic Representation Logic Equations

RISC Architecture: Multi-Cycle Implementation

CO Computer Architecture and Programming Languages CAPL. Lecture 18 & 19

Design of the MIPS Processor

Major CPU Design Steps

CSE 2021: Computer Organization Fall 2010 Solution to Assignment # 3: Multicycle Implementation

Processor (multi-cycle)

RISC Design: Multi-Cycle Implementation

Initial Representation Finite State Diagram Microprogram. Sequencing Control Explicit Next State Microprogram counter

RISC Architecture: Multi-Cycle Implementation

ECE 313 Computer Organization FINAL EXAM December 14, This exam is open book and open notes. You have 2 hours.

Design of the MIPS Processor (contd)

Control Unit for Multiple Cycle Implementation

CS/COE0447: Computer Organization

CS/COE0447: Computer Organization

Lecture 5: The Processor

Microprogramming. Microprogramming

ECE468 Computer Organization and Architecture. Designing a Multiple Cycle Controller

Multi-cycle Approach. Single cycle CPU. Multi-cycle CPU. Requires state elements to hold intermediate values. one clock cycle or instruction

5.7. Microprogramming: Simplifying Control Design 5.7

ECE 313 Computer Organization EXAM 2 November 9, 2001

Single vs. Multi-cycle Implementation

THE HONG KONG UNIVERSITY OF SCIENCE & TECHNOLOGY Computer Organization (COMP 2611) Spring Semester, 2014 Final Examination

CSE 2021 Computer Organization. Hugh Chesser, CSEB 1012U W10-M

Processor (I) - datapath & control. Hwansoo Han

Computer Organization & Design The Hardware/Software Interface Chapter 5 The processor : Datapath and control

Using a Hardware Description Language to Design and Simulate a Processor 5.8

Computer Architecture Chapter 5. Fall 2005 Department of Computer Science Kent State University

CS152 Computer Architecture and Engineering. Lecture 8 Multicycle Design and Microcode John Lazzaro (

ELEC 5200/6200 Computer Architecture and Design Spring 2017 Lecture 4: Datapath and Control

CS152 Computer Architecture and Engineering Lecture 13: Microprogramming and Exceptions. Review of a Multiple Cycle Implementation

EE457. Note: Parts of the solutions are extracted from the solutions manual accompanying the text book.

ECE 3056: Architecture, Concurrency and Energy of Computation. Single and Multi-Cycle Datapaths: Practice Problems

Systems Architecture

COMPUTER ORGANIZATION AND DESIGN. The Hardware/Software Interface. Chapter 4. The Processor: A Based on P&H

LECTURE 5. Single-Cycle Datapath and Control

COMP303 - Computer Architecture Lecture 10. Multi-Cycle Design & Exceptions

TDT4255 Computer Design. Lecture 4. Magnus Jahre. TDT4255 Computer Design

Processor Implementation in VHDL. University of Ulster at Jordanstown University of Applied Sciences, Augsburg

CPE 335 Computer Organization. Basic MIPS Architecture Part I

Lecture 10 Multi-Cycle Implementation

Lab 8: Multicycle Processor (Part 1) 0.0

EECS150 - Digital Design Lecture 10- CPU Microarchitecture. Processor Microarchitecture Introduction

Lecture 9: Microcontrolled Multi-Cycle Implementations. Who Am I?

Digital Design & Computer Architecture (E85) D. Money Harris Fall 2007

CENG 3420 Lecture 06: Datapath

Introduction. ENG3380 Computer Organization and Architecture MIPS: Data Path Design Part 3. Topics. References. School of Engineering 1

Review: Abstract Implementation View

Chapter 4. The Processor. Computer Architecture and IC Design Lab

Control & Execution. Finite State Machines for Control. MIPS Execution. Comp 411. L14 Control & Execution 1

ECE232: Hardware Organization and Design

CS232 Final Exam May 5, 2001

COMP303 - Computer Architecture Lecture 8. Designing a Single Cycle Datapath

The Processor. Z. Jerry Shi Department of Computer Science and Engineering University of Connecticut. CSE3666: Introduction to Computer Architecture

CENG 3420 Computer Organization and Design. Lecture 06: MIPS Processor - I. Bei Yu

CSE Lecture In Class Example Handout

Inf2C - Computer Systems Lecture Processor Design Single Cycle

EECS150 - Digital Design Lecture 9- CPU Microarchitecture. Watson: Jeopardy-playing Computer

CPU Organization (Design)

Lecture Topics. Announcements. Today: Single-Cycle Processors (P&H ) Next: continued. Milestone #3 (due 2/9) Milestone #4 (due 2/23)

COMP2611: Computer Organization. The Pipelined Processor

CSEN 601: Computer System Architecture Summer 2014

Week 6: Processor Components

The Big Picture: Where are We Now? EEM 486: Computer Architecture. Lecture 3. Designing a Single Cycle Datapath

CSE Computer Architecture I Fall 2009 Lecture 13 In Class Notes and Problems October 6, 2009

For More Practice FMP

The Processor (1) Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Final Project: MIPS-like Microprocessor

Transcription:

ICS 152 Computer Systems Architecture Prof. Juan Luis Aragón Lecture 5 and 6 Multicycle Implementation Introduction to Microprogramming Readings: Sections 5.4 and 5.5 1

Review of Last Lecture We have seen one implementation of the MIPS ISA First approach: single-clock cycle Datapath design ALU Control Unit design Main Control Unit design Problems of the Single-Clock Cycle Implementation Clock cycle is equal to the slowest instruction FU duplication There are more efficient approaches Multicycle implementation 2

Multicycle Implementation Overview The execution of an instruction can be broken up into multiple steps Each step takes 1 shorter clock cycle Now, each instruction takes more than 1 clock cycle We will be sharing functional units ALU used to compute branch target address and to increment PC Memory used for instruction and data More complex Control Unit We ll use a finite state machine for control 3

Multicycle Datapath Overview Modified Multicycle Datapath Only 1 Memory Unit and 1 ALU Introduce internal registers since at the end of a cycle some results must be stored for use in later cycles Requires additional multiplexers PC 0 M ux 1 Address Write data Memory MemData Instruction [25 21] Instruction [20 16] Instruction [15 0] Instruction register Instruction [15 0] Instruction [15 11] 0 M u x 1 0 M ux Read register 1 Read register 2 Registers Write register Write data Read data 1 Read data 2 A B 4 0 M ux 1 0 1 M ux 2 3 Zero ALU ALU result ALUOut Memory data register 1 16 Sign extend 32 Shift left 2 4

Multicycle Datapath and Control Units New Control Signals For new/extended multiplexers IR and PC registers (what about the others? ) PC 0 M u x 1 Address Write data Memory MemData Instruction [31-26] Instruction [25 21] Instruction [20 16] Instruction [15 0] Instruction register Instruction [15 0] Memory data register PCWriteCond PCWrite IorD Outputs MemRead MemWrite Control MemtoReg IRWrite Instruction [25 0] Instruction [15 11] Op [5 0] 0 M u x 1 0 M u x 1 PCSource ALUOp ALUSrcB ALUSrcA RegDst 16 RegWrite Read register 1 Read register 2 Registers Write register Write data Sign extend Read data 1 Read data 2 32 Shift left 2 A B 4 0 M u x 1 0 1 M u 2 x 3 26 28 Shift left 2 ALU control PC [31-28] Zero ALU ALU result Jump address [31-0] ALUOut 0 1 2 M u x Instruction [5 0] 5

Breaking the Execution into Clock Cycles Goal: balance the amount of work done in each cycle Why? Restrictions: each step should contain at most 1 ALU operation 1 register file access 1 memory access What if we allow using 2 FUs in 1 cycle? Remember: at the end of each cycle all generated outputs must be stored for the next cycle in either A major state element (PC, register file, memory) An internal register (IR, MDR, A, B, ALUOut) 6

Five Execution Steps Instruction Fetch Instruction Decode and Register Fetch Execution, Memory Address Computation, or Branch Completion Memory Access or R-type instruction completion Write-back step (only loads) 7

Step 1: Instruction Fetch Use PC to get instruction and put it in IR Increment the PC by 4 and put the result back in the PC IR = Memory[PC]; PC = PC + 4; Control signals MemRead = 1 IRWrite = 1 IorD = 0 (selects the PC to access memory) ALUSrcA = 0 (selects the PC as ALU s first operand) ALUSrcB = 01 (selects 4 as ALU s second operand) ALUOp = 00 (selects addition) PCWrite = 1 PCSource = 00 (selects the PC+4) 8

Step 2: Instruction Decode and Register Fetch Remember: we still don t know the instruction type We perform not harmful operations Read registers rs and rt in case we need them Compute the branch address in case of a branch A = Reg[IR[25-21]]; B = Reg[IR[20-16]]; ALUOut = PC + (sign-extend(ir[15-0]) << 2); Control signals ALUSrcA = 0 (selects the PC as ALU s first operand) ALUSrcB = 11 (selects the sign-extended/shifted offset as 2 nd ) ALUOp = 00 (selects addition) After this step we KNOW the instruction type 9

Step 3: Execution (instruction dependent) Memory Reference: ALUOut = A + sign-extend(ir[15-0]); Control signals ALUSrcA = 1 (selects register A as ALU s first operand) ALUSrcB = 10 (selects the sign-extended offset as 2 nd ) ALUOp = 00 (selects addition) R-type: ALUOut = A op B; Control signals ALUSrcA = 1 (selects register A as ALU s first operand) ALUSrcB = 00 (selects register B as ALU s second operand) ALUOp = 10 (ALU operation depends on funct field) 10

Step 3: Execution (instruction dependent) Branch: if (A==B) PC = ALUOut; Control signals ALUSrcA = 1 (selects register A as ALU s first operand) ALUSrcB = 00 (selects register B as ALU s second operand) ALUOp = 01 (selects subtraction) PCSource = 01 (PC comes from ALUout) PCWriteCond = 1 (PC modified if the Zero output is asserted) Jump: PC = PC [31-28] (IR[25-0] <<2); Control signals PCSource = 10 (PC comes from jump target address) PCWrite = 1 (PC is written) 11

Step 4: Memory-access or R-type Completion LOADS: MDR = Memory[ALUOut]; MemRead = 1, IorD = 1 STORES: Memory[ALUOut] = B; MemWrite = 1, IorD = 1 R-type instructions finish Reg[IR[15-11]] = ALUOut; RegDst = 1 (destination register comes from rd) RegWrite = 1 (a register is written) MemtoReg = 0 (data to be written comes from ALUout) 12

Step 5: Memory Read Completion Loads write-back the value from memory Reg[IR[20-16]]= MDR; Control signals RegDst = 1 (destination register comes from rd) RegWrite = 1 (a register is written) MemtoReg = 0 (data to be written comes from ALUout) What about all the other instructions? 13

Summary: Remember: instructions take from 3 to 5 steps Step name Action for R-type instructions Action for memory-reference instructions Action for branches Action for jumps Instruction fetch IR = Memory[PC] PC = PC + 4 Instruction decode/register fetch A = Reg [IR[25-21]] B = Reg [IR[20-16]] ALUOut = PC + (sign-extend (IR[15-0]) << 2) Execution, address computation, branch/ jump completion ALUOut = A op B ALUOut = A + sign-extend (IR[15-0]) if (A ==B) then PC = ALUOut PC = PC[31-28] II (IR[25-0]<<2) Memory access or R-type completion Reg[ IR[15-11] ] = ALUOut Load: MDR = Memory[ALUOut] or Store: Memory[ALUOut] = B Memory read completion Load: Reg[ IR[20-16] ] = MDR 14

Implementing the Control Unit Value of control signals is dependent upon: What instruction is being executed Which step is being performed Use the information we ve accumulated to specify a Finite State Machine Specify the finite state machine graphically, or Use microprogramming Implementation can be derived from specification Gates PLAs ROMs 15

Review: Finite State Machines Finite State Machines (FSM) a set of states and next state function (determined by current state and the input) output function (determined by current state and possibly input) Combinational logic Outputs Next state State register Inputs We ll use a Moore machine (output based only on current state) 16

Control Unit: Overview Overview Implements the five execution steps Each step will take 1 cycle Start Instruction fetch/decode and register fetch (Figure 5.37) Memory access instructions (Figure 5.38) R-type instructions (Figure 5.39) Branch instruction (Figure 5.40) Jump instruction (Figure 5.41) 17

Control Unit: Fetch and Decode First two steps: Independent of the instruction class Start 0 MemRead ALUSrcA = 0 IorD = 0 IR W rite ALUSrcB = 01 ALUOp = 00 PCWrite PCSource = 00 Instruction fetch Instruction decode/ Register fetch 1 ALUSrcA = 0 ALUSrcB = 11 ALUOp = 00 ( O p = 'L W ') o r ( O p = 'S W ') (O p = R -t y p e ) (O p = 'B E Q ') (Op = 'JM P') M em ory reference FS M (Figure 5.38) R-type FSM (Figure 5.39) Branch FSM (Figure 5.40) Jump FSM (Figure 5.41) 18

Control Unit: Memory and R-type Execution Memory Reference 2 3 From state 1 ALUSrcA = 1 ALUSrcB = 10 ALUOp = 00 (Op = 'LW') MemRead IorD = 1 (Op='LW')or(Op='SW') Memory address computation Memory access (Op = 'SW') 5 MemWrite IorD = 1 Memory access 6 7 R-type From state 1 ALUSrcA = 1 ALUSrcB = 00 ALUOp = 10 RegDst = 1 RegWrite MemtoReg = 0 (Op = R-type) Execution R-type completion 4 Write-back step RegWrite MemtoReg = 1 RegDst = 0 To state 0 (Figure 5.37) To state 0 (Figure 5.37) 19

Control Unit: Complete FSM 2 Memory address computation ALUSrcA = 1 ALUSrcB = 10 ALUOp = 00 Start Instruction fetch 0 MemRead ALUSrcA = 0 IorD = 0 IRWrite ALUSrcB = 01 ALUOp = 00 PCWrite PCSource = 00 6 (Op = 'LW') or (Op = 'SW') Execution ALUSrcA =1 ALUSrcB = 00 ALUOp= 10 8 (Op = R-type) Branch completion ALUSrcA = 1 ALUSrcB = 00 ALUOp = 01 PCWriteCond PCSource = 01 Instruction decode/ register fetch 1 (Op = 'BEQ') 9 ALUSrcA = 0 ALUSrcB = 11 ALUOp = 00 (Op = 'J') Jump completion PCWrite PCSource = 10 3 (Op = 'LW') Memory access (Op = 'SW') 5 Memory access 7 R-type completion MemRead IorD = 1 MemWrite IorD = 1 RegDst = 1 RegWrite MemtoReg = 0 4 Write-back step RegDst=0 RegWrite MemtoReg =1 20

Control Unit Implementation Implementation Overview: Control logic Inputs Outputs PCWrite PCWriteCond IorD MemRead MemWrite IRWrite MemtoReg PCSource ALUOp ALUSrcB ALUSrcA RegWrite RegDst NS3 NS2 NS1 NS0 Op5 Op4 Op3 Op2 Op1 Op0 S3 S2 S1 S0 Instruction register opcode field State register 21

PLA Implementation Op5 Op4 Op3 Op2 Op1 Op0 S3 S2 S1 S0 PCWrite PCWriteCond IorD MemRead MemWrite IRWrite MemtoReg PCSource1 PCSource0 ALUOp1 ALUOp0 ALUSrcB1 ALUSrcB0 ALUSrcA RegWrite RegDst NS3 NS2 NS1 NS0 22

Microprogramming A graphical representation is adequate when There are few instructions What about if we want to implement the full MIPS ISA? The control specification will be very complex Solution: Use some ideas from programming to specify control Microinstruction: Defines the set of control signals that must be asserted We must specify the sequencing of microinstructions Sequential Non-sequential (branches inside the Microprogram) Microprogram: A symbolic representation of the control using microinstructions 23

Microinstruction Format Format: Each microinstruction is composed of several fields Each field controls one or several control signals Goal: Simplify the representation Make the Microprogram easy to read We are using 7 fields: Label ALU Control SRC1 SRC2 Regist. Control Memory PCWrite Control Sequen. Can you figure out the purpose of each field? 24

Microinstruction Format SRC1 Field name Value Signals active Comment ALU control SRC2 Register control Memory PC write control Sequencing Add ALUOp = 00 Cause the ALU to add. Subt ALUOp = 01 Cause the ALU to subtract; this implements the compare for branches. Func code ALUOp = 10 Use the instruction's function code to determine ALU control. PC ALUSrcA = 0 Use the PC as the first ALU input. A ALUSrcA = 1 Register A is the first ALU input. B ALUSrcB = 00 Register B is the second ALU input. 4 ALUSrcB = 01 Use 4 as the second ALU input. Extend ALUSrcB = 10 Use output of the sign extension unit as the second ALU input. Extshft Read ALUSrcB = 11 Use the output of the shift-by-two unit as the second ALU input. Read two registers using the rs and rt fields of the IR as the register numbers and putting the data into registers A and B. RegWrite, Write a register using the rd field of the IR as the register number and Write ALU RegDst = 1, the contents of the ALUOut as the data. MemtoReg = 0 RegWrite, Write a register using the rt field of the IR as the register number and Write MDR RegDst = 0, the contents of the MDR as the data. MemtoReg = 1 Read PC Read ALU Write ALU ALU ALUOut-cond jump address MemRead, Read memory using the ALUOut as address; write result into MDR. lord = 1 PCSource = 00 Write the output of the ALU into the PC. PCWrite PCSource = 10, Write the PC with the jump address from the instruction. PCWrite MemRead, MemWrite, PCSource = 01, Read memory using the PC as address; write result into IR (and Write memory using the ALUOut as address, contents of B as the If the Zero output of the ALU is active, write the PC with the contents lord = 0 lord = 1 PCWriteCond the MDR). data. of the register ALUOut. Seq AddrCtl = 11 Choose the next microinstruction sequentially. Fetch AddrCtl = 00 Go to the first microinstruction to begin a new instruction. Dispatch 1 AddrCtl = 01 Dispatch using the ROM 1. Dispatch 2 AddrCtl = 10 Dispatch using the ROM 2. 25

Creating the Microprogram Step 1: Instruction Fetch Step 2: Instruction Decode and Register Fetch Label ALU SRC1 SRC2 Regist. Memory PCWrite Sequen. Control Control Control Fetch Add PC 4 Read PC ALU Seq Add PC Extshift Read Dispatch 1 Remember: how to choose the next instruction Sequencing field = Seq Sequencing field = Fetch Sequencing field = Dispatch i (Access ROM i using the Opcode) 26

Creating the Microprogram Memory-Reference Instructions Step 3 (address calculation): LW and SW Step 4 (memory access): LW and SW Step 5 (write-back): only LW Label ALU SRC1 SRC2 Regist. Memory PCWrite Sequen. Control Control Control Mem1 Add A Extend Dispatch 2 LW2 Read ALU Seq Write MDR Fetch SW2 Write ALU Fetch 27

Creating the Microprogram R-type Instructions Step 3: ALU operation Step 4: Write-back Branch and Jump Instructions Step 3: Comparison and write next PC (branches) Step 3: Write next PC (jumps) Label ALU SRC1 SRC2 Regist. Memory PCWrite Sequen. Control Control Control Rformat1 FuncCode A B Seq Write ALU Fetch BEQ1 Subt A B ALUout cond JUMP1 Jump address Fetch Fetch 28

Complete Microprogram A symbolic representation of the control using just 10 microinstructions! Label ALU SRC1 SRC2 Regist. Memory PCWrite Sequen. Control Control Control Fetch Add PC 4 Read PC ALU Seq Add PC Extshft Read Dispatch 1 Mem1 Add A Extend Dispatch 2 LW2 Read ALU Seq Write MDR Fetch SW2 Write ALU Fetch Rformat1 FuncCode A B Seq Write ALU Fetch BEQ1 Subt A B ALUout Fetch cond JUMP1 Jump address Fetch 29

Implementing the Microprogram Translate each Microinstruction to the corresponding bit pattern of control signals (PLAs, ROMs, ) Use a Sequencer and a Microprogram Counter Control unit Microcode memory Input Outputs PCWrite PCWriteCond IorD MemRead MemWrite IRWrite BWrite MemtoReg PCSource ALUOp ALUSrcB ALUSrcA RegWrite RegDst AddrCtl Datapath 1 Microprogram counter Adder Address select logic Op[5 0] Instruction register opcode field 30

Summary We have seen the Multicycle Implementation The execution of an instruction is broken up into multiple steps Each step takes 1 shorter clock cycle Shared Functional Units We have modified the Datapath accordingly We implemented the Main Control Unit using either Finite State Machine Adequate for few instructions Microprogramming Symbolic representation of the control signals Easier to implement Now, let us see how to improve the Multicycle Implementation 31

End of Lecture 32