1
0

more coherence API cleanup

This commit is contained in:
Henry Cook 2014-07-10 17:10:32 -07:00
parent faed47d131
commit 149d51d644
3 changed files with 63 additions and 58 deletions

View File

@ -376,7 +376,7 @@ class L2VoluntaryReleaseTracker(trackerId: Int, bankId: Int) extends L2XactTrack
io.inner.grant.valid := Bool(false) io.inner.grant.valid := Bool(false)
io.inner.grant.bits.header.src := UInt(bankId) io.inner.grant.bits.header.src := UInt(bankId)
io.inner.grant.bits.header.dst := init_client_id 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, xact.client_xact_id,
UInt(trackerId)) UInt(trackerId))
@ -454,11 +454,12 @@ class L2AcquireTracker(trackerId: Int, bankId: Int) extends L2XactTracker {
io.inner.probe.valid := Bool(false) io.inner.probe.valid := Bool(false)
io.inner.probe.bits.header.src := UInt(bankId) io.inner.probe.bits.header.src := UInt(bankId)
io.inner.probe.bits.header.dst := curr_p_id 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, /*xact_internal.meta), TODO*/
co.masterMetadataOnFlush),
xact.addr, xact.addr,
UInt(trackerId)) 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.valid := Bool(false)
io.inner.grant.bits.header.src := UInt(bankId) io.inner.grant.bits.header.src := UInt(bankId)
io.inner.grant.bits.header.dst := init_client_id io.inner.grant.bits.header.dst := init_client_id

View File

@ -28,7 +28,7 @@ object MasterMetadata {
def apply(state: UInt)(implicit c: CoherencePolicy): MasterMetadata = { def apply(state: UInt)(implicit c: CoherencePolicy): MasterMetadata = {
val m = new MasterMetadata val m = new MasterMetadata
m.state := state m.state := state
m.sharers := m.sharers.flush() m.sharers.flush()
m m
} }
def apply(state: UInt, sharers: DirectoryRepresentation)(implicit c: CoherencePolicy): MasterMetadata = { 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 { abstract class DirectoryRepresentation extends Bundle {
val sharers: UInt val internal: UInt
def pop(id: UInt): DirectoryRepresentation def pop(id: UInt): DirectoryRepresentation
def push(id: UInt): DirectoryRepresentation def push(id: UInt): DirectoryRepresentation
def flush(dummy: Int = 0): DirectoryRepresentation def flush(dummy: Int = 0): DirectoryRepresentation
def none(dummy: Int = 0): Bool def none(dummy: Int = 0): Bool
def one(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 { class NullRepresentation extends DirectoryRepresentation {
val sharers = UInt(0) val internal = UInt(0)
def pop(id: UInt) = this def pop(id: UInt) = this
def push(id: UInt) = this def push(id: UInt) = this
def flush(dummy: Int = 0) = this def flush(dummy: Int = 0) = this
def none(dummy: Int = 0) = Bool(false) def none(dummy: Int = 0) = Bool(false)
def one(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 { class FullRepresentation(nClients: Int) extends DirectoryRepresentation {
val sharers = UInt(width = nClients) val internal = UInt(width = nClients)
def pop(id: UInt) = { sharers := sharers & ~UIntToOH(id); this } def pop(id: UInt) = { internal := internal & ~UIntToOH(id); this }
def push(id: UInt) = { sharers := sharers | UIntToOH(id); this } def push(id: UInt) = { internal := internal | UIntToOH(id); this }
def flush(dummy: Int = 0) = { sharers := UInt(0, width = nClients); this } def flush(dummy: Int = 0) = { internal := UInt(0, width = nClients); this }
def none(dummy: Int = 0) = sharers === UInt(0) def none(dummy: Int = 0) = internal === UInt(0)
def one(dummy: Int = 0) = PopCount(sharers) === UInt(1) def one(dummy: Int = 0) = PopCount(internal) === UInt(1)
def count(dummy: Int = 0) = PopCount(sharers) def count(dummy: Int = 0) = PopCount(internal)
def next(dummy: Int = 0) = PriorityEncoder(sharers) def next(dummy: Int = 0) = PriorityEncoder(internal)
override def clone = new FullRepresentation(nClients).asInstanceOf[this.type] 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 getAcquireTypeOnPrimaryMiss(cmd: UInt, m: ClientMetadata): UInt
def getAcquireTypeOnSecondaryMiss(cmd: UInt, m: ClientMetadata, outstanding: Acquire): 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 getReleaseTypeOnCacheControl(cmd: UInt): UInt
def getReleaseTypeOnVoluntaryWriteback(): UInt def getReleaseTypeOnVoluntaryWriteback(): UInt
def getReleaseTypeOnProbe(incoming: Probe, m: ClientMetadata): UInt def getReleaseTypeOnProbe(p: Probe, m: ClientMetadata): UInt
def getGrantType(a_type: UInt, count: UInt): UInt def getGrantType(a: Acquire, m: MasterMetadata): UInt
def getGrantType(rel: Release, count: UInt): 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 messageHasData (rel: SourcedMessage): Bool
def messageUpdatesDataArray (reply: Grant): 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 isCoherenceConflict(addr1: UInt, addr2: UInt): Bool = (addr1 === addr2)
def getGrantType(a_type: UInt, count: UInt): UInt = { def getGrantType(a: Acquire, m: MasterMetadata): UInt = {
MuxLookup(a_type, grantReadUncached, Array( MuxLookup(a.a_type, grantReadUncached, Array(
acquireReadExclusive -> grantReadExclusive, acquireReadExclusive -> grantReadExclusive,
acquireReadUncached -> grantReadUncached, acquireReadUncached -> grantReadUncached,
acquireWriteUncached -> grantWriteUncached, acquireWriteUncached -> grantWriteUncached,
@ -270,14 +276,14 @@ class MICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicyWit
)) ))
} }
def getGrantType(rel: Release, count: UInt): UInt = { def getGrantType(r: Release, m: MasterMetadata): UInt = {
MuxLookup(rel.r_type, grantReadUncached, Array( MuxLookup(r.r_type, grantReadUncached, Array(
releaseVoluntaryInvalidateData -> grantVoluntaryAck releaseVoluntaryInvalidateData -> grantVoluntaryAck
)) ))
} }
def getProbeType(a_type: UInt, m: MasterMetadata): UInt = { def getProbeType(a: Acquire, m: MasterMetadata): UInt = {
MuxLookup(a_type, probeCopy, Array( MuxLookup(a.a_type, probeCopy, Array(
acquireReadExclusive -> probeInvalidate, acquireReadExclusive -> probeInvalidate,
acquireReadUncached -> probeCopy, acquireReadUncached -> probeCopy,
acquireWriteUncached -> probeInvalidate, acquireWriteUncached -> probeInvalidate,
@ -427,8 +433,8 @@ class MEICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicyWi
def isCoherenceConflict(addr1: UInt, addr2: UInt): Bool = (addr1 === addr2) def isCoherenceConflict(addr1: UInt, addr2: UInt): Bool = (addr1 === addr2)
def getGrantType(a_type: UInt, count: UInt): UInt = { def getGrantType(a: Acquire, m: MasterMetadata): UInt = {
MuxLookup(a_type, grantReadUncached, Array( MuxLookup(a.a_type, grantReadUncached, Array(
acquireReadExclusiveClean -> grantReadExclusive, acquireReadExclusiveClean -> grantReadExclusive,
acquireReadExclusiveDirty -> grantReadExclusive, acquireReadExclusiveDirty -> grantReadExclusive,
acquireReadUncached -> grantReadUncached, acquireReadUncached -> grantReadUncached,
@ -438,15 +444,15 @@ class MEICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicyWi
acquireAtomicUncached -> grantAtomicUncached acquireAtomicUncached -> grantAtomicUncached
)) ))
} }
def getGrantType(rel: Release, count: UInt): UInt = { def getGrantType(r: Release, m: MasterMetadata): UInt = {
MuxLookup(rel.r_type, grantReadUncached, Array( MuxLookup(r.r_type, grantReadUncached, Array(
releaseVoluntaryInvalidateData -> grantVoluntaryAck releaseVoluntaryInvalidateData -> grantVoluntaryAck
)) ))
} }
def getProbeType(a_type: UInt, m: MasterMetadata): UInt = { def getProbeType(a: Acquire, m: MasterMetadata): UInt = {
MuxLookup(a_type, probeCopy, Array( MuxLookup(a.a_type, probeCopy, Array(
acquireReadExclusiveClean -> probeInvalidate, acquireReadExclusiveClean -> probeInvalidate,
acquireReadExclusiveDirty -> probeInvalidate, acquireReadExclusiveDirty -> probeInvalidate,
acquireReadUncached -> probeCopy, acquireReadUncached -> probeCopy,
@ -604,9 +610,9 @@ class MSICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicyWi
def isCoherenceConflict(addr1: UInt, addr2: UInt): Bool = (addr1 === addr2) def isCoherenceConflict(addr1: UInt, addr2: UInt): Bool = (addr1 === addr2)
def getGrantType(a_type: UInt, count: UInt): UInt = { def getGrantType(a: Acquire, m: MasterMetadata): UInt = {
MuxLookup(a_type, grantReadUncached, Array( MuxLookup(a.a_type, grantReadUncached, Array(
acquireReadShared -> Mux(count > UInt(0), grantReadShared, grantReadExclusive), acquireReadShared -> Mux(m.sharers.count() > UInt(0), grantReadShared, grantReadExclusive),
acquireReadExclusive -> grantReadExclusive, acquireReadExclusive -> grantReadExclusive,
acquireReadUncached -> grantReadUncached, acquireReadUncached -> grantReadUncached,
acquireWriteUncached -> grantWriteUncached, acquireWriteUncached -> grantWriteUncached,
@ -615,14 +621,14 @@ class MSICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicyWi
acquireAtomicUncached -> grantAtomicUncached acquireAtomicUncached -> grantAtomicUncached
)) ))
} }
def getGrantType(rel: Release, count: UInt): UInt = { def getGrantType(r: Release, m: MasterMetadata): UInt = {
MuxLookup(rel.r_type, grantReadUncached, Array( MuxLookup(r.r_type, grantReadUncached, Array(
releaseVoluntaryInvalidateData -> grantVoluntaryAck releaseVoluntaryInvalidateData -> grantVoluntaryAck
)) ))
} }
def getProbeType(a_type: UInt, m: MasterMetadata): UInt = { def getProbeType(a: Acquire, m: MasterMetadata): UInt = {
MuxLookup(a_type, probeCopy, Array( MuxLookup(a.a_type, probeCopy, Array(
acquireReadShared -> probeDowngrade, acquireReadShared -> probeDowngrade,
acquireReadExclusive -> probeInvalidate, acquireReadExclusive -> probeInvalidate,
acquireReadUncached -> probeCopy, acquireReadUncached -> probeCopy,
@ -778,9 +784,9 @@ class MESICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicyW
def isCoherenceConflict(addr1: UInt, addr2: UInt): Bool = (addr1 === addr2) def isCoherenceConflict(addr1: UInt, addr2: UInt): Bool = (addr1 === addr2)
def getGrantType(a_type: UInt, count: UInt): UInt = { def getGrantType(a: Acquire, m: MasterMetadata): UInt = {
MuxLookup(a_type, grantReadUncached, Array( MuxLookup(a.a_type, grantReadUncached, Array(
acquireReadShared -> Mux(count > UInt(0), grantReadShared, grantReadExclusive), acquireReadShared -> Mux(m.sharers.count() > UInt(0), grantReadShared, grantReadExclusive),
acquireReadExclusive -> grantReadExclusive, acquireReadExclusive -> grantReadExclusive,
acquireReadUncached -> grantReadUncached, acquireReadUncached -> grantReadUncached,
acquireWriteUncached -> grantWriteUncached, acquireWriteUncached -> grantWriteUncached,
@ -789,15 +795,15 @@ class MESICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicyW
acquireAtomicUncached -> grantAtomicUncached acquireAtomicUncached -> grantAtomicUncached
)) ))
} }
def getGrantType(rel: Release, count: UInt): UInt = { def getGrantType(r: Release, m: MasterMetadata): UInt = {
MuxLookup(rel.r_type, grantReadUncached, Array( MuxLookup(r.r_type, grantReadUncached, Array(
releaseVoluntaryInvalidateData -> grantVoluntaryAck releaseVoluntaryInvalidateData -> grantVoluntaryAck
)) ))
} }
def getProbeType(a_type: UInt, m: MasterMetadata): UInt = { def getProbeType(a: Acquire, m: MasterMetadata): UInt = {
MuxLookup(a_type, probeCopy, Array( MuxLookup(a.a_type, probeCopy, Array(
acquireReadShared -> probeDowngrade, acquireReadShared -> probeDowngrade,
acquireReadExclusive -> probeInvalidate, acquireReadExclusive -> probeInvalidate,
acquireReadUncached -> probeCopy, acquireReadUncached -> probeCopy,
@ -975,9 +981,9 @@ class MigratoryCoherence(dir: () => DirectoryRepresentation) extends CoherencePo
def isCoherenceConflict(addr1: UInt, addr2: UInt): Bool = (addr1 === addr2) def isCoherenceConflict(addr1: UInt, addr2: UInt): Bool = (addr1 === addr2)
def getGrantType(a_type: UInt, count: UInt): UInt = { def getGrantType(a: Acquire, m: MasterMetadata): UInt = {
MuxLookup(a_type, grantReadUncached, Array( MuxLookup(a.a_type, grantReadUncached, Array(
acquireReadShared -> Mux(count > UInt(0), grantReadShared, grantReadExclusive), //TODO: what is count? Depend on release.p_type??? acquireReadShared -> Mux(m.sharers.count() > UInt(0), grantReadShared, grantReadExclusive), //TODO: what is count? Depend on release.p_type???
acquireReadExclusive -> grantReadExclusive, acquireReadExclusive -> grantReadExclusive,
acquireReadUncached -> grantReadUncached, acquireReadUncached -> grantReadUncached,
acquireWriteUncached -> grantWriteUncached, acquireWriteUncached -> grantWriteUncached,
@ -987,15 +993,15 @@ class MigratoryCoherence(dir: () => DirectoryRepresentation) extends CoherencePo
acquireInvalidateOthers -> grantReadExclusiveAck //TODO: add this to MESI? acquireInvalidateOthers -> grantReadExclusiveAck //TODO: add this to MESI?
)) ))
} }
def getGrantType(rel: Release, count: UInt): UInt = { def getGrantType(r: Release, m: MasterMetadata): UInt = {
MuxLookup(rel.r_type, grantReadUncached, Array( MuxLookup(r.r_type, grantReadUncached, Array(
releaseVoluntaryInvalidateData -> grantVoluntaryAck releaseVoluntaryInvalidateData -> grantVoluntaryAck
)) ))
} }
def getProbeType(a_type: UInt, m: MasterMetadata): UInt = { def getProbeType(a: Acquire, m: MasterMetadata): UInt = {
MuxLookup(a_type, probeCopy, Array( MuxLookup(a.a_type, probeCopy, Array(
acquireReadShared -> probeDowngrade, acquireReadShared -> probeDowngrade,
acquireReadExclusive -> probeInvalidate, acquireReadExclusive -> probeInvalidate,
acquireReadUncached -> probeCopy, acquireReadUncached -> probeCopy,

View File

@ -130,7 +130,7 @@ class VoluntaryReleaseTracker(trackerId: Int, bankId: Int) extends XactTracker {
io.inner.grant.valid := Bool(false) io.inner.grant.valid := Bool(false)
io.inner.grant.bits.header.src := UInt(bankId) io.inner.grant.bits.header.src := UInt(bankId)
io.inner.grant.bits.header.dst := init_client_id 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, xact.client_xact_id,
UInt(trackerId)) 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))) val init_client_id = Reg(init=UInt(0, width = log2Up(nClients)))
//TODO: Will need id reg for merged release xacts //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 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 probe_flags = Reg(init=Bits(0, width = nClients))
val curr_p_id = PriorityEncoder(probe_flags) 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.valid := Bool(false)
io.inner.probe.bits.header.src := UInt(bankId) io.inner.probe.bits.header.src := UInt(bankId)
io.inner.probe.bits.header.dst := curr_p_id 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, xact.addr,
UInt(trackerId)) 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.valid := Bool(false)
io.inner.grant.bits.header.src := UInt(bankId) io.inner.grant.bits.header.src := UInt(bankId)
io.inner.grant.bits.header.dst := init_client_id 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 ) { when( io.inner.acquire.valid ) {
xact := c_acq.payload xact := c_acq.payload
init_client_id := c_acq.header.src init_client_id := c_acq.header.src
init_sharer_cnt := UInt(nClients) // TODO: Broadcast only
probe_flags := probe_initial_flags probe_flags := probe_initial_flags
if(nClients > 1) { if(nClients > 1) {
release_count := PopCount(probe_initial_flags) release_count := PopCount(probe_initial_flags)