Nios® V Processor Software Developer Handbook

ID 743810
Date 10/06/2025
Public
Document Table of Contents

9.2.1.2.2.1. Traps Occurs

When a trap occurs, and the processor transfers control to the trap handler, it does the following:

  • Switches to the separate exception stack (if enabled)
  • Saves register values onto the stack
    • Save all register values if shadow register is turned off.
    • Saves the lower 16 general-purpose register values only if shadow register is enabled. (This is not implemented in MicroC/OS-II HAL firmware.)
  • Determines the type of trap (either exceptions or interrupts)
  • Passes control to the correct dispatchers

The trap handler looks at the Machine Cause (mcause) register to determine the trap type.

  • If the Interrupt bit is set, the trap handler transfers control to the interrupt dispatcher.
  • Otherwise (Interrupt bit is not set), the trap handler calls the exception dispatcher.