1
0

cleanup DirectoryRepresentation and coherence params

This commit is contained in:
Henry Cook 2014-12-15 19:23:13 -08:00
parent d04da83f96
commit ab39cbb15d
3 changed files with 86 additions and 90 deletions

View File

@ -123,7 +123,7 @@ object L2Metadata {
} }
} }
class L2Metadata extends Metadata with L2HellaCacheParameters { class L2Metadata extends Metadata with L2HellaCacheParameters {
val coh = new MasterMetadata()(co) //co.masterMetadataOnFlush.clone val coh = new MasterMetadata
} }
class L2MetaReadReq extends MetaReadReq with HasL2Id { class L2MetaReadReq extends MetaReadReq with HasL2Id {
@ -524,8 +524,8 @@ class L2AcquireTracker(trackerId: Int, bankId: Int, innerId: String, outerId: St
val (local_data_resp_cnt, local_data_resp_done) = Counter(io.data.resp.valid, tlDataBeats) val (local_data_resp_cnt, local_data_resp_done) = Counter(io.data.resp.valid, tlDataBeats)
val release_count = Reg(init = UInt(0, width = log2Up(nClients+1))) val release_count = Reg(init = UInt(0, width = log2Up(nClients+1)))
val pending_probes = Reg(init = co.dir().flush) val pending_probes = Reg(init = co.dir.flush)
val curr_p_id = co.dir().next(pending_probes) val curr_p_id = co.dir.next(pending_probes)
val needs_writeback = !xact_tag_match && co.needsWriteback(xact_meta.coh) val needs_writeback = !xact_tag_match && co.needsWriteback(xact_meta.coh)
val is_hit = xact_tag_match && co.isHit(xact, xact_meta.coh) val is_hit = xact_tag_match && co.isHit(xact, xact_meta.coh)
@ -645,11 +645,11 @@ class L2AcquireTracker(trackerId: Int, bankId: Int, innerId: String, outerId: St
val _is_hit = _tag_match && co.isHit(xact, coh) val _is_hit = _tag_match && co.isHit(xact, coh)
val _needs_probes = co.requiresProbes(xact, coh) val _needs_probes = co.requiresProbes(xact, coh)
when(_needs_probes) { when(_needs_probes) {
val mask_incoherent = co.dir().full(coh.sharers) & ~io.tile_incoherent val mask_incoherent = co.dir.full(coh.sharers) & ~io.tile_incoherent
val mask_self = mask_incoherent & val mask_self = mask_incoherent &
~(!(co.requiresSelfProbe(xact) || _needs_writeback) << xact_src) ~(!(co.requiresSelfProbe(xact) || _needs_writeback) << xact_src)
pending_probes := mask_self pending_probes := mask_self
release_count := co.dir().count(mask_self) release_count := co.dir.count(mask_self)
crel_had_data := Bool(false) crel_had_data := Bool(false)
crel_was_voluntary := Bool(false) crel_was_voluntary := Bool(false)
} }
@ -663,9 +663,9 @@ class L2AcquireTracker(trackerId: Int, bankId: Int, innerId: String, outerId: St
} }
} }
is(s_probe) { is(s_probe) {
io.inner.probe.valid := !co.dir().none(pending_probes) io.inner.probe.valid := !co.dir.none(pending_probes)
when(io.inner.probe.ready) { when(io.inner.probe.ready) {
pending_probes := co.dir().pop(pending_probes, curr_p_id) pending_probes := co.dir.pop(pending_probes, curr_p_id)
} }
// Handle releases, which may have data being written back // Handle releases, which may have data being written back

View File

@ -3,46 +3,35 @@
package uncore package uncore
import Chisel._ import Chisel._
abstract class CoherenceMetadata extends Bundle abstract class CoherenceMetadata extends Bundle with CoherenceAgentParameters
class ClientMetadata extends CoherenceMetadata {
val state = UInt(width = co.clientStateWidth)
def ===(right: ClientMetadata): Bool = this.state === right.state
override def clone = new ClientMetadata().asInstanceOf[this.type]
}
object ClientMetadata { object ClientMetadata {
def apply(state: UInt)(implicit c: CoherencePolicy) = { def apply(state: UInt) = {
val m = new ClientMetadata val m = new ClientMetadata
m.state := state m.state := state
m m
} }
} }
class ClientMetadata(implicit c: CoherencePolicy) extends CoherenceMetadata {
val state = UInt(width = c.clientStateWidth)
def ===(right: ClientMetadata): Bool = this.state === right.state
override def clone = new ClientMetadata()(c).asInstanceOf[this.type]
}
class MasterMetadata extends CoherenceMetadata {
val state = UInt(width = co.masterStateWidth)
val sharers = UInt(width = co.dir.width)
override def clone = new MasterMetadata().asInstanceOf[this.type]
}
object MasterMetadata { object MasterMetadata {
def apply(state: UInt)(implicit c: CoherencePolicy): MasterMetadata = { def apply(state: UInt, sharers: UInt) = {
val m = new MasterMetadata val m = new MasterMetadata
m.state := state m.state := state
m.sharers := c.dir().flush
m
}
def apply(state: UInt, sharers: UInt)(implicit c: CoherencePolicy): MasterMetadata = {
val m = apply(state)
m.sharers := sharers m.sharers := sharers
m m
} }
def apply(state: UInt): MasterMetadata = apply(state, new MasterMetadata().co.dir.flush)
} }
class MasterMetadata(implicit c: CoherencePolicy) extends CoherenceMetadata {
val state = UInt(width = c.masterStateWidth)
val sharers = UInt(width = c.dir().width)
override def clone = new MasterMetadata()(c).asInstanceOf[this.type]
}
/*
class MixedMetadata(inner: CoherencePolicy, outer: CoherencePolicy) extends CoherenceMetadata {
val cstate = UInt(width = outer.clientStateWidth)
val mstate = UInt(width = inner.masterStateWidth)
val sharers = inner.dir.sharers.clone
}
*/
abstract class DirectoryRepresentation(val width: Int) { abstract class DirectoryRepresentation(val width: Int) {
def pop(prev: UInt, id: UInt): UInt def pop(prev: UInt, id: UInt): UInt
@ -77,7 +66,7 @@ class FullRepresentation(nClients: Int) extends DirectoryRepresentation(nClients
def full(s: UInt) = s def full(s: UInt) = s
} }
abstract class CoherencePolicy(val dir: () => DirectoryRepresentation) { abstract class CoherencePolicy(val dir: DirectoryRepresentation) {
def nClientStates: Int def nClientStates: Int
def nMasterStates: Int def nMasterStates: Int
def nAcquireTypes: Int def nAcquireTypes: Int
@ -143,7 +132,7 @@ abstract class CoherencePolicy(val dir: () => DirectoryRepresentation) {
} }
} }
class MICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicy(dir) { class MICoherence(dir: DirectoryRepresentation) extends CoherencePolicy(dir) {
def nClientStates = 2 def nClientStates = 2
def nMasterStates = 2 def nMasterStates = 2
def nAcquireTypes = 1 def nAcquireTypes = 1
@ -184,18 +173,18 @@ class MICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicy(di
MuxLookup(cmd, clientInvalid, Array( MuxLookup(cmd, clientInvalid, Array(
M_INV -> clientInvalid, M_INV -> clientInvalid,
M_CLN -> clientValid M_CLN -> clientValid
)))(this) )))
def clientMetadataOnFlush = clientMetadataOnCacheControl(M_INV) def clientMetadataOnFlush = clientMetadataOnCacheControl(M_INV)
def clientMetadataOnGrant(incoming: Grant, outstanding: Acquire) = def clientMetadataOnGrant(incoming: Grant, outstanding: Acquire) =
ClientMetadata(Mux(incoming.uncached, clientInvalid, clientValid))(this) ClientMetadata(Mux(incoming.uncached, clientInvalid, clientValid))
def clientMetadataOnProbe(incoming: Probe, m: ClientMetadata) = ClientMetadata( def clientMetadataOnProbe(incoming: Probe, m: ClientMetadata) = ClientMetadata(
MuxLookup(incoming.p_type, m.state, Array( MuxLookup(incoming.p_type, m.state, Array(
probeInvalidate -> clientInvalid, probeInvalidate -> clientInvalid,
probeCopy -> m.state probeCopy -> m.state
)))(this) )))
def masterMetadataOnFlush = MasterMetadata(masterInvalid)(this) def masterMetadataOnFlush = MasterMetadata(masterInvalid)
def masterMetadataOnRelease(r: Release, m: MasterMetadata, src: UInt) = { def masterMetadataOnRelease(r: Release, m: MasterMetadata, src: UInt) = {
val next = MasterMetadata(masterValid, dir().pop(m.sharers, src))(this) val next = MasterMetadata(masterValid, dir.pop(m.sharers, src))
MuxBundle(m, Array( MuxBundle(m, Array(
r.is(releaseVoluntaryInvalidateData) -> next, r.is(releaseVoluntaryInvalidateData) -> next,
r.is(releaseInvalidateData) -> next, r.is(releaseInvalidateData) -> next,
@ -203,8 +192,8 @@ class MICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicy(di
)) ))
} }
def masterMetadataOnGrant(g: Grant, m: MasterMetadata, dst: UInt) = { def masterMetadataOnGrant(g: Grant, m: MasterMetadata, dst: UInt) = {
val cached = MasterMetadata(masterValid, dir().push(m.sharers, dst))(this) val cached = MasterMetadata(masterValid, dir.push(m.sharers, dst))
val uncached = MasterMetadata(masterValid, m.sharers)(this) val uncached = MasterMetadata(masterValid, m.sharers)
Mux(g.uncached, uncached, cached) Mux(g.uncached, uncached, cached)
} }
@ -263,11 +252,11 @@ class MICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicy(di
def requiresAckForGrant(g: Grant) = g.uncached || g.g_type != grantVoluntaryAck def requiresAckForGrant(g: Grant) = g.uncached || g.g_type != grantVoluntaryAck
def requiresAckForRelease(r: Release) = Bool(false) def requiresAckForRelease(r: Release) = Bool(false)
def requiresSelfProbe(a: Acquire) = a.uncached && a.a_type === Acquire.uncachedRead def requiresSelfProbe(a: Acquire) = a.uncached && a.a_type === Acquire.uncachedRead
def requiresProbes(a: Acquire, m: MasterMetadata) = !dir().none(m.sharers) def requiresProbes(a: Acquire, m: MasterMetadata) = !dir.none(m.sharers)
def pendingVoluntaryReleaseIsSufficient(r_type: UInt, p_type: UInt): Bool = (r_type === releaseVoluntaryInvalidateData) def pendingVoluntaryReleaseIsSufficient(r_type: UInt, p_type: UInt): Bool = (r_type === releaseVoluntaryInvalidateData)
} }
class MEICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicy(dir) { class MEICoherence(dir: DirectoryRepresentation) extends CoherencePolicy(dir) {
def nClientStates = 3 def nClientStates = 3
def nMasterStates = 2 def nMasterStates = 2
def nAcquireTypes = 2 def nAcquireTypes = 2
@ -307,27 +296,27 @@ class MEICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicy(d
def needsWriteback(m: MasterMetadata) = isValid(m) def needsWriteback(m: MasterMetadata) = isValid(m)
def clientMetadataOnHit(cmd: UInt, m: ClientMetadata) = def clientMetadataOnHit(cmd: UInt, m: ClientMetadata) =
ClientMetadata(Mux(isWrite(cmd), clientExclusiveDirty, m.state))(this) ClientMetadata(Mux(isWrite(cmd), clientExclusiveDirty, m.state))
def clientMetadataOnCacheControl(cmd: UInt) = ClientMetadata( def clientMetadataOnCacheControl(cmd: UInt) = ClientMetadata(
MuxLookup(cmd, clientInvalid, Array( MuxLookup(cmd, clientInvalid, Array(
M_INV -> clientInvalid, M_INV -> clientInvalid,
M_CLN -> clientExclusiveClean M_CLN -> clientExclusiveClean
)))(this) )))
def clientMetadataOnFlush() = clientMetadataOnCacheControl(M_INV) def clientMetadataOnFlush() = clientMetadataOnCacheControl(M_INV)
def clientMetadataOnGrant(incoming: Grant, outstanding: Acquire) = ClientMetadata( def clientMetadataOnGrant(incoming: Grant, outstanding: Acquire) = ClientMetadata(
Mux(incoming.uncached, clientInvalid, Mux(incoming.uncached, clientInvalid,
Mux(outstanding.a_type === acquireReadExclusiveDirty, clientExclusiveDirty, Mux(outstanding.a_type === acquireReadExclusiveDirty, clientExclusiveDirty,
clientExclusiveClean)))(this) clientExclusiveClean)))
def clientMetadataOnProbe(incoming: Probe, m: ClientMetadata) = ClientMetadata( def clientMetadataOnProbe(incoming: Probe, m: ClientMetadata) = ClientMetadata(
MuxLookup(incoming.p_type, m.state, Array( MuxLookup(incoming.p_type, m.state, Array(
probeInvalidate -> clientInvalid, probeInvalidate -> clientInvalid,
probeDowngrade -> clientExclusiveClean, probeDowngrade -> clientExclusiveClean,
probeCopy -> m.state probeCopy -> m.state
)))(this) )))
def masterMetadataOnFlush = MasterMetadata(masterInvalid)(this) def masterMetadataOnFlush = MasterMetadata(masterInvalid)
def masterMetadataOnRelease(r: Release, m: MasterMetadata, src: UInt) = { def masterMetadataOnRelease(r: Release, m: MasterMetadata, src: UInt) = {
val next = MasterMetadata(masterValid, dir().pop(m.sharers,src))(this) val next = MasterMetadata(masterValid, dir.pop(m.sharers,src))
MuxBundle(m, Array( MuxBundle(m, Array(
r.is(releaseVoluntaryInvalidateData) -> next, r.is(releaseVoluntaryInvalidateData) -> next,
r.is(releaseInvalidateData) -> next, r.is(releaseInvalidateData) -> next,
@ -335,8 +324,8 @@ class MEICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicy(d
)) ))
} }
def masterMetadataOnGrant(g: Grant, m: MasterMetadata, dst: UInt) = { def masterMetadataOnGrant(g: Grant, m: MasterMetadata, dst: UInt) = {
val cached = MasterMetadata(masterValid, dir().push(m.sharers, dst))(this) val cached = MasterMetadata(masterValid, dir.push(m.sharers, dst))
val uncached = MasterMetadata(masterValid, m.sharers)(this) val uncached = MasterMetadata(masterValid, m.sharers)
Mux(g.uncached, uncached, cached) Mux(g.uncached, uncached, cached)
} }
@ -401,12 +390,12 @@ class MEICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicy(d
def requiresAckForGrant(g: Grant) = g.uncached || g.g_type != grantVoluntaryAck def requiresAckForGrant(g: Grant) = g.uncached || g.g_type != grantVoluntaryAck
def requiresAckForRelease(r: Release) = Bool(false) def requiresAckForRelease(r: Release) = Bool(false)
def requiresSelfProbe(a: Acquire) = a.uncached && a.a_type === Acquire.uncachedRead def requiresSelfProbe(a: Acquire) = a.uncached && a.a_type === Acquire.uncachedRead
def requiresProbes(a: Acquire, m: MasterMetadata) = !dir().none(m.sharers) def requiresProbes(a: Acquire, m: MasterMetadata) = !dir.none(m.sharers)
def pendingVoluntaryReleaseIsSufficient(r_type: UInt, p_type: UInt): Bool = (r_type === releaseVoluntaryInvalidateData) def pendingVoluntaryReleaseIsSufficient(r_type: UInt, p_type: UInt): Bool = (r_type === releaseVoluntaryInvalidateData)
} }
class MSICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicy(dir) { class MSICoherence(dir: DirectoryRepresentation) extends CoherencePolicy(dir) {
def nClientStates = 3 def nClientStates = 3
def nMasterStates = 2 def nMasterStates = 2
def nAcquireTypes = 2 def nAcquireTypes = 2
@ -452,26 +441,26 @@ class MSICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicy(d
def needsWriteback(m: MasterMetadata) = isValid(m) def needsWriteback(m: MasterMetadata) = isValid(m)
def clientMetadataOnHit(cmd: UInt, m: ClientMetadata) = def clientMetadataOnHit(cmd: UInt, m: ClientMetadata) =
ClientMetadata(Mux(isWrite(cmd), clientExclusiveDirty, m.state))(this) ClientMetadata(Mux(isWrite(cmd), clientExclusiveDirty, m.state))
def clientMetadataOnCacheControl(cmd: UInt) = ClientMetadata( def clientMetadataOnCacheControl(cmd: UInt) = ClientMetadata(
MuxLookup(cmd, clientInvalid, Array( MuxLookup(cmd, clientInvalid, Array(
M_INV -> clientInvalid, M_INV -> clientInvalid,
M_CLN -> clientShared M_CLN -> clientShared
)))(this) )))
def clientMetadataOnFlush() = clientMetadataOnCacheControl(M_INV) def clientMetadataOnFlush() = clientMetadataOnCacheControl(M_INV)
def clientMetadataOnGrant(incoming: Grant, outstanding: Acquire) = ClientMetadata( def clientMetadataOnGrant(incoming: Grant, outstanding: Acquire) = ClientMetadata(
Mux(incoming.uncached, clientInvalid, Mux(incoming.uncached, clientInvalid,
Mux(incoming.g_type === grantReadShared, clientShared, Mux(incoming.g_type === grantReadShared, clientShared,
clientExclusiveDirty)))(this) clientExclusiveDirty)))
def clientMetadataOnProbe(incoming: Probe, m: ClientMetadata) = ClientMetadata( def clientMetadataOnProbe(incoming: Probe, m: ClientMetadata) = ClientMetadata(
MuxLookup(incoming.p_type, m.state, Array( MuxLookup(incoming.p_type, m.state, Array(
probeInvalidate -> clientInvalid, probeInvalidate -> clientInvalid,
probeDowngrade -> clientShared, probeDowngrade -> clientShared,
probeCopy -> m.state probeCopy -> m.state
)))(this) )))
def masterMetadataOnFlush = MasterMetadata(masterInvalid)(this) def masterMetadataOnFlush = MasterMetadata(masterInvalid)
def masterMetadataOnRelease(r: Release, m: MasterMetadata, src: UInt) = { def masterMetadataOnRelease(r: Release, m: MasterMetadata, src: UInt) = {
val next = MasterMetadata(masterValid, dir().pop(m.sharers,src))(this) val next = MasterMetadata(masterValid, dir.pop(m.sharers,src))
MuxBundle(m, Array( MuxBundle(m, Array(
r.is(releaseVoluntaryInvalidateData) -> next, r.is(releaseVoluntaryInvalidateData) -> next,
r.is(releaseInvalidateData) -> next, r.is(releaseInvalidateData) -> next,
@ -479,8 +468,8 @@ class MSICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicy(d
)) ))
} }
def masterMetadataOnGrant(g: Grant, m: MasterMetadata, dst: UInt) = { def masterMetadataOnGrant(g: Grant, m: MasterMetadata, dst: UInt) = {
val cached = MasterMetadata(masterValid, dir().push(m.sharers, dst))(this) val cached = MasterMetadata(masterValid, dir.push(m.sharers, dst))
val uncached = MasterMetadata(masterValid, m.sharers)(this) val uncached = MasterMetadata(masterValid, m.sharers)
Mux(g.uncached, uncached, cached) Mux(g.uncached, uncached, cached)
} }
@ -525,7 +514,7 @@ class MSICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicy(d
def getGrantType(a: Acquire, m: MasterMetadata): UInt = { def getGrantType(a: Acquire, m: MasterMetadata): UInt = {
Mux(a.uncached, getGrantTypeForUncached(a, m), Mux(a.uncached, getGrantTypeForUncached(a, m),
Mux(a.a_type === acquireReadShared, Mux(a.a_type === acquireReadShared,
Mux(!dir().none(m.sharers), grantReadShared, grantReadExclusive), Mux(!dir.none(m.sharers), grantReadShared, grantReadExclusive),
grantReadExclusive)) grantReadExclusive))
} }
def getGrantTypeOnVoluntaryWriteback(m: MasterMetadata): UInt = grantVoluntaryAck def getGrantTypeOnVoluntaryWriteback(m: MasterMetadata): UInt = grantVoluntaryAck
@ -552,12 +541,12 @@ class MSICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicy(d
def requiresAckForGrant(g: Grant) = g.uncached || g.g_type != grantVoluntaryAck def requiresAckForGrant(g: Grant) = g.uncached || g.g_type != grantVoluntaryAck
def requiresAckForRelease(r: Release) = Bool(false) def requiresAckForRelease(r: Release) = Bool(false)
def requiresSelfProbe(a: Acquire) = a.uncached && a.a_type === Acquire.uncachedRead def requiresSelfProbe(a: Acquire) = a.uncached && a.a_type === Acquire.uncachedRead
def requiresProbes(a: Acquire, m: MasterMetadata) = !dir().none(m.sharers) def requiresProbes(a: Acquire, m: MasterMetadata) = !dir.none(m.sharers)
def pendingVoluntaryReleaseIsSufficient(r_type: UInt, p_type: UInt): Bool = (r_type === releaseVoluntaryInvalidateData) def pendingVoluntaryReleaseIsSufficient(r_type: UInt, p_type: UInt): Bool = (r_type === releaseVoluntaryInvalidateData)
} }
class MESICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicy(dir) { class MESICoherence(dir: DirectoryRepresentation) extends CoherencePolicy(dir) {
def nClientStates = 4 def nClientStates = 4
def nMasterStates = 2 def nMasterStates = 2
def nAcquireTypes = 2 def nAcquireTypes = 2
@ -603,13 +592,13 @@ class MESICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicy(
def needsWriteback(m: MasterMetadata) = isValid(m) def needsWriteback(m: MasterMetadata) = isValid(m)
def clientMetadataOnHit(cmd: UInt, m: ClientMetadata) = def clientMetadataOnHit(cmd: UInt, m: ClientMetadata) =
ClientMetadata(Mux(isWrite(cmd), clientExclusiveDirty, m.state))(this) ClientMetadata(Mux(isWrite(cmd), clientExclusiveDirty, m.state))
def clientMetadataOnCacheControl(cmd: UInt) = ClientMetadata( def clientMetadataOnCacheControl(cmd: UInt) = ClientMetadata(
MuxLookup(cmd, clientInvalid, Array( MuxLookup(cmd, clientInvalid, Array(
M_INV -> clientInvalid, M_INV -> clientInvalid,
M_CLN -> clientShared M_CLN -> clientShared
)))(this) )))
def clientMetadataOnFlush = clientMetadataOnCacheControl(M_INV) def clientMetadataOnFlush = clientMetadataOnCacheControl(M_INV)
def clientMetadataOnGrant(incoming: Grant, outstanding: Acquire) = ClientMetadata( def clientMetadataOnGrant(incoming: Grant, outstanding: Acquire) = ClientMetadata(
Mux(incoming.uncached, clientInvalid, Mux(incoming.uncached, clientInvalid,
@ -618,16 +607,16 @@ class MESICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicy(
grantReadExclusive -> Mux(outstanding.a_type === acquireReadExclusive, grantReadExclusive -> Mux(outstanding.a_type === acquireReadExclusive,
clientExclusiveDirty, clientExclusiveClean), clientExclusiveDirty, clientExclusiveClean),
grantReadExclusiveAck -> clientExclusiveDirty grantReadExclusiveAck -> clientExclusiveDirty
))))(this) ))))
def clientMetadataOnProbe(incoming: Probe, m: ClientMetadata) = ClientMetadata( def clientMetadataOnProbe(incoming: Probe, m: ClientMetadata) = ClientMetadata(
MuxLookup(incoming.p_type, m.state, Array( MuxLookup(incoming.p_type, m.state, Array(
probeInvalidate -> clientInvalid, probeInvalidate -> clientInvalid,
probeDowngrade -> clientShared, probeDowngrade -> clientShared,
probeCopy -> m.state probeCopy -> m.state
)))(this) )))
def masterMetadataOnFlush = MasterMetadata(masterInvalid)(this) def masterMetadataOnFlush = MasterMetadata(masterInvalid)
def masterMetadataOnRelease(r: Release, m: MasterMetadata, src: UInt) = { def masterMetadataOnRelease(r: Release, m: MasterMetadata, src: UInt) = {
val next = MasterMetadata(masterValid, dir().pop(m.sharers,src))(this) val next = MasterMetadata(masterValid, dir.pop(m.sharers,src))
MuxBundle(m, Array( MuxBundle(m, Array(
r.is(releaseVoluntaryInvalidateData) -> next, r.is(releaseVoluntaryInvalidateData) -> next,
r.is(releaseInvalidateData) -> next, r.is(releaseInvalidateData) -> next,
@ -635,8 +624,8 @@ class MESICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicy(
)) ))
} }
def masterMetadataOnGrant(g: Grant, m: MasterMetadata, dst: UInt) = { def masterMetadataOnGrant(g: Grant, m: MasterMetadata, dst: UInt) = {
val cached = MasterMetadata(masterValid, dir().push(m.sharers, dst))(this) val cached = MasterMetadata(masterValid, dir.push(m.sharers, dst))
val uncached = MasterMetadata(masterValid, m.sharers)(this) val uncached = MasterMetadata(masterValid, m.sharers)
Mux(g.uncached, uncached, cached) Mux(g.uncached, uncached, cached)
} }
@ -681,7 +670,7 @@ class MESICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicy(
def getGrantType(a: Acquire, m: MasterMetadata): UInt = { def getGrantType(a: Acquire, m: MasterMetadata): UInt = {
Mux(a.uncached, getGrantTypeForUncached(a, m), Mux(a.uncached, getGrantTypeForUncached(a, m),
Mux(a.a_type === acquireReadShared, Mux(a.a_type === acquireReadShared,
Mux(!dir().none(m.sharers), grantReadShared, grantReadExclusive), Mux(!dir.none(m.sharers), grantReadShared, grantReadExclusive),
grantReadExclusive)) grantReadExclusive))
} }
def getGrantTypeOnVoluntaryWriteback(m: MasterMetadata): UInt = grantVoluntaryAck def getGrantTypeOnVoluntaryWriteback(m: MasterMetadata): UInt = grantVoluntaryAck
@ -708,12 +697,12 @@ class MESICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicy(
def requiresAckForGrant(g: Grant) = g.uncached || g.g_type != grantVoluntaryAck def requiresAckForGrant(g: Grant) = g.uncached || g.g_type != grantVoluntaryAck
def requiresAckForRelease(r: Release) = Bool(false) def requiresAckForRelease(r: Release) = Bool(false)
def requiresSelfProbe(a: Acquire) = a.uncached && a.a_type === Acquire.uncachedRead def requiresSelfProbe(a: Acquire) = a.uncached && a.a_type === Acquire.uncachedRead
def requiresProbes(a: Acquire, m: MasterMetadata) = !dir().none(m.sharers) def requiresProbes(a: Acquire, m: MasterMetadata) = !dir.none(m.sharers)
def pendingVoluntaryReleaseIsSufficient(r_type: UInt, p_type: UInt): Bool = (r_type === releaseVoluntaryInvalidateData) def pendingVoluntaryReleaseIsSufficient(r_type: UInt, p_type: UInt): Bool = (r_type === releaseVoluntaryInvalidateData)
} }
class MigratoryCoherence(dir: () => DirectoryRepresentation) extends CoherencePolicy(dir) { class MigratoryCoherence(dir: DirectoryRepresentation) extends CoherencePolicy(dir) {
def nClientStates = 7 def nClientStates = 7
def nMasterStates = 2 def nMasterStates = 2
def nAcquireTypes = 3 def nAcquireTypes = 3
@ -760,12 +749,12 @@ class MigratoryCoherence(dir: () => DirectoryRepresentation) extends CoherencePo
def clientMetadataOnHit(cmd: UInt, m: ClientMetadata) = ClientMetadata( def clientMetadataOnHit(cmd: UInt, m: ClientMetadata) = ClientMetadata(
Mux(isWrite(cmd), MuxLookup(m.state, clientExclusiveDirty, Array( Mux(isWrite(cmd), MuxLookup(m.state, clientExclusiveDirty, Array(
clientExclusiveClean -> clientExclusiveDirty, clientExclusiveClean -> clientExclusiveDirty,
clientMigratoryClean -> clientMigratoryDirty)), m.state))(this) clientMigratoryClean -> clientMigratoryDirty)), m.state))
def clientMetadataOnCacheControl(cmd: UInt) = ClientMetadata( def clientMetadataOnCacheControl(cmd: UInt) = ClientMetadata(
MuxLookup(cmd, clientInvalid, Array( MuxLookup(cmd, clientInvalid, Array(
M_INV -> clientInvalid, M_INV -> clientInvalid,
M_CLN -> clientShared M_CLN -> clientShared
)))(this) )))
def clientMetadataOnFlush = clientMetadataOnCacheControl(M_INV) def clientMetadataOnFlush = clientMetadataOnCacheControl(M_INV)
def clientMetadataOnGrant(incoming: Grant, outstanding: Acquire) = ClientMetadata( def clientMetadataOnGrant(incoming: Grant, outstanding: Acquire) = ClientMetadata(
Mux(incoming.uncached, clientInvalid, Mux(incoming.uncached, clientInvalid,
@ -779,7 +768,7 @@ class MigratoryCoherence(dir: () => DirectoryRepresentation) extends CoherencePo
acquireInvalidateOthers -> clientMigratoryDirty, acquireInvalidateOthers -> clientMigratoryDirty,
acquireReadExclusive -> clientMigratoryDirty, acquireReadExclusive -> clientMigratoryDirty,
acquireReadShared -> clientMigratoryClean)) acquireReadShared -> clientMigratoryClean))
))))(this) ))))
def clientMetadataOnProbe(incoming: Probe, m: ClientMetadata) = ClientMetadata( def clientMetadataOnProbe(incoming: Probe, m: ClientMetadata) = ClientMetadata(
MuxLookup(incoming.p_type, m.state, Array( MuxLookup(incoming.p_type, m.state, Array(
probeInvalidate -> clientInvalid, probeInvalidate -> clientInvalid,
@ -791,10 +780,10 @@ class MigratoryCoherence(dir: () => DirectoryRepresentation) extends CoherencePo
clientSharedByTwo -> clientShared, clientSharedByTwo -> clientShared,
clientMigratoryClean -> clientSharedByTwo, clientMigratoryClean -> clientSharedByTwo,
clientMigratoryDirty -> clientInvalid)) clientMigratoryDirty -> clientInvalid))
)))(this) )))
def masterMetadataOnFlush = MasterMetadata(masterInvalid)(this) def masterMetadataOnFlush = MasterMetadata(masterInvalid)
def masterMetadataOnRelease(r: Release, m: MasterMetadata, src: UInt) = { def masterMetadataOnRelease(r: Release, m: MasterMetadata, src: UInt) = {
val next = MasterMetadata(masterValid, dir().pop(m.sharers,src))(this) val next = MasterMetadata(masterValid, dir.pop(m.sharers,src))
MuxBundle(m, Array( MuxBundle(m, Array(
r.is(releaseVoluntaryInvalidateData) -> next, r.is(releaseVoluntaryInvalidateData) -> next,
r.is(releaseInvalidateData) -> next, r.is(releaseInvalidateData) -> next,
@ -804,8 +793,8 @@ class MigratoryCoherence(dir: () => DirectoryRepresentation) extends CoherencePo
)) ))
} }
def masterMetadataOnGrant(g: Grant, m: MasterMetadata, dst: UInt) = { def masterMetadataOnGrant(g: Grant, m: MasterMetadata, dst: UInt) = {
val cached = MasterMetadata(masterValid, dir().push(m.sharers, dst))(this) val cached = MasterMetadata(masterValid, dir.push(m.sharers, dst))
val uncached = MasterMetadata(masterValid, m.sharers)(this) val uncached = MasterMetadata(masterValid, m.sharers)
Mux(g.uncached, uncached, cached) Mux(g.uncached, uncached, cached)
} }
@ -853,7 +842,7 @@ class MigratoryCoherence(dir: () => DirectoryRepresentation) extends CoherencePo
def getGrantType(a: Acquire, m: MasterMetadata): UInt = { def getGrantType(a: Acquire, m: MasterMetadata): UInt = {
Mux(a.uncached, getGrantTypeForUncached(a, m), Mux(a.uncached, getGrantTypeForUncached(a, m),
MuxLookup(a.a_type, grantReadShared, Array( MuxLookup(a.a_type, grantReadShared, Array(
acquireReadShared -> Mux(!dir().none(m.sharers), grantReadShared, grantReadExclusive), acquireReadShared -> Mux(!dir.none(m.sharers), grantReadShared, grantReadExclusive),
acquireReadExclusive -> grantReadExclusive, acquireReadExclusive -> grantReadExclusive,
acquireInvalidateOthers -> grantReadExclusiveAck //TODO: add this to MESI for broadcast? acquireInvalidateOthers -> grantReadExclusiveAck //TODO: add this to MESI for broadcast?
))) )))
@ -883,7 +872,7 @@ class MigratoryCoherence(dir: () => DirectoryRepresentation) extends CoherencePo
def requiresAckForGrant(g: Grant) = g.uncached || g.g_type != grantVoluntaryAck def requiresAckForGrant(g: Grant) = g.uncached || g.g_type != grantVoluntaryAck
def requiresAckForRelease(r: Release) = Bool(false) def requiresAckForRelease(r: Release) = Bool(false)
def requiresSelfProbe(a: Acquire) = a.uncached && a.a_type === Acquire.uncachedRead def requiresSelfProbe(a: Acquire) = a.uncached && a.a_type === Acquire.uncachedRead
def requiresProbes(a: Acquire, m: MasterMetadata) = !dir().none(m.sharers) def requiresProbes(a: Acquire, m: MasterMetadata) = !dir.none(m.sharers)
def pendingVoluntaryReleaseIsSufficient(r_type: UInt, p_type: UInt): Bool = (r_type === releaseVoluntaryInvalidateData) def pendingVoluntaryReleaseIsSufficient(r_type: UInt, p_type: UInt): Bool = (r_type === releaseVoluntaryInvalidateData)
} }

View File

@ -4,16 +4,22 @@ package uncore
import Chisel._ import Chisel._
case object NReleaseTransactors extends Field[Int] case object NReleaseTransactors extends Field[Int]
case object NProbeTransactors extends Field[Int]
case object NAcquireTransactors extends Field[Int] case object NAcquireTransactors extends Field[Int]
case object NIncoherentClients extends Field[Int]
case object NCoherentClients extends Field[Int]
case object L2StoreDataQueueDepth extends Field[Int] case object L2StoreDataQueueDepth extends Field[Int]
case object NClients extends Field[Int] case object L2CoherencePolicy extends Field[DirectoryRepresentation => CoherencePolicy]
case object L2DirectoryRepresentation extends Field[DirectoryRepresentation]
abstract trait CoherenceAgentParameters extends UsesParameters abstract trait CoherenceAgentParameters extends UsesParameters
with TileLinkParameters { with TileLinkParameters {
val nReleaseTransactors = 1 val nReleaseTransactors = 1
val nAcquireTransactors = params(NAcquireTransactors) val nAcquireTransactors = params(NAcquireTransactors)
val nTransactors = nReleaseTransactors + nAcquireTransactors val nTransactors = nReleaseTransactors + nAcquireTransactors
val nClients = params(NClients) val nCoherentClients = params(NCoherentClients)
val nIncoherentClients = params(NIncoherentClients)
val nClients = nCoherentClients + nIncoherentClients
val sdqDepth = params(L2StoreDataQueueDepth)*tlDataBeats val sdqDepth = params(L2StoreDataQueueDepth)*tlDataBeats
val dqIdxBits = math.max(log2Up(nReleaseTransactors) + 1, log2Up(sdqDepth)) val dqIdxBits = math.max(log2Up(nReleaseTransactors) + 1, log2Up(sdqDepth))
val nDataQueueLocations = 3 //Stores, VoluntaryWBs, Releases val nDataQueueLocations = 3 //Stores, VoluntaryWBs, Releases
@ -41,7 +47,7 @@ abstract class CoherenceAgent(innerId: String, outerId: String) extends Module
} }
} }
class L2CoherenceAgent(bankId: Int, innerId: String, outerId: String) extends class L2BroadcastHub(bankId: Int, innerId: String, outerId: String) extends
CoherenceAgent(innerId, outerId) { CoherenceAgent(innerId, outerId) {
val internalDataBits = new DataQueueLocation().getWidth val internalDataBits = new DataQueueLocation().getWidth
@ -143,11 +149,12 @@ class L2CoherenceAgent(bankId: Int, innerId: String, outerId: String) extends
abstract class XactTracker(innerId: String, outerId: String) extends Module { abstract class XactTracker(innerId: String, outerId: String) extends Module {
val (co, nClients, tlDataBeats) = (params(TLCoherence),params(NClients),params(TLDataBeats)) val (co, tlDataBeats) = (params(TLCoherence), params(TLDataBeats))
val nClients = params(NCoherentClients) + params(NIncoherentClients)
val io = new Bundle { val io = new Bundle {
val inner = Bundle(new TileLinkIO, {case TLId => innerId}).flip val inner = Bundle(new TileLinkIO, {case TLId => innerId}).flip
val outer = Bundle(new UncachedTileLinkIO, {case TLId => outerId}) val outer = Bundle(new UncachedTileLinkIO, {case TLId => outerId})
val tile_incoherent = Bits(INPUT, params(NClients)) val tile_incoherent = Bits(INPUT, nClients)
val has_acquire_conflict = Bool(OUTPUT) val has_acquire_conflict = Bool(OUTPUT)
val has_release_conflict = Bool(OUTPUT) val has_release_conflict = Bool(OUTPUT)
} }