-
Notifications
You must be signed in to change notification settings - Fork 16
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
User Mode and remaining mstatus fields #729
Conversation
coreblocks/func_blocks/csr/csr.py
Outdated
# Temporary, until privileged spec is implemented | ||
priv_level = Signal(PrivilegeLevel, reset=PrivilegeLevel.MACHINE) | ||
priv_level = Signal(PrivilegeLevel) | ||
with Transaction().body(m): |
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 an always running transaction, right? We'll need a way to assert that easily in Transactron. For now, maybe state this in a comment?
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.
Call moved to other internal transaction.
Side note: It could be relatively easily asserted with naming transaction and asserting .grant
. But is the assertion really needed for single-use transaction only to read nonexclusive and always-ready by definition CSR method?
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.
Call moved to other internal transaction.
But this will make critical path longer :(
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.
But is the assertion really needed for single-use transaction only to read nonexclusive and always-ready by definition CSR method?
It is not, but in time code gets modified. It could happen that someone added another, potentially blocking, method call to the transaction, which could then create some kind of a heisenbug. Assertions help protect against future mistakes.
Because it's not the first time something like this happens, maybe some short way for asserting this is needed - e.g. using a keyword argument for Transaction().body
.
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.
But this will make critical path longer :(
Why?
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.
Because now it is under Switch.
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.
But the output of the read
method does not depend combinationally on the run
signal.
coreblocks/priv/csr/csr_instances.py
Outdated
self.priv_mode = CSRRegister( | ||
None, | ||
gen_params, | ||
width=2, |
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.
Not something for this PR, but what about accepting arbitrary shapes in CSR definitions? This would allow, e.g., using strongly typed Enum
instead of weakly typed IntEnum
more.
For now, I would write:
width=2, | |
width=Shape.cast(PrivilegeLevel), |
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.
I'm not sure if that would be too beneficial, as CSR can be written with arbitrary values from functional unit and typing could be wrong in some cases.
|
||
|
||
@unique | ||
class MstatusFieldOffsets(IntEnum): |
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.
Why there is no SD field?
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.
because SD
field has variable position (last bit of mstatus different on 32/64), but now I added it with value -1, so position is calculated from MstatusFieldOffsets.SD % mstatus.width
coreblocks/priv/csr/csr_instances.py
Outdated
with m.Case(PrivilegeLevel.USER): | ||
m.d.comb += legal.eq(gen_params.user_mode) | ||
with m.Default(): | ||
pass |
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.
Shouldn't be 0
? So that Supervisor mode will be illegal?
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.
0
is a default value, updated to set it explicitely
No description provided.