You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Explicit writes to minstret lose to the automatic retirement update #260
NutShell does not make an explicit write to minstret visible to the immediately following CSR read.
The minimal sequence is:
csrw minstret, zerocsrr s0, minstret
In the supplied differential trace, Spike returns s0 = 0, while NutShell returns s0 = 3. The failing value is the running retired-instruction count, indicating that the automatic retire-count update wins over, or is not correctly arbitrated with, the architectural CSR write.
RISC-V Specification Requirement
The key rule for this case is that an explicit CSR write must be the value observed by following instructions. For this sequence, csrw minstret, zero must leave minstret holding zero, even though the csrw instruction itself also retires. The next csrr s0, minstret therefore must read zero.
The ratified Zicsr specification, Section CSR Access Ordering, provides the underlying rule:
when a CSR modified implicitly by instruction execution is explicitly written, the explicit write is performed instead of the implicit update;
a value written to instret by one instruction is the value read by the following instruction;
explicit CSR accesses and their consequences are observed in program order.
Activity
Lemover commentedon Nov 2, 2026
Confirmed. It has been fixed in PR #281