Cleaning/Add documentation
This commit is contained in:
parent
835dd4ad50
commit
88a2c4a603
89
README.md
89
README.md
|
@ -20,76 +20,47 @@ The hardware description of this CPU is done by using an very software oriented
|
|||
- There is an service system which provide a very dynamic framework. As instance, a plugin could provide an exception service which could then be used by others plugins to emit exceptions from the pipeline.
|
||||
|
||||
|
||||
## CPU instantiation
|
||||
There is an example of instantiation of the CPU
|
||||
## CPU generation
|
||||
You can find two example of CPU instantiation in :
|
||||
- src/main/scala/VexRiscv/GenFull.scala
|
||||
- src/main/scala/VexRiscv/GenSmallest.scala
|
||||
|
||||
```scala
|
||||
//Define the cpu configuraiton
|
||||
val config = VexRiscvConfig(
|
||||
pcWidth = 32
|
||||
)
|
||||
To generate the corresponding RTL as a VexRiscv.v file, run :
|
||||
|
||||
//Define the CSR configuration (riscv-privileged-v1.9.1)
|
||||
val csrConfig = MachineCsrConfig(
|
||||
mvendorid = 11,
|
||||
marchid = 22,
|
||||
mimpid = 33,
|
||||
mhartid = 0,
|
||||
misaExtensionsInit = 66,
|
||||
misaAccess = CsrAccess.READ_WRITE,
|
||||
mtvecAccess = CsrAccess.READ_WRITE,
|
||||
mtvecInit = 0x00000020l,
|
||||
mepcAccess = CsrAccess.READ_WRITE,
|
||||
mscratchGen = true,
|
||||
mcauseAccess = CsrAccess.READ_WRITE,
|
||||
mbadaddrAccess = CsrAccess.READ_WRITE,
|
||||
mcycleAccess = CsrAccess.READ_WRITE,
|
||||
minstretAccess = CsrAccess.READ_WRITE,
|
||||
ecallGen = true,
|
||||
wfiGen = true
|
||||
)
|
||||
```sh
|
||||
sbt run-main VexRiscv.GenFull
|
||||
|
||||
//Add plugins into the cpu configuration
|
||||
config.plugins ++= List(
|
||||
new PcManagerSimplePlugin(0x00000000l, false),
|
||||
new IBusSimplePlugin(
|
||||
interfaceKeepData = true
|
||||
),
|
||||
new DecoderSimplePlugin(
|
||||
catchIllegalInstruction = true
|
||||
),
|
||||
new RegFilePlugin(
|
||||
regFileReadyKind = Plugin.SYNC,
|
||||
zeroBoot = false
|
||||
),
|
||||
new IntAluPlugin,
|
||||
new SrcPlugin,
|
||||
new FullBarrielShifterPlugin,
|
||||
new DBusSimplePlugin(
|
||||
catchUnalignedException = true
|
||||
),
|
||||
new HazardSimplePlugin(true, true, true, true),
|
||||
new MulPlugin,
|
||||
new DivPlugin,
|
||||
new MachineCsr(csrConfig),
|
||||
new BranchPlugin(
|
||||
earlyBranch = false,
|
||||
catchUnalignedException = true,
|
||||
prediction = DYNAMIC
|
||||
)
|
||||
)
|
||||
# or
|
||||
sbt run-main VexRiscv.GenSmallest
|
||||
```
|
||||
|
||||
//Instanciate the CPU
|
||||
val toplevel = new VexRiscv(config)
|
||||
## Tests
|
||||
To run tests (need the verilator simulator), go in the src/test/cpp/regression folder and run :
|
||||
|
||||
```sh
|
||||
# To test the GenFull CPU
|
||||
make clean run
|
||||
|
||||
# To test the GenSmallest CPU
|
||||
make clean run IBUS=IBUS_SIMPLE DBUS=DBUS_SIMPLE CSR=no MMU=no DEBUG_PLUGIN=no MUL=no DIV=no
|
||||
```
|
||||
|
||||
## Interactive debug of the simulated CPU via GDB/OpenOCD in Verilator
|
||||
It's as described to run tests, but you just have to add DEBUG_PLUGIN_EXTERNAL=yes in the make arguments.
|
||||
Work for the GenFull, but not for the GenSmallest as this configuration has no debug module.
|
||||
|
||||
Then you can use the https://github.com/SpinalHDL/openocd_riscv tool to create a GDB server connected to the target (the simulated CPU)
|
||||
|
||||
```sh
|
||||
src/openocd -c "set VEXRISCV_YAML PATH_TO_THE_GENERATED_CPU0_YAML_FILE" -f tcl/target/vexriscv_sim.cfg
|
||||
```
|
||||
|
||||
|
||||
## Plugin structure
|
||||
## Cpu plugin structure
|
||||
|
||||
There is an example of an pseudo ALU plugin :
|
||||
|
||||
```scala
|
||||
|
||||
//Define an signal name/type which could be used in the pipeline
|
||||
object ALU_ENABLE extends Stageable(Bool)
|
||||
object ALU_OP extends Stageable(Bits(2 bits)) // ADD, SUB, AND, OR
|
||||
|
|
40
cpu0.yaml
40
cpu0.yaml
|
@ -1,40 +0,0 @@
|
|||
dBus: !!SpinalRiscv.BusReport
|
||||
flushInstructions: [147, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455, 33587347, 1879101455,
|
||||
33587347, 1879101455]
|
||||
info: !!SpinalRiscv.CacheReport {bytePerLine: 32, size: 4096}
|
||||
kind: cached
|
||||
iBus: !!SpinalRiscv.BusReport
|
||||
flushInstructions: [16399]
|
||||
info: !!SpinalRiscv.CacheReport {bytePerLine: 32, size: 4096}
|
||||
kind: cached
|
|
@ -0,0 +1,93 @@
|
|||
package VexRiscv
|
||||
|
||||
import VexRiscv.Plugin._
|
||||
import VexRiscv.ip.{DataCacheConfig, InstructionCacheConfig}
|
||||
import spinal.core._
|
||||
|
||||
/**
|
||||
* Created by spinalvm on 15.06.17.
|
||||
*/
|
||||
object GenFull extends App{
|
||||
SpinalVerilog(
|
||||
gen = new VexRiscv(
|
||||
config = VexRiscvConfig(
|
||||
plugins = List(
|
||||
new PcManagerSimplePlugin(0x00000000l, false),
|
||||
new IBusCachedPlugin(
|
||||
config = InstructionCacheConfig(
|
||||
cacheSize = 4096,
|
||||
bytePerLine =32,
|
||||
wayCount = 1,
|
||||
wrappedMemAccess = true,
|
||||
addressWidth = 32,
|
||||
cpuDataWidth = 32,
|
||||
memDataWidth = 32,
|
||||
catchIllegalAccess = true,
|
||||
catchAccessFault = true,
|
||||
catchMemoryTranslationMiss = true,
|
||||
asyncTagMemory = false,
|
||||
twoStageLogic = true
|
||||
),
|
||||
askMemoryTranslation = true,
|
||||
memoryTranslatorPortConfig = MemoryTranslatorPortConfig(
|
||||
portTlbSize = 4
|
||||
)
|
||||
),
|
||||
new DBusCachedPlugin(
|
||||
config = new DataCacheConfig(
|
||||
cacheSize = 4096,
|
||||
bytePerLine = 32,
|
||||
wayCount = 1,
|
||||
addressWidth = 32,
|
||||
cpuDataWidth = 32,
|
||||
memDataWidth = 32,
|
||||
catchAccessError = true,
|
||||
catchIllegal = true,
|
||||
catchUnaligned = true,
|
||||
catchMemoryTranslationMiss = true
|
||||
),
|
||||
memoryTranslatorPortConfig = MemoryTranslatorPortConfig(
|
||||
portTlbSize = 6
|
||||
)
|
||||
),
|
||||
new MemoryTranslatorPlugin(
|
||||
tlbSize = 32,
|
||||
virtualRange = _(31 downto 28) === 0xC,
|
||||
ioRange = _(31 downto 28) === 0xF
|
||||
),
|
||||
new DecoderSimplePlugin(
|
||||
catchIllegalInstruction = true
|
||||
),
|
||||
new RegFilePlugin(
|
||||
regFileReadyKind = Plugin.SYNC,
|
||||
zeroBoot = true
|
||||
),
|
||||
new IntAluPlugin,
|
||||
new SrcPlugin(
|
||||
separatedAddSub = false
|
||||
),
|
||||
new FullBarrielShifterPlugin,
|
||||
new HazardSimplePlugin(
|
||||
bypassExecute = true,
|
||||
bypassMemory = true,
|
||||
bypassWriteBack = true,
|
||||
bypassWriteBackBuffer = true,
|
||||
pessimisticUseSrc = false,
|
||||
pessimisticWriteRegFile = false,
|
||||
pessimisticAddressMatch = false
|
||||
),
|
||||
new MulPlugin,
|
||||
new DivPlugin,
|
||||
new CsrPlugin(CsrPluginConfig.all),
|
||||
new DebugPlugin(ClockDomain.current.clone(reset = Bool().setName("debugReset"))),
|
||||
new BranchPlugin(
|
||||
earlyBranch = false,
|
||||
catchAddressMisaligned = true,
|
||||
prediction = DYNAMIC
|
||||
),
|
||||
new YamlPlugin("cpu0.yaml")
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package VexRiscv
|
||||
|
||||
import VexRiscv.Plugin._
|
||||
import VexRiscv.ip.{DataCacheConfig, InstructionCacheConfig}
|
||||
import spinal.core._
|
||||
|
||||
/**
|
||||
* Created by spinalvm on 15.06.17.
|
||||
*/
|
||||
object GenSmallest extends App{
|
||||
SpinalVerilog(
|
||||
gen = new VexRiscv(
|
||||
config = VexRiscvConfig(
|
||||
plugins = List(
|
||||
new PcManagerSimplePlugin(0x00000000l, true),
|
||||
new IBusSimplePlugin(
|
||||
interfaceKeepData = false,
|
||||
catchAccessFault = false
|
||||
),
|
||||
new DBusSimplePlugin(
|
||||
catchAddressMisaligned = false,
|
||||
catchAccessFault = false
|
||||
),
|
||||
new CsrPlugin(CsrPluginConfig.smallest),
|
||||
new DecoderSimplePlugin(
|
||||
catchIllegalInstruction = false
|
||||
),
|
||||
new RegFilePlugin(
|
||||
regFileReadyKind = Plugin.SYNC,
|
||||
zeroBoot = true
|
||||
),
|
||||
new IntAluPlugin,
|
||||
new SrcPlugin(
|
||||
separatedAddSub = false
|
||||
),
|
||||
new LightShifterPlugin,
|
||||
new HazardSimplePlugin(
|
||||
bypassExecute = false,
|
||||
bypassMemory = false,
|
||||
bypassWriteBack = false,
|
||||
bypassWriteBackBuffer = false,
|
||||
pessimisticUseSrc = false,
|
||||
pessimisticWriteRegFile = false,
|
||||
pessimisticAddressMatch = false
|
||||
),
|
||||
new BranchPlugin(
|
||||
earlyBranch = false,
|
||||
catchAddressMisaligned = false,
|
||||
prediction = NONE
|
||||
),
|
||||
new YamlPlugin("cpu0.yaml")
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package SpinalRiscv
|
||||
package VexRiscv
|
||||
|
||||
import SpinalRiscv.Plugin._
|
||||
import VexRiscv.Plugin._
|
||||
import spinal.core._
|
||||
import spinal.lib._
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package SpinalRiscv.Plugin
|
||||
package VexRiscv.Plugin
|
||||
|
||||
import SpinalRiscv.Riscv._
|
||||
import SpinalRiscv._
|
||||
import VexRiscv.Riscv._
|
||||
import VexRiscv._
|
||||
import spinal.core._
|
||||
import spinal.lib._
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package SpinalRiscv.Plugin
|
||||
package VexRiscv.Plugin
|
||||
|
||||
import spinal.core._
|
||||
import spinal.lib._
|
||||
import SpinalRiscv._
|
||||
import SpinalRiscv.Riscv._
|
||||
import VexRiscv._
|
||||
import VexRiscv.Riscv._
|
||||
|
||||
import scala.collection.mutable.ArrayBuffer
|
||||
import scala.collection.mutable
|
||||
|
@ -31,7 +31,7 @@ object CsrAccess {
|
|||
}
|
||||
|
||||
case class ExceptionPortInfo(port : Flow[ExceptionCause],stage : Stage, priority : Int)
|
||||
case class MachineCsrConfig(
|
||||
case class csrPluginConfig(
|
||||
catchIllegalAccess : Boolean,
|
||||
mvendorid : BigInt,
|
||||
marchid : BigInt,
|
||||
|
@ -54,7 +54,71 @@ case class MachineCsrConfig(
|
|||
assert(!ucycleAccess.canWrite)
|
||||
}
|
||||
|
||||
object CsrPluginConfig{
|
||||
val all = csrPluginConfig(
|
||||
catchIllegalAccess = true,
|
||||
mvendorid = 11,
|
||||
marchid = 22,
|
||||
mimpid = 33,
|
||||
mhartid = 0,
|
||||
misaExtensionsInit = 66,
|
||||
misaAccess = CsrAccess.READ_WRITE,
|
||||
mtvecAccess = CsrAccess.READ_WRITE,
|
||||
mtvecInit = 0x00000020l,
|
||||
mepcAccess = CsrAccess.READ_WRITE,
|
||||
mscratchGen = true,
|
||||
mcauseAccess = CsrAccess.READ_WRITE,
|
||||
mbadaddrAccess = CsrAccess.READ_WRITE,
|
||||
mcycleAccess = CsrAccess.READ_WRITE,
|
||||
minstretAccess = CsrAccess.READ_WRITE,
|
||||
ecallGen = true,
|
||||
wfiGen = true,
|
||||
ucycleAccess = CsrAccess.READ_ONLY
|
||||
)
|
||||
|
||||
val small = csrPluginConfig(
|
||||
catchIllegalAccess = false,
|
||||
mvendorid = null,
|
||||
marchid = null,
|
||||
mimpid = null,
|
||||
mhartid = null,
|
||||
misaExtensionsInit = 66,
|
||||
misaAccess = CsrAccess.NONE,
|
||||
mtvecAccess = CsrAccess.NONE,
|
||||
mtvecInit = 0x00000020l,
|
||||
mepcAccess = CsrAccess.READ_WRITE,
|
||||
mscratchGen = false,
|
||||
mcauseAccess = CsrAccess.READ_ONLY,
|
||||
mbadaddrAccess = CsrAccess.READ_ONLY,
|
||||
mcycleAccess = CsrAccess.NONE,
|
||||
minstretAccess = CsrAccess.NONE,
|
||||
ecallGen = false,
|
||||
wfiGen = false,
|
||||
ucycleAccess = CsrAccess.NONE
|
||||
)
|
||||
|
||||
val smallest = csrPluginConfig(
|
||||
catchIllegalAccess = false,
|
||||
mvendorid = null,
|
||||
marchid = null,
|
||||
mimpid = null,
|
||||
mhartid = null,
|
||||
misaExtensionsInit = 66,
|
||||
misaAccess = CsrAccess.NONE,
|
||||
mtvecAccess = CsrAccess.NONE,
|
||||
mtvecInit = 0x00000020l,
|
||||
mepcAccess = CsrAccess.READ_ONLY,
|
||||
mscratchGen = false,
|
||||
mcauseAccess = CsrAccess.READ_ONLY,
|
||||
mbadaddrAccess = CsrAccess.NONE,
|
||||
mcycleAccess = CsrAccess.NONE,
|
||||
minstretAccess = CsrAccess.NONE,
|
||||
ecallGen = false,
|
||||
wfiGen = false,
|
||||
ucycleAccess = CsrAccess.NONE
|
||||
)
|
||||
|
||||
}
|
||||
case class CsrWrite(that : Data, bitOffset : Int)
|
||||
case class CsrRead(that : Data , bitOffset : Int)
|
||||
case class CsrMapping(){
|
||||
|
@ -76,7 +140,7 @@ case class CsrMapping(){
|
|||
|
||||
|
||||
|
||||
class CsrPlugin(config : MachineCsrConfig) extends Plugin[VexRiscv] with ExceptionService with PrivilegeService with InterruptionInhibitor{
|
||||
class CsrPlugin(config : csrPluginConfig) extends Plugin[VexRiscv] with ExceptionService with PrivilegeService with InterruptionInhibitor{
|
||||
import config._
|
||||
import CsrAccess._
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package SpinalRiscv.Plugin
|
||||
package VexRiscv.Plugin
|
||||
|
||||
import SpinalRiscv.ip._
|
||||
import SpinalRiscv._
|
||||
import VexRiscv.ip._
|
||||
import VexRiscv._
|
||||
import spinal.core._
|
||||
import spinal.lib._
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package SpinalRiscv.Plugin
|
||||
package VexRiscv.Plugin
|
||||
|
||||
import SpinalRiscv._
|
||||
import VexRiscv._
|
||||
import spinal.core._
|
||||
import spinal.lib._
|
||||
import spinal.lib.bus.amba4.axi._
|
|
@ -1,8 +1,8 @@
|
|||
package SpinalRiscv.Plugin
|
||||
package VexRiscv.Plugin
|
||||
|
||||
import SpinalRiscv.Plugin.IntAluPlugin.{AluCtrlEnum, ALU_CTRL}
|
||||
import SpinalRiscv._
|
||||
import SpinalRiscv.ip._
|
||||
import VexRiscv.Plugin.IntAluPlugin.{AluCtrlEnum, ALU_CTRL}
|
||||
import VexRiscv._
|
||||
import VexRiscv.ip._
|
||||
import spinal.core._
|
||||
import spinal.lib._
|
||||
import spinal.lib.bus.amba3.apb.{Apb3Config, Apb3}
|
|
@ -1,6 +1,6 @@
|
|||
package SpinalRiscv.Plugin
|
||||
package VexRiscv.Plugin
|
||||
|
||||
import SpinalRiscv._
|
||||
import VexRiscv._
|
||||
import spinal.core._
|
||||
import spinal.lib._
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package SpinalRiscv.Plugin
|
||||
package VexRiscv.Plugin
|
||||
|
||||
import SpinalRiscv.{VexRiscv, _}
|
||||
import VexRiscv.{VexRiscv, _}
|
||||
import spinal.core._
|
||||
import spinal.lib.math.MixedDivider
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package SpinalRiscv.Plugin
|
||||
package VexRiscv.Plugin
|
||||
|
||||
import SpinalRiscv._
|
||||
import VexRiscv._
|
||||
import spinal.core._
|
||||
import spinal.lib._
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package SpinalRiscv.Plugin
|
||||
package VexRiscv.Plugin
|
||||
|
||||
import SpinalRiscv._
|
||||
import VexRiscv._
|
||||
import spinal.core._
|
||||
import spinal.lib._
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package SpinalRiscv.Plugin
|
||||
package VexRiscv.Plugin
|
||||
|
||||
import SpinalRiscv._
|
||||
import SpinalRiscv.ip._
|
||||
import VexRiscv._
|
||||
import VexRiscv.ip._
|
||||
import spinal.core._
|
||||
import spinal.lib._
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package SpinalRiscv.Plugin
|
||||
package VexRiscv.Plugin
|
||||
|
||||
import SpinalRiscv.{Stageable, ExceptionService, ExceptionCause, VexRiscv}
|
||||
import VexRiscv.{Stageable, ExceptionService, ExceptionCause, VexRiscv}
|
||||
import spinal.core._
|
||||
import spinal.lib._
|
||||
import spinal.lib.bus.amba4.axi._
|
|
@ -1,6 +1,6 @@
|
|||
package SpinalRiscv.Plugin
|
||||
package VexRiscv.Plugin
|
||||
|
||||
import SpinalRiscv._
|
||||
import VexRiscv._
|
||||
import spinal.core._
|
||||
object IntAluPlugin{
|
||||
object AluBitwiseCtrlEnum extends SpinalEnum(binarySequential){
|
|
@ -1,6 +1,6 @@
|
|||
package SpinalRiscv.Plugin
|
||||
package VexRiscv.Plugin
|
||||
|
||||
import SpinalRiscv.{VexRiscv, _}
|
||||
import VexRiscv.{VexRiscv, _}
|
||||
import spinal.core._
|
||||
import spinal.lib._
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package SpinalRiscv.Plugin
|
||||
import SpinalRiscv._
|
||||
import SpinalRiscv.VexRiscv
|
||||
package VexRiscv.Plugin
|
||||
import VexRiscv._
|
||||
import VexRiscv.VexRiscv
|
||||
import spinal.core._
|
||||
|
||||
class MulPlugin extends Plugin[VexRiscv]{
|
|
@ -1,6 +1,6 @@
|
|||
package SpinalRiscv.Plugin
|
||||
package VexRiscv.Plugin
|
||||
|
||||
import SpinalRiscv._
|
||||
import VexRiscv._
|
||||
import spinal.core._
|
||||
import spinal.lib._
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package SpinalRiscv.Plugin
|
||||
package VexRiscv.Plugin
|
||||
|
||||
import SpinalRiscv.{Pipeline, Stage}
|
||||
import VexRiscv.{Pipeline, Stage}
|
||||
import spinal.core.Area
|
||||
|
||||
/**
|
|
@ -1,6 +1,6 @@
|
|||
package SpinalRiscv.Plugin
|
||||
package VexRiscv.Plugin
|
||||
|
||||
import SpinalRiscv._
|
||||
import VexRiscv._
|
||||
import spinal.core._
|
||||
import spinal.lib._
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package SpinalRiscv.Plugin
|
||||
package VexRiscv.Plugin
|
||||
|
||||
import SpinalRiscv._
|
||||
import VexRiscv._
|
||||
import spinal.core._
|
||||
import spinal.lib.Reverse
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package SpinalRiscv.Plugin
|
||||
package VexRiscv.Plugin
|
||||
|
||||
import SpinalRiscv.{Riscv, VexRiscv}
|
||||
import VexRiscv.{Riscv, VexRiscv}
|
||||
import spinal.core._
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package SpinalRiscv.Plugin
|
||||
package VexRiscv.Plugin
|
||||
|
||||
import SpinalRiscv.{VexRiscv, _}
|
||||
import VexRiscv.{VexRiscv, _}
|
||||
import spinal.core._
|
||||
import spinal.lib._
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package SpinalRiscv.Plugin
|
||||
package VexRiscv.Plugin
|
||||
|
||||
import java.util
|
||||
|
||||
import SpinalRiscv.{ReportService, VexRiscv}
|
||||
import VexRiscv.{ReportService, VexRiscv}
|
||||
import org.yaml.snakeyaml.{DumperOptions, Yaml}
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package SpinalRiscv
|
||||
package VexRiscv
|
||||
|
||||
import spinal.core._
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package SpinalRiscv
|
||||
package VexRiscv
|
||||
|
||||
import java.util
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package SpinalRiscv
|
||||
package VexRiscv
|
||||
|
||||
import spinal.core._
|
||||
import spinal.lib._
|
|
@ -16,92 +16,16 @@
|
|||
* License along with this library.
|
||||
*/
|
||||
|
||||
package SpinalRiscv
|
||||
package VexRiscv
|
||||
|
||||
import SpinalRiscv.Plugin._
|
||||
import VexRiscv.Plugin._
|
||||
import spinal.core._
|
||||
import spinal.lib._
|
||||
import SpinalRiscv.ip._
|
||||
import VexRiscv.ip._
|
||||
|
||||
object TopLevel {
|
||||
object TestsWorkspace {
|
||||
def main(args: Array[String]) {
|
||||
SpinalVerilog {
|
||||
|
||||
|
||||
// val iCacheConfig = InstructionCacheConfig(
|
||||
// cacheSize =4096,
|
||||
// bytePerLine =32,
|
||||
// wayCount = 1,
|
||||
// wrappedMemAccess = true,
|
||||
// addressWidth = 32,
|
||||
// cpuDataWidth = 32,
|
||||
// memDataWidth = 32
|
||||
// )
|
||||
|
||||
|
||||
val csrConfigAll = MachineCsrConfig(
|
||||
catchIllegalAccess = true,
|
||||
mvendorid = 11,
|
||||
marchid = 22,
|
||||
mimpid = 33,
|
||||
mhartid = 0,
|
||||
misaExtensionsInit = 66,
|
||||
misaAccess = CsrAccess.READ_WRITE,
|
||||
mtvecAccess = CsrAccess.READ_WRITE,
|
||||
mtvecInit = 0x00000020l,
|
||||
mepcAccess = CsrAccess.READ_WRITE,
|
||||
mscratchGen = true,
|
||||
mcauseAccess = CsrAccess.READ_WRITE,
|
||||
mbadaddrAccess = CsrAccess.READ_WRITE,
|
||||
mcycleAccess = CsrAccess.READ_WRITE,
|
||||
minstretAccess = CsrAccess.READ_WRITE,
|
||||
ecallGen = true,
|
||||
wfiGen = true,
|
||||
ucycleAccess = CsrAccess.READ_ONLY
|
||||
)
|
||||
|
||||
val csrConfigSmall = MachineCsrConfig(
|
||||
catchIllegalAccess = false,
|
||||
mvendorid = null,
|
||||
marchid = null,
|
||||
mimpid = null,
|
||||
mhartid = null,
|
||||
misaExtensionsInit = 66,
|
||||
misaAccess = CsrAccess.NONE,
|
||||
mtvecAccess = CsrAccess.NONE,
|
||||
mtvecInit = 0x00000020l,
|
||||
mepcAccess = CsrAccess.READ_WRITE,
|
||||
mscratchGen = false,
|
||||
mcauseAccess = CsrAccess.READ_ONLY,
|
||||
mbadaddrAccess = CsrAccess.READ_ONLY,
|
||||
mcycleAccess = CsrAccess.NONE,
|
||||
minstretAccess = CsrAccess.NONE,
|
||||
ecallGen = false,
|
||||
wfiGen = false,
|
||||
ucycleAccess = CsrAccess.NONE
|
||||
)
|
||||
|
||||
val csrConfigSmallest = MachineCsrConfig(
|
||||
catchIllegalAccess = false,
|
||||
mvendorid = null,
|
||||
marchid = null,
|
||||
mimpid = null,
|
||||
mhartid = null,
|
||||
misaExtensionsInit = 66,
|
||||
misaAccess = CsrAccess.NONE,
|
||||
mtvecAccess = CsrAccess.NONE,
|
||||
mtvecInit = 0x00000020l,
|
||||
mepcAccess = CsrAccess.READ_ONLY,
|
||||
mscratchGen = false,
|
||||
mcauseAccess = CsrAccess.READ_ONLY,
|
||||
mbadaddrAccess = CsrAccess.NONE,
|
||||
mcycleAccess = CsrAccess.NONE,
|
||||
minstretAccess = CsrAccess.NONE,
|
||||
ecallGen = false,
|
||||
wfiGen = false,
|
||||
ucycleAccess = CsrAccess.NONE
|
||||
)
|
||||
|
||||
val configFull = VexRiscvConfig(
|
||||
plugins = List(
|
||||
new PcManagerSimplePlugin(0x00000000l, false),
|
||||
|
@ -185,7 +109,7 @@ object TopLevel {
|
|||
// new HazardSimplePlugin(false, false, false, false),
|
||||
new MulPlugin,
|
||||
new DivPlugin,
|
||||
new CsrPlugin(csrConfigAll),
|
||||
new CsrPlugin(CsrPluginConfig.all),
|
||||
new DebugPlugin(ClockDomain.current.clone(reset = Bool().setName("debugReset"))),
|
||||
new BranchPlugin(
|
||||
earlyBranch = false,
|
||||
|
@ -259,7 +183,7 @@ object TopLevel {
|
|||
catchAddressMisaligned = true,
|
||||
catchAccessFault = true
|
||||
),
|
||||
new CsrPlugin(csrConfigSmall),
|
||||
new CsrPlugin(CsrPluginConfig.small),
|
||||
new DecoderSimplePlugin(
|
||||
catchIllegalInstruction = true
|
||||
),
|
||||
|
@ -298,10 +222,6 @@ object TopLevel {
|
|||
val toplevel = new VexRiscv(configFull)
|
||||
// val toplevel = new VexRiscv(configLight)
|
||||
// val toplevel = new VexRiscv(configTest)
|
||||
toplevel.decode.input(toplevel.config.INSTRUCTION).addAttribute(Verilator.public)
|
||||
toplevel.decode.input(toplevel.config.PC).addAttribute(Verilator.public)
|
||||
toplevel.decode.arbitration.isValid.addAttribute(Verilator.public)
|
||||
toplevel.decode.arbitration.haltIt.addAttribute(Verilator.public)
|
||||
// toplevel.writeBack.input(config.PC).addAttribute(Verilator.public)
|
||||
// toplevel.service(classOf[DecoderSimplePlugin]).bench(toplevel)
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package SpinalRiscv
|
||||
package VexRiscv
|
||||
|
||||
import SpinalRiscv.Plugin.Plugin
|
||||
import VexRiscv.Plugin.Plugin
|
||||
import spinal.core._
|
||||
import spinal.lib._
|
||||
import scala.collection.mutable.ArrayBuffer
|
||||
|
@ -56,6 +56,10 @@ class VexRiscv(val config : VexRiscvConfig) extends Component with Pipeline{
|
|||
plugins ++= config.plugins
|
||||
|
||||
//regression usage
|
||||
decode.input(config.INSTRUCTION).addAttribute(Verilator.public)
|
||||
decode.input(config.PC).addAttribute(Verilator.public)
|
||||
decode.arbitration.isValid.addAttribute(Verilator.public)
|
||||
decode.arbitration.haltIt.addAttribute(Verilator.public)
|
||||
writeBack.input(config.INSTRUCTION) keep() addAttribute(Verilator.public)
|
||||
writeBack.input(config.PC) keep() addAttribute(Verilator.public)
|
||||
writeBack.arbitration.isValid keep() addAttribute(Verilator.public)
|
|
@ -1,9 +1,9 @@
|
|||
package SpinalRiscv.demo
|
||||
package VexRiscv.demo
|
||||
|
||||
|
||||
import SpinalRiscv.Plugin._
|
||||
import SpinalRiscv._
|
||||
import SpinalRiscv.ip.{DataCacheConfig, InstructionCacheConfig}
|
||||
import VexRiscv.Plugin._
|
||||
import VexRiscv._
|
||||
import VexRiscv.ip.{DataCacheConfig, InstructionCacheConfig}
|
||||
import spinal.core._
|
||||
import spinal.lib._
|
||||
import spinal.lib.bus.amba3.apb._
|
||||
|
@ -265,7 +265,7 @@ class Briey(config: BrieyConfig) extends Component{
|
|||
prediction = STATIC
|
||||
),
|
||||
new CsrPlugin(
|
||||
config = MachineCsrConfig(
|
||||
config = csrPluginConfig(
|
||||
catchIllegalAccess = false,
|
||||
mvendorid = null,
|
||||
marchid = null,
|
|
@ -1,6 +1,6 @@
|
|||
package SpinalRiscv.ip
|
||||
package VexRiscv.ip
|
||||
|
||||
import SpinalRiscv._
|
||||
import VexRiscv._
|
||||
import spinal.core._
|
||||
import spinal.lib._
|
||||
import spinal.lib.bus.amba4.axi.{Axi4Shared, Axi4Config}
|
|
@ -1,6 +1,6 @@
|
|||
package SpinalRiscv.ip
|
||||
package VexRiscv.ip
|
||||
|
||||
import SpinalRiscv._
|
||||
import VexRiscv._
|
||||
import spinal.core._
|
||||
import spinal.lib._
|
||||
import spinal.lib.bus.amba4.axi.{Axi4ReadOnly, Axi4Config}
|
|
@ -39,7 +39,12 @@ public:
|
|||
uint8_t* get(uint32_t address){
|
||||
if(mem[address >> 20] == NULL) {
|
||||
uint8_t* ptr = new uint8_t[1024*1024];
|
||||
for(uint32_t i = 0;i < 1024*1024;i++) ptr[i] = 0xFF;
|
||||
for(uint32_t i = 0;i < 1024*1024;i+=4) {
|
||||
ptr[i + 0] = 0xFF;
|
||||
ptr[i + 1] = 0xFF;
|
||||
ptr[i + 2] = 0xFF;
|
||||
ptr[i + 3] = 0xFF;
|
||||
}
|
||||
mem[address >> 20] = ptr;
|
||||
}
|
||||
return &mem[address >> 20][address & 0xFFFFF];
|
||||
|
@ -223,7 +228,7 @@ public:
|
|||
virtual void iBusAccess(uint32_t addr, uint32_t *data, bool *error) {
|
||||
if(addr % 4 != 0) {
|
||||
cout << "Warning, unaligned IBusAccess : " << addr << endl;
|
||||
fail();
|
||||
// fail();
|
||||
}
|
||||
*data = ( (mem[addr + 0] << 0)
|
||||
| (mem[addr + 1] << 8)
|
||||
|
@ -461,7 +466,7 @@ public:
|
|||
|
||||
virtual void preCycle(){
|
||||
if (top->iBus_cmd_valid && top->iBus_cmd_ready && !pending) {
|
||||
assertEq(top->iBus_cmd_payload_pc & 3,0);
|
||||
//assertEq(top->iBus_cmd_payload_pc & 3,0);
|
||||
pending = true;
|
||||
ws->iBusAccess(top->iBus_cmd_payload_pc,&inst_next,&error_next);
|
||||
}
|
||||
|
@ -966,7 +971,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
#ifdef DEBUG_PLUGIN
|
||||
|
||||
#include<pthread.h>
|
||||
#include<stdlib.h>
|
||||
|
@ -1137,6 +1142,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
string riscvTestMain[] = {
|
||||
"rv32ui-p-simple",
|
||||
|
@ -1223,67 +1229,75 @@ int main(int argc, char **argv, char **env) {
|
|||
for(int idx = 0;idx < 1;idx++){
|
||||
#ifndef REF
|
||||
|
||||
#ifdef DEBUG_PLUGIN_EXTERNAL
|
||||
{
|
||||
Workspace w("debugPluginExternal");
|
||||
w.loadHex("../../resources/hex/debugPluginExternal.hex");
|
||||
w.noInstructionReadCheck();
|
||||
#if defined(TRACE) || defined(TRACE_ACCESS)
|
||||
w.setCyclesPerSecond(5e3);
|
||||
printf("Speed reduced 5Khz\n");
|
||||
#ifdef DEBUG_PLUGIN_EXTERNAL
|
||||
{
|
||||
Workspace w("debugPluginExternal");
|
||||
w.loadHex("../../resources/hex/debugPluginExternal.hex");
|
||||
w.noInstructionReadCheck();
|
||||
#if defined(TRACE) || defined(TRACE_ACCESS)
|
||||
w.setCyclesPerSecond(5e3);
|
||||
printf("Speed reduced 5Khz\n");
|
||||
#endif
|
||||
w.run(1e9);
|
||||
}
|
||||
#endif
|
||||
w.run(1e9);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
TestA().run();
|
||||
TestA().run();
|
||||
|
||||
|
||||
|
||||
|
||||
for(const string &name : riscvTestMain){
|
||||
redo(REDO,RiscvTest(name).run();)
|
||||
}
|
||||
for(const string &name : riscvTestMemory){
|
||||
redo(REDO,RiscvTest(name).run();)
|
||||
}
|
||||
for(const string &name : riscvTestMul){
|
||||
redo(REDO,RiscvTest(name).run();)
|
||||
}
|
||||
for(const string &name : riscvTestDiv){
|
||||
redo(REDO,RiscvTest(name).run();)
|
||||
}
|
||||
for(const string &name : riscvTestMain){
|
||||
redo(REDO,RiscvTest(name).run();)
|
||||
}
|
||||
for(const string &name : riscvTestMemory){
|
||||
redo(REDO,RiscvTest(name).run();)
|
||||
}
|
||||
#ifdef MUL
|
||||
for(const string &name : riscvTestMul){
|
||||
redo(REDO,RiscvTest(name).run();)
|
||||
}
|
||||
#endif
|
||||
#ifdef DIV
|
||||
for(const string &name : riscvTestDiv){
|
||||
redo(REDO,RiscvTest(name).run();)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CSR
|
||||
uint32_t machineCsrRef[] = {1,11, 2,0x80000003u, 3,0x80000007u, 4,0x8000000bu, 5,6,7,0x80000007u ,
|
||||
8,6,9,6,10,4,11,4, 12,13,0, 14,2, 15,5,16,17,1 };
|
||||
redo(REDO,TestX28("machineCsr",machineCsrRef, sizeof(machineCsrRef)/4).noInstructionReadCheck()->run(4e3);)
|
||||
#endif
|
||||
#ifdef MMU
|
||||
uint32_t mmuRef[] = {1,2,3, 0x11111111, 0x11111111, 0x11111111, 0x22222222, 0x22222222, 0x22222222, 4, 0x11111111, 0x33333333, 0x33333333, 5,
|
||||
13, 0xC4000000,0x33333333, 6,7,
|
||||
1,2,3, 0x11111111, 0x11111111, 0x11111111, 0x22222222, 0x22222222, 0x22222222, 4, 0x11111111, 0x33333333, 0x33333333, 5,
|
||||
13, 0xC4000000,0x33333333, 6,7};
|
||||
redo(REDO,TestX28("mmu",mmuRef, sizeof(mmuRef)/4).noInstructionReadCheck()->run(4e3);)
|
||||
#endif
|
||||
#ifdef CSR
|
||||
uint32_t machineCsrRef[] = {1,11, 2,0x80000003u, 3,0x80000007u, 4,0x8000000bu, 5,6,7,0x80000007u ,
|
||||
8,6,9,6,10,4,11,4, 12,13,0, 14,2, 15,5,16,17,1 };
|
||||
redo(REDO,TestX28("machineCsr",machineCsrRef, sizeof(machineCsrRef)/4).noInstructionReadCheck()->run(4e3);)
|
||||
#endif
|
||||
#ifdef MMU
|
||||
uint32_t mmuRef[] = {1,2,3, 0x11111111, 0x11111111, 0x11111111, 0x22222222, 0x22222222, 0x22222222, 4, 0x11111111, 0x33333333, 0x33333333, 5,
|
||||
13, 0xC4000000,0x33333333, 6,7,
|
||||
1,2,3, 0x11111111, 0x11111111, 0x11111111, 0x22222222, 0x22222222, 0x22222222, 4, 0x11111111, 0x33333333, 0x33333333, 5,
|
||||
13, 0xC4000000,0x33333333, 6,7};
|
||||
redo(REDO,TestX28("mmu",mmuRef, sizeof(mmuRef)/4).noInstructionReadCheck()->run(4e3);)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_PLUGIN
|
||||
redo(REDO,DebugPluginTest().run(1e6););
|
||||
redo(REDO,DebugPluginTest().run(1e6););
|
||||
#endif
|
||||
|
||||
#ifdef DHRYSTONE
|
||||
Dhrystone("dhrystoneO3_Stall","dhrystoneO3",true,true).run(1.1e6);
|
||||
Dhrystone("dhrystoneO3M_Stall","dhrystoneO3M",true,true).run(1.5e6);
|
||||
Dhrystone("dhrystoneO3","dhrystoneO3",false,false).run(1.5e6);
|
||||
Dhrystone("dhrystoneO3M","dhrystoneO3M",false,false).run(1.2e6);
|
||||
Dhrystone("dhrystoneO3_Stall","dhrystoneO3",true,true).run(1.1e6);
|
||||
#if defined(MUL) || defined(DIV)
|
||||
Dhrystone("dhrystoneO3M_Stall","dhrystoneO3M",true,true).run(1.5e6);
|
||||
#endif
|
||||
Dhrystone("dhrystoneO3","dhrystoneO3",false,false).run(1.5e6);
|
||||
#if defined(MUL) || defined(DIV)
|
||||
Dhrystone("dhrystoneO3M","dhrystoneO3M",false,false).run(1.2e6);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef FREE_RTOS
|
||||
redo(1,Workspace("freeRTOS_demo").loadHex("../../resources/hex/freeRTOS_demo.hex")->bootAt(0x80000000u)->run(100e6);)
|
||||
redo(1,Workspace("freeRTOS_demo").loadHex("../../resources/hex/freeRTOS_demo.hex")->bootAt(0x80000000u)->run(100e6);)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
IBUS=IBUS_CACHED
|
||||
DBUS=DBUS_CACHED
|
||||
IBUS?=IBUS_CACHED
|
||||
DBUS?=DBUS_CACHED
|
||||
TRACE?=no
|
||||
TRACE_ACCESS?=no
|
||||
TRACE_START=0
|
||||
CSR=yes
|
||||
MMU=yes
|
||||
DEBUG_PLUGIN=yes
|
||||
MUL?=yes
|
||||
DIV?=yes
|
||||
CSR?=yes
|
||||
MMU?=yes
|
||||
DEBUG_PLUGIN?=yes
|
||||
DEBUG_PLUGIN_EXTERNAL?=no
|
||||
DHRYSTONE=yes
|
||||
FREE_RTOS=no
|
||||
REDO=10
|
||||
REDO?=10
|
||||
REF=no
|
||||
TRACE_WITH_TIME=no
|
||||
REF_TIME=no
|
||||
|
@ -45,6 +47,14 @@ ifeq ($(MMU),yes)
|
|||
ADDCFLAGS += -CFLAGS -DMMU
|
||||
endif
|
||||
|
||||
ifeq ($(MUL),yes)
|
||||
ADDCFLAGS += -CFLAGS -DMUL
|
||||
endif
|
||||
|
||||
ifeq ($(DIV),yes)
|
||||
ADDCFLAGS += -CFLAGS -DDIV
|
||||
endif
|
||||
|
||||
ifeq ($(TRACE_ACCESS),yes)
|
||||
ADDCFLAGS += -CFLAGS -DTRACE_ACCESS
|
||||
endif
|
||||
|
|
Loading…
Reference in New Issue