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

Updates to mret/xinhv handling. #331

Merged
merged 2 commits into from Oct 27, 2022

Conversation

silabs-oysteink
Copy link
Contributor

Updated handling of mret related to mcause.mpp and mcause.minhv. No inhv assumes for mpp==PRIV_LVL_U. Unique case violation in cs_registers due to clearing of minhv fixed, assertions added to make sure there is no conflicting writes to mcause.

When merged, this PR will be cherry picked to the E40X to apply the changes there. Should fix issue #498 on CV32E40X when done.

…nhv assumes for mpp==PRIV_LVL_U. Unique case violation in cs_registers due to clearing of minhv fixed, assertions added to make sure there is no conflicting writes to mcause.

Signed-off-by: Oystein Knauserud <Oystein.Knauserud@silabs.com>

Added comments and assertions to explain why the clearing of mcause.minhv is allowed to happen at the same time as an mret updates CSRs from the WB stage. Other updates to comments to clarify minhv handling.

Signed-off-by: Oystein Knauserud <Oystein.Knauserud@silabs.com>
@silabs-oysteink silabs-oysteink added the Component:RTL For issues in the RTL (e.g. for files in the rtl directory) label Oct 26, 2022
@@ -753,6 +761,9 @@ module cv32e40s_controller_fsm import cv32e40s_pkg::*;
ctrl_fsm_o.csr_save_cause = !debug_mode_q; // Do not update CSRs if in debug mode
ctrl_fsm_o.csr_cause.exception_code = exception_cause_wb;

// Keep mcause.minhv when taking exceptions and interrupts, only cleared on successful pointer fetches or CSR writes.
ctrl_fsm_o.csr_cause.minhv = mcause_i.minhv;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have an assertion checking that various CLIC related signals are inactive when SMCLIC=0?

E.g.FSM is never in POINTER_FETCH state, ctrl_fsm_o.csr_cause.minhv is 1'b0, mcause_i.minhv = 1'b0, *.instr_meta.clic_ptr = 1'b0, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added assertion.

// The fields mstatus.mpp and mstatus.mpie er aliased between mcause and mstatus. The mcause write
// due to csr_celar_minhv will however only write to mcause.minhv, and no updates to mstatus.mpp/mpie.
if (ctrl_fsm_i.csr_clear_minhv) begin
if (SMCLIC) begin
Copy link
Contributor

Choose a reason for hiding this comment

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

Can if (SMCLI) be made the 'outer if' instead (for code coverage reasons)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Order of if's fixed.

…CLIC=0.

Refactored order of if statement for coverage purposes.

Signed-off-by: Oystein Knauserud <Oystein.Knauserud@silabs.com>
@Silabs-ArjanB Silabs-ArjanB merged commit 6ef4354 into openhwgroup:master Oct 27, 2022
silabs-oysteink pushed a commit to silabs-oysteink/cv32e40s that referenced this pull request Nov 2, 2022
Updates to mret/xinhv handling.

Signed-off-by: Oystein Knauserud <Oystein.Knauserud@silabs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component:RTL For issues in the RTL (e.g. for files in the rtl directory)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants