fix(csr): 修复mpp写问题
This commit is contained in:
parent
69f5974661
commit
5512fb26ec
|
@ -100,6 +100,9 @@ class Csr(implicit val config: CpuConfig) extends Module with HasCSRConst {
|
||||||
val pmpaddr3 = RegInit(UInt(XLEN.W), 0.U)
|
val pmpaddr3 = RegInit(UInt(XLEN.W), 0.U)
|
||||||
val pmpaddrWmask = "h3fffffff".U(64.W) // 32bit physical address
|
val pmpaddrWmask = "h3fffffff".U(64.W) // 32bit physical address
|
||||||
|
|
||||||
|
val rdata = Wire(UInt(XLEN.W))
|
||||||
|
val wdata = Wire(UInt(XLEN.W))
|
||||||
|
|
||||||
// Side Effect
|
// Side Effect
|
||||||
def mstatusUpdateSideEffect(mstatus: UInt): UInt = {
|
def mstatusUpdateSideEffect(mstatus: UInt): UInt = {
|
||||||
val mstatusOld = WireInit(mstatus.asTypeOf(new Mstatus))
|
val mstatusOld = WireInit(mstatus.asTypeOf(new Mstatus))
|
||||||
|
@ -107,6 +110,12 @@ class Csr(implicit val config: CpuConfig) extends Module with HasCSRConst {
|
||||||
mstatusNew
|
mstatusNew
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val mstatus_wmask = Mux(
|
||||||
|
wdata.asTypeOf(new Mstatus).mpp === ModeM || wdata.asTypeOf(new Mstatus).mpp === ModeU,
|
||||||
|
"h0000000000021888".U(64.W),
|
||||||
|
"h0000000000020088".U(64.W)
|
||||||
|
)
|
||||||
|
|
||||||
// CSR reg map
|
// CSR reg map
|
||||||
val mapping = Map(
|
val mapping = Map(
|
||||||
// User Trap Setup
|
// User Trap Setup
|
||||||
|
@ -151,7 +160,7 @@ class Csr(implicit val config: CpuConfig) extends Module with HasCSRConst {
|
||||||
MaskedRegMap(Mimpid, mimpid, 0.U, MaskedRegMap.Unwritable),
|
MaskedRegMap(Mimpid, mimpid, 0.U, MaskedRegMap.Unwritable),
|
||||||
MaskedRegMap(Mhartid, mhartid, 0.U, MaskedRegMap.Unwritable),
|
MaskedRegMap(Mhartid, mhartid, 0.U, MaskedRegMap.Unwritable),
|
||||||
// Machine Trap Setup
|
// Machine Trap Setup
|
||||||
MaskedRegMap(Mstatus, mstatus, "h0000000000021888".U(64.W)),
|
MaskedRegMap(Mstatus, mstatus, mstatus_wmask),
|
||||||
MaskedRegMap(Misa, misa), // now MXL, EXT is not changeable
|
MaskedRegMap(Misa, misa), // now MXL, EXT is not changeable
|
||||||
// MaskedRegMap(Medeleg, medeleg, "hbbff".U(64.W)), TODO
|
// MaskedRegMap(Medeleg, medeleg, "hbbff".U(64.W)), TODO
|
||||||
// MaskedRegMap(Mideleg, mideleg, "h222".U(64.W)),
|
// MaskedRegMap(Mideleg, mideleg, "h222".U(64.W)),
|
||||||
|
@ -214,12 +223,11 @@ class Csr(implicit val config: CpuConfig) extends Module with HasCSRConst {
|
||||||
val op = io.executeUnit.in.inst_info.op
|
val op = io.executeUnit.in.inst_info.op
|
||||||
val fusel = io.executeUnit.in.inst_info.fusel
|
val fusel = io.executeUnit.in.inst_info.fusel
|
||||||
val addr = io.executeUnit.in.inst_info.inst(31, 20)
|
val addr = io.executeUnit.in.inst_info.inst(31, 20)
|
||||||
val rdata = Wire(UInt(XLEN.W))
|
|
||||||
val src1 = io.executeUnit.in.src_info.src1_data
|
val src1 = io.executeUnit.in.src_info.src1_data
|
||||||
val csri = ZeroExtend(io.executeUnit.in.inst_info.inst(19, 15), XLEN)
|
val csri = ZeroExtend(io.executeUnit.in.inst_info.inst(19, 15), XLEN)
|
||||||
val exe_stall = io.ctrl.exe_stall
|
val exe_stall = io.ctrl.exe_stall
|
||||||
val mem_stall = io.ctrl.mem_stall
|
val mem_stall = io.ctrl.mem_stall
|
||||||
val wdata = LookupTree(
|
wdata := LookupTree(
|
||||||
op,
|
op,
|
||||||
List(
|
List(
|
||||||
CSROpType.wrt -> src1,
|
CSROpType.wrt -> src1,
|
||||||
|
|
Loading…
Reference in New Issue