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

User Mode and remaining mstatus fields #729

Merged
merged 20 commits into from
Oct 9, 2024

Conversation

piotro888
Copy link
Member

No description provided.

@piotro888 piotro888 marked this pull request as ready for review September 30, 2024 14:42
@piotro888 piotro888 added the enhancement New feature or request label Sep 30, 2024
@piotro888 piotro888 added this to the Implement machine mode ISA milestone Sep 30, 2024
# Temporary, until privileged spec is implemented
priv_level = Signal(PrivilegeLevel, reset=PrivilegeLevel.MACHINE)
priv_level = Signal(PrivilegeLevel)
with Transaction().body(m):
Copy link
Member

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?

Copy link
Member Author

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?

Copy link
Contributor

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 :(

Copy link
Member

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.

Copy link
Member

@tilk tilk Oct 9, 2024

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?

Copy link
Contributor

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.

Copy link
Member

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.

self.priv_mode = CSRRegister(
None,
gen_params,
width=2,
Copy link
Member

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:

Suggested change
width=2,
width=Shape.cast(PrivilegeLevel),

Copy link
Member Author

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.

coreblocks/priv/csr/csr_instances.py Outdated Show resolved Hide resolved
coreblocks/priv/csr/csr_instances.py Outdated Show resolved Hide resolved
coreblocks/priv/csr/csr_instances.py Outdated Show resolved Hide resolved
coreblocks/priv/csr/csr_instances.py Show resolved Hide resolved
@piotro888 piotro888 requested a review from lekcyjna123 October 5, 2024 11:44


@unique
class MstatusFieldOffsets(IntEnum):
Copy link
Contributor

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?

Copy link
Member Author

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/arch/csr_address.py Outdated Show resolved Hide resolved
with m.Case(PrivilegeLevel.USER):
m.d.comb += legal.eq(gen_params.user_mode)
with m.Default():
pass
Copy link
Contributor

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?

Copy link
Member Author

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

@tilk tilk merged commit 0e2887a into kuznia-rdzeni:master Oct 9, 2024
13 checks passed
github-actions bot pushed a commit that referenced this pull request Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants