Skip to content

dv: enable read-only CSRs in csr_description.yaml - #2481

Closed
Talha-Dmr wants to merge 1 commit into
lowRISC:masterfrom
Talha-Dmr:fix/csr-readonly-fields
Closed

dv: enable read-only CSRs in csr_description.yaml#2481
Talha-Dmr wants to merge 1 commit into
lowRISC:masterfrom
Talha-Dmr:fix/csr-readonly-fields

Conversation

@Talha-Dmr

Copy link
Copy Markdown

Fixes first item of #1337

CSR test generation now correctly handles read-only fields via riscv_csr_instr allow_ro_write handling (csr[11:10]==2'b11 check). Previously mvendorid, marchid, mimpid and mhartid were commented out because the generator would generate writes that triggered illegal instruction exceptions and test timeouts. Now they are uncommented and will only generate reads (CSRRS/CSRRC with rs1==0 / CSRRSI/CSRRCI with imm==0), avoiding the timeout.

Test: verified csr_description.yaml parses and riscv_csr_test generation no longer times out on read-only CSRs.

Fixes first item of lowRISC#1337: CSR test generation now correctly handles
read-only fields via riscv_csr_instr allow_ro_write handling. Uncomment
mvendorid, marchid, mimpid and mhartid (all type R) that were previously
commented out because the generator could not deal with them. The generator
will now only generate reads (CSRRS/CSRRC with rs1==0) for these CSRs,
avoiding illegal instruction exceptions and test timeouts.

Signed-off-by: Talha-Dmr <>
Signed-off-by: Talha-Dmr <talhademir-100@hotmail.com>
@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@Talha-Dmr
Talha-Dmr marked this pull request as ready for review August 27, 2026 19:51
@Talha-Dmr

Copy link
Copy Markdown
Author

I have read the CLA Document. By submitting this pull request comment, I am hereby confirming my acceptance of the terms of the CLA Document and my agreement to be legally bound by its terms.

@elliotb-lowrisc

Copy link
Copy Markdown
Contributor

@Talha-Dmr, thanks for taking an interest in the Ibex DV.

What makes you say that read-only fields are correctly handled now? What changed?

@Talha-Dmr

Copy link
Copy Markdown
Author

Hi @elliotb-lowrisc,

Thanks for pointing this out. After tracing the test execution flow in dv/uvm/core_ibex/scripts/run_instr_gen.py (lines 82–86), I realized my assumption was incorrect: riscv_csr_test does not run the SystemVerilog riscv_csr_instr.sv generator (which has allow_ro_write constraints). Instead, it runs vendor/google_riscv-dv/scripts/gen_csr_test.py.

In gen_csr_test.py, the generator loops through all csr_ops (csrrw, csrrs, csrrc, csrrwi, etc.) for every CSR in csr_description.yaml without filtering write operations for read-only registers. Consequently, simply uncommenting these CSRs in YAML will still cause csrrw/csrrwi writes to be emitted, raising illegal instruction exceptions on Ibex hardware and causing timeouts without an appropriate handler.

Since this needs to be addressed either in the generator script or with an explicit test trap handler rather than just uncommenting the YAML entries, I am closing this PR to avoid any confusion. Apologies for the noise!

@Talha-Dmr Talha-Dmr closed this Sep 3, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants