3.3.6.1.1. Machine Status Register (mstatus)
3.3.6.1.2. Machine Trap-Vector Base-Address Register (mtvec)
3.3.6.1.3. Machine Interrupt Register (mip and mie)
3.3.6.1.4. Machine Exception Program Counter Register (mepc)
3.3.6.1.5. Machine Cause Register (mcause)
3.3.6.1.6. Machine Trap Value Register (mtval)
4.3.1. General-Purpose Register File
4.3.2. Shadow Register
4.3.3. Arithmetic Logic Unit
4.3.4. Multipy and Divide Units
4.3.5. Floating-Point Unit
4.3.6. Custom Instruction
4.3.7. Instruction Cycles
4.3.8. Reset and Debug Signals
4.3.9. Control and Status Registers
4.3.10. Trap Controller (CLINT)
4.3.11. Trap Controller (CLIC)
4.3.12. Memory and I/O Organization
4.3.13. RISC-V based Debug Module
4.3.14. Error Correction Code (ECC)
4.3.15. Branch Prediction
4.3.16. Lockstep Module
4.3.10.1.1. Machine Status Register (mstatus)
4.3.10.1.2. Machine Trap-Vector Base-Address Register (mtvec)
4.3.10.1.3. Machine Interrupt Register (mip and mie)
4.3.10.1.4. Machine Exception Program Counter Register (mepc)
4.3.10.1.5. Machine Cause Register (mcause)
4.3.10.1.6. Machine Trap Value Register (mtval)
4.3.10.1.7. Machine Second Trap Value Register (mtval2)
4.3.11.1.3.1. Machine Trap-handler Vector Table base address Register (mtvt)
4.3.11.1.3.2. Machine Next Interrupt Handler Address and Interrupt Enable Register (mnxti)
4.3.11.1.3.3. Machine Interrupt Status Register (mintstatus)
4.3.11.1.3.4. Machine Interrupt-Level Threshold Register (mintthresh)
4.3.11.1.3.5. Machine Scratch Swap for Interrupt-Level Register (mscratchcswl)
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.
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. |
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. |