uncore: add DTS meta-data for devices
This commit is contained in:
@ -849,7 +849,7 @@ trait DebugModule extends Module with HasDebugModuleParameters with HasRegMap {
|
||||
*/
|
||||
|
||||
class TLDebugModule(address: BigInt = 0)(implicit p: Parameters)
|
||||
extends TLRegisterRouter(address, beatBytes=p(XLen)/8, executable=true)(
|
||||
extends TLRegisterRouter(address, "debug", Nil, beatBytes=p(XLen)/8, executable=true)(
|
||||
new TLRegBundle((), _ ) with DebugModuleBundle)(
|
||||
new TLRegModule((), _, _) with DebugModule)
|
||||
|
||||
|
@ -58,19 +58,34 @@ class TLPLIC(supervisor: Boolean, maxPriorities: Int, address: BigInt = 0xC00000
|
||||
val contextsPerHart = if (supervisor) 2 else 1
|
||||
require (maxPriorities >= 0)
|
||||
|
||||
// plic0 => max devices 1023
|
||||
val device = new SimpleDevice("interrupt-controller", Seq("riscv,plic0")) {
|
||||
override val alwaysExtended = true
|
||||
override def describe(resources: ResourceBindings): Description = {
|
||||
val Description(name, mapping) = super.describe(resources)
|
||||
val extra = Map(
|
||||
"interrupt-controller" -> Nil,
|
||||
"riscv,ndev" -> Seq(ResourceInt(nDevices)),
|
||||
"#interrupt-cells" -> Seq(ResourceInt(1)),
|
||||
"#address-cells" -> Seq(ResourceInt(0)))
|
||||
Description(name, mapping ++ extra)
|
||||
}
|
||||
}
|
||||
|
||||
val node = TLRegisterNode(
|
||||
address = AddressSet(address, PLICConsts.size-1),
|
||||
device = device,
|
||||
beatBytes = p(XLen)/8,
|
||||
undefZero = false)
|
||||
|
||||
val intnode = IntNexusNode(
|
||||
numSourcePorts = 0 to 1024,
|
||||
numSinkPorts = 0 to 1024,
|
||||
sourceFn = { _ => IntSourcePortParameters(Seq(IntSourceParameters(contextsPerHart))) },
|
||||
sourceFn = { _ => IntSourcePortParameters(Seq(IntSourceParameters(contextsPerHart, Seq(Resource(device, "int"))))) },
|
||||
sinkFn = { _ => IntSinkPortParameters(Seq(IntSinkParameters())) })
|
||||
|
||||
/* Negotiated sizes */
|
||||
def nDevices = intnode.edgesIn.map(_.source.num).sum
|
||||
def nDevices: Int = intnode.edgesIn.map(_.source.num).sum
|
||||
def nPriorities = min(maxPriorities, nDevices)
|
||||
def nHarts = intnode.edgesOut.map(_.source.num).sum
|
||||
|
||||
@ -106,6 +121,19 @@ class TLPLIC(supervisor: Boolean, maxPriorities: Int, address: BigInt = 0xC00000
|
||||
s" };\n")).mkString
|
||||
}
|
||||
|
||||
// Assign all the devices unique ranges
|
||||
lazy val sources = intnode.edgesIn.map(_.source)
|
||||
lazy val flatSources = (sources zip sources.map(_.num).scanLeft(0)(_+_).init).map {
|
||||
case (s, o) => s.sources.map(z => z.copy(range = z.range.offset(o)))
|
||||
}.flatten
|
||||
|
||||
ResourceBinding {
|
||||
flatSources.foreach { s => s.resources.foreach { r =>
|
||||
// +1 because interrupt 0 is reserved
|
||||
(s.range.start until s.range.end).foreach { i => r.bind(device, ResourceInt(i+1)) }
|
||||
} }
|
||||
}
|
||||
|
||||
lazy val module = new LazyModuleImp(this) {
|
||||
val io = new Bundle {
|
||||
val tl_in = node.bundleIn
|
||||
@ -113,11 +141,6 @@ class TLPLIC(supervisor: Boolean, maxPriorities: Int, address: BigInt = 0xC00000
|
||||
val harts = intnode.bundleOut
|
||||
}
|
||||
|
||||
// Assign all the devices unique ranges
|
||||
val sources = intnode.edgesIn.map(_.source)
|
||||
val flatSources = (sources zip sources.map(_.num).scanLeft(0)(_+_).init).map {
|
||||
case (s, o) => s.sources.map(z => z.copy(range = z.range.offset(o)))
|
||||
}.flatten
|
||||
// Compact the interrupt vector the same way
|
||||
val interrupts = (intnode.edgesIn zip io.devices).map { case (e, i) => i.take(e.source.num) }.flatten
|
||||
// This flattens the harts into an MSMSMSMSMS... or MMMMM.... sequence
|
||||
|
@ -83,8 +83,9 @@ trait CoreplexLocalInterrupterModule extends Module with HasRegMap with MixCorep
|
||||
|
||||
/** Power, Reset, Clock, Interrupt */
|
||||
// Magic TL2 Incantation to create a TL2 Slave
|
||||
// prci0 => at most 4095 devices
|
||||
class CoreplexLocalInterrupter(address: BigInt = 0x02000000)(implicit p: Parameters)
|
||||
extends TLRegisterRouter(address, size = ClintConsts.size, beatBytes = p(XLen)/8, undefZero = true)(
|
||||
extends TLRegisterRouter(address, "clint", Seq("riscv,clint0"), size = ClintConsts.size, beatBytes = p(XLen)/8, undefZero = true)(
|
||||
new TLRegBundle((), _) with CoreplexLocalInterrupterBundle)(
|
||||
new TLRegModule((), _, _) with CoreplexLocalInterrupterModule)
|
||||
{
|
||||
|
@ -14,8 +14,11 @@ import config._
|
||||
|
||||
class TLROM(val base: BigInt, val size: Int, contentsDelayed: => Seq[Byte], executable: Boolean = true, beatBytes: Int = 4)(implicit p: Parameters) extends LazyModule
|
||||
{
|
||||
val device = new SimpleDevice("rom", Nil)
|
||||
|
||||
val node = TLManagerNode(beatBytes, TLManagerParameters(
|
||||
address = List(AddressSet(base, size-1)),
|
||||
resources = device.reg,
|
||||
regionType = RegionType.UNCACHED,
|
||||
executable = executable,
|
||||
supportsGet = TransferSizes(1, beatBytes),
|
||||
|
Reference in New Issue
Block a user