Nios® V Processor Software Developer Handbook

ID 743810
Date 10/06/2025
Public
Document Table of Contents

9.4.2. Shadow Register

The Nios® V/g processor offers optional shadow registers for all supported hardware interrupt controllers. This chapter focuses on the firmware aspect of Nios® V/g processor related to the shadow register.

A shadow register set is a complete alternate set of Nios® V general-purpose registers (GPR) and floating-point registers, which can be used to maintain a separate runtime context for a trap. Shadow registers speed up interrupt response time by reducing the number of registers saved into or restored from the stack.

Here are some traits of shadow registers:
  • They have no impact on interrupt processing time.
  • They can reduce interrupt response time.
  • They have no impact on exceptions.

The Altera HAL firmware and FreeRTOS firmware manage shadow register switching during runtime, only when in CLINT-Direct interrupt mode. The shadow register is left unutilized during CLINT-Vectored modes.

The following source codes demonstrate the shadow register management:
Table 52.  Operating System and Related Source Codes
Operating System Related Source Codes
Altera HAL
  • <Project directory>\software\bsp\HAL\src\crt0.S
  • <Project directory>\software\bsp\HAL\src\machine_trap.S
MicroC/OS-II

None

FreeRTOS
  • <Project directory>\software\bsp\HAL\src\crt0.S
  • <Project directory>\software\bsp\FreeRTOS-Kernel\portable\GCC\RISC-V\portContext.h