Altera Nios II User Manual page 90

Hide thumbs Also See for Nios II:
Table of Contents

Advertisement

3–50
Without Extra Exception Information
When you have not included the extra exception information in your Nios II system,
your exception handler must determine the cause of exception itself. For this reason,
Altera recommends always enabling the extra exception information.
When the extra exception information is not available, use the sequence in
Example 3–3 on page 3–50
Example 3–3. Determining Exception Cause Without Extra Exception Information
/* With an internal interrupt controller, check for interrupt
exceptions. With an external interrupt controller, ipending is
always 0, and this check can be omitted. */
if (estatus.PIE == 1 and ipending != 0) {
/* Decode exception from instruction */
/* Note: Because the exception register is included with the MMU and */
/* MPU, you never need to determine MMU or MPU exceptions by decoding */
} else {
}
Handling Nested Exceptions
The Nios II processor supports several types of nested exceptions, depending on
which optional features are implemented. Nested exceptions can occur under the
following circumstances:
An exception handler enables maskable interrupts
An EIC is present, and an NMI occurs
An EIC is present, and the processor is configured to keep maskable interrupts
enabled when taking an interrupt
An exception handler triggers an instruction-related exception
Nios II Processor Reference Handbook
to determine the cause of an exception.
handle interrupt
decode instruction at $ea-4
if (instruction is trap)
handle trap exception
else if (instruction is load or store)
handle misaligned data address exception
else if (instruction is branch, bret, callr, eret, jmp, or ret)
handle misaligned destination address exception
else if (instruction is unimplemented)
handle unimplemented instruction exception
else if (instruction is illegal)
handle illegal instruction exception
else if (instruction is divide) {
if (denominator == 0)
handle division error exception
else if (instruction is signed divide and numerator == 0x80000000
handle division error exception
}
}
/* Not any known exception */
} else {
handle unknown exception (If internal interrupt controller
is implemented, could be spurious interrupt)
}
Chapter 3: Programming Model
Exception Processing
and denominator == 0xffffffff)
February 2014 Altera Corporation

Advertisement

Table of Contents
loading

Table of Contents