Add ExternalInterruptArrayPlugin

This commit is contained in:
Dolu1990 2018-04-20 17:56:21 +02:00
parent 6598e82920
commit 74f2a4194a
1 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,21 @@
package vexriscv.plugin
import spinal.core._
import vexriscv.VexRiscv
class ExternalInterruptArrayPlugin(arrayWidth : Int = 32) extends Plugin[VexRiscv]{
var externalInterruptArray : Bits = null
override def setup(pipeline: VexRiscv): Unit = {
externalInterruptArray = in(Bits(arrayWidth bits)).setName("externalInterruptArray")
}
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.asDirectionLess() := pendings.orR
csr.rw(0x330, mask)
csr.r(0x360, pendings)
}
}