Hazarplugin tell to branch plugin if the RS are hazardous in the execute stage

This commit is contained in:
Dolu1990 2018-11-24 13:38:54 +01:00
parent c2b9544794
commit 7075e08d9f
2 changed files with 23 additions and 2 deletions

View File

@ -208,6 +208,8 @@ class BranchPlugin(earlyBranch : Boolean,
branchExceptionPort.valid := arbitration.isValid && input(BRANCH_DO) && jumpInterface.payload(1) branchExceptionPort.valid := arbitration.isValid && input(BRANCH_DO) && jumpInterface.payload(1)
branchExceptionPort.code := 0 branchExceptionPort.code := 0
branchExceptionPort.badAddr := jumpInterface.payload branchExceptionPort.badAddr := jumpInterface.payload
if(branchStage == execute) branchExceptionPort.valid clearWhen(service(classOf[HazardService]).hazardOnExecuteRS)
} }
} }
} }
@ -289,6 +291,8 @@ class BranchPlugin(earlyBranch : Boolean,
branchExceptionPort.valid := arbitration.isValid && unalignedJump branchExceptionPort.valid := arbitration.isValid && unalignedJump
branchExceptionPort.code := 0 branchExceptionPort.code := 0
branchExceptionPort.badAddr := input(BRANCH_CALC) //pipeline.stages(pipeline.indexOf(branchStage)-1).input branchExceptionPort.badAddr := input(BRANCH_CALC) //pipeline.stages(pipeline.indexOf(branchStage)-1).input
if(branchStage == execute) branchExceptionPort.valid clearWhen(service(classOf[HazardService]).hazardOnExecuteRS)
} }
} }
@ -366,6 +370,8 @@ class BranchPlugin(earlyBranch : Boolean,
branchExceptionPort.valid := arbitration.isValid && input(BRANCH_DO) && input(BRANCH_CALC)(1) branchExceptionPort.valid := arbitration.isValid && input(BRANCH_DO) && input(BRANCH_CALC)(1)
branchExceptionPort.code := 0 branchExceptionPort.code := 0
branchExceptionPort.badAddr := input(BRANCH_CALC) branchExceptionPort.badAddr := input(BRANCH_CALC)
if(branchStage == execute) branchExceptionPort.valid clearWhen(service(classOf[HazardService]).hazardOnExecuteRS)
} }
} }
} }

View File

@ -4,16 +4,24 @@ import vexriscv._
import spinal.core._ import spinal.core._
import spinal.lib._ import spinal.lib._
trait HazardService{
def hazardOnExecuteRS : Bool
}
class HazardSimplePlugin(bypassExecute : Boolean = false, class HazardSimplePlugin(bypassExecute : Boolean = false,
bypassMemory: Boolean = false, bypassMemory: Boolean = false,
bypassWriteBack: Boolean = false, bypassWriteBack: Boolean = false,
bypassWriteBackBuffer : Boolean = false, bypassWriteBackBuffer : Boolean = false,
pessimisticUseSrc : Boolean = false, pessimisticUseSrc : Boolean = false,
pessimisticWriteRegFile : Boolean = false, pessimisticWriteRegFile : Boolean = false,
pessimisticAddressMatch : Boolean = false) extends Plugin[VexRiscv] { pessimisticAddressMatch : Boolean = false) extends Plugin[VexRiscv] with HazardService{
import Riscv._ import Riscv._
def hazardOnExecuteRS = {
if(pipeline.service(classOf[RegFileService]).readStage() == pipeline.execute) pipeline.execute.arbitration.isStuckByOthers else False
}
override def setup(pipeline: VexRiscv): Unit = { override def setup(pipeline: VexRiscv): Unit = {
import pipeline.config._ import pipeline.config._
val decoderService = pipeline.service(classOf[DecoderService]) val decoderService = pipeline.service(classOf[DecoderService])
@ -105,3 +113,10 @@ class HazardSimplePlugin(bypassExecute : Boolean = false,
} }
} }
} }
class NoHazardPlugin extends Plugin[VexRiscv] with HazardService {
override def build(pipeline: VexRiscv): Unit = {}
def hazardOnExecuteRS = False
}