Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify textra behavior when XLEN changes. #978

Merged
merged 1 commit into from
Mar 13, 2024
Merged

Clarify textra behavior when XLEN changes. #978

merged 1 commit into from
Mar 13, 2024

Conversation

rtwfroody
Copy link
Collaborator

No description provided.

Copy link
Collaborator

@pdonahue-ventana pdonahue-ventana left a comment

Choose a reason for hiding this comment

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

This seems reasonable.

Writes to this register will clear the high bits of the corresponding fields in {csr-textra64}.

If you do something like csrrsi x0, textra32, 1 then it will set the LSB. Are csrrs, csrrc, csrrsi, csrrci considered to be writes to this register? My inclination is that they are writes because the 32b mode is basically claiming ownership and it might expect that csrrs of value X followed by csrrc of ~X should be equivalent to csrrw of X. It would be good to explicitly say that the set/clear operations are writes.

@rtwfroody
Copy link
Collaborator Author

From the unpriv spec, section 11.1: "All CSR instructions atomically read-modify-write a single CSR"

To me that unambiguously says all those ops, including csrrsi are writes.

Note that we already have similar language in our spec. Section 5.7 says:

In this section XLEN means MXLEN when in M-mode, and DXLEN when in Debug Mode. On systems
where those values of XLEN can differ, this is handled as follows. Fields retain their values regardless
of XLEN, which only affects where in the register these fields appear (e.g. type). Some fields are wider
when XLEN is 64 than when it is 32 (e.g. svalue). The high bits in such fields retain their value but are
not readable when XLEN is 32. A modification of a register when XLEN is 32 clears any inaccessible
bits in that register.

We didn't mention any specific csr instructions there either.

Copy link
Collaborator

@pdonahue-ventana pdonahue-ventana left a comment

Choose a reason for hiding this comment

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

OK, sure. I just like to think about all the weird ways that people can interpret the spec. This just talks about "writes to this register" and not "csrrw to this register" so I guess that it's reasonably clear.

@rtwfroody rtwfroody changed the base branch from main to rc2 March 7, 2024 18:07
@rtwfroody rtwfroody merged commit dc06142 into rc2 Mar 13, 2024
1 check passed
@rtwfroody rtwfroody deleted the csr_xlen branch March 13, 2024 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants