-
Notifications
You must be signed in to change notification settings - Fork 164
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
Fix error in senvcfg definition #413
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good spot. I don't think there's any issue using the same type for both since the lower 32 bits are the same? However we have ended up splitting the legalize functions up as you have done here so I think that is a good idea (also needed for PBMT).
function legalize_envcfg(o : Envcfg, v : bits(64)) -> Envcfg = { | ||
let v = Mk_Envcfg(v); | ||
function legalize_senvcfg(o : SEnvcfg, v : bits(64)) -> SEnvcfg = { | ||
let v = Mk_SEnvcfg(v); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this actually compile on RV32? You have v
as 64-bit and SEnvcfg
as 32-bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. v should also be xlenbits. I will fix that. SEnvcfg is not 32-bit - its xlenbits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fixed.
|
Correct, but the code to read/write |
The underlying type is not 64 bits. Its xlenbits - xlenbits is 32 or 64 based on xlen. When both MXLEN and SXLEN are 64-bit, the current implementation would allow storing setting PBMTE/ADUE/STCE/CDE bits in senvcfg. The common legalizer is also a problem because it does not allow legalizing senvcfg based on menvcfg as needed by some ISA extensions - such as this rule - "The Zicfiss extension adds the SSE field (bit 3) to menvcfg. When the SSE field is set to 1 the Zicfiss extension is activated in S-mode. Zicfiss extension introduces the SSE field (bit 3) in senvcfg. When menvcfg.SSE field is 0, the henvcfg.SSE and senvcfg.SSE fields will read as zero and are read-only. " |
I mean the underlying type of
Right, but we fixed (privately) that just by splitting the legalize functions. I still don't think there's any need to split the register type. Here's our current code:
This implementation does not allow storing Maybe need a third opinion on the readability. I guess since you changed it that's at least one data point that having both registers use the same type is confusing! |
We should have the formal model to be clear about the types. And if someday documentation is going to be generated, as envisioned, from sail then this will be not very helpful. |
I don't really know much about the formal models (will defer to @arichardson / @Alasdair there). Good point about the documentation though. You can generate register diagrams from Sail's |
senvcfg
in thesenvcfg
register.The
menvcfg
andsenvcfg
should be legalized separately as they do not hold identical fields.senvcfg
is SXLEN wide and not 64-bit wide.