Revamp the config system for Top/Harness (#347)
* Refactor how Configs parameterize the Top and TestHarnesses * Bump sha3, testchipip, icenet, firesim
This commit is contained in:
@@ -10,7 +10,8 @@ module GCDMMIOBlackBox
|
||||
input [WIDTH-1:0] y,
|
||||
input output_ready,
|
||||
output output_valid,
|
||||
output reg [WIDTH-1:0] gcd
|
||||
output reg [WIDTH-1:0] gcd,
|
||||
output busy
|
||||
);
|
||||
// DOC include end: GCD portlist
|
||||
|
||||
@@ -21,6 +22,7 @@ module GCDMMIOBlackBox
|
||||
|
||||
assign input_ready = state == S_IDLE;
|
||||
assign output_valid = state == S_DONE;
|
||||
assign busy = state != S_IDLE;
|
||||
|
||||
always @(posedge clock) begin
|
||||
if (reset)
|
||||
|
||||
@@ -9,54 +9,72 @@ import freechips.rocketchip.config.{Config}
|
||||
// ---------------------
|
||||
|
||||
class SmallBoomConfig extends Config(
|
||||
new WithTop ++ // use normal top
|
||||
new WithTSI ++ // use testchipip serial offchip link
|
||||
new WithNoGPIO ++ // no top-level GPIO pins (overrides default set in sifive-blocks)
|
||||
new WithBootROM ++ // use testchipip bootrom
|
||||
new WithUART ++ // add a UART
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++ // no top-level mmio master port (overrides default set in rocketchip)
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++ // no top-level mmio slave port (overrides default set in rocketchip)
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++ // use SiFive L2 cache
|
||||
new boom.common.WithSmallBooms ++ // 1-wide BOOM
|
||||
new boom.common.WithNBoomCores(1) ++ // single-core
|
||||
new freechips.rocketchip.system.BaseConfig) // "base" rocketchip system
|
||||
|
||||
class MediumBoomConfig extends Config(
|
||||
new WithTop ++
|
||||
new WithTSI ++
|
||||
new WithNoGPIO ++
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new boom.common.WithMediumBooms ++ // 2-wide BOOM
|
||||
new boom.common.WithNBoomCores(1) ++
|
||||
new freechips.rocketchip.system.BaseConfig)
|
||||
|
||||
class LargeBoomConfig extends Config(
|
||||
new WithTop ++
|
||||
new WithTSI ++
|
||||
new WithNoGPIO ++
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new boom.common.WithLargeBooms ++ // 3-wide BOOM
|
||||
new boom.common.WithNBoomCores(1) ++
|
||||
new freechips.rocketchip.system.BaseConfig)
|
||||
|
||||
class MegaBoomConfig extends Config(
|
||||
new WithTop ++
|
||||
new WithTSI ++
|
||||
new WithNoGPIO ++
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new boom.common.WithMegaBooms ++ // 4-wide BOOM
|
||||
new boom.common.WithNBoomCores(1) ++
|
||||
new freechips.rocketchip.system.BaseConfig)
|
||||
|
||||
class DualSmallBoomConfig extends Config(
|
||||
new WithTop ++
|
||||
new WithTSI ++
|
||||
new WithNoGPIO ++
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new boom.common.WithSmallBooms ++
|
||||
new boom.common.WithNBoomCores(2) ++ // dual-core
|
||||
new freechips.rocketchip.system.BaseConfig)
|
||||
|
||||
class SmallRV32BoomConfig extends Config(
|
||||
new WithTop ++
|
||||
new WithTSI ++
|
||||
new WithNoGPIO ++
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new boom.common.WithoutBoomFPU ++ // no fp
|
||||
new boom.common.WithBoomRV32 ++ // rv32 (32bit)
|
||||
@@ -65,9 +83,12 @@ class SmallRV32BoomConfig extends Config(
|
||||
new freechips.rocketchip.system.BaseConfig)
|
||||
|
||||
class HwachaLargeBoomConfig extends Config(
|
||||
new WithTop ++
|
||||
new WithTSI ++
|
||||
new WithNoGPIO ++
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new hwacha.DefaultHwachaConfig ++ // use Hwacha vector accelerator
|
||||
new boom.common.WithLargeBooms ++ // 3-wide BOOM
|
||||
@@ -75,11 +96,16 @@ class HwachaLargeBoomConfig extends Config(
|
||||
new freechips.rocketchip.system.BaseConfig)
|
||||
|
||||
class LoopbackNICBoomConfig extends Config(
|
||||
new WithIceNIC ++
|
||||
new WithLoopbackNICTop ++
|
||||
new WithTSI ++
|
||||
new WithNoGPIO ++
|
||||
new WithLoopbackNIC ++ // loopback the NIC
|
||||
new WithIceNIC ++ // add IceNIC
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new boom.common.WithLargeBooms ++ // 3-wide BOOM
|
||||
new boom.common.WithLargeBooms ++
|
||||
new boom.common.WithNBoomCores(1) ++
|
||||
new freechips.rocketchip.system.BaseConfig)
|
||||
|
||||
|
||||
@@ -7,8 +7,10 @@ import freechips.rocketchip.config.{Field, Parameters, Config}
|
||||
import freechips.rocketchip.subsystem.{SystemBusKey, RocketTilesKey, WithRoccExample, WithNMemoryChannels, WithNBigCores, WithRV32, CacheBlockBytes}
|
||||
import freechips.rocketchip.diplomacy.{LazyModule, ValName}
|
||||
import freechips.rocketchip.devices.tilelink.BootROMParams
|
||||
import freechips.rocketchip.tile.{RocketTileParams, MaxHartIdBits, XLen, BuildRoCC, TileKey, LazyRoCC}
|
||||
import freechips.rocketchip.devices.debug.{Debug}
|
||||
import freechips.rocketchip.tile.{XLen, BuildRoCC, TileKey, LazyRoCC, RocketTileParams, MaxHartIdBits}
|
||||
import freechips.rocketchip.rocket.{RocketCoreParams, MulDivParams, DCacheParams, ICacheParams}
|
||||
import freechips.rocketchip.util.{AsyncResetReg}
|
||||
|
||||
import boom.common.{BoomTilesKey}
|
||||
|
||||
@@ -33,23 +35,30 @@ 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")
|
||||
})
|
||||
|
||||
// DOC include start: WithGPIO
|
||||
/**
|
||||
* Class to add in GPIO
|
||||
*/
|
||||
// DOC include start: gpio mixin
|
||||
class WithGPIO extends Config((site, here, up) => {
|
||||
case PeripheryGPIOKey => Seq(
|
||||
GPIOParams(address = 0x10012000, width = 4, includeIOF = false))
|
||||
case BuildTop => (clock: Clock, reset: Bool, p: Parameters, success: Bool) => {
|
||||
val top = up(BuildTop, site)(clock, reset, p, success)
|
||||
// TODO: Currently FIRRTL will error if the GPIO input
|
||||
// pins are unconnected, so tie them to 0.
|
||||
// In future IO cell blackboxes will replace this with
|
||||
// more correct functionality
|
||||
for (gpio <- top.gpio) {
|
||||
for (pin <- gpio.pins) {
|
||||
pin.i.ival := false.B
|
||||
}
|
||||
}
|
||||
top
|
||||
}
|
||||
})
|
||||
// DOC include end: WithGPIO
|
||||
// DOC include end: gpio mixin
|
||||
|
||||
/**
|
||||
* Class to add in UART
|
||||
@@ -59,92 +68,58 @@ class WithUART extends Config((site, here, up) => {
|
||||
UARTParams(address = 0x54000000L, nTxEntries = 256, nRxEntries = 256))
|
||||
})
|
||||
|
||||
// -----------------------------------------------
|
||||
// BOOM and/or Rocket Top Level System Parameter Mixins
|
||||
// -----------------------------------------------
|
||||
|
||||
/**
|
||||
* Class to specify a "plain" top level BOOM and/or Rocket system
|
||||
*/
|
||||
class WithTop extends Config((site, here, up) => {
|
||||
case BuildTop => (clock: Clock, reset: Bool, p: Parameters) => {
|
||||
Module(LazyModule(new Top()(p)).module)
|
||||
class WithNoGPIO extends Config((site, here, up) => {
|
||||
case PeripheryGPIOKey => Seq()
|
||||
})
|
||||
|
||||
// DOC include start: tsi mixin
|
||||
class WithTSI extends Config((site, here, up) => {
|
||||
case SerialKey => true
|
||||
case BuildTop => (clock: Clock, reset: Bool, p: Parameters, success: Bool) => {
|
||||
val top = up(BuildTop, site)(clock, reset, p, success)
|
||||
success := top.connectSimSerial()
|
||||
top
|
||||
}
|
||||
})
|
||||
// DOC include end: tsi mixin
|
||||
|
||||
class WithDTM extends Config((site, here, up) => {
|
||||
case BuildTop => (clock: Clock, reset: Bool, p: Parameters, success: Bool) => {
|
||||
val top = up(BuildTop, site)(clock, reset, p, success)
|
||||
top.reset := reset.asBool | top.debug.map { debug => AsyncResetReg(debug.ndreset) }.getOrElse(false.B)
|
||||
Debug.connectDebug(top.debug, top.psd, clock, reset.asBool, success)(p)
|
||||
top
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* Class to specify a top level BOOM and/or Rocket system with DTM
|
||||
*/
|
||||
class WithDTMTop extends Config((site, here, up) => {
|
||||
case BuildTopWithDTM => (clock: Clock, reset: Bool, p: Parameters) => {
|
||||
Module(LazyModule(new TopWithDTM()(p)).module)
|
||||
}
|
||||
// DOC include start: GCD mixin
|
||||
class WithGCD(useAXI4: Boolean, useBlackBox: Boolean) extends Config((site, here, up) => {
|
||||
case GCDKey => Some(GCDParams(useAXI4 = useAXI4, useBlackBox = useBlackBox))
|
||||
})
|
||||
// DOC include end: GCD mixin
|
||||
|
||||
/**
|
||||
* Class to specify a top level BOOM and/or Rocket system with PWM
|
||||
*/
|
||||
// DOC include start: WithPWMTop
|
||||
class WithPWMTop extends Config((site, here, up) => {
|
||||
case BuildTop => (clock: Clock, reset: Bool, p: Parameters) =>
|
||||
Module(LazyModule(new TopWithPWMTL()(p)).module)
|
||||
})
|
||||
// DOC include end: WithPWMTop
|
||||
|
||||
/**
|
||||
* Class to specify a top level BOOM and/or Rocket system with a PWM AXI4
|
||||
*/
|
||||
class WithPWMAXI4Top extends Config((site, here, up) => {
|
||||
case BuildTop => (clock: Clock, reset: Bool, p: Parameters) =>
|
||||
Module(LazyModule(new TopWithPWMAXI4()(p)).module)
|
||||
})
|
||||
|
||||
/**
|
||||
* Class to specify a top level BOOM and/or Rocket system with a TL-attached GCD device
|
||||
*/
|
||||
class WithGCDTop extends Config((site, here, up) => {
|
||||
case BuildTop => (clock: Clock, reset: Bool, p: Parameters) =>
|
||||
Module(LazyModule(new TopWithGCD()(p)).module)
|
||||
})
|
||||
|
||||
/**
|
||||
* Class to specify a top level BOOM and/or Rocket system with a block device
|
||||
*/
|
||||
class WithBlockDeviceModelTop extends Config((site, here, up) => {
|
||||
case BuildTop => (clock: Clock, reset: Bool, p: Parameters) => {
|
||||
val top = Module(LazyModule(new TopWithBlockDevice()(p)).module)
|
||||
class WithBlockDeviceModel extends Config((site, here, up) => {
|
||||
case BuildTop => (clock: Clock, reset: Bool, p: Parameters, success: Bool) => {
|
||||
val top = up(BuildTop, site)(clock, reset, p, success)
|
||||
top.connectBlockDeviceModel()
|
||||
top
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* Class to specify a top level BOOM and/or Rocket system with a simulator block device
|
||||
*/
|
||||
class WithSimBlockDeviceTop extends Config((site, here, up) => {
|
||||
case BuildTop => (clock: Clock, reset: Bool, p: Parameters) => {
|
||||
val top = Module(LazyModule(new TopWithBlockDevice()(p)).module)
|
||||
class WithSimBlockDevice extends Config((site, here, up) => {
|
||||
case BuildTop => (clock: Clock, reset: Bool, p: Parameters, success: Bool) => {
|
||||
val top = up(BuildTop, site)(clock, reset, p, success)
|
||||
top.connectSimBlockDevice(clock, reset)
|
||||
top
|
||||
}
|
||||
})
|
||||
|
||||
// DOC include start: WithGPIOTop
|
||||
/**
|
||||
* Class to specify a top level BOOM and/or Rocket system with GPIO
|
||||
*/
|
||||
class WithGPIOTop extends Config((site, here, up) => {
|
||||
case BuildTop => (clock: Clock, reset: Bool, p: Parameters) => {
|
||||
val top = Module(LazyModule(new TopWithGPIO()(p)).module)
|
||||
for (gpio <- top.gpio) {
|
||||
for (pin <- gpio.pins) {
|
||||
pin.i.ival := false.B
|
||||
}
|
||||
}
|
||||
top
|
||||
}
|
||||
// DOC include start: WithInitZero
|
||||
class WithInitZero(base: BigInt, size: BigInt) extends Config((site, here, up) => {
|
||||
case InitZeroKey => Some(InitZeroConfig(base, size))
|
||||
})
|
||||
// DOC include end: WithGPIOTop
|
||||
// DOC include end: WithInitZero
|
||||
|
||||
// ------------------
|
||||
// Multi-RoCC Support
|
||||
@@ -184,16 +159,6 @@ class WithMultiRoCCHwacha(harts: Int*) extends Config((site, here, up) => {
|
||||
}
|
||||
})
|
||||
|
||||
// DOC include start: WithInitZero
|
||||
class WithInitZero(base: BigInt, size: BigInt) extends Config((site, here, up) => {
|
||||
case InitZeroKey => InitZeroConfig(base, size)
|
||||
})
|
||||
|
||||
class WithInitZeroTop extends Config((site, here, up) => {
|
||||
case BuildTop => (clock: Clock, reset: Bool, p: Parameters) =>
|
||||
Module(LazyModule(new TopWithInitZero()(p)).module)
|
||||
})
|
||||
// DOC include end: WithInitZero
|
||||
|
||||
/**
|
||||
* Mixin to add a small Rocket core to the system as a "control" core.
|
||||
@@ -227,15 +192,15 @@ class WithControlCore extends Config((site, here, up) => {
|
||||
|
||||
class WithIceNIC(inBufFlits: Int = 1800, usePauser: Boolean = false)
|
||||
extends Config((site, here, up) => {
|
||||
case NICKey => NICConfig(
|
||||
case NICKey => Some(NICConfig(
|
||||
inBufFlits = inBufFlits,
|
||||
usePauser = usePauser,
|
||||
checksumOffload = true)
|
||||
checksumOffload = true))
|
||||
})
|
||||
|
||||
class WithLoopbackNICTop extends Config((site, here, up) => {
|
||||
case BuildTop => (clock: Clock, reset: Bool, p: Parameters) => {
|
||||
val top = Module(LazyModule(new TopWithIceNIC()(p)).module)
|
||||
class WithLoopbackNIC extends Config((site, here, up) => {
|
||||
case BuildTop => (clock: Clock, reset: Bool, p: Parameters, success: Bool) => {
|
||||
val top = up(BuildTop, site)(clock, reset, p, success)
|
||||
top.connectNicLoopback()
|
||||
top
|
||||
}
|
||||
|
||||
200
generators/example/src/main/scala/GCD.scala
Normal file
200
generators/example/src/main/scala/GCD.scala
Normal file
@@ -0,0 +1,200 @@
|
||||
package example
|
||||
|
||||
import chisel3._
|
||||
import chisel3.util._
|
||||
import chisel3.experimental.{IntParam, BaseModule}
|
||||
import freechips.rocketchip.amba.axi4._
|
||||
import freechips.rocketchip.subsystem.BaseSubsystem
|
||||
import freechips.rocketchip.config.{Parameters, Field}
|
||||
import freechips.rocketchip.diplomacy._
|
||||
import freechips.rocketchip.regmapper.{HasRegMap, RegField}
|
||||
import freechips.rocketchip.tilelink._
|
||||
import freechips.rocketchip.util.UIntIsOneOf
|
||||
|
||||
// DOC include start: GCD params
|
||||
case class GCDParams(
|
||||
address: BigInt = 0x2000,
|
||||
width: Int = 32,
|
||||
useAXI4: Boolean = false,
|
||||
useBlackBox: Boolean = true)
|
||||
// DOC include end: GCD params
|
||||
|
||||
// DOC include start: GCD key
|
||||
case object GCDKey extends Field[Option[GCDParams]](None)
|
||||
// DOC include end: GCD key
|
||||
|
||||
class GCDIO(val w: Int) extends Bundle {
|
||||
val clock = Input(Clock())
|
||||
val reset = Input(Bool())
|
||||
val input_ready = Output(Bool())
|
||||
val input_valid = Input(Bool())
|
||||
val x = Input(UInt(w.W))
|
||||
val y = Input(UInt(w.W))
|
||||
val output_ready = Input(Bool())
|
||||
val output_valid = Output(Bool())
|
||||
val gcd = Output(UInt(w.W))
|
||||
val busy = Output(Bool())
|
||||
}
|
||||
|
||||
trait GCDTopIO extends Bundle {
|
||||
val gcd_busy = Output(Bool())
|
||||
}
|
||||
|
||||
trait HasGCDIO extends BaseModule {
|
||||
val w: Int
|
||||
val io = IO(new GCDIO(w))
|
||||
}
|
||||
|
||||
// DOC include start: GCD blackbox
|
||||
class GCDMMIOBlackBox(val w: Int) extends BlackBox(Map("WIDTH" -> IntParam(w))) with HasBlackBoxResource
|
||||
with HasGCDIO
|
||||
{
|
||||
addResource("/vsrc/GCDMMIOBlackBox.v")
|
||||
}
|
||||
// DOC include end: GCD blackbox
|
||||
|
||||
// DOC include start: GCD chisel
|
||||
class GCDMMIOChiselModule(val w: Int) extends Module
|
||||
with HasGCDIO
|
||||
{
|
||||
val s_idle :: s_run :: s_done :: Nil = Enum(3)
|
||||
|
||||
val state = RegInit(s_idle)
|
||||
val tmp = Reg(UInt(w.W))
|
||||
val gcd = Reg(UInt(w.W))
|
||||
|
||||
io.input_ready := state === s_idle
|
||||
io.output_valid := state === s_done
|
||||
io.gcd := gcd
|
||||
|
||||
when (state === s_idle && io.input_valid) {
|
||||
state := s_run
|
||||
} .elsewhen (state === s_run && tmp === 0.U) {
|
||||
state := s_done
|
||||
} .elsewhen (state === s_done && io.output_ready) {
|
||||
state := s_idle
|
||||
}
|
||||
|
||||
when (state === s_idle && io.input_valid) {
|
||||
gcd := io.x
|
||||
tmp := io.y
|
||||
} .elsewhen (state === s_run) {
|
||||
when (gcd > tmp) {
|
||||
gcd := gcd - tmp
|
||||
} .otherwise {
|
||||
tmp := tmp - gcd
|
||||
}
|
||||
}
|
||||
|
||||
io.busy := state =/= s_idle
|
||||
}
|
||||
// DOC include end: GCD chisel
|
||||
|
||||
// DOC include start: GCD instance regmap
|
||||
|
||||
trait GCDModule extends HasRegMap {
|
||||
val io: GCDTopIO
|
||||
|
||||
implicit val p: Parameters
|
||||
def params: GCDParams
|
||||
val clock: Clock
|
||||
val reset: Reset
|
||||
|
||||
|
||||
// How many clock cycles in a PWM cycle?
|
||||
val x = Reg(UInt(params.width.W))
|
||||
val y = Wire(new DecoupledIO(UInt(params.width.W)))
|
||||
val gcd = Wire(new DecoupledIO(UInt(params.width.W)))
|
||||
val status = Wire(UInt(2.W))
|
||||
|
||||
val impl = if (params.useBlackBox) {
|
||||
Module(new GCDMMIOBlackBox(params.width))
|
||||
} else {
|
||||
Module(new GCDMMIOChiselModule(params.width))
|
||||
}
|
||||
|
||||
impl.io.clock := clock
|
||||
impl.io.reset := reset.asBool
|
||||
|
||||
impl.io.x := x
|
||||
impl.io.y := y.bits
|
||||
impl.io.input_valid := y.valid
|
||||
y.ready := impl.io.input_ready
|
||||
|
||||
gcd.bits := impl.io.gcd
|
||||
gcd.valid := impl.io.output_valid
|
||||
impl.io.output_ready := gcd.ready
|
||||
|
||||
status := Cat(impl.io.input_ready, impl.io.output_ready)
|
||||
io.gcd_busy := impl.io.busy
|
||||
|
||||
regmap(
|
||||
0x00 -> Seq(
|
||||
RegField.r(2, status)), // a read-only register capturing current status
|
||||
0x04 -> Seq(
|
||||
RegField.w(params.width, x)), // a plain, write-only register
|
||||
0x08 -> Seq(
|
||||
RegField.w(params.width, y)), // write-only, y.valid is set on write
|
||||
0x0C -> Seq(
|
||||
RegField.r(params.width, gcd))) // read-only, gcd.ready is set on read
|
||||
}
|
||||
// DOC include end: GCD instance regmap
|
||||
|
||||
// DOC include start: GCD router
|
||||
class GCDTL(params: GCDParams, beatBytes: Int)(implicit p: Parameters)
|
||||
extends TLRegisterRouter(
|
||||
params.address, "gcd", Seq("ucbbar,gcd"),
|
||||
beatBytes = beatBytes)(
|
||||
new TLRegBundle(params, _) with GCDTopIO)(
|
||||
new TLRegModule(params, _, _) with GCDModule)
|
||||
|
||||
class GCDAXI4(params: GCDParams, beatBytes: Int)(implicit p: Parameters)
|
||||
extends AXI4RegisterRouter(
|
||||
params.address,
|
||||
beatBytes=beatBytes)(
|
||||
new AXI4RegBundle(params, _) with GCDTopIO)(
|
||||
new AXI4RegModule(params, _, _) with GCDModule)
|
||||
// DOC include end: GCD router
|
||||
|
||||
// DOC include start: GCD lazy trait
|
||||
trait CanHavePeripheryGCD { this: BaseSubsystem =>
|
||||
private val portName = "gcd"
|
||||
|
||||
// Only build if we are using the TL (nonAXI4) version
|
||||
val gcd = p(GCDKey) match {
|
||||
case Some(params) => {
|
||||
if (params.useAXI4) {
|
||||
val gcd = LazyModule(new GCDAXI4(params, pbus.beatBytes)(p))
|
||||
pbus.toSlave(Some(portName)) {
|
||||
gcd.node :=
|
||||
AXI4Buffer () :=
|
||||
TLToAXI4 () :=
|
||||
// toVariableWidthSlave doesn't use holdFirstDeny, which TLToAXI4() needsx
|
||||
TLFragmenter(pbus.beatBytes, pbus.blockBytes, holdFirstDeny = true)
|
||||
}
|
||||
Some(gcd)
|
||||
} else {
|
||||
val gcd = LazyModule(new GCDTL(params, pbus.beatBytes)(p))
|
||||
pbus.toVariableWidthSlave(Some(portName)) { gcd.node }
|
||||
Some(gcd)
|
||||
}
|
||||
}
|
||||
case None => None
|
||||
}
|
||||
}
|
||||
// DOC include end: GCD lazy trait
|
||||
|
||||
// DOC include start: GCD imp trait
|
||||
trait CanHavePeripheryGCDModuleImp extends LazyModuleImp {
|
||||
val outer: CanHavePeripheryGCD
|
||||
val gcd_busy = outer.gcd match {
|
||||
case Some(gcd) => {
|
||||
val busy = IO(Output(Bool()))
|
||||
busy := gcd.module.io.gcd_busy
|
||||
Some(busy)
|
||||
}
|
||||
case None => None
|
||||
}
|
||||
}
|
||||
|
||||
// DOC include end: GCD imp trait
|
||||
@@ -1,98 +0,0 @@
|
||||
package example
|
||||
|
||||
import chisel3._
|
||||
import chisel3.util._
|
||||
import chisel3.core.{IntParam, Reset}
|
||||
import freechips.rocketchip.amba.axi4._
|
||||
import freechips.rocketchip.subsystem.BaseSubsystem
|
||||
import freechips.rocketchip.config.{Parameters, Field}
|
||||
import freechips.rocketchip.diplomacy._
|
||||
import freechips.rocketchip.regmapper.{HasRegMap, RegField}
|
||||
import freechips.rocketchip.tilelink._
|
||||
import freechips.rocketchip.util.UIntIsOneOf
|
||||
|
||||
// DOC include start: GCD blackbox
|
||||
class GCDMMIOBlackBox(w: Int) extends BlackBox(Map("WIDTH" -> IntParam(w))) with HasBlackBoxResource {
|
||||
val io = IO(new Bundle {
|
||||
val clock = Input(Clock())
|
||||
val reset = Input(Bool())
|
||||
val input_ready = Output(Bool())
|
||||
val input_valid = Input(Bool())
|
||||
val x = Input(UInt(w.W))
|
||||
val y = Input(UInt(w.W))
|
||||
val output_ready = Input(Bool())
|
||||
val output_valid = Output(Bool())
|
||||
val gcd = Output(UInt(w.W))
|
||||
})
|
||||
|
||||
addResource("/vsrc/GCDMMIOBlackBox.v")
|
||||
}
|
||||
// DOC include end: GCD blackbox
|
||||
|
||||
// DOC include start: GCD instance regmap
|
||||
case class GCDParams(address: BigInt, beatBytes: Int, width: Int)
|
||||
|
||||
trait GCDModule extends HasRegMap {
|
||||
implicit val p: Parameters
|
||||
def params: GCDParams
|
||||
val clock: Clock
|
||||
val reset: Reset
|
||||
|
||||
val impl = Module(new GCDMMIOBlackBox(params.width))
|
||||
|
||||
// How many clock cycles in a PWM cycle?
|
||||
val x = Reg(UInt(params.width.W))
|
||||
val y = Wire(new DecoupledIO(impl.io.y))
|
||||
val gcd = Wire(new DecoupledIO(impl.io.gcd))
|
||||
val status = Cat(impl.io.input_ready, impl.io.output_valid)
|
||||
|
||||
impl.io.clock := clock
|
||||
impl.io.reset := reset.asBool
|
||||
impl.io.x := x
|
||||
impl.io.y := y.bits
|
||||
impl.io.input_valid := y.valid
|
||||
y.ready := impl.io.input_ready
|
||||
|
||||
gcd.bits := impl.io.gcd
|
||||
gcd.valid := impl.io.output_valid
|
||||
impl.io.output_ready := gcd.ready
|
||||
|
||||
regmap(
|
||||
0x00 -> Seq(
|
||||
RegField.r(2, status)), // a read-only register capturing current status
|
||||
0x04 -> Seq(
|
||||
RegField.w(params.width, x)), // a plain, write-only register
|
||||
0x08 -> Seq(
|
||||
RegField.w(params.width, y)), // write-only, y.valid is set on write
|
||||
0x0C -> Seq(
|
||||
RegField.r(params.width, gcd))) // read-only, gcd.ready is set on read
|
||||
}
|
||||
// DOC include end: GCD instance regmap
|
||||
|
||||
// DOC include start: GCD cake
|
||||
class GCD(c: GCDParams)(implicit p: Parameters)
|
||||
extends TLRegisterRouter(
|
||||
c.address, "gcd", Seq("ucbbar,gcd"),
|
||||
beatBytes = c.beatBytes)(
|
||||
new TLRegBundle(c, _))(
|
||||
new TLRegModule(c, _, _) with GCDModule)
|
||||
|
||||
trait HasPeripheryGCD { this: BaseSubsystem =>
|
||||
implicit val p: Parameters
|
||||
|
||||
private val address = 0x2000
|
||||
private val portName = "gcd"
|
||||
private val gcdWidth = 32
|
||||
|
||||
val gcd = LazyModule(new GCD(
|
||||
GCDParams(address, pbus.beatBytes, gcdWidth))(p))
|
||||
|
||||
pbus.toVariableWidthSlave(Some(portName)) { gcd.node }
|
||||
}
|
||||
|
||||
trait HasPeripheryGCDModuleImp extends LazyModuleImp {
|
||||
implicit val p: Parameters
|
||||
val outer: HasPeripheryGCD
|
||||
}
|
||||
|
||||
// DOC include end: GCD cake
|
||||
@@ -9,10 +9,13 @@ import freechips.rocketchip.config.{Config}
|
||||
// ---------------------
|
||||
|
||||
class LargeBoomAndRocketConfig extends Config(
|
||||
new WithTop ++ // default top
|
||||
new WithTSI ++ // use testchipip serial offchip link
|
||||
new WithNoGPIO ++ // no top-level GPIO pins (overrides default set in sifive-blocks)
|
||||
new WithBootROM ++ // default bootrom
|
||||
new WithUART ++ // add a UART
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++ // use SiFive l2
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++ // no top-level MMIO master port (overrides default set in rocketchip)
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++ // no top-level MMIO slave port (overrides default set in rocketchip)
|
||||
new boom.common.WithRenumberHarts ++ // avoid hartid overlap
|
||||
new boom.common.WithLargeBooms ++ // 3-wide boom
|
||||
new boom.common.WithNBoomCores(1) ++ // single-core boom
|
||||
@@ -20,10 +23,13 @@ class LargeBoomAndRocketConfig extends Config(
|
||||
new freechips.rocketchip.system.BaseConfig) // "base" rocketchip system
|
||||
|
||||
class SmallBoomAndRocketConfig extends Config(
|
||||
new WithTop ++
|
||||
new WithTSI ++
|
||||
new WithNoGPIO ++
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new boom.common.WithRenumberHarts ++
|
||||
new boom.common.WithSmallBooms ++ // 1-wide boom
|
||||
new boom.common.WithNBoomCores(1) ++
|
||||
@@ -32,11 +38,14 @@ class SmallBoomAndRocketConfig extends Config(
|
||||
|
||||
// DOC include start: BoomAndRocketWithHwacha
|
||||
class HwachaLargeBoomAndHwachaRocketConfig extends Config(
|
||||
new WithTop ++
|
||||
new WithTSI ++
|
||||
new WithNoGPIO ++
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new hwacha.DefaultHwachaConfig ++ // add hwacha to all harts
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new boom.common.WithRenumberHarts ++
|
||||
new boom.common.WithLargeBooms ++
|
||||
new boom.common.WithNBoomCores(1) ++
|
||||
@@ -45,10 +54,13 @@ class HwachaLargeBoomAndHwachaRocketConfig extends Config(
|
||||
// DOC include end: BoomAndRocketWithHwacha
|
||||
|
||||
class RoccLargeBoomAndRoccRocketConfig extends Config(
|
||||
new WithTop ++
|
||||
new WithTSI ++
|
||||
new WithNoGPIO ++
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithRoccExample ++ // add example rocc accelerator to all harts
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new boom.common.WithRenumberHarts ++
|
||||
new boom.common.WithLargeBooms ++
|
||||
@@ -57,9 +69,12 @@ class RoccLargeBoomAndRoccRocketConfig extends Config(
|
||||
new freechips.rocketchip.system.BaseConfig)
|
||||
|
||||
class DualLargeBoomAndRocketConfig extends Config(
|
||||
new WithTop ++
|
||||
new WithTSI ++
|
||||
new WithNoGPIO ++
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new boom.common.WithRenumberHarts ++
|
||||
new boom.common.WithLargeBooms ++
|
||||
@@ -69,10 +84,13 @@ class DualLargeBoomAndRocketConfig extends Config(
|
||||
|
||||
// DOC include start: DualBoomAndRocketOneHwacha
|
||||
class DualLargeBoomAndHwachaRocketConfig extends Config(
|
||||
new WithTop ++
|
||||
new WithTSI ++
|
||||
new WithNoGPIO ++
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new WithMultiRoCC ++ // support heterogeneous rocc
|
||||
new WithMultiRoCCHwacha(2) ++ // put hwacha on hart-2 (rocket)
|
||||
new boom.common.WithRenumberHarts ++
|
||||
@@ -83,10 +101,13 @@ class DualLargeBoomAndHwachaRocketConfig extends Config(
|
||||
// DOC include end: DualBoomAndRocketOneHwacha
|
||||
|
||||
class LargeBoomAndRV32RocketConfig extends Config(
|
||||
new WithTop ++
|
||||
new WithTSI ++
|
||||
new WithNoGPIO ++
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new boom.common.WithRenumberHarts ++
|
||||
new boom.common.WithLargeBooms ++
|
||||
new boom.common.WithNBoomCores(1) ++
|
||||
@@ -96,10 +117,13 @@ class LargeBoomAndRV32RocketConfig extends Config(
|
||||
|
||||
// DOC include start: DualBoomAndRocket
|
||||
class DualLargeBoomAndDualRocketConfig extends Config(
|
||||
new WithTop ++
|
||||
new WithTSI ++
|
||||
new WithNoGPIO ++
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new boom.common.WithRenumberHarts ++
|
||||
new boom.common.WithLargeBooms ++
|
||||
new boom.common.WithNBoomCores(2) ++ // 2 boom cores
|
||||
@@ -108,10 +132,13 @@ class DualLargeBoomAndDualRocketConfig extends Config(
|
||||
// DOC include end: DualBoomAndRocket
|
||||
|
||||
class MultiCoreWithControlCoreConfig extends Config(
|
||||
new WithTop ++
|
||||
new WithTSI ++
|
||||
new WithNoGPIO ++
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new WithControlCore ++ // add small control core (last hartid)
|
||||
new boom.common.WithRenumberHarts ++
|
||||
new boom.common.WithLargeBooms ++
|
||||
|
||||
@@ -8,7 +8,7 @@ import freechips.rocketchip.diplomacy.{LazyModule, LazyModuleImp, IdRange}
|
||||
import testchipip.TLHelper
|
||||
|
||||
case class InitZeroConfig(base: BigInt, size: BigInt)
|
||||
case object InitZeroKey extends Field[InitZeroConfig]
|
||||
case object InitZeroKey extends Field[Option[InitZeroConfig]](None)
|
||||
|
||||
class InitZero(implicit p: Parameters) extends LazyModule {
|
||||
val node = TLHelper.makeClientNode(
|
||||
@@ -18,7 +18,7 @@ class InitZero(implicit p: Parameters) extends LazyModule {
|
||||
}
|
||||
|
||||
class InitZeroModuleImp(outer: InitZero) extends LazyModuleImp(outer) {
|
||||
val config = p(InitZeroKey)
|
||||
val config = p(InitZeroKey).get
|
||||
|
||||
val (mem, edge) = outer.node.out(0)
|
||||
val addrBits = edge.bundle.addressBits
|
||||
@@ -57,13 +57,11 @@ class InitZeroModuleImp(outer: InitZero) extends LazyModuleImp(outer) {
|
||||
}
|
||||
}
|
||||
|
||||
trait HasPeripheryInitZero { this: BaseSubsystem =>
|
||||
trait CanHavePeripheryInitZero { this: BaseSubsystem =>
|
||||
implicit val p: Parameters
|
||||
|
||||
val initZero = LazyModule(new InitZero()(p))
|
||||
fbus.fromPort(Some("init-zero"))() := initZero.node
|
||||
}
|
||||
|
||||
trait HasPeripheryInitZeroModuleImp extends LazyModuleImp {
|
||||
// Don't need anything here
|
||||
p(InitZeroKey) .map { k =>
|
||||
val initZero = LazyModule(new InitZero()(p))
|
||||
fbus.fromPort(Some("init-zero"))() := initZero.node
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,134 +0,0 @@
|
||||
package example
|
||||
|
||||
import chisel3._
|
||||
import chisel3.util._
|
||||
import freechips.rocketchip.amba.axi4._
|
||||
import freechips.rocketchip.subsystem.BaseSubsystem
|
||||
import freechips.rocketchip.config.{Parameters, Field}
|
||||
import freechips.rocketchip.diplomacy._
|
||||
import freechips.rocketchip.regmapper.{HasRegMap, RegField}
|
||||
import freechips.rocketchip.tilelink._
|
||||
import freechips.rocketchip.util.UIntIsOneOf
|
||||
|
||||
// DOC include start: PWM generic traits
|
||||
case class PWMParams(address: BigInt, beatBytes: Int)
|
||||
|
||||
class PWMBase(w: Int) extends Module {
|
||||
val io = IO(new Bundle {
|
||||
val pwmout = Output(Bool())
|
||||
val period = Input(UInt(w.W))
|
||||
val duty = Input(UInt(w.W))
|
||||
val enable = Input(Bool())
|
||||
})
|
||||
|
||||
// The counter should count up until period is reached
|
||||
val counter = Reg(UInt(w.W))
|
||||
|
||||
when (counter >= (io.period - 1.U)) {
|
||||
counter := 0.U
|
||||
} .otherwise {
|
||||
counter := counter + 1.U
|
||||
}
|
||||
|
||||
// If PWM is enabled, pwmout is high when counter < duty
|
||||
// If PWM is not enabled, it will always be low
|
||||
io.pwmout := io.enable && (counter < io.duty)
|
||||
}
|
||||
|
||||
trait PWMBundle extends Bundle {
|
||||
val pwmout = Output(Bool())
|
||||
}
|
||||
|
||||
trait PWMModule extends HasRegMap {
|
||||
val io: PWMBundle
|
||||
implicit val p: Parameters
|
||||
def params: PWMParams
|
||||
|
||||
// How many clock cycles in a PWM cycle?
|
||||
val period = Reg(UInt(32.W))
|
||||
// For how many cycles should the clock be high?
|
||||
val duty = Reg(UInt(32.W))
|
||||
// Is the PWM even running at all?
|
||||
val enable = RegInit(false.B)
|
||||
|
||||
val base = Module(new PWMBase(32))
|
||||
io.pwmout := base.io.pwmout
|
||||
base.io.period := period
|
||||
base.io.duty := duty
|
||||
base.io.enable := enable
|
||||
|
||||
regmap(
|
||||
0x00 -> Seq(
|
||||
RegField(32, period)),
|
||||
0x04 -> Seq(
|
||||
RegField(32, duty)),
|
||||
0x08 -> Seq(
|
||||
RegField(1, enable)))
|
||||
}
|
||||
// DOC include end: PWM generic traits
|
||||
|
||||
// DOC include start: PWMTL
|
||||
class PWMTL(c: PWMParams)(implicit p: Parameters)
|
||||
extends TLRegisterRouter(
|
||||
c.address, "pwm", Seq("ucbbar,pwm"),
|
||||
beatBytes = c.beatBytes)(
|
||||
new TLRegBundle(c, _) with PWMBundle)(
|
||||
new TLRegModule(c, _, _) with PWMModule)
|
||||
// DOC include end: PWMTL
|
||||
|
||||
class PWMAXI4(c: PWMParams)(implicit p: Parameters)
|
||||
extends AXI4RegisterRouter(c.address, beatBytes = c.beatBytes)(
|
||||
new AXI4RegBundle(c, _) with PWMBundle)(
|
||||
new AXI4RegModule(c, _, _) with PWMModule)
|
||||
|
||||
// DOC include start: HasPeripheryPWMTL
|
||||
trait HasPeripheryPWMTL { this: BaseSubsystem =>
|
||||
implicit val p: Parameters
|
||||
|
||||
private val address = 0x2000
|
||||
private val portName = "pwm"
|
||||
|
||||
val pwm = LazyModule(new PWMTL(
|
||||
PWMParams(address, pbus.beatBytes))(p))
|
||||
|
||||
pbus.toVariableWidthSlave(Some(portName)) { pwm.node }
|
||||
}
|
||||
// DOC include end: HasPeripheryPWMTL
|
||||
|
||||
// DOC include start: HasPeripheryPWMTLModuleImp
|
||||
trait HasPeripheryPWMTLModuleImp extends LazyModuleImp {
|
||||
implicit val p: Parameters
|
||||
val outer: HasPeripheryPWMTL
|
||||
|
||||
val pwmout = IO(Output(Bool()))
|
||||
|
||||
pwmout := outer.pwm.module.io.pwmout
|
||||
}
|
||||
// DOC include end: HasPeripheryPWMTLModuleImp
|
||||
|
||||
trait HasPeripheryPWMAXI4 { this: BaseSubsystem =>
|
||||
implicit val p: Parameters
|
||||
|
||||
private val address = 0x2000
|
||||
private val portName = "pwm"
|
||||
|
||||
val pwm = LazyModule(new PWMAXI4(
|
||||
PWMParams(address, pbus.beatBytes))(p))
|
||||
|
||||
pbus.toSlave(Some(portName)) {
|
||||
pwm.node :=
|
||||
AXI4Buffer () :=
|
||||
TLToAXI4() :=
|
||||
// toVariableWidthSlave doesn't use holdFirstDeny, which TLToAXI4() needs
|
||||
TLFragmenter(pbus.beatBytes, pbus.blockBytes, holdFirstDeny = true)
|
||||
}
|
||||
}
|
||||
|
||||
trait HasPeripheryPWMAXI4ModuleImp extends LazyModuleImp {
|
||||
implicit val p: Parameters
|
||||
val outer: HasPeripheryPWMAXI4
|
||||
|
||||
val pwmout = IO(Output(Bool()))
|
||||
|
||||
pwmout := outer.pwm.module.io.pwmout
|
||||
}
|
||||
@@ -9,17 +9,23 @@ import freechips.rocketchip.config.{Config}
|
||||
// --------------
|
||||
|
||||
class RocketConfig extends Config(
|
||||
new WithTop ++ // use default top
|
||||
new WithTSI ++ // use testchipip serial offchip link
|
||||
new WithNoGPIO ++ // no top-level GPIO pins (overrides default set in sifive-blocks)
|
||||
new WithBootROM ++ // use default bootrom
|
||||
new WithUART ++ // add a UART
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++ // no top-level MMIO master port (overrides default set in rocketchip)
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++ // no top-level MMIO slave port (overrides default set in rocketchip)
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++ // use Sifive L2 cache
|
||||
new freechips.rocketchip.subsystem.WithNBigCores(1) ++ // single rocket-core
|
||||
new freechips.rocketchip.system.BaseConfig) // "base" rocketchip system
|
||||
|
||||
class HwachaRocketConfig extends Config(
|
||||
new WithTop ++
|
||||
new WithTSI ++
|
||||
new WithNoGPIO ++
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new hwacha.DefaultHwachaConfig ++ // use Hwacha vector accelerator
|
||||
new freechips.rocketchip.subsystem.WithNBigCores(1) ++
|
||||
@@ -27,9 +33,12 @@ class HwachaRocketConfig extends Config(
|
||||
|
||||
// DOC include start: GemminiRocketConfig
|
||||
class GemminiRocketConfig extends Config(
|
||||
new WithTop ++
|
||||
new WithTSI ++
|
||||
new WithNoGPIO ++
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new gemmini.DefaultGemminiConfig ++ // use Gemmini systolic array GEMM accelerator
|
||||
new freechips.rocketchip.subsystem.WithNBigCores(1) ++
|
||||
@@ -37,9 +46,12 @@ class GemminiRocketConfig extends Config(
|
||||
// DOC include end: GemminiRocketConfig
|
||||
|
||||
class RoccRocketConfig extends Config(
|
||||
new WithTop ++
|
||||
new WithTSI ++
|
||||
new WithNoGPIO ++
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new freechips.rocketchip.subsystem.WithRoccExample ++ // use example RoCC-based accelerator
|
||||
new freechips.rocketchip.subsystem.WithNBigCores(1) ++
|
||||
@@ -47,10 +59,13 @@ class RoccRocketConfig extends Config(
|
||||
|
||||
// DOC include start: JtagRocket
|
||||
class jtagRocketConfig extends Config(
|
||||
new WithDTMTop ++ // use top with dtm
|
||||
new freechips.rocketchip.subsystem.WithJtagDTM ++ // add jtag+DTM module to coreplex
|
||||
new WithDTM ++ // use top with dtm
|
||||
new WithNoGPIO ++
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithJtagDTM ++ // enable communicating with the DTM using jtag
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new freechips.rocketchip.subsystem.WithNBigCores(1) ++
|
||||
new freechips.rocketchip.system.BaseConfig)
|
||||
@@ -58,100 +73,127 @@ class jtagRocketConfig extends Config(
|
||||
|
||||
// DOC include start: DmiRocket
|
||||
class dmiRocketConfig extends Config(
|
||||
new WithDTMTop ++ // use top with dtm
|
||||
new WithDTM ++ // use top with dtm
|
||||
new WithNoGPIO ++
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new freechips.rocketchip.subsystem.WithNBigCores(1) ++
|
||||
new freechips.rocketchip.system.BaseConfig)
|
||||
// DOC include end: DmiRocket
|
||||
|
||||
// DOC include start: PWMRocketConfig
|
||||
class PWMRocketConfig extends Config(
|
||||
new WithPWMTop ++ // use top with tilelink-controlled PWM
|
||||
new WithBootROM ++
|
||||
// DOC include start: GCDTLRocketConfig
|
||||
class GCDTLRocketConfig extends Config(
|
||||
new WithTSI ++
|
||||
new WithNoGPIO ++
|
||||
new WithUART ++
|
||||
new WithGCD(useAXI4=false, useBlackBox=false) ++ // Use GCD Chisel, connect Tilelink
|
||||
new WithBootROM ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new freechips.rocketchip.subsystem.WithNBigCores(1) ++
|
||||
new freechips.rocketchip.system.BaseConfig)
|
||||
// DOC include end: PWMRocketConfig
|
||||
// DOC include end: GCDTLRocketConfig
|
||||
|
||||
class PWMAXI4RocketConfig extends Config(
|
||||
new WithPWMAXI4Top ++ // use top with axi4-controlled PWM
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new freechips.rocketchip.subsystem.WithNBigCores(1) ++
|
||||
new freechips.rocketchip.system.BaseConfig)
|
||||
|
||||
class GCDRocketConfig extends Config( // add MMIO GCD module
|
||||
new WithGCDTop ++
|
||||
new WithBootROM ++
|
||||
// DOC include start: GCDAXI4BlackBoxRocketConfig
|
||||
class GCDAXI4BlackBoxRocketConfig extends Config(
|
||||
new WithTSI ++
|
||||
new WithUART ++
|
||||
new WithNoGPIO ++
|
||||
new WithGCD(useAXI4=true, useBlackBox=true) ++ // Use GCD blackboxed verilog, connect by AXI4->Tilelink
|
||||
new WithBootROM ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new freechips.rocketchip.subsystem.WithNBigCores(1) ++
|
||||
new freechips.rocketchip.system.BaseConfig)
|
||||
// DOC include end: GCDAXI4BlackBoxRocketConfig
|
||||
|
||||
class SimBlockDeviceRocketConfig extends Config(
|
||||
new WithTSI ++
|
||||
new WithNoGPIO ++
|
||||
new testchipip.WithBlockDevice ++ // add block-device module to peripherybus
|
||||
new WithSimBlockDeviceTop ++ // use top with block-device IOs and connect to simblockdevice
|
||||
new WithSimBlockDevice ++ // use top with block-device IOs and connect to simblockdevice
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new freechips.rocketchip.subsystem.WithNBigCores(1) ++
|
||||
new freechips.rocketchip.system.BaseConfig)
|
||||
|
||||
class BlockDeviceModelRocketConfig extends Config(
|
||||
new WithTSI ++
|
||||
new WithNoGPIO ++
|
||||
new testchipip.WithBlockDevice ++ // add block-device module to periphery bus
|
||||
new WithBlockDeviceModelTop ++ // use top with block-device IOs and connect to a blockdevicemodel
|
||||
new WithBlockDeviceModel ++ // use top with block-device IOs and connect to a blockdevicemodel
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new freechips.rocketchip.subsystem.WithNBigCores(1) ++
|
||||
new freechips.rocketchip.system.BaseConfig)
|
||||
|
||||
// DOC include start: GPIORocketConfig
|
||||
class GPIORocketConfig extends Config(
|
||||
new WithTSI ++
|
||||
new WithGPIO ++ // add GPIOs to the peripherybus
|
||||
new WithGPIOTop ++ // use top with GPIOs
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new freechips.rocketchip.subsystem.WithNBigCores(1) ++
|
||||
new freechips.rocketchip.system.BaseConfig)
|
||||
// DOC include end: GPIORocketConfig
|
||||
|
||||
class DualCoreRocketConfig extends Config(
|
||||
new WithTop ++
|
||||
new WithTSI ++
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new WithNoGPIO ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new freechips.rocketchip.subsystem.WithNBigCores(2) ++ // dual-core (2 RocketTiles)
|
||||
new freechips.rocketchip.system.BaseConfig)
|
||||
|
||||
class RV32RocketConfig extends Config(
|
||||
new WithTop ++
|
||||
new WithTSI ++
|
||||
new WithNoGPIO ++
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new freechips.rocketchip.subsystem.WithRV32 ++ // set RocketTiles to be 32-bit
|
||||
new freechips.rocketchip.subsystem.WithNBigCores(1) ++
|
||||
new freechips.rocketchip.system.BaseConfig)
|
||||
|
||||
class GB1MemoryRocketConfig extends Config(
|
||||
new WithTop ++
|
||||
new WithTSI ++
|
||||
new WithNoGPIO ++
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new freechips.rocketchip.subsystem.WithExtMemSize((1<<30) * 1L) ++ // use 2GB simulated external memory
|
||||
new freechips.rocketchip.subsystem.WithExtMemSize((1<<30) * 1L) ++ // use 1GB simulated external memory
|
||||
new freechips.rocketchip.subsystem.WithNBigCores(1) ++
|
||||
new freechips.rocketchip.system.BaseConfig)
|
||||
|
||||
// DOC include start: Sha3Rocket
|
||||
class Sha3RocketConfig extends Config(
|
||||
new WithTop ++
|
||||
new WithTSI ++
|
||||
new WithNoGPIO ++
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new sha3.WithSha3Accel ++ // add SHA3 rocc accelerator
|
||||
new freechips.rocketchip.subsystem.WithNBigCores(1) ++
|
||||
@@ -160,20 +202,27 @@ class Sha3RocketConfig extends Config(
|
||||
|
||||
// DOC include start: InitZeroRocketConfig
|
||||
class InitZeroRocketConfig extends Config(
|
||||
new WithInitZero(0x88000000L, 0x1000L) ++
|
||||
new WithInitZeroTop ++
|
||||
new WithInitZero(0x88000000L, 0x1000L) ++ // add InitZero
|
||||
new WithNoGPIO ++
|
||||
new WithTSI ++
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new freechips.rocketchip.subsystem.WithNBigCores(1) ++
|
||||
new freechips.rocketchip.system.BaseConfig)
|
||||
// DOC include end: InitZeroRocketConfig
|
||||
|
||||
class LoopbackNICRocketConfig extends Config(
|
||||
new WithTSI ++
|
||||
new WithIceNIC ++
|
||||
new WithLoopbackNICTop ++
|
||||
new WithNoGPIO ++
|
||||
new WithLoopbackNIC ++
|
||||
new WithBootROM ++
|
||||
new WithUART ++
|
||||
new freechips.rocketchip.subsystem.WithNoMMIOPort ++
|
||||
new freechips.rocketchip.subsystem.WithNoSlavePort ++
|
||||
new freechips.rocketchip.subsystem.WithInclusiveCache ++
|
||||
new freechips.rocketchip.subsystem.WithNBigCores(1) ++
|
||||
new freechips.rocketchip.system.BaseConfig)
|
||||
|
||||
@@ -10,12 +10,22 @@ import freechips.rocketchip.config.{Field, Parameters}
|
||||
import freechips.rocketchip.util.GeneratorApp
|
||||
import freechips.rocketchip.devices.debug.{Debug}
|
||||
|
||||
/**
|
||||
* TODO: Why do we need this?
|
||||
*/
|
||||
import ConfigValName._
|
||||
|
||||
// -------------------------------
|
||||
// BOOM and/or Rocket Test Harness
|
||||
// -------------------------------
|
||||
|
||||
case object BuildTop extends Field[(Clock, Bool, Parameters) => TopModule[Top]]
|
||||
case object BuildTopWithDTM extends Field[(Clock, Bool, Parameters) => TopWithDTMModule[TopWithDTM]]
|
||||
case object BuildTop extends Field[(Clock, Bool, Parameters, Bool) => TopModule[Top]](
|
||||
(clock: Clock, reset: Bool, p: Parameters, success: Bool) => {
|
||||
val top = Module(LazyModule(new Top()(p)).suggestName("top").module)
|
||||
top.debug.map { debug => debug := DontCare }
|
||||
top
|
||||
}
|
||||
)
|
||||
|
||||
/**
|
||||
* Test harness using TSI to bringup the system
|
||||
@@ -25,48 +35,8 @@ class TestHarness(implicit val p: Parameters) extends Module {
|
||||
val success = Output(Bool())
|
||||
})
|
||||
|
||||
// force Chisel to rename module
|
||||
override def desiredName = "TestHarness"
|
||||
|
||||
val dut = p(BuildTop)(clock, reset.toBool, p)
|
||||
|
||||
dut.debug.foreach(_ := 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
|
||||
}
|
||||
})
|
||||
val dut = p(BuildTop)(clock, reset.toBool, p, io.success)
|
||||
dut.connectSimUARTs()
|
||||
|
||||
io.success := dut.connectSimSerial()
|
||||
}
|
||||
|
||||
/**
|
||||
* Test harness using the Debug Test Module (DTM) to bringup the system
|
||||
*/
|
||||
class TestHarnessWithDTM(implicit p: Parameters) extends Module
|
||||
{
|
||||
val io = IO(new Bundle {
|
||||
val success = Output(Bool())
|
||||
})
|
||||
|
||||
// force Chisel to rename module
|
||||
override def desiredName = "TestHarness"
|
||||
|
||||
val dut = p(BuildTopWithDTM)(clock, reset.toBool, p)
|
||||
|
||||
dut.reset := reset.asBool | dut.debug.get.ndreset
|
||||
dut.connectSimAXIMem()
|
||||
dut.connectSimAXIMMIO()
|
||||
dut.dontTouchPorts()
|
||||
@@ -84,5 +54,4 @@ class TestHarnessWithDTM(implicit p: Parameters) extends Module
|
||||
}
|
||||
})
|
||||
|
||||
Debug.connectDebug(dut.debug, dut.psd, clock, reset.asBool, io.success)
|
||||
}
|
||||
|
||||
@@ -15,103 +15,33 @@ import utilities.{System, SystemModule}
|
||||
import sifive.blocks.devices.gpio._
|
||||
import sifive.blocks.devices.uart._
|
||||
|
||||
import icenet.{HasPeripheryIceNIC, HasPeripheryIceNICModuleImp}
|
||||
import icenet.{CanHavePeripheryIceNIC, CanHavePeripheryIceNICModuleImp}
|
||||
|
||||
// ------------------------------------
|
||||
// BOOM and/or Rocket Top Level Systems
|
||||
// ------------------------------------
|
||||
|
||||
// DOC include start: Top
|
||||
class Top(implicit p: Parameters) extends System
|
||||
with HasNoDebug
|
||||
with HasPeripherySerial
|
||||
with CanHavePeripheryUARTWithAdapter {
|
||||
with CanHavePeripheryUARTAdapter // Enables optionally adding the UART print adapter
|
||||
with HasPeripheryUART // Enables optionally adding the sifive UART
|
||||
with HasPeripheryGPIO // Enables optionally adding the sifive GPIOs
|
||||
with CanHavePeripheryBlockDevice // Enables optionally adding the block device
|
||||
with CanHavePeripheryInitZero // Enables optionally adding the initzero example widget
|
||||
with CanHavePeripheryGCD // Enables optionally adding the GCD example widget
|
||||
with CanHavePeripherySerial // Enables optionally adding the TSI serial-adapter and port
|
||||
with CanHavePeripheryIceNIC // Enables optionally adding the IceNIC for firesim
|
||||
{
|
||||
override lazy val module = new TopModule(this)
|
||||
}
|
||||
|
||||
class TopModule[+L <: Top](l: L) extends SystemModule(l)
|
||||
with HasNoDebugModuleImp
|
||||
with HasPeripherySerialModuleImp
|
||||
with CanHavePeripheryUARTWithAdapterImp
|
||||
with DontTouch
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
// DOC include start: TopWithPWMTL
|
||||
|
||||
class TopWithPWMTL(implicit p: Parameters) extends Top
|
||||
with HasPeripheryPWMTL {
|
||||
override lazy val module = new TopWithPWMTLModule(this)
|
||||
}
|
||||
|
||||
class TopWithPWMTLModule(l: TopWithPWMTL) extends TopModule(l)
|
||||
with HasPeripheryPWMTLModuleImp
|
||||
|
||||
// DOC include end: TopWithPWMTL
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
|
||||
class TopWithPWMAXI4(implicit p: Parameters) extends Top
|
||||
with HasPeripheryPWMAXI4 {
|
||||
override lazy val module = new TopWithPWMAXI4Module(this)
|
||||
}
|
||||
|
||||
class TopWithPWMAXI4Module(l: TopWithPWMAXI4) extends TopModule(l)
|
||||
with HasPeripheryPWMAXI4ModuleImp
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
|
||||
class TopWithGCD(implicit p: Parameters) extends Top
|
||||
with HasPeripheryGCD {
|
||||
override lazy val module = new TopWithGCDModule(this)
|
||||
}
|
||||
|
||||
class TopWithGCDModule(l: TopWithGCD) extends TopModule(l)
|
||||
with HasPeripheryGCDModuleImp
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
|
||||
class TopWithBlockDevice(implicit p: Parameters) extends Top
|
||||
with HasPeripheryBlockDevice {
|
||||
override lazy val module = new TopWithBlockDeviceModule(this)
|
||||
}
|
||||
|
||||
class TopWithBlockDeviceModule(l: TopWithBlockDevice) extends TopModule(l)
|
||||
with HasPeripheryBlockDeviceModuleImp
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
|
||||
class TopWithGPIO(implicit p: Parameters) extends Top
|
||||
with HasPeripheryGPIO {
|
||||
override lazy val module = new TopWithGPIOModule(this)
|
||||
}
|
||||
|
||||
class TopWithGPIOModule(l: TopWithGPIO)
|
||||
extends TopModule(l)
|
||||
with HasPeripheryGPIOModuleImp
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
|
||||
class TopWithDTM(implicit p: Parameters) extends System
|
||||
{
|
||||
override lazy val module = new TopWithDTMModule(this)
|
||||
}
|
||||
|
||||
class TopWithDTMModule[+L <: TopWithDTM](l: L) extends SystemModule(l)
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
// DOC include start: TopWithInitZero
|
||||
class TopWithInitZero(implicit p: Parameters) extends Top
|
||||
with HasPeripheryInitZero {
|
||||
override lazy val module = new TopWithInitZeroModuleImp(this)
|
||||
}
|
||||
|
||||
class TopWithInitZeroModuleImp(l: TopWithInitZero) extends TopModule(l)
|
||||
with HasPeripheryInitZeroModuleImp
|
||||
// DOC include end: TopWithInitZero
|
||||
|
||||
class TopWithIceNIC(implicit p: Parameters) extends Top
|
||||
with HasPeripheryIceNIC {
|
||||
override lazy val module = new TopWithIceNICModule(this)
|
||||
}
|
||||
|
||||
class TopWithIceNICModule(outer: TopWithIceNIC)
|
||||
extends TopModule(outer)
|
||||
with HasPeripheryIceNICModuleImp
|
||||
with HasPeripheryUARTModuleImp
|
||||
with CanHavePeripheryBlockDeviceModuleImp
|
||||
with CanHavePeripheryGCDModuleImp
|
||||
with CanHavePeripherySerialModuleImp
|
||||
with CanHavePeripheryIceNICModuleImp
|
||||
with CanHavePeripheryUARTAdapterModuleImp
|
||||
with DontTouch
|
||||
// DOC include end: Top
|
||||
|
||||
Reference in New Issue
Block a user