From 668047e3fdad7f6c0ca6dabf2e12014e40bb77b2 Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Sun, 21 Apr 2019 15:19:15 -0700 Subject: [PATCH] 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