From e9ed53424be6bf1a79aff39c96fe9617c7e2a7c1 Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Fri, 19 Apr 2019 21:06:32 -0700 Subject: [PATCH 01/14] add sifive blocks | add rebar configs for boom --- .gitmodules | 3 + build.sbt | 1 + generators/sifive-blocks | 1 + src/main/scala/boomexample/Configs.scala | 90 ++++++++++++++++++++ src/main/scala/boomexample/TestHarness.scala | 44 ++++++++++ src/main/scala/boomexample/Top.scala | 54 ++++++++++++ src/main/scala/example/Top.scala | 8 ++ 7 files changed, 201 insertions(+) create mode 160000 generators/sifive-blocks create mode 100644 src/main/scala/boomexample/Configs.scala create mode 100644 src/main/scala/boomexample/TestHarness.scala create mode 100644 src/main/scala/boomexample/Top.scala diff --git a/.gitmodules b/.gitmodules index 3d3a7a73..73e556a4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -25,3 +25,6 @@ [submodule "generators/boom"] path = generators/boom url = git@github.com:riscv-boom/riscv-boom.git +[submodule "generators/sifive-blocks"] + path = generators/sifive-blocks + url = git@github.com:sifive/sifive-blocks.git diff --git a/build.sbt b/build.sbt index 41ccfc36..0f379698 100644 --- a/build.sbt +++ b/build.sbt @@ -42,6 +42,7 @@ def conditionalDependsOn(prj: Project): Project = { } lazy val example = conditionalDependsOn(project in file(".")) + .dependsOn(boom) .settings(commonSettings) lazy val boom = (project in file("generators/boom")) diff --git a/generators/sifive-blocks b/generators/sifive-blocks new file mode 160000 index 00000000..24dd5378 --- /dev/null +++ b/generators/sifive-blocks @@ -0,0 +1 @@ +Subproject commit 24dd537894379dc160ed9e15d33444439822ab5b diff --git a/src/main/scala/boomexample/Configs.scala b/src/main/scala/boomexample/Configs.scala new file mode 100644 index 00000000..738e2922 --- /dev/null +++ b/src/main/scala/boomexample/Configs.scala @@ -0,0 +1,90 @@ +package boomexample + +import chisel3._ +import freechips.rocketchip.config.{Parameters, Config} +import freechips.rocketchip.subsystem.{WithRoccExample, WithNMemoryChannels} +import freechips.rocketchip.diplomacy.{LazyModule, ValName} +import freechips.rocketchip.devices.tilelink.BootROMParams +import freechips.rocketchip.tile.XLen +import testchipip._ + +class WithBootROM extends Config((site, here, up) => { + case BootROMParams => BootROMParams( + contentFileName = s"./bootrom/bootrom.rv${site(XLen)}.img") +}) + +object ConfigValName { + implicit val valName = ValName("TestHarness") +} +import ConfigValName._ + +class WithBoomExampleTop extends Config((site, here, up) => { + case BuildTop => (clock: Clock, reset: Bool, p: Parameters) => { + Module(LazyModule(new BoomExampleTop()(p)).module) + } +}) + +class WithPWM extends Config((site, here, up) => { + case BuildTop => (clock: Clock, reset: Bool, p: Parameters) => + Module(LazyModule(new BoomExampleTopWithPWMTL()(p)).module) +}) + +class WithPWMAXI4 extends Config((site, here, up) => { + case BuildTop => (clock: Clock, reset: Bool, p: Parameters) => + Module(LazyModule(new BoomExampleTopWithPWMAXI4()(p)).module) +}) + +class WithBlockDeviceModel extends Config((site, here, up) => { + case BuildTop => (clock: Clock, reset: Bool, p: Parameters) => { + val top = Module(LazyModule(new BoomExampleTopWithBlockDevice()(p)).module) + top.connectBlockDeviceModel() + top + } +}) + +class WithSimBlockDevice extends Config((site, here, up) => { + case BuildTop => (clock: Clock, reset: Bool, p: Parameters) => { + val top = Module(LazyModule(new BoomExampleTopWithBlockDevice()(p)).module) + top.connectSimBlockDevice(clock, reset) + top + } +}) + +class BaseBoomExampleConfig extends Config( + new WithBootROM ++ + new boom.system.SmallBoomConfig) + +class DefaultBoomExampleConfig extends Config( + new WithBoomExampleTop ++ + new BaseBoomExampleConfig) + +class RoccBoomExampleConfig extends Config( + new WithRoccExample ++ + new DefaultBoomExampleConfig) + +class PWMBoomExampleConfig extends Config( + new WithPWM ++ + new BaseBoomExampleConfig) + +class PWMAXI4BoomExampleConfig extends Config( + new WithPWMAXI4 ++ + new BaseBoomExampleConfig) + +class SimBlockDeviceBoomExampleConfig extends Config( + new WithBlockDevice ++ + new WithSimBlockDevice ++ + new BaseBoomExampleConfig) + +class BlockDeviceModelBoomExampleConfig extends Config( + new WithBlockDevice ++ + new WithBlockDeviceModel ++ + new BaseBoomExampleConfig) + +class DualCoreBoomExampleConfig extends Config( + // Core gets tacked onto existing list + new boom.system.WithNBoomCores(2) ++ + new DefaultBoomExampleConfig) + +class RV32BoomExampleConfig extends Config( + new WithBootROM ++ + new boom.system.SmallRV32UnifiedBoomConfig) diff --git a/src/main/scala/boomexample/TestHarness.scala b/src/main/scala/boomexample/TestHarness.scala new file mode 100644 index 00000000..fd5e766d --- /dev/null +++ b/src/main/scala/boomexample/TestHarness.scala @@ -0,0 +1,44 @@ +package boomexample + +import chisel3._ +import chisel3.experimental._ +import firrtl.transforms.{BlackBoxResourceAnno, BlackBoxSourceHelper} +import freechips.rocketchip.diplomacy.LazyModule +import freechips.rocketchip.config.{Field, Parameters} +import freechips.rocketchip.util.GeneratorApp + +case object BuildTop extends Field[(Clock, Bool, Parameters) => BoomExampleTopModule[BoomExampleTop]] + +class TestHarness(implicit val p: Parameters) extends Module { + val io = IO(new Bundle { + val success = Output(Bool()) + }) + + val dut = p(BuildTop)(clock, reset.toBool, p) + dut.debug := DontCare + dut.connectSimAXIMem() + dut.connectSimAXIMMIO() + dut.dontTouchPorts() + dut.tieOffInterrupts() + dut.l2_frontend_bus_axi4.foreach(axi => { + axi.tieoff() + experimental.DataMirror.directionOf(axi.ar.ready) match { + case core.ActualDirection.Input => + axi.r.bits := DontCare + axi.b.bits := DontCare + case core.ActualDirection.Output => + axi.aw.bits := DontCare + axi.ar.bits := DontCare + axi.w.bits := DontCare + } + }) + io.success := dut.connectSimSerial() +} + +object Generator extends GeneratorApp { + val longName = names.topModuleProject + "." + names.topModuleClass + "." + names.configs + generateFirrtl + generateAnno + generateTestSuiteMakefrags + generateArtefacts +} diff --git a/src/main/scala/boomexample/Top.scala b/src/main/scala/boomexample/Top.scala new file mode 100644 index 00000000..312d43fd --- /dev/null +++ b/src/main/scala/boomexample/Top.scala @@ -0,0 +1,54 @@ +package boomexample + +import chisel3._ +import freechips.rocketchip.subsystem._ +import freechips.rocketchip.system._ +import freechips.rocketchip.config.Parameters +import freechips.rocketchip.devices.tilelink._ +import freechips.rocketchip.util.DontTouch +import testchipip._ +import example.{HasPeripheryPWMTL, HasPeripheryPWMAXI4, HasPeripheryPWMTLModuleImp, HasPeripheryPWMAXI4ModuleImp} + +//--------------------------------------------------------------------------------------------------------- + +class BoomExampleTop(implicit p: Parameters) extends boom.system.ExampleBoomSystem + with HasNoDebug + with HasPeripherySerial { + override lazy val module = new BoomExampleTopModule(this) +} + +class BoomExampleTopModule[+L <: BoomExampleTop](l: L) extends boom.system.ExampleBoomSystemModule(l) + with HasRTCModuleImp + with HasNoDebugModuleImp + with HasPeripherySerialModuleImp + with DontTouch + +//--------------------------------------------------------------------------------------------------------- + +class BoomExampleTopWithPWMTL(implicit p: Parameters) extends BoomExampleTop + with HasPeripheryPWMTL { + override lazy val module = new BoomExampleTopWithPWMTLModule(this) +} + +class BoomExampleTopWithPWMTLModule(l: BoomExampleTopWithPWMTL) extends BoomExampleTopModule(l) + with HasPeripheryPWMTLModuleImp + +//--------------------------------------------------------------------------------------------------------- + +class BoomExampleTopWithPWMAXI4(implicit p: Parameters) extends BoomExampleTop + with HasPeripheryPWMAXI4 { + override lazy val module = new BoomExampleTopWithPWMAXI4Module(this) +} + +class BoomExampleTopWithPWMAXI4Module(l: BoomExampleTopWithPWMAXI4) extends BoomExampleTopModule(l) + with HasPeripheryPWMAXI4ModuleImp + +//--------------------------------------------------------------------------------------------------------- + +class BoomExampleTopWithBlockDevice(implicit p: Parameters) extends BoomExampleTop + with HasPeripheryBlockDevice { + override lazy val module = new BoomExampleTopWithBlockDeviceModule(this) +} + +class BoomExampleTopWithBlockDeviceModule(l: BoomExampleTopWithBlockDevice) extends BoomExampleTopModule(l) + with HasPeripheryBlockDeviceModuleImp diff --git a/src/main/scala/example/Top.scala b/src/main/scala/example/Top.scala index bcc745ad..bb156575 100644 --- a/src/main/scala/example/Top.scala +++ b/src/main/scala/example/Top.scala @@ -8,6 +8,8 @@ import freechips.rocketchip.devices.tilelink._ import freechips.rocketchip.util.DontTouch import testchipip._ +//--------------------------------------------------------------------------------------------------------- + class ExampleTop(implicit p: Parameters) extends ExampleRocketSystem //RocketSubsystem with CanHaveMasterAXI4MemPort with HasPeripheryBootROM @@ -27,6 +29,8 @@ class ExampleTopModule[+L <: ExampleTop](l: L) extends ExampleRocketSystemModule with HasPeripherySerialModuleImp with DontTouch +//--------------------------------------------------------------------------------------------------------- + class ExampleTopWithPWMTL(implicit p: Parameters) extends ExampleTop with HasPeripheryPWMTL { override lazy val module = new ExampleTopWithPWMTLModule(this) @@ -35,6 +39,8 @@ class ExampleTopWithPWMTL(implicit p: Parameters) extends ExampleTop class ExampleTopWithPWMTLModule(l: ExampleTopWithPWMTL) extends ExampleTopModule(l) with HasPeripheryPWMTLModuleImp +//--------------------------------------------------------------------------------------------------------- + class ExampleTopWithPWMAXI4(implicit p: Parameters) extends ExampleTop with HasPeripheryPWMAXI4 { override lazy val module = new ExampleTopWithPWMAXI4Module(this) @@ -43,6 +49,8 @@ class ExampleTopWithPWMAXI4(implicit p: Parameters) extends ExampleTop class ExampleTopWithPWMAXI4Module(l: ExampleTopWithPWMAXI4) extends ExampleTopModule(l) with HasPeripheryPWMAXI4ModuleImp +//--------------------------------------------------------------------------------------------------------- + class ExampleTopWithBlockDevice(implicit p: Parameters) extends ExampleTop with HasPeripheryBlockDevice { override lazy val module = new ExampleTopWithBlockDeviceModule(this) From c0b0e293c5e3ee41be2a49eb5250de7c118afe81 Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Sat, 20 Apr 2019 21:18:20 -0700 Subject: [PATCH 02/14] removed boom package and combined into example | removed example from naming | split generator file --- build.sbt | 6 +- src/main/scala/boomexample/Configs.scala | 90 --------- src/main/scala/boomexample/TestHarness.scala | 44 ----- src/main/scala/boomexample/Top.scala | 54 ------ src/main/scala/example/Configs.scala | 181 +++++++++++++++---- src/main/scala/example/Generator.scala | 16 ++ src/main/scala/example/TestHarness.scala | 46 ++++- src/main/scala/example/Top.scala | 83 +++++++-- 8 files changed, 269 insertions(+), 251 deletions(-) delete mode 100644 src/main/scala/boomexample/Configs.scala delete mode 100644 src/main/scala/boomexample/TestHarness.scala delete mode 100644 src/main/scala/boomexample/Top.scala create mode 100644 src/main/scala/example/Generator.scala diff --git a/build.sbt b/build.sbt index 0f379698..633ff032 100644 --- a/build.sbt +++ b/build.sbt @@ -42,7 +42,7 @@ def conditionalDependsOn(prj: Project): Project = { } lazy val example = conditionalDependsOn(project in file(".")) - .dependsOn(boom) + .dependsOn(boom, sifive_blocks) .settings(commonSettings) lazy val boom = (project in file("generators/boom")) @@ -60,3 +60,7 @@ lazy val `barstools-macros` = (project in file("./tools/barstools/macros/")) .dependsOn(mdf, rocketchip, rebarFirrtl) .enablePlugins(sbtassembly.AssemblyPlugin) .settings(commonSettings) + +lazy val sifive_blocks = (project in file("generators/sifive-blocks")) + .dependsOn(rocketchip) + .settings(commonSettings) diff --git a/src/main/scala/boomexample/Configs.scala b/src/main/scala/boomexample/Configs.scala deleted file mode 100644 index 738e2922..00000000 --- a/src/main/scala/boomexample/Configs.scala +++ /dev/null @@ -1,90 +0,0 @@ -package boomexample - -import chisel3._ -import freechips.rocketchip.config.{Parameters, Config} -import freechips.rocketchip.subsystem.{WithRoccExample, WithNMemoryChannels} -import freechips.rocketchip.diplomacy.{LazyModule, ValName} -import freechips.rocketchip.devices.tilelink.BootROMParams -import freechips.rocketchip.tile.XLen -import testchipip._ - -class WithBootROM extends Config((site, here, up) => { - case BootROMParams => BootROMParams( - contentFileName = s"./bootrom/bootrom.rv${site(XLen)}.img") -}) - -object ConfigValName { - implicit val valName = ValName("TestHarness") -} -import ConfigValName._ - -class WithBoomExampleTop extends Config((site, here, up) => { - case BuildTop => (clock: Clock, reset: Bool, p: Parameters) => { - Module(LazyModule(new BoomExampleTop()(p)).module) - } -}) - -class WithPWM extends Config((site, here, up) => { - case BuildTop => (clock: Clock, reset: Bool, p: Parameters) => - Module(LazyModule(new BoomExampleTopWithPWMTL()(p)).module) -}) - -class WithPWMAXI4 extends Config((site, here, up) => { - case BuildTop => (clock: Clock, reset: Bool, p: Parameters) => - Module(LazyModule(new BoomExampleTopWithPWMAXI4()(p)).module) -}) - -class WithBlockDeviceModel extends Config((site, here, up) => { - case BuildTop => (clock: Clock, reset: Bool, p: Parameters) => { - val top = Module(LazyModule(new BoomExampleTopWithBlockDevice()(p)).module) - top.connectBlockDeviceModel() - top - } -}) - -class WithSimBlockDevice extends Config((site, here, up) => { - case BuildTop => (clock: Clock, reset: Bool, p: Parameters) => { - val top = Module(LazyModule(new BoomExampleTopWithBlockDevice()(p)).module) - top.connectSimBlockDevice(clock, reset) - top - } -}) - -class BaseBoomExampleConfig extends Config( - new WithBootROM ++ - new boom.system.SmallBoomConfig) - -class DefaultBoomExampleConfig extends Config( - new WithBoomExampleTop ++ - new BaseBoomExampleConfig) - -class RoccBoomExampleConfig extends Config( - new WithRoccExample ++ - new DefaultBoomExampleConfig) - -class PWMBoomExampleConfig extends Config( - new WithPWM ++ - new BaseBoomExampleConfig) - -class PWMAXI4BoomExampleConfig extends Config( - new WithPWMAXI4 ++ - new BaseBoomExampleConfig) - -class SimBlockDeviceBoomExampleConfig extends Config( - new WithBlockDevice ++ - new WithSimBlockDevice ++ - new BaseBoomExampleConfig) - -class BlockDeviceModelBoomExampleConfig extends Config( - new WithBlockDevice ++ - new WithBlockDeviceModel ++ - new BaseBoomExampleConfig) - -class DualCoreBoomExampleConfig extends Config( - // Core gets tacked onto existing list - new boom.system.WithNBoomCores(2) ++ - new DefaultBoomExampleConfig) - -class RV32BoomExampleConfig extends Config( - new WithBootROM ++ - new boom.system.SmallRV32UnifiedBoomConfig) diff --git a/src/main/scala/boomexample/TestHarness.scala b/src/main/scala/boomexample/TestHarness.scala deleted file mode 100644 index fd5e766d..00000000 --- a/src/main/scala/boomexample/TestHarness.scala +++ /dev/null @@ -1,44 +0,0 @@ -package boomexample - -import chisel3._ -import chisel3.experimental._ -import firrtl.transforms.{BlackBoxResourceAnno, BlackBoxSourceHelper} -import freechips.rocketchip.diplomacy.LazyModule -import freechips.rocketchip.config.{Field, Parameters} -import freechips.rocketchip.util.GeneratorApp - -case object BuildTop extends Field[(Clock, Bool, Parameters) => BoomExampleTopModule[BoomExampleTop]] - -class TestHarness(implicit val p: Parameters) extends Module { - val io = IO(new Bundle { - val success = Output(Bool()) - }) - - val dut = p(BuildTop)(clock, reset.toBool, p) - dut.debug := DontCare - dut.connectSimAXIMem() - dut.connectSimAXIMMIO() - dut.dontTouchPorts() - dut.tieOffInterrupts() - dut.l2_frontend_bus_axi4.foreach(axi => { - axi.tieoff() - experimental.DataMirror.directionOf(axi.ar.ready) match { - case core.ActualDirection.Input => - axi.r.bits := DontCare - axi.b.bits := DontCare - case core.ActualDirection.Output => - axi.aw.bits := DontCare - axi.ar.bits := DontCare - axi.w.bits := DontCare - } - }) - io.success := dut.connectSimSerial() -} - -object Generator extends GeneratorApp { - val longName = names.topModuleProject + "." + names.topModuleClass + "." + names.configs - generateFirrtl - generateAnno - generateTestSuiteMakefrags - generateArtefacts -} diff --git a/src/main/scala/boomexample/Top.scala b/src/main/scala/boomexample/Top.scala deleted file mode 100644 index 312d43fd..00000000 --- a/src/main/scala/boomexample/Top.scala +++ /dev/null @@ -1,54 +0,0 @@ -package boomexample - -import chisel3._ -import freechips.rocketchip.subsystem._ -import freechips.rocketchip.system._ -import freechips.rocketchip.config.Parameters -import freechips.rocketchip.devices.tilelink._ -import freechips.rocketchip.util.DontTouch -import testchipip._ -import example.{HasPeripheryPWMTL, HasPeripheryPWMAXI4, HasPeripheryPWMTLModuleImp, HasPeripheryPWMAXI4ModuleImp} - -//--------------------------------------------------------------------------------------------------------- - -class BoomExampleTop(implicit p: Parameters) extends boom.system.ExampleBoomSystem - with HasNoDebug - with HasPeripherySerial { - override lazy val module = new BoomExampleTopModule(this) -} - -class BoomExampleTopModule[+L <: BoomExampleTop](l: L) extends boom.system.ExampleBoomSystemModule(l) - with HasRTCModuleImp - with HasNoDebugModuleImp - with HasPeripherySerialModuleImp - with DontTouch - -//--------------------------------------------------------------------------------------------------------- - -class BoomExampleTopWithPWMTL(implicit p: Parameters) extends BoomExampleTop - with HasPeripheryPWMTL { - override lazy val module = new BoomExampleTopWithPWMTLModule(this) -} - -class BoomExampleTopWithPWMTLModule(l: BoomExampleTopWithPWMTL) extends BoomExampleTopModule(l) - with HasPeripheryPWMTLModuleImp - -//--------------------------------------------------------------------------------------------------------- - -class BoomExampleTopWithPWMAXI4(implicit p: Parameters) extends BoomExampleTop - with HasPeripheryPWMAXI4 { - override lazy val module = new BoomExampleTopWithPWMAXI4Module(this) -} - -class BoomExampleTopWithPWMAXI4Module(l: BoomExampleTopWithPWMAXI4) extends BoomExampleTopModule(l) - with HasPeripheryPWMAXI4ModuleImp - -//--------------------------------------------------------------------------------------------------------- - -class BoomExampleTopWithBlockDevice(implicit p: Parameters) extends BoomExampleTop - with HasPeripheryBlockDevice { - override lazy val module = new BoomExampleTopWithBlockDeviceModule(this) -} - -class BoomExampleTopWithBlockDeviceModule(l: BoomExampleTopWithBlockDevice) extends BoomExampleTopModule(l) - with HasPeripheryBlockDeviceModuleImp diff --git a/src/main/scala/example/Configs.scala b/src/main/scala/example/Configs.scala index b7664614..72c40a1b 100644 --- a/src/main/scala/example/Configs.scala +++ b/src/main/scala/example/Configs.scala @@ -8,77 +8,190 @@ import freechips.rocketchip.devices.tilelink.BootROMParams import freechips.rocketchip.tile.XLen import testchipip._ +/** + * Class to specify where the BootRom file is (from `rebar` top) + */ class WithBootROM extends Config((site, here, up) => { case BootROMParams => BootROMParams( contentFileName = s"./bootrom/bootrom.rv${site(XLen)}.img") }) +/** + * TODO: Why do we need this? + */ object ConfigValName { implicit val valName = ValName("TestHarness") } import ConfigValName._ -class WithExampleTop extends Config((site, here, up) => { - case BuildTop => (clock: Clock, reset: Bool, p: Parameters) => { - Module(LazyModule(new ExampleTop()(p)).module) +// ------------------------------- +// Rocket Top Level System Configs +// ------------------------------- + +/** + * Class to specify a "plain" top level rocket-chip system + */ +class WithNormalRocketTop extends Config((site, here, up) => { + case BuildRocketTop => (clock: Clock, reset: Bool, p: Parameters) => { + Module(LazyModule(new RocketTop()(p)).module) } }) -class WithPWM extends Config((site, here, up) => { - case BuildTop => (clock: Clock, reset: Bool, p: Parameters) => - Module(LazyModule(new ExampleTopWithPWMTL()(p)).module) +/** + * Class to specify a top level rocket-chip system with PWM + */ +class WithPWMRocketTop extends Config((site, here, up) => { + case BuildRocketTop => (clock: Clock, reset: Bool, p: Parameters) => + Module(LazyModule(new RocketTopWithPWMTL()(p)).module) }) -class WithPWMAXI4 extends Config((site, here, up) => { - case BuildTop => (clock: Clock, reset: Bool, p: Parameters) => - Module(LazyModule(new ExampleTopWithPWMAXI4()(p)).module) +/** + * Class to specify a top level rocket-chip system with a PWM AXI4 + */ +class WithPWMAXI4RocketTop extends Config((site, here, up) => { + case BuildRocketTop => (clock: Clock, reset: Bool, p: Parameters) => + Module(LazyModule(new RocketTopWithPWMAXI4()(p)).module) }) -class WithBlockDeviceModel extends Config((site, here, up) => { - case BuildTop => (clock: Clock, reset: Bool, p: Parameters) => { - val top = Module(LazyModule(new ExampleTopWithBlockDevice()(p)).module) +/** + * Class to specify a top level rocket-chip system with a block device + */ +class WithBlockDeviceModelRocketTop extends Config((site, here, up) => { + case BuildRocketTop => (clock: Clock, reset: Bool, p: Parameters) => { + val top = Module(LazyModule(new RocketTopWithBlockDevice()(p)).module) top.connectBlockDeviceModel() top } }) -class WithSimBlockDevice extends Config((site, here, up) => { - case BuildTop => (clock: Clock, reset: Bool, p: Parameters) => { - val top = Module(LazyModule(new ExampleTopWithBlockDevice()(p)).module) +/** + * Class to specify a top level rocket-chip system with a simulator block device + */ +class WithSimBlockDeviceRocketTop extends Config((site, here, up) => { + case BuildRocketTop => (clock: Clock, reset: Bool, p: Parameters) => { + val top = Module(LazyModule(new RocketTopWithBlockDevice()(p)).module) top.connectSimBlockDevice(clock, reset) top } }) -class BaseExampleConfig extends Config( +// -------------- +// Rocket Configs +// -------------- + +class BaseRocketConfig extends Config( new WithBootROM ++ new freechips.rocketchip.system.DefaultConfig) -class DefaultExampleConfig extends Config( - new WithExampleTop ++ new BaseExampleConfig) +class DefaultRocketConfig extends Config( + new WithNormalRocketTop ++ + new BaseRocketConfig) -class RoccExampleConfig extends Config( - new WithRoccExample ++ new DefaultExampleConfig) +class RoccRocketConfig extends Config( + new WithRoccExample ++ + new DefaultRocketConfig) -class PWMConfig extends Config(new WithPWM ++ new BaseExampleConfig) +class PWMRocketConfig extends Config( + new WithPWMRocketTop ++ + new BaseRocketConfig) -class PWMAXI4Config extends Config(new WithPWMAXI4 ++ new BaseExampleConfig) +class PWMAXI4RocketConfig extends Config( + new WithPWMAXI4RocketTop ++ + new BaseRocketConfig) -class SimBlockDeviceConfig extends Config( - new WithBlockDevice ++ new WithSimBlockDevice ++ new BaseExampleConfig) +class SimBlockDeviceRocketConfig extends Config( + new WithBlockDevice ++ + new WithSimBlockDeviceRocketTop ++ + new BaseRocketConfig) -class BlockDeviceModelConfig extends Config( - new WithBlockDevice ++ new WithBlockDeviceModel ++ new BaseExampleConfig) +class BlockDeviceModelRocketConfig extends Config( + new WithBlockDevice ++ + new WithBlockDeviceModelRocketTop ++ + new BaseRocketConfig) -class WithTwoTrackers extends WithNBlockDeviceTrackers(2) -class WithFourTrackers extends WithNBlockDeviceTrackers(4) +class DualCoreRocketConfig extends Config( + new WithNBigCores(2) ++ + new DefaultRocketConfig) -class WithTwoMemChannels extends WithNMemoryChannels(2) -class WithFourMemChannels extends WithNMemoryChannels(4) +class RV32RocketConfig extends Config( + new WithRV32 ++ + new DefaultRocketConfig) -class DualCoreConfig extends Config( +// ----------------------------- +// BOOM Top Level System Configs +// ----------------------------- + +class WithNormalBoomTop extends Config((site, here, up) => { + case BuildBoomTop => (clock: Clock, reset: Bool, p: Parameters) => { + Module(LazyModule(new BoomTop()(p)).module) + } +}) + +class WithPWMBoomTop extends Config((site, here, up) => { + case BuildBoomTop => (clock: Clock, reset: Bool, p: Parameters) => + Module(LazyModule(new BoomTopWithPWMTL()(p)).module) +}) + +class WithPWMAXI4BoomTop extends Config((site, here, up) => { + case BuildBoomTop => (clock: Clock, reset: Bool, p: Parameters) => + Module(LazyModule(new BoomTopWithPWMAXI4()(p)).module) +}) + +class WithBlockDeviceModelBoomTop extends Config((site, here, up) => { + case BuildBoomTop => (clock: Clock, reset: Bool, p: Parameters) => { + val top = Module(LazyModule(new BoomTopWithBlockDevice()(p)).module) + top.connectBlockDeviceModel() + top + } +}) + +class WithSimBlockDeviceBoomTop extends Config((site, here, up) => { + case BuildBoomTop => (clock: Clock, reset: Bool, p: Parameters) => { + val top = Module(LazyModule(new BoomTopWithBlockDevice()(p)).module) + top.connectSimBlockDevice(clock, reset) + top + } +}) + +// ------------ +// BOOM Configs +// ------------ + +class BaseBoomConfig extends Config( + new WithBootROM ++ + new boom.system.SmallBoomConfig) + +class DefaultBoomConfig extends Config( + new WithNormalBoomTop ++ + new BaseBoomConfig) + +class RoccBoomConfig extends Config( + new WithRoccExample ++ + new DefaultBoomConfig) + +class PWMBoomConfig extends Config( + new WithPWMBoomTop ++ + new BaseBoomConfig) + +class PWMAXI4BoomConfig extends Config( + new WithPWMAXI4BoomTop ++ + new BaseBoomConfig) + +class SimBlockDeviceBoomConfig extends Config( + new WithBlockDevice ++ + new WithSimBlockDeviceBoomTop ++ + new BaseBoomConfig) + +class BlockDeviceModelBoomConfig extends Config( + new WithBlockDevice ++ + new WithBlockDeviceModelBoomTop ++ + new BaseBoomConfig) + +class DualCoreBoomConfig extends Config( // Core gets tacked onto existing list - new WithNBigCores(2) ++ new DefaultExampleConfig) + new boom.system.WithNBoomCores(2) ++ + new DefaultBoomConfig) -class RV32ExampleConfig extends Config( - new WithRV32 ++ new DefaultExampleConfig) +class RV32BoomConfig extends Config( + new WithBootROM ++ + new boom.system.SmallRV32UnifiedBoomConfig) diff --git a/src/main/scala/example/Generator.scala b/src/main/scala/example/Generator.scala new file mode 100644 index 00000000..9b86a826 --- /dev/null +++ b/src/main/scala/example/Generator.scala @@ -0,0 +1,16 @@ +package example + +import chisel3._ +import chisel3.experimental._ +import firrtl.transforms.{BlackBoxResourceAnno, BlackBoxSourceHelper} +import freechips.rocketchip.diplomacy.LazyModule +import freechips.rocketchip.config.{Field, Parameters} +import freechips.rocketchip.util.GeneratorApp + +object Generator extends GeneratorApp { + val longName = names.topModuleProject + "." + names.topModuleClass + "." + names.configs + generateFirrtl + generateAnno + generateTestSuiteMakefrags + generateArtefacts +} diff --git a/src/main/scala/example/TestHarness.scala b/src/main/scala/example/TestHarness.scala index a5af6240..a278c46b 100644 --- a/src/main/scala/example/TestHarness.scala +++ b/src/main/scala/example/TestHarness.scala @@ -7,14 +7,18 @@ import freechips.rocketchip.diplomacy.LazyModule import freechips.rocketchip.config.{Field, Parameters} import freechips.rocketchip.util.GeneratorApp -case object BuildTop extends Field[(Clock, Bool, Parameters) => ExampleTopModule[ExampleTop]] +// ------------------- +// Rocket Test Harness +// ------------------- -class TestHarness(implicit val p: Parameters) extends Module { +case object BuildRocketTop extends Field[(Clock, Bool, Parameters) => RocketTopModule[RocketTop]] + +class RocketTestHarness(implicit val p: Parameters) extends Module { val io = IO(new Bundle { val success = Output(Bool()) }) - val dut = p(BuildTop)(clock, reset.toBool, p) + val dut = p(BuildRocketTop)(clock, reset.toBool, p) dut.debug := DontCare dut.connectSimAXIMem() dut.connectSimAXIMMIO() @@ -35,10 +39,34 @@ class TestHarness(implicit val p: Parameters) extends Module { io.success := dut.connectSimSerial() } -object Generator extends GeneratorApp { - val longName = names.topModuleProject + "." + names.topModuleClass + "." + names.configs - generateFirrtl - generateAnno - generateTestSuiteMakefrags - generateArtefacts +// ----------------- +// BOOM Test Harness +// ----------------- + +case object BuildBoomTop extends Field[(Clock, Bool, Parameters) => BoomTopModule[BoomTop]] + +class BoomTestHarness(implicit val p: Parameters) extends Module { + val io = IO(new Bundle { + val success = Output(Bool()) + }) + + val dut = p(BuildBoomTop)(clock, reset.toBool, p) + dut.debug := DontCare + dut.connectSimAXIMem() + dut.connectSimAXIMMIO() + dut.dontTouchPorts() + dut.tieOffInterrupts() + dut.l2_frontend_bus_axi4.foreach(axi => { + axi.tieoff() + experimental.DataMirror.directionOf(axi.ar.ready) match { + case core.ActualDirection.Input => + axi.r.bits := DontCare + axi.b.bits := DontCare + case core.ActualDirection.Output => + axi.aw.bits := DontCare + axi.ar.bits := DontCare + axi.w.bits := DontCare + } + }) + io.success := dut.connectSimSerial() } diff --git a/src/main/scala/example/Top.scala b/src/main/scala/example/Top.scala index bb156575..4dbf5a53 100644 --- a/src/main/scala/example/Top.scala +++ b/src/main/scala/example/Top.scala @@ -8,54 +8,99 @@ import freechips.rocketchip.devices.tilelink._ import freechips.rocketchip.util.DontTouch import testchipip._ -//--------------------------------------------------------------------------------------------------------- +// ------------------------ +// Rocket Top Level Systems +// ------------------------ -class ExampleTop(implicit p: Parameters) extends ExampleRocketSystem //RocketSubsystem +class RocketTop(implicit p: Parameters) extends RocketSystem with CanHaveMasterAXI4MemPort with HasPeripheryBootROM -// with HasSystemErrorSlave -// with HasSyncExtInterrupts with HasNoDebug with HasPeripherySerial { - override lazy val module = new ExampleTopModule(this) + override lazy val module = new RocketTopModule(this) } -class ExampleTopModule[+L <: ExampleTop](l: L) extends ExampleRocketSystemModuleImp(l) // RocketSubsystemModuleImp(l) +class RocketTopModule[+L <: RocketTop](l: L) extends RocketSystemModuleImp(l) with HasRTCModuleImp with CanHaveMasterAXI4MemPortModuleImp with HasPeripheryBootROMModuleImp -// with HasExtInterruptsModuleImp with HasNoDebugModuleImp with HasPeripherySerialModuleImp with DontTouch //--------------------------------------------------------------------------------------------------------- -class ExampleTopWithPWMTL(implicit p: Parameters) extends ExampleTop +class RocketTopWithPWMTL(implicit p: Parameters) extends RocketTop with HasPeripheryPWMTL { - override lazy val module = new ExampleTopWithPWMTLModule(this) + override lazy val module = new RocketTopWithPWMTLModule(this) } -class ExampleTopWithPWMTLModule(l: ExampleTopWithPWMTL) - extends ExampleTopModule(l) with HasPeripheryPWMTLModuleImp +class RocketTopWithPWMTLModule(l: RocketTopWithPWMTL) + extends RocketTopModule(l) with HasPeripheryPWMTLModuleImp //--------------------------------------------------------------------------------------------------------- -class ExampleTopWithPWMAXI4(implicit p: Parameters) extends ExampleTop +class RocketTopWithPWMAXI4(implicit p: Parameters) extends RocketTop with HasPeripheryPWMAXI4 { - override lazy val module = new ExampleTopWithPWMAXI4Module(this) + override lazy val module = new RocketTopWithPWMAXI4Module(this) } -class ExampleTopWithPWMAXI4Module(l: ExampleTopWithPWMAXI4) - extends ExampleTopModule(l) with HasPeripheryPWMAXI4ModuleImp +class RocketTopWithPWMAXI4Module(l: RocketTopWithPWMAXI4) + extends RocketTopModule(l) with HasPeripheryPWMAXI4ModuleImp //--------------------------------------------------------------------------------------------------------- -class ExampleTopWithBlockDevice(implicit p: Parameters) extends ExampleTop +class RocketTopWithBlockDevice(implicit p: Parameters) extends RocketTop with HasPeripheryBlockDevice { - override lazy val module = new ExampleTopWithBlockDeviceModule(this) + override lazy val module = new RocketTopWithBlockDeviceModule(this) } -class ExampleTopWithBlockDeviceModule(l: ExampleTopWithBlockDevice) - extends ExampleTopModule(l) +class RocketTopWithBlockDeviceModule(l: RocketTopWithBlockDevice) + extends RocketTopModule(l) + with HasPeripheryBlockDeviceModuleImp + +// ---------------------- +// BOOM Top Level Systems +// ---------------------- + +class BoomTop(implicit p: Parameters) extends boom.system.BoomSystem + with HasNoDebug + with HasPeripherySerial { + override lazy val module = new BoomTopModule(this) +} + +class BoomTopModule[+L <: BoomTop](l: L) extends boom.system.BoomSystemModule(l) + with HasRTCModuleImp + with HasNoDebugModuleImp + with HasPeripherySerialModuleImp + with DontTouch + +//--------------------------------------------------------------------------------------------------------- + +class BoomTopWithPWMTL(implicit p: Parameters) extends BoomTop + with HasPeripheryPWMTL { + override lazy val module = new BoomTopWithPWMTLModule(this) +} + +class BoomTopWithPWMTLModule(l: BoomTopWithPWMTL) extends BoomTopModule(l) + with HasPeripheryPWMTLModuleImp + +//--------------------------------------------------------------------------------------------------------- + +class BoomTopWithPWMAXI4(implicit p: Parameters) extends BoomTop + with HasPeripheryPWMAXI4 { + override lazy val module = new BoomTopWithPWMAXI4Module(this) +} + +class BoomTopWithPWMAXI4Module(l: BoomTopWithPWMAXI4) extends BoomTopModule(l) + with HasPeripheryPWMAXI4ModuleImp + +//--------------------------------------------------------------------------------------------------------- + +class BoomTopWithBlockDevice(implicit p: Parameters) extends BoomTop + with HasPeripheryBlockDevice { + override lazy val module = new BoomTopWithBlockDeviceModule(this) +} + +class BoomTopWithBlockDeviceModule(l: BoomTopWithBlockDevice) extends BoomTopModule(l) with HasPeripheryBlockDeviceModuleImp From b8eadb99eb68a9b80afa5d25160a6f0c491fa37b Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Sat, 20 Apr 2019 21:20:20 -0700 Subject: [PATCH 03/14] add back example to rocket system --- src/main/scala/example/Top.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/example/Top.scala b/src/main/scala/example/Top.scala index 4dbf5a53..aa2f8d0d 100644 --- a/src/main/scala/example/Top.scala +++ b/src/main/scala/example/Top.scala @@ -12,7 +12,7 @@ import testchipip._ // Rocket Top Level Systems // ------------------------ -class RocketTop(implicit p: Parameters) extends RocketSystem +class RocketTop(implicit p: Parameters) extends ExampleRocketSystem with CanHaveMasterAXI4MemPort with HasPeripheryBootROM with HasNoDebug @@ -20,7 +20,7 @@ class RocketTop(implicit p: Parameters) extends RocketSystem override lazy val module = new RocketTopModule(this) } -class RocketTopModule[+L <: RocketTop](l: L) extends RocketSystemModuleImp(l) +class RocketTopModule[+L <: RocketTop](l: L) extends ExampleRocketSystemModuleImp(l) with HasRTCModuleImp with CanHaveMasterAXI4MemPortModuleImp with HasPeripheryBootROMModuleImp From eda0b113c1e7f9cd8c2aad49932fae72d019cfcc Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Sun, 21 Apr 2019 14:41:02 -0700 Subject: [PATCH 04/14] more default subprojects | fix example builds --- src/main/scala/example/Top.scala | 4 ++-- variables.mk | 23 +++++++++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/main/scala/example/Top.scala b/src/main/scala/example/Top.scala index aa2f8d0d..6850580f 100644 --- a/src/main/scala/example/Top.scala +++ b/src/main/scala/example/Top.scala @@ -63,13 +63,13 @@ class RocketTopWithBlockDeviceModule(l: RocketTopWithBlockDevice) // BOOM Top Level Systems // ---------------------- -class BoomTop(implicit p: Parameters) extends boom.system.BoomSystem +class BoomTop(implicit p: Parameters) extends boom.system.ExampleBoomSystem with HasNoDebug with HasPeripherySerial { override lazy val module = new BoomTopModule(this) } -class BoomTopModule[+L <: BoomTop](l: L) extends boom.system.BoomSystemModule(l) +class BoomTopModule[+L <: BoomTop](l: L) extends boom.system.ExampleBoomSystemModule(l) with HasRTCModuleImp with HasNoDebugModuleImp with HasPeripherySerialModuleImp diff --git a/variables.mk b/variables.mk index 5aea54a5..7b2f6ba0 100644 --- a/variables.mk +++ b/variables.mk @@ -3,7 +3,7 @@ ######################################################################################### ######################################################################################### -# default variables to invoke the generator +# default variables to invoke the generator for a example Rocket system # descriptions: # PROJECT = the scala package to find the MODEL/Generator in # MODEL = the top level module of the project (normally the harness) @@ -17,17 +17,28 @@ # SUB_PROJECT = use the specific subproject default variables ######################################################################################### PROJECT ?= example -MODEL ?= TestHarness -CONFIG ?= DefaultExampleConfig +MODEL ?= RocketTestHarness +CONFIG ?= DefaultRocketConfig CFG_PROJECT ?= $(PROJECT) SBT_PROJECT ?= $(PROJECT) TB ?= TestDriver -TOP ?= ExampleTop +TOP ?= RocketTop +# make it so that you only change 1 param to change most or all of them! SUB_PROJECT ?= example -ifeq ($(SUB_PROJECT),boom) # make it so that you only change 1 param to change them all! - SBT_PROJECT=boom +ifeq ($(SUB_PROJECT),boomexample) + # for a BOOM based system (provides all necessary params) + MODEL=BoomTestHarness + CONFIG=DefaultBoomConfig + TOP=BoomTop +endif +ifeq ($(SUB_PROJECT),boom) + # for BOOM developers (only need to provide a CONFIG) PROJECT=boom.system + MODEL=TestHarness + #CONFIG: User specified + CFG_PROJECT=boom.system + SBT_PROJECT=boom TOP=ExampleBoomSystem endif From 668047e3fdad7f6c0ca6dabf2e12014e40bb77b2 Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Sun, 21 Apr 2019 15:19:15 -0700 Subject: [PATCH 05/14] added GPIO config | breaks on building test harness --- src/main/scala/example/Configs.scala | 68 ++++++++++++++++++++++-- src/main/scala/example/TestHarness.scala | 1 + src/main/scala/example/Top.scala | 23 ++++++++ 3 files changed, 87 insertions(+), 5 deletions(-) diff --git a/src/main/scala/example/Configs.scala b/src/main/scala/example/Configs.scala index 72c40a1b..3ace5fb2 100644 --- a/src/main/scala/example/Configs.scala +++ b/src/main/scala/example/Configs.scala @@ -7,6 +7,19 @@ import freechips.rocketchip.diplomacy.{LazyModule, ValName} import freechips.rocketchip.devices.tilelink.BootROMParams import freechips.rocketchip.tile.XLen import testchipip._ +import sifive.blocks.devices.gpio._ + +/** + * TODO: Why do we need this? + */ +object ConfigValName { + implicit val valName = ValName("TestHarness") +} +import ConfigValName._ + +// ------------------------------- +// Common Configs +// ------------------------------- /** * Class to specify where the BootRom file is (from `rebar` top) @@ -17,12 +30,12 @@ class WithBootROM extends Config((site, here, up) => { }) /** - * TODO: Why do we need this? + * Class to add in GPIO */ -object ConfigValName { - implicit val valName = ValName("TestHarness") -} -import ConfigValName._ +class WithGPIO extends Config((site, here, up) => { + case PeripheryGPIOKey => List( + GPIOParams(address = 0x10012000, width = 4, includeIOF = true)) +}) // ------------------------------- // Rocket Top Level System Configs @@ -75,6 +88,16 @@ class WithSimBlockDeviceRocketTop extends Config((site, here, up) => { } }) +/** + * Class to specify a top level rocket-chip system with GPIO + */ +class WithGPIORocketTop extends Config((site, here, up) => { + case BuildRocketTop => (clock: Clock, reset: Bool, p: Parameters) => { + val top = Module(LazyModule(new RocketTopWithGPIO()(p)).module) + top + } +}) + // -------------- // Rocket Configs // -------------- @@ -117,26 +140,43 @@ class RV32RocketConfig extends Config( new WithRV32 ++ new DefaultRocketConfig) +class GPIORocketConfig extends Config( + new WithGPIO ++ + new WithGPIORocketTop ++ + new BaseRocketConfig) + // ----------------------------- // BOOM Top Level System Configs // ----------------------------- +/** + * Class to specify a "plain" top level BOOM system + */ class WithNormalBoomTop extends Config((site, here, up) => { case BuildBoomTop => (clock: Clock, reset: Bool, p: Parameters) => { Module(LazyModule(new BoomTop()(p)).module) } }) +/** + * Class to specify a top level BOOM system with PWM + */ class WithPWMBoomTop extends Config((site, here, up) => { case BuildBoomTop => (clock: Clock, reset: Bool, p: Parameters) => Module(LazyModule(new BoomTopWithPWMTL()(p)).module) }) +/** + * Class to specify a top level BOOM system with a PWM AXI4 + */ class WithPWMAXI4BoomTop extends Config((site, here, up) => { case BuildBoomTop => (clock: Clock, reset: Bool, p: Parameters) => Module(LazyModule(new BoomTopWithPWMAXI4()(p)).module) }) +/** + * Class to specify a top level BOOM system with a block device + */ class WithBlockDeviceModelBoomTop extends Config((site, here, up) => { case BuildBoomTop => (clock: Clock, reset: Bool, p: Parameters) => { val top = Module(LazyModule(new BoomTopWithBlockDevice()(p)).module) @@ -145,6 +185,9 @@ class WithBlockDeviceModelBoomTop extends Config((site, here, up) => { } }) +/** + * Class to specify a top level BOOM system with a simulator block device + */ class WithSimBlockDeviceBoomTop extends Config((site, here, up) => { case BuildBoomTop => (clock: Clock, reset: Bool, p: Parameters) => { val top = Module(LazyModule(new BoomTopWithBlockDevice()(p)).module) @@ -153,6 +196,16 @@ class WithSimBlockDeviceBoomTop extends Config((site, here, up) => { } }) +/** + * Class to specify a top level BOOM system with GPIO + */ +class WithGPIOBoomTop extends Config((site, here, up) => { + case BuildBoomTop => (clock: Clock, reset: Bool, p: Parameters) => { + val top = Module(LazyModule(new BoomTopWithGPIO()(p)).module) + top + } +}) + // ------------ // BOOM Configs // ------------ @@ -195,3 +248,8 @@ class DualCoreBoomConfig extends Config( class RV32BoomConfig extends Config( new WithBootROM ++ new boom.system.SmallRV32UnifiedBoomConfig) + +class GPIOBoomConfig extends Config( + new WithGPIO ++ + new WithGPIOBoomTop ++ + new BaseBoomConfig) diff --git a/src/main/scala/example/TestHarness.scala b/src/main/scala/example/TestHarness.scala index a278c46b..61296545 100644 --- a/src/main/scala/example/TestHarness.scala +++ b/src/main/scala/example/TestHarness.scala @@ -36,6 +36,7 @@ class RocketTestHarness(implicit val p: Parameters) extends Module { axi.w.bits := DontCare } }) + io.success := dut.connectSimSerial() } diff --git a/src/main/scala/example/Top.scala b/src/main/scala/example/Top.scala index 6850580f..8a39e3d1 100644 --- a/src/main/scala/example/Top.scala +++ b/src/main/scala/example/Top.scala @@ -7,6 +7,7 @@ import freechips.rocketchip.config.Parameters import freechips.rocketchip.devices.tilelink._ import freechips.rocketchip.util.DontTouch import testchipip._ +import sifive.blocks.devices.gpio._ // ------------------------ // Rocket Top Level Systems @@ -59,6 +60,17 @@ class RocketTopWithBlockDeviceModule(l: RocketTopWithBlockDevice) extends RocketTopModule(l) with HasPeripheryBlockDeviceModuleImp +//--------------------------------------------------------------------------------------------------------- + +class RocketTopWithGPIO(implicit p: Parameters) extends RocketTop + with HasPeripheryGPIO { + override lazy val module = new RocketTopWithGPIOModule(this) +} + +class RocketTopWithGPIOModule(l: RocketTopWithGPIO) + extends RocketTopModule(l) + with HasPeripheryGPIOModuleImp + // ---------------------- // BOOM Top Level Systems // ---------------------- @@ -104,3 +116,14 @@ class BoomTopWithBlockDevice(implicit p: Parameters) extends BoomTop class BoomTopWithBlockDeviceModule(l: BoomTopWithBlockDevice) extends BoomTopModule(l) with HasPeripheryBlockDeviceModuleImp + +//--------------------------------------------------------------------------------------------------------- + +class BoomTopWithGPIO(implicit p: Parameters) extends BoomTop + with HasPeripheryGPIO { + override lazy val module = new BoomTopWithGPIOModule(this) +} + +class BoomTopWithGPIOModule(l: BoomTopWithGPIO) + extends BoomTopModule(l) + with HasPeripheryGPIOModuleImp From 180a2ab4a8f01f301127257f6ad7f6183505234a Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Sun, 21 Apr 2019 16:07:30 -0700 Subject: [PATCH 06/14] harness builds with gpio tied off --- src/main/scala/example/Configs.scala | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/scala/example/Configs.scala b/src/main/scala/example/Configs.scala index 3ace5fb2..4326dadb 100644 --- a/src/main/scala/example/Configs.scala +++ b/src/main/scala/example/Configs.scala @@ -34,7 +34,7 @@ class WithBootROM extends Config((site, here, up) => { */ class WithGPIO extends Config((site, here, up) => { case PeripheryGPIOKey => List( - GPIOParams(address = 0x10012000, width = 4, includeIOF = true)) + GPIOParams(address = 0x10012000, width = 4, includeIOF = false)) }) // ------------------------------- @@ -94,6 +94,11 @@ class WithSimBlockDeviceRocketTop extends Config((site, here, up) => { class WithGPIORocketTop extends Config((site, here, up) => { case BuildRocketTop => (clock: Clock, reset: Bool, p: Parameters) => { val top = Module(LazyModule(new RocketTopWithGPIO()(p)).module) + for (gpio <- top.gpio) { + for (pin <- gpio.pins) { + pin.i.ival := false.B + } + } top } }) @@ -202,6 +207,11 @@ class WithSimBlockDeviceBoomTop extends Config((site, here, up) => { class WithGPIOBoomTop extends Config((site, here, up) => { case BuildBoomTop => (clock: Clock, reset: Bool, p: Parameters) => { val top = Module(LazyModule(new BoomTopWithGPIO()(p)).module) + for (gpio <- top.gpio) { + for (pin <- gpio.pins) { + pin.i.ival := false.B + } + } top } }) From 47149a0649709dc48346c3964a221bcf84ad3e53 Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Mon, 22 Apr 2019 14:47:53 -0700 Subject: [PATCH 07/14] change smallboom to boomconfig --- src/main/scala/example/Configs.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/example/Configs.scala b/src/main/scala/example/Configs.scala index 4326dadb..7c7faf47 100644 --- a/src/main/scala/example/Configs.scala +++ b/src/main/scala/example/Configs.scala @@ -222,7 +222,7 @@ class WithGPIOBoomTop extends Config((site, here, up) => { class BaseBoomConfig extends Config( new WithBootROM ++ - new boom.system.SmallBoomConfig) + new boom.system.BoomConfig) class DefaultBoomConfig extends Config( new WithNormalBoomTop ++ From 0278845009b772c9fe9c9ec607a0f93cf6da760a Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Mon, 22 Apr 2019 16:28:37 -0700 Subject: [PATCH 08/14] separated mixins from configs --- src/main/scala/example/Configs.scala | 166 +-------------------------- 1 file changed, 1 insertion(+), 165 deletions(-) diff --git a/src/main/scala/example/Configs.scala b/src/main/scala/example/Configs.scala index 7c7faf47..52ee21de 100644 --- a/src/main/scala/example/Configs.scala +++ b/src/main/scala/example/Configs.scala @@ -1,107 +1,9 @@ package example import chisel3._ -import freechips.rocketchip.config.{Parameters, Config} +import freechips.rocketchip.config.{Config} import freechips.rocketchip.subsystem.{WithRoccExample, WithNMemoryChannels, WithNBigCores, WithRV32} -import freechips.rocketchip.diplomacy.{LazyModule, ValName} -import freechips.rocketchip.devices.tilelink.BootROMParams -import freechips.rocketchip.tile.XLen import testchipip._ -import sifive.blocks.devices.gpio._ - -/** - * TODO: Why do we need this? - */ -object ConfigValName { - implicit val valName = ValName("TestHarness") -} -import ConfigValName._ - -// ------------------------------- -// Common Configs -// ------------------------------- - -/** - * Class to specify where the BootRom file is (from `rebar` top) - */ -class WithBootROM extends Config((site, here, up) => { - case BootROMParams => BootROMParams( - contentFileName = s"./bootrom/bootrom.rv${site(XLen)}.img") -}) - -/** - * Class to add in GPIO - */ -class WithGPIO extends Config((site, here, up) => { - case PeripheryGPIOKey => List( - GPIOParams(address = 0x10012000, width = 4, includeIOF = false)) -}) - -// ------------------------------- -// Rocket Top Level System Configs -// ------------------------------- - -/** - * Class to specify a "plain" top level rocket-chip system - */ -class WithNormalRocketTop extends Config((site, here, up) => { - case BuildRocketTop => (clock: Clock, reset: Bool, p: Parameters) => { - Module(LazyModule(new RocketTop()(p)).module) - } -}) - -/** - * Class to specify a top level rocket-chip system with PWM - */ -class WithPWMRocketTop extends Config((site, here, up) => { - case BuildRocketTop => (clock: Clock, reset: Bool, p: Parameters) => - Module(LazyModule(new RocketTopWithPWMTL()(p)).module) -}) - -/** - * Class to specify a top level rocket-chip system with a PWM AXI4 - */ -class WithPWMAXI4RocketTop extends Config((site, here, up) => { - case BuildRocketTop => (clock: Clock, reset: Bool, p: Parameters) => - Module(LazyModule(new RocketTopWithPWMAXI4()(p)).module) -}) - -/** - * Class to specify a top level rocket-chip system with a block device - */ -class WithBlockDeviceModelRocketTop extends Config((site, here, up) => { - case BuildRocketTop => (clock: Clock, reset: Bool, p: Parameters) => { - val top = Module(LazyModule(new RocketTopWithBlockDevice()(p)).module) - top.connectBlockDeviceModel() - top - } -}) - -/** - * Class to specify a top level rocket-chip system with a simulator block device - */ -class WithSimBlockDeviceRocketTop extends Config((site, here, up) => { - case BuildRocketTop => (clock: Clock, reset: Bool, p: Parameters) => { - val top = Module(LazyModule(new RocketTopWithBlockDevice()(p)).module) - top.connectSimBlockDevice(clock, reset) - top - } -}) - -/** - * Class to specify a top level rocket-chip system with GPIO - */ -class WithGPIORocketTop extends Config((site, here, up) => { - case BuildRocketTop => (clock: Clock, reset: Bool, p: Parameters) => { - val top = Module(LazyModule(new RocketTopWithGPIO()(p)).module) - for (gpio <- top.gpio) { - for (pin <- gpio.pins) { - pin.i.ival := false.B - } - } - top - } -}) // -------------- // Rocket Configs @@ -150,72 +52,6 @@ class GPIORocketConfig extends Config( new WithGPIORocketTop ++ new BaseRocketConfig) -// ----------------------------- -// BOOM Top Level System Configs -// ----------------------------- - -/** - * Class to specify a "plain" top level BOOM system - */ -class WithNormalBoomTop extends Config((site, here, up) => { - case BuildBoomTop => (clock: Clock, reset: Bool, p: Parameters) => { - Module(LazyModule(new BoomTop()(p)).module) - } -}) - -/** - * Class to specify a top level BOOM system with PWM - */ -class WithPWMBoomTop extends Config((site, here, up) => { - case BuildBoomTop => (clock: Clock, reset: Bool, p: Parameters) => - Module(LazyModule(new BoomTopWithPWMTL()(p)).module) -}) - -/** - * Class to specify a top level BOOM system with a PWM AXI4 - */ -class WithPWMAXI4BoomTop extends Config((site, here, up) => { - case BuildBoomTop => (clock: Clock, reset: Bool, p: Parameters) => - Module(LazyModule(new BoomTopWithPWMAXI4()(p)).module) -}) - -/** - * Class to specify a top level BOOM system with a block device - */ -class WithBlockDeviceModelBoomTop extends Config((site, here, up) => { - case BuildBoomTop => (clock: Clock, reset: Bool, p: Parameters) => { - val top = Module(LazyModule(new BoomTopWithBlockDevice()(p)).module) - top.connectBlockDeviceModel() - top - } -}) - -/** - * Class to specify a top level BOOM system with a simulator block device - */ -class WithSimBlockDeviceBoomTop extends Config((site, here, up) => { - case BuildBoomTop => (clock: Clock, reset: Bool, p: Parameters) => { - val top = Module(LazyModule(new BoomTopWithBlockDevice()(p)).module) - top.connectSimBlockDevice(clock, reset) - top - } -}) - -/** - * Class to specify a top level BOOM system with GPIO - */ -class WithGPIOBoomTop extends Config((site, here, up) => { - case BuildBoomTop => (clock: Clock, reset: Bool, p: Parameters) => { - val top = Module(LazyModule(new BoomTopWithGPIO()(p)).module) - for (gpio <- top.gpio) { - for (pin <- gpio.pins) { - pin.i.ival := false.B - } - } - top - } -}) - // ------------ // BOOM Configs // ------------ From f11901a393c6dfa68bc4f7dc0711a5db53b4ab4d Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Mon, 22 Apr 2019 16:41:11 -0700 Subject: [PATCH 09/14] added configmixin file --- src/main/scala/example/ConfigMixins.scala | 170 ++++++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 src/main/scala/example/ConfigMixins.scala diff --git a/src/main/scala/example/ConfigMixins.scala b/src/main/scala/example/ConfigMixins.scala new file mode 100644 index 00000000..e9b113b1 --- /dev/null +++ b/src/main/scala/example/ConfigMixins.scala @@ -0,0 +1,170 @@ +package example + +import chisel3._ +import freechips.rocketchip.config.{Parameters, Config} +import freechips.rocketchip.subsystem.{WithRoccExample, WithNMemoryChannels, WithNBigCores, WithRV32} +import freechips.rocketchip.diplomacy.{LazyModule, ValName} +import freechips.rocketchip.devices.tilelink.BootROMParams +import freechips.rocketchip.tile.XLen +import testchipip._ +import sifive.blocks.devices.gpio._ + +/** + * TODO: Why do we need this? + */ +object ConfigValName { + implicit val valName = ValName("TestHarness") +} +import ConfigValName._ + +// ----------------------- +// Common Parameter Mixins +// ----------------------- + +/** + * Class to specify where the BootRom file is (from `rebar` top) + */ +class WithBootROM extends Config((site, here, up) => { + case BootROMParams => BootROMParams( + contentFileName = s"./bootrom/bootrom.rv${site(XLen)}.img") +}) + +/** + * Class to add in GPIO + */ +class WithGPIO extends Config((site, here, up) => { + case PeripheryGPIOKey => List( + GPIOParams(address = 0x10012000, width = 4, includeIOF = false)) +}) + +// ---------------------------------------- +// Rocket Top Level System Parameter Mixins +// ---------------------------------------- + +/** + * Class to specify a "plain" top level rocket-chip system + */ +class WithNormalRocketTop extends Config((site, here, up) => { + case BuildRocketTop => (clock: Clock, reset: Bool, p: Parameters) => { + Module(LazyModule(new RocketTop()(p)).module) + } +}) + +/** + * Class to specify a top level rocket-chip system with PWM + */ +class WithPWMRocketTop extends Config((site, here, up) => { + case BuildRocketTop => (clock: Clock, reset: Bool, p: Parameters) => + Module(LazyModule(new RocketTopWithPWMTL()(p)).module) +}) + +/** + * Class to specify a top level rocket-chip system with a PWM AXI4 + */ +class WithPWMAXI4RocketTop extends Config((site, here, up) => { + case BuildRocketTop => (clock: Clock, reset: Bool, p: Parameters) => + Module(LazyModule(new RocketTopWithPWMAXI4()(p)).module) +}) + +/** + * Class to specify a top level rocket-chip system with a block device + */ +class WithBlockDeviceModelRocketTop extends Config((site, here, up) => { + case BuildRocketTop => (clock: Clock, reset: Bool, p: Parameters) => { + val top = Module(LazyModule(new RocketTopWithBlockDevice()(p)).module) + top.connectBlockDeviceModel() + top + } +}) + +/** + * Class to specify a top level rocket-chip system with a simulator block device + */ +class WithSimBlockDeviceRocketTop extends Config((site, here, up) => { + case BuildRocketTop => (clock: Clock, reset: Bool, p: Parameters) => { + val top = Module(LazyModule(new RocketTopWithBlockDevice()(p)).module) + top.connectSimBlockDevice(clock, reset) + top + } +}) + +/** + * Class to specify a top level rocket-chip system with GPIO + */ +class WithGPIORocketTop extends Config((site, here, up) => { + case BuildRocketTop => (clock: Clock, reset: Bool, p: Parameters) => { + val top = Module(LazyModule(new RocketTopWithGPIO()(p)).module) + for (gpio <- top.gpio) { + for (pin <- gpio.pins) { + pin.i.ival := false.B + } + } + top + } +}) + +// -------------------------------------- +// BOOM Top Level System Parameter Mixins +// -------------------------------------- + +/** + * Class to specify a "plain" top level BOOM system + */ +class WithNormalBoomTop extends Config((site, here, up) => { + case BuildBoomTop => (clock: Clock, reset: Bool, p: Parameters) => { + Module(LazyModule(new BoomTop()(p)).module) + } +}) + +/** + * Class to specify a top level BOOM system with PWM + */ +class WithPWMBoomTop extends Config((site, here, up) => { + case BuildBoomTop => (clock: Clock, reset: Bool, p: Parameters) => + Module(LazyModule(new BoomTopWithPWMTL()(p)).module) +}) + +/** + * Class to specify a top level BOOM system with a PWM AXI4 + */ +class WithPWMAXI4BoomTop extends Config((site, here, up) => { + case BuildBoomTop => (clock: Clock, reset: Bool, p: Parameters) => + Module(LazyModule(new BoomTopWithPWMAXI4()(p)).module) +}) + +/** + * Class to specify a top level BOOM system with a block device + */ +class WithBlockDeviceModelBoomTop extends Config((site, here, up) => { + case BuildBoomTop => (clock: Clock, reset: Bool, p: Parameters) => { + val top = Module(LazyModule(new BoomTopWithBlockDevice()(p)).module) + top.connectBlockDeviceModel() + top + } +}) + +/** + * Class to specify a top level BOOM system with a simulator block device + */ +class WithSimBlockDeviceBoomTop extends Config((site, here, up) => { + case BuildBoomTop => (clock: Clock, reset: Bool, p: Parameters) => { + val top = Module(LazyModule(new BoomTopWithBlockDevice()(p)).module) + top.connectSimBlockDevice(clock, reset) + top + } +}) + +/** + * Class to specify a top level BOOM system with GPIO + */ +class WithGPIOBoomTop extends Config((site, here, up) => { + case BuildBoomTop => (clock: Clock, reset: Bool, p: Parameters) => { + val top = Module(LazyModule(new BoomTopWithGPIO()(p)).module) + for (gpio <- top.gpio) { + for (pin <- gpio.pins) { + pin.i.ival := false.B + } + } + top + } +}) From 0e5e1bac15dcb064a4757966dacb4e9e444859db Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Mon, 22 Apr 2019 22:36:04 -0700 Subject: [PATCH 10/14] fix test harness builds --- README.md | 2 +- common.mk | 2 +- src/main/scala/example/TestHarness.scala | 6 ++++++ variables.mk | 19 ++++++++++--------- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 887dce08..7748e53e 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ **This branch is under development** **It currently has many submodules** -**Please run ./scripts/init-submodules-no-riscv-tools.sh to update submodules, unless you want to spend a long time waiting for submodule to clone** +**Please run ./scripts/init-submodules-no-riscv-tools.sh to update submodules, unless you want to spend a long time waiting for submodules to clone** This is a starter template for your custom RISC-V project. It will allow you to leverage the Chisel HDL and RocketChip SoC generator to produce a diff --git a/common.mk b/common.mk index b090285d..e2603be7 100644 --- a/common.mk +++ b/common.mk @@ -53,7 +53,7 @@ $(VERILOG_FILE) $(SMEMS_CONF) $(TOP_ANNO) $(TOP_FIR) $(sim_top_blackboxes): $(FI cp $(build_dir)/firrtl_black_box_resource_files.f $(sim_top_blackboxes) $(HARNESS_FILE) $(HARNESS_ANNO) $(HARNESS_FIR) $(sim_harness_blackboxes): $(FIRRTL_FILE) $(ANNO_FILE) $(sim_top_blackboxes) - cd $(base_dir) && $(SBT) "project tapeout" "runMain barstools.tapeout.transforms.GenerateHarness -o $(HARNESS_FILE) -i $(FIRRTL_FILE) --syn-top $(TOP) --harness-top $(MODEL) -faf $(ANNO_FILE) -thaof $(HARNESS_ANNO) -thf $(HARNESS_FIR) -td $(build_dir)" + cd $(base_dir) && $(SBT) "project tapeout" "runMain barstools.tapeout.transforms.GenerateHarness -o $(HARNESS_FILE) -i $(FIRRTL_FILE) --syn-top $(TOP) --harness-top $(FIRRTL_MODEL) -faf $(ANNO_FILE) -thaof $(HARNESS_ANNO) -thf $(HARNESS_FIR) -td $(build_dir)" grep -v "SimSerial.cc\|SimDTM.cc\|SimJTAG.cc" $(build_dir)/firrtl_black_box_resource_files.f > $(sim_harness_blackboxes) # This file is for simulation only. VLSI flows should replace this file with one containing hard SRAMs diff --git a/src/main/scala/example/TestHarness.scala b/src/main/scala/example/TestHarness.scala index 61296545..b7120329 100644 --- a/src/main/scala/example/TestHarness.scala +++ b/src/main/scala/example/TestHarness.scala @@ -18,6 +18,9 @@ class RocketTestHarness(implicit val p: Parameters) extends Module { val success = Output(Bool()) }) + // force Chisel to rename module + override def desiredName = "TestHarness" + val dut = p(BuildRocketTop)(clock, reset.toBool, p) dut.debug := DontCare dut.connectSimAXIMem() @@ -51,6 +54,9 @@ class BoomTestHarness(implicit val p: Parameters) extends Module { val success = Output(Bool()) }) + // force Chisel to rename module + override def desiredName = "TestHarness" + val dut = p(BuildBoomTop)(clock, reset.toBool, p) dut.debug := DontCare dut.connectSimAXIMem() diff --git a/variables.mk b/variables.mk index 7b2f6ba0..baf18d6a 100644 --- a/variables.mk +++ b/variables.mk @@ -6,7 +6,8 @@ # default variables to invoke the generator for a example Rocket system # descriptions: # PROJECT = the scala package to find the MODEL/Generator in -# MODEL = the top level module of the project (normally the harness) +# MODEL = the top level module of the project in Chisel (normally the harness) +# FIRRTL_MODEL = the top level module of the project in Firrtl (normally the harness) # CONFIG = the configuration class to give the parameters for the project # CFG_PROJECT = the scala package to find the CONFIG class # SBT_PROJECT = the SBT project that you should find the Generator class in @@ -16,13 +17,14 @@ # project specific: # SUB_PROJECT = use the specific subproject default variables ######################################################################################### -PROJECT ?= example -MODEL ?= RocketTestHarness -CONFIG ?= DefaultRocketConfig -CFG_PROJECT ?= $(PROJECT) -SBT_PROJECT ?= $(PROJECT) -TB ?= TestDriver -TOP ?= RocketTop +PROJECT ?= example +MODEL ?= RocketTestHarness +FIRRTL_MODEL ?= TestHarness +CONFIG ?= DefaultRocketConfig +CFG_PROJECT ?= $(PROJECT) +SBT_PROJECT ?= $(PROJECT) +TB ?= TestDriver +TOP ?= RocketTop # make it so that you only change 1 param to change most or all of them! SUB_PROJECT ?= example @@ -36,7 +38,6 @@ ifeq ($(SUB_PROJECT),boom) # for BOOM developers (only need to provide a CONFIG) PROJECT=boom.system MODEL=TestHarness - #CONFIG: User specified CFG_PROJECT=boom.system SBT_PROJECT=boom TOP=ExampleBoomSystem From 2bd70937cbe002173aad6e6b98875313cbb33fd7 Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Mon, 22 Apr 2019 23:26:13 -0700 Subject: [PATCH 11/14] support verilator | rename build variable --- common.mk | 2 +- sims/verisim/Makefile | 12 ++++++------ sims/verisim/verilator.mk | 4 ++-- variables.mk | 18 +++++++++--------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/common.mk b/common.mk index e2603be7..d7703f7e 100644 --- a/common.mk +++ b/common.mk @@ -53,7 +53,7 @@ $(VERILOG_FILE) $(SMEMS_CONF) $(TOP_ANNO) $(TOP_FIR) $(sim_top_blackboxes): $(FI cp $(build_dir)/firrtl_black_box_resource_files.f $(sim_top_blackboxes) $(HARNESS_FILE) $(HARNESS_ANNO) $(HARNESS_FIR) $(sim_harness_blackboxes): $(FIRRTL_FILE) $(ANNO_FILE) $(sim_top_blackboxes) - cd $(base_dir) && $(SBT) "project tapeout" "runMain barstools.tapeout.transforms.GenerateHarness -o $(HARNESS_FILE) -i $(FIRRTL_FILE) --syn-top $(TOP) --harness-top $(FIRRTL_MODEL) -faf $(ANNO_FILE) -thaof $(HARNESS_ANNO) -thf $(HARNESS_FIR) -td $(build_dir)" + cd $(base_dir) && $(SBT) "project tapeout" "runMain barstools.tapeout.transforms.GenerateHarness -o $(HARNESS_FILE) -i $(FIRRTL_FILE) --syn-top $(TOP) --harness-top $(VLOG_MODEL) -faf $(ANNO_FILE) -thaof $(HARNESS_ANNO) -thf $(HARNESS_FIR) -td $(build_dir)" grep -v "SimSerial.cc\|SimDTM.cc\|SimJTAG.cc" $(build_dir)/firrtl_black_box_resource_files.f > $(sim_harness_blackboxes) # This file is for simulation only. VLSI flows should replace this file with one containing hard SRAMs diff --git a/sims/verisim/Makefile b/sims/verisim/Makefile index 89d9c6e8..93f45d5a 100644 --- a/sims/verisim/Makefile +++ b/sims/verisim/Makefile @@ -41,11 +41,11 @@ include $(sim_dir)/verilator.mk model_dir = $(build_dir)/$(long_name) model_dir_debug = $(build_dir)/$(long_name).debug -model_header = $(model_dir)/V$(MODEL).h -model_header_debug = $(model_dir_debug)/V$(MODEL).h +model_header = $(model_dir)/V$(VLOG_MODEL).h +model_header_debug = $(model_dir_debug)/V$(VLOG_MODEL).h -model_mk = $(model_dir)/V$(MODEL).mk -model_mk_debug = $(model_dir_debug)/V$(MODEL).mk +model_mk = $(model_dir)/V$(VLOG_MODEL).mk +model_mk_debug = $(model_dir_debug)/V$(VLOG_MODEL).mk ######################################################################################### # build makefile fragment that builds the verilator sim rules @@ -72,10 +72,10 @@ $(model_mk_debug): $(sim_vsrcs) $(sim_dotf) $(INSTALLED_VERILATOR) # invoke make to make verilator sim rules ######################################################################################### $(sim): $(model_mk) - $(MAKE) VM_PARALLEL_BUILDS=1 -C $(build_dir)/$(long_name) -f V$(MODEL).mk + $(MAKE) VM_PARALLEL_BUILDS=1 -C $(build_dir)/$(long_name) -f V$(VLOG_MODEL).mk $(sim_debug): $(model_mk_debug) - $(MAKE) VM_PARALLEL_BUILDS=1 -C $(build_dir)/$(long_name).debug -f V$(MODEL).mk + $(MAKE) VM_PARALLEL_BUILDS=1 -C $(build_dir)/$(long_name).debug -f V$(VLOG_MODEL).mk ######################################################################################### # create a vcs vpd rule diff --git a/sims/verisim/verilator.mk b/sims/verisim/verilator.mk index 3af9b335..b0aaae62 100644 --- a/sims/verisim/verilator.mk +++ b/sims/verisim/verilator.mk @@ -39,9 +39,9 @@ verilator/verilator-$(VERILATOR_VERSION).tar.gz: ######################################################################################### VERILATOR := $(INSTALLED_VERILATOR) --cc --exe CXXFLAGS := $(CXXFLAGS) -O1 -std=c++11 -I$(RISCV)/include -D__STDC_FORMAT_MACROS -VERILATOR_FLAGS := --top-module $(MODEL) \ +VERILATOR_FLAGS := --top-module $(VLOG_MODEL) \ +define+PRINTF_COND=\$$c\(\"verbose\",\"\&\&\"\,\"done_reset\"\) \ +define+STOP_COND=\$$c\(\"done_reset\"\) --assert \ --output-split 20000 \ -Wno-STMTDLY --x-assign unique \ - -O3 -CFLAGS "$(CXXFLAGS) -DTEST_HARNESS=V$(MODEL) -DVERILATOR" + -O3 -CFLAGS "$(CXXFLAGS) -DTEST_HARNESS=V$(VLOG_MODEL) -DVERILATOR" diff --git a/variables.mk b/variables.mk index baf18d6a..34d829fe 100644 --- a/variables.mk +++ b/variables.mk @@ -7,7 +7,7 @@ # descriptions: # PROJECT = the scala package to find the MODEL/Generator in # MODEL = the top level module of the project in Chisel (normally the harness) -# FIRRTL_MODEL = the top level module of the project in Firrtl (normally the harness) +# VLOG_MODEL = the top level module of the project in Firrtl/Verilog (normally the harness) # CONFIG = the configuration class to give the parameters for the project # CFG_PROJECT = the scala package to find the CONFIG class # SBT_PROJECT = the SBT project that you should find the Generator class in @@ -17,14 +17,14 @@ # project specific: # SUB_PROJECT = use the specific subproject default variables ######################################################################################### -PROJECT ?= example -MODEL ?= RocketTestHarness -FIRRTL_MODEL ?= TestHarness -CONFIG ?= DefaultRocketConfig -CFG_PROJECT ?= $(PROJECT) -SBT_PROJECT ?= $(PROJECT) -TB ?= TestDriver -TOP ?= RocketTop +PROJECT ?= example +MODEL ?= RocketTestHarness +VLOG_MODEL ?= TestHarness +CONFIG ?= DefaultRocketConfig +CFG_PROJECT ?= $(PROJECT) +SBT_PROJECT ?= $(PROJECT) +TB ?= TestDriver +TOP ?= RocketTop # make it so that you only change 1 param to change most or all of them! SUB_PROJECT ?= example From c1a0916e401c3febbc69c6a37e5a7c80fff11c85 Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Tue, 23 Apr 2019 09:20:47 -0700 Subject: [PATCH 12/14] add asm/bmark tests to generator --- src/main/scala/example/Generator.scala | 126 ++++++++++++++++++++++++- 1 file changed, 124 insertions(+), 2 deletions(-) diff --git a/src/main/scala/example/Generator.scala b/src/main/scala/example/Generator.scala index 9b86a826..3a1300b4 100644 --- a/src/main/scala/example/Generator.scala +++ b/src/main/scala/example/Generator.scala @@ -1,13 +1,135 @@ package example +import scala.collection.mutable.LinkedHashSet import chisel3._ import chisel3.experimental._ import firrtl.transforms.{BlackBoxResourceAnno, BlackBoxSourceHelper} -import freechips.rocketchip.diplomacy.LazyModule +import freechips.rocketchip.subsystem.{RocketTilesKey} +import freechips.rocketchip.diplomacy.{LazyModule} import freechips.rocketchip.config.{Field, Parameters} -import freechips.rocketchip.util.GeneratorApp +import freechips.rocketchip.util.{GeneratorApp} +import freechips.rocketchip.tile.{XLen} +import freechips.rocketchip.system.{TestGeneration, RegressionTestSuite} +import boom.system.{BoomTilesKey, BoomTestSuites} object Generator extends GeneratorApp { + val rv64RegrTestNames = LinkedHashSet( + "rv64ud-v-fcvt", + "rv64ud-p-fdiv", + "rv64ud-v-fadd", + "rv64uf-v-fadd", + "rv64um-v-mul", + "rv64mi-p-breakpoint", + "rv64uc-v-rvc", + "rv64ud-v-structural", + "rv64si-p-wfi", + "rv64um-v-divw", + "rv64ua-v-lrsc", + "rv64ui-v-fence_i", + "rv64ud-v-fcvt_w", + "rv64uf-v-fmin", + "rv64ui-v-sb", + "rv64ua-v-amomax_d", + "rv64ud-v-move", + "rv64ud-v-fclass", + "rv64ua-v-amoand_d", + "rv64ua-v-amoxor_d", + "rv64si-p-sbreak", + "rv64ud-v-fmadd", + "rv64uf-v-ldst", + "rv64um-v-mulh", + "rv64si-p-dirty") + + val rv32RegrTestNames = LinkedHashSet( + "rv32mi-p-ma_addr", + "rv32mi-p-csr", + "rv32ui-p-sh", + "rv32ui-p-lh", + "rv32uc-p-rvc", + "rv32mi-p-sbreak", + "rv32ui-p-sll") + + override def addTestSuites { + import freechips.rocketchip.system.DefaultTestSuites._ + val xlen = params(XLen) + + // TODO: for now only generate tests for the first rocket/boom tile in the subsystem + // TODO: support heterogenous systems? + + // rocket specific tests + params(RocketTilesKey).headOption.map { tileParams => + val coreParams = tileParams.core + val vm = coreParams.useVM + val env = if (vm) List("p","v") else List("p") + coreParams.fpu foreach { case cfg => + if (xlen == 32) { + TestGeneration.addSuites(env.map(rv32uf)) + if (cfg.fLen >= 64) + TestGeneration.addSuites(env.map(rv32ud)) + } else { + TestGeneration.addSuite(rv32udBenchmarks) + TestGeneration.addSuites(env.map(rv64uf)) + if (cfg.fLen >= 64) + TestGeneration.addSuites(env.map(rv64ud)) + } + } + if (coreParams.useAtomics) { + if (tileParams.dcache.flatMap(_.scratch).isEmpty) + TestGeneration.addSuites(env.map(if (xlen == 64) rv64ua else rv32ua)) + else + TestGeneration.addSuites(env.map(if (xlen == 64) rv64uaSansLRSC else rv32uaSansLRSC)) + } + if (coreParams.useCompressed) TestGeneration.addSuites(env.map(if (xlen == 64) rv64uc else rv32uc)) + val (rvi, rvu) = + if (xlen == 64) ((if (vm) rv64i else rv64pi), rv64u) + else ((if (vm) rv32i else rv32pi), rv32u) + + TestGeneration.addSuites(rvi.map(_("p"))) + TestGeneration.addSuites((if (vm) List("v") else List()).flatMap(env => rvu.map(_(env)))) + TestGeneration.addSuite(benchmarks) + TestGeneration.addSuite(new RegressionTestSuite(if (xlen == 64) rv64RegrTestNames else rv32RegrTestNames)) + } + + // boom specific tests + params(BoomTilesKey).headOption.map { tileParams => + val coreParams = tileParams.core + val vm = coreParams.useVM + val env = if (vm) List("p","v") else List("p") + coreParams.fpu foreach { case cfg => + if (xlen == 32) { + TestGeneration.addSuites(env.map(rv32uf)) + if (cfg.fLen >= 64) { + TestGeneration.addSuites(env.map(rv32ud)) + } + } else if (cfg.fLen >= 64) { + TestGeneration.addSuites(env.map(rv64ud)) + TestGeneration.addSuites(env.map(rv64uf)) + TestGeneration.addSuite(rv32udBenchmarks) + } + } + if (coreParams.useAtomics) { + if (tileParams.dcache.flatMap(_.scratch).isEmpty) { + TestGeneration.addSuites(env.map(if (xlen == 64) rv64ua else rv32ua)) + } else { + TestGeneration.addSuites(env.map(if (xlen == 64) rv64uaSansLRSC else rv32uaSansLRSC)) + } + } + if (coreParams.useCompressed) TestGeneration.addSuites(env.map(if (xlen == 64) rv64uc else rv32uc)) + + // Include our BOOM-specific overrides. + val (rvi, rvu) = + if (xlen == 64) ((if (vm) BoomTestSuites.rv64i else BoomTestSuites.rv64pi), rv64u) + else ((if (vm) rv32i else rv32pi), rv32u) + + TestGeneration.addSuites(rvi.map(_("p"))) + TestGeneration.addSuites(rvu.map(_("p"))) + TestGeneration.addSuites((if (vm) List("v") else List()).flatMap(env => rvu.map(_(env)))) + TestGeneration.addSuite(benchmarks) + rv64RegrTestNames -= "rv64mi-p-breakpoint" // TODO: breakpoints not implemented yet + TestGeneration.addSuite(new RegressionTestSuite(if (xlen == 64) rv64RegrTestNames else rv32RegrTestNames)) + } + } + val longName = names.topModuleProject + "." + names.topModuleClass + "." + names.configs generateFirrtl generateAnno From 862c217ff41ceb23bb4709a5ce497dd3aa2ecaa6 Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Tue, 23 Apr 2019 11:50:36 -0700 Subject: [PATCH 13/14] allow rocket builds | asm tests pass --- build.sbt | 12 ++++++++---- src/main/scala/example/Simulator.scala | 1 + variables.mk | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/build.sbt b/build.sbt index 633ff032..55a28adf 100644 --- a/build.sbt +++ b/build.sbt @@ -24,10 +24,14 @@ lazy val rebarFirrtl = (project in file("tools/firrtl")) lazy val rocketchip = RootProject(file("generators/rocket-chip")) -lazy val testchipip = (project in file("generators/testchipip")) +lazy val rebarrocketchip = project .dependsOn(rocketchip) .settings(commonSettings) +lazy val testchipip = (project in file("generators/testchipip")) + .dependsOn(rebarrocketchip) + .settings(commonSettings) + // Checks for -DROCKET_USE_MAVEN. // If it's there, use a maven dependency. // Else, depend on subprojects in git submodules. @@ -46,7 +50,7 @@ lazy val example = conditionalDependsOn(project in file(".")) .settings(commonSettings) lazy val boom = (project in file("generators/boom")) - .dependsOn(rocketchip) + .dependsOn(rebarrocketchip) .settings(commonSettings) lazy val tapeout = conditionalDependsOn(project in file("./tools/barstools/tapeout/")) @@ -57,10 +61,10 @@ lazy val mdf = (project in file("./tools/barstools/mdf/scalalib/")) .settings(commonSettings) lazy val `barstools-macros` = (project in file("./tools/barstools/macros/")) - .dependsOn(mdf, rocketchip, rebarFirrtl) + .dependsOn(mdf, rebarrocketchip, rebarFirrtl) .enablePlugins(sbtassembly.AssemblyPlugin) .settings(commonSettings) lazy val sifive_blocks = (project in file("generators/sifive-blocks")) - .dependsOn(rocketchip) + .dependsOn(rebarrocketchip) .settings(commonSettings) diff --git a/src/main/scala/example/Simulator.scala b/src/main/scala/example/Simulator.scala index 09c2cd77..98d69c8a 100644 --- a/src/main/scala/example/Simulator.scala +++ b/src/main/scala/example/Simulator.scala @@ -102,6 +102,7 @@ object GenerateSimFiles extends App with HasGenerateSimConfig { firrtl.FileUtils.makeDirectory("./bootrom/") writeResource("/testchipip/bootrom/bootrom.rv64.img", "./bootrom/") writeResource("/testchipip/bootrom/bootrom.rv32.img", "./bootrom/") + writeResource("/project-template/bootrom/bootrom.img", "./bootrom/") } def writeFiles(cfg: GenerateSimConfig): Unit = { diff --git a/variables.mk b/variables.mk index 34d829fe..9b52c45c 100644 --- a/variables.mk +++ b/variables.mk @@ -42,6 +42,15 @@ ifeq ($(SUB_PROJECT),boom) SBT_PROJECT=boom TOP=ExampleBoomSystem endif +ifeq ($(SUB_PROJECT),rocketchip) + # for Rocket-chip developers + PROJECT=freechips.rocketchip.system + MODEL=TestHarness + CONFIG=DefaultConfig + CFG_PROJECT=freechips.rocketchip.system + SBT_PROJECT=rebarrocketchip + TOP=ExampleRocketSystem +endif ######################################################################################### # path to rocket-chip and testchipip @@ -55,6 +64,11 @@ REBAR_FIRRTL_DIR = $(base_dir)/tools/firrtl ######################################################################################### long_name = $(PROJECT).$(MODEL).$(CONFIG) +# if building from rocketchip, override the long_name to match what they expect +ifeq ($(SBT_PROJECT),rebarrocketchip) + long_name=$(PROJECT).$(CONFIG) +endif + FIRRTL_FILE ?= $(build_dir)/$(long_name).fir ANNO_FILE ?= $(build_dir)/$(long_name).anno.json VERILOG_FILE ?= $(build_dir)/$(long_name).top.v From 978832df9346ae4252211b7f2512a22dd0a09018 Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Tue, 23 Apr 2019 11:53:18 -0700 Subject: [PATCH 14/14] added bootrom symlink to support rocket --- src/main/resources/project-template/bootrom | 1 + 1 file changed, 1 insertion(+) create mode 120000 src/main/resources/project-template/bootrom diff --git a/src/main/resources/project-template/bootrom b/src/main/resources/project-template/bootrom new file mode 120000 index 00000000..a77fb516 --- /dev/null +++ b/src/main/resources/project-template/bootrom @@ -0,0 +1 @@ +../../../../generators/rocket-chip/bootrom/ \ No newline at end of file