Add jump priority managment in PcPlugins

This commit is contained in:
Dolu1990 2018-02-16 14:27:20 +01:00
parent 506e0e3f60
commit 93110d3b95
5 changed files with 13 additions and 8 deletions

View File

@ -8,7 +8,7 @@ import spinal.lib._
import scala.beans.BeanProperty import scala.beans.BeanProperty
trait JumpService{ trait JumpService{
def createJumpInterface(stage : Stage) : Flow[UInt] def createJumpInterface(stage : Stage, priority : Int = 0) : Flow[UInt]
} }
trait DecoderService{ trait DecoderService{

View File

@ -41,9 +41,9 @@ object TestsWorkspace {
// ), // ),
new IBusCachedPlugin( new IBusCachedPlugin(
config = InstructionCacheConfig( config = InstructionCacheConfig(
cacheSize = 4096, cacheSize = 1024,
bytePerLine = 32, bytePerLine = 32,
wayCount = 4, wayCount = 2,
wrappedMemAccess = true, wrappedMemAccess = true,
addressWidth = 32, addressWidth = 32,
cpuDataWidth = 32, cpuDataWidth = 32,

View File

@ -32,7 +32,7 @@ class IBusCachedPlugin(config : InstructionCacheConfig, askMemoryTranslation : B
)) ))
//TODO manage priority with branch prediction //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) { if(catchSomething) {
val exceptionService = pipeline.service(classOf[ExceptionService]) val exceptionService = pipeline.service(classOf[ExceptionService])

View File

@ -9,11 +9,11 @@ import scala.collection.mutable.ArrayBuffer
class PcManagerSimplePlugin(resetVector : BigInt, class PcManagerSimplePlugin(resetVector : BigInt,
relaxedPcCalculation : Boolean = false) extends Plugin[VexRiscv] with JumpService{ relaxedPcCalculation : Boolean = false) extends Plugin[VexRiscv] with JumpService{
//FetchService interface //FetchService interface
case class JumpInfo(interface : Flow[UInt], stage: Stage) case class JumpInfo(interface : Flow[UInt], stage: Stage, priority : Int)
val jumpInfos = ArrayBuffer[JumpInfo]() 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)) val interface = Flow(UInt(32 bits))
jumpInfos += JumpInfo(interface,stage) jumpInfos += JumpInfo(interface,stage, priority)
interface interface
} }
var prefetchExceptionPort : Flow[ExceptionCause] = null var prefetchExceptionPort : Flow[ExceptionCause] = null
@ -59,7 +59,10 @@ class PcManagerSimplePlugin(resetVector : BigInt,
//JumpService hardware implementation //JumpService hardware implementation
val jump = if(jumpInfos.length != 0) new Area { 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 valids = sortedByStage.map(_.interface.valid)
val pcs = sortedByStage.map(_.interface.payload) val pcs = sortedByStage.map(_.interface.payload)

View File

@ -199,6 +199,8 @@ public:
Workspace(string name){ Workspace(string name){
//setIStall(false);
//setDStall(false);
staticMutex.lock(); staticMutex.lock();
testsCounter++; testsCounter++;
staticMutex.unlock(); staticMutex.unlock();