Machine Trap-Vector Base-Address Register (mtvec) - 2024.1 English - UG1629

MicroBlaze V Processor Reference Guide (UG1629)

Document ID
UG1629
Release Date
2024-05-30
Version
2024.1 English

The mtvec register is a read/write register that holds trap vector configuration, consisting of a vector base address (BASE) and a read-only vector mode (MODE).

Figure 1. Machine Trap-Vector Base-Address Register

Table 1. Machine Trap-Vector Base-Address Register
Bits Name Description Reset Value
31:2 BASE Vector base address (C_BASE_VECTORS + 4) / 4
1:0 MODE Direct: All traps set PC to BASE. Read only. 00

Because MODE is read-only zero, the trap handler code must be aligned on a 32-bit word boundary.

With compressed instructions enabled (C_USE_COMPRESSION > 0), software must use an align attribute to ensure this is the case.

With the RISC-V GCC compiler, this can be achieved with the following code:
/* Ensure alignment on a word boundary */
void trap_handler(void) __attribute__((aligned(4)));