Nios® V Processor Software Developer Handbook

ID 743810
Date 4/07/2025
Public
Document Table of Contents

9.2.1.2.2.1. Traps Occurs

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

  • Switches to the separate exception stack (if enabled)
  • Stores register values onto the stack
    • Stores all register values if shadow register is turned off.
    • Store the lower 16 general-purpose register values only if shadow register is enabled. (This is not implemented in Altera HAL firmware.)
  • Determines the type of traps (either exceptions or interrupts)
  • Passes control to the correct dispatchers

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

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