Skip to content

Mirror ISA extension organization for CSRs - #422

Open
Luca Colagrande (colluca) wants to merge 5 commits into
riscv:masterfrom
pulp-platform:csr-org
Open

Mirror ISA extension organization for CSRs#422
Luca Colagrande (colluca) wants to merge 5 commits into
riscv:masterfrom
pulp-platform:csr-org

Conversation

@colluca

Copy link
Copy Markdown
Contributor

To support managing custom (and possibly conflicting) sets of CSRs, we propose to reorganize the CSR definitions, mirroring the organization of the ISA extensions.

Ratified CSR sets would live in the csrs/ folder, while custom CSR sets go in csrs/unratified.
The list of desired CSR sets can be passed to the CLI, similar to how the CLI accepts a list of ISA extensions.
To this end, a new --csr flag is provided.

Usage

To add a custom CSR set, place a file under csrs/unratified/:

# MyVendor CSRs
0x800, mv_ctrl
0x801, mv_status

Then pass --csr rv_myvendor to include only that set, or omit --csr to include all CSR sets, including ratified sets.

Changes

  • read_lines is moved to resources.py so it can be reused also in constants.py, and in general by any file that needs to read some resource
  • read_int_map_csv is updated to use read_lines instead of opening the CSV resource directly, enabling #-prefixed comment lines and blank lines in all CSV files, as supported in ISA extension files
  • the module-level csrs and csrs32 globals are removed entirely. Generators no longer import CSR data from constants but instead take a CSR dictionary as argument, which is populated with the CSR sets selected on the CLI (similar to how instructions are handled)
  • csrs.csv and csrs32.csv have been moved to the new csrs/ subdirectory
  • a --csr CLI argument (repeatable) is added to specify which CSR sets to load. Omitting --csr includes all sets. generate_extensions gains a csrs parameter; it calls create_csr_dict once and passes the resulting csr_dict to every generator.
  • all generators gain a csr_dict: CsrDict parameter. Most generators are agnostic to which sets are present. The exception are Chisel's all and all32 arrays, which retain their semantics by reading csr_dict.get("csrs", []) and csr_dict.get("csrs32", []) respectively.

@colluca
Luca Colagrande (colluca) marked this pull request as draft June 22, 2026 12:55
@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.81%. Comparing base (4644ba3) to head (41cf7e5).
⚠️ Report is 16 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #422      +/-   ##
==========================================
- Coverage   97.08%   96.81%   -0.27%     
==========================================
  Files          14       14              
  Lines         926      942      +16     
==========================================
+ Hits          899      912      +13     
- Misses         27       30       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@aswaterman

Copy link
Copy Markdown
Member

Seems reasonable at first blush, but I'm hoping someone else has some time to do a code review.

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.

2 participants