Skip to content

Conversation

@jserv
Copy link
Contributor

@jserv jserv commented Jan 16, 2026

This refactors mstatus/sstatus register field definitions:

  • Use anonymous enum for true compile-time constants (usable in switch cases, array sizes, static assertions)
  • Eliminate SSTATUS duplication by aliasing to MSTATUS values
  • Use unsigned literals (1U) to prevent sign-bit shift issues

Summary by cubic

Simplified CSR field definitions and centralized cycle/time CSR sync to reduce duplication and ensure correct timer behavior on TIME CSR reads.

  • Refactors

    • Replaced mstatus macros with an anonymous enum for true compile-time constants.
    • Aliased sstatus fields to mstatus to remove duplicate definitions.
    • Extracted cycle/time CSR syncing into csr_sync_cycle and used it in CSRRW/CSRRS/CSRRC.
  • Bug Fixes

    • Used unsigned masks (1U) to prevent sign-bit shift issues in bit operations.

Written for commit 50a75ef. Summary will update on new commits.

This refactors mstatus/sstatus register field definitions:
- Use anonymous enum for true compile-time constants (usable in switch
  cases, array sizes, static assertions)
- Eliminate SSTATUS duplication by aliasing to MSTATUS values
- Use unsigned literals (1U) to prevent sign-bit shift issues
@jserv jserv added this to the release-2026.1 milestone Jan 16, 2026
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Copy link
Contributor Author

@jserv jserv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmarks

Details
Benchmark suite Current: 50a75ef Previous: df9727a Ratio
Dhrystone 1624 DMIPS 1593.333 DMIPS 0.98
CoreMark 950.045 iterations/sec 947.117 iterations/sec 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@jserv jserv merged commit 2efa3bb into master Jan 16, 2026
23 of 24 checks passed
@jserv jserv deleted the simplify-csr branch January 16, 2026 23:03
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