Skip to content

Commit

Permalink
Bump to July 2020 rocketchip
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryz123 committed Aug 3, 2020
1 parent fdfef87 commit 3b7edfd
Show file tree
Hide file tree
Showing 17 changed files with 147 additions and 108 deletions.
2 changes: 1 addition & 1 deletion generators/ariane
17 changes: 8 additions & 9 deletions generators/chipyard/src/main/scala/ChipTop.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ class ChipTop(implicit p: Parameters) extends LazyModule with HasTestHarnessFunc
// The system module specified by BuildSystem
val lSystem = LazyModule(p(BuildSystem)(p)).suggestName("system")

// The systemClockSinkNode provides the implicit clock and reset for the System
val systemClockSinkNode = ClockSinkNode(Seq(ClockSinkParameters()))
val systemClockGroup = LazyModule(new ClockGroup("system_clock"))
systemClockSinkNode := systemClockGroup.node
// The implicitClockSinkNode provides the implicit clock and reset for the System
val implicitClockSinkNode = ClockSinkNode(Seq(ClockSinkParameters()))

// Generate Clocks and Reset
p(ChipyardClockKey)(this)
Expand All @@ -46,12 +44,13 @@ class ChipTop(implicit p: Parameters) extends LazyModule with HasTestHarnessFunc
// anyways, they probably need to be explicitly clocked.
lazy val module: LazyModuleImpLike = new LazyRawModuleImp(this) {
// These become the implicit clock and reset to the System
val system_clock = systemClockSinkNode.in.head._1.clock
val system_reset = systemClockSinkNode.in.head._1.reset
val implicit_clock = implicitClockSinkNode.in.head._1.clock
val implicit_reset = implicitClockSinkNode.in.head._1.reset


// The implicit clock and reset for the system is also, by convention, used for all the IOBinders
// TODO: This may not be the right thing to do in all cases
withClockAndReset(system_clock, system_reset) {
withClockAndReset(implicit_clock, implicit_reset) {
val (_ports, _iocells, _harnessFunctions) = p(IOBinders).values.flatMap(f => f(lSystem) ++ f(lSystem.module)).unzip3
// We ignore _ports for now...
iocells ++= _iocells.flatten
Expand All @@ -60,8 +59,8 @@ class ChipTop(implicit p: Parameters) extends LazyModule with HasTestHarnessFunc

// Connect the implicit clock/reset, if present
lSystem.module match { case l: LazyModuleImp => {
l.clock := system_clock
l.reset := system_reset
l.clock := implicit_clock
l.reset := implicit_reset
}}
}
}
Expand Down
77 changes: 44 additions & 33 deletions generators/chipyard/src/main/scala/Clocks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -83,59 +83,65 @@ case object ChipyardClockKey extends Field[ChipTop => Unit](ClockDrivers.harness


object ClockDrivers {
// A simple clock provider, for testing. All clocks in system are aggregated into one,
// and are driven by directly punching out to the TestHarness clock
// A simple clock provider, for testing
val harnessClock: ChipTop => Unit = { chiptop =>
implicit val p = chiptop.p
val simpleClockGroupSourceNode = ClockGroupSourceNode(Seq(ClockGroupSourceParameters()))
val clockAggregator = LazyModule(new ClockGroupAggregator("clocks"))

// Aggregate all 3 possible clock groups with the clockAggregator
chiptop.systemClockGroup.node := clockAggregator.node
if (p(SubsystemDriveAsyncClockGroupsKey).isEmpty) {
chiptop.lSystem match { case l: BaseSubsystem => l.asyncClockGroupsNode := clockAggregator.node }
}
chiptop.lSystem match {
case l: ChipyardSubsystem => l.tileClockGroupNode := clockAggregator.node
case _ =>
}
val implicitClockSourceNode = ClockSourceNode(Seq(ClockSourceParameters()))
chiptop.implicitClockSinkNode := implicitClockSourceNode

// Drive the diplomaticclock graph of the DigitalTop (if present)
val simpleClockGroupSourceNode = chiptop.lSystem match {
case l: BaseSubsystem if (p(SubsystemDriveAsyncClockGroupsKey).isEmpty) => {
val n = ClockGroupSourceNode(Seq(ClockGroupSourceParameters()))
l.asyncClockGroupsNode := n
Some(n)
}
case _ => None
}

clockAggregator.node := simpleClockGroupSourceNode
InModuleBody {
// this needs directionality so generateIOFromSignal works
//this needs directionality so generateIOFromSignal works
val clock_wire = Wire(Input(Clock()))
val reset_wire = GenerateReset(chiptop, clock_wire)
val (clock_io, clockIOCell) = IOCell.generateIOFromSignal(clock_wire, Some("iocell_clock"))
chiptop.iocells ++= clockIOCell
clock_io.suggestName("clock")

simpleClockGroupSourceNode.out.unzip._1.flatMap(_.member).map { o =>
implicitClockSourceNode.out.unzip._1.map { o =>
o.clock := clock_wire
o.reset := reset_wire
}

simpleClockGroupSourceNode.map { n => n.out.unzip._1.map { out: ClockGroupBundle =>
out.member.data.foreach { o =>
o.clock := clock_wire
o.reset := reset_wire
}
}}

chiptop.harnessFunctions += ((th: HasHarnessUtils) => {
clock_io := th.harnessClock
Nil
})
}

}

val harnessMultiClock: ChipTop => Unit = { chiptop =>

val harnessDividedClock: ChipTop => Unit = { chiptop =>
implicit val p = chiptop.p
val simpleClockGroupSourceNode = ClockGroupSourceNode(Seq(ClockGroupSourceParameters(), ClockGroupSourceParameters()))
val uncoreClockAggregator = LazyModule(new ClockGroupAggregator("uncore_clocks"))

// Aggregate only the uncoreclocks
chiptop.systemClockGroup.node := uncoreClockAggregator.node
if (p(SubsystemDriveAsyncClockGroupsKey).isEmpty) {
chiptop.lSystem match { case l: BaseSubsystem => l.asyncClockGroupsNode := uncoreClockAggregator.node }
}
val implicitClockSourceNode = ClockSourceNode(Seq(ClockSourceParameters()))
chiptop.implicitClockSinkNode := implicitClockSourceNode

uncoreClockAggregator.node := simpleClockGroupSourceNode
chiptop.lSystem match {
case l: ChipyardSubsystem => l.tileClockGroupNode := simpleClockGroupSourceNode
case _ => throw new Exception("MultiClock assumes ChipyardSystem")
val simpleClockGroupSourceNode = chiptop.lSystem match {
case l: BaseSubsystem if (p(SubsystemDriveAsyncClockGroupsKey).isEmpty) => {
val n = ClockGroupSourceNode(Seq(ClockGroupSourceParameters()))
l.asyncClockGroupsNode := n
Some(n)
}
case _ => throw new Exception("Harness multiclock assumes BaseSubsystem")
}

InModuleBody {
Expand All @@ -147,14 +153,19 @@ object ClockDrivers {
clock_io.suggestName("clock")
val div_clock = Pow2ClockDivider(clock_wire, 2)

simpleClockGroupSourceNode.out(0)._1.member.map { o =>
implicitClockSourceNode.out.unzip._1.map { o =>
o.clock := div_clock
o.reset := ResetCatchAndSync(div_clock, reset_wire.asBool)
}
simpleClockGroupSourceNode.out(1)._1.member.map { o =>
o.clock := clock_wire
o.reset := reset_wire
}

simpleClockGroupSourceNode.map { n => n.out.unzip._1.map { out: ClockGroupBundle =>
out.member.elements.map { case (name, data) =>
// This is mega hacks, how are you actually supposed to do this?
data.clock := (if (name.contains("core")) clock_wire else div_clock)
data.reset := reset_wire
}
}}

chiptop.harnessFunctions += ((th: HasHarnessUtils) => {
clock_io := th.harnessClock
Nil
Expand Down
10 changes: 5 additions & 5 deletions generators/chipyard/src/main/scala/ConfigFragments.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import chisel3.util.{log2Up}
import freechips.rocketchip.config.{Field, Parameters, Config}
import freechips.rocketchip.subsystem._
import freechips.rocketchip.diplomacy.{LazyModule, ValName}
import freechips.rocketchip.devices.tilelink.BootROMParams
import freechips.rocketchip.devices.tilelink.{BootROMLocated}
import freechips.rocketchip.devices.debug.{Debug}
import freechips.rocketchip.groundtest.{GroundTestSubsystem}
import freechips.rocketchip.tile._
import freechips.rocketchip.rocket.{RocketCoreParams, MulDivParams, DCacheParams, ICacheParams}
import freechips.rocketchip.util.{AsyncResetReg}
import freechips.rocketchip.prci._

import testchipip._
import tracegen.{TraceGenSystem}
Expand All @@ -33,8 +34,7 @@ import chipyard.{BuildTop, BuildSystem, ClockDrivers, ChipyardClockKey, TestSuit
// -----------------------

class WithBootROM extends Config((site, here, up) => {
case BootROMParams => BootROMParams(
contentFileName = s"./bootrom/bootrom.rv${site(XLen)}.img")
case BootROMLocated(x) => up(BootROMLocated(x), site).map(_.copy(contentFileName = s"./bootrom/bootrom.rv${site(XLen)}.img"))
})

// DOC include start: gpio config fragment
Expand Down Expand Up @@ -159,6 +159,6 @@ class WithNoSubsystemDrivenClocks extends Config((site, here, up) => {
case SubsystemDriveAsyncClockGroupsKey => None
})

class WithTileMultiClock extends Config((site, here, up) => {
case ChipyardClockKey => ClockDrivers.harnessMultiClock
class WithTileDividedClock extends Config((site, here, up) => {
case ChipyardClockKey => ClockDrivers.harnessDividedClock
})
28 changes: 15 additions & 13 deletions generators/chipyard/src/main/scala/Subsystem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,34 @@ class ChipyardSubsystem(implicit p: Parameters) extends BaseSubsystem
case b: BoomTile => b.module.core.coreMonitorBundle
}.toList

val tileClockSinkNode = ClockSinkNode(List(ClockSinkParameters()))
val tileClockGroup = LazyModule(new ClockGroup("tile_clock"))
val tileClockGroupNode = tileClockGroup.node
tileClockSinkNode := tileClockGroupNode
// val tileClockSinkNode = ClockSinkNode(List(ClockSinkParameters()))
// val tileClockGroup = LazyModule(new ClockGroup("tile_clock"))
// val tileClockGroupNode = tileClockGroup.node
// tileClockSinkNode := tileClockGroupNode

override lazy val module = new ChipyardSubsystemModuleImp(this)
}

class ChipyardSubsystemModuleImp[+L <: ChipyardSubsystem](_outer: L) extends BaseSubsystemModuleImp(_outer)
with HasResetVectorWire
with HasTilesModuleImp
{
for (i <- 0 until outer.tiles.size) {
val wire = tile_inputs(i)
wire.hartid := outer.hartIdList(i).U
wire.reset_vector := global_reset_vector
// <<<<<<< Updated upstream
// for (i <- 0 until outer.tiles.size) {
// val wire = tile_inputs(i)
// wire.hartid := outer.hartIdList(i).U
// wire.reset_vector := global_reset_vector


outer.tiles(i).module.clock := outer.tileClockSinkNode.in.head._1.clock
outer.tiles(i).module.reset := outer.tileClockSinkNode.in.head._1.reset
}
// outer.tiles(i).module.clock := outer.tileClockSinkNode.in.head._1.clock
// outer.tiles(i).module.reset := outer.tileClockSinkNode.in.head._1.reset
// }
// =======
// >>>>>>> Stashed changes

// create file with core params
ElaborationArtefacts.add("""core.config""", outer.tiles.map(x => x.module.toString).mkString("\n"))
// Generate C header with relevant information for Dromajo
// This is included in the `dromajo_params.h` header file
DromajoHelper.addArtefacts()
DromajoHelper.addArtefacts(InSubsystem)
}

5 changes: 3 additions & 2 deletions generators/chipyard/src/main/scala/System.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ class ChipyardSystem(implicit p: Parameters) extends ChipyardSubsystem
with CanHaveMasterAXI4MemPort
with CanHaveMasterAXI4MMIOPort
with CanHaveSlaveAXI4Port
with HasPeripheryBootROM
{

val bootROM = p(BootROMLocated(location)).map { BootROM.attach(_, this, CBUS) }
val maskROMs = p(MaskROMLocated(location)).map { MaskROM.attach(_, this, CBUS) }
override lazy val module = new ChipyardSystemModule(this)
}

Expand All @@ -37,5 +39,4 @@ class ChipyardSystem(implicit p: Parameters) extends ChipyardSubsystem
class ChipyardSystemModule[+L <: ChipyardSystem](_outer: L) extends ChipyardSubsystemModuleImp(_outer)
with HasRTCModuleImp
with HasExtInterruptsModuleImp
with HasPeripheryBootROMModuleImp
with DontTouch
2 changes: 1 addition & 1 deletion generators/chipyard/src/main/scala/TestHarness.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TestHarness(implicit val p: Parameters) extends Module with HasHarnessUtil
val success = Output(Bool())
})

val ldut = LazyModule(p(BuildTop)(p)).suggestName("ChipTop")
val ldut = LazyModule(p(BuildTop)(p)).suggestName("chiptop")
val dut = Module(ldut.module)
io.success := false.B

Expand Down
11 changes: 9 additions & 2 deletions generators/chipyard/src/main/scala/config/RocketConfigs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,15 @@ class MMIORocketConfig extends Config(

// NOTE: This config doesn't work yet because SimWidgets in the TestHarness
// always get the TestHarness clock. The Tiles and Uncore receive the correct clocks
class MultiClockRocketConfig extends Config(
new chipyard.config.WithTileMultiClock ++ // Put the Tile on its own clock domain
class DividedClockRocketConfig extends Config(
new chipyard.config.WithTileDividedClock ++ // Put the Tile on its own clock domain
new freechips.rocketchip.subsystem.WithRationalRocketTiles ++ // Add rational crossings between RocketTile and uncore
new freechips.rocketchip.subsystem.WithNBigCores(1) ++
new chipyard.config.AbstractConfig)


class TestClockRocketConfig extends Config(
//new chipyard.config.WithTileMultiClock ++ // Put the Tile on its own clock domain
new freechips.rocketchip.subsystem.WithAsynchronousRocketTiles(8, 3) ++ // Add rational crossings between RocketTile and uncore
new freechips.rocketchip.subsystem.WithNBigCores(1) ++
new chipyard.config.AbstractConfig)
71 changes: 44 additions & 27 deletions generators/firechip/src/main/scala/FireSim.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,36 @@ object NodeIdx {
class WithFireSimSimpleClocks extends Config((site, here, up) => {
case ChipyardClockKey => { chiptop: ChipTop =>
implicit val p = chiptop.p
val simpleClockGroupSourceNode = ClockGroupSourceNode(Seq(ClockGroupSourceParameters()))
val clockAggregator = LazyModule(new ClockGroupAggregator("clocks"))

// Aggregate all 3 possible clock groups with the clockAggregator
chiptop.systemClockGroup.node := clockAggregator.node
if (p(SubsystemDriveAsyncClockGroupsKey).isEmpty) {
chiptop.lSystem match { case l: BaseSubsystem => l.asyncClockGroupsNode := clockAggregator.node }
val implicitClockSourceNode = ClockSourceNode(Seq(ClockSourceParameters()))
chiptop.implicitClockSinkNode := implicitClockSourceNode

// Drive the diplomaticclock graph of the DigitalTop (if present)
val simpleClockGroupSourceNode = chiptop.lSystem match {
case l: BaseSubsystem if (p(SubsystemDriveAsyncClockGroupsKey).isEmpty) => {
val n = ClockGroupSourceNode(Seq(ClockGroupSourceParameters()))
l.asyncClockGroupsNode := n
Some(n)
}
case _ => None
}
chiptop.lSystem match { case l: ChipyardSubsystem => l.tileClockGroupNode := clockAggregator.node }

clockAggregator.node := simpleClockGroupSourceNode
InModuleBody {
val clock = IO(Input(Clock())).suggestName("clock")
val reset = IO(Input(Reset())).suggestName("reset")
val clock = Wire(Clock())
val reset = Wire(Reset())

simpleClockGroupSourceNode.out.unzip._1.flatMap(_.member).map { o =>
implicitClockSourceNode.out.unzip._1.map { o =>
o.clock := clock
o.reset := reset
}

simpleClockGroupSourceNode.map { n => n.out.unzip._1.map { out: ClockGroupBundle =>
out.member.data.foreach { o =>
o.clock := clock
o.reset := reset
}
}}

chiptop.harnessFunctions += ((th: HasHarnessUtils) => {
clock := th.harnessClock
reset := th.harnessReset
Expand All @@ -78,35 +88,42 @@ class WithFireSimRationalTileDomain(multiplier: Int, divisor: Int) extends Confi
case FireSimClockKey => FireSimClockParameters(Seq(RationalClock("TileDomain", multiplier, divisor)))
case ChipyardClockKey => { chiptop: ChipTop =>
implicit val p = chiptop.p
val simpleClockGroupSourceNode = ClockGroupSourceNode(Seq(ClockGroupSourceParameters(), ClockGroupSourceParameters()))
val uncoreClockAggregator = LazyModule(new ClockGroupAggregator("uncore_clocks"))

// Aggregate only the uncoreclocks
chiptop.systemClockGroup.node := uncoreClockAggregator.node
if (p(SubsystemDriveAsyncClockGroupsKey).isEmpty) {
chiptop.lSystem match { case l: BaseSubsystem => l.asyncClockGroupsNode := uncoreClockAggregator.node }
}
val implicitClockSourceNode = ClockSourceNode(Seq(ClockSourceParameters()))
chiptop.implicitClockSinkNode := implicitClockSourceNode

uncoreClockAggregator.node := simpleClockGroupSourceNode
chiptop.lSystem match {
case l: ChipyardSubsystem => l.tileClockGroupNode := simpleClockGroupSourceNode
case _ => throw new Exception("MultiClock assumes ChipyardSystem")
// Drive the diplomaticclock graph of the DigitalTop (if present)
val simpleClockGroupSourceNode = chiptop.lSystem match {
case l: BaseSubsystem if (p(SubsystemDriveAsyncClockGroupsKey).isEmpty) => {
val n = ClockGroupSourceNode(Seq(ClockGroupSourceParameters()))
l.asyncClockGroupsNode := n
Some(n)
}
case _ => None
}

InModuleBody {
val uncore_clock = IO(Input(Clock())).suggestName("uncore_clock")
val tile_clock = IO(Input(Clock())).suggestName("tile_clock")
val reset = IO(Input(Reset())).suggestName("reset")

simpleClockGroupSourceNode.out(0)._1.member.map { o =>
implicitClockSourceNode.out.unzip._1.map { o =>
o.clock := uncore_clock
o.reset := reset
}

simpleClockGroupSourceNode.out(1)._1.member.map { o =>
o.clock := tile_clock
o.reset := ResetCatchAndSync(tile_clock, reset.asBool)
}
simpleClockGroupSourceNode.map { n => n.out.unzip._1.map { out: ClockGroupBundle =>
out.member.elements.map { case (name, data) =>
// This is mega hacks, how are you actually supposed to do this?
if (name.contains("core")) {
data.clock := tile_clock
data.reset := ResetCatchAndSync(tile_clock, reset.asBool)
} else {
data.clock := uncore_clock
data.clock := reset
}
}
}}

chiptop.harnessFunctions += ((th: HasHarnessUtils) => {
uncore_clock := th.harnessClock
Expand Down
Loading

0 comments on commit 3b7edfd

Please sign in to comment.