Add supervisor support in the ExternalInterruptArrayPlugin
This commit is contained in:
parent
3094f8b349
commit
01db217ab9
|
@ -310,7 +310,7 @@ trait IContextSwitching{
|
|||
def isContextSwitching : Bool
|
||||
}
|
||||
|
||||
class CsrPlugin(config: CsrPluginConfig) extends Plugin[VexRiscv] with ExceptionService with PrivilegeService with InterruptionInhibitor with ExceptionInhibitor with IContextSwitching with CsrInterface{
|
||||
class CsrPlugin(val config: CsrPluginConfig) extends Plugin[VexRiscv] with ExceptionService with PrivilegeService with InterruptionInhibitor with ExceptionInhibitor with IContextSwitching with CsrInterface{
|
||||
import config._
|
||||
import CsrAccess._
|
||||
|
||||
|
|
|
@ -3,7 +3,11 @@ package vexriscv.plugin
|
|||
import spinal.core._
|
||||
import vexriscv.VexRiscv
|
||||
|
||||
class ExternalInterruptArrayPlugin(arrayWidth : Int = 32, maskCsrId : Int = 0xBC0, pendingsCsrId : Int = 0xFC0) extends Plugin[VexRiscv]{
|
||||
class ExternalInterruptArrayPlugin(arrayWidth : Int = 32,
|
||||
machineMaskCsrId : Int = 0xBC0,
|
||||
machinePendingsCsrId : Int = 0xFC0,
|
||||
supervisorMaskCsrId : Int = 0x9C0,
|
||||
supervisorPendingsCsrId : Int = 0xDC0) extends Plugin[VexRiscv]{
|
||||
var externalInterruptArray : Bits = null
|
||||
|
||||
override def setup(pipeline: VexRiscv): Unit = {
|
||||
|
@ -12,10 +16,15 @@ class ExternalInterruptArrayPlugin(arrayWidth : Int = 32, maskCsrId : Int = 0xBC
|
|||
|
||||
override def build(pipeline: VexRiscv): Unit = {
|
||||
val csr = pipeline.service(classOf[CsrPlugin])
|
||||
val mask = Reg(Bits(arrayWidth bits)) init(0)
|
||||
val pendings = mask & RegNext(externalInterruptArray)
|
||||
csr.externalInterrupt.setAsDirectionLess() := pendings.orR
|
||||
csr.rw(maskCsrId, mask)
|
||||
csr.r(pendingsCsrId, pendings)
|
||||
val externalInterruptArrayBuffer = RegNext(externalInterruptArray)
|
||||
def gen(maskCsrId : Int, pendingsCsrId : Int, interruptPin : Bool) = new Area {
|
||||
val mask = Reg(Bits(arrayWidth bits)) init(0)
|
||||
val pendings = mask & externalInterruptArrayBuffer
|
||||
interruptPin.setAsDirectionLess() := pendings.orR
|
||||
csr.rw(maskCsrId, mask)
|
||||
csr.r(pendingsCsrId, pendings)
|
||||
}
|
||||
gen(machineMaskCsrId, machinePendingsCsrId, csr.externalInterrupt)
|
||||
if(csr.config.supervisorGen) gen(supervisorMaskCsrId, supervisorPendingsCsrId, csr.externalInterruptS)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue