Docsity

Understanding MIPS Interrupts & Exceptions: Overflow, Invalid Instruction & Handling, Study Guides, Projects, Research of Engineering

Partial preview of the text

Download Understanding MIPS Interrupts & Exceptions: Overflow, Invalid Instruction & Handling and more Study Guides, Projects, Research Engineering in PDF only on Docsity!

COE 1502

Project 2: Unit 3

Interrupt and Exception Handling

Background Lecture

Interrupts and Exceptions

 Events other than branches that change the normal flow of instruction execution

  • Exceptions  Unexpected event from inside the processor - Arithmetic overflow, divide-by-zero - Invalid instruction (bus error) - L/S address error (misalignment, attempted access to protected memory) - Reserved/privileged instruction - Syscall (invoking the OS from user program) - Breakpoint
  • Interrupts  Unexpected event from outside the processor - I/O device request - Timer  Additional information
  • H&P text

Interrupts

 Must implement way for external devices to get the

processor’s attention

  • All external inputs share combined to on signal  Multiple sources resolved externally (more later)
  • Signaled to processor through IRQ input
  • Processor signals ready through IACK output  Want to complete current instruction before servicing interrupt

Interrupts and Exceptions

 How they work in MIPS architecture

  • Execute code in response to event (handler)  Save PC (EPC reg,)  Record cause (Cause reg.)  Disable e/i (shift Status reg.)  Set new PC (4)
  • Return from handler  Restore PC  Enable e/i (shift Status reg.)  Determining type of exception
  • Use vectored exceptions  Infer type from address
  • Use polled exceptions  Use Cause register  This is what MIPS does

Cause Register

 Use last 2 bits…

11 SYSCALL System call 10 OVF Arithmetic overflow 01 IBUS Instruction bus error (invalid instruction) 00 INT External Interrupt ID Name Description

Status Register

 Use last 4 bits…

0 SYSCALL

1 OVF

2 IBUS

3 INT

Bit Exception/Interrupt

Required Hardware

Required Instructions

 EPC, Status, and Cause registers

  • Instruction set treats these registers as being on coprocessor 0  Status (12), Cause (13), and EPC (14)
  • To use these registers, we’ll implement two instructions:  mfc0 rt, rd  mtc0 rd, rt  Datapath analysis for these instructions? 010000 00000 rt rd 00000000000 31..26 25..21 20..16 15.11 10.. 010000 00100 rt rd 00000000000 31..26 25..21 20..16 15.11 10..

Interrupts in Wishbone System Model  Start with the CPU wrapper that you did in the previous unit.  Use the new view (called Unit3) for the synthesis wrapper.  Add the following pins to your CPU wrapper (and CPU)

  • IRQ
  • IACK

New Synthesis Wrapper