m-labs / VexRiscv-verilog

Using VexRiscv without installing Scala
36 stars 39 forks source link

VexRiscv: Bump to 1.6.0 version of Spinal-HDL #12

Closed occheung closed 3 years ago

occheung commented 3 years ago

Summary

This PR bump VexRiscv to recent versions that implements FPU, and updated the generated verilog of the VexRiscv_IMA variant.

Changed build files

build.sbt: Updated to build the scala project correctly. (See post on gitter, worked immediately after updating build.sbt only)

sbourdeauducq commented 3 years ago

The FPU is not enabled in the generated file here, correct?

occheung commented 3 years ago

Yes. I think we should make another variant that enables FPU instead in another patch. It will probably be something like VexRiscv_IMAF I guess, subject to RV32 extension conventions.

Dolu1990 commented 3 years ago

<3

@occheung The FPU require the data cache, f32 should be plug and play, while f64 would require some config changes as having a 64bits data cache.

If you want to try the f64, let's me know ^^

occheung commented 3 years ago

If you want to try the f64, let's me know ^^

@Dolu1990 Definitely! Also, is it possible to have the 64-bits cache with wishbone? I think the wishbone configuration is currently hardcoded to support 32-bits data width only in VexRiscv.

  def getWishboneConfig() = WishboneConfig(
    addressWidth = 30,
    dataWidth = 32,
    selWidth = 4,
    useSTALL = false,
    useLOCK = false,
    useERR = true,
    useRTY = false,
    tgaWidth = 0,
    tgcWidth = 0,
    tgdWidth = 0,
    useBTE = true,
    useCTI = true
  )

https://github.com/SpinalHDL/VexRiscv/blob/68e704f3092be640aa92c876cf78702a83167f94/src/main/scala/vexriscv/ip/DataCache.scala#L79-L92

Dolu1990 commented 3 years ago

@occheung I changed the bridge to allow more than 32 bits, let's me know if it create issues ^^.

So if you want to go with the 64 bits FPU, you can take a look into :

https://github.com/SpinalHDL/SaxonSoc/blob/dev-0.3/hardware/scala/saxon/board/radiona/ulx3s/Ulx3sSmp.scala#L296

which show the impact on a regular 32 bits system to handle the 64 bits FPU via the includeFpu argument.

    dBusWidth = if (includeFpu) 64 else 32,
    loadStoreWidth = if (includeFpu) 64 else 32,

=> https://github.com/SpinalHDL/VexRiscv/blob/5f2fcc7d0f9973ab05d4b1f9dd0fca70400e3280/src/main/scala/vexriscv/demo/smp/VexRiscvSmpCluster.scala#L260

=>


        new DBusCachedPlugin(
          config = new DataCacheConfig(
            cpuDataWidth      = 64,
            memDataWidth      = 64,
            withWriteAggregation = true
             ...
          ),
          ....
        ),
occheung commented 3 years ago

@occheung I changed the bridge to allow more than 32 bits, let's me know if it create issues ^^.

@Dolu1990 Thanks for the work! Though VexRiscv complained about a few things.

-    cmdBridge.address := (isBurst ? (cmd.address(31 downto widthOf(counter) + 2) @@ counter @@ U"00") | (cmd.address(31 downto 2) @@ U"00"))
+    cmdBridge.address := (isBurst ? (cmd.address(31 downto widthOf(counter) + addressShift) @@ counter @@ U(0, addressShift bits)) | (cmd.address(31 downto 2) @@ U(0, addressShift bits)))

For the (cmd.address(31 downto 2) @@ U(0, addressShift bits) statement, the signal seems to be 33 bits wide. Perhaps you meant this instead?

(cmd.address(31 downto addressShift) @@ U(0, addressShift bits)

Also, there are some errors emitted when I tried to generate the 64-bit I$.

          new IBusCachedPlugin(
            resetVector = argConfig.resetVector,
            relaxedPcCalculation = false,
            prediction = argConfig.prediction,
            memoryTranslatorPortConfig = if(linux) MmuPortConfig(portTlbSize = 4) else null,
            config = InstructionCacheConfig(
              cacheSize = argConfig.iCacheSize,
              bytePerLine = 64,
              wayCount = 1,
              addressWidth = 32,
              cpuDataWidth = 64,
              memDataWidth = 64,
              catchIllegalAccess = true,
              catchAccessFault = true,
              asyncTagMemory = false,
              twoCycleRam = false,
              twoCycleCache = true
            )
          )
Click to see the error. ``` [error] Exception in thread "main" spinal.core.SpinalExit: [error] Error detected in phase PhaseNormalizeNodeInputs [error] ******************************************************************************** [error] ******************************************************************************** [error] WIDTH MISMATCH (64 bits <- 32 bits) on (Bool ? Bits | Bits)[64 bits] at [error] vexriscv.plugin.IBusCachedPlugin$$anon$1$$anonfun$13$$anon$4.(IBusCachedPlugin.scala:214) [error] vexriscv.plugin.IBusCachedPlugin$$anon$1$$anonfun$13.apply(IBusCachedPlugin.scala:206) [error] vexriscv.plugin.IBusCachedPlugin$$anon$1$$anonfun$13.apply(IBusCachedPlugin.scala:206) [error] vexriscv.plugin.IBusCachedPlugin$$anon$1.(IBusCachedPlugin.scala:206) [error] vexriscv.plugin.IBusCachedPlugin.build(IBusCachedPlugin.scala:137) [error] vexriscv.plugin.IBusCachedPlugin.build(IBusCachedPlugin.scala:28) [error] vexriscv.Pipeline$$anonfun$build$4.apply(Pipeline.scala:55) [error] vexriscv.Pipeline$$anonfun$build$4.apply(Pipeline.scala:55) [error] vexriscv.Pipeline$class.build(Pipeline.scala:55) [error] vexriscv.VexRiscv.build(VexRiscv.scala:122) [error] vexriscv.Pipeline$$anonfun$1.apply$mcV$sp(Pipeline.scala:161) [error] vexriscv.GenCoreDefault$$anonfun$main$1.apply(GenCoreDefault.scala:250) [error] vexriscv.GenCoreDefault$$anonfun$main$1.apply(GenCoreDefault.scala:88) [error] spinal.sim.JvmThread.run(SimManager.scala:51) [error] ******************************************************************************** [error] ******************************************************************************** [error] WIDTH MISMATCH (32 bits <- 64 bits) on (toplevel/??? : Bits[32 bits]) := (Bool ? Bits | Bits)[64 bits] at [error] vexriscv.plugin.IBusCachedPlugin$$anon$1$$anonfun$13$$anon$4.(IBusCachedPlugin.scala:214) [error] vexriscv.plugin.IBusCachedPlugin$$anon$1$$anonfun$13.apply(IBusCachedPlugin.scala:206) [error] vexriscv.plugin.IBusCachedPlugin$$anon$1$$anonfun$13.apply(IBusCachedPlugin.scala:206) [error] vexriscv.plugin.IBusCachedPlugin$$anon$1.(IBusCachedPlugin.scala:206) [error] vexriscv.plugin.IBusCachedPlugin.build(IBusCachedPlugin.scala:137) [error] vexriscv.plugin.IBusCachedPlugin.build(IBusCachedPlugin.scala:28) [error] vexriscv.Pipeline$$anonfun$build$4.apply(Pipeline.scala:55) [error] vexriscv.Pipeline$$anonfun$build$4.apply(Pipeline.scala:55) [error] vexriscv.Pipeline$class.build(Pipeline.scala:55) [error] vexriscv.VexRiscv.build(VexRiscv.scala:122) [error] vexriscv.Pipeline$$anonfun$1.apply$mcV$sp(Pipeline.scala:161) [error] vexriscv.GenCoreDefault$$anonfun$main$1.apply(GenCoreDefault.scala:250) [error] vexriscv.GenCoreDefault$$anonfun$main$1.apply(GenCoreDefault.scala:88) [error] spinal.sim.JvmThread.run(SimManager.scala:51) [error] ******************************************************************************** [error] ******************************************************************************** [error] WIDTH MISMATCH (32 bits <- 64 bits) on (toplevel/IBusCachedPlugin_iBusRsp_output_payload_rsp_inst : Bits[32 bits]) := (toplevel/IBusCachedPlugin_cache/io_cpu_decode_data : out Bits[64 bits]) at [error] vexriscv.plugin.IBusCachedPlugin$$anon$1$$anon$5.(IBusCachedPlugin.scala:270) [error] vexriscv.plugin.IBusCachedPlugin$$anon$1.(IBusCachedPlugin.scala:218) [error] vexriscv.plugin.IBusCachedPlugin.build(IBusCachedPlugin.scala:137) [error] vexriscv.plugin.IBusCachedPlugin.build(IBusCachedPlugin.scala:28) [error] vexriscv.Pipeline$$anonfun$build$4.apply(Pipeline.scala:55) [error] vexriscv.Pipeline$$anonfun$build$4.apply(Pipeline.scala:55) [error] vexriscv.Pipeline$class.build(Pipeline.scala:55) [error] vexriscv.VexRiscv.build(VexRiscv.scala:122) [error] vexriscv.Pipeline$$anonfun$1.apply$mcV$sp(Pipeline.scala:161) [error] vexriscv.GenCoreDefault$$anonfun$main$1.apply(GenCoreDefault.scala:250) [error] vexriscv.GenCoreDefault$$anonfun$main$1.apply(GenCoreDefault.scala:88) [error] spinal.sim.JvmThread.run(SimManager.scala:51) [error] ******************************************************************************** [error] ******************************************************************************** [error] Design's errors are listed above. [error] SpinalHDL compiler exit stack : [error] at spinal.core.SpinalExit$.apply(Misc.scala:414) [error] at spinal.core.SpinalError$.apply(Misc.scala:469) [error] at spinal.core.internals.PhaseContext.checkPendingErrors(Phase.scala:175) [error] at spinal.core.internals.PhaseContext.doPhase(Phase.scala:191) [error] at spinal.core.internals.SpinalVerilogBoot$$anonfun$singleShot$2$$anonfun$apply$120.apply(Phase.scala:2531) [error] at spinal.core.internals.SpinalVerilogBoot$$anonfun$singleShot$2$$anonfun$apply$120.apply(Phase.scala:2529) [error] at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59) [error] at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48) [error] at spinal.core.internals.SpinalVerilogBoot$$anonfun$singleShot$2.apply(Phase.scala:2529) [error] at spinal.core.internals.SpinalVerilogBoot$$anonfun$singleShot$2.apply(Phase.scala:2466) [error] at spinal.core.ScopeProperty$.sandbox(ScopeProperty.scala:32) [error] at spinal.core.internals.SpinalVerilogBoot$.singleShot(Phase.scala:2466) [error] at spinal.core.internals.SpinalVerilogBoot$.apply(Phase.scala:2461) [error] at spinal.core.Spinal$.apply(Spinal.scala:355) [error] at spinal.core.SpinalConfig.generateVerilog(Spinal.scala:161) [error] at vexriscv.GenCoreDefault$.main(GenCoreDefault.scala:88) [error] at vexriscv.GenCoreDefault.main(GenCoreDefault.scala) [error] Nonzero exit code returned from runner: 1 [error] (Compile / runMain) Nonzero exit code returned from runner: 1 [error] Total time: 2 s, completed Sep 17, 2021, 12:26:39 PM ```

I just cherry picked your commit from the dev branch and put it onto master, do I need other commits from the dev branch as well?

Dolu1990 commented 3 years ago

@occheung

Fixed :)

So, about the second error reported for the IBusCachedPlugin, did you set :

          new IBusCachedPlugin(
....
            config = InstructionCacheConfig(
              ..
              addressWidth = 32,
              cpuDataWidth = 32, //This should not be 64, only the refill need to be set to 64 bits
              memDataWidth = 64,

?

occheung commented 3 years ago

@occheung

Fixed :)

So, about the second error reported for the IBusCachedPlugin, did you set :

          new IBusCachedPlugin(
....
            config = InstructionCacheConfig(
              ..
              addressWidth = 32,
              cpuDataWidth = 32, //This should not be 64, only the refill need to be set to 64 bits
              memDataWidth = 64,

?

Thanks for the heads-up! VexRiscv with 64-bits I$ and D$ just ran the BIOS!

MiSoC BIOS
(c) Copyright 2007-2017 M-Labs Limited
Built Sep 17 2021 16:10:51

BIOS CRC passed (e2caea81)
Initializing SDRAM...
Read delays: 1:00-09  0:00-09  completed
Memtest OK
Booting from serial...
Press Q or ESC to abort boot completely.
sL5DdSMmkekro
Timeout
Booting from flash...
Error: Invalid flash boot image length 0xffffffff
Booting from network...
Local IP : 192.168.1.50
Remote IP: 192.168.1.100
Unable to download boot.bin over TFTP
Network boot failed
No boot medium found
BIOS> mr 0x400000
Memory dump:
0x00400000  6f 00 40 0b                                      o.@.            
BIOS> mr 0x400000 128
Memory dump:
0x00400000  6f 00 40 0b 13 00 00 00 13 00 00 00 13 00 00 00  o.@.............
0x00400010  13 00 00 00 13 00 00 00 13 00 00 00 13 00 00 00  ................
0x00400020  23 2e 11 fe 23 2c 51 fe 23 2a 61 fe 23 28 71 fe  #...#,Q.#*a.#(q.
0x00400030  23 26 a1 fe 23 24 b1 fe 23 22 c1 fe 23 20 d1 fe  #&..#$..#"..# ..
0x00400040  23 2e e1 fc 23 2c f1 fc 23 2a 01 fd 23 28 11 fd  #...#,..#*..#(..
0x00400050  23 26 c1 fd 23 24 d1 fd 23 22 e1 fd 23 20 f1 fd  #&..#$..#"..# ..
0x00400060  13 01 01 fc 97 00 00 00 e7 80 c0 09 83 20 c1 03  ............. ..
0x00400070  83 22 81 03 03 23 41 03 83 23 01 03 03 25 c1 02  ."...#A..#...%..
BIOS>