From 21383ce16dfbe69480a079ec468b65bb26df39ff Mon Sep 17 00:00:00 2001 From: JeanRochCoulon Date: Fri, 21 Jun 2024 17:27:48 +0200 Subject: [PATCH] Fix mstatus.mpp in relation to the possible legal values (#2285) --- core/csr_regfile.sv | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/core/csr_regfile.sv b/core/csr_regfile.sv index f37a9f5dea..a01ccd808d 100644 --- a/core/csr_regfile.sv +++ b/core/csr_regfile.sv @@ -1283,11 +1283,10 @@ module csr_regfile mstatus_d.tw = riscv::Off; mstatus_d.mprv = riscv::Off; end - // If h-extension is not enabled, priv level HS is reserved - if (!CVA6Cfg.RVH) begin - if (mstatus_d.mpp == riscv::PRIV_LVL_HS) begin - mstatus_d.mpp = riscv::PRIV_LVL_U; - end + if ((!CVA6Cfg.RVH & mstatus_d.mpp == riscv::PRIV_LVL_HS) | + (!CVA6Cfg.RVS & mstatus_d.mpp == riscv::PRIV_LVL_S) | + (!CVA6Cfg.RVU & mstatus_d.mpp == riscv::PRIV_LVL_U)) begin + mstatus_d.mpp = mstatus_q.mpp; end mstatus_d.wpri3 = 9'b0; mstatus_d.wpri1 = 1'b0;