PcManagerPlugin is can now handle an external reset vector signal
This commit is contained in:
parent
c7d852c497
commit
a9cbc48eb2
|
@ -23,6 +23,9 @@ object KeepAttribute{
|
||||||
class PcManagerSimplePlugin(resetVector : BigInt,
|
class PcManagerSimplePlugin(resetVector : BigInt,
|
||||||
relaxedPcCalculation : Boolean = false,
|
relaxedPcCalculation : Boolean = false,
|
||||||
keepPcPlus4 : Boolean = true) extends Plugin[VexRiscv] with JumpService{
|
keepPcPlus4 : Boolean = true) extends Plugin[VexRiscv] with JumpService{
|
||||||
|
|
||||||
|
var externalResetVector : UInt = null
|
||||||
|
|
||||||
//FetchService interface
|
//FetchService interface
|
||||||
case class JumpInfo(interface : Flow[UInt], stage: Stage, priority : Int)
|
case class JumpInfo(interface : Flow[UInt], stage: Stage, priority : Int)
|
||||||
val jumpInfos = ArrayBuffer[JumpInfo]()
|
val jumpInfos = ArrayBuffer[JumpInfo]()
|
||||||
|
@ -35,6 +38,7 @@ class PcManagerSimplePlugin(resetVector : BigInt,
|
||||||
|
|
||||||
override def setup(pipeline: VexRiscv): Unit = {
|
override def setup(pipeline: VexRiscv): Unit = {
|
||||||
if(!relaxedPcCalculation) pipeline.unremovableStages += pipeline.prefetch
|
if(!relaxedPcCalculation) pipeline.unremovableStages += pipeline.prefetch
|
||||||
|
if(resetVector == null) externalResetVector = in(UInt(32 bits).setName("externalResetVector"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,7 +71,7 @@ class PcManagerSimplePlugin(resetVector : BigInt,
|
||||||
arbitration.isValid := True
|
arbitration.isValid := True
|
||||||
|
|
||||||
//PC calculation without Jump
|
//PC calculation without Jump
|
||||||
val pcReg = Reg(UInt(32 bits)) init(resetVector) addAttribute(Verilator.public)
|
val pcReg = Reg(UInt(32 bits)) init(if(resetVector != null) resetVector else externalResetVector) addAttribute(Verilator.public)
|
||||||
val pcPlus4 = pcReg + 4
|
val pcPlus4 = pcReg + 4
|
||||||
if(keepPcPlus4) KeepAttribute(pcPlus4)
|
if(keepPcPlus4) KeepAttribute(pcPlus4)
|
||||||
when(arbitration.isFiring){
|
when(arbitration.isFiring){
|
||||||
|
@ -78,7 +82,7 @@ class PcManagerSimplePlugin(resetVector : BigInt,
|
||||||
val jump = if(jumpInfos.length != 0) new Area {
|
val jump = if(jumpInfos.length != 0) new Area {
|
||||||
val sortedByStage = jumpInfos.sortWith((a, b) => {
|
val sortedByStage = jumpInfos.sortWith((a, b) => {
|
||||||
(pipeline.indexOf(a.stage) > pipeline.indexOf(b.stage)) ||
|
(pipeline.indexOf(a.stage) > pipeline.indexOf(b.stage)) ||
|
||||||
(pipeline.indexOf(a.stage) == pipeline.indexOf(b.stage) && a.priority > b.priority)
|
(pipeline.indexOf(a.stage) == pipeline.indexOf(b.stage) && a.priority > b.priority)
|
||||||
})
|
})
|
||||||
val valids = sortedByStage.map(_.interface.valid)
|
val valids = sortedByStage.map(_.interface.valid)
|
||||||
val pcs = sortedByStage.map(_.interface.payload)
|
val pcs = sortedByStage.map(_.interface.payload)
|
||||||
|
@ -109,7 +113,7 @@ class PcManagerSimplePlugin(resetVector : BigInt,
|
||||||
arbitration.isValid := True
|
arbitration.isValid := True
|
||||||
|
|
||||||
//PC calculation without Jump
|
//PC calculation without Jump
|
||||||
val pcReg = Reg(UInt(32 bits)) init(resetVector) addAttribute(Verilator.public)
|
val pcReg = Reg(UInt(32 bits)) init(if(resetVector != null) resetVector else externalResetVector) addAttribute(Verilator.public)
|
||||||
val inc = RegInit(False)
|
val inc = RegInit(False)
|
||||||
val pcBeforeJumps = pcReg + (inc ## B"00").asUInt
|
val pcBeforeJumps = pcReg + (inc ## B"00").asUInt
|
||||||
insert(PC_CALC_WITHOUT_JUMP) := pcBeforeJumps
|
insert(PC_CALC_WITHOUT_JUMP) := pcBeforeJumps
|
||||||
|
|
Loading…
Reference in New Issue