Nios® V Processor Reference Manual

ID 683632
Date 5/25/2025
Public

Visible to Intel only — GUID: fhu1741140338817

Ixiasoft

Document Table of Contents

4.3.11.1.4.4. Machine Cause Register (mcause)

The mcause register is a 32-bits wide register. When a trap is taken, mcause holds a code identifying the event that caused the trap.

Table 133.  Machine Trap Cause Register Fields (For CLIC mode)
Bit Fields
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
interrupt minhv mpp[1:0] = 00 mpie Reserved mpil[7:0]
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Reserved exccode[11:0]
Table 134.   Mcause Field Encoding
Bits Field Description
31 interrupt

0: Exception

1: Interrupt

30 minvh 0: mepc contains (virtual) address of instruction
29:28 mpp[1:0] Previous privilege mode. Same as mstatus.mpp
27 mpie Previous interrupt enable. Same as mstatus.mpie
26:24 Reserved -
23:16 mpil[7:0] Previous interrupt level
15:12 Reserved -
11:0 exccode[11:0] Exception/interrupt code

The mcause.mpp and mcause.mpie fields mirror the mstatus.mpp and mstatus.mpie fields to reduce context save/restore code. For backwards compatibility in implementations supporting both CLINT and CLIC modes, when switching to CLINT mode the new CLIC mcause.mpil state field is zeroed.

Table 135.   Mcause.interupt and mcause.exccode Value After Trap
Interrupt Exception Code Description
1 3 Machine software interrupt
1 7 Machine timer interrupt
1 16-2064 2048 Platform interrupts, connected through irq[0:2047] interface.
For example:
  • Exception code 16 = irq[0]
  • Exception code 2064 = irq[2047]
1 Others Reserved
0 0 Instruction address misaligned
0 1 Instruction access fault
0 2 Illegal Instruction
0 3 Breakpoint
0 4 Load address misaligned
0 5 Load access fault
0 6 Store address misaligned
0 7 Store access fault
0 Others Reserved

If an instruction may raise multiple synchronous exceptions, the decreasing priority order indicates which exception is taken and reported in mcause.

Table 136.  Exception Priority in Decreasing Priority Order
Priority Exception Code Description
Highest 3 Instruction address breakpoint

1

With physical address for instruction:

Instruction access fault

2

0

3

3

Illegal instruction

Instruction address misaligned

Environment break

Load/Store address breakpoint

4,6

Optionally:

Load/Store address misaligned

5,7

With physical address for an explicit memory access:

Load/Store access fault

Lowest 4,6 Load/Store address misaligned