Skip to content

Commit

Permalink
Additional correction for issue #896 to manage MSTATUS.FS write confl…
Browse files Browse the repository at this point in the history
…ict between CSRW and FLW.

Signed-off-by: Pascal Gouedo <[email protected]>
  • Loading branch information
Pascal Gouedo committed Nov 6, 2023
1 parent 0f3c925 commit e6f2800
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions rtl/cv32e40p_cs_registers.sv
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ module cv32e40p_cs_registers

logic [31:0] exception_pc;
Status_t mstatus_q, mstatus_n;
logic mstatus_we_int;
FS_t mstatus_fs_q, mstatus_fs_n;
logic [5:0] mcause_q, mcause_n;
logic [5:0] ucause_q, ucause_n;
Expand Down Expand Up @@ -898,6 +899,7 @@ module cv32e40p_cs_registers
dscratch0_n = dscratch0_q;
dscratch1_n = dscratch1_q;

mstatus_we_int = 1'b0;
mstatus_n = mstatus_q;
mcause_n = mcause_q;
ucause_n = '0; // Not used if PULP_SECURE == 0
Expand Down Expand Up @@ -958,7 +960,8 @@ module cv32e40p_cs_registers
mprv: csr_wdata_int[MSTATUS_MPRV_BIT]
};
if (FPU == 1 && ZFINX == 0) begin
mstatus_fs_n = FS_t'(csr_wdata_int[MSTATUS_FS_BIT_HIGH:MSTATUS_FS_BIT_LOW]);
mstatus_we_int = 1'b1;
mstatus_fs_n = FS_t'(csr_wdata_int[MSTATUS_FS_BIT_HIGH:MSTATUS_FS_BIT_LOW]);
end
end
// mie: machine interrupt enable
Expand Down Expand Up @@ -1028,7 +1031,7 @@ module cv32e40p_cs_registers

if (ZFINX == 0) begin
// FPU Register File/Flags implicit update or modified by CSR instructions
if (fregs_we_i || fflags_we_i || fcsr_update) begin
if ((fregs_we_i && !(mstatus_we_int && mstatus_fs_n != FS_DIRTY)) || fflags_we_i || fcsr_update) begin
mstatus_fs_n = FS_DIRTY;
end
end
Expand Down

0 comments on commit e6f2800

Please sign in to comment.