EECC550 - Shaaban #1 Lec # 6 Spring2000 3-27-2000 Control may be designed using one of several initial representations. The choice of sequence control,

Slides:



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

CS 152 Computer Architecture and Engineering Lecture 9 Multiprogramming and Exceptions February 25, 2004 John Kubiatowicz (
ECE 232 L15.Microprog.1 Adapted from Patterson 97 ©UCBCopyright 1998 Morgan Kaufmann Publishers ECE 232 Hardware Organization and Design Lecture 15 Microprogrammed.
CS152 / Kubiatowicz Lec11.1 3/05/03©UCB Spring 2003 CS 152 Computer Architecture and Engineering Lecture 11 Multicycle Controller Design March 5, 2003.
Chapter 5 The Processor: Datapath and Control Basic MIPS Architecture Homework 2 due October 28 th. Project Designs due October 28 th. Project Reports.
CS152 / Kubiatowicz Lec10.1 3/1/99©UCB Spring 1999 Alternative datapath (book): Multiple Cycle Datapath °Miminizes Hardware: 1 memory, 1 adder Ideal Memory.
EECC550 - Shaaban #1 Lec # 5 Winter CPU Design Steps 1. Analyze instruction set operations using independent ISA => RTN => datapath requirements.
EECC550 - Shaaban #1 Lec # 5 Winter CPU Design Steps 1. Analyze instruction set operations using independent RTN => datapath requirements.
EECC550 - Shaaban #1 Lec # 5 Winter CPU Design Steps 1. Analyze instruction set operations using independent RTN => datapath requirements.
Adapted from the lecture notes of John Kubiatowicz (UCB)
Pipeline Exceptions & ControlCSCE430/830 Pipeline: Exceptions & Control CSCE430/830 Computer Architecture Lecturer: Prof. Hong Jiang Courtesy of Yifeng.
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 ( )
ECE 232 L16.Microprog.1 Adapted from Patterson 97 ©UCBCopyright 1998 Morgan Kaufmann Publishers ECE 232 Hardware Organization and Design Lecture 16 Microprogrammed.
CS152 / Kubiatowicz Lec /03/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 10 Multicycle Controller Design (Continued) October.
CS152 Lec11.1 CS 152 Computer Architecture and Engineering Lecture 11 Multicycle Controller Design (Continued)
EE30332 Ch5 Ext - DP.1 Ch 5 The Processor: Datapath and Control  The state digrams that arise define the controller for an instruction set processor are.
Class 9.1 Computer Architecture - HUJI Computer Architecture Class 9 Microprogramming.
EECC550 - Shaaban #1 Lec # 6 Winter Control may be designed using one of several initial representations. The choice of sequence control,
CS152 / Kubiatowicz Lec /05/01©UCB Fall 2001 CS 152 Computer Architecture and Engineering Lecture 11 Multicycle Controller Design October 5, 2001.
EECC550 - Shaaban #1 Lec # 5 Spring CPU Design Steps 1. Analyze instruction set operations using independent RTN => datapath requirements.
CPSC 321 Computer Architecture and Engineering Lecture 8 Designing a Multicycle Processor Instructor: Rabi Mahapatra & Hank Walker Adapted from the lecture.
ECE 232 L23.Exceptions.1 Adapted from Patterson 97 ©UCBCopyright 1998 Morgan Kaufmann Publishers ECE 232 Hardware Organization and Design Lecture 23 Exceptions.
Dr. Iyad F. Jafar Basic MIPS Architecture: Multi-Cycle Datapath and Control.
What are Exception and Interrupts? MIPS terminology Exception: any unexpected change in the internal control flow – Invoking an operating system service.
CS4100: 計算機結構 Designing a Multicycle Processor 國立清華大學資訊工程學系 九十六學年度第一學期 Adapted from class notes of D. Patterson and W. Dally Copyright 1998, 2000 UCB.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Multi-Cycle Processor.
COSC 3430 L08 Basic MIPS Architecture.1 COSC 3430 Computer Architecture Lecture 08 Processors Single cycle Datapath PH 3: Sections
CS/EE 362 multicontroller..1 ©DAP & SIK 1995 CS/EE 362 Hardware Fundamentals Lecture 15: Designing a Multi-Cycle Controller (Chapter 5: Hennessy and Patterson)
ECS154B Computer Architecture Multicycle Controller Design
1 Computer Organization & Design Microcode for Control Sec. 5.7 (CDROM) Appendix C (CDROM) / / pdf / lec_3a_notes.pdf.
CPE232 Basic MIPS Architecture1 Computer Organization Multi-cycle Approach Dr. Iyad Jafar Adapted from Dr. Gheith Abandah slides
Exam 2 Review Two’s Complement Arithmetic Ripple carry ALU logic and performance Look-ahead techniques Basic multiplication and division ( non- restoring)
C HAPTER 5 T HE PROCESSOR : D ATAPATH AND C ONTROL M ULTICYCLE D ESIGN.
Computer Architecture and Design – ECEN 350 Part 6 [Some slides adapted from A. Sprintson, M. Irwin, D. Paterson and others]
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.
CS152 Lec12.1 CS 152 Computer Architecture and Engineering Lecture 12 Multicycle Controller Design Exceptions.
Overview of Control Hardware Development
Multicycle Implementation
CMCS Computer Architecture Lecture 16 Micro-programming & Exceptions April 2, CMSC411.htm Mohamed Younis.
Chapter 4 From: Dr. Iyad F. Jafar Basic MIPS Architecture: Single-Cycle Datapath and Control.
CDA 3101 Spring 2016 Introduction to Computer Organization Microprogramming and Exceptions 08 March 2016.
Chapter 4 From: Dr. Iyad F. Jafar Basic MIPS Architecture: Multi-Cycle Datapath and Control.
Computer Architecture Lecture 6.  Our implementation of the MIPS is simplified memory-reference instructions: lw, sw arithmetic-logical instructions:
Design a MIPS Processor (II)
Chapter 5: A Multi-Cycle CPU.
CS 152: Computer Architecture and Engineering Lecture 11 Multicycle Controller Design Exceptions Randy H. Katz, Instructor Satrajit Chatterjee, Teaching.
IT 251 Computer Organization and Architecture
/ Computer Architecture and Design
Systems Architecture I
Extensions to the Multicycle CPU
CS/COE0447 Computer Organization & Assembly Language
CSCE 212 Chapter 5 The Processor: Datapath and Control
Processor: Finite State Machine & Microprogramming
Computer Architecture
The Multicycle Implementation
Chapter Five The Processor: Datapath and Control
The Multicycle Implementation
Systems Architecture I
CpE 442 Microprogramming and Exceptions
Vishwani D. Agrawal James J. Danaher Professor
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
Systems Architecture I
Alternative datapath (book): Multiple Cycle Datapath
Control Implementation Alternatives For Multi-Cycle CPUs
COMS 361 Computer Organization
Processor: Datapath and Control
Presentation transcript:

EECC550 - Shaaban #1 Lec # 6 Spring Control may be designed using one of several initial representations. The choice of sequence control, and how logic is represented, can then be determined independently; the control can then be implemented with one of several methods using a structured logic technique. Initial Representation Finite State Diagram Microprogram Sequencing Control Explicit Next State Microprogram counter Function + Dispatch ROMs Logic Representation Logic Equations Truth Tables Implementation PLAROM Technique “hardwired control”“microprogrammed control” Control Implementation Alternatives

EECC550 - Shaaban #2 Lec # 6 Spring Alternative datapath (Textbook): Multiple Cycle Datapath

EECC550 - Shaaban #3 Lec # 6 Spring Operations In Each Cycle Instruction Fetch Instruction Decode Execution Memory Write Back R-Type IR  Mem[PC] PC  PC + 4 A  R[rs] B  R[rt] ALUout  PC + (SignExt(imm16) x4) ALUout  A + B R[rd]  ALUout Logic Immediate IR  Mem[PC] PC  PC + 4 A  R[rs] B  R[rt] ALUout  PC + (SignExt(imm16) x4) ALUout  A OR ZeroExt[imm16] R[rt]  ALUout Load IR  Mem[PC] PC  PC + 4 A  R[rs] B  R[rt] ALUout  PC + (SignExt(imm16) x4) ALUout   A + SignEx(Im16) M  Mem[ALUout] R[rd]  Mem Store IR  Mem[PC] PC  PC + 4 A  R[rs] B  R[rt] ALUout  PC + (SignExt(imm16) x4) ALUout  A + SignEx(Im16) Mem[ALUout]  B Branch IR  Mem[PC] PC  PC + 4 A  R[rs] B  R[rt] ALUout  PC + (SignExt(imm16) x4) If Equal = 1 PC  ALUout

EECC550 - Shaaban #4 Lec # 6 Spring Finite State Machine (FSM) Specification Finite State Machine (FSM) Specification IR  MEM[PC] PC  PC + 4 R-type ALUout  A fun B R[rd]  ALUout ALUout  A op ZX R[rt]  ALUout ORi ALUout  A + SX R[rt]  M M  MEM[ALUout] LW ALUout  A + SX MEM[ALUout]  B SW “instruction fetch” “decode” Execute Memory Write-back BEQ 0010 If A = B then PC  ALUout A  R[rs] B  R[rt] ALUout  PC +SX To instruction fetch

EECC550 - Shaaban #5 Lec # 6 Spring Microprogrammed Control Finite state machine control for a full set of instructions is very complex, and may involve a very large number of states: –Slight microoperation changes require new FSM controller. Microprogramming: Designing the control as a program that implements the machine instructions. A microprogam for a given machine instruction is a symbolic representation of the control involved in executing the instruction and is comprised of a sequence of microinstructions. Each microinstruction defines the set of datapath control signals that must asserted (active) in a given state or cycle. The format of the microinstructions is defined by a number of fields each responsible for asserting a set of control signals. Microarchitecture: –Logical structure and functional capabilities of the hardware as seen by the microprogrammer.

EECC550 - Shaaban #6 Lec # 6 Spring A Typical Microcode Controller Implementation ROM/ PLA

EECC550 - Shaaban #7 Lec # 6 Spring “Macroinstruction” Interpretation Main Memory execution unit control memory CPU ADD SUB AND DATA User program plus Data AND microsequence e.g., Fetch Calc Operand Addr Fetch Operand(s) Calculate Save Answer(s) one of these is mapped into one of these Microprogram Storage

EECC550 - Shaaban #8 Lec # 6 Spring Variations on Microprogram Formats “Horizontal” Microcode: –A control field for each control point in the machine. “Vertical” Microcode: –A Compact microinstruction format for each class of control points. –Local decode is used to generate all control points. µseq µaddr A-mux B-mux bus enables register enables Horizontal Vertical

EECC550 - Shaaban #9 Lec # 6 Spring More Vertical Microprogram Formats src dst DECDEC DECDEC other control fields next statesinputs MUX Multiformat Microcode: condnext address 1dstsrcalu DECDEC DECDEC Branch Jump Register Xfer Operation

EECC550 - Shaaban #10 Lec # 6 Spring Microinstruction Format/Addressing Start with list of all control signals. Partition control signals with similar functions into a number of signal sets that share a single microinstruction field. A sequencing microinstruction field is used to indicate the next microinstruction to execute. Places fields in some logical order (e.g., ALU operation & ALU operands first and microinstruction sequencing last). Since microinstructions are placed in a ROM or PLA, addresses must be assigned to microinstructions, usually sequentially. Create a symbolic legend for the microinstruction format, showing name of field values and how they set the control signals. To minimize microinstruction width, operations that will never be used at the same time may be encoded.

EECC550 - Shaaban #11 Lec # 6 Spring Next Microinstruction Selection The next microinstruction to execute can be found by using the sequencing field: –Branch to a microinstruction that begins execution of the next MIPS instruction. “Fetch” is placed in the sequencing field. –Increment the address of the current instruction. Indicated in the microinstruction by putting “Seq” in the sequencing field. –Choose the next microinstruction based on the control unit input (a dispatch). Dispatches are implemented by a look-up table stored in a ROM containing addresses of target microinstruction. The table is indexed by the control unit input. A dispatch operation is indicated by placing “Dispatch i” in the sequencing field; i is the dispatch table number.

EECC550 - Shaaban #12 Lec # 6 Spring Types of “branching” Set state to 0 (fetch) Dispatch i (state 1) Use incremented address (seq) state number 2 Opcode State Reg Microinstruction Address Inputs Outputs Control Signal Fields Microprogram Storage ROM/PLA Multicycle Datapath 1 Address Select Logic Adder Microprogram Counter, MicroPC Sequencing Control Field Microprogrammed Control Unit

EECC550 - Shaaban #13 Lec # 6 Spring Next State Function: Sequencing Field For next state function (next microinstruction address): Signal NameValueEffect Sequencing Fetch 00Next µaddress = 0 Dispatch i 01Next µaddress = dispatch ROM Seq 10Next µaddress = µaddress + 1 Opcode microPC 1 µAddress Select Logic Adder ROM Mux Microprogram Storage Dispatch ROM

EECC550 - Shaaban #14 Lec # 6 Spring List of control Signals Grouped Into Fields Signal nameEffect when deassertedEffect when asserted ALUSelA1st ALU operand = PC1st ALU operand = Reg[rs] RegWriteNoneReg. is written MemtoRegReg. write data input = ALUReg. write data input = memory RegDstReg. dest. no. = rtReg. dest. no. = rd MemReadNoneMemory at address is read, MDR  Mem[addr] MemWriteNoneMemory at address is written IorDMemory address = PCMemory address = S IRWriteNoneIR  Memory PCWriteNonePC  PCSource PCWriteCond NoneIF ALUzero then PC  PCSource PCSource PCSource = ALU PCSource = ALUout Single Bit Control Signal nameValueEffect ALUOp00ALU adds 01ALU subtracts 10ALU does function code 11ALU does logical OR ALUSelB0002nd ALU input = Reg[rt] 0012nd ALU input = nd ALU input = sign extended IR[15-0] 0112nd ALU input = sign extended, shift left 2 IR[15-0] 1002nd ALU input = zero extended IR[15-0] Multiple Bit Control

EECC550 - Shaaban #15 Lec # 6 Spring Microinstruction Format Field Name Width Control Signals Set wide narrow ALU Control 42ALUOp SRC1 21ALUSelA SRC2 53ALUSelB Destination 32 RegWrite, MemtoReg, RegDst Memory 43MemRead, MemWrite, IorD Memory Register 11IRWrite PCWrite Control 43PCWrite, PCWriteCond, PCSource Sequencing 32AddrCtl Total width 2617bits

EECC550 - Shaaban #16 Lec # 6 Spring Microinstruction Field Values Field NameValues for FieldFunction of Field with Specific Value ALUAddALU adds Subt. ALU subtracts Func codeALU does function code OrALU does logical OR SRC1PC1st ALU input = PC rs1st ALU input = Reg[rs] SRC242nd ALU input = 4 Extend2nd ALU input = sign ext. IR[15-0] Extend02nd ALU input = zero ext. IR[15-0] Extshft2nd ALU input = sign ex., sl IR[15-0] rt2nd ALU input = Reg[rt] destinationrd ALUReg[rd]  ALUout rt ALUReg[rt]  ALUout rt Mem Reg[rt]  Mem MemoryRead PCRead memory using PC Read ALURead memory using ALU output Write ALUWrite memory using ALU output, value B Memory registerIRIR  Mem PC writeALUPC  ALU ALUoutCondIF ALU Zero then PC  ALUout SequencingSeqGo to sequential µinstruction FetchGo to the first microinstruction Dispatch iDispatch using ROM.

EECC550 - Shaaban #17 Lec # 6 Spring Instruction Fetch/decode Microcode Sequence LabelALU SRC1SRC2Dest.MemoryMem. Reg. PC Write Sequencing Fetch:AddPC4Read PCIRALUSeq AddPCExtshftDispatch First microinstruction: Fetch, increment PC Field NameValue for FieldFunction of Field ALUAddALU adds SRC1PC1st ALU input = PC SRC242nd ALU input = 4 MemoryRead PCRead memory using PC Memory registerIRIR  Mem PC writeALUPC  ALU SequencingSeqGo to sequential µinstruction Second microinstruction: Decode, calculate branch address Field NameValue for FieldFunction of Field ALUAddALU adds result in ALUout SRC1PC1st ALU input = PC SRC2Extshft2nd ALU input = sign ex., sl IR[15-0] SequencingDispatch Dispatch using ROM according to opcode

EECC550 - Shaaban #18 Lec # 6 Spring LW Completion Microcode Sequence LabelALU SRC1SRC2Dest.MemoryMem. Reg. PC Write Sequencing Lw:AddrsExtend Seq Read ALU Seq rt MEM Fetch First microinstruction: Execute, effective memory address calculation Second microinstruction: Memory, read using ALUout Third microinstruction: Write Back, from memory to register rt Field NameValue for FieldFunction of Field ALUAddALU adds, result in ALUout SRC1rs1st ALU input = Reg[rs] SRC2Extend2nd ALU input = sign ext. IR[15-0] SequencingSeqGo to sequential µinstruction Field NameValues for FieldFunction of Field MemoryRead ALURead memory using ALU output SequencingSeqGo to sequential µinstruction Field NameValues for FieldFunction of Field destinationrt Mem Reg[rt]  Mem SequencingFetchGo to the first microinstruction (fetch)

EECC550 - Shaaban #19 Lec # 6 Spring SW Completion Microcode Sequence LabelALU SRC1SRC2Dest.MemoryMem. Reg. PC Write Sequencing Sw:AddrsExtendSeq Write ALUFetch First microinstruction: Execute, effective memory address calculation Field NameValue for FieldFunction of Field ALUAddALU adds result in ALUout SRC1rs1st ALU input = Reg[rs] SRC2Extend2nd ALU input = sign ext. IR[15-0] SequencingSeqGo to sequential µinstruction Second microinstruction: Memory, write to memory Field NameValues for FieldFunction of Field Memory Write ALUWrite memory using ALU output, value B Sequencing FetchGo to the first microinstruction (fetch)

EECC550 - Shaaban #20 Lec # 6 Spring R-Type Completion Microcode Sequence LabelALU SRC1SRC2Dest.MemoryMem. Reg. PC Write Sequencing Rtype:FuncrsrtSeq rd ALUFetch First microinstruction: Execute, perform ALU function Second microinstruction: Write Back, ALU result in register rd Field NameValues for FieldFunction of Field destinationrd ALUReg[rd]  ALUout SequencingFetchGo to the first microinstruction (fetch) Field NameValue for FieldFunction of Field ALUFunc codeALU does function code SRC1rs1st ALU input = Reg[rs] SRC2rt2nd ALU input = Reg[rt] SequencingSeqGo to sequential µinstruction

EECC550 - Shaaban #21 Lec # 6 Spring BEQ Completion Microcode Sequence LabelALU SRC1SRC2Dest.MemoryMem. Reg. PC Write Sequencing Beq:Subt.rsrt ALUoutCond.Fetch Field NameValues for FieldFunction of Field ALUSubt. ALU subtracts SRC1rs1st ALU input = Reg[rs] SRC2rt2nd ALU input = Reg[rt] PC writeALUoutCondIF ALU Zero then PC  ALUout SequencingFetchGo to the first microinstruction (fetch) First microinstruction: Execute, compute condition, update PC

EECC550 - Shaaban #22 Lec # 6 Spring ORI Completion Microcode Sequence LabelALU SRC1SRC2Dest.MemoryMem. Reg. PC Write Sequencing Ori:Orrs Extend0 Seq rt ALUFetch First microinstruction: Execute, rs OR immediate Second microinstruction: Write Back, ALU result in register rt Field NameValues for FieldFunction of Field destinationrt ALUReg[rt]  ALUout SequencingFetchGo to the first microinstruction (fetch) Field NameValue for FieldFunction of Field ALUOrALU does logical OR result in ALUout SRC1rs1st ALU input = Reg[rs] SRC2Extend02nd ALU input = zero ext. IR[15-0] SequencingSeqGo to sequential µinstruction

EECC550 - Shaaban #23 Lec # 6 Spring Microprogram for The Control Unit LabelALU SRC1SRC2Dest.MemoryMem. Reg. PC Write Sequencing Fetch:AddPC4Read PCIRALUSeq AddPCExtshftDispatch Lw:AddrsExtend Seq Read ALU Seq rt MEM Fetch Sw:AddrsExtendSeq Write ALUFetch Rtype:FuncrsrtSeq rd ALUFetch Beq:Subt.rsrt ALUoutCond.Fetch Ori:Orrs Extend0 Seq rt ALUFetch

EECC550 - Shaaban #24 Lec # 6 Spring Microprogramming Pros and Cons Ease of design. Flexibility: –Easy to adapt to changes in organization, timing, technology. –Can make changes late in design cycle, or even in the field. Can implement very powerful instruction sets (just more microprogram control memory is needed). Generality: –Can implement multiple instruction sets on the same machine. –Can tailor instruction set to application. Compatibility: –Many organizations, same instruction set. Possibly more costly to implement than FSM control. Slower than FSM control.

EECC550 - Shaaban #25 Lec # 6 Spring Exceptions Handling in MIPS Exceptions: Events Other than branches or jumps that change the normal flow of instruction execution. Two main types: Interrupts, Traps. –An interrupt usually comes from outside the processor (I/O devices) to get the CPU’s attention to start a service routine. –A trap usually originates from an event within the CPU (Arithmetic overflow, undefined instruction) and initiates an exception handling routine usually by the operating system. The current MIPS implementation being considered can be extended to handle exceptions by adding two additional registers and the associated control lines: –EPC: A 32 bit register to hold the address of the affected instruction –Cause: A register used to record the cause of the exception. In this implementation only the low-order bit is used to encode the two handled exceptions: undefined instruction = 0 overflow = 1 Two additional states are added to the control finite state machine to handle these exceptions.

EECC550 - Shaaban #26 Lec # 6 Spring Two Types of Exceptions Interrupts: –Caused by external events. –Asynchronous to program execution. –May be handled between instructions. –Simply suspend and resume user program. Traps: –Caused by internal events: Exceptional conditions (overflow). Errors (parity). faults (non-resident page). –Synchronous to program execution. –Condition must be remedied by the handler. –Instruction may be retried or simulated and program continued or program may be aborted.

EECC550 - Shaaban #27 Lec # 6 Spring Exception Handling Exception = an unprogrammed control transfer –System takes action to handle the exception Must record the address of the offending instruction. Returns control to user. must save & restore user state. user program System Exception Handler Exception: return from exception

EECC550 - Shaaban #28 Lec # 6 Spring Addressing The Exception Handler Traditional Approach, Interrupt Vector: –PC  MEM[ IV_base + cause || 00] –Used in: 370, 68000, Vax, 80x86,... RISC Handler Table: –PC  IT_base + cause || 0000 –saves state and jumps –Used in: Sparc, HP-PA,... MIPS Approach: Fixed entry –PC  EXC_addr –Actually a very small table: RESET entry TLB other iv_base cause handler code iv_base cause handler entry code

EECC550 - Shaaban #29 Lec # 6 Spring Exception Handling: Saving The State Push it onto the stack: –Vax, 68k, 80x86 Save it in special registers: –MIPS: EPC, BadVaddr, Status, Cause Shadow Registers: –M88k. –Save state in a shadow of the internal pipeline registers.

EECC550 - Shaaban #30 Lec # 6 Spring Additions to MIPS to Support Exceptions EPC: A 32-bit register used to hold the address of the affected instruction (in reality register 14 of coprocessor 0). Cause: A register used to record the cause of the exception. In the MIPS architecture this register is 32 bits, though some bits are currently unused. Assume that bits 5 to 2 of this register encode the two possible exception sources mentioned above: –Undefined instruction = 0 –Arithmetic overflow = 1 (in reality, register 13 of coprocessor 0). BadVAddr: Register contains memory address at which memory reference occurred (register 8 of coprocessor 0). Status: Interrupt mask and enable bits (register 12 of coprocessor 0). Control signals to write EPC, Cause, BadVAddr, and Status. Be able to write exception address into PC, increase mux to add as input two ( hex ). May have to undo PC = PC + 4, since we want EPC to point to offending instruction (not its successor); PC = PC - 4

EECC550 - Shaaban #31 Lec # 6 Spring Details of MIPS Status Register Mask = 1 bit for each of 5 hardware and 3 software interrupt levels 1  enables interrupts 0  disables interrupts k = kernel/user 0  was in the kernel when interrupt occurred 1  was running user mode e = interrupt enable 0  interrupts were disabled 1  interrupts were enabled Status k 4 e 3 k 2 e 1 k 0 e Mask oldprev current

EECC550 - Shaaban #32 Lec # 6 Spring Details of MIPS Cause register Pending interrupt: 5 hardware levels: bit set if interrupt occurs but not yet serviced: –Handles cases when more than one interrupt occurs at same time, or while records interrupt requests when interrupts disabled. Exception Code: Encodes reasons for interrupt: 0 (INT)  external interrupt 4 (ADDRL)  Address error exception (load or instr fetch). 5 (ADDRS)  Address error exception (store). 6 (IBUS)  Bus error on instruction fetch. 7 (DBUS)  Bus error on data fetch. 8 (Syscall)  Syscall exception. 9 (BKPT)  Breakpoint exception. 10 (RI)  Reserved Instruction exception. 12 (OVF)  Arithmetic overflow exception. Status 1510 Pending 52 Code

EECC550 - Shaaban #33 Lec # 6 Spring The MIPS Multicycle Datapath With Exception Handling Added

EECC550 - Shaaban #34 Lec # 6 Spring Finite State Machine (FSM) Specification IR  MEM[PC] PC  PC + 4 R-type ALUout  A fun B R[rd]  ALUout ALUout  A op ZX R[rt]  ALUout ORi ALUout  A + SX R[rt]  M M  MEM[ALUout] LW ALUout  A + SX MEM[ALUout]  B SW “instruction fetch” “decode” Execute Memory Write-back BEQ 0010 If A = B then PC  ALUout A  R[rs] B  R[rt] ALUout  PC +SX To instruction fetch

EECC550 - Shaaban #35 Lec # 6 Spring Exception Processing FSM Control States Undefined Instruction Arithmetic overflow

EECC550 - Shaaban #36 Lec # 6 Spring FSM Control Specification To Handle Exceptions IR  MEM[PC] PC  PC + 4 R-type ALUout  A fun B R[rd]  ALUout ALUout  A op ZX R[rt]  ALUout ORi ALUout  A + SX R[rt]  M M  MEM[ALUout] LW ALUout  A + SX MEM[ALUout]  B SW “instruction fetch” “decode” Execute Memory Write-back A  R[rs] B  R[rt] ALUout  PC +SX EPC  PC - 4 PC  exp_addr cause  10 (RI) undefined instruction EPC  PC - 4 PC  exp_addr cause  12 (Ovf) overflow BEQ 0010 If A = B then PC  ALUout To instruction fetch

EECC550 - Shaaban #37 Lec # 6 Spring Control Finite State Machine With Exception Detection Version In Textbook