Specifications
alt_u32 addr,
alt_u32 bad_addr );
The instruction-related exception handler’s return value is a flag requesting that the HAL either re-
execute the instruction, or skip it.
The HAL exception funnel calls the instruction-related exception handler with the following arguments:
• cause—A value representing the exception type, as shown in the "Nios II Exception Cause Codes"
table (Table 8-4)
• addr—Instruction address at which exception occurred
• bad_addr—Bad address register (if implemented)
Include the following header file in your instruction-related exception handler code:
#include “sys/alt_exceptions.h”
alt_exceptions.h provides type macro definitions required to interface your instruction-related exception
handler to the HAL, including the cause codes shown in the "Nios II Exception Cause Codes" table (Table
8-4).
The API function alt_exception_cause_generated_bad_addr() is provided by the HAL, for the use of
the instruction-related exception handler. This function parses the cause argument and determines if
bad_addr contains the exception-causing address.
For more information about Nios II processor exception causes, refer to “Exception Processing” in the
"Programming Model" chapter of the Nios II Processor Reference Handbook.
Related Information
Programming Model
Exception Cause Codes
Table 8-4: Nios II Exception Cause Codes
Exception Cause
Code
Cause Symbol
(8)
Reset 0 NIOS2_EXCEPTION_RESET
Processor-only Reset
Request
1 NIOS2_EXCEPTION_CPU_ONLY_RESET_REQUEST
Hardware Interrupt 2 NIOS2_EXCEPTION_INTERRUPT
Trap Instruction 3 NIOS2_EXCEPTION_TRAP_INST
Unimplemented Instruction 4 NIOS2_EXCEPTION_UNIMPLEMENTED_INST
Illegal Instruction 5 NIOS2_EXCEPTION_ILLEGAL_INST
Misaligned Data Address 6 NIOS2_EXCEPTION_MISALIGNED_DATA_ADDR
Misaligned Destination
Address
7 NIOS2_EXCEPTION_MISALIGNED_TARGET_PC
Division Error 8 NIOS2_EXCEPTION_DIVISION_ERROR
(8)
Cause symbols are defined in sys/alt_exceptions.h.
NII5V2
2015.05.14
Exception Cause Codes
8-33
Exception Handling
Altera Corporation
Send Feedback