Nios® V Processor Software Developer Handbook

ID 743810
Date 10/06/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 handler
  • The interrupt dispatcher
    • ISR for timer interrupts
    • ISR for software interrupts
    • ISR for each peripheral that generates platform interrupts
  • The exception dispatcher
    • Handler for hardware exception

With the CLINT-Direct, all traps start from the same trap handler. The trap handler 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 41.  CLINT-Direct Trap Handling
Traps Address Computation Action Taken
All Exceptions pc <= Exception Vector Enters trap handler
Machine software interrupt
Machine timer interrupt
Platform interrupt 0
Platform interrupt 16