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

CLIC: Spec chapter 5.1 #485

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed issue where a write to mcause.mpie used the wrong index into ms…
…tatus.

Signed-off-by: Oystein Knauserud <[email protected]>
silabs-oysteink committed Mar 23, 2022

Unverified

This user has not yet uploaded their public signing key.
commit 38b6ce930e6226cf1ea0475b160a8c2824c91fa9
37 changes: 27 additions & 10 deletions rtl/cv32e40x_cs_registers.sv
Original file line number Diff line number Diff line change
@@ -534,16 +534,33 @@ module cv32e40x_cs_registers import cv32e40x_pkg::*;
dscratch1_n = csr_wdata_int;
dscratch1_we = 1'b0;

// todo: when SD/XS/FS/VS are implemented, a write to mcause.mpp/mpie
// must be handled correctly to not corrupt the mentioned bitfields.
mstatus_n = '{
tw: 1'b0,
mprv: 1'b0,
mpp: PRIV_LVL_M,
mpie: csr_wdata_int[MSTATUS_MPIE_BIT],
mie: csr_wdata_int[MSTATUS_MIE_BIT],
default: 'b0
};
if (SMCLIC) begin
// SMCLIC: A write to mcause.mpp or mcause.mpie is stored in mstatus
Copy link
Contributor

Choose a reason for hiding this comment

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

Same remark as above: 'CLIC mode is assumed when SMCLIC = 1'.

if(mcause_we) begin
mstatus_n = mstatus_q;
mstatus_n.mpp = PRIV_LVL_M;
mstatus_n.mpie = csr_wdata_int[MCAUSE_MPIE_BIT];
end else begin
// TODO: add support for SD/XS/FS/VS
mstatus_n = '{
Copy link
Contributor

Choose a reason for hiding this comment

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

Reorganize code to avoid this code duplication. Simply first do the original mstatus_n assignment and then a if (SMCLIC) if (mcause_we)

tw: 1'b0,
mprv: 1'b0,
mpp: PRIV_LVL_M,
mpie: csr_wdata_int[MSTATUS_MPIE_BIT],
mie: csr_wdata_int[MSTATUS_MIE_BIT],
default: 'b0
};
end
end else begin
mstatus_n = '{
tw: 1'b0,
mprv: 1'b0,
mpp: PRIV_LVL_M,
mpie: csr_wdata_int[MSTATUS_MPIE_BIT],
mie: csr_wdata_int[MSTATUS_MIE_BIT],
default: 'b0
};
end // SMCLIC
mstatus_we = 1'b0;

// SMCLIC: Not setting mpp or mpie, as these are stored in mstatus
2 changes: 2 additions & 0 deletions rtl/include/cv32e40x_pkg.sv
Original file line number Diff line number Diff line change
@@ -468,6 +468,8 @@ parameter NUM_HPM_EVENTS = 16;
parameter MSTATUS_MIE_BIT = 3;
parameter MSTATUS_MPIE_BIT = 7;

parameter MCAUSE_MPIE_BIT = 27;

// misa
parameter logic [1:0] MXL = 2'd1; // M-XLEN: XLEN in M-Mode for RV32