Fix exception pipelining

This commit is contained in:
Dolu1990 2018-06-15 13:00:26 +02:00
parent 83864710a3
commit b2cd8c5314
1 changed files with 4 additions and 5 deletions

View File

@ -388,8 +388,8 @@ class CsrPlugin(config : CsrPluginConfig) extends Plugin[VexRiscv] with Exceptio
//Aggregate all exception port and remove required instructions //Aggregate all exception port and remove required instructions
val exceptionPortCtrl = if(exceptionPortsInfos.nonEmpty) new Area{ val exceptionPortCtrl = if(exceptionPortsInfos.nonEmpty) new Area{
val firstStageIndexWithExceptionPort = exceptionPortsInfos.map(i => indexOf(i.stage)).min val firstStageIndexWithExceptionPort = exceptionPortsInfos.map(i => indexOf(i.stage)).min
val exceptionValids = Vec(Bool,stages.length) val exceptionValids = Vec(stages.map(s => Bool().setPartialName(s.getName())))
val exceptionValidsRegs = Vec(Reg(Bool) init(False), stages.length).allowUnsetRegToAvoidLatch val exceptionValidsRegs = Vec(stages.map(s => Reg(Bool).init(False).setPartialName(s.getName()))).allowUnsetRegToAvoidLatch
val exceptionContext = Reg(ExceptionCause()) val exceptionContext = Reg(ExceptionCause())
//Assume 2 stages before decode //Assume 2 stages before decode
@ -430,14 +430,13 @@ class CsrPlugin(config : CsrPluginConfig) extends Plugin[VexRiscv] with Exceptio
when(stage.arbitration.isFlushed){ when(stage.arbitration.isFlushed){
exceptionValids(stageId) := False exceptionValids(stageId) := False
} }
val previousStage = if(stageId == firstStageIndexWithExceptionPort) stage else stages(stageId-1)
when(!stage.arbitration.isStuck){ when(!stage.arbitration.isStuck){
exceptionValidsRegs(stageId) := (if(stageId != firstStageIndexWithExceptionPort) exceptionValids(stageId-1) else False) exceptionValidsRegs(stageId) := (if(stageId != firstStageIndexWithExceptionPort) exceptionValids(stageId-1) && !previousStage.arbitration.isStuck else False)
}otherwise{ }otherwise{
exceptionValidsRegs(stageId) := exceptionValids(stageId) exceptionValidsRegs(stageId) := exceptionValids(stageId)
} }
} }
} else null } else null