Skip to content

Commit

Permalink
Bring VexRiscvLitexSmpClusterOpenSbi sim back to a functional state
Browse files Browse the repository at this point in the history
  • Loading branch information
Dolu1990 committed Feb 12, 2024
1 parent e77938a commit 7d98033
Showing 1 changed file with 30 additions and 16 deletions.
46 changes: 30 additions & 16 deletions src/main/scala/vexriscv/demo/smp/VexRiscvSmpLitexCluster.scala
Original file line number Diff line number Diff line change
Expand Up @@ -252,27 +252,29 @@ object VexRiscvLitexSmpClusterCmdGen extends App {
////addAttribute("""mark_debug = "true"""")
object VexRiscvLitexSmpClusterOpenSbi extends App{
import spinal.core.sim._
Handle.loadHandleAsync = true

val simConfig = SimConfig
simConfig.withWave
simConfig.withFstWave
simConfig.allOptimisation

val cpuCount = 2
val cpuCount = 1

def parameter = VexRiscvLitexSmpClusterParameter(
cluster = VexRiscvSmpClusterParameter(
cpuConfigs = List.tabulate(cpuCount) { hartId =>
vexRiscvConfig(
hartId = hartId,
ioRange = address => address(31 downto 28) === 0xF,
resetVector = 0x80000000l
resetVector = 0x40f00000l,
rvc = true
)
},
withExclusiveAndInvalidation = true,
jtagHeaderIgnoreWidth = 0
),
liteDram = LiteDramNativeParameter(addressWidth = 32, dataWidth = 128),
liteDramMapping = SizeMapping(0x80000000l, 0x70000000l),
liteDramMapping = SizeMapping(0x40000000l, 0x40000000l),
coherentDma = false,
wishboneMemory = false,
cpuPerFpu = 4,
Expand Down Expand Up @@ -305,12 +307,24 @@ object VexRiscvLitexSmpClusterOpenSbi extends App{

simConfig.compile(dutGen).doSimUntilVoid(seed = 42){dut =>
dut.body.debugCd.inputClockDomain.get.forkStimulus(10)
fork{
sleep(20)
dut.body.debugCd.inputClockDomain.clockToggle()
sleep(20)
dut.body.debugCd.inputClockDomain.clockToggle()
}

val ram = SparseMemory()
ram.loadBin(0x80000000l, "../opensbi/build/platform/spinal/vexriscv/sim/smp/firmware/fw_jump.bin")
ram.loadBin(0xC0000000l, "../buildroot/output/images/Image")
ram.loadBin(0xC1000000l, "../buildroot/output/images/dtb")
ram.loadBin(0xC2000000l, "../buildroot/output/images/rootfs.cpio")
val dist = "/media/data2/proj/upstream/nuttex/test1/dist"
// ram.write(0x80000000l, Seq(0xb7, 0x0f, 0x00, 0x40, 0xe7, 0x80, 0x0f,0x00).map(_.toByte).toArray) //Seq(0x80000fb7, 0x000f80e7)
ram.loadBin(0xC00000, dist + "/romfs.img")
ram.loadBin(0x0000000, dist + "/nuttx.bin")
ram.loadBin(0xf00000, dist + "/opensbi.bin")

// ram.loadBin(0x80000000l, "../opensbi/build/platform/spinal/vexriscv/sim/smp/firmware/fw_jump.bin")
// ram.loadBin(0xC0000000l, "../buildroot/output/images/Image")
// ram.loadBin(0xC1000000l, "../buildroot/output/images/dtb")
// ram.loadBin(0xC2000000l, "../buildroot/output/images/rootfs.cpio")


dut.body.iBridge.dram.simSlave(ram, dut.body.debugCd.inputClockDomain)
Expand All @@ -328,13 +342,13 @@ object VexRiscvLitexSmpClusterOpenSbi extends App{
}
}

fork{
while(true) {
disableSimWave()
sleep(100000 * 10)
enableSimWave()
sleep( 100 * 10)
}
}
// fork{
// while(true) {
// disableSimWave()
// sleep(100000 * 10)
// enableSimWave()
// sleep( 100 * 10)
// }
// }
}
}

0 comments on commit 7d98033

Please sign in to comment.