Move Clock binders to separate file
This commit is contained in:
@@ -22,8 +22,8 @@ import barstools.iocell.chisel._
|
|||||||
import testchipip._
|
import testchipip._
|
||||||
|
|
||||||
import chipyard._
|
import chipyard._
|
||||||
import chipyard.clocking.{HasChipyardPRCI}
|
import chipyard.clocking.{HasChipyardPRCI, ClockWithFreq}
|
||||||
import chipyard.iobinders.{GetSystemParameters, JTAGChipIO, ClockWithFreq}
|
import chipyard.iobinders.{GetSystemParameters, JTAGChipIO}
|
||||||
|
|
||||||
import tracegen.{TraceGenSystemModuleImp}
|
import tracegen.{TraceGenSystemModuleImp}
|
||||||
import icenet.{CanHavePeripheryIceNIC, SimNetwork, NicLoopback, NICKey, NICIOvonly}
|
import icenet.{CanHavePeripheryIceNIC, SimNetwork, NicLoopback, NICKey, NICIOvonly}
|
||||||
|
|||||||
@@ -425,45 +425,4 @@ class WithDontTouchPorts extends OverrideIOBinder({
|
|||||||
(system: DontTouch) => system.dontTouchPorts(); (Nil, Nil)
|
(system: DontTouch) => system.dontTouchPorts(); (Nil, Nil)
|
||||||
})
|
})
|
||||||
|
|
||||||
class ClockWithFreq(val freqMHz: Double) extends Bundle {
|
|
||||||
val clock = Clock()
|
|
||||||
}
|
|
||||||
|
|
||||||
class WithDividerOnlyClockGenerator extends OverrideLazyIOBinder({
|
|
||||||
(system: HasChipyardPRCI) => {
|
|
||||||
// Connect the implicit clock
|
|
||||||
implicit val p = GetSystemParameters(system)
|
|
||||||
val implicitClockSinkNode = ClockSinkNode(Seq(ClockSinkParameters(name = Some("implicit_clock"))))
|
|
||||||
system.connectImplicitClockSinkNode(implicitClockSinkNode)
|
|
||||||
InModuleBody {
|
|
||||||
val implicit_clock = implicitClockSinkNode.in.head._1.clock
|
|
||||||
val implicit_reset = implicitClockSinkNode.in.head._1.reset
|
|
||||||
system.asInstanceOf[BaseSubsystem].module match { case l: LazyModuleImp => {
|
|
||||||
l.clock := implicit_clock
|
|
||||||
l.reset := implicit_reset
|
|
||||||
}}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Connect all other requested clocks
|
|
||||||
val referenceClockSource = ClockSourceNode(Seq(ClockSourceParameters()))
|
|
||||||
val dividerOnlyClockGen = LazyModule(new DividerOnlyClockGenerator("buildTopClockGenerator"))
|
|
||||||
|
|
||||||
(system.allClockGroupsNode
|
|
||||||
:= dividerOnlyClockGen.node
|
|
||||||
:= referenceClockSource)
|
|
||||||
|
|
||||||
InModuleBody {
|
|
||||||
val clock_wire = Wire(Input(new ClockWithFreq(dividerOnlyClockGen.module.referenceFreq)))
|
|
||||||
val reset_wire = Wire(Input(AsyncReset()))
|
|
||||||
val (clock_io, clockIOCell) = IOCell.generateIOFromSignal(clock_wire, "clock", p(IOCellKey))
|
|
||||||
val (reset_io, resetIOCell) = IOCell.generateIOFromSignal(reset_wire, "reset", p(IOCellKey))
|
|
||||||
|
|
||||||
referenceClockSource.out.unzip._1.map { o =>
|
|
||||||
o.clock := clock_wire.clock
|
|
||||||
o.reset := reset_wire
|
|
||||||
}
|
|
||||||
|
|
||||||
(Seq(clock_io, reset_io), clockIOCell ++ resetIOCell)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package chipyard.clocking
|
||||||
|
|
||||||
|
import chisel3._
|
||||||
|
import chisel3.util._
|
||||||
|
import chipyard.iobinders.{OverrideLazyIOBinder, GetSystemParameters, IOCellKey}
|
||||||
|
import freechips.rocketchip.prci._
|
||||||
|
import freechips.rocketchip.diplomacy._
|
||||||
|
import freechips.rocketchip.subsystem._
|
||||||
|
import barstools.iocell.chisel._
|
||||||
|
|
||||||
|
class ClockWithFreq(val freqMHz: Double) extends Bundle {
|
||||||
|
val clock = Clock()
|
||||||
|
}
|
||||||
|
|
||||||
|
class WithDividerOnlyClockGenerator extends OverrideLazyIOBinder({
|
||||||
|
(system: HasChipyardPRCI) => {
|
||||||
|
// Connect the implicit clock
|
||||||
|
implicit val p = GetSystemParameters(system)
|
||||||
|
val implicitClockSinkNode = ClockSinkNode(Seq(ClockSinkParameters(name = Some("implicit_clock"))))
|
||||||
|
system.connectImplicitClockSinkNode(implicitClockSinkNode)
|
||||||
|
InModuleBody {
|
||||||
|
val implicit_clock = implicitClockSinkNode.in.head._1.clock
|
||||||
|
val implicit_reset = implicitClockSinkNode.in.head._1.reset
|
||||||
|
system.asInstanceOf[BaseSubsystem].module match { case l: LazyModuleImp => {
|
||||||
|
l.clock := implicit_clock
|
||||||
|
l.reset := implicit_reset
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Connect all other requested clocks
|
||||||
|
val referenceClockSource = ClockSourceNode(Seq(ClockSourceParameters()))
|
||||||
|
val dividerOnlyClockGen = LazyModule(new DividerOnlyClockGenerator("buildTopClockGenerator"))
|
||||||
|
|
||||||
|
(system.allClockGroupsNode
|
||||||
|
:= dividerOnlyClockGen.node
|
||||||
|
:= referenceClockSource)
|
||||||
|
|
||||||
|
InModuleBody {
|
||||||
|
val clock_wire = Wire(Input(new ClockWithFreq(dividerOnlyClockGen.module.referenceFreq)))
|
||||||
|
val reset_wire = Wire(Input(AsyncReset()))
|
||||||
|
val (clock_io, clockIOCell) = IOCell.generateIOFromSignal(clock_wire, "clock", p(IOCellKey))
|
||||||
|
val (reset_io, resetIOCell) = IOCell.generateIOFromSignal(reset_wire, "reset", p(IOCellKey))
|
||||||
|
|
||||||
|
referenceClockSource.out.unzip._1.map { o =>
|
||||||
|
o.clock := clock_wire.clock
|
||||||
|
o.reset := reset_wire
|
||||||
|
}
|
||||||
|
|
||||||
|
(Seq(clock_io, reset_io), clockIOCell ++ resetIOCell)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -40,7 +40,11 @@ class AbstractConfig extends Config(
|
|||||||
new chipyard.iobinders.WithTraceIOPunchthrough ++
|
new chipyard.iobinders.WithTraceIOPunchthrough ++
|
||||||
new chipyard.iobinders.WithExtInterruptIOCells ++
|
new chipyard.iobinders.WithExtInterruptIOCells ++
|
||||||
new chipyard.iobinders.WithCustomBootPin ++
|
new chipyard.iobinders.WithCustomBootPin ++
|
||||||
new chipyard.iobinders.WithDividerOnlyClockGenerator ++
|
|
||||||
|
// Default behavior is to use a divider-only clock-generator
|
||||||
|
// This works in VCS, Verilator, and FireSim/
|
||||||
|
// This should get replaced with a PLL-like config instead
|
||||||
|
new chipyard.clocking.WithDividerOnlyClockGenerator ++
|
||||||
|
|
||||||
new testchipip.WithSerialTLWidth(32) ++ // fatten the serialTL interface to improve testing performance
|
new testchipip.WithSerialTLWidth(32) ++ // fatten the serialTL interface to improve testing performance
|
||||||
new testchipip.WithDefaultSerialTL ++ // use serialized tilelink port to external serialadapter/harnessRAM
|
new testchipip.WithDefaultSerialTL ++ // use serialized tilelink port to external serialadapter/harnessRAM
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class AbstractTraceGenConfig extends Config(
|
|||||||
new chipyard.harness.WithClockAndResetFromHarness ++
|
new chipyard.harness.WithClockAndResetFromHarness ++
|
||||||
new chipyard.iobinders.WithAXI4MemPunchthrough ++
|
new chipyard.iobinders.WithAXI4MemPunchthrough ++
|
||||||
new chipyard.iobinders.WithTraceGenSuccessPunchthrough ++
|
new chipyard.iobinders.WithTraceGenSuccessPunchthrough ++
|
||||||
new chipyard.iobinders.WithDividerOnlyClockGenerator ++
|
new chipyard.clocking.WithDividerOnlyClockGenerator ++
|
||||||
new chipyard.config.WithTracegenSystem ++
|
new chipyard.config.WithTracegenSystem ++
|
||||||
new chipyard.config.WithNoSubsystemDrivenClocks ++
|
new chipyard.config.WithNoSubsystemDrivenClocks ++
|
||||||
new chipyard.config.WithPeripheryBusFrequencyAsDefault ++
|
new chipyard.config.WithPeripheryBusFrequencyAsDefault ++
|
||||||
|
|||||||
Reference in New Issue
Block a user