Nios® V Processor Reference Manual

ID 683632
Date 5/25/2025
Public

Visible to Intel only — GUID: tmp1741142948831

Ixiasoft

Document Table of Contents

4.3.11.2.3. Trap Handling with Pre-emption

In comparison with CLINT, CLIC offers more capabilities in interrupt management. The CLIC extends interrupt pre-emption to support up to 256 interrupt levels, where higher-numbered interrupt levels can pre-empt lower-numbered interrupt levels. Interrupt level 0 corresponds to regular execution outside of an interrupt handler.

Under CLIC mode, the processor is running under a specific interrupt level at any time. The current interrupt level is made visible in the mintstatus register. Incoming interrupts with a higher interrupt level can pre-empt an active interrupt handler running at a lower interrupt level, when interrupts are globally enabled in this privilege mode (mstatus.mie = 1).

The global interrupt-enable (mstatus.mie) guarantee atomicity with respect to interrupt handlers. It functions as such:
  • If mstatus.mie is clear, no interrupts will be taken.
  • If mie is set, any pending-enabled interrupts at a higher interrupt level will pre-empt current execution and run the interrupt handler for the higher interrupt level. For software vectored interrupts this takes the form of a re-entrant call to the common trap handler.
The overall behaviour is summarized in the following table.
Table 139.  Behaviour Between Normal Execution and Interrupt
Before Interrupt from CLIC After Description
mstatus.mie pc Interrupt Level Interrupt Level Threshold pc epc
0 main Don’t Care Don’t Care main - Interrupt is disabled. Normal execution cannot be interrupted.
1 main 0 Don’t Care main - No interrupt is present. Normal execution continues.
1 main Lower than threshold (mintthresh.th) mintthresh.th main - Interrupt level is lower than threshold. Interrupt is ignored, and normal execution continues.
1 main Higher than threshold (mintthresh.th) mintstatus.mil Handler main Interrupt level is higher than threshold. Interrupt is taken.
Table 140.  Behaviour Between Different Levels of interrupt
Before Interrupt from CLIC After Description
mstatus.mie pc Interrupt Level Interrupt Level Threshold pc epc
0 Handler 1 Don’t Care Don’t Care Handler 1 main Interrupt is disabled. Handler 1 cannot be pre-empted.
1 Handler 1 0 mintstatus.mil (Handler 1) Handler 1 main No interrupt is present. Handler 1 continues.
1 Handler 1 Lower than Handler 1 interrupt level mintstatus.mil (Handler 1) Handler 1 main Interrupt level is lower than threshold. Interrupt is ignored, and Handler 1 continues.
1 Handler 1 Higher than Handler 1 interrupt level mintstatus.mil (Handler 2) Handler 2 Handler 1 Interrupt level is higher than threshold. Handler 1 is pre-empted.