Combine all the PMP logic into one FSM
This commit is contained in:
parent
2a4ca0b249
commit
342b06128f
|
@ -160,7 +160,7 @@ class PmpPlugin(regions : Int, granularity : Int, ioRange : UInt => Bool) extend
|
||||||
}
|
}
|
||||||
when (pmpaddrCsr) {
|
when (pmpaddrCsr) {
|
||||||
csrService.allowCsr()
|
csrService.allowCsr()
|
||||||
csrService.readData() := pmpaddr.readAsync(pmpNcfg).asBits
|
csrService.readData() := pmpaddr(pmpNcfg).asBits
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,28 +173,12 @@ class PmpPlugin(regions : Int, granularity : Int, ioRange : UInt => Bool) extend
|
||||||
writeData_ := csrService.writeData()
|
writeData_ := csrService.writeData()
|
||||||
pmpNcfg_ := pmpNcfg
|
pmpNcfg_ := pmpNcfg
|
||||||
pmpcfgN_ := pmpcfgN
|
pmpcfgN_ := pmpcfgN
|
||||||
pmpaddrCsr_ := pmpcfgCsr
|
pmpcfgCsr_ := pmpcfgCsr
|
||||||
pmpcfgCsr_ := pmpaddrCsr
|
pmpaddrCsr_ := pmpaddrCsr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val writer = new Area {
|
|
||||||
when (pending) {
|
|
||||||
arbitration.haltItself := True
|
|
||||||
when (hazardFree & pmpaddrCsr_) {
|
|
||||||
val overwrite = writeData_.subdivideIn(8 bits)
|
|
||||||
for (i <- 0 until 4) {
|
|
||||||
when (~pmpcfg(pmpcfgN_ @@ U(i, 2 bits))(lBit)) {
|
|
||||||
pmpcfg(pmpcfgN_ @@ U(i, 2 bits)).assignFromBits(overwrite(i))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val locked = pmpcfg(pmpNcfg_)(lBit)
|
|
||||||
pmpaddr.write(pmpNcfg_, writeData_.asUInt, ~locked & pmpcfgCsr_ & pending & hazardFree)
|
|
||||||
}
|
|
||||||
|
|
||||||
val controller = new StateMachine {
|
val controller = new StateMachine {
|
||||||
val enable = RegInit(False)
|
val enable = RegInit(False)
|
||||||
val counter = Reg(UInt(log2Up(regions) bits)) init(0)
|
val counter = Reg(UInt(log2Up(regions) bits)) init(0)
|
||||||
|
@ -205,21 +189,38 @@ class PmpPlugin(regions : Int, granularity : Int, ioRange : UInt => Bool) extend
|
||||||
enable := False
|
enable := False
|
||||||
counter := 0
|
counter := 0
|
||||||
}
|
}
|
||||||
onExit {
|
|
||||||
enable := True
|
|
||||||
arbitration.haltItself := True
|
|
||||||
}
|
|
||||||
whenIsActive {
|
whenIsActive {
|
||||||
when (pending & hazardFree) {
|
when (pending) {
|
||||||
when (pmpaddrCsr_) {
|
arbitration.haltItself := True
|
||||||
goto(stateCfg)
|
when (hazardFree) {
|
||||||
}.elsewhen (pmpcfgCsr_) {
|
goto(stateWrite)
|
||||||
goto(stateAddr)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val stateWrite : State = new State {
|
||||||
|
onExit (enable := True)
|
||||||
|
whenIsActive {
|
||||||
|
arbitration.haltItself := True
|
||||||
|
when (pmpcfgCsr_) {
|
||||||
|
val overwrite = writeData_.subdivideIn(8 bits)
|
||||||
|
for (i <- 0 until 4) {
|
||||||
|
when (~pmpcfg(pmpcfgN_ @@ U(i, 2 bits))(lBit)) {
|
||||||
|
pmpcfg(pmpcfgN_ @@ U(i, 2 bits)).assignFromBits(overwrite(i))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
goto(stateCfg)
|
||||||
|
}
|
||||||
|
when (pmpaddrCsr_) {
|
||||||
|
when (~pmpcfg(pmpNcfg_)(lBit)) {
|
||||||
|
pmpaddr(pmpNcfg_) := writeData_.asUInt
|
||||||
|
}
|
||||||
|
goto(stateAddr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val stateCfg : State = new State {
|
val stateCfg : State = new State {
|
||||||
onEntry (counter := pmpcfgN_ @@ U(0, 2 bits))
|
onEntry (counter := pmpcfgN_ @@ U(0, 2 bits))
|
||||||
whenIsActive {
|
whenIsActive {
|
||||||
|
@ -237,10 +238,10 @@ class PmpPlugin(regions : Int, granularity : Int, ioRange : UInt => Bool) extend
|
||||||
whenIsActive (goto(stateIdle))
|
whenIsActive (goto(stateIdle))
|
||||||
}
|
}
|
||||||
|
|
||||||
when (pmpcfgCsr_) {
|
when (pmpaddrCsr_) {
|
||||||
setter.io.addr := writeData_.asUInt
|
setter.io.addr := writeData_.asUInt
|
||||||
} otherwise {
|
} otherwise {
|
||||||
setter.io.addr := pmpaddr.readAsync(counter)
|
setter.io.addr := pmpaddr(counter)
|
||||||
}
|
}
|
||||||
|
|
||||||
when (enable & ~pmpcfg(counter)(lBit)) {
|
when (enable & ~pmpcfg(counter)(lBit)) {
|
||||||
|
|
Loading…
Reference in New Issue