From 149d51d644d1ffb0ae7914d512f0c7b41951ff71 Mon Sep 17 00:00:00 2001 From: Henry Cook Date: Thu, 10 Jul 2014 17:10:32 -0700 Subject: [PATCH] more coherence API cleanup --- uncore/src/main/scala/cache.scala | 11 +-- uncore/src/main/scala/coherence.scala | 102 ++++++++++++++------------ uncore/src/main/scala/uncore.scala | 8 +- 3 files changed, 63 insertions(+), 58 deletions(-) diff --git a/uncore/src/main/scala/cache.scala b/uncore/src/main/scala/cache.scala index 686f0ac1..faa879a9 100644 --- a/uncore/src/main/scala/cache.scala +++ b/uncore/src/main/scala/cache.scala @@ -376,7 +376,7 @@ class L2VoluntaryReleaseTracker(trackerId: Int, bankId: Int) extends L2XactTrack io.inner.grant.valid := Bool(false) io.inner.grant.bits.header.src := UInt(bankId) io.inner.grant.bits.header.dst := init_client_id - io.inner.grant.bits.payload := Grant(co.getGrantType(xact, UInt(0)), + io.inner.grant.bits.payload := Grant(co.getGrantType(xact, conf.tl.co.masterMetadataOnFlush),// TODO xact_internal.meta) xact.client_xact_id, UInt(trackerId)) @@ -454,11 +454,12 @@ class L2AcquireTracker(trackerId: Int, bankId: Int) extends L2XactTracker { io.inner.probe.valid := Bool(false) io.inner.probe.bits.header.src := UInt(bankId) io.inner.probe.bits.header.dst := curr_p_id - io.inner.probe.bits.payload := Probe(co.getProbeType(xact.a_type, co.masterMetadataOnFlush), - xact.addr, - UInt(trackerId)) + io.inner.probe.bits.payload := Probe(co.getProbeType(xact, /*xact_internal.meta), TODO*/ + co.masterMetadataOnFlush), + xact.addr, + UInt(trackerId)) - val grant_type = co.getGrantType(xact.a_type, init_sharer_cnt) + val grant_type = co.getGrantType(xact, conf.tl.co.masterMetadataOnFlush)// TODO xact_internal.meta) io.inner.grant.valid := Bool(false) io.inner.grant.bits.header.src := UInt(bankId) io.inner.grant.bits.header.dst := init_client_id diff --git a/uncore/src/main/scala/coherence.scala b/uncore/src/main/scala/coherence.scala index abacdabd..bd6fecc3 100644 --- a/uncore/src/main/scala/coherence.scala +++ b/uncore/src/main/scala/coherence.scala @@ -28,7 +28,7 @@ object MasterMetadata { def apply(state: UInt)(implicit c: CoherencePolicy): MasterMetadata = { val m = new MasterMetadata m.state := state - m.sharers := m.sharers.flush() + m.sharers.flush() m } def apply(state: UInt, sharers: DirectoryRepresentation)(implicit c: CoherencePolicy): MasterMetadata = { @@ -51,32 +51,36 @@ class MixedMetadata(inner: CoherencePolicy, outer: CoherencePolicy) extends Cohe */ abstract class DirectoryRepresentation extends Bundle { - val sharers: UInt + val internal: UInt def pop(id: UInt): DirectoryRepresentation def push(id: UInt): DirectoryRepresentation def flush(dummy: Int = 0): DirectoryRepresentation def none(dummy: Int = 0): Bool def one(dummy: Int = 0): Bool + def count(dummy: Int = 0): UInt + def next(dummy: Int = 0): UInt } class NullRepresentation extends DirectoryRepresentation { - val sharers = UInt(0) + val internal = UInt(0) def pop(id: UInt) = this def push(id: UInt) = this def flush(dummy: Int = 0) = this def none(dummy: Int = 0) = Bool(false) def one(dummy: Int = 0) = Bool(false) + def count(dummy: Int = 0) = UInt(0) + def next(dummy: Int = 0) = UInt(0) } class FullRepresentation(nClients: Int) extends DirectoryRepresentation { - val sharers = UInt(width = nClients) - def pop(id: UInt) = { sharers := sharers & ~UIntToOH(id); this } - def push(id: UInt) = { sharers := sharers | UIntToOH(id); this } - def flush(dummy: Int = 0) = { sharers := UInt(0, width = nClients); this } - def none(dummy: Int = 0) = sharers === UInt(0) - def one(dummy: Int = 0) = PopCount(sharers) === UInt(1) - def count(dummy: Int = 0) = PopCount(sharers) - def next(dummy: Int = 0) = PriorityEncoder(sharers) + val internal = UInt(width = nClients) + def pop(id: UInt) = { internal := internal & ~UIntToOH(id); this } + def push(id: UInt) = { internal := internal | UIntToOH(id); this } + def flush(dummy: Int = 0) = { internal := UInt(0, width = nClients); this } + def none(dummy: Int = 0) = internal === UInt(0) + def one(dummy: Int = 0) = PopCount(internal) === UInt(1) + def count(dummy: Int = 0) = PopCount(internal) + def next(dummy: Int = 0) = PriorityEncoder(internal) override def clone = new FullRepresentation(nClients).asInstanceOf[this.type] } @@ -113,12 +117,14 @@ abstract class CoherencePolicy(val dir: () => DirectoryRepresentation) { def getAcquireTypeOnPrimaryMiss(cmd: UInt, m: ClientMetadata): UInt def getAcquireTypeOnSecondaryMiss(cmd: UInt, m: ClientMetadata, outstanding: Acquire): UInt - def getProbeType(a_type: UInt, m: MasterMetadata): UInt + def getProbeType(a: Acquire, m: MasterMetadata): UInt def getReleaseTypeOnCacheControl(cmd: UInt): UInt def getReleaseTypeOnVoluntaryWriteback(): UInt - def getReleaseTypeOnProbe(incoming: Probe, m: ClientMetadata): UInt - def getGrantType(a_type: UInt, count: UInt): UInt - def getGrantType(rel: Release, count: UInt): UInt + def getReleaseTypeOnProbe(p: Probe, m: ClientMetadata): UInt + def getGrantType(a: Acquire, m: MasterMetadata): UInt + def getGrantType(r: Release, m: MasterMetadata): UInt + //def getGrantType(a: Acquire) = getGrantType(a, new NullRepresentation) // TODO + //def getGrantType(r: Release) = getGrantType(r, new NullRepresentation) def messageHasData (rel: SourcedMessage): Bool def messageUpdatesDataArray (reply: Grant): Bool @@ -259,8 +265,8 @@ class MICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicyWit def isCoherenceConflict(addr1: UInt, addr2: UInt): Bool = (addr1 === addr2) - def getGrantType(a_type: UInt, count: UInt): UInt = { - MuxLookup(a_type, grantReadUncached, Array( + def getGrantType(a: Acquire, m: MasterMetadata): UInt = { + MuxLookup(a.a_type, grantReadUncached, Array( acquireReadExclusive -> grantReadExclusive, acquireReadUncached -> grantReadUncached, acquireWriteUncached -> grantWriteUncached, @@ -270,14 +276,14 @@ class MICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicyWit )) } - def getGrantType(rel: Release, count: UInt): UInt = { - MuxLookup(rel.r_type, grantReadUncached, Array( + def getGrantType(r: Release, m: MasterMetadata): UInt = { + MuxLookup(r.r_type, grantReadUncached, Array( releaseVoluntaryInvalidateData -> grantVoluntaryAck )) } - def getProbeType(a_type: UInt, m: MasterMetadata): UInt = { - MuxLookup(a_type, probeCopy, Array( + def getProbeType(a: Acquire, m: MasterMetadata): UInt = { + MuxLookup(a.a_type, probeCopy, Array( acquireReadExclusive -> probeInvalidate, acquireReadUncached -> probeCopy, acquireWriteUncached -> probeInvalidate, @@ -427,8 +433,8 @@ class MEICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicyWi def isCoherenceConflict(addr1: UInt, addr2: UInt): Bool = (addr1 === addr2) - def getGrantType(a_type: UInt, count: UInt): UInt = { - MuxLookup(a_type, grantReadUncached, Array( + def getGrantType(a: Acquire, m: MasterMetadata): UInt = { + MuxLookup(a.a_type, grantReadUncached, Array( acquireReadExclusiveClean -> grantReadExclusive, acquireReadExclusiveDirty -> grantReadExclusive, acquireReadUncached -> grantReadUncached, @@ -438,15 +444,15 @@ class MEICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicyWi acquireAtomicUncached -> grantAtomicUncached )) } - def getGrantType(rel: Release, count: UInt): UInt = { - MuxLookup(rel.r_type, grantReadUncached, Array( + def getGrantType(r: Release, m: MasterMetadata): UInt = { + MuxLookup(r.r_type, grantReadUncached, Array( releaseVoluntaryInvalidateData -> grantVoluntaryAck )) } - def getProbeType(a_type: UInt, m: MasterMetadata): UInt = { - MuxLookup(a_type, probeCopy, Array( + def getProbeType(a: Acquire, m: MasterMetadata): UInt = { + MuxLookup(a.a_type, probeCopy, Array( acquireReadExclusiveClean -> probeInvalidate, acquireReadExclusiveDirty -> probeInvalidate, acquireReadUncached -> probeCopy, @@ -604,9 +610,9 @@ class MSICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicyWi def isCoherenceConflict(addr1: UInt, addr2: UInt): Bool = (addr1 === addr2) - def getGrantType(a_type: UInt, count: UInt): UInt = { - MuxLookup(a_type, grantReadUncached, Array( - acquireReadShared -> Mux(count > UInt(0), grantReadShared, grantReadExclusive), + def getGrantType(a: Acquire, m: MasterMetadata): UInt = { + MuxLookup(a.a_type, grantReadUncached, Array( + acquireReadShared -> Mux(m.sharers.count() > UInt(0), grantReadShared, grantReadExclusive), acquireReadExclusive -> grantReadExclusive, acquireReadUncached -> grantReadUncached, acquireWriteUncached -> grantWriteUncached, @@ -615,14 +621,14 @@ class MSICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicyWi acquireAtomicUncached -> grantAtomicUncached )) } - def getGrantType(rel: Release, count: UInt): UInt = { - MuxLookup(rel.r_type, grantReadUncached, Array( + def getGrantType(r: Release, m: MasterMetadata): UInt = { + MuxLookup(r.r_type, grantReadUncached, Array( releaseVoluntaryInvalidateData -> grantVoluntaryAck )) } - def getProbeType(a_type: UInt, m: MasterMetadata): UInt = { - MuxLookup(a_type, probeCopy, Array( + def getProbeType(a: Acquire, m: MasterMetadata): UInt = { + MuxLookup(a.a_type, probeCopy, Array( acquireReadShared -> probeDowngrade, acquireReadExclusive -> probeInvalidate, acquireReadUncached -> probeCopy, @@ -778,9 +784,9 @@ class MESICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicyW def isCoherenceConflict(addr1: UInt, addr2: UInt): Bool = (addr1 === addr2) - def getGrantType(a_type: UInt, count: UInt): UInt = { - MuxLookup(a_type, grantReadUncached, Array( - acquireReadShared -> Mux(count > UInt(0), grantReadShared, grantReadExclusive), + def getGrantType(a: Acquire, m: MasterMetadata): UInt = { + MuxLookup(a.a_type, grantReadUncached, Array( + acquireReadShared -> Mux(m.sharers.count() > UInt(0), grantReadShared, grantReadExclusive), acquireReadExclusive -> grantReadExclusive, acquireReadUncached -> grantReadUncached, acquireWriteUncached -> grantWriteUncached, @@ -789,15 +795,15 @@ class MESICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicyW acquireAtomicUncached -> grantAtomicUncached )) } - def getGrantType(rel: Release, count: UInt): UInt = { - MuxLookup(rel.r_type, grantReadUncached, Array( + def getGrantType(r: Release, m: MasterMetadata): UInt = { + MuxLookup(r.r_type, grantReadUncached, Array( releaseVoluntaryInvalidateData -> grantVoluntaryAck )) } - def getProbeType(a_type: UInt, m: MasterMetadata): UInt = { - MuxLookup(a_type, probeCopy, Array( + def getProbeType(a: Acquire, m: MasterMetadata): UInt = { + MuxLookup(a.a_type, probeCopy, Array( acquireReadShared -> probeDowngrade, acquireReadExclusive -> probeInvalidate, acquireReadUncached -> probeCopy, @@ -975,9 +981,9 @@ class MigratoryCoherence(dir: () => DirectoryRepresentation) extends CoherencePo def isCoherenceConflict(addr1: UInt, addr2: UInt): Bool = (addr1 === addr2) - def getGrantType(a_type: UInt, count: UInt): UInt = { - MuxLookup(a_type, grantReadUncached, Array( - acquireReadShared -> Mux(count > UInt(0), grantReadShared, grantReadExclusive), //TODO: what is count? Depend on release.p_type??? + def getGrantType(a: Acquire, m: MasterMetadata): UInt = { + MuxLookup(a.a_type, grantReadUncached, Array( + acquireReadShared -> Mux(m.sharers.count() > UInt(0), grantReadShared, grantReadExclusive), //TODO: what is count? Depend on release.p_type??? acquireReadExclusive -> grantReadExclusive, acquireReadUncached -> grantReadUncached, acquireWriteUncached -> grantWriteUncached, @@ -987,15 +993,15 @@ class MigratoryCoherence(dir: () => DirectoryRepresentation) extends CoherencePo acquireInvalidateOthers -> grantReadExclusiveAck //TODO: add this to MESI? )) } - def getGrantType(rel: Release, count: UInt): UInt = { - MuxLookup(rel.r_type, grantReadUncached, Array( + def getGrantType(r: Release, m: MasterMetadata): UInt = { + MuxLookup(r.r_type, grantReadUncached, Array( releaseVoluntaryInvalidateData -> grantVoluntaryAck )) } - def getProbeType(a_type: UInt, m: MasterMetadata): UInt = { - MuxLookup(a_type, probeCopy, Array( + def getProbeType(a: Acquire, m: MasterMetadata): UInt = { + MuxLookup(a.a_type, probeCopy, Array( acquireReadShared -> probeDowngrade, acquireReadExclusive -> probeInvalidate, acquireReadUncached -> probeCopy, diff --git a/uncore/src/main/scala/uncore.scala b/uncore/src/main/scala/uncore.scala index 8f1a7a67..2e62d79f 100644 --- a/uncore/src/main/scala/uncore.scala +++ b/uncore/src/main/scala/uncore.scala @@ -130,7 +130,7 @@ class VoluntaryReleaseTracker(trackerId: Int, bankId: Int) extends XactTracker { io.inner.grant.valid := Bool(false) io.inner.grant.bits.header.src := UInt(bankId) io.inner.grant.bits.header.dst := init_client_id - io.inner.grant.bits.payload := Grant(co.getGrantType(xact, UInt(0)), + io.inner.grant.bits.payload := Grant(co.getGrantType(xact, co.masterMetadataOnFlush), xact.client_xact_id, UInt(trackerId)) @@ -161,7 +161,6 @@ class AcquireTracker(trackerId: Int, bankId: Int) extends XactTracker { val init_client_id = Reg(init=UInt(0, width = log2Up(nClients))) //TODO: Will need id reg for merged release xacts - val init_sharer_cnt = Reg(init=UInt(0, width = log2Up(nClients))) val release_count = if (nClients == 1) UInt(0) else Reg(init=UInt(0, width = log2Up(nClients))) val probe_flags = Reg(init=Bits(0, width = nClients)) val curr_p_id = PriorityEncoder(probe_flags) @@ -195,11 +194,11 @@ class AcquireTracker(trackerId: Int, bankId: Int) extends XactTracker { io.inner.probe.valid := Bool(false) io.inner.probe.bits.header.src := UInt(bankId) io.inner.probe.bits.header.dst := curr_p_id - io.inner.probe.bits.payload := Probe(co.getProbeType(xact.a_type, co.masterMetadataOnFlush), + io.inner.probe.bits.payload := Probe(co.getProbeType(xact, co.masterMetadataOnFlush), xact.addr, UInt(trackerId)) - val grant_type = co.getGrantType(xact.a_type, init_sharer_cnt) + val grant_type = co.getGrantType(xact, co.masterMetadataOnFlush) io.inner.grant.valid := Bool(false) io.inner.grant.bits.header.src := UInt(bankId) io.inner.grant.bits.header.dst := init_client_id @@ -219,7 +218,6 @@ class AcquireTracker(trackerId: Int, bankId: Int) extends XactTracker { when( io.inner.acquire.valid ) { xact := c_acq.payload init_client_id := c_acq.header.src - init_sharer_cnt := UInt(nClients) // TODO: Broadcast only probe_flags := probe_initial_flags if(nClients > 1) { release_count := PopCount(probe_initial_flags)