Nios® V Processor Reference Manual

ID 683632
Date 1/27/2025
Public
Document Table of Contents

4.3.9.1.5. Machine Cause Register (mcause)

Table 101.  Machine Cause (mcause) Register Fields
Bit Field
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Interrupt Cause (WLRL)
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Cause (WLRL)

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

The Interrupt field is set when the trap was caused by an interrupt. The Cause field contains the code identifying the last trap event.

Table 102.   mcause Value After Trap
Interrupt Exception Code Description
1 3 Machine software interrupt
1 7 Machine timer interrupt
1 16-31 16 Platform interrupt
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 19 Hardware error due to uncorrectable ECC
0 Others Reserved

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

Table 103.  Exception Priority in Decreasing Priority Order
Priority Exception Code Description
1 (Highest) 3 Instruction address breakpoint
2

1

With physical address for instruction:

Instruction access fault

3

2

0

3

3

Illegal instruction

Instruction address misaligned

Environment break

Load/Store address breakpoint

5

4,6

Optionally:

Load/Store address misaligned

6

5,7

With physical address for an explicit memory access:

Load/Store access fault

7 (Lowest) 4,6 Load/Store address misaligned