Skip to content

[dv] Add exception handler to CSR test generator (Fixes #1337)#2439

Open
RKNAGA18 wants to merge 1 commit into
lowRISC:masterfrom
RKNAGA18:fix-csr-exception-handler
Open

[dv] Add exception handler to CSR test generator (Fixes #1337)#2439
RKNAGA18 wants to merge 1 commit into
lowRISC:masterfrom
RKNAGA18:fix-csr-exception-handler

Conversation

@RKNAGA18
Copy link
Copy Markdown

Currently, the gen_csr_test.py script generates CSR test assembly that lacks a Machine Trap-Vector (mtvec) initialization sequence. If the generated test attempts an illegal access (such as writing to certain read-only fields), it triggers an Illegal Instruction exception. Without a trap handler configured, the core jumps to 0x0, executing garbage memory until the simulation times out.

Changes

Modified gen_setup() in vendor/google_riscv-dv/scripts/gen_csr_test.py to initialize mtvec.

The trap vector is now explicitly loaded with the address of the existing csr_fail label.

Impact
Illegal CSR accesses that trigger an exception will now be caught by the trap handler, gracefully forcing an immediate test failure rather than hanging the simulator for the duration of the timeout period.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant