Repository navigation
On the side effects of Zicsr instructions and Normative Rules tags #2928
Replies: 2 comments
|
Masanori Ogino (@omasanori) The Zicsr specification defines two related but slightly different behaviors:
My interpretation is that the second sentence is tagged because it expresses a distinct, testable behavioral requirement that is not simply implied by the generic read-modify-write semantics. It tells an implementation exactly when field-level side effects must (and must not) occur, making it a natural candidate for a certification or conformance rule. By contrast, the first sentence appears to be describing the expected behavior of the CSRRW/CSRRWI write operation itself. From what I can tell, it may have been considered sufficiently covered by the instruction's normative definition ("atomically swaps values... writes That said, I couldn't find documentation stating the criterion used by the editors for deciding which normative statements receive Rule tags. If the intent is for every independently testable requirement to be tagged, then your observation seems reasonable—the CSRRW[I] sentence also looks like something that could stand on its own as a Rule. So I suspect the answer depends on the editorial policy for Rule tagging rather than the semantics of Zicsr itself. It would be interesting to hear from the CSC/spec editors whether:
If this solves your problem, feel free to mark it as the accepted answer so others can find it easily. |
|
@***@***.*** ***@***.***> might be the one who
tagged this one.
CSRRW[I] either writes all fields (or just bits[4:0] in the I case), or no
fields (if the source Xreg is !=0 or ==x0)
CSRR[C/S][I] only writes fields whose source register (or immediate) field
is set.
What is really important is which fields are *changed* by each of these.
If a field isn't changed (e.g. it is written in the CSRRW case with the
same value it already had, or set /clear of an already set/clear bit)
then there are no actionable side effects, even though the field was
written. The same is true for the CSRR[S/C] case.
Note that many CSRs have no actionable side effects regardless of what is
written (e.g. scratch or tval);
readonly CSRs will trap if written (so nothing got written, no side effect).
If there is an exception to this, I am unaware of it (which doesn't mean it
doesn't exist).
Control fields (e.g.writes cause something to reset, but the field reads
back as zero) essentially follow this rule, and that's as close to an
exception as I can think of.
So, overall, any *change* to a field value made by *any* CSR op alway
actions side effects (which is another way of say that any side effects
occur immediately, before the next instruction is executed)
That's a much more succinct way of saying this with far fewer words.
…On Sat, Jul 18, 2026 at 1:59 AM Ganesh Kambli ***@***.***> wrote:
Masanori Ogino ***@***.***) <https://github.com/omasanori>
I think the distinction comes down to what the *Normative Rule tags are
trying to capture*, rather than whether a sentence is "important."
The Zicsr specification defines two related but slightly different
behaviors:
- *CSRRW[I]*: writing the CSR always actions side effects for all
written fields.
- *CSRRS[I]/CSRRC[I]*: field side effects are *conditional*—they are
only actioned for fields whose corresponding rs1/uimm bit is set.
:contentReference[oaicite:0]{index=0}
My interpretation is that the second sentence is tagged because it
expresses a distinct, testable behavioral requirement that is not simply
implied by the generic read-modify-write semantics. It tells an
implementation exactly *when* field-level side effects must (and must
not) occur, making it a natural candidate for a certification or
conformance rule.
By contrast, the first sentence appears to be describing the expected
behavior of the CSRRW/CSRRWI write operation itself. From what I can tell,
it may have been considered sufficiently covered by the instruction's
normative definition ("atomically swaps values... writes rs1 to the
CSR"), so an additional Rule tag may have been viewed as redundant rather
than omitted because it is less normative.
:contentReference[oaicite:1]{index=1}
That said, I couldn't find documentation stating the criterion used by the
editors for deciding which normative statements receive Rule tags. If the
intent is for *every independently testable requirement* to be tagged,
then your observation seems reasonable—the CSRRW[I] sentence also looks
like something that could stand on its own as a Rule.
So I suspect the answer depends on the editorial policy for Rule tagging
rather than the semantics of Zicsr itself.
It would be interesting to hear from the CSC/spec editors whether:
- the CSRRW[I] behavior is intentionally left untagged because it is
considered redundant with the instruction definition, or
- it is simply an omission that should be tagged for consistency with
the CSRRS[I]/CSRRC[I] requirement.
If this solves your problem, feel free to mark it as the accepted answer
so others can find it easily.
—
Reply to this email directly, view it on GitHub
<#2928?email_source=notifications&email_token=AHPXVJVLWMLBCXVUEZUZLXD5FM4ARA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCNZWG44TKNJRUZZGKYLTN5XKU43VMJZWG4TJMJSWJJLFOZSW45FMMZXW65DFOJPWG3DJMNVQ#discussioncomment-17679551>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHPXVJSYO5UP7NQDIKPSADD5FM4ARAVCNFSNUABGKJSXA33TNF2G64TZHM4DANRYHE2TGOJ3IRUXGY3VONZWS33OHM4TSMBWHE3DTILWAI>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AHPXVJU7EVD6JRFZFNWDKZT5FM4ARA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCNZWG44TKNJRUZZGKYLTN5XKU43VMJZWG4TJMJSWJJLFOZSW45FKMZXW65DFOJPWS33T>
and Android
<https://github.com/notifications/mobile/android/AHPXVJXCIF6ZB6TAEJFW4IT5FM4ARA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCNZWG44TKNJRUZZGKYLTN5XKU43VMJZWG4TJMJSWJJLFOZSW45FOMZXW65DFOJPWC3TEOJXWSZA>.
Download it today!
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***
.com>
|
Uh oh!
There was an error while loading. Please reload this page.
The sentence
is not a Normative Rule, while
is a Normative Rule.
Why the former is not marked up? Because it is obvious from the definition (it atomically swaps values in the CSRs and integer registers), correct?
(cc @riscv/csc)
All reactions