mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Update csrsr.sv
Program clean up
This commit is contained in:
parent
fbdf76629f
commit
6866a9c541
@ -140,22 +140,22 @@ module csrsr import cvw::*; #(parameter cvw_t P) (
|
|||||||
// complex register with reset, write enable, and the ability to update other bits in certain cases
|
// complex register with reset, write enable, and the ability to update other bits in certain cases
|
||||||
always_ff @(posedge clk) //, posedge reset)
|
always_ff @(posedge clk) //, posedge reset)
|
||||||
if (reset) begin
|
if (reset) begin
|
||||||
STATUS_TSR_INT <= #1 0;
|
STATUS_TSR_INT <= #1 0;
|
||||||
STATUS_TW_INT <= #1 0;
|
STATUS_TW_INT <= #1 0;
|
||||||
STATUS_TVM_INT <= #1 0;
|
STATUS_TVM_INT <= #1 0;
|
||||||
STATUS_MXR_INT <= #1 0;
|
STATUS_MXR_INT <= #1 0;
|
||||||
STATUS_SUM_INT <= #1 0;
|
STATUS_SUM_INT <= #1 0;
|
||||||
STATUS_MPRV_INT <= #1 0; // Per Priv 3.3
|
STATUS_MPRV_INT <= #1 0; // Per Priv 3.3
|
||||||
STATUS_FS_INT <= #1 P.F_SUPPORTED ? 2'b00 : 2'b00; // leave floating-point off until activated, even if F_SUPPORTED
|
STATUS_FS_INT <= #1 P.F_SUPPORTED ? 2'b00 : 2'b00; // leave floating-point off until activated, even if F_SUPPORTED
|
||||||
STATUS_MPP <= #1 0;
|
STATUS_MPP <= #1 0;
|
||||||
STATUS_SPP <= #1 0;
|
STATUS_SPP <= #1 0;
|
||||||
STATUS_MPIE <= #1 0;
|
STATUS_MPIE <= #1 0;
|
||||||
STATUS_SPIE <= #1 0;
|
STATUS_SPIE <= #1 0;
|
||||||
STATUS_MIE <= #1 0;
|
STATUS_MIE <= #1 0;
|
||||||
STATUS_SIE <= #1 0;
|
STATUS_SIE <= #1 0;
|
||||||
STATUS_MBE <= #1 0;
|
STATUS_MBE <= #1 0;
|
||||||
STATUS_SBE <= #1 0;
|
STATUS_SBE <= #1 0;
|
||||||
STATUS_UBE <= #1 0;
|
STATUS_UBE <= #1 0;
|
||||||
end else if (~StallW) begin
|
end else if (~StallW) begin
|
||||||
if (TrapM) begin
|
if (TrapM) begin
|
||||||
// Update interrupt enables per Privileged Spec p. 21
|
// Update interrupt enables per Privileged Spec p. 21
|
||||||
@ -164,54 +164,54 @@ module csrsr import cvw::*; #(parameter cvw_t P) (
|
|||||||
// Modes: 11 = Machine, 01 = Supervisor, 00 = User
|
// Modes: 11 = Machine, 01 = Supervisor, 00 = User
|
||||||
if (NextPrivilegeModeM == P.M_MODE) begin
|
if (NextPrivilegeModeM == P.M_MODE) begin
|
||||||
STATUS_MPIE <= #1 STATUS_MIE;
|
STATUS_MPIE <= #1 STATUS_MIE;
|
||||||
STATUS_MIE <= #1 0;
|
STATUS_MIE <= #1 0;
|
||||||
STATUS_MPP <= #1 PrivilegeModeW;
|
STATUS_MPP <= #1 PrivilegeModeW;
|
||||||
end else begin // supervisor mode
|
end else begin // supervisor mode
|
||||||
STATUS_SPIE <= #1 STATUS_SIE;
|
STATUS_SPIE <= #1 STATUS_SIE;
|
||||||
STATUS_SIE <= #1 0;
|
STATUS_SIE <= #1 0;
|
||||||
STATUS_SPP <= #1 PrivilegeModeW[0];
|
STATUS_SPP <= #1 PrivilegeModeW[0];
|
||||||
end
|
end
|
||||||
end else if (mretM) begin // Privileged 3.1.6.1
|
end else if (mretM) begin // Privileged 3.1.6.1
|
||||||
STATUS_MIE <= #1 STATUS_MPIE; // restore global interrupt enable
|
STATUS_MIE <= #1 STATUS_MPIE; // restore global interrupt enable
|
||||||
STATUS_MPIE <= #1 1; //
|
STATUS_MPIE <= #1 1; //
|
||||||
STATUS_MPP <= #1 P.U_SUPPORTED ? P.U_MODE : P.M_MODE; // set MPP to lowest supported privilege level
|
STATUS_MPP <= #1 P.U_SUPPORTED ? P.U_MODE : P.M_MODE; // set MPP to lowest supported privilege level
|
||||||
STATUS_MPRV_INT <= #1 STATUS_MPRV_INT & (STATUS_MPP == P.M_MODE); // page 21 of privileged spec.
|
STATUS_MPRV_INT <= #1 STATUS_MPRV_INT & (STATUS_MPP == P.M_MODE); // page 21 of privileged spec.
|
||||||
end else if (sretM) begin
|
end else if (sretM) begin
|
||||||
STATUS_SIE <= #1 STATUS_SPIE; // restore global interrupt enable
|
STATUS_SIE <= #1 STATUS_SPIE; // restore global interrupt enable
|
||||||
STATUS_SPIE <= #1 P.S_SUPPORTED;
|
STATUS_SPIE <= #1 P.S_SUPPORTED;
|
||||||
STATUS_SPP <= #1 0; // set SPP to lowest supported privilege level to catch bugs
|
STATUS_SPP <= #1 0; // set SPP to lowest supported privilege level to catch bugs
|
||||||
STATUS_MPRV_INT <= #1 0; // always clear MPRV
|
STATUS_MPRV_INT <= #1 0; // always clear MPRV
|
||||||
end else if (WriteMSTATUSM) begin
|
end else if (WriteMSTATUSM) begin
|
||||||
STATUS_TSR_INT <= #1 CSRWriteValM[22];
|
STATUS_TSR_INT <= #1 CSRWriteValM[22];
|
||||||
STATUS_TW_INT <= #1 CSRWriteValM[21];
|
STATUS_TW_INT <= #1 CSRWriteValM[21];
|
||||||
STATUS_TVM_INT <= #1 CSRWriteValM[20];
|
STATUS_TVM_INT <= #1 CSRWriteValM[20];
|
||||||
STATUS_MXR_INT <= #1 CSRWriteValM[19];
|
STATUS_MXR_INT <= #1 CSRWriteValM[19];
|
||||||
STATUS_SUM_INT <= #1 CSRWriteValM[18];
|
STATUS_SUM_INT <= #1 CSRWriteValM[18];
|
||||||
STATUS_MPRV_INT <= #1 CSRWriteValM[17];
|
STATUS_MPRV_INT <= #1 CSRWriteValM[17];
|
||||||
STATUS_FS_INT <= #1 CSRWriteValM[14:13];
|
STATUS_FS_INT <= #1 CSRWriteValM[14:13];
|
||||||
STATUS_MPP <= #1 STATUS_MPP_NEXT;
|
STATUS_MPP <= #1 STATUS_MPP_NEXT;
|
||||||
STATUS_SPP <= #1 P.S_SUPPORTED & CSRWriteValM[8];
|
STATUS_SPP <= #1 P.S_SUPPORTED & CSRWriteValM[8];
|
||||||
STATUS_MPIE <= #1 CSRWriteValM[7];
|
STATUS_MPIE <= #1 CSRWriteValM[7];
|
||||||
STATUS_SPIE <= #1 P.S_SUPPORTED & CSRWriteValM[5];
|
STATUS_SPIE <= #1 P.S_SUPPORTED & CSRWriteValM[5];
|
||||||
STATUS_MIE <= #1 CSRWriteValM[3];
|
STATUS_MIE <= #1 CSRWriteValM[3];
|
||||||
STATUS_SIE <= #1 P.S_SUPPORTED & CSRWriteValM[1];
|
STATUS_SIE <= #1 P.S_SUPPORTED & CSRWriteValM[1];
|
||||||
STATUS_UBE <= #1 CSRWriteValM[6] & P.U_SUPPORTED & P.BIGENDIAN_SUPPORTED;
|
STATUS_UBE <= #1 CSRWriteValM[6] & P.U_SUPPORTED & P.BIGENDIAN_SUPPORTED;
|
||||||
STATUS_MBE <= #1 nextMBE;
|
STATUS_MBE <= #1 nextMBE;
|
||||||
STATUS_SBE <= #1 nextSBE;
|
STATUS_SBE <= #1 nextSBE;
|
||||||
// coverage off
|
// coverage off
|
||||||
// MSTATUSH only exists in 32-bit configurations, will not be hit on rv64gc
|
// MSTATUSH only exists in 32-bit configurations, will not be hit on rv64gc
|
||||||
end else if (WriteMSTATUSHM) begin
|
end else if (WriteMSTATUSHM) begin
|
||||||
STATUS_MBE <= #1 CSRWriteValM[5] & P.BIGENDIAN_SUPPORTED;
|
STATUS_MBE <= #1 CSRWriteValM[5] & P.BIGENDIAN_SUPPORTED;
|
||||||
STATUS_SBE <= #1 CSRWriteValM[4] & P.S_SUPPORTED & P.BIGENDIAN_SUPPORTED;
|
STATUS_SBE <= #1 CSRWriteValM[4] & P.S_SUPPORTED & P.BIGENDIAN_SUPPORTED;
|
||||||
// coverage on
|
// coverage on
|
||||||
end else if (WriteSSTATUSM) begin // write a subset of the STATUS bits
|
end else if (WriteSSTATUSM) begin // write a subset of the STATUS bits
|
||||||
STATUS_MXR_INT <= #1 CSRWriteValM[19];
|
STATUS_MXR_INT <= #1 CSRWriteValM[19];
|
||||||
STATUS_SUM_INT <= #1 CSRWriteValM[18];
|
STATUS_SUM_INT <= #1 CSRWriteValM[18];
|
||||||
STATUS_FS_INT <= #1 CSRWriteValM[14:13];
|
STATUS_FS_INT <= #1 CSRWriteValM[14:13];
|
||||||
STATUS_SPP <= #1 P.S_SUPPORTED & CSRWriteValM[8];
|
STATUS_SPP <= #1 P.S_SUPPORTED & CSRWriteValM[8];
|
||||||
STATUS_SPIE <= #1 P.S_SUPPORTED & CSRWriteValM[5];
|
STATUS_SPIE <= #1 P.S_SUPPORTED & CSRWriteValM[5];
|
||||||
STATUS_SIE <= #1 P.S_SUPPORTED & CSRWriteValM[1];
|
STATUS_SIE <= #1 P.S_SUPPORTED & CSRWriteValM[1];
|
||||||
STATUS_UBE <= #1 CSRWriteValM[6] & P.U_SUPPORTED & P.BIGENDIAN_SUPPORTED;
|
STATUS_UBE <= #1 CSRWriteValM[6] & P.U_SUPPORTED & P.BIGENDIAN_SUPPORTED;
|
||||||
end else if (FRegWriteM | WriteFRMM | WriteFFLAGSM) STATUS_FS_INT <= #1 2'b11;
|
end else if (FRegWriteM | WriteFRMM | WriteFFLAGSM) STATUS_FS_INT <= #1 2'b11;
|
||||||
end
|
end
|
||||||
endmodule
|
endmodule
|
||||||
|
Loading…
Reference in New Issue
Block a user