Nios® V Processor Reference Manual

ID 683632
Date 5/25/2025
Public

Visible to Intel only — GUID: xlg1740968901197

Ixiasoft

Document Table of Contents

4.3.2. Shadow Register

The Nios® V processor can have one or more optional shadow register sets. A shadow register set is an alternate set of Nios® V general-purpose registers that works just like the general-purpose register set. This feature helps to accelerate context switching by swapping register file sets.
By maintaining a separate runtime context for an interrupt service routine (ISR), the processor software can remove the requirement to save and restore register state when entering or exiting an ISR respectively. This can greatly improve ISR performance and latency for timing critical ISRs.
Figure 11. Context Switching

Note that there is a total of 32 Nios® V general-purpose registers, but the shadow register set comprised of the upper 16 registers only. Consequently, the shadow register set is not a complete alternate set of GPR. This implementation is intentionally for the following reasons:

  • The RISC-V ABI assigns zero to x0 and pointer registers to x2 – x4. These registers must be in sync across all register sets.
  • Reduce memory block utilization.

Besides GPRs, the Nios® V/g processor support 32 floating-point registers, when floating-point unit is enabled. Unlike GPRs, the processor implements the shadow register as a complete alternate set of floating-point registers.

Enabling shadow register is backward compatible with ISRs that are built with shadow register disabled. To take advantage of the shadow registers, the ISRs can be enhanced by stop saving and restoring the upper 16 register state and floating-point registers.

Table 97.  RV32I and “F” extension Register Set vs Shadow Register Set
RISC-V ISAa Register Set Saving and Restoring Registers during Context Switching
Shadow Register Set Without Shadow Register With Shadow Register
RV32I x0 – x15 Not present Required Required
x16 – x31 x16 – x31 Required Not required (Replaced by register switching)
“F” Extension f0 – f31 f0 – f31 Required Not required (Replaced by register switching)
Note: The Altera HAL firmware is not optimized to use shadow register. All registers are saved and restored during context switching, despite that shadow register is implemented. Thus, interrupt response time remains the same, when running Altera HAL firmware with or without shadow register.