2014-09-13 00:31:38 +02:00
|
|
|
// See LICENSE for license details.
|
|
|
|
|
2012-09-27 21:59:45 +02:00
|
|
|
package uncore
|
2012-04-03 21:03:05 +02:00
|
|
|
import Chisel._
|
2015-10-22 03:16:44 +02:00
|
|
|
import cde.{Parameters, Field}
|
2012-04-03 21:03:05 +02:00
|
|
|
|
2014-08-08 21:21:57 +02:00
|
|
|
case object NReleaseTransactors extends Field[Int]
|
2014-12-16 04:23:13 +01:00
|
|
|
case object NProbeTransactors extends Field[Int]
|
2014-08-08 21:21:57 +02:00
|
|
|
case object NAcquireTransactors extends Field[Int]
|
2014-04-27 04:11:36 +02:00
|
|
|
|
2015-10-14 08:42:28 +02:00
|
|
|
/** Identifies the TLId of the inner network in a hierarchical cache controller */
|
|
|
|
case object InnerTLId extends Field[String]
|
|
|
|
/** Identifies the TLId of the outer network in a hierarchical cache controller */
|
|
|
|
case object OuterTLId extends Field[String]
|
|
|
|
|
2015-10-06 06:41:46 +02:00
|
|
|
trait HasCoherenceAgentParameters {
|
|
|
|
implicit val p: Parameters
|
2014-11-12 21:55:07 +01:00
|
|
|
val nReleaseTransactors = 1
|
2015-10-06 06:41:46 +02:00
|
|
|
val nAcquireTransactors = p(NAcquireTransactors)
|
2014-08-12 03:35:49 +02:00
|
|
|
val nTransactors = nReleaseTransactors + nAcquireTransactors
|
2015-10-14 08:42:28 +02:00
|
|
|
val outerTLId = p(OuterTLId)
|
|
|
|
val outerTLParams = p(TLKey(outerTLId))
|
|
|
|
val outerDataBeats = outerTLParams.dataBeats
|
2015-10-21 20:31:13 +02:00
|
|
|
val outerDataBits = outerTLParams.dataBitsPerBeat
|
2015-03-11 23:43:41 +01:00
|
|
|
val outerBeatAddrBits = log2Up(outerDataBeats)
|
|
|
|
val outerByteAddrBits = log2Up(outerDataBits/8)
|
2015-10-14 08:42:28 +02:00
|
|
|
val outerWriteMaskBits = outerTLParams.writeMaskBits
|
|
|
|
val innerTLId = p(InnerTLId)
|
|
|
|
val innerTLParams = p(TLKey(innerTLId))
|
|
|
|
val innerDataBeats = innerTLParams.dataBeats
|
2015-10-21 20:31:13 +02:00
|
|
|
val innerDataBits = innerTLParams.dataBitsPerBeat
|
2015-10-14 08:42:28 +02:00
|
|
|
val innerWriteMaskBits = innerTLParams.writeMaskBits
|
2015-03-01 02:02:13 +01:00
|
|
|
val innerBeatAddrBits = log2Up(innerDataBeats)
|
|
|
|
val innerByteAddrBits = log2Up(innerDataBits/8)
|
2016-01-15 07:01:42 +01:00
|
|
|
val maxManagerXacts = innerTLParams.maxManagerXacts
|
2015-10-14 08:42:28 +02:00
|
|
|
require(outerDataBeats == innerDataBeats) //TODO: fix all xact_data Vecs to remove this requirement
|
2014-08-12 03:35:49 +02:00
|
|
|
}
|
2015-04-20 07:06:44 +02:00
|
|
|
|
2015-10-06 06:41:46 +02:00
|
|
|
abstract class CoherenceAgentModule(implicit val p: Parameters) extends Module
|
|
|
|
with HasCoherenceAgentParameters
|
|
|
|
abstract class CoherenceAgentBundle(implicit val p: Parameters) extends junctions.ParameterizedBundle()(p)
|
|
|
|
with HasCoherenceAgentParameters
|
2015-03-01 02:02:13 +01:00
|
|
|
|
|
|
|
trait HasCoherenceAgentWiringHelpers {
|
2015-04-18 01:55:20 +02:00
|
|
|
def doOutputArbitration[T <: TileLinkChannel](
|
|
|
|
out: DecoupledIO[T],
|
|
|
|
ins: Seq[DecoupledIO[T]]) {
|
|
|
|
def lock(o: T) = o.hasMultibeatData()
|
2015-07-16 03:06:27 +02:00
|
|
|
val arb = Module(new LockingRRArbiter(out.bits, ins.size, out.bits.tlDataBeats, lock _))
|
2015-03-01 02:02:13 +01:00
|
|
|
out <> arb.io.out
|
2015-04-18 01:55:20 +02:00
|
|
|
arb.io.in <> ins
|
2014-12-12 10:11:08 +01:00
|
|
|
}
|
2013-01-17 08:57:35 +01:00
|
|
|
|
2015-10-06 06:41:46 +02:00
|
|
|
def doInputRouting[T <: Bundle with HasManagerTransactionId](
|
2015-04-18 01:55:20 +02:00
|
|
|
in: DecoupledIO[T],
|
|
|
|
outs: Seq[DecoupledIO[T]]) {
|
|
|
|
val idx = in.bits.manager_xact_id
|
2015-03-01 02:02:13 +01:00
|
|
|
outs.map(_.bits := in.bits)
|
|
|
|
outs.zipWithIndex.map { case (o,i) => o.valid := in.valid && idx === UInt(i) }
|
|
|
|
in.ready := Vec(outs.map(_.ready)).read(idx)
|
2014-11-12 21:55:07 +01:00
|
|
|
}
|
2016-03-07 08:12:16 +01:00
|
|
|
|
|
|
|
/** Broadcasts valid messages on this channel to all trackers,
|
|
|
|
* but includes logic to allocate a new tracker in the case where
|
|
|
|
* no previously allocated tracker matches the new req's addr.
|
|
|
|
*
|
|
|
|
* When a match is reported, if ready is high the new transaction
|
|
|
|
* is merged; when ready is low the transaction is being blocked.
|
|
|
|
* When no match is reported, any high readys are presumed to be
|
|
|
|
* from trackers that are available for allocation, and one is
|
|
|
|
* assigned via alloc based on priority; f no readys are high then
|
|
|
|
* all trackers are busy with other transactions.
|
|
|
|
*/
|
|
|
|
def doInputRoutingWithAllocation[T <: TileLinkChannel with HasTileLinkData](
|
|
|
|
in: DecoupledIO[T],
|
|
|
|
outs: Seq[DecoupledIO[T]],
|
|
|
|
matches: Seq[Bool],
|
|
|
|
allocs: Seq[Bool],
|
|
|
|
dataOverrides: Option[Seq[UInt]] = None,
|
|
|
|
allocOverride: Option[Bool] = None) {
|
|
|
|
val ready_bits = Vec(outs.map(_.ready)).toBits
|
|
|
|
val alloc_bits = PriorityEncoderOH(ready_bits)
|
|
|
|
val match_bits = Vec(matches).toBits
|
|
|
|
val no_matches = !match_bits.orR
|
|
|
|
val do_alloc = allocOverride.getOrElse(Bool(true))
|
|
|
|
in.ready := Mux(no_matches, ready_bits.orR, (match_bits & ready_bits).orR) && do_alloc
|
|
|
|
outs.zip(allocs).zipWithIndex.foreach { case((out, a), i) =>
|
|
|
|
out.valid := in.valid
|
|
|
|
out.bits := in.bits
|
|
|
|
dataOverrides foreach { d => out.bits.data := d(i) }
|
|
|
|
a := alloc_bits(i) & no_matches & do_alloc
|
|
|
|
}
|
|
|
|
}
|
2013-01-17 08:57:35 +01:00
|
|
|
}
|
|
|
|
|
2015-10-06 06:41:46 +02:00
|
|
|
trait HasInnerTLIO extends HasCoherenceAgentParameters {
|
2015-10-22 03:16:44 +02:00
|
|
|
val inner = new ManagerTileLinkIO()(p.alterPartial({case TLId => p(InnerTLId)}))
|
2016-01-14 22:47:47 +01:00
|
|
|
val incoherent = Vec(inner.tlNCachingClients, Bool()).asInput
|
2015-04-18 01:55:20 +02:00
|
|
|
def iacq(dummy: Int = 0) = inner.acquire.bits
|
|
|
|
def iprb(dummy: Int = 0) = inner.probe.bits
|
|
|
|
def irel(dummy: Int = 0) = inner.release.bits
|
|
|
|
def ignt(dummy: Int = 0) = inner.grant.bits
|
|
|
|
def ifin(dummy: Int = 0) = inner.finish.bits
|
2013-01-29 01:39:45 +01:00
|
|
|
}
|
|
|
|
|
2015-10-06 06:41:46 +02:00
|
|
|
trait HasUncachedOuterTLIO extends HasCoherenceAgentParameters {
|
2015-10-22 03:16:44 +02:00
|
|
|
val outer = new ClientUncachedTileLinkIO()(p.alterPartial({case TLId => p(OuterTLId)}))
|
2015-03-24 10:06:53 +01:00
|
|
|
def oacq(dummy: Int = 0) = outer.acquire.bits
|
|
|
|
def ognt(dummy: Int = 0) = outer.grant.bits
|
2013-01-29 01:39:45 +01:00
|
|
|
}
|
2013-01-17 08:57:35 +01:00
|
|
|
|
2015-10-06 06:41:46 +02:00
|
|
|
trait HasCachedOuterTLIO extends HasCoherenceAgentParameters {
|
2015-10-22 03:16:44 +02:00
|
|
|
val outer = new ClientTileLinkIO()(p.alterPartial({case TLId => p(OuterTLId)}))
|
2015-03-24 10:06:53 +01:00
|
|
|
def oacq(dummy: Int = 0) = outer.acquire.bits
|
|
|
|
def oprb(dummy: Int = 0) = outer.probe.bits
|
|
|
|
def orel(dummy: Int = 0) = outer.release.bits
|
|
|
|
def ognt(dummy: Int = 0) = outer.grant.bits
|
2015-03-01 02:02:13 +01:00
|
|
|
}
|
2014-03-29 18:53:49 +01:00
|
|
|
|
2015-10-06 06:41:46 +02:00
|
|
|
class ManagerTLIO(implicit p: Parameters) extends CoherenceAgentBundle()(p)
|
|
|
|
with HasInnerTLIO
|
|
|
|
with HasUncachedOuterTLIO
|
2013-01-17 08:57:35 +01:00
|
|
|
|
2015-10-06 06:41:46 +02:00
|
|
|
abstract class CoherenceAgent(implicit p: Parameters) extends CoherenceAgentModule()(p) {
|
2015-04-18 01:55:20 +02:00
|
|
|
def innerTL: ManagerTileLinkIO
|
|
|
|
def outerTL: ClientTileLinkIO
|
2015-03-01 02:02:13 +01:00
|
|
|
def incoherent: Vec[Bool]
|
|
|
|
}
|
2014-12-12 10:11:08 +01:00
|
|
|
|
2015-10-06 06:41:46 +02:00
|
|
|
abstract class ManagerCoherenceAgent(implicit p: Parameters) extends CoherenceAgent()(p)
|
2015-03-01 02:02:13 +01:00
|
|
|
with HasCoherenceAgentWiringHelpers {
|
|
|
|
val io = new ManagerTLIO
|
|
|
|
def innerTL = io.inner
|
2015-11-09 20:10:02 +01:00
|
|
|
lazy val outerTL = TileLinkIOWrapper(io.outer)(p.alterPartial({case TLId => p(OuterTLId)}))
|
2015-03-01 02:02:13 +01:00
|
|
|
def incoherent = io.incoherent
|
|
|
|
}
|
2014-03-29 18:53:49 +01:00
|
|
|
|
2015-10-06 06:41:46 +02:00
|
|
|
class HierarchicalTLIO(implicit p: Parameters) extends CoherenceAgentBundle()(p)
|
|
|
|
with HasInnerTLIO
|
|
|
|
with HasCachedOuterTLIO
|
2014-03-29 18:53:49 +01:00
|
|
|
|
2015-10-06 06:41:46 +02:00
|
|
|
abstract class HierarchicalCoherenceAgent(implicit p: Parameters) extends CoherenceAgent()(p) {
|
2015-03-01 02:02:13 +01:00
|
|
|
val io = new HierarchicalTLIO
|
|
|
|
def innerTL = io.inner
|
|
|
|
def outerTL = io.outer
|
|
|
|
def incoherent = io.incoherent
|
|
|
|
}
|
2014-03-29 18:53:49 +01:00
|
|
|
|
2016-03-07 08:12:16 +01:00
|
|
|
trait HasTrackerAllocationIO extends Bundle {
|
|
|
|
val matches = new Bundle {
|
|
|
|
val iacq = Bool(OUTPUT)
|
|
|
|
val irel = Bool(OUTPUT)
|
|
|
|
val oprb = Bool(OUTPUT)
|
|
|
|
}
|
|
|
|
val alloc = new Bundle {
|
|
|
|
val iacq = Bool(INPUT)
|
|
|
|
val irel = Bool(INPUT)
|
|
|
|
val oprb = Bool(INPUT)
|
|
|
|
}
|
2015-03-01 02:02:13 +01:00
|
|
|
}
|
2014-03-29 18:53:49 +01:00
|
|
|
|
2015-10-06 06:41:46 +02:00
|
|
|
class ManagerXactTrackerIO(implicit p: Parameters) extends ManagerTLIO()(p)
|
2016-03-07 08:12:16 +01:00
|
|
|
with HasTrackerAllocationIO
|
2013-01-17 08:57:35 +01:00
|
|
|
|
2015-10-06 06:41:46 +02:00
|
|
|
class HierarchicalXactTrackerIO(implicit p: Parameters) extends HierarchicalTLIO()(p)
|
2016-03-07 08:12:16 +01:00
|
|
|
with HasTrackerAllocationIO
|
2015-10-06 06:41:46 +02:00
|
|
|
|
|
|
|
abstract class XactTracker(implicit p: Parameters) extends CoherenceAgentModule()(p)
|
|
|
|
with HasDataBeatCounters {
|
2015-04-04 02:24:44 +02:00
|
|
|
def addPendingBitWhenBeat[T <: HasBeat](inc: Bool, in: T): UInt =
|
|
|
|
Fill(in.tlDataBeats, inc) & UIntToOH(in.addr_beat)
|
2016-03-07 08:12:16 +01:00
|
|
|
|
2015-04-04 02:24:44 +02:00
|
|
|
def dropPendingBitWhenBeat[T <: HasBeat](dec: Bool, in: T): UInt =
|
|
|
|
~Fill(in.tlDataBeats, dec) | ~UIntToOH(in.addr_beat)
|
2015-03-24 10:06:53 +01:00
|
|
|
|
2016-03-07 08:12:16 +01:00
|
|
|
def addPendingBitWhenId[T <: HasClientId](inc: Bool, in: T): UInt =
|
|
|
|
Fill(in.tlNCachingClients, inc) & UIntToOH(in.client_id)
|
|
|
|
|
|
|
|
def dropPendingBitWhenId[T <: HasClientId](dec: Bool, in: T): UInt =
|
|
|
|
~Fill(in.tlNCachingClients, dec) | ~UIntToOH(in.client_id)
|
|
|
|
|
2015-11-16 22:23:17 +01:00
|
|
|
def addPendingBitWhenBeatHasData[T <: HasBeat](in: DecoupledIO[T], inc: Bool = Bool(true)): UInt =
|
|
|
|
addPendingBitWhenBeat(in.fire() && in.bits.hasData() && inc, in.bits)
|
2015-03-18 01:51:00 +01:00
|
|
|
|
2015-05-13 02:14:06 +02:00
|
|
|
def addPendingBitWhenBeatHasDataAndAllocs(in: DecoupledIO[AcquireFromSrc]): UInt =
|
2015-11-16 22:23:17 +01:00
|
|
|
addPendingBitWhenBeatHasData(in, in.bits.allocate())
|
2015-05-13 02:14:06 +02:00
|
|
|
|
2015-04-18 01:55:20 +02:00
|
|
|
def addPendingBitWhenBeatIsGetOrAtomic(in: DecoupledIO[AcquireFromSrc]): UInt = {
|
|
|
|
val a = in.bits
|
2015-03-24 10:06:53 +01:00
|
|
|
val isGetOrAtomic = a.isBuiltInType() &&
|
2015-04-18 01:55:20 +02:00
|
|
|
(Vec(Acquire.getType, Acquire.getBlockType, Acquire.putAtomicType).contains(a.a_type))
|
|
|
|
addPendingBitWhenBeat(in.fire() && isGetOrAtomic, a)
|
2015-03-18 01:51:00 +01:00
|
|
|
}
|
2015-03-18 04:28:06 +01:00
|
|
|
|
2015-11-16 22:23:17 +01:00
|
|
|
def addPendingBitsFromAcquire(a: SecondaryMissInfo): UInt =
|
|
|
|
Mux(a.hasMultibeatData(), Fill(a.tlDataBeats, UInt(1, 1)), UIntToOH(a.addr_beat))
|
|
|
|
|
2015-04-18 01:55:20 +02:00
|
|
|
def dropPendingBitWhenBeatHasData[T <: HasBeat](in: DecoupledIO[T]): UInt =
|
|
|
|
dropPendingBitWhenBeat(in.fire() && in.bits.hasData(), in.bits)
|
2015-03-19 01:55:05 +01:00
|
|
|
|
2016-03-07 08:12:16 +01:00
|
|
|
def dropPendingBitAtDest[T <: HasId](in: DecoupledIO[T]): UInt =
|
|
|
|
dropPendingBitWhenId(in.fire(), in.bits)
|
|
|
|
|
|
|
|
def dropPendingBitAtDestWhenVoluntary[T <: HasId with MightBeVoluntary](in: DecoupledIO[T]): UInt =
|
|
|
|
dropPendingBitWhenId(in.fire() && in.bits.isVoluntary(), in.bits)
|
|
|
|
|
|
|
|
def addPendingBitAtSrc[T <: HasId](in: DecoupledIO[T]): UInt =
|
|
|
|
addPendingBitWhenId(in.fire(), in.bits)
|
|
|
|
|
|
|
|
def addPendingBitAtSrcWhenVoluntary[T <: HasId with MightBeVoluntary](in: DecoupledIO[T]): UInt =
|
|
|
|
addPendingBitWhenId(in.fire() && in.bits.isVoluntary(), in.bits)
|
2016-02-10 20:12:43 +01:00
|
|
|
|
|
|
|
def pinAllReadyValidLow[T <: Data](b: Bundle) {
|
|
|
|
b.elements.foreach {
|
|
|
|
_._2 match {
|
|
|
|
case d: DecoupledIO[_] =>
|
|
|
|
if(d.ready.dir == OUTPUT) d.ready := Bool(false)
|
|
|
|
else if(d.valid.dir == OUTPUT) d.valid := Bool(false)
|
|
|
|
case v: ValidIO[_] => if(v.valid.dir == OUTPUT) v.valid := Bool(false)
|
|
|
|
case b: Bundle => pinAllReadyValidLow(b)
|
|
|
|
case _ =>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-01-17 08:57:35 +01:00
|
|
|
}
|