Skip to content

Conversation

@visitorckw
Copy link
Collaborator

@visitorckw visitorckw commented Dec 11, 2025

The RISC-V PLIC specification states that "if two or more pending interrupts have the same priority, the one with the lowest ID has the highest priority."

The previous implementation used ilog2(), which identifies the most significant bit (highest ID). Replace it with rv_ctz() to select the least significant bit (lowest ID), ensuring compliance with the specification's arbitration rule.


Summary by cubic

Fix PLIC tie-breaking to choose the lowest interrupt ID when multiple pending interrupts share the same priority, matching the RISC-V spec. Replaced ilog2() with rv_ctz() to select the least significant set bit in the pending-enabled mask.

Written for commit a7ca51b. Summary will update automatically on new commits.

The RISC-V PLIC specification states that "if two or more pending
interrupts have the same priority, the one with the lowest ID has the
highest priority."

The previous implementation used ilog2(), which identifies the most
significant bit (highest ID). Replace it with rv_ctz() to select the
least significant bit (lowest ID), ensuring compliance with the
specification's arbitration rule.
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 1 file

@jserv jserv merged commit 3a168b7 into sysprog21:master Dec 13, 2025
14 of 20 checks passed
@jserv
Copy link
Contributor

jserv commented Dec 13, 2025

Thank @visitorckw for contributing!

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