2014-09-13 00:31:38 +02:00
|
|
|
// See LICENSE for license details.
|
|
|
|
|
2012-09-27 21:59:45 +02:00
|
|
|
package uncore
|
2012-02-15 00:51:32 +01:00
|
|
|
import Chisel._
|
|
|
|
|
2014-05-28 22:35:08 +02:00
|
|
|
object MuxBundle {
|
|
|
|
def apply[T <: Data] (default: T, mapping: Seq[(Bool, T)]): T = {
|
2014-07-11 01:59:48 +02:00
|
|
|
mapping.reverse.foldLeft(default)((b, a) => Mux(a._1, a._2, b))
|
2014-05-28 22:35:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
abstract class CoherenceMetadata extends Bundle
|
|
|
|
|
|
|
|
object ClientMetadata {
|
|
|
|
def apply(state: UInt)(implicit c: CoherencePolicy) = {
|
|
|
|
val m = new ClientMetadata
|
|
|
|
m.state := state
|
|
|
|
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]
|
|
|
|
}
|
|
|
|
|
|
|
|
object MasterMetadata {
|
|
|
|
def apply(state: UInt)(implicit c: CoherencePolicy): MasterMetadata = {
|
|
|
|
val m = new MasterMetadata
|
|
|
|
m.state := state
|
2014-07-11 02:10:32 +02:00
|
|
|
m.sharers.flush()
|
2014-05-28 22:35:08 +02:00
|
|
|
m
|
|
|
|
}
|
|
|
|
def apply(state: UInt, sharers: DirectoryRepresentation)(implicit c: CoherencePolicy): MasterMetadata = {
|
|
|
|
val m = apply(state)
|
|
|
|
m.sharers := sharers
|
|
|
|
m
|
|
|
|
}
|
|
|
|
}
|
|
|
|
class MasterMetadata(implicit c: CoherencePolicy) extends CoherenceMetadata {
|
|
|
|
val state = UInt(width = c.masterStateWidth)
|
2014-07-11 02:01:19 +02:00
|
|
|
val sharers = c.dir()
|
2014-05-28 22:35:08 +02:00
|
|
|
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 extends Bundle {
|
|
|
|
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
|
2014-07-11 02:10:32 +02:00
|
|
|
def count(dummy: Int = 0): UInt
|
|
|
|
def next(dummy: Int = 0): UInt
|
2014-05-28 22:35:08 +02:00
|
|
|
}
|
|
|
|
|
2014-11-12 01:05:25 +01:00
|
|
|
class NullRepresentation(nClients: Int) extends DirectoryRepresentation {
|
2014-05-28 22:35:08 +02:00
|
|
|
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)
|
2014-11-12 01:05:25 +01:00
|
|
|
def count(dummy: Int = 0) = UInt(nClients)
|
2014-07-11 02:10:32 +02:00
|
|
|
def next(dummy: Int = 0) = UInt(0)
|
2014-05-28 22:35:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class FullRepresentation(nClients: Int) extends DirectoryRepresentation {
|
2014-07-11 02:10:32 +02:00
|
|
|
val internal = UInt(width = nClients)
|
2014-07-14 07:29:15 +02:00
|
|
|
def pop(id: UInt) = { internal := internal & ~UIntToOH(id); this } // make new FullRep to return?
|
2014-07-11 02:10:32 +02:00
|
|
|
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)
|
2014-05-28 22:35:08 +02:00
|
|
|
override def clone = new FullRepresentation(nClients).asInstanceOf[this.type]
|
|
|
|
}
|
|
|
|
|
2014-07-11 02:01:19 +02:00
|
|
|
abstract class CoherencePolicy(val dir: () => DirectoryRepresentation) {
|
2013-08-02 23:55:06 +02:00
|
|
|
def nClientStates: Int
|
|
|
|
def nMasterStates: Int
|
|
|
|
def nAcquireTypes: Int
|
|
|
|
def nProbeTypes: Int
|
|
|
|
def nReleaseTypes: Int
|
|
|
|
def nGrantTypes: Int
|
2013-08-12 19:36:44 +02:00
|
|
|
def clientStateWidth = log2Up(nClientStates)
|
|
|
|
def masterStateWidth = log2Up(nMasterStates)
|
|
|
|
def acquireTypeWidth = log2Up(nAcquireTypes)
|
|
|
|
def probeTypeWidth = log2Up(nProbeTypes)
|
|
|
|
def releaseTypeWidth = log2Up(nReleaseTypes)
|
|
|
|
def grantTypeWidth = log2Up(nGrantTypes)
|
|
|
|
|
2014-05-28 22:35:08 +02:00
|
|
|
def isHit (cmd: UInt, m: ClientMetadata): Bool
|
|
|
|
def isValid (m: ClientMetadata): Bool
|
|
|
|
def isHit (incoming: Acquire, m: MasterMetadata): Bool
|
|
|
|
def isValid (m: MasterMetadata): Bool
|
2013-08-12 19:36:44 +02:00
|
|
|
|
|
|
|
def needsTransactionOnSecondaryMiss(cmd: UInt, outstanding: Acquire): Bool
|
2014-05-28 22:35:08 +02:00
|
|
|
def needsTransactionOnCacheControl(cmd: UInt, m: ClientMetadata): Bool
|
|
|
|
def needsWriteback(m: ClientMetadata): Bool
|
|
|
|
|
|
|
|
def clientMetadataOnHit(cmd: UInt, m: ClientMetadata): ClientMetadata
|
|
|
|
def clientMetadataOnCacheControl(cmd: UInt): ClientMetadata
|
|
|
|
def clientMetadataOnFlush: ClientMetadata
|
|
|
|
def clientMetadataOnGrant(incoming: Grant, outstanding: Acquire): ClientMetadata
|
|
|
|
def clientMetadataOnProbe(incoming: Probe, m: ClientMetadata): ClientMetadata
|
|
|
|
def masterMetadataOnFlush: MasterMetadata
|
|
|
|
def masterMetadataOnRelease(incoming: Release, m: MasterMetadata, src: UInt): MasterMetadata
|
|
|
|
|
|
|
|
def getAcquireTypeOnPrimaryMiss(cmd: UInt, m: ClientMetadata): UInt
|
|
|
|
def getAcquireTypeOnSecondaryMiss(cmd: UInt, m: ClientMetadata, outstanding: Acquire): UInt
|
2014-07-11 02:10:32 +02:00
|
|
|
def getProbeType(a: Acquire, m: MasterMetadata): UInt
|
2014-01-21 21:20:55 +01:00
|
|
|
def getReleaseTypeOnCacheControl(cmd: UInt): UInt
|
|
|
|
def getReleaseTypeOnVoluntaryWriteback(): UInt
|
2014-07-11 02:10:32 +02:00
|
|
|
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)
|
2012-04-05 00:51:33 +02:00
|
|
|
|
2013-03-20 22:10:16 +01:00
|
|
|
def messageHasData (rel: SourcedMessage): Bool
|
2013-01-22 02:17:26 +01:00
|
|
|
def messageUpdatesDataArray (reply: Grant): Bool
|
|
|
|
def messageIsUncached(acq: Acquire): Bool
|
2012-04-05 00:51:33 +02:00
|
|
|
|
2014-01-21 21:20:55 +01:00
|
|
|
def isCoherenceConflict(addr1: UInt, addr2: UInt): Bool
|
2013-01-29 01:39:45 +01:00
|
|
|
def isVoluntary(rel: Release): Bool
|
2013-03-01 03:13:41 +01:00
|
|
|
def isVoluntary(gnt: Grant): Bool
|
2014-05-28 22:35:08 +02:00
|
|
|
def requiresOuterRead(a_type: UInt, m: MasterMetadata): Bool
|
|
|
|
def requiresOuterWrite(a_type: UInt, m: MasterMetadata): Bool
|
|
|
|
def requiresOuterRead(a_type: UInt): Bool
|
|
|
|
def requiresOuterWrite(a_type: UInt): Bool
|
2014-01-21 21:20:55 +01:00
|
|
|
def requiresSelfProbe(a_type: UInt): Bool
|
|
|
|
def requiresAckForGrant(g_type: UInt): Bool
|
|
|
|
def requiresAckForRelease(r_type: UInt): Bool
|
2013-08-12 19:36:44 +02:00
|
|
|
def pendingVoluntaryReleaseIsSufficient(r_type: UInt, p_type: UInt): Bool
|
2012-04-05 00:51:33 +02:00
|
|
|
}
|
2012-03-02 03:49:00 +01:00
|
|
|
|
2012-04-10 09:09:58 +02:00
|
|
|
trait UncachedTransactions {
|
2014-01-21 21:20:55 +01:00
|
|
|
def getUncachedReadAcquireType: UInt
|
|
|
|
def getUncachedWriteAcquireType: UInt
|
|
|
|
def getUncachedReadWordAcquireType: UInt
|
|
|
|
def getUncachedWriteWordAcquireType: UInt
|
|
|
|
def getUncachedAtomicAcquireType: UInt
|
2013-01-22 02:17:26 +01:00
|
|
|
def isUncachedReadTransaction(acq: Acquire): Bool
|
2012-04-10 09:09:58 +02:00
|
|
|
}
|
|
|
|
|
2014-07-11 02:01:19 +02:00
|
|
|
abstract class CoherencePolicyWithUncached(dir: () => DirectoryRepresentation) extends CoherencePolicy(dir)
|
2014-05-28 22:35:08 +02:00
|
|
|
with UncachedTransactions
|
2013-01-29 01:39:45 +01:00
|
|
|
|
2014-07-11 02:01:19 +02:00
|
|
|
class MICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicyWithUncached(dir) {
|
2013-08-02 23:55:06 +02:00
|
|
|
def nClientStates = 2
|
|
|
|
def nMasterStates = 2
|
|
|
|
def nAcquireTypes = 6
|
|
|
|
def nProbeTypes = 2
|
|
|
|
def nReleaseTypes = 5
|
|
|
|
def nGrantTypes = 7
|
2012-04-10 09:09:58 +02:00
|
|
|
|
2014-05-28 22:35:08 +02:00
|
|
|
val clientInvalid :: clientValid :: Nil = Enum(UInt(), nClientStates)
|
|
|
|
val masterInvalid :: masterValid :: Nil = Enum(UInt(), nMasterStates)
|
2013-08-02 23:55:06 +02:00
|
|
|
|
2013-09-10 19:54:51 +02:00
|
|
|
val acquireReadExclusive :: acquireReadUncached :: acquireWriteUncached :: acquireReadWordUncached :: acquireWriteWordUncached :: acquireAtomicUncached :: Nil = Enum(UInt(), nAcquireTypes)
|
|
|
|
val probeInvalidate :: probeCopy :: Nil = Enum(UInt(), nProbeTypes)
|
|
|
|
val releaseVoluntaryInvalidateData :: releaseInvalidateData :: releaseCopyData :: releaseInvalidateAck :: releaseCopyAck :: Nil = Enum(UInt(), nReleaseTypes)
|
|
|
|
val grantVoluntaryAck :: grantReadExclusive :: grantReadUncached :: grantWriteUncached :: grantReadWordUncached :: grantWriteWordUncached :: grantAtomicUncached :: Nil = Enum(UInt(), nGrantTypes)
|
2012-04-10 09:09:58 +02:00
|
|
|
|
2014-04-17 03:14:12 +02:00
|
|
|
val uncachedAcquireTypeVec = Vec(acquireReadUncached, acquireWriteUncached, acquireReadWordUncached, acquireWriteWordUncached, acquireAtomicUncached)
|
|
|
|
val hasDataAcquireTypeVec = Vec(acquireWriteUncached, acquireWriteWordUncached, acquireAtomicUncached)
|
|
|
|
val hasDataReleaseTypeVec = Vec(releaseVoluntaryInvalidateData, releaseInvalidateData, releaseCopyData)
|
|
|
|
val hasDataGrantTypeVec = Vec(grantReadExclusive, grantReadUncached, grantReadWordUncached, grantAtomicUncached)
|
2012-04-10 09:09:58 +02:00
|
|
|
|
2014-05-28 22:35:08 +02:00
|
|
|
def isHit (cmd: UInt, m: ClientMetadata): Bool = isValid(m)
|
|
|
|
def isValid (m: ClientMetadata): Bool = m.state != clientInvalid
|
|
|
|
def isHit (incoming: Acquire, m: MasterMetadata): Bool = isValid(m)
|
|
|
|
def isValid (m: MasterMetadata): Bool = m.state != masterInvalid
|
2012-04-10 09:09:58 +02:00
|
|
|
|
2013-08-12 19:36:44 +02:00
|
|
|
def needsTransactionOnSecondaryMiss(cmd: UInt, outstanding: Acquire): Bool = (outstanding.a_type != acquireReadExclusive)
|
2014-05-28 22:35:08 +02:00
|
|
|
def needsTransactionOnCacheControl(cmd: UInt, m: ClientMetadata): Bool = {
|
|
|
|
MuxLookup(cmd, (m.state === clientValid), Array(
|
|
|
|
M_INV -> (m.state === clientValid),
|
|
|
|
M_CLN -> (m.state === clientValid)
|
2012-04-10 09:09:58 +02:00
|
|
|
))
|
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def needsWriteback (m: ClientMetadata): Bool = {
|
|
|
|
needsTransactionOnCacheControl(M_INV, m)
|
|
|
|
}
|
|
|
|
|
|
|
|
def clientMetadataOnHit(cmd: UInt, m: ClientMetadata) = m
|
|
|
|
def clientMetadataOnCacheControl(cmd: UInt) = ClientMetadata(
|
|
|
|
MuxLookup(cmd, clientInvalid, Array(
|
|
|
|
M_INV -> clientInvalid,
|
|
|
|
M_CLN -> clientValid
|
|
|
|
)))(this)
|
|
|
|
def clientMetadataOnFlush = clientMetadataOnCacheControl(M_INV)
|
|
|
|
def clientMetadataOnGrant(incoming: Grant, outstanding: Acquire) = ClientMetadata(
|
|
|
|
MuxLookup(incoming.g_type, clientInvalid, Array(
|
|
|
|
grantReadExclusive -> clientValid,
|
|
|
|
grantReadUncached -> clientInvalid,
|
|
|
|
grantWriteUncached -> clientInvalid,
|
|
|
|
grantReadWordUncached -> clientInvalid,
|
|
|
|
grantWriteWordUncached -> clientInvalid,
|
|
|
|
grantAtomicUncached -> clientInvalid
|
|
|
|
)))(this)
|
|
|
|
def clientMetadataOnProbe(incoming: Probe, m: ClientMetadata) = ClientMetadata(
|
|
|
|
MuxLookup(incoming.p_type, m.state, Array(
|
|
|
|
probeInvalidate -> clientInvalid,
|
|
|
|
probeCopy -> m.state
|
|
|
|
)))(this)
|
|
|
|
def masterMetadataOnFlush = MasterMetadata(masterInvalid)(this)
|
|
|
|
def masterMetadataOnRelease(incoming: Release, m: MasterMetadata, src: UInt) = {
|
|
|
|
val popped = m.sharers.pop(src)
|
|
|
|
val next = MasterMetadata(Mux(popped.none(), masterInvalid, masterValid), popped)(this)
|
|
|
|
def is(r: UInt) = incoming.r_type === r
|
|
|
|
MuxBundle(m, Array(
|
|
|
|
is(releaseVoluntaryInvalidateData) -> next,
|
|
|
|
is(releaseInvalidateData) -> next,
|
|
|
|
is(releaseCopyData) -> m,
|
|
|
|
is(releaseInvalidateAck) -> next,
|
|
|
|
is(releaseCopyAck) -> m
|
2012-04-10 09:09:58 +02:00
|
|
|
))
|
|
|
|
}
|
|
|
|
|
2013-08-02 23:55:06 +02:00
|
|
|
def getUncachedReadAcquireType = acquireReadUncached
|
|
|
|
def getUncachedWriteAcquireType = acquireWriteUncached
|
|
|
|
def getUncachedReadWordAcquireType = acquireReadWordUncached
|
|
|
|
def getUncachedWriteWordAcquireType = acquireWriteWordUncached
|
|
|
|
def getUncachedAtomicAcquireType = acquireAtomicUncached
|
2013-01-22 02:17:26 +01:00
|
|
|
def isUncachedReadTransaction(acq: Acquire) = acq.a_type === acquireReadUncached
|
2013-01-29 01:39:45 +01:00
|
|
|
def isVoluntary(rel: Release) = rel.r_type === releaseVoluntaryInvalidateData
|
2013-03-01 03:13:41 +01:00
|
|
|
def isVoluntary(gnt: Grant) = gnt.g_type === grantVoluntaryAck
|
2012-10-02 01:05:37 +02:00
|
|
|
|
2014-05-28 22:35:08 +02:00
|
|
|
def getAcquireTypeOnPrimaryMiss(cmd: UInt, m: ClientMetadata): UInt = acquireReadExclusive
|
|
|
|
def getAcquireTypeOnSecondaryMiss(cmd: UInt, m: ClientMetadata, outstanding: Acquire): UInt = acquireReadExclusive
|
2014-01-21 21:20:55 +01:00
|
|
|
def getReleaseTypeOnCacheControl(cmd: UInt): UInt = releaseVoluntaryInvalidateData // TODO
|
|
|
|
def getReleaseTypeOnVoluntaryWriteback(): UInt = getReleaseTypeOnCacheControl(M_INV)
|
2014-05-28 22:35:08 +02:00
|
|
|
def getReleaseTypeOnProbe(incoming: Probe, m: ClientMetadata): UInt = {
|
2013-01-22 02:17:26 +01:00
|
|
|
val with_data = MuxLookup(incoming.p_type, releaseInvalidateData, Array(
|
|
|
|
probeInvalidate -> releaseInvalidateData,
|
|
|
|
probeCopy -> releaseCopyData
|
2012-04-10 09:09:58 +02:00
|
|
|
))
|
2013-01-22 02:17:26 +01:00
|
|
|
val without_data = MuxLookup(incoming.p_type, releaseInvalidateAck, Array(
|
|
|
|
probeInvalidate -> releaseInvalidateAck,
|
|
|
|
probeCopy -> releaseCopyAck
|
2012-04-10 09:09:58 +02:00
|
|
|
))
|
2014-05-28 22:35:08 +02:00
|
|
|
Mux(needsWriteback(m), with_data, without_data)
|
2012-04-10 09:09:58 +02:00
|
|
|
}
|
|
|
|
|
2013-03-20 22:10:16 +01:00
|
|
|
def messageHasData(msg: SourcedMessage) = msg match {
|
2014-04-17 03:14:12 +02:00
|
|
|
case acq: Acquire => hasDataAcquireTypeVec.contains(acq.a_type)
|
|
|
|
case grant: Grant => hasDataGrantTypeVec.contains(grant.g_type)
|
|
|
|
case rel: Release => hasDataReleaseTypeVec.contains(rel.r_type)
|
2013-03-20 22:10:16 +01:00
|
|
|
case _ => Bool(false)
|
|
|
|
}
|
2013-01-22 02:17:26 +01:00
|
|
|
def messageUpdatesDataArray (reply: Grant): Bool = {
|
|
|
|
(reply.g_type === grantReadExclusive)
|
2012-04-10 09:09:58 +02:00
|
|
|
}
|
2014-04-17 03:14:12 +02:00
|
|
|
def messageIsUncached(acq: Acquire): Bool = uncachedAcquireTypeVec.contains(acq.a_type)
|
2012-04-10 09:09:58 +02:00
|
|
|
|
2014-01-21 21:20:55 +01:00
|
|
|
def isCoherenceConflict(addr1: UInt, addr2: UInt): Bool = (addr1 === addr2)
|
2012-04-10 09:09:58 +02:00
|
|
|
|
2014-07-11 02:10:32 +02:00
|
|
|
def getGrantType(a: Acquire, m: MasterMetadata): UInt = {
|
|
|
|
MuxLookup(a.a_type, grantReadUncached, Array(
|
2013-01-22 02:17:26 +01:00
|
|
|
acquireReadExclusive -> grantReadExclusive,
|
|
|
|
acquireReadUncached -> grantReadUncached,
|
|
|
|
acquireWriteUncached -> grantWriteUncached,
|
|
|
|
acquireReadWordUncached -> grantReadWordUncached,
|
|
|
|
acquireWriteWordUncached -> grantWriteWordUncached,
|
|
|
|
acquireAtomicUncached -> grantAtomicUncached
|
2012-04-10 09:09:58 +02:00
|
|
|
))
|
|
|
|
}
|
|
|
|
|
2014-07-11 02:10:32 +02:00
|
|
|
def getGrantType(r: Release, m: MasterMetadata): UInt = {
|
|
|
|
MuxLookup(r.r_type, grantReadUncached, Array(
|
2013-01-29 01:39:45 +01:00
|
|
|
releaseVoluntaryInvalidateData -> grantVoluntaryAck
|
|
|
|
))
|
|
|
|
}
|
|
|
|
|
2014-07-11 02:10:32 +02:00
|
|
|
def getProbeType(a: Acquire, m: MasterMetadata): UInt = {
|
|
|
|
MuxLookup(a.a_type, probeCopy, Array(
|
2013-01-22 02:17:26 +01:00
|
|
|
acquireReadExclusive -> probeInvalidate,
|
|
|
|
acquireReadUncached -> probeCopy,
|
|
|
|
acquireWriteUncached -> probeInvalidate,
|
|
|
|
acquireReadWordUncached -> probeCopy,
|
|
|
|
acquireWriteWordUncached -> probeInvalidate,
|
|
|
|
acquireAtomicUncached -> probeInvalidate
|
2012-04-10 09:09:58 +02:00
|
|
|
))
|
|
|
|
}
|
|
|
|
|
2014-05-28 22:35:08 +02:00
|
|
|
def requiresOuterRead(a_type: UInt) = {
|
2013-01-22 02:17:26 +01:00
|
|
|
(a_type != acquireWriteUncached)
|
2012-04-10 09:09:58 +02:00
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def requiresOuterWrite(a_type: UInt) = {
|
2013-01-22 02:17:26 +01:00
|
|
|
(a_type === acquireWriteUncached)
|
2012-04-10 09:09:58 +02:00
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def requiresOuterRead(a_type: UInt, m: MasterMetadata) = requiresOuterRead(a_type)
|
|
|
|
def requiresOuterWrite(a_type: UInt, m: MasterMetadata) = requiresOuterWrite(a_type)
|
2014-01-21 21:20:55 +01:00
|
|
|
def requiresAckForGrant(g_type: UInt) = g_type != grantVoluntaryAck
|
|
|
|
def requiresAckForRelease(r_type: UInt) = Bool(false)
|
|
|
|
def requiresSelfProbe(a_type: UInt) = Bool(false)
|
2013-08-12 19:36:44 +02:00
|
|
|
def pendingVoluntaryReleaseIsSufficient(r_type: UInt, p_type: UInt): Bool = (r_type === releaseVoluntaryInvalidateData)
|
2012-04-10 09:09:58 +02:00
|
|
|
}
|
|
|
|
|
2014-07-11 02:01:19 +02:00
|
|
|
class MEICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicyWithUncached(dir) {
|
2013-08-02 23:55:06 +02:00
|
|
|
def nClientStates = 3
|
|
|
|
def nMasterStates = 2
|
|
|
|
def nAcquireTypes = 7
|
|
|
|
def nProbeTypes = 3
|
|
|
|
def nReleaseTypes = 7
|
|
|
|
def nGrantTypes = 8
|
2012-04-10 09:09:58 +02:00
|
|
|
|
2014-05-28 22:35:08 +02:00
|
|
|
val clientInvalid :: clientExclusiveClean :: clientExclusiveDirty :: Nil = Enum(UInt(), nClientStates)
|
|
|
|
val masterInvalid :: masterValid :: Nil = Enum(UInt(), nMasterStates)
|
2012-04-10 09:09:58 +02:00
|
|
|
|
2013-09-10 19:54:51 +02:00
|
|
|
val acquireReadExclusiveClean :: acquireReadExclusiveDirty :: acquireReadUncached :: acquireWriteUncached :: acquireReadWordUncached :: acquireWriteWordUncached :: acquireAtomicUncached :: Nil = Enum(UInt(), nAcquireTypes)
|
|
|
|
val probeInvalidate :: probeDowngrade :: probeCopy :: Nil = Enum(UInt(), nProbeTypes)
|
|
|
|
val releaseVoluntaryInvalidateData :: releaseInvalidateData :: releaseDowngradeData :: releaseCopyData :: releaseInvalidateAck :: releaseDowngradeAck :: releaseCopyAck :: Nil = Enum(UInt(), nReleaseTypes)
|
|
|
|
val grantVoluntaryAck :: grantReadExclusive :: grantReadUncached :: grantWriteUncached :: grantReadExclusiveAck :: grantReadWordUncached :: grantWriteWordUncached :: grantAtomicUncached :: Nil = Enum(UInt(), nGrantTypes)
|
2013-03-01 03:13:41 +01:00
|
|
|
|
2014-04-17 03:14:12 +02:00
|
|
|
val uncachedAcquireTypeVec = Vec(acquireReadUncached, acquireWriteUncached, acquireReadWordUncached, acquireWriteWordUncached, acquireAtomicUncached)
|
|
|
|
val hasDataAcquireTypeVec = Vec(acquireWriteUncached, acquireWriteWordUncached, acquireAtomicUncached)
|
|
|
|
val hasDataReleaseTypeVec = Vec(releaseVoluntaryInvalidateData, releaseInvalidateData, releaseDowngradeData, releaseCopyData)
|
|
|
|
val hasDataGrantTypeVec = Vec(grantReadExclusive, grantReadUncached, grantReadWordUncached, grantAtomicUncached)
|
2012-04-10 09:09:58 +02:00
|
|
|
|
2014-05-28 22:35:08 +02:00
|
|
|
def isHit (cmd: UInt, m: ClientMetadata) = isValid(m)
|
|
|
|
def isValid (m: ClientMetadata) = m.state != clientInvalid
|
|
|
|
def isHit (incoming: Acquire, m: MasterMetadata) = isValid(m)
|
|
|
|
def isValid (m: MasterMetadata) = m.state != masterInvalid
|
2012-04-10 09:09:58 +02:00
|
|
|
|
2013-08-12 19:36:44 +02:00
|
|
|
def needsTransactionOnSecondaryMiss(cmd: UInt, outstanding: Acquire): Bool = {
|
2013-04-08 04:23:44 +02:00
|
|
|
(isRead(cmd) && messageIsUncached(outstanding)) ||
|
|
|
|
(isWriteIntent(cmd) && (outstanding.a_type != acquireReadExclusiveDirty))
|
2012-04-10 09:09:58 +02:00
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def needsTransactionOnCacheControl(cmd: UInt, m: ClientMetadata): Bool = {
|
|
|
|
MuxLookup(cmd, (m.state === clientExclusiveDirty), Array(
|
|
|
|
M_INV -> (m.state === clientExclusiveDirty),
|
|
|
|
M_CLN -> (m.state === clientExclusiveDirty)
|
2012-04-10 09:09:58 +02:00
|
|
|
))
|
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def needsWriteback (m: ClientMetadata): Bool = {
|
|
|
|
needsTransactionOnCacheControl(M_INV, m)
|
|
|
|
}
|
|
|
|
|
|
|
|
def clientMetadataOnHit(cmd: UInt, m: ClientMetadata) =
|
|
|
|
ClientMetadata(Mux(isWrite(cmd), clientExclusiveDirty, m.state))(this)
|
|
|
|
|
|
|
|
def clientMetadataOnCacheControl(cmd: UInt) = ClientMetadata(
|
|
|
|
MuxLookup(cmd, clientInvalid, Array(
|
|
|
|
M_INV -> clientInvalid,
|
|
|
|
M_CLN -> clientExclusiveClean
|
|
|
|
)))(this)
|
|
|
|
def clientMetadataOnFlush() = clientMetadataOnCacheControl(M_INV)
|
|
|
|
def clientMetadataOnGrant(incoming: Grant, outstanding: Acquire) = ClientMetadata(
|
|
|
|
MuxLookup(incoming.g_type, clientInvalid, Array(
|
|
|
|
grantReadExclusive -> Mux(outstanding.a_type === acquireReadExclusiveDirty,
|
|
|
|
clientExclusiveDirty, clientExclusiveClean),
|
|
|
|
grantReadExclusiveAck -> clientExclusiveDirty,
|
|
|
|
grantReadUncached -> clientInvalid,
|
|
|
|
grantWriteUncached -> clientInvalid,
|
|
|
|
grantReadWordUncached -> clientInvalid,
|
|
|
|
grantWriteWordUncached -> clientInvalid,
|
|
|
|
grantAtomicUncached -> clientInvalid
|
|
|
|
)))(this)
|
|
|
|
def clientMetadataOnProbe(incoming: Probe, m: ClientMetadata) = ClientMetadata(
|
|
|
|
MuxLookup(incoming.p_type, m.state, Array(
|
|
|
|
probeInvalidate -> clientInvalid,
|
|
|
|
probeDowngrade -> clientExclusiveClean,
|
|
|
|
probeCopy -> m.state
|
|
|
|
)))(this)
|
|
|
|
def masterMetadataOnFlush = MasterMetadata(masterInvalid)(this)
|
|
|
|
def masterMetadataOnRelease(incoming: Release, m: MasterMetadata, src: UInt) = {
|
|
|
|
val popped = m.sharers.pop(src)
|
|
|
|
val next = MasterMetadata(Mux(popped.none(), masterInvalid, masterValid), popped)(this)
|
|
|
|
def is(r: UInt) = incoming.r_type === r
|
|
|
|
MuxBundle(m, Array(
|
|
|
|
is(releaseVoluntaryInvalidateData) -> next,
|
|
|
|
is(releaseInvalidateData) -> next,
|
|
|
|
is(releaseDowngradeData) -> m,
|
|
|
|
is(releaseCopyData) -> m,
|
|
|
|
is(releaseInvalidateAck) -> next,
|
|
|
|
is(releaseDowngradeAck) -> m,
|
|
|
|
is(releaseCopyAck) -> m
|
2012-04-10 09:09:58 +02:00
|
|
|
))
|
|
|
|
}
|
|
|
|
|
2013-08-02 23:55:06 +02:00
|
|
|
def getUncachedReadAcquireType = acquireReadUncached
|
|
|
|
def getUncachedWriteAcquireType = acquireWriteUncached
|
|
|
|
def getUncachedReadWordAcquireType = acquireReadWordUncached
|
|
|
|
def getUncachedWriteWordAcquireType = acquireWriteWordUncached
|
|
|
|
def getUncachedAtomicAcquireType = acquireAtomicUncached
|
2013-01-22 02:17:26 +01:00
|
|
|
def isUncachedReadTransaction(acq: Acquire) = acq.a_type === acquireReadUncached
|
2013-01-29 01:39:45 +01:00
|
|
|
def isVoluntary(rel: Release) = rel.r_type === releaseVoluntaryInvalidateData
|
2013-03-01 03:13:41 +01:00
|
|
|
def isVoluntary(gnt: Grant) = gnt.g_type === grantVoluntaryAck
|
2012-10-02 01:05:37 +02:00
|
|
|
|
2014-05-28 22:35:08 +02:00
|
|
|
def getAcquireTypeOnPrimaryMiss(cmd: UInt, m: ClientMetadata): UInt = {
|
2013-04-08 04:23:44 +02:00
|
|
|
Mux(isWriteIntent(cmd), acquireReadExclusiveDirty, acquireReadExclusiveClean)
|
2012-04-10 09:09:58 +02:00
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def getAcquireTypeOnSecondaryMiss(cmd: UInt, m: ClientMetadata, outstanding: Acquire): UInt = {
|
2013-04-08 04:23:44 +02:00
|
|
|
Mux(isWriteIntent(cmd), acquireReadExclusiveDirty, outstanding.a_type)
|
2012-04-10 09:09:58 +02:00
|
|
|
}
|
2014-01-21 21:20:55 +01:00
|
|
|
def getReleaseTypeOnCacheControl(cmd: UInt): UInt = releaseVoluntaryInvalidateData // TODO
|
|
|
|
def getReleaseTypeOnVoluntaryWriteback(): UInt = getReleaseTypeOnCacheControl(M_INV)
|
2014-05-28 22:35:08 +02:00
|
|
|
def getReleaseTypeOnProbe(incoming: Probe, m: ClientMetadata): UInt = {
|
2013-01-22 02:17:26 +01:00
|
|
|
val with_data = MuxLookup(incoming.p_type, releaseInvalidateData, Array(
|
|
|
|
probeInvalidate -> releaseInvalidateData,
|
|
|
|
probeDowngrade -> releaseDowngradeData,
|
|
|
|
probeCopy -> releaseCopyData
|
2012-04-10 09:09:58 +02:00
|
|
|
))
|
2013-01-22 02:17:26 +01:00
|
|
|
val without_data = MuxLookup(incoming.p_type, releaseInvalidateAck, Array(
|
|
|
|
probeInvalidate -> releaseInvalidateAck,
|
|
|
|
probeDowngrade -> releaseDowngradeAck,
|
|
|
|
probeCopy -> releaseCopyAck
|
2012-04-10 09:09:58 +02:00
|
|
|
))
|
2014-05-28 22:35:08 +02:00
|
|
|
Mux(needsWriteback(m), with_data, without_data)
|
2012-04-10 09:09:58 +02:00
|
|
|
}
|
|
|
|
|
2013-03-20 22:10:16 +01:00
|
|
|
def messageHasData(msg: SourcedMessage) = msg match {
|
2014-04-17 03:14:12 +02:00
|
|
|
case acq: Acquire => hasDataAcquireTypeVec.contains(acq.a_type)
|
|
|
|
case grant: Grant => hasDataGrantTypeVec.contains(grant.g_type)
|
|
|
|
case rel: Release => hasDataReleaseTypeVec.contains(rel.r_type)
|
2013-03-20 22:10:16 +01:00
|
|
|
case _ => Bool(false)
|
|
|
|
}
|
2013-01-22 02:17:26 +01:00
|
|
|
def messageUpdatesDataArray (reply: Grant): Bool = {
|
|
|
|
(reply.g_type === grantReadExclusive)
|
2012-04-10 09:09:58 +02:00
|
|
|
}
|
2014-04-17 03:14:12 +02:00
|
|
|
def messageIsUncached(acq: Acquire): Bool = uncachedAcquireTypeVec.contains(acq.a_type)
|
2012-04-10 09:09:58 +02:00
|
|
|
|
2014-01-21 21:20:55 +01:00
|
|
|
def isCoherenceConflict(addr1: UInt, addr2: UInt): Bool = (addr1 === addr2)
|
2012-04-10 09:09:58 +02:00
|
|
|
|
2014-07-11 02:10:32 +02:00
|
|
|
def getGrantType(a: Acquire, m: MasterMetadata): UInt = {
|
|
|
|
MuxLookup(a.a_type, grantReadUncached, Array(
|
2013-01-22 02:17:26 +01:00
|
|
|
acquireReadExclusiveClean -> grantReadExclusive,
|
|
|
|
acquireReadExclusiveDirty -> grantReadExclusive,
|
|
|
|
acquireReadUncached -> grantReadUncached,
|
|
|
|
acquireWriteUncached -> grantWriteUncached,
|
|
|
|
acquireReadWordUncached -> grantReadWordUncached,
|
|
|
|
acquireWriteWordUncached -> grantWriteWordUncached,
|
|
|
|
acquireAtomicUncached -> grantAtomicUncached
|
2012-04-10 09:09:58 +02:00
|
|
|
))
|
|
|
|
}
|
2014-07-11 02:10:32 +02:00
|
|
|
def getGrantType(r: Release, m: MasterMetadata): UInt = {
|
|
|
|
MuxLookup(r.r_type, grantReadUncached, Array(
|
2013-01-29 01:39:45 +01:00
|
|
|
releaseVoluntaryInvalidateData -> grantVoluntaryAck
|
|
|
|
))
|
|
|
|
}
|
|
|
|
|
2012-04-10 09:09:58 +02:00
|
|
|
|
2014-07-11 02:10:32 +02:00
|
|
|
def getProbeType(a: Acquire, m: MasterMetadata): UInt = {
|
|
|
|
MuxLookup(a.a_type, probeCopy, Array(
|
2013-01-22 02:17:26 +01:00
|
|
|
acquireReadExclusiveClean -> probeInvalidate,
|
|
|
|
acquireReadExclusiveDirty -> probeInvalidate,
|
|
|
|
acquireReadUncached -> probeCopy,
|
|
|
|
acquireWriteUncached -> probeInvalidate,
|
|
|
|
acquireReadWordUncached -> probeCopy,
|
|
|
|
acquireWriteWordUncached -> probeInvalidate,
|
|
|
|
acquireAtomicUncached -> probeInvalidate
|
2012-04-10 09:09:58 +02:00
|
|
|
))
|
|
|
|
}
|
|
|
|
|
2014-05-28 22:35:08 +02:00
|
|
|
def requiresOuterRead(a_type: UInt) = {
|
2013-01-22 02:17:26 +01:00
|
|
|
(a_type != acquireWriteUncached)
|
2012-04-10 09:09:58 +02:00
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def requiresOuterWrite(a_type: UInt) = {
|
2013-01-22 02:17:26 +01:00
|
|
|
(a_type === acquireWriteUncached)
|
2012-04-10 09:09:58 +02:00
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def requiresOuterRead(a_type: UInt, m: MasterMetadata) = requiresOuterRead(a_type)
|
|
|
|
def requiresOuterWrite(a_type: UInt, m: MasterMetadata) = requiresOuterWrite(a_type)
|
2014-01-21 21:20:55 +01:00
|
|
|
def requiresAckForGrant(g_type: UInt) = g_type != grantVoluntaryAck
|
|
|
|
def requiresAckForRelease(r_type: UInt) = Bool(false)
|
|
|
|
def requiresSelfProbe(a_type: UInt) = Bool(false)
|
2013-03-01 03:13:41 +01:00
|
|
|
|
2013-08-12 19:36:44 +02:00
|
|
|
def pendingVoluntaryReleaseIsSufficient(r_type: UInt, p_type: UInt): Bool = (r_type === releaseVoluntaryInvalidateData)
|
2012-02-15 00:51:32 +01:00
|
|
|
}
|
|
|
|
|
2014-07-11 02:01:19 +02:00
|
|
|
class MSICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicyWithUncached(dir) {
|
2013-08-02 23:55:06 +02:00
|
|
|
def nClientStates = 3
|
|
|
|
def nMasterStates = 3
|
|
|
|
def nAcquireTypes = 7
|
|
|
|
def nProbeTypes = 3
|
|
|
|
def nReleaseTypes = 7
|
|
|
|
def nGrantTypes = 9
|
|
|
|
|
2014-05-28 22:35:08 +02:00
|
|
|
val clientInvalid :: clientShared :: clientExclusiveDirty :: Nil = Enum(UInt(), nClientStates)
|
|
|
|
val masterInvalid :: masterShared :: masterExclusive :: Nil = Enum(UInt(), nMasterStates)
|
2012-04-12 02:56:59 +02:00
|
|
|
|
2013-09-10 19:54:51 +02:00
|
|
|
val acquireReadShared :: acquireReadExclusive :: acquireReadUncached :: acquireWriteUncached :: acquireReadWordUncached :: acquireWriteWordUncached :: acquireAtomicUncached :: Nil = Enum(UInt(), nAcquireTypes)
|
|
|
|
val probeInvalidate :: probeDowngrade :: probeCopy :: Nil = Enum(UInt(), nProbeTypes)
|
|
|
|
val releaseVoluntaryInvalidateData :: releaseInvalidateData :: releaseDowngradeData :: releaseCopyData :: releaseInvalidateAck :: releaseDowngradeAck :: releaseCopyAck :: Nil = Enum(UInt(), nReleaseTypes)
|
|
|
|
val grantVoluntaryAck :: grantReadShared :: grantReadExclusive :: grantReadUncached :: grantWriteUncached :: grantReadExclusiveAck :: grantReadWordUncached :: grantWriteWordUncached :: grantAtomicUncached :: Nil = Enum(UInt(), nGrantTypes)
|
2012-04-12 02:56:59 +02:00
|
|
|
|
2014-04-17 03:14:12 +02:00
|
|
|
val uncachedAcquireTypeVec = Vec(acquireReadUncached, acquireWriteUncached, acquireReadWordUncached, acquireWriteWordUncached, acquireAtomicUncached)
|
|
|
|
val hasDataAcquireTypeVec = Vec(acquireWriteUncached, acquireWriteWordUncached, acquireAtomicUncached)
|
|
|
|
val hasDataReleaseTypeVec = Vec(releaseVoluntaryInvalidateData, releaseInvalidateData, releaseDowngradeData, releaseCopyData)
|
|
|
|
val hasDataGrantTypeVec = Vec(grantReadShared, grantReadExclusive, grantReadUncached, grantReadWordUncached, grantAtomicUncached)
|
2012-04-12 02:56:59 +02:00
|
|
|
|
2014-05-28 22:35:08 +02:00
|
|
|
def isHit (cmd: UInt, m: ClientMetadata): Bool = {
|
|
|
|
Mux(isWriteIntent(cmd), (m.state === clientExclusiveDirty),
|
|
|
|
(m.state === clientShared || m.state === clientExclusiveDirty))
|
2012-04-12 02:56:59 +02:00
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def isValid (m: ClientMetadata): Bool = {
|
|
|
|
m.state != clientInvalid
|
2012-04-12 02:56:59 +02:00
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def isHit (incoming: Acquire, m: MasterMetadata) = isValid(m)
|
|
|
|
def isValid (m: MasterMetadata) = m.state != masterInvalid
|
2012-04-12 02:56:59 +02:00
|
|
|
|
2013-08-12 19:36:44 +02:00
|
|
|
def needsTransactionOnSecondaryMiss(cmd: UInt, outstanding: Acquire): Bool = {
|
2013-04-08 04:23:44 +02:00
|
|
|
(isRead(cmd) && messageIsUncached(outstanding)) ||
|
|
|
|
(isWriteIntent(cmd) && (outstanding.a_type != acquireReadExclusive))
|
2012-04-12 02:56:59 +02:00
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def needsTransactionOnCacheControl(cmd: UInt, m: ClientMetadata): Bool = {
|
|
|
|
MuxLookup(cmd, (m.state === clientExclusiveDirty), Array(
|
|
|
|
M_INV -> (m.state === clientExclusiveDirty),
|
|
|
|
M_CLN -> (m.state === clientExclusiveDirty)
|
2012-04-12 02:56:59 +02:00
|
|
|
))
|
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def needsWriteback (m: ClientMetadata): Bool = {
|
|
|
|
needsTransactionOnCacheControl(M_INV, m)
|
|
|
|
}
|
|
|
|
|
|
|
|
def clientMetadataOnHit(cmd: UInt, m: ClientMetadata) =
|
|
|
|
ClientMetadata(Mux(isWrite(cmd), clientExclusiveDirty, m.state))(this)
|
|
|
|
def clientMetadataOnCacheControl(cmd: UInt) = ClientMetadata(
|
|
|
|
MuxLookup(cmd, clientInvalid, Array(
|
|
|
|
M_INV -> clientInvalid,
|
|
|
|
M_CLN -> clientShared
|
|
|
|
)))(this)
|
|
|
|
def clientMetadataOnFlush() = clientMetadataOnCacheControl(M_INV)
|
|
|
|
def clientMetadataOnGrant(incoming: Grant, outstanding: Acquire) = ClientMetadata(
|
|
|
|
MuxLookup(incoming.g_type, clientInvalid, Array(
|
|
|
|
grantReadShared -> clientShared,
|
|
|
|
grantReadExclusive -> clientExclusiveDirty,
|
|
|
|
grantReadExclusiveAck -> clientExclusiveDirty,
|
|
|
|
grantReadUncached -> clientInvalid,
|
|
|
|
grantWriteUncached -> clientInvalid,
|
|
|
|
grantReadWordUncached -> clientInvalid,
|
|
|
|
grantWriteWordUncached -> clientInvalid,
|
|
|
|
grantAtomicUncached -> clientInvalid
|
|
|
|
)))(this)
|
|
|
|
def clientMetadataOnProbe(incoming: Probe, m: ClientMetadata) = ClientMetadata(
|
|
|
|
MuxLookup(incoming.p_type, m.state, Array(
|
|
|
|
probeInvalidate -> clientInvalid,
|
|
|
|
probeDowngrade -> clientShared,
|
|
|
|
probeCopy -> m.state
|
|
|
|
)))(this)
|
|
|
|
def masterMetadataOnFlush = MasterMetadata(masterInvalid)(this)
|
|
|
|
def masterMetadataOnRelease(incoming: Release, m: MasterMetadata, src: UInt) = {
|
|
|
|
val popped = m.sharers.pop(src)
|
|
|
|
val next = MasterMetadata(
|
|
|
|
Mux(popped.none(), masterInvalid,
|
|
|
|
Mux(popped.one(), masterExclusive, masterShared)), popped)(this)
|
|
|
|
def is(r: UInt) = incoming.r_type === r
|
|
|
|
MuxBundle(m, Array(
|
|
|
|
is(releaseVoluntaryInvalidateData) -> next,
|
|
|
|
is(releaseInvalidateData) -> next,
|
|
|
|
is(releaseDowngradeData) -> m,
|
|
|
|
is(releaseCopyData) -> m,
|
|
|
|
is(releaseInvalidateAck) -> next,
|
|
|
|
is(releaseDowngradeAck) -> m,
|
|
|
|
is(releaseCopyAck) -> m
|
2012-04-12 02:56:59 +02:00
|
|
|
))
|
|
|
|
}
|
|
|
|
|
2013-08-02 23:55:06 +02:00
|
|
|
def getUncachedReadAcquireType = acquireReadUncached
|
|
|
|
def getUncachedWriteAcquireType = acquireWriteUncached
|
|
|
|
def getUncachedReadWordAcquireType = acquireReadWordUncached
|
|
|
|
def getUncachedWriteWordAcquireType = acquireWriteWordUncached
|
|
|
|
def getUncachedAtomicAcquireType = acquireAtomicUncached
|
2013-01-22 02:17:26 +01:00
|
|
|
def isUncachedReadTransaction(acq: Acquire) = acq.a_type === acquireReadUncached
|
2013-01-29 01:39:45 +01:00
|
|
|
def isVoluntary(rel: Release) = rel.r_type === releaseVoluntaryInvalidateData
|
2013-03-01 03:13:41 +01:00
|
|
|
def isVoluntary(gnt: Grant) = gnt.g_type === grantVoluntaryAck
|
2012-10-02 01:05:37 +02:00
|
|
|
|
2014-05-28 22:35:08 +02:00
|
|
|
def getAcquireTypeOnPrimaryMiss(cmd: UInt, m: ClientMetadata): UInt = {
|
2013-04-04 07:13:51 +02:00
|
|
|
Mux(isWriteIntent(cmd), acquireReadExclusive, acquireReadShared)
|
2012-04-12 02:56:59 +02:00
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def getAcquireTypeOnSecondaryMiss(cmd: UInt, m: ClientMetadata, outstanding: Acquire): UInt = {
|
2013-04-08 04:23:44 +02:00
|
|
|
Mux(isWriteIntent(cmd), acquireReadExclusive, outstanding.a_type)
|
2012-04-12 02:56:59 +02:00
|
|
|
}
|
2014-01-21 21:20:55 +01:00
|
|
|
def getReleaseTypeOnCacheControl(cmd: UInt): UInt = releaseVoluntaryInvalidateData // TODO
|
|
|
|
def getReleaseTypeOnVoluntaryWriteback(): UInt = getReleaseTypeOnCacheControl(M_INV)
|
2014-05-28 22:35:08 +02:00
|
|
|
def getReleaseTypeOnProbe(incoming: Probe, m: ClientMetadata): UInt = {
|
2013-01-22 02:17:26 +01:00
|
|
|
val with_data = MuxLookup(incoming.p_type, releaseInvalidateData, Array(
|
|
|
|
probeInvalidate -> releaseInvalidateData,
|
|
|
|
probeDowngrade -> releaseDowngradeData,
|
|
|
|
probeCopy -> releaseCopyData
|
2012-04-12 02:56:59 +02:00
|
|
|
))
|
2013-01-22 02:17:26 +01:00
|
|
|
val without_data = MuxLookup(incoming.p_type, releaseInvalidateAck, Array(
|
|
|
|
probeInvalidate -> releaseInvalidateAck,
|
|
|
|
probeDowngrade -> releaseDowngradeAck,
|
|
|
|
probeCopy -> releaseCopyAck
|
2012-04-12 02:56:59 +02:00
|
|
|
))
|
2014-05-28 22:35:08 +02:00
|
|
|
Mux(needsWriteback(m), with_data, without_data)
|
2012-04-12 02:56:59 +02:00
|
|
|
}
|
|
|
|
|
2013-03-20 22:10:16 +01:00
|
|
|
def messageHasData(msg: SourcedMessage) = msg match {
|
2014-04-17 03:14:12 +02:00
|
|
|
case acq: Acquire => hasDataAcquireTypeVec.contains(acq.a_type)
|
|
|
|
case grant: Grant => hasDataGrantTypeVec.contains(grant.g_type)
|
|
|
|
case rel: Release => hasDataReleaseTypeVec.contains(rel.r_type)
|
2013-03-20 22:10:16 +01:00
|
|
|
case _ => Bool(false)
|
|
|
|
}
|
2013-01-22 02:17:26 +01:00
|
|
|
def messageUpdatesDataArray (reply: Grant): Bool = {
|
|
|
|
(reply.g_type === grantReadShared || reply.g_type === grantReadExclusive)
|
2012-04-12 02:56:59 +02:00
|
|
|
}
|
2014-04-17 03:14:12 +02:00
|
|
|
def messageIsUncached(acq: Acquire): Bool = uncachedAcquireTypeVec.contains(acq.a_type)
|
2012-04-12 02:56:59 +02:00
|
|
|
|
2014-01-21 21:20:55 +01:00
|
|
|
def isCoherenceConflict(addr1: UInt, addr2: UInt): Bool = (addr1 === addr2)
|
2012-04-12 02:56:59 +02:00
|
|
|
|
2014-07-11 02:10:32 +02:00
|
|
|
def getGrantType(a: Acquire, m: MasterMetadata): UInt = {
|
|
|
|
MuxLookup(a.a_type, grantReadUncached, Array(
|
|
|
|
acquireReadShared -> Mux(m.sharers.count() > UInt(0), grantReadShared, grantReadExclusive),
|
2013-01-22 02:17:26 +01:00
|
|
|
acquireReadExclusive -> grantReadExclusive,
|
|
|
|
acquireReadUncached -> grantReadUncached,
|
|
|
|
acquireWriteUncached -> grantWriteUncached,
|
|
|
|
acquireReadWordUncached -> grantReadWordUncached,
|
|
|
|
acquireWriteWordUncached -> grantWriteWordUncached,
|
|
|
|
acquireAtomicUncached -> grantAtomicUncached
|
2012-04-12 02:56:59 +02:00
|
|
|
))
|
|
|
|
}
|
2014-07-11 02:10:32 +02:00
|
|
|
def getGrantType(r: Release, m: MasterMetadata): UInt = {
|
|
|
|
MuxLookup(r.r_type, grantReadUncached, Array(
|
2013-01-29 01:39:45 +01:00
|
|
|
releaseVoluntaryInvalidateData -> grantVoluntaryAck
|
|
|
|
))
|
|
|
|
}
|
|
|
|
|
2014-07-11 02:10:32 +02:00
|
|
|
def getProbeType(a: Acquire, m: MasterMetadata): UInt = {
|
|
|
|
MuxLookup(a.a_type, probeCopy, Array(
|
2013-01-22 02:17:26 +01:00
|
|
|
acquireReadShared -> probeDowngrade,
|
|
|
|
acquireReadExclusive -> probeInvalidate,
|
|
|
|
acquireReadUncached -> probeCopy,
|
|
|
|
acquireWriteUncached -> probeInvalidate
|
2012-04-12 02:56:59 +02:00
|
|
|
))
|
|
|
|
}
|
|
|
|
|
2014-05-28 22:35:08 +02:00
|
|
|
def requiresOuterRead(a_type: UInt) = {
|
2013-01-22 02:17:26 +01:00
|
|
|
(a_type != acquireWriteUncached)
|
2012-04-12 02:56:59 +02:00
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def requiresOuterWrite(a_type: UInt) = {
|
2013-01-22 02:17:26 +01:00
|
|
|
(a_type === acquireWriteUncached)
|
2012-04-12 02:56:59 +02:00
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def requiresOuterRead(a_type: UInt, m: MasterMetadata) = requiresOuterRead(a_type)
|
|
|
|
def requiresOuterWrite(a_type: UInt, m: MasterMetadata) = requiresOuterWrite(a_type)
|
2014-01-21 21:20:55 +01:00
|
|
|
def requiresAckForGrant(g_type: UInt) = g_type != grantVoluntaryAck
|
|
|
|
def requiresAckForRelease(r_type: UInt) = Bool(false)
|
|
|
|
def requiresSelfProbe(a_type: UInt) = Bool(false)
|
2013-03-01 03:13:41 +01:00
|
|
|
|
2013-08-12 19:36:44 +02:00
|
|
|
def pendingVoluntaryReleaseIsSufficient(r_type: UInt, p_type: UInt): Bool = (r_type === releaseVoluntaryInvalidateData)
|
2012-04-12 02:56:59 +02:00
|
|
|
}
|
|
|
|
|
2014-07-11 02:01:19 +02:00
|
|
|
class MESICoherence(dir: () => DirectoryRepresentation) extends CoherencePolicyWithUncached(dir) {
|
2013-08-02 23:55:06 +02:00
|
|
|
def nClientStates = 4
|
|
|
|
def nMasterStates = 3
|
|
|
|
def nAcquireTypes = 7
|
|
|
|
def nProbeTypes = 3
|
|
|
|
def nReleaseTypes = 7
|
|
|
|
def nGrantTypes = 9
|
2012-02-15 00:51:32 +01:00
|
|
|
|
2014-05-28 22:35:08 +02:00
|
|
|
val clientInvalid :: clientShared :: clientExclusiveClean :: clientExclusiveDirty :: Nil = Enum(UInt(), nClientStates)
|
|
|
|
val masterInvalid :: masterShared :: masterExclusive :: Nil = Enum(UInt(), nMasterStates)
|
2012-02-15 00:51:32 +01:00
|
|
|
|
2013-09-10 19:54:51 +02:00
|
|
|
val acquireReadShared :: acquireReadExclusive :: acquireReadUncached :: acquireWriteUncached :: acquireReadWordUncached :: acquireWriteWordUncached :: acquireAtomicUncached :: Nil = Enum(UInt(), nAcquireTypes)
|
|
|
|
val probeInvalidate :: probeDowngrade :: probeCopy :: Nil = Enum(UInt(), nProbeTypes)
|
|
|
|
val releaseVoluntaryInvalidateData :: releaseInvalidateData :: releaseDowngradeData :: releaseCopyData :: releaseInvalidateAck :: releaseDowngradeAck :: releaseCopyAck :: Nil = Enum(UInt(), nReleaseTypes)
|
|
|
|
val grantVoluntaryAck :: grantReadShared :: grantReadExclusive :: grantReadUncached :: grantWriteUncached :: grantReadExclusiveAck :: grantReadWordUncached :: grantWriteWordUncached :: grantAtomicUncached :: Nil = Enum(UInt(), nGrantTypes)
|
2013-03-01 03:13:41 +01:00
|
|
|
|
2014-04-17 03:14:12 +02:00
|
|
|
val uncachedAcquireTypeVec = Vec(acquireReadUncached, acquireWriteUncached, acquireReadWordUncached, acquireWriteWordUncached, acquireAtomicUncached)
|
|
|
|
val hasDataAcquireTypeVec = Vec(acquireWriteUncached, acquireWriteWordUncached, acquireAtomicUncached)
|
|
|
|
val hasDataReleaseTypeVec = Vec(releaseVoluntaryInvalidateData, releaseInvalidateData, releaseDowngradeData, releaseCopyData)
|
|
|
|
val hasDataGrantTypeVec = Vec(grantReadShared, grantReadExclusive, grantReadUncached, grantReadWordUncached, grantAtomicUncached)
|
2012-04-03 21:03:05 +02:00
|
|
|
|
2014-05-28 22:35:08 +02:00
|
|
|
def isHit (cmd: UInt, m: ClientMetadata): Bool = {
|
|
|
|
Mux(isWriteIntent(cmd), (m.state === clientExclusiveClean || m.state === clientExclusiveDirty),
|
|
|
|
(m.state === clientShared || m.state === clientExclusiveClean || m.state === clientExclusiveDirty))
|
2012-02-16 21:59:38 +01:00
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def isValid (m: ClientMetadata): Bool = {
|
|
|
|
m.state != clientInvalid
|
2012-02-15 00:51:32 +01:00
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def isHit (incoming: Acquire, m: MasterMetadata) = isValid(m)
|
|
|
|
def isValid (m: MasterMetadata) = m.state != masterInvalid
|
2012-02-15 00:51:32 +01:00
|
|
|
|
2013-08-12 19:36:44 +02:00
|
|
|
def needsTransactionOnSecondaryMiss(cmd: UInt, outstanding: Acquire): Bool = {
|
2013-04-08 04:23:44 +02:00
|
|
|
(isRead(cmd) && messageIsUncached(outstanding)) ||
|
|
|
|
(isWriteIntent(cmd) && (outstanding.a_type != acquireReadExclusive))
|
2012-04-03 21:03:05 +02:00
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def needsTransactionOnCacheControl(cmd: UInt, m: ClientMetadata): Bool = {
|
|
|
|
MuxLookup(cmd, (m.state === clientExclusiveDirty), Array(
|
|
|
|
M_INV -> (m.state === clientExclusiveDirty),
|
|
|
|
M_CLN -> (m.state === clientExclusiveDirty)
|
2012-04-03 21:03:05 +02:00
|
|
|
))
|
2012-03-07 10:26:35 +01:00
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def needsWriteback (m: ClientMetadata): Bool = {
|
|
|
|
needsTransactionOnCacheControl(M_INV, m)
|
|
|
|
}
|
|
|
|
|
|
|
|
def clientMetadataOnHit(cmd: UInt, m: ClientMetadata) =
|
|
|
|
ClientMetadata(Mux(isWrite(cmd), clientExclusiveDirty, m.state))(this)
|
|
|
|
|
|
|
|
def clientMetadataOnCacheControl(cmd: UInt) = ClientMetadata(
|
|
|
|
MuxLookup(cmd, clientInvalid, Array(
|
|
|
|
M_INV -> clientInvalid,
|
|
|
|
M_CLN -> clientShared
|
|
|
|
)))(this)
|
|
|
|
def clientMetadataOnFlush = clientMetadataOnCacheControl(M_INV)
|
|
|
|
def clientMetadataOnGrant(incoming: Grant, outstanding: Acquire) = ClientMetadata(
|
|
|
|
MuxLookup(incoming.g_type, clientInvalid, Array(
|
|
|
|
grantReadShared -> clientShared,
|
|
|
|
grantReadExclusive -> Mux(outstanding.a_type === acquireReadExclusive, clientExclusiveDirty, clientExclusiveClean),
|
|
|
|
grantReadExclusiveAck -> clientExclusiveDirty,
|
|
|
|
grantReadUncached -> clientInvalid,
|
|
|
|
grantWriteUncached -> clientInvalid,
|
|
|
|
grantReadWordUncached -> clientInvalid,
|
|
|
|
grantWriteWordUncached -> clientInvalid,
|
|
|
|
grantAtomicUncached -> clientInvalid
|
|
|
|
)))(this)
|
|
|
|
def clientMetadataOnProbe(incoming: Probe, m: ClientMetadata) = ClientMetadata(
|
|
|
|
MuxLookup(incoming.p_type, m.state, Array(
|
|
|
|
probeInvalidate -> clientInvalid,
|
|
|
|
probeDowngrade -> clientShared,
|
|
|
|
probeCopy -> m.state
|
|
|
|
)))(this)
|
|
|
|
def masterMetadataOnFlush = MasterMetadata(masterInvalid)(this)
|
|
|
|
def masterMetadataOnRelease(incoming: Release, m: MasterMetadata, src: UInt) = {
|
|
|
|
val popped = m.sharers.pop(src)
|
|
|
|
val next = MasterMetadata(
|
|
|
|
Mux(popped.none(), masterInvalid,
|
|
|
|
Mux(popped.one(), masterExclusive, masterShared)), popped)(this)
|
|
|
|
def is(r: UInt) = incoming.r_type === r
|
|
|
|
MuxBundle(m, Array(
|
|
|
|
is(releaseVoluntaryInvalidateData) -> next,
|
|
|
|
is(releaseInvalidateData) -> next,
|
|
|
|
is(releaseDowngradeData) -> m,
|
|
|
|
is(releaseCopyData) -> m,
|
|
|
|
is(releaseInvalidateAck) -> next,
|
|
|
|
is(releaseDowngradeAck) -> m,
|
|
|
|
is(releaseCopyAck) -> m
|
2012-03-02 03:23:46 +01:00
|
|
|
))
|
2012-02-15 00:51:32 +01:00
|
|
|
}
|
2012-03-02 02:03:56 +01:00
|
|
|
|
2013-08-02 23:55:06 +02:00
|
|
|
def getUncachedReadAcquireType = acquireReadUncached
|
|
|
|
def getUncachedWriteAcquireType = acquireWriteUncached
|
|
|
|
def getUncachedReadWordAcquireType = acquireReadWordUncached
|
|
|
|
def getUncachedWriteWordAcquireType = acquireWriteWordUncached
|
|
|
|
def getUncachedAtomicAcquireType = acquireAtomicUncached
|
2013-01-22 02:17:26 +01:00
|
|
|
def isUncachedReadTransaction(acq: Acquire) = acq.a_type === acquireReadUncached
|
2013-01-29 01:39:45 +01:00
|
|
|
def isVoluntary(rel: Release) = rel.r_type === releaseVoluntaryInvalidateData
|
2013-03-01 03:13:41 +01:00
|
|
|
def isVoluntary(gnt: Grant) = gnt.g_type === grantVoluntaryAck
|
2012-10-02 01:05:37 +02:00
|
|
|
|
2014-05-28 22:35:08 +02:00
|
|
|
def getAcquireTypeOnPrimaryMiss(cmd: UInt, m: ClientMetadata): UInt = {
|
2013-04-04 07:13:51 +02:00
|
|
|
Mux(isWriteIntent(cmd), acquireReadExclusive, acquireReadShared)
|
2012-04-03 21:03:05 +02:00
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def getAcquireTypeOnSecondaryMiss(cmd: UInt, m: ClientMetadata, outstanding: Acquire): UInt = {
|
2013-04-08 04:23:44 +02:00
|
|
|
Mux(isWriteIntent(cmd), acquireReadExclusive, outstanding.a_type)
|
2012-04-03 21:03:05 +02:00
|
|
|
}
|
2014-01-21 21:20:55 +01:00
|
|
|
def getReleaseTypeOnCacheControl(cmd: UInt): UInt = releaseVoluntaryInvalidateData // TODO
|
|
|
|
def getReleaseTypeOnVoluntaryWriteback(): UInt = getReleaseTypeOnCacheControl(M_INV)
|
2014-05-28 22:35:08 +02:00
|
|
|
def getReleaseTypeOnProbe(incoming: Probe, m: ClientMetadata): UInt = {
|
2013-01-22 02:17:26 +01:00
|
|
|
val with_data = MuxLookup(incoming.p_type, releaseInvalidateData, Array(
|
|
|
|
probeInvalidate -> releaseInvalidateData,
|
|
|
|
probeDowngrade -> releaseDowngradeData,
|
|
|
|
probeCopy -> releaseCopyData
|
2012-03-14 00:43:35 +01:00
|
|
|
))
|
2013-01-22 02:17:26 +01:00
|
|
|
val without_data = MuxLookup(incoming.p_type, releaseInvalidateAck, Array(
|
|
|
|
probeInvalidate -> releaseInvalidateAck,
|
|
|
|
probeDowngrade -> releaseDowngradeAck,
|
|
|
|
probeCopy -> releaseCopyAck
|
2012-03-14 00:43:35 +01:00
|
|
|
))
|
2014-05-28 22:35:08 +02:00
|
|
|
Mux(needsWriteback(m), with_data, without_data)
|
2012-03-14 00:43:35 +01:00
|
|
|
}
|
2012-04-03 21:03:05 +02:00
|
|
|
|
2013-03-20 22:10:16 +01:00
|
|
|
def messageHasData(msg: SourcedMessage) = msg match {
|
2014-04-17 03:14:12 +02:00
|
|
|
case acq: Acquire => hasDataAcquireTypeVec.contains(acq.a_type)
|
|
|
|
case grant: Grant => hasDataGrantTypeVec.contains(grant.g_type)
|
|
|
|
case rel: Release => hasDataReleaseTypeVec.contains(rel.r_type)
|
2013-03-20 22:10:16 +01:00
|
|
|
case _ => Bool(false)
|
|
|
|
}
|
2013-01-22 02:17:26 +01:00
|
|
|
def messageUpdatesDataArray (reply: Grant): Bool = {
|
|
|
|
(reply.g_type === grantReadShared || reply.g_type === grantReadExclusive)
|
2012-04-10 09:09:58 +02:00
|
|
|
}
|
2014-04-17 03:14:12 +02:00
|
|
|
def messageIsUncached(acq: Acquire): Bool = uncachedAcquireTypeVec.contains(acq.a_type)
|
2012-02-15 00:51:32 +01:00
|
|
|
|
2014-01-21 21:20:55 +01:00
|
|
|
def isCoherenceConflict(addr1: UInt, addr2: UInt): Bool = (addr1 === addr2)
|
2012-04-03 21:03:05 +02:00
|
|
|
|
2014-07-11 02:10:32 +02:00
|
|
|
def getGrantType(a: Acquire, m: MasterMetadata): UInt = {
|
|
|
|
MuxLookup(a.a_type, grantReadUncached, Array(
|
|
|
|
acquireReadShared -> Mux(m.sharers.count() > UInt(0), grantReadShared, grantReadExclusive),
|
2013-01-22 02:17:26 +01:00
|
|
|
acquireReadExclusive -> grantReadExclusive,
|
|
|
|
acquireReadUncached -> grantReadUncached,
|
|
|
|
acquireWriteUncached -> grantWriteUncached,
|
|
|
|
acquireReadWordUncached -> grantReadWordUncached,
|
|
|
|
acquireWriteWordUncached -> grantWriteWordUncached,
|
|
|
|
acquireAtomicUncached -> grantAtomicUncached
|
2012-04-03 21:03:05 +02:00
|
|
|
))
|
2012-02-23 03:24:52 +01:00
|
|
|
}
|
2014-07-11 02:10:32 +02:00
|
|
|
def getGrantType(r: Release, m: MasterMetadata): UInt = {
|
|
|
|
MuxLookup(r.r_type, grantReadUncached, Array(
|
2013-01-29 01:39:45 +01:00
|
|
|
releaseVoluntaryInvalidateData -> grantVoluntaryAck
|
|
|
|
))
|
|
|
|
}
|
|
|
|
|
2012-02-22 21:14:57 +01:00
|
|
|
|
2014-07-11 02:10:32 +02:00
|
|
|
def getProbeType(a: Acquire, m: MasterMetadata): UInt = {
|
|
|
|
MuxLookup(a.a_type, probeCopy, Array(
|
2013-01-22 02:17:26 +01:00
|
|
|
acquireReadShared -> probeDowngrade,
|
|
|
|
acquireReadExclusive -> probeInvalidate,
|
|
|
|
acquireReadUncached -> probeCopy,
|
|
|
|
acquireWriteUncached -> probeInvalidate,
|
|
|
|
acquireReadWordUncached -> probeCopy,
|
|
|
|
acquireWriteWordUncached -> probeInvalidate,
|
|
|
|
acquireAtomicUncached -> probeInvalidate
|
2012-03-03 08:51:53 +01:00
|
|
|
))
|
2012-02-29 02:33:06 +01:00
|
|
|
}
|
|
|
|
|
2014-05-28 22:35:08 +02:00
|
|
|
def requiresOuterRead(a_type: UInt) = {
|
2013-01-22 02:17:26 +01:00
|
|
|
(a_type != acquireWriteUncached)
|
2012-02-29 11:59:27 +01:00
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def requiresOuterWrite(a_type: UInt) = {
|
2013-01-22 02:17:26 +01:00
|
|
|
(a_type === acquireWriteUncached)
|
2012-02-29 11:59:27 +01:00
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def requiresOuterRead(a_type: UInt, m: MasterMetadata) = requiresOuterRead(a_type)
|
|
|
|
def requiresOuterWrite(a_type: UInt, m: MasterMetadata) = requiresOuterWrite(a_type)
|
2013-01-29 01:39:45 +01:00
|
|
|
|
2014-01-21 21:20:55 +01:00
|
|
|
def requiresAckForGrant(g_type: UInt) = g_type != grantVoluntaryAck
|
|
|
|
def requiresAckForRelease(r_type: UInt) = Bool(false)
|
|
|
|
def requiresSelfProbe(a_type: UInt) = Bool(false)
|
2013-03-01 03:13:41 +01:00
|
|
|
|
2013-08-12 19:36:44 +02:00
|
|
|
def pendingVoluntaryReleaseIsSufficient(r_type: UInt, p_type: UInt): Bool = (r_type === releaseVoluntaryInvalidateData)
|
2012-02-23 03:24:52 +01:00
|
|
|
}
|
2012-10-24 03:01:53 +02:00
|
|
|
|
2014-07-11 02:01:19 +02:00
|
|
|
class MigratoryCoherence(dir: () => DirectoryRepresentation) extends CoherencePolicyWithUncached(dir) {
|
2013-08-02 23:55:06 +02:00
|
|
|
def nClientStates = 7
|
2014-05-28 22:35:08 +02:00
|
|
|
def nMasterStates = 3
|
2013-08-02 23:55:06 +02:00
|
|
|
def nAcquireTypes = 8
|
|
|
|
def nProbeTypes = 4
|
|
|
|
def nReleaseTypes = 11
|
|
|
|
def nGrantTypes = 9
|
2012-10-24 03:01:53 +02:00
|
|
|
|
2014-05-28 22:35:08 +02:00
|
|
|
val clientInvalid :: clientShared :: clientExclusiveClean :: clientExclusiveDirty :: clientSharedByTwo :: clientMigratoryClean :: clientMigratoryDirty :: Nil = Enum(UInt(), nClientStates)
|
|
|
|
val masterInvalid :: masterShared :: masterExclusive :: Nil = Enum(UInt(), nMasterStates)
|
2012-10-24 03:01:53 +02:00
|
|
|
|
2013-09-10 19:54:51 +02:00
|
|
|
val acquireReadShared :: acquireReadExclusive :: acquireReadUncached :: acquireWriteUncached :: acquireReadWordUncached :: acquireWriteWordUncached :: acquireAtomicUncached :: acquireInvalidateOthers :: Nil = Enum(UInt(), nAcquireTypes)
|
|
|
|
val probeInvalidate :: probeDowngrade :: probeCopy :: probeInvalidateOthers :: Nil = Enum(UInt(), nProbeTypes)
|
|
|
|
val releaseVoluntaryInvalidateData :: releaseInvalidateData :: releaseDowngradeData :: releaseCopyData :: releaseInvalidateAck :: releaseDowngradeAck :: releaseCopyAck :: releaseDowngradeDataMigratory :: releaseDowngradeAckHasCopy :: releaseInvalidateDataMigratory :: releaseInvalidateAckMigratory :: Nil = Enum(UInt(), nReleaseTypes)
|
|
|
|
val grantVoluntaryAck :: grantReadShared :: grantReadExclusive :: grantReadUncached :: grantWriteUncached :: grantReadExclusiveAck :: grantReadWordUncached :: grantWriteWordUncached :: grantAtomicUncached :: grantReadMigratory :: Nil = Enum(UInt(), nGrantTypes)
|
2012-10-24 03:01:53 +02:00
|
|
|
|
2014-04-17 03:14:12 +02:00
|
|
|
val uncachedAcquireTypeVec = Vec(acquireReadUncached, acquireWriteUncached, acquireReadWordUncached, acquireWriteWordUncached, acquireAtomicUncached)
|
|
|
|
val hasDataAcquireTypeVec = Vec(acquireWriteUncached, acquireWriteWordUncached, acquireAtomicUncached)
|
|
|
|
val hasDataGrantTypeVec = Vec(grantReadShared, grantReadExclusive, grantReadUncached, grantReadMigratory, grantReadWordUncached, grantAtomicUncached)
|
|
|
|
val hasDataReleaseTypeVec = Vec(releaseVoluntaryInvalidateData, releaseInvalidateData, releaseDowngradeData, releaseCopyData, releaseInvalidateDataMigratory, releaseDowngradeDataMigratory)
|
2012-10-24 03:01:53 +02:00
|
|
|
|
2014-05-28 22:35:08 +02:00
|
|
|
def isHit (cmd: UInt, m: ClientMetadata): Bool = {
|
|
|
|
Mux(isWriteIntent(cmd), Vec(clientExclusiveClean, clientExclusiveDirty, clientMigratoryClean, clientMigratoryDirty).contains(m.state), (m.state != clientInvalid))
|
2012-10-24 03:01:53 +02:00
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def isValid (m: ClientMetadata): Bool = {
|
|
|
|
m.state != clientInvalid
|
2012-10-24 03:01:53 +02:00
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def isHit (incoming: Acquire, m: MasterMetadata) = isValid(m)
|
|
|
|
def isValid (m: MasterMetadata) = m.state != masterInvalid
|
2012-10-24 03:01:53 +02:00
|
|
|
|
2013-08-12 19:36:44 +02:00
|
|
|
def needsTransactionOnSecondaryMiss(cmd: UInt, outstanding: Acquire): Bool = {
|
2013-04-08 04:23:44 +02:00
|
|
|
(isRead(cmd) && messageIsUncached(outstanding)) ||
|
|
|
|
(isWriteIntent(cmd) && (outstanding.a_type != acquireReadExclusive && outstanding.a_type != acquireInvalidateOthers))
|
2012-10-24 03:01:53 +02:00
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def needsTransactionOnCacheControl(cmd: UInt, m: ClientMetadata): Bool = {
|
|
|
|
MuxLookup(cmd, (m.state === clientExclusiveDirty), Array(
|
|
|
|
M_INV -> Vec(clientExclusiveDirty,clientMigratoryDirty).contains(m.state),
|
|
|
|
M_CLN -> Vec(clientExclusiveDirty,clientMigratoryDirty).contains(m.state)
|
|
|
|
))
|
|
|
|
}
|
|
|
|
def needsWriteback (m: ClientMetadata): Bool = {
|
|
|
|
needsTransactionOnCacheControl(M_INV, m)
|
|
|
|
}
|
|
|
|
|
|
|
|
def clientMetadataOnHit(cmd: UInt, m: ClientMetadata) = ClientMetadata(
|
|
|
|
Mux(isWrite(cmd), MuxLookup(m.state, clientExclusiveDirty, Array(
|
|
|
|
clientExclusiveClean -> clientExclusiveDirty,
|
|
|
|
clientMigratoryClean -> clientMigratoryDirty)), m.state))(this)
|
|
|
|
def clientMetadataOnCacheControl(cmd: UInt) = ClientMetadata(
|
|
|
|
MuxLookup(cmd, clientInvalid, Array(
|
|
|
|
M_INV -> clientInvalid,
|
|
|
|
M_CLN -> clientShared
|
|
|
|
)))(this)
|
|
|
|
def clientMetadataOnFlush = clientMetadataOnCacheControl(M_INV)
|
|
|
|
def clientMetadataOnGrant(incoming: Grant, outstanding: Acquire) = ClientMetadata(
|
|
|
|
MuxLookup(incoming.g_type, clientInvalid, Array(
|
|
|
|
grantReadShared -> clientShared,
|
|
|
|
grantReadExclusive -> MuxLookup(outstanding.a_type, clientExclusiveDirty, Array(
|
|
|
|
acquireReadExclusive -> clientExclusiveDirty,
|
|
|
|
acquireReadShared -> clientExclusiveClean)),
|
|
|
|
grantReadExclusiveAck -> clientExclusiveDirty,
|
|
|
|
grantReadUncached -> clientInvalid,
|
|
|
|
grantWriteUncached -> clientInvalid,
|
|
|
|
grantReadWordUncached -> clientInvalid,
|
|
|
|
grantWriteWordUncached -> clientInvalid,
|
|
|
|
grantAtomicUncached -> clientInvalid,
|
|
|
|
grantReadMigratory -> MuxLookup(outstanding.a_type, clientMigratoryDirty, Array(
|
|
|
|
acquireInvalidateOthers -> clientMigratoryDirty,
|
|
|
|
acquireReadExclusive -> clientMigratoryDirty,
|
|
|
|
acquireReadShared -> clientMigratoryClean))
|
|
|
|
)))(this)
|
|
|
|
def clientMetadataOnProbe(incoming: Probe, m: ClientMetadata) = ClientMetadata(
|
|
|
|
MuxLookup(incoming.p_type, m.state, Array(
|
|
|
|
probeInvalidate -> clientInvalid,
|
|
|
|
probeInvalidateOthers -> clientInvalid,
|
|
|
|
probeCopy -> m.state,
|
|
|
|
probeDowngrade -> MuxLookup(m.state, clientShared, Array(
|
|
|
|
clientExclusiveClean -> clientSharedByTwo,
|
|
|
|
clientExclusiveDirty -> clientSharedByTwo,
|
|
|
|
clientSharedByTwo -> clientShared,
|
|
|
|
clientMigratoryClean -> clientSharedByTwo,
|
|
|
|
clientMigratoryDirty -> clientInvalid))
|
|
|
|
)))(this)
|
|
|
|
def masterMetadataOnFlush = MasterMetadata(masterInvalid)(this)
|
|
|
|
def masterMetadataOnRelease(incoming: Release, m: MasterMetadata, src: UInt) = {
|
|
|
|
val popped = m.sharers.pop(src)
|
|
|
|
val next = MasterMetadata(
|
|
|
|
Mux(popped.none(), masterInvalid,
|
|
|
|
Mux(popped.one(), masterExclusive, masterShared)),
|
|
|
|
popped)(this)
|
|
|
|
def is(r: UInt) = incoming.r_type === r
|
|
|
|
MuxBundle(m, Array(
|
|
|
|
is(releaseVoluntaryInvalidateData) -> next,
|
|
|
|
is(releaseInvalidateData) -> next,
|
|
|
|
is(releaseDowngradeData) -> m,
|
|
|
|
is(releaseCopyData) -> m,
|
|
|
|
is(releaseInvalidateAck) -> next,
|
|
|
|
is(releaseDowngradeAck) -> m,
|
|
|
|
is(releaseCopyAck) -> m,
|
|
|
|
is(releaseDowngradeDataMigratory) -> m,
|
|
|
|
is(releaseDowngradeAckHasCopy) -> m,
|
|
|
|
is(releaseInvalidateDataMigratory) -> next,
|
|
|
|
is(releaseInvalidateAckMigratory) -> next
|
2012-10-24 03:01:53 +02:00
|
|
|
))
|
|
|
|
}
|
|
|
|
|
2014-05-28 22:35:08 +02:00
|
|
|
|
2013-08-02 23:55:06 +02:00
|
|
|
def getUncachedReadAcquireType = acquireReadUncached
|
|
|
|
def getUncachedWriteAcquireType = acquireWriteUncached
|
|
|
|
def getUncachedReadWordAcquireType = acquireReadWordUncached
|
|
|
|
def getUncachedWriteWordAcquireType = acquireWriteWordUncached
|
|
|
|
def getUncachedAtomicAcquireType = acquireAtomicUncached
|
2013-01-22 02:17:26 +01:00
|
|
|
def isUncachedReadTransaction(acq: Acquire) = acq.a_type === acquireReadUncached
|
2013-01-29 01:39:45 +01:00
|
|
|
def isVoluntary(rel: Release) = rel.r_type === releaseVoluntaryInvalidateData
|
2013-03-01 03:13:41 +01:00
|
|
|
def isVoluntary(gnt: Grant) = gnt.g_type === grantVoluntaryAck
|
2012-10-24 03:01:53 +02:00
|
|
|
|
2014-05-28 22:35:08 +02:00
|
|
|
def getAcquireTypeOnPrimaryMiss(cmd: UInt, m: ClientMetadata): UInt = {
|
|
|
|
Mux(isWriteIntent(cmd), Mux(m.state === clientInvalid, acquireReadExclusive, acquireInvalidateOthers), acquireReadShared)
|
2012-10-24 03:01:53 +02:00
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def getAcquireTypeOnSecondaryMiss(cmd: UInt, m: ClientMetadata, outstanding: Acquire): UInt = {
|
|
|
|
Mux(isWriteIntent(cmd), Mux(m.state === clientInvalid, acquireReadExclusive, acquireInvalidateOthers), outstanding.a_type)
|
2013-01-22 02:17:26 +01:00
|
|
|
}
|
2014-01-21 21:20:55 +01:00
|
|
|
def getReleaseTypeOnCacheControl(cmd: UInt): UInt = releaseVoluntaryInvalidateData // TODO
|
|
|
|
def getReleaseTypeOnVoluntaryWriteback(): UInt = getReleaseTypeOnCacheControl(M_INV)
|
2014-05-28 22:35:08 +02:00
|
|
|
def getReleaseTypeOnProbe(incoming: Probe, m: ClientMetadata): UInt = {
|
2013-01-22 02:17:26 +01:00
|
|
|
val with_data = MuxLookup(incoming.p_type, releaseInvalidateData, Array(
|
2014-05-28 22:35:08 +02:00
|
|
|
probeInvalidate -> Mux(Vec(clientExclusiveDirty, clientMigratoryDirty).contains(m.state),
|
2013-01-22 02:17:26 +01:00
|
|
|
releaseInvalidateDataMigratory, releaseInvalidateData),
|
2014-05-28 22:35:08 +02:00
|
|
|
probeDowngrade -> Mux(m.state === clientMigratoryDirty, releaseDowngradeDataMigratory, releaseDowngradeData),
|
2013-08-02 23:55:06 +02:00
|
|
|
probeCopy -> releaseCopyData
|
2013-01-22 02:17:26 +01:00
|
|
|
))
|
|
|
|
val without_data = MuxLookup(incoming.p_type, releaseInvalidateAck, Array(
|
2014-05-28 22:35:08 +02:00
|
|
|
probeInvalidate -> Mux(clientExclusiveClean === m.state, releaseInvalidateAckMigratory, releaseInvalidateAck),
|
|
|
|
probeInvalidateOthers -> Mux(m.state === clientSharedByTwo, releaseInvalidateAckMigratory, releaseInvalidateAck),
|
|
|
|
probeDowngrade -> Mux(m.state != clientInvalid, releaseDowngradeAckHasCopy, releaseDowngradeAck),
|
2013-01-22 02:17:26 +01:00
|
|
|
probeCopy -> releaseCopyAck
|
|
|
|
))
|
2014-05-28 22:35:08 +02:00
|
|
|
Mux(needsWriteback(m), with_data, without_data)
|
2012-10-24 03:01:53 +02:00
|
|
|
}
|
|
|
|
|
2013-03-20 22:10:16 +01:00
|
|
|
def messageHasData(msg: SourcedMessage) = msg match {
|
2014-04-17 03:14:12 +02:00
|
|
|
case acq: Acquire => hasDataAcquireTypeVec.contains(acq.a_type)
|
|
|
|
case grant: Grant => hasDataGrantTypeVec.contains(grant.g_type)
|
|
|
|
case rel: Release => hasDataReleaseTypeVec.contains(rel.r_type)
|
2013-03-20 22:10:16 +01:00
|
|
|
case _ => Bool(false)
|
|
|
|
}
|
2014-04-17 03:14:12 +02:00
|
|
|
def messageUpdatesDataArray (reply: Grant): Bool = Vec(grantReadShared, grantReadExclusive, grantReadMigratory).contains(reply.g_type)
|
|
|
|
def messageIsUncached(acq: Acquire): Bool = uncachedAcquireTypeVec.contains(acq.a_type)
|
2012-10-24 03:01:53 +02:00
|
|
|
|
2014-01-21 21:20:55 +01:00
|
|
|
def isCoherenceConflict(addr1: UInt, addr2: UInt): Bool = (addr1 === addr2)
|
2012-10-24 03:01:53 +02:00
|
|
|
|
2014-07-11 02:10:32 +02:00
|
|
|
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???
|
2013-01-22 02:17:26 +01:00
|
|
|
acquireReadExclusive -> grantReadExclusive,
|
|
|
|
acquireReadUncached -> grantReadUncached,
|
|
|
|
acquireWriteUncached -> grantWriteUncached,
|
|
|
|
acquireReadWordUncached -> grantReadWordUncached,
|
|
|
|
acquireWriteWordUncached -> grantWriteWordUncached,
|
|
|
|
acquireAtomicUncached -> grantAtomicUncached,
|
2014-05-28 22:35:08 +02:00
|
|
|
acquireInvalidateOthers -> grantReadExclusiveAck //TODO: add this to MESI?
|
2012-10-24 03:01:53 +02:00
|
|
|
))
|
|
|
|
}
|
2014-07-11 02:10:32 +02:00
|
|
|
def getGrantType(r: Release, m: MasterMetadata): UInt = {
|
|
|
|
MuxLookup(r.r_type, grantReadUncached, Array(
|
2013-01-29 01:39:45 +01:00
|
|
|
releaseVoluntaryInvalidateData -> grantVoluntaryAck
|
|
|
|
))
|
|
|
|
}
|
|
|
|
|
2012-10-24 03:01:53 +02:00
|
|
|
|
2014-07-11 02:10:32 +02:00
|
|
|
def getProbeType(a: Acquire, m: MasterMetadata): UInt = {
|
|
|
|
MuxLookup(a.a_type, probeCopy, Array(
|
2013-01-22 02:17:26 +01:00
|
|
|
acquireReadShared -> probeDowngrade,
|
|
|
|
acquireReadExclusive -> probeInvalidate,
|
|
|
|
acquireReadUncached -> probeCopy,
|
|
|
|
acquireWriteUncached -> probeInvalidate,
|
|
|
|
acquireReadWordUncached -> probeCopy,
|
|
|
|
acquireWriteWordUncached -> probeInvalidate,
|
|
|
|
acquireAtomicUncached -> probeInvalidate,
|
|
|
|
acquireInvalidateOthers -> probeInvalidateOthers
|
2012-10-24 03:01:53 +02:00
|
|
|
))
|
|
|
|
}
|
|
|
|
|
2014-05-28 22:35:08 +02:00
|
|
|
def requiresOuterRead(a_type: UInt) = {
|
2013-01-22 02:17:26 +01:00
|
|
|
(a_type != acquireWriteUncached && a_type != acquireInvalidateOthers)
|
2012-10-24 03:01:53 +02:00
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def requiresOuterWrite(a_type: UInt) = {
|
2013-01-22 02:17:26 +01:00
|
|
|
(a_type === acquireWriteUncached || a_type === acquireWriteWordUncached || a_type === acquireAtomicUncached)
|
2012-10-24 03:01:53 +02:00
|
|
|
}
|
2014-05-28 22:35:08 +02:00
|
|
|
def requiresOuterRead(a_type: UInt, m: MasterMetadata) = requiresOuterRead(a_type)
|
|
|
|
def requiresOuterWrite(a_type: UInt, m: MasterMetadata) = requiresOuterWrite(a_type)
|
2014-01-21 21:20:55 +01:00
|
|
|
|
|
|
|
def requiresAckForGrant(g_type: UInt) = g_type != grantVoluntaryAck
|
|
|
|
def requiresAckForRelease(r_type: UInt) = Bool(false)
|
|
|
|
def requiresSelfProbe(a_type: UInt) = Bool(false)
|
2013-03-01 03:13:41 +01:00
|
|
|
|
2013-08-12 19:36:44 +02:00
|
|
|
def pendingVoluntaryReleaseIsSufficient(r_type: UInt, p_type: UInt): Bool = (r_type === releaseVoluntaryInvalidateData)
|
2012-10-24 03:01:53 +02:00
|
|
|
}
|