Nios® V Processor Software Developer Handbook

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

9.2.1.2.1. Trap Handling System Structure

The trap handling system consists of the following components:

  • The trap handling code
  • The interrupt dispatcher
    • ISR for timer interrupts
    • ISR for software interrupts
    • ISR for each peripheral that generates platform interrupts
  • The exception dispatcher
    • Handler for instruction-related exception

With the CLINT-Direct, all traps start from the same trap handling code. The trap handling code manages the processor context switch and RTOS overhead (if any). Next, it determines the source of the trap, and executes the correct dispatcher:

  • If the trap is an interrupt, the interrupt dispatcher is executed.
  • If the trap is an exception, the exception dispatcher is executed.

The interrupt dispatcher passes control to the relevant ISRs, while the exception dispatcher passes control to the correct exception handler.

The following files provides the HAL API for the trap handling system:

  • <Project directory>\software\bsp\HAL\src\intel_niosv_irq.c
  • <Project directory>\software\bsp\HAL\src\machine_trap.S
  • <Project directory>\software\bsp\HAL\src\alt_irq_handler.c
Figure 17. HAL Trap Handling System in CLINT-Direct
Table 39.  CLINT-Direct Trap Handling
Traps Address Computation Action Taken
All Exceptions pc <= Exception Vector Enters trap handling code
Machine software interrupt
Machine timer interrupt
Platform interrupt 0
Platform interrupt 16