Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prci: allow configurable ClockGroupDriver drive function #2319

Merged
merged 1 commit into from
Mar 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions src/main/scala/prci/ClockParameters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ package freechips.rocketchip.prci
import chisel3._
import chisel3.internal.sourceinfo.SourceInfo
import freechips.rocketchip.config.Parameters
import freechips.rocketchip.diplomacy.{InModuleBody, ModuleValue, ValName}
import freechips.rocketchip.util.{HeterogeneousBag}
import scala.math.max

// All Clock parameters specify only the PLL values required at power-on
Expand Down Expand Up @@ -77,9 +79,29 @@ case class ClockGroupEdgeParameters(
}

// Used to create simple clock group drivers that just use the Chisel implicit clock
case class ClockGroupDriverParameters(num: Int = 1) {
def driveFromImplicitClock(groups: ClockGroupEphemeralNode)(implicit p: Parameters): Unit = {
case class ClockGroupDriverParameters(
num: Int = 1,
driveFn: ClockGroupDriver.DriveFn = ClockGroupDriver.driveFromImplicitClock
) {
def drive(node: ClockGroupEphemeralNode)(implicit p: Parameters, vn: ValName): ModuleValue[HeterogeneousBag[ClockGroupBundle]] = {
driveFn(node, num, p, vn)
}
}

object ClockGroupDriver {
type DriveFn = (ClockGroupEphemeralNode, Int, Parameters, ValName) => ModuleValue[HeterogeneousBag[ClockGroupBundle]]

def driveFromImplicitClock: DriveFn = { (groups, num, p, vn) =>
implicit val pp = p
val dummyClockGroupSourceNode: ClockGroupSourceNode = SimpleClockGroupSource(num)
groups :*= dummyClockGroupSourceNode
InModuleBody { HeterogeneousBag[ClockGroupBundle](Nil) }
}

def driveFromIOs: DriveFn = { (groups, num, p, vn) =>
implicit val pp = p
val ioClockGroupSourceNode = ClockGroupSourceNode(List.fill(num) { ClockGroupSourceParameters() })
groups :*= ioClockGroupSourceNode
InModuleBody { ioClockGroupSourceNode.makeIOs()(vn) }
}
}
5 changes: 4 additions & 1 deletion src/main/scala/subsystem/BaseSubsystem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ abstract class BaseSubsystem(implicit p: Parameters) extends BareSubsystem
}

implicit val asyncClockGroupsNode = p(AsyncClockGroupsKey)
p(SubsystemDriveAsyncClockGroupsKey).foreach(_.driveFromImplicitClock(asyncClockGroupsNode))
val async_clock_groups =
p(SubsystemDriveAsyncClockGroupsKey)
.map(_.drive(asyncClockGroupsNode))
.getOrElse(InModuleBody { HeterogeneousBag[ClockGroupBundle](Nil) })

// Collect information for use in DTS
lazy val topManagers = sbus.unifyManagers
Expand Down