Nios® V Processor Software Developer Handbook

ID 743810
Date 9/26/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

8.7.1. Writing an Instruction-Related Exception Handler

The prototype for an instruction-related exception handler is as follows:
alt_exception_result handler(alt_exception_cause cause, 
alt_u32 exception_pc, 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 V Processor Exception Cause Codes table
  • exception_pc — Instruction address at which exception occurred
  • bad_addr — Bad address associated with exception (if applicable)
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 V Processor Exception Cause Codes table.

For more information about RISCV-based processor exception causes, refer to the The RISC-V Instruction Set Manual Volume II in RISC-V International website.