package example import chisel3._ import freechips.rocketchip.config.{Parameters, Config} import freechips.rocketchip.subsystem.{WithRoccExample, WithNMemoryChannels, WithNBigCores, WithRV32} import freechips.rocketchip.devices.tilelink.BootROMParams import freechips.rocketchip.diplomacy.{LazyModule, ValName} import freechips.rocketchip.tile.XLen import testchipip._ import icenet._ object ConfigValName { implicit val valName = ValName("TestHarness") } import ConfigValName._ class WithBootROM extends Config((site, here, up) => { case BootROMParams => BootROMParams( contentFileName = s"./testchipip/bootrom/bootrom.rv${site(XLen)}.img") }) class WithExampleTop extends Config((site, here, up) => { case BuildTop => (clock: Clock, reset: Bool, p: Parameters) => { Module(LazyModule(new ExampleTop()(p)).module) } }) class WithPWM extends Config((site, here, up) => { case BuildTop => (clock: Clock, reset: Bool, p: Parameters) => Module(LazyModule(new ExampleTopWithPWM()(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) 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) top.connectSimBlockDevice(clock, reset) top } }) class WithLoopbackNIC extends Config((site, here, up) => { case NICKey => NICConfig(inBufFlits = 1800, usePauser = true) case BuildTop => (clock: Clock, reset: Bool, p: Parameters) => { val top = Module(LazyModule(new ExampleTopWithIceNIC()(p)).module) top.connectNicLoopback() top } }) class WithSimNetwork extends Config((site, here, up) => { case NICKey => NICConfig(inBufFlits = 1800) case BuildTop => (clock: Clock, reset: Bool, p: Parameters) => { val top = Module(LazyModule(new ExampleTopWithIceNIC()(p)).module) top.connectSimNetwork(clock, reset) top } }) class BaseExampleConfig extends Config( new WithBootROM ++ new freechips.rocketchip.system.DefaultConfig) class DefaultExampleConfig extends Config( new WithExampleTop ++ new BaseExampleConfig) class RoccExampleConfig extends Config( new WithRoccExample ++ new DefaultExampleConfig) class PWMConfig extends Config(new WithPWM ++ new BaseExampleConfig) class SimBlockDeviceConfig extends Config( new WithBlockDevice ++ new WithSimBlockDevice ++ new BaseExampleConfig) class BlockDeviceModelConfig extends Config( new WithBlockDevice ++ new WithBlockDeviceModel ++ new BaseExampleConfig) class LoopbackNICConfig extends Config( new WithLoopbackNIC ++ new BaseExampleConfig) class SimNetworkConfig extends Config( new WithSimNetwork ++ new BaseExampleConfig) class WithTwoTrackers extends WithNBlockDeviceTrackers(2) class WithFourTrackers extends WithNBlockDeviceTrackers(4) class WithTwoMemChannels extends WithNMemoryChannels(2) class WithFourMemChannels extends WithNMemoryChannels(4) class DualCoreConfig extends Config( // Core gets tacked onto existing list new WithNBigCores(1) ++ new DefaultExampleConfig) class RV32ExampleConfig extends Config( new WithRV32 ++ new DefaultExampleConfig)