Browse Source

AIA: Let mvien.SSIP be writable

When mvien.SSIP=0, mvip.SSIP is an alias of mip.SSIP. Accessing
mvip.SSIP reads from and writes to mip.SSIP.

When mvien.SSIP=1, mvip.SSIP is a separate writable bit independent of
mip.SSIP. Accessing mvip.SSIP reads from and writes to the separate,
writable, independent bit normally.
pull/1988/head
YenHaoChen 2 years ago
committed by Binno
parent
commit
929d671211
  1. 2
      riscv/csr_init.cc
  2. 10
      riscv/csrs.cc

2
riscv/csr_init.cc

@ -475,7 +475,7 @@ void state_t::csr_init(processor_t* const proc, reg_t max_isa)
const reg_t srmcfg_mask = SRMCFG_MCID | SRMCFG_RCID;
add_const_ext_csr(EXT_SSQOSID, CSR_SRMCFG, std::make_shared<srmcfg_csr_t>(proc, CSR_SRMCFG, srmcfg_mask, 0));
mvien = std::make_shared<const_csr_t>(proc, CSR_MVIEN, 0);
mvien = std::make_shared<masked_csr_t>(proc, CSR_MVIEN, MIP_SSIP, 0);
mvip = std::make_shared<mvip_csr_t>(proc, CSR_MVIP, 0);
if (proc->extension_enabled_const(EXT_SMAIA)) {
add_csr(CSR_MTOPI, std::make_shared<mtopi_csr_t>(proc, CSR_MTOPI));

10
riscv/csrs.cc

@ -1999,12 +1999,14 @@ mvip_csr_t::mvip_csr_t(processor_t* const proc, const reg_t addr, const reg_t in
}
reg_t mvip_csr_t::read() const noexcept {
const reg_t val = basic_csr_t::read();
const reg_t mvien = state->mvien->read();
const reg_t mip = state->mip->read();
const reg_t menvcfg = state->menvcfg->read();
return 0
| (mip & MIP_SEIP)
| ((menvcfg & MENVCFG_STCE) ? 0 : (mip & MIP_STIP))
| (mip & MIP_SSIP)
| (((mvien & MIP_SSIP) ? val : mip) & MIP_SSIP)
;
}
@ -2012,7 +2014,9 @@ bool mvip_csr_t::unlogged_write(const reg_t val) noexcept {
state->mip->write_with_mask(MIP_SEIP, val);
if (!(state->menvcfg->read() & MENVCFG_STCE))
state->mip->write_with_mask(MIP_STIP, val); // mvip.STIP is an alias of mip.STIP when mip.STIP is writable
state->mip->write_with_mask(MIP_SSIP, val);
if (!(state->mvien->read() & MIP_SSIP))
state->mip->write_with_mask(MIP_SSIP, val); // mvip.SSIP is an alias of mip.SSIP when mvien.SSIP=0
return false;
const reg_t new_val = ((state->mvien->read() & MIP_SSIP) ? val : basic_csr_t::read()) & MIP_SSIP;
return basic_csr_t::unlogged_write(new_val);
}

Loading…
Cancel
Save