Encapsulate PMP reset

This commit is contained in:
Andrew Waterman 2019-01-23 11:39:53 -08:00
parent e86a4df663
commit d859a1c048
2 changed files with 6 additions and 4 deletions

View File

@ -873,10 +873,7 @@ class CSRFile(
bp := new BP().fromBits(0)
for (pmp <- reg_pmp) {
pmp.cfg.res := 0
when (reset) {
pmp.cfg.a := 0
pmp.cfg.l := 0
}
when (reset) { pmp.reset() }
}
for (((t, insn), i) <- (io.trace zip io.inst).zipWithIndex) {

View File

@ -32,6 +32,11 @@ class PMPReg(implicit p: Parameters) extends CoreBundle()(p) {
val cfg = new PMPConfig
val addr = UInt(width = paddrBits - PMP.lgAlign)
def reset() {
cfg.a := 0
cfg.l := 0
}
def readAddr = if (pmpGranularity.log2 == PMP.lgAlign) addr else {
val mask = ((BigInt(1) << (pmpGranularity.log2 - PMP.lgAlign)) - 1).U
Mux(napot, addr | (mask >> 1), ~(~addr | mask))