From 93110d3b953ddcc0e5fcc63cb645a34a01a6d57d Mon Sep 17 00:00:00 2001 From: Dolu1990 Date: Fri, 16 Feb 2018 14:27:20 +0100 Subject: [PATCH] Add jump priority managment in PcPlugins --- src/main/scala/vexriscv/Services.scala | 2 +- src/main/scala/vexriscv/TestsWorkspace.scala | 4 ++-- src/main/scala/vexriscv/plugin/IBusCachedPlugin.scala | 2 +- .../scala/vexriscv/plugin/PcManagerSimplePlugin.scala | 11 +++++++---- src/test/cpp/regression/main.cpp | 2 ++ 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/scala/vexriscv/Services.scala b/src/main/scala/vexriscv/Services.scala index 5d6e371..451fd68 100644 --- a/src/main/scala/vexriscv/Services.scala +++ b/src/main/scala/vexriscv/Services.scala @@ -8,7 +8,7 @@ import spinal.lib._ import scala.beans.BeanProperty trait JumpService{ - def createJumpInterface(stage : Stage) : Flow[UInt] + def createJumpInterface(stage : Stage, priority : Int = 0) : Flow[UInt] } trait DecoderService{ diff --git a/src/main/scala/vexriscv/TestsWorkspace.scala b/src/main/scala/vexriscv/TestsWorkspace.scala index 9c1b4a4..fb2d2d7 100644 --- a/src/main/scala/vexriscv/TestsWorkspace.scala +++ b/src/main/scala/vexriscv/TestsWorkspace.scala @@ -41,9 +41,9 @@ object TestsWorkspace { // ), new IBusCachedPlugin( config = InstructionCacheConfig( - cacheSize = 4096, + cacheSize = 1024, bytePerLine = 32, - wayCount = 4, + wayCount = 2, wrappedMemAccess = true, addressWidth = 32, cpuDataWidth = 32, diff --git a/src/main/scala/vexriscv/plugin/IBusCachedPlugin.scala b/src/main/scala/vexriscv/plugin/IBusCachedPlugin.scala index cfff932..7c8455a 100644 --- a/src/main/scala/vexriscv/plugin/IBusCachedPlugin.scala +++ b/src/main/scala/vexriscv/plugin/IBusCachedPlugin.scala @@ -32,7 +32,7 @@ class IBusCachedPlugin(config : InstructionCacheConfig, askMemoryTranslation : B )) //TODO manage priority with branch prediction - redoBranch = pipeline.service(classOf[JumpService]).createJumpInterface(pipeline.decode) + redoBranch = pipeline.service(classOf[JumpService]).createJumpInterface(pipeline.decode, priority = 1) //Priority 1 will win against branch predictor if(catchSomething) { val exceptionService = pipeline.service(classOf[ExceptionService]) diff --git a/src/main/scala/vexriscv/plugin/PcManagerSimplePlugin.scala b/src/main/scala/vexriscv/plugin/PcManagerSimplePlugin.scala index 0c219f0..843cd3e 100644 --- a/src/main/scala/vexriscv/plugin/PcManagerSimplePlugin.scala +++ b/src/main/scala/vexriscv/plugin/PcManagerSimplePlugin.scala @@ -9,11 +9,11 @@ import scala.collection.mutable.ArrayBuffer class PcManagerSimplePlugin(resetVector : BigInt, relaxedPcCalculation : Boolean = false) extends Plugin[VexRiscv] with JumpService{ //FetchService interface - case class JumpInfo(interface : Flow[UInt], stage: Stage) + case class JumpInfo(interface : Flow[UInt], stage: Stage, priority : Int) val jumpInfos = ArrayBuffer[JumpInfo]() - override def createJumpInterface(stage: Stage): Flow[UInt] = { + override def createJumpInterface(stage: Stage, priority : Int = 0): Flow[UInt] = { val interface = Flow(UInt(32 bits)) - jumpInfos += JumpInfo(interface,stage) + jumpInfos += JumpInfo(interface,stage, priority) interface } var prefetchExceptionPort : Flow[ExceptionCause] = null @@ -59,7 +59,10 @@ class PcManagerSimplePlugin(resetVector : BigInt, //JumpService hardware implementation val jump = if(jumpInfos.length != 0) new Area { - val sortedByStage = jumpInfos.sortWith((a, b) => pipeline.indexOf(a.stage) > pipeline.indexOf(b.stage)) + val sortedByStage = jumpInfos.sortWith((a, b) => { + (pipeline.indexOf(a.stage) > pipeline.indexOf(b.stage)) || + (pipeline.indexOf(a.stage) == pipeline.indexOf(b.stage) && a.priority > b.priority) + }) val valids = sortedByStage.map(_.interface.valid) val pcs = sortedByStage.map(_.interface.payload) diff --git a/src/test/cpp/regression/main.cpp b/src/test/cpp/regression/main.cpp index 27dda00..054ec41 100644 --- a/src/test/cpp/regression/main.cpp +++ b/src/test/cpp/regression/main.cpp @@ -199,6 +199,8 @@ public: Workspace(string name){ + //setIStall(false); + //setDStall(false); staticMutex.lock(); testsCounter++; staticMutex.unlock();