-
Notifications
You must be signed in to change notification settings - Fork 162
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
riscv
: Add macro to define CSR register types
#218
Comments
riscv
: Add macro to define CSR register types
We could also potentially add a Adding a |
I was thinking more about Regarding option 1: I would prefer to leave as less dependencies as possible in Regarding the |
Agreed, I just included it because it reduces the verbosity of the macro call.
Yes, it would be a macro parameter to define the valid bitmask for the register. For example, a register with valid fields bitranges Which would then allow us to provide a safe interfaces for creating/setting all fileds at once: pub const fn from_bits(val: usize) -> Self {
Self { bits: val & $mask }
}
pub const fn bits(&self) -> usize {
self.bits & $mask
}
I don't think this is something we really need to worry about in the macro. Since we are effectively implementing a WLRL (write-legal, read-legal), by only providing interfaces to set legal fields. For additional constraints like: "Field-A is only writable when Field-B is What are the situations for WARL registers you think need to be covered that aren't currently addressed by the macro? After thinking some more about the macro, and more generally the interfaces we want to provide, should we also provide another variant that takes in a multi-bit mask that covers a single field? For example, say we have a field with the bitrange Currently, there are only two variants:
|
I think you could open a PR as an RFC where we could work on an implementation with reviews etc. and we can see how it would look like. What do you think? |
Sounds good to me, I'll add some things we discussed here, and open a PR. |
As discussed in #217, it would be nice to have a macro to define CSR register types.
I worked on a couple solutions:
paste
crate: master...rmsyn:riscv:riscv/csr-macro-pastepaste
crate as a dependency, and exposing thepaste!
macro as a public re-exportpaste
crate: master...rmsyn:riscv:riscv/csr-macro-no-pasteset_<field>
values/// Gets the field value.
What are some thoughts and/or preferences about the two implementations?
The text was updated successfully, but these errors were encountered: