Computer Organization Lecture Set – 05.2 Chapter 5 Huei-Yung Lin.

Slides:



Advertisements
Similar presentations
1 Chapter Five The Processor: Datapath and Control.
Advertisements

Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 14 - Multi-Cycle.
The Processor Data Path & Control Chapter 5 Part 2 - Multi-Clock Cycle Design N. Guydosh 2/29/04.
Chapter 5 The Processor: Datapath and Control Basic MIPS Architecture Homework 2 due October 28 th. Project Designs due October 28 th. Project Reports.
EECE476 Lecture 9: Multi-cycle CPU Datapath Chapter 5: Section 5.5 The University of British ColumbiaEECE 476© 2005 Guy Lemieux.
CSE378 Multicycle impl,.1 Drawbacks of single cycle implementation All instructions take the same time although –some instructions are longer than others;
1 5.5 A Multicycle Implementation A single memory unit is used for both instructions and data. There is a single ALU, rather than an ALU and two adders.
Embedded Systems in Silicon TD5102 MIPS design Datapath and Control Henk Corporaal Technical University.
CSCE 212 Chapter 5 The Processor: Datapath and Control Instructor: Jason D. Bakos.
EECE476 Lectures 10: Multi-cycle CPU Control Chapter 5: Section 5.5 The University of British ColumbiaEECE 476© 2005 Guy Lemieux.
Preparation for Midterm Binary Data Storage (integer, char, float pt) and Operations, Logic, Flip Flops, Switch Debouncing, Timing, Synchronous / Asynchronous.
ENEE350 Ankur Srivastava University of Maryland, College Park Based on Slides from Mary Jane Irwin ( )
Advanced Computer Architecture 5MD00 / 5Z033 MIPS Design data path and control Henk Corporaal TUEindhoven 2007.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Multi-Cycle Processor.
331 W10.1Spring :332:331 Computer Architecture and Assembly Language Spring 2005 Week 10 Building a Multi-Cycle Datapath [Adapted from Dave Patterson’s.
1 The Processor: Datapath and Control We will design a microprocessor that includes a subset of the MIPS instruction set: –Memory access: load/store word.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Multi-Cycle Processor.
Dr. Iyad F. Jafar Basic MIPS Architecture: Multi-Cycle Datapath and Control.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Multi-Cycle Processor.
Computer Architecture Chapter 5 Fall 2005 Department of Computer Science Kent State University.
CPE232 Basic MIPS Architecture1 Computer Organization Multi-cycle Approach Dr. Iyad Jafar Adapted from Dr. Gheith Abandah slides
1 CS/COE0447 Computer Organization & Assembly Language Multi-Cycle Execution.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 15 - Multi-Cycle.
C HAPTER 5 T HE PROCESSOR : D ATAPATH AND C ONTROL M ULTICYCLE D ESIGN.
Gary MarsdenSlide 1University of Cape Town Stages.
1 Processor: Datapath and Control Single cycle processor –Datapath and Control Multicycle processor –Datapath and Control Microprogramming –Vertical and.
Multicycle Implementation
ECE-C355 Computer Structures Winter 2008 The MIPS Datapath Slides have been adapted from Prof. Mary Jane Irwin ( )
Fall 2015, Sep ELEC / Lecture 5 1 ELEC / Computer Architecture and Design Fall 2015 Datapath and Control (Chapter.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 16 - Multi-Cycle.
Datapath and Control AddressInstruction Memory Write Data Reg Addr Register File ALU Data Memory Address Write Data Read Data PC Read Data Read Data.
Multicycle datapath.
CDA 3101 Spring 2016 Introduction to Computer Organization Microprogramming and Exceptions 08 March 2016.
Computer Organization Lecture Set – 05.1 Chapter 5 Huei-Yung Lin.
Chapter 4 From: Dr. Iyad F. Jafar Basic MIPS Architecture: Multi-Cycle Datapath and Control.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 5 Part 3.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 5 Part 3 In-Class Exercises.
Computer Architecture Lecture 6.  Our implementation of the MIPS is simplified memory-reference instructions: lw, sw arithmetic-logical instructions:
Design a MIPS Processor (II)
Multi-Cycle Datapath and Control
Exceptions Another form of control hazard Could be caused by…
IT 251 Computer Organization and Architecture
Chapter 5 The Processor: Datapath and Control
Systems Architecture I
Multi-Cycle CPU.
Extensions to the Multicycle CPU
D.4 Finite State Diagram for the Multi-cycle processor
Multi-Cycle CPU.
CS/COE0447 Computer Organization & Assembly Language
Multiple Cycle Implementation of MIPS-Lite CPU
CSCE 212 Chapter 5 The Processor: Datapath and Control
Processor: Finite State Machine & Microprogramming
Computer Architecture
Chapter Five The Processor: Datapath and Control
Multicycle Approach Break up the instructions into steps
The Multicycle Implementation
CS/COE0447 Computer Organization & Assembly Language
Chapter Five The Processor: Datapath and Control
Drawbacks of single cycle implementation
The Multicycle Implementation
Systems Architecture I
Vishwani D. Agrawal James J. Danaher Professor
COSC 2021: Computer Organization Instructor: Dr. Amir Asif
Processor: Multi-Cycle Datapath & Control
Multi-Cycle Datapath Lecture notes from MKP, H. H. Lee and S. Yalamanchili.
Chapter Four The Processor: Datapath and Control
5.5 A Multicycle Implementation
Systems Architecture I
COMS 361 Computer Organization
CS161 – Design and Architecture of Computer Systems
Presentation transcript:

Computer Organization Lecture Set – 05.2 Chapter 5 Huei-Yung Lin

H.Y. Lin, CCUEE Computer Organization 2 Outline - Processor Implementation Overview Single-Cycle Implementation Multi-Cycle Implementation  1.Analyze instruction set; get datapath requirements 2.Select datapath components and establish clocking methodology 3.Assemble datapath that meets requirements 4.Determine control signal values for each instruction 5.Assemble control logic to generate control signals Pipelined Implementation

H.Y. Lin, CCUEE Computer Organization 3 Outline - Multicycle Design Overview  Datapath Design Controller Design Microprogramming Exceptions Performance Considerations

H.Y. Lin, CCUEE Computer Organization 4 Multicycle Execution - Key Idea Break instruction execution into multiple cycles One clock cycle for each major task 1.Instruction Fetch 2.Instruction Decode and Register Fetch 3.Execution, memory address computation, or branch computation 4.Memory access / R-type instruction completion 5.Memory read completion Share hardware to simplify datapath

H.Y. Lin, CCUEE Computer Organization 5 Characteristics of Multicycle Design Instructions take more than one cycle  Some instructions take more cycles than others  Clock cycle is shorter than single-cycle clock Reuse of major components simplifies datapath  Single ALU for all calculations  Single memory for instructions and data  But, added registers needed to store values across cycles Control Unit Implemented w/ State Machine  Control signals no longer a function of just the instruction

H.Y. Lin, CCUEE Computer Organization 6 (Equivalent to Book Fig. 5.25, p. 318) Multicycle Datapath - High-Level View

H.Y. Lin, CCUEE Computer Organization 7 Review: Steps in Processor Design 1.Analyze instruction set; get datapath requirements 2.Select datapath components and establish clocking methodology 3.Assemble datapath that meets requirements 4.Determine control signal values for each instruction 5.Assemble control logic to generate control signals

H.Y. Lin, CCUEE Computer Organization 8 Review: Register Transfers Instruction Fetch Instruction <= MEM[PC]; PC = PC + 4; Instruction Execution Instr.Register Transfers add R[rd] <= R[rs] + R[rt]; sub R[rd] <= R[rs] - R[rt]; and R[rd] <= R[rs] & R[rt]; or R[rd] <= R[rs] | R[rt]; lw R[rt] <= MEM[R[rs] + s_extend(offset)]; sw MEM[R[rs] + sign_extend(offset)] <= R[rt];PC <= PC + 4 beq if (R[rs] == R[rt]) then PC <- PC+4 + s_extend(offset<<2) else PC <= PC + 4 j PC <= << 2) Key idea: break into multiple cycles!

H.Y. Lin, CCUEE Computer Organization 9 Multicycle Execution Steps 1.Instruction Fetch 2.Instruction Decode and Register Fetch (and branch target calculation) 3.One of the following:  Execute R-Type Instruction OR  Calculate memory address for load/store OR  Perform comparison for branch 4.Memory access for load/store OR R-type instruction completion (save result) 5.Memory read completion (save result - load only)

H.Y. Lin, CCUEE Computer Organization 10 Summary - Multicycle Execution Instructions take between 3 and 5 clock cycles (Book Fig. 5.30, p. 329) (1) (2) (3) (4) (5) New registers needed to store values across clock steps!

H.Y. Lin, CCUEE Computer Organization 11 IR = Memory[PC]; PC = PC + 4; 4 PC + 4 Multicycle Execution Step (1) Instruction Fetch

H.Y. Lin, CCUEE Computer Organization 12 Multicycle Execution Step (2) Instruction Decode and Register Fetch A = Reg[IR[25-21]];(A = Reg[rs]) B = Reg[IR[20-15]];(B = Reg[rt]) ALUOut = (PC + sign-extend(IR[15-0]) << 2) Branch Target Address Reg[rs] Reg[rt] PC + 4

H.Y. Lin, CCUEE Computer Organization 13 Multicycle Execution Steps (3) Memory Reference Instructions ALUOut = A + sign-extend(IR[15-0]); Mem. Address Reg[rs] Reg[rt] PC + 4

H.Y. Lin, CCUEE Computer Organization 14 Multicycle Execution Steps (3) ALU Instruction (R-Type) ALUOut = A op B R-Type Result Reg[rs] Reg[rt] PC + 4

H.Y. Lin, CCUEE Computer Organization 15 Multicycle Execution Steps (3) Branch Instructions if (A == B) PC = ALUOut; Branch Target Address Reg[rs] Reg[rt] Branch Target Address

H.Y. Lin, CCUEE Computer Organization 16 Multicycle Execution Step (3) Jump Instruction PC = PC[31-28] concat (IR[25-0] << 2) Jump Address Reg[rs] Reg[rt] Branch Target Address

H.Y. Lin, CCUEE Computer Organization 17 Multicycle Execution Steps (4) Memory Access - Read (lw) MDR = Memory[ALUOut]; Mem. Data PC + 4 Reg[rs] Reg[rt] Mem. Address

H.Y. Lin, CCUEE Computer Organization 18 Multicycle Execution Steps (4) Memory Access - Write (sw) Memory[ALUOut] = B; PC + 4 Reg[rs] Reg[rt]

H.Y. Lin, CCUEE Computer Organization 19 Multicycle Execution Steps (4) ALU Instruction (R-Type) Reg[IR[15:11]] = ALUOUT R-Type Result Reg[rs] Reg[rt] PC + 4

H.Y. Lin, CCUEE Computer Organization 20 Multicycle Execution Steps (5) Memory Read Completion (lw) Reg[IR[20-16]] = MDR; PC + 4 Reg[rs] Reg[rt] Mem. Data Mem. Address

H.Y. Lin, CCUEE Computer Organization 21 Summary - Multicycle Execution Instructions take between 3 and 5 clock cycles (Book Fig. 5.30, p. 329)

H.Y. Lin, CCUEE Computer Organization 22 Full Multicycle Datapath (Equivalent to Book Fig. 5.27, p. 322 without ALU control)

H.Y. Lin, CCUEE Computer Organization 23 Full Multicycle Implementation (Equivalent to Book Fig. 5.28, p. 323)

H.Y. Lin, CCUEE Computer Organization 24 Review: Steps in Processor Design 1.Analyze instruction set; get datapath requirements 2.Select datapath components and establish clocking methodology 3.Assemble datapath that meets requirements 4.Determine control signal values for each instruction 5.Assemble control logic to generate control signals

H.Y. Lin, CCUEE Computer Organization 25 Multicycle Execution Step (1) Fetch IR = Memory[PC]; PC = PC + 4; X 0 X

H.Y. Lin, CCUEE Computer Organization 26 Multicycle Execution Step (2) Instruction Decode and Register Fetch A = Reg[IR[25-21]];(A = Reg[rs]) B = Reg[IR[20-15]];(B = Reg[rt]) ALUOut = (PC + sign-extend(IR[15-0]) << 2) 0 0 X 0 0 X 3 0 X X 010 0

H.Y. Lin, CCUEE Computer Organization 27 0 X Multicycle Execution Steps (3) Memory Reference Instructions ALUOut = A + sign-extend(IR[15-0]); X X 0 1 X 010 0

H.Y. Lin, CCUEE Computer Organization 28 Multicycle Execution Steps (3) ALU Instruction (R-Type) ALUOut = A op B 0 X X X 0 1 X ??? 0

H.Y. Lin, CCUEE Computer Organization 29 1 if Zero=1 Multicycle Execution Steps (3) Branch Instructions if (A == B) PC = ALUOut; 0 X X 0 0 X

H.Y. Lin, CCUEE Computer Organization 30 Multicycle Execution Step (3) Jump Instruction PC = PC[21-28] concat (IR[25-0] << 2) 0 X X X 0 1 X 0 X 2 XXX 0

H.Y. Lin, CCUEE Computer Organization 31 Multicycle Execution Steps (4) Memory Access - Read (lw) MDR = Memory[ALUOut]; 0 X X X X X XXX 0

H.Y. Lin, CCUEE Computer Organization 32 Multicycle Execution Steps (4) Memory Access - Write (sw) Memory[ALUOut] = B; 0 X X X X X XXX 0

H.Y. Lin, CCUEE Computer Organization X 0 X 0 XXX X X 1 1 Multicycle Execution Step (4) ALU Instruction (R-Type) Reg[IR[15:11]] = ALUOut;(Reg[Rd] = ALUOut)

H.Y. Lin, CCUEE Computer Organization 34 Multicycle Execution Steps (5) Memory Read Completion (lw) Reg[IR[20-16]] = MDR; X 0 0 X 0 X X XXX 0

H.Y. Lin, CCUEE Computer Organization 35 Review: Steps in Processor Design 1.Analyze instruction set; get datapath requirements 2.Select datapath components and establish clocking methodology 3.Assemble datapath that meets requirements 4.Determine control signal values for each instruction 5.Assemble control logic to generate control signals

H.Y. Lin, CCUEE Computer Organization 36 Full Multicycle Implementation

H.Y. Lin, CCUEE Computer Organization 37 Multicycle Control Unit Review: single-cycle implementation  All control signals can be determined by current instruction + condition  Implemented in combinational logic Multicycle implementation is different  Control signals depend on current instruction which clock cycle is currently being executed  Implemented as Finite State Machine (FSM) OR Microprogrammed Implementation - “ stylized FSM ”

H.Y. Lin, CCUEE Computer Organization 38 Review - Finite State Machines What’s in the Finite State Machine  Combinational Logic  Storage Elements (Flip-flops) Inputs Outputs Current State Next State

H.Y. Lin, CCUEE Computer Organization 39 Review - Finite State Machines Behavior characterized by  States - unique values of flip-flops e.g., “ 101 ”  Transitions between states, depending on current state inputs  Output values, depending on current state inputs Describing FSMs:  State Diagrams  State Transition Tables

H.Y. Lin, CCUEE Computer Organization 40 Review - State Diagrams "Bubbles" - states Arrows - transition edges labeled with condition expressions Example: Car Alarm arm door honk clk f clk = 1Hz IDLE BEEP Honk=1 WAIT ARMDOOR ARM ARM’ ARM’ + ARMDOOR’ = ARM’ + DOOR’

H.Y. Lin, CCUEE Computer Organization 41 State Transition Table Transition List - lists edges in State Diagram PSConditionNSOutput IDLEARM' + DOOR'IDLE0 IDLEARM*DOORBEEP0 BEEPARMWAIT1 BEEPARM'IDLE1 WAITARMBEEP0 WAITARM'IDLE0 IDLE BEEP Honk=1 WAIT ARMDOOR ARM ARM’ ARM’ + ARMDOOR’ = ARM’ + DOOR’

H.Y. Lin, CCUEE Computer Organization 42 State Machine Design Traditional Approach:  Create State Diagram  Create State Transition Table  Assign State Codes  Write Excitation Equations & Minimize Modern Approach  Enter FSM Description into CAD program  Synthesize implementation of FSM

H.Y. Lin, CCUEE Computer Organization 43 FSM Control Unit Implementation FSM Inputs:  Clock  Instruction register op field FSM Outputs: control signals for datapath  Enable signals: Register file, Memory, PC, MDR, and IR  Multiplexer signals: ALUSrcA, ALUSrcB, etc.  ALUOp signal - used for ALU Control as in single-cycle implementation

H.Y. Lin, CCUEE Computer Organization 44 Enable Control Signals  Asserted (true) in a state if they appear in the state bubble  Assumed Deasserted (false) in a state if they do not appear in the state bubble Multiplexer/ALU Control Signals  Asserted with a given value in a state if they appear in a state bubble  Assumed Don ’ t Care if they do not appear in the state bubble See Figures MemRead IorD = 0 Memory access (Op=‘LW’) Enable signal Multiplexer signal State name Transition from previous state (conditioanl) Transition to next state (unconditioanl) Describing Controller Function in State Diagrams - Conventions

H.Y. Lin, CCUEE Computer Organization 45 Multicycle Control - Full State Diagram

H.Y. Lin, CCUEE Computer Organization 46 State 8 Branch State (OP = ‘BEQ’) State 6 Execution States (OP = ‘R-Type’) State 2 Mem. Ref States (Op = ‘LW’ or Op = ‘SW’) MemRead ALUSrcA = 0 IorD = 0 IRWrite ALUSrcB = 01 ALUOp = 00 PCWrite PCSource = 00 State 0 Instruction Fetch Start State 1 Instruction Decode / Register Fetch State 9 Jump State (OP = ‘J’) ALUSrcA = 0 ALUSrcB = 11 ALUOp = 00 Control FSM - Instruction Fetch / Decode States

H.Y. Lin, CCUEE Computer Organization 47 (OP = ‘LW’) State 3 Memory Access State 4 Write-back step State 5 Memory Access (OP = ‘SW’) Memory Address ComputationState 2 from State 1 (OP = ‘LW’ OR OP = ‘SW’) to State 0 ALUSrcA = 1 ALUSrcB = 10 ALUOp = 00 MemRead IorD = 1 MemWrite IorD = 1 RegWrite MemToReg=1 RegDst = 0 Control FSM - Memory Reference States

H.Y. Lin, CCUEE Computer Organization 48 Control FSM - R-Type States State 7 R-type completion to State 0 State 6 from State 1 (OP = R-Type) Execution ALUSrcA = 1 ALUSrcB = 00 ALUOp = 10 RegDst = 1 RegWrite MemtoReg = 0

H.Y. Lin, CCUEE Computer Organization 49 Control FSM - Branch State State 8 Branch Completion from State 1 (OP = ‘BEQ’) to State 0 ALUSrcA = 1 ALUSrcB = 00 ALUOp = 01 PCWriteCond PCSource = 01

H.Y. Lin, CCUEE Computer Organization 50 Control FSM - Jump State State 9 Jump Completion from State 1 (OP = ‘J’) to State 0 PCWrite PCSource = 10

H.Y. Lin, CCUEE Computer Organization 51 Controller Implementation Typical Implementation: Figure 5-37, p. 338 Variations  Random logic  PLA  ROM address lines = inputs data lines = outputs contents = “truth table” Datapath control outputs Inputs from Instr. Reg (opcode) Combinational Control Logic State Next State

H.Y. Lin, CCUEE Computer Organization 52 What is the CPI of the Multicycle Implementation? Using measured instruction mix from SPECINT2000 lw5 cycles25% sw4 cycles10% R-type4 cycles52% branch3 cycles11% jump3 cycles2% What is the CPI?  CPI = (5 cycles * 0.25) + (4 cycles * 0.10) + (4 cycles * 0.53) + (3 cycles * 0.11) + (3 cycles * 0.02)  CPI = 4.12 cycles per instruction Performance of a Multicycle Implementation

H.Y. Lin, CCUEE Computer Organization 53 Performance Continued Assuming a 200ps clock, what is average execution time/instruction?  Sec/Instr = 4.12 CPI * 200ps/cycle) = 824ps/instr How does this compare to the Single-Cycle Case?  Sec/Instr = 1 CPI * 600ps/cycle = 600ps/instr  Single-Cycle is 1.38 times faster than Multicycle Why is Single-Cycle faster than Multicycle?  Branch & jump are the same speed (600ps vs 600ps)  R-type & store are faster (600ps vs 800ps)  Load word is faster (600ps vs 1000ps)

H.Y. Lin, CCUEE Computer Organization 54 Multicycle Example Problem Extend the design to implement the “jr” (jump register) instruction: jr rsPC = Reg[rs] Format: Steps: 1.Review instruction requirements (register transfer) 2.Modify datapath 3.Modify control logic 0 rs bits5 bits 6 bits

H.Y. Lin, CCUEE Computer Organization 55 Reg[rs] Example Problem: Datapath What needs to be changed?

H.Y. Lin, CCUEE Computer Organization 56 Example Problem: Control What needs to be changed? PCWrite PCSource = 11 (OP = ‘JR‘)

H.Y. Lin, CCUEE Computer Organization 57 Exceptions - “ Stuff Happens ” Definition: "unexpected change in control flow" Used to handle runtime errors  Overflow  Undefined Instruction  Hardware malfunction Used to handle external events, "service" functions  Interrupts - external I/O Device request  Page fault - virtual memory  System call - user request for OS action

H.Y. Lin, CCUEE Computer Organization 58 Example: Undefined Instructions (OP ≠ R-Type OP≠LW, OP–W, OP≠BEQ) What happens here ????

H.Y. Lin, CCUEE Computer Organization 59 What Happens During an Exception Save user state – register values, etc. Take action to handle exception Restore user state and continue execution if possible (e.g., emulate undefined instr.) Exception: undefined instruction Return from exception user program add.s f0,f1,f2 srl r1,r2,2 beq r0,r1,L sub r5,r3,r2 add r5,r4,r3 bne r4,r3,L2 add r3,r1,r2 Exception Handler (System) rfe

H.Y. Lin, CCUEE Computer Organization 60 Two exceptions (for now):  Undefined instruction  Arithmetic overflow Add registers to architecture to save state  EPC - Exception Program Counter (32 bits)  Cause - records cause of exception (32 bits) Undefined instruction: Cause <- 0 Arithmetic overflow: Cause <- 1 Alternatives used by other architectures Save PC on stack Communicate exception type using Exception Vector Adding Exceptions to the Multicycle Processor

H.Y. Lin, CCUEE Computer Organization 61 Implementing Exceptions Add datapath components - Figure 5.39  ExceptionPC (EPC) - stores PC of offending instruction  Cause Register - records the cause of the exception Modify control - Figures 5.40  Undefined Instruction - state 1 (Instruction decode)  Overflow - state 7 (R-type completion)

H.Y. Lin, CCUEE Computer Organization 62 Implementing Exceptions Datapath modifications  Calculate address of offending instruction (PC-4) and store in EPC  Store 0 or 1 in Cause  Add overflow output from ALU (described in Ch. 4)  Assign " hex " to PC - fixed location of handler Control modifications  Undefined instruction: add ” default" branch to Instruction Fetch state  Overflow: test after execution state for R-type instructions

H.Y. Lin, CCUEE Computer Organization 63 Adding Exception Support to Datapath

H.Y. Lin, CCUEE Computer Organization 64 IntCause = 0 CauseWrite ALUSrcA = 0 ALUSrcB = 01 ALUOp = 01 EPCWRITE PCWrite PCSource=11 State 10 Undefined Instruction State 0 ALUSrcA = 0 ALUSrcB = 11 ALUOp = 00 State 1 Instruction Decode / Register Fetch State 9 Jump State State 8 Branch State State 6 Execution States State 2 Mem. Ref States (OP = ‘J’) (OP = ‘BEQ’) (OP = ‘R-Type’) (Op = ‘LW’ or Op = ‘SW’) from State 0 (OP = Other) Adding Exception Support to Control - Undefined Instruction

H.Y. Lin, CCUEE Computer Organization 65 IntCause = 1 CauseWrite ALUSrcA = 0 ALUSrcB = 01 ALUOp = 01 EPCWRITE PCWrite PCSource=11 State 10 Overflow State 0 Overflow Note: requires storage of overflow condition from previous state ALUSrcA = 1 ALUSrcB = 00 ALUOp = 10 State 6 RegDst = 1 RegWrite MemtoReg = 0 State 7 R-type completion from State 1 (OP = R-Type) to State 0 Execution No Overflow Adding Exception Support to Control - Arithmetic Overflow

H.Y. Lin, CCUEE Computer Organization 66 What Makes Exceptions Hard The “ real ” MIPS architecture requires that instruction causing exception must have "no effect" Implication: undo effects of instruction  decrement PC  prevent storage of result during R-type instruction What about “ recursive ” exceptions?  Must add instructions to save exception registers on stack  Disable exceptions / interrupts until registers saved  More details in Appendix A (A.7)

H.Y. Lin, CCUEE Computer Organization 67 Summary - Exceptions Must consider as part of overall design Must find "convenient" places to detect exceptions Must find way to cleanly return from exception Must keep control “ small and fast ” Much harder in pipelined implementations!