MulPlugin fix buffer interraction with partial regfile bypass

This commit is contained in:
Dolu1990 2021-02-17 11:35:17 +01:00
parent 8b2a2afb6f
commit 06b7a91de4
2 changed files with 61 additions and 59 deletions

View File

@ -31,15 +31,17 @@ class HazardSimplePlugin(bypassExecute : Boolean = false,
override def build(pipeline: VexRiscv): Unit = {
import pipeline._
import pipeline.config._
pipeline plug new Area {
val src0Hazard = False
val src1Hazard = False
val readStage = service(classOf[RegFileService]).readStage()
def trackHazardWithStage(stage : Stage,bypassable : Boolean, runtimeBypassable : Stageable[Bool]): Unit ={
val runtimeBypassableValue = if(runtimeBypassable != null) stage.input(runtimeBypassable) else True
val addr0Match = if(pessimisticAddressMatch) True else stage.input(INSTRUCTION)(rdRange) === readStage.input(INSTRUCTION)(rs1Range)
val addr1Match = if(pessimisticAddressMatch) True else stage.input(INSTRUCTION)(rdRange) === readStage.input(INSTRUCTION)(rs2Range)
def trackHazardWithStage(stage: Stage, bypassable: Boolean, runtimeBypassable: Stageable[Bool]): Unit = {
val runtimeBypassableValue = if (runtimeBypassable != null) stage.input(runtimeBypassable) else True
val addr0Match = if (pessimisticAddressMatch) True else stage.input(INSTRUCTION)(rdRange) === readStage.input(INSTRUCTION)(rs1Range)
val addr1Match = if (pessimisticAddressMatch) True else stage.input(INSTRUCTION)(rdRange) === readStage.input(INSTRUCTION)(rs2Range)
when(stage.arbitration.isValid && stage.input(REGFILE_WRITE_VALID)) {
if (bypassable) {
when(runtimeBypassableValue) {
@ -52,7 +54,7 @@ class HazardSimplePlugin(bypassExecute : Boolean = false,
}
}
}
when(stage.arbitration.isValid && (if(pessimisticWriteRegFile) True else stage.input(REGFILE_WRITE_VALID))) {
when(stage.arbitration.isValid && (if (pessimisticWriteRegFile) True else stage.input(REGFILE_WRITE_VALID))) {
when((Bool(!bypassable) || !runtimeBypassableValue)) {
when(addr0Match) {
src0Hazard := True
@ -65,7 +67,7 @@ class HazardSimplePlugin(bypassExecute : Boolean = false,
}
val writeBackWrites = Flow(cloneable(new Bundle{
val writeBackWrites = Flow(cloneable(new Bundle {
val address = Bits(5 bits)
val data = Bits(32 bits)
}))
@ -74,8 +76,8 @@ class HazardSimplePlugin(bypassExecute : Boolean = false,
writeBackWrites.data := stages.last.output(REGFILE_WRITE_DATA)
val writeBackBuffer = writeBackWrites.stage()
val addr0Match = if(pessimisticAddressMatch) True else writeBackBuffer.address === readStage.input(INSTRUCTION)(rs1Range)
val addr1Match = if(pessimisticAddressMatch) True else writeBackBuffer.address === readStage.input(INSTRUCTION)(rs2Range)
val addr0Match = if (pessimisticAddressMatch) True else writeBackBuffer.address === readStage.input(INSTRUCTION)(rs1Range)
val addr1Match = if (pessimisticAddressMatch) True else writeBackBuffer.address === readStage.input(INSTRUCTION)(rs2Range)
when(writeBackBuffer.valid) {
if (bypassWriteBackBuffer) {
when(addr0Match) {
@ -94,12 +96,12 @@ class HazardSimplePlugin(bypassExecute : Boolean = false,
}
}
if(withWriteBackStage) trackHazardWithStage(writeBack,bypassWriteBack,null)
if(withMemoryStage) trackHazardWithStage(memory ,bypassMemory, if(stages.last == memory) null else BYPASSABLE_MEMORY_STAGE)
if(readStage != execute) trackHazardWithStage(execute ,bypassExecute , if(stages.last == execute) null else BYPASSABLE_EXECUTE_STAGE)
if (withWriteBackStage) trackHazardWithStage(writeBack, bypassWriteBack, null)
if (withMemoryStage) trackHazardWithStage(memory, bypassMemory, if (stages.last == memory) null else BYPASSABLE_MEMORY_STAGE)
if (readStage != execute) trackHazardWithStage(execute, bypassExecute, if (stages.last == execute) null else BYPASSABLE_EXECUTE_STAGE)
if(!pessimisticUseSrc) {
if (!pessimisticUseSrc) {
when(!readStage.input(RS1_USE)) {
src0Hazard := False
}
@ -108,10 +110,11 @@ class HazardSimplePlugin(bypassExecute : Boolean = false,
}
}
when(readStage.arbitration.isValid && (src0Hazard || src1Hazard)){
when(readStage.arbitration.isValid && (src0Hazard || src1Hazard)) {
readStage.arbitration.haltByOther := True
}
}
}
}

View File

@ -61,10 +61,9 @@ class MulPlugin(var inputBuffer : Boolean = false,
when(arbitration.isValid && input(IS_MUL) && counter =/= delay){
arbitration.haltItself := True
}
when(!arbitration.isStuckByOthers){
counter := counter + 1
}
when(!arbitration.isStuck){
when(!arbitration.isStuck || arbitration.isStuckByOthers){
counter := 0
}
}