From e6c2d446ccf85a409969e8b298fa5c6baca4ff4a Mon Sep 17 00:00:00 2001 From: "Wesley W. Terpstra" Date: Wed, 28 Jun 2017 14:45:46 -0700 Subject: [PATCH] rocket: link dtim to its cpu --- src/main/scala/rocket/RocketTiles.scala | 3 +++ src/main/scala/rocket/ScratchpadSlavePort.scala | 14 +++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/scala/rocket/RocketTiles.scala b/src/main/scala/rocket/RocketTiles.scala index a393cb15..4e5fccad 100644 --- a/src/main/scala/rocket/RocketTiles.scala +++ b/src/main/scala/rocket/RocketTiles.scala @@ -89,6 +89,9 @@ class RocketTile(val rocketParams: RocketTileParams, val hartid: Int)(implicit p ++ dcache ++ icache ++ nextlevel ++ mmu ++ itlb ++ dtlb) } } + + override def dtimOwner = Some(cpuDevice) + val intcDevice = new Device { def describe(resources: ResourceBindings): Description = { Description(s"cpus/cpu@${hartid}/interrupt-controller", Map( diff --git a/src/main/scala/rocket/ScratchpadSlavePort.scala b/src/main/scala/rocket/ScratchpadSlavePort.scala index 667cc157..12035ee8 100644 --- a/src/main/scala/rocket/ScratchpadSlavePort.scala +++ b/src/main/scala/rocket/ScratchpadSlavePort.scala @@ -13,9 +13,16 @@ import uncore.tilelink2._ import uncore.util._ import util._ -class ScratchpadSlavePort(address: AddressSet)(implicit p: Parameters) extends LazyModule +class ScratchpadSlavePort(address: AddressSet, owner: => Option[Device] = None)(implicit p: Parameters) extends LazyModule with HasCoreParameters { - val device = new SimpleDevice("dtim", Seq("sifive,dtim0")) + val device = new SimpleDevice("dtim", Seq("sifive,dtim0")) { + override def describe(resources: ResourceBindings): Description = { + val extra = owner.map(x => ("sifive,cpu" -> Seq(ResourceReference(x.label)))) + val Description(name, mapping) = super.describe(resources) + Description(name, mapping ++ extra) + } + } + val node = TLManagerNode(Seq(TLManagerPortParameters( Seq(TLManagerParameters( address = List(address), @@ -102,6 +109,7 @@ trait CanHaveScratchpad extends HasHellaCache with HasICacheFrontend with HasCor val module: CanHaveScratchpadModule val slaveNode = TLInputNode() // Up to two uses for this input node: + def dtimOwner: Option[Device] = None // who owns the Scratchpad? // 1) Frontend always exists, but may or may not have a scratchpad node val fg = LazyModule(new TLFragmenter(fetchWidth*coreInstBytes, p(CacheBlockBytes), earlyAck=true)) @@ -112,7 +120,7 @@ trait CanHaveScratchpad extends HasHellaCache with HasICacheFrontend with HasCor // 2) ScratchpadSlavePort always has a node, but only exists when the HellaCache has a scratchpad val scratch = tileParams.dcache.flatMap(d => d.scratch.map(s => - LazyModule(new ScratchpadSlavePort(AddressSet(s, d.dataScratchpadBytes-1))))) + LazyModule(new ScratchpadSlavePort(AddressSet(s, d.dataScratchpadBytes-1), dtimOwner)))) scratch foreach { lm => lm.node := TLFragmenter(xLen/8, p(CacheBlockBytes), earlyAck=true)(slaveNode) } def findScratchpadFromICache: Option[AddressSet] = scratch.map { s =>