Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/main/scala/vexriscv/VexRiscv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@ import spinal.core._
import scala.collection.mutable.ArrayBuffer

object VexRiscvConfig{
def apply(withMemoryStage : Boolean, withWriteBackStage : Boolean, plugins : Seq[Plugin[VexRiscv]]): VexRiscvConfig = {
def apply(withMemoryStage : Boolean, withMemory2Stage : Boolean, withWriteBackStage : Boolean, plugins : Seq[Plugin[VexRiscv]]): VexRiscvConfig = {
val config = VexRiscvConfig()
config.plugins ++= plugins
config.withMemoryStage = withMemoryStage
config.withMemory2Stage = withMemory2Stage
config.withWriteBackStage = withWriteBackStage
config
}

def apply(plugins : Seq[Plugin[VexRiscv]] = ArrayBuffer()) : VexRiscvConfig = apply(true,true,plugins)
def apply(plugins : Seq[Plugin[VexRiscv]] = ArrayBuffer()) : VexRiscvConfig = apply(true,true,true,plugins)
}

case class VexRiscvConfig(){
var withMemoryStage = true
var withMemory2Stage = false
var withWriteBackStage = true
val plugins = ArrayBuffer[Plugin[VexRiscv]]()

Expand All @@ -28,6 +30,7 @@ case class VexRiscvConfig(){
object IS_RVC extends Stageable(Bool)
object BYPASSABLE_EXECUTE_STAGE extends Stageable(Bool)
object BYPASSABLE_MEMORY_STAGE extends Stageable(Bool)
object BYPASSABLE_MEMORY2_STAGE extends Stageable(Bool)
object RS1 extends Stageable(Bits(32 bits))
object RS2 extends Stageable(Bits(32 bits))
object RS1_USE extends Stageable(Bool)
Expand Down Expand Up @@ -92,6 +95,7 @@ class VexRiscv(val config : VexRiscvConfig) extends Component with Pipeline{
val decode = newStage()
val execute = newStage()
val memory = ifGen(config.withMemoryStage) (newStage())
val memory2 = ifGen(config.withMemory2Stage) (newStage())
val writeBack = ifGen(config.withWriteBackStage) (newStage())

def stagesFromExecute = stages.dropWhile(_ != execute)
Expand All @@ -109,6 +113,9 @@ class VexRiscv(val config : VexRiscvConfig) extends Component with Pipeline{
if(withMemoryStage){
memory.arbitration.removeIt.noBackendCombMerge
}
if(withMemory2Stage){
memory2.arbitration.removeIt.noBackendCombMerge
}
execute.arbitration.flushAll.noBackendCombMerge

this(RVC_GEN) = false
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/vexriscv/demo/GenMicroNoCsr.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ object GenMicroNoCsr extends App{
def cpu() = new VexRiscv(
config = VexRiscvConfig(
withMemoryStage = false,
withMemory2Stage = false,
withWriteBackStage = false,
plugins = List(
new IBusSimplePlugin(
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/vexriscv/plugin/CsrPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,8 @@ class CsrPlugin(val config: CsrPluginConfig) extends Plugin[VexRiscv] with Excep
IS_CSR -> True,
REGFILE_WRITE_VALID -> True,
BYPASSABLE_EXECUTE_STAGE -> False,
BYPASSABLE_MEMORY_STAGE -> True
BYPASSABLE_MEMORY_STAGE -> True,
BYPASSABLE_MEMORY2_STAGE -> True
) ++ (if(catchIllegalAccess) List(HAS_SIDE_EFFECT -> True) else Nil)

val nonImmediatActions = defaultCsrActions ++ List(
Expand Down
2 changes: 2 additions & 0 deletions src/main/scala/vexriscv/plugin/DBusCachedPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class DBusCachedPlugin(config : DataCacheConfig,
REGFILE_WRITE_VALID -> True,
BYPASSABLE_EXECUTE_STAGE -> False,
BYPASSABLE_MEMORY_STAGE -> False,
BYPASSABLE_MEMORY2_STAGE -> False,
MEMORY_WR -> False
) ++ (if(catchSomething) List(HAS_SIDE_EFFECT -> True) else Nil)

Expand Down Expand Up @@ -104,6 +105,7 @@ class DBusCachedPlugin(config : DataCacheConfig,
REGFILE_WRITE_VALID -> True,
BYPASSABLE_EXECUTE_STAGE -> False,
BYPASSABLE_MEMORY_STAGE -> False,
BYPASSABLE_MEMORY2_STAGE -> False,
MEMORY_LRSC -> True
)
)
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/vexriscv/plugin/DBusSimplePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ class DBusSimplePlugin(catchAddressMisaligned : Boolean = false,
REGFILE_WRITE_VALID -> True,
BYPASSABLE_EXECUTE_STAGE -> False,
BYPASSABLE_MEMORY_STAGE -> Bool(earlyInjection),
BYPASSABLE_MEMORY2_STAGE -> Bool(earlyInjection),
MEMORY_STORE -> False
) ++ (if(catchAccessFault || catchAddressMisaligned) List(HAS_SIDE_EFFECT -> True) else Nil)

Expand Down
1 change: 1 addition & 0 deletions src/main/scala/vexriscv/plugin/DivPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class DivPlugin extends MulDivIterativePlugin(genMul = false, genDiv = true, mul
// REGFILE_WRITE_VALID -> True,
// BYPASSABLE_EXECUTE_STAGE -> False,
// BYPASSABLE_MEMORY_STAGE -> True,
// BYPASSABLE_MEMORY2_STAGE -> True,
// RS1_USE -> True,
// RS2_USE -> True,
// IS_DIV -> True
Expand Down
4 changes: 3 additions & 1 deletion src/main/scala/vexriscv/plugin/HazardSimplePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ trait HazardService{

class HazardSimplePlugin(bypassExecute : Boolean = false,
bypassMemory: Boolean = false,
bypassMemory2: Boolean = false,
bypassWriteBack: Boolean = false,
bypassWriteBackBuffer : Boolean = false,
pessimisticUseSrc : Boolean = false,
Expand Down Expand Up @@ -95,6 +96,7 @@ class HazardSimplePlugin(bypassExecute : Boolean = false,
}

if(withWriteBackStage) trackHazardWithStage(writeBack,bypassWriteBack,null)
if(withMemory2Stage) trackHazardWithStage(memory2 ,bypassMemory2 ,BYPASSABLE_MEMORY2_STAGE)
if(withMemoryStage) trackHazardWithStage(memory ,bypassMemory ,BYPASSABLE_MEMORY_STAGE)
if(readStage != execute) trackHazardWithStage(execute ,bypassExecute , if(stages.last == execute) null else BYPASSABLE_EXECUTE_STAGE)

Expand All @@ -119,4 +121,4 @@ class NoHazardPlugin extends Plugin[VexRiscv] with HazardService {
override def build(pipeline: VexRiscv): Unit = {}

def hazardOnExecuteRS = False
}
}
5 changes: 4 additions & 1 deletion src/main/scala/vexriscv/plugin/IntAluPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class IntAluPlugin extends Plugin[VexRiscv]{
REGFILE_WRITE_VALID -> True,
BYPASSABLE_EXECUTE_STAGE -> True,
BYPASSABLE_MEMORY_STAGE -> True,
BYPASSABLE_MEMORY2_STAGE -> True,
RS1_USE -> True
)

Expand All @@ -37,14 +38,16 @@ class IntAluPlugin extends Plugin[VexRiscv]{
REGFILE_WRITE_VALID -> True,
BYPASSABLE_EXECUTE_STAGE -> True,
BYPASSABLE_MEMORY_STAGE -> True,
BYPASSABLE_MEMORY2_STAGE -> True,
RS1_USE -> True,
RS2_USE -> True
)

val otherAction = List[(Stageable[_ <: BaseType],Any)](
REGFILE_WRITE_VALID -> True,
BYPASSABLE_EXECUTE_STAGE -> True,
BYPASSABLE_MEMORY_STAGE -> True
BYPASSABLE_MEMORY_STAGE -> True,
BYPASSABLE_MEMORY2_STAGE -> True
)


Expand Down
1 change: 1 addition & 0 deletions src/main/scala/vexriscv/plugin/MulDivIterativePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class MulDivIterativePlugin(genMul : Boolean = true,
REGFILE_WRITE_VALID -> True,
BYPASSABLE_EXECUTE_STAGE -> False,
BYPASSABLE_MEMORY_STAGE -> True,
BYPASSABLE_MEMORY2_STAGE -> True,
RS1_USE -> True,
RS2_USE -> True
)
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/vexriscv/plugin/MulPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class MulPlugin extends Plugin[VexRiscv]{
REGFILE_WRITE_VALID -> True,
BYPASSABLE_EXECUTE_STAGE -> False,
BYPASSABLE_MEMORY_STAGE -> False,
BYPASSABLE_MEMORY2_STAGE -> False,
RS1_USE -> True,
RS2_USE -> True,
IS_MUL -> True
Expand Down
2 changes: 2 additions & 0 deletions src/main/scala/vexriscv/plugin/ShiftPlugins.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class FullBarrelShifterPlugin(earlyInjection : Boolean = false) extends Plugin[V
REGFILE_WRITE_VALID -> True,
BYPASSABLE_EXECUTE_STAGE -> Bool(earlyInjection),
BYPASSABLE_MEMORY_STAGE -> True,
BYPASSABLE_MEMORY2_STAGE -> True,
RS1_USE -> True
)

Expand All @@ -35,6 +36,7 @@ class FullBarrelShifterPlugin(earlyInjection : Boolean = false) extends Plugin[V
REGFILE_WRITE_VALID -> True,
BYPASSABLE_EXECUTE_STAGE -> Bool(earlyInjection),
BYPASSABLE_MEMORY_STAGE -> True,
BYPASSABLE_MEMORY2_STAGE -> True,
RS1_USE -> True,
RS2_USE -> True
)
Expand Down
3 changes: 2 additions & 1 deletion src/test/scala/vexriscv/TestIndividualFeatures.scala
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ class TestIndividualFeatures extends FunSuite {
SpinalVerilog{
val config = VexRiscvConfig(
withMemoryStage = !noMemory,
withMemory2Stage = false,
withWriteBackStage = !noWriteback,
plugins = List(
new IntAluPlugin,
Expand Down Expand Up @@ -682,4 +683,4 @@ FAIL AltQTest_rv32i_O3

val seed = 4331444545509090137l
1 => flops i O0
*/
*/