114184Sgabeblack@google.com/*
214184Sgabeblack@google.com * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
314184Sgabeblack@google.com * All rights reserved.
414184Sgabeblack@google.com *
514184Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
614184Sgabeblack@google.com * modification, are permitted provided that the following conditions are
714184Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
814184Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
914184Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
1014184Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
1114184Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
1214184Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
1314184Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
1414184Sgabeblack@google.com * this software without specific prior written permission.
1514184Sgabeblack@google.com *
1614184Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1714184Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1814184Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1914184Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2014184Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2114184Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2214184Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2314184Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2414184Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2514184Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2614184Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2714184Sgabeblack@google.com *
2814184Sgabeblack@google.com * AMD's contributions to the MOESI hammer protocol do not constitute an 
2914184Sgabeblack@google.com * endorsement of its similarity to any AMD products.
3014184Sgabeblack@google.com */
3114184Sgabeblack@google.com
3214184Sgabeblack@google.com// CoherenceRequestType
3314184Sgabeblack@google.comenumeration(CoherenceRequestType, desc="...") {
3414184Sgabeblack@google.com  GETX,      desc="Get eXclusive";
3514184Sgabeblack@google.com  GETS,      desc="Get Shared";
3614184Sgabeblack@google.com  MERGED_GETS, desc="Get Shared";
3714184Sgabeblack@google.com  PUT,       desc="Put Ownership";
3814184Sgabeblack@google.com  WB_ACK,    desc="Writeback ack";
3914184Sgabeblack@google.com  WB_NACK,   desc="Writeback neg. ack";
4014184Sgabeblack@google.com  PUTF,      desc="PUT on a Flush";
4114184Sgabeblack@google.com  GETF,      desc="Issue exclusive for Flushing";
4214184Sgabeblack@google.com  BLOCK_ACK, desc="Dir Block ack";
4314184Sgabeblack@google.com  INV,       desc="Invalidate";
4414184Sgabeblack@google.com}
4514184Sgabeblack@google.com
4614184Sgabeblack@google.com// CoherenceResponseType
4714184Sgabeblack@google.comenumeration(CoherenceResponseType, desc="...") {
4814184Sgabeblack@google.com  ACK,                desc="ACKnowledgment, responder does not have a copy";
4914184Sgabeblack@google.com  ACK_SHARED,         desc="ACKnowledgment, responder has a shared copy";
5014184Sgabeblack@google.com  DATA,               desc="Data, responder does not have a copy";
5114184Sgabeblack@google.com  DATA_SHARED,        desc="Data, responder has a shared copy";
5214184Sgabeblack@google.com  DATA_EXCLUSIVE,     desc="Data, responder was exclusive, gave us a copy, and they went to invalid";
5314184Sgabeblack@google.com  WB_CLEAN,           desc="Clean writeback";
5414184Sgabeblack@google.com  WB_DIRTY,           desc="Dirty writeback";
5514184Sgabeblack@google.com  WB_EXCLUSIVE_CLEAN, desc="Clean writeback of exclusive data";
5614184Sgabeblack@google.com  WB_EXCLUSIVE_DIRTY, desc="Dirty writeback of exclusive data";
5714184Sgabeblack@google.com  UNBLOCK,            desc="Unblock for writeback";
5814184Sgabeblack@google.com  UNBLOCKS,            desc="Unblock now in S";
5914184Sgabeblack@google.com  UNBLOCKM,            desc="Unblock now in M/O/E";
6014184Sgabeblack@google.com  NULL,               desc="Null value";
6114184Sgabeblack@google.com}
6214184Sgabeblack@google.com
6314184Sgabeblack@google.com// TriggerType
6414184Sgabeblack@google.comenumeration(TriggerType, desc="...") {
6514184Sgabeblack@google.com  L2_to_L1,            desc="L2 to L1 transfer";
6614184Sgabeblack@google.com  ALL_ACKS,            desc="See corresponding event";
6714184Sgabeblack@google.com  ALL_ACKS_OWNER_EXISTS,desc="See corresponding event";
6814184Sgabeblack@google.com  ALL_ACKS_NO_SHARERS, desc="See corresponding event";
6914184Sgabeblack@google.com  ALL_UNBLOCKS,        desc="all unblockS received";
7014184Sgabeblack@google.com}
7114184Sgabeblack@google.com
7214184Sgabeblack@google.com// TriggerMsg
7314184Sgabeblack@google.comstructure(TriggerMsg, desc="...", interface="Message") {
7414184Sgabeblack@google.com  Addr addr,             desc="Physical address for this request";
7514184Sgabeblack@google.com  TriggerType Type,            desc="Type of trigger";
7614184Sgabeblack@google.com
7714184Sgabeblack@google.com  bool functionalRead(Packet *pkt) {
7814184Sgabeblack@google.com    // Trigger messages do not hold any data!
7914184Sgabeblack@google.com    return false;
8014184Sgabeblack@google.com  }
8114184Sgabeblack@google.com
8214184Sgabeblack@google.com  bool functionalWrite(Packet *pkt) {
8314184Sgabeblack@google.com    // Trigger messages do not hold any data!
8414184Sgabeblack@google.com    return false;
8514184Sgabeblack@google.com  }
8614184Sgabeblack@google.com}
8714184Sgabeblack@google.com
8814184Sgabeblack@google.com// RequestMsg (and also forwarded requests)
8914184Sgabeblack@google.comstructure(RequestMsg, desc="...", interface="Message") {
9014184Sgabeblack@google.com  Addr addr,             desc="Physical address for this request";
9114184Sgabeblack@google.com  CoherenceRequestType Type,   desc="Type of request (GetS, GetX, PutX, etc)";
9214184Sgabeblack@google.com  MachineID Requestor,            desc="Node who initiated the request";
9314184Sgabeblack@google.com  NetDest MergedRequestors,    desc="Merge set of read requestors";
9414184Sgabeblack@google.com  NetDest Destination,             desc="Multicast destination mask";
9514184Sgabeblack@google.com  MessageSizeType MessageSize, desc="size category of the message";
9614184Sgabeblack@google.com  bool DirectedProbe, default="false", desc="probe filter directed probe";
9714184Sgabeblack@google.com
9814184Sgabeblack@google.com  Cycles InitialRequestTime, default="Cycles(0)",
9914184Sgabeblack@google.com        desc="time the initial requests was sent from the L1Cache";
10014184Sgabeblack@google.com  Cycles ForwardRequestTime, default="Cycles(0)",
10114184Sgabeblack@google.com        desc="time the dir forwarded the request";
10214184Sgabeblack@google.com  int SilentAcks, default="0", desc="silent acks from the full-bit directory";
10314184Sgabeblack@google.com
10414184Sgabeblack@google.com  bool functionalRead(Packet *pkt) {
10514184Sgabeblack@google.com    // Request messages do not hold any data
10614184Sgabeblack@google.com    return false;
10714184Sgabeblack@google.com  }
10814184Sgabeblack@google.com
10914184Sgabeblack@google.com  bool functionalWrite(Packet *pkt) {
11014184Sgabeblack@google.com    // Request messages do not hold any data
11114184Sgabeblack@google.com    return false;
11214184Sgabeblack@google.com  }
11314184Sgabeblack@google.com}
11414184Sgabeblack@google.com
11514184Sgabeblack@google.com// ResponseMsg (and also unblock requests)
11614184Sgabeblack@google.comstructure(ResponseMsg, desc="...", interface="Message") {
11714184Sgabeblack@google.com  Addr addr,             desc="Physical address for this request";
11814184Sgabeblack@google.com  CoherenceResponseType Type,  desc="Type of response (Ack, Data, etc)";
11914184Sgabeblack@google.com  MachineID Sender,               desc="Node who sent the data";
12014184Sgabeblack@google.com  MachineID CurOwner,      desc="current owner of the block, used for UnblockS responses";
12114184Sgabeblack@google.com  NetDest Destination,             desc="Node to whom the data is sent";
12214184Sgabeblack@google.com  DataBlock DataBlk,           desc="data for the cache line";
12314184Sgabeblack@google.com  bool Dirty,                  desc="Is the data dirty (different than memory)?";
12414184Sgabeblack@google.com  int Acks, default="0",    desc="How many messages this counts as";
12514184Sgabeblack@google.com  MessageSizeType MessageSize, desc="size category of the message";
12614184Sgabeblack@google.com
12714184Sgabeblack@google.com  Cycles InitialRequestTime, default="Cycles(0)",
12814184Sgabeblack@google.com        desc="time the initial requests was sent from the L1Cache";
12914184Sgabeblack@google.com  Cycles ForwardRequestTime, default="Cycles(0)",
13014184Sgabeblack@google.com        desc="time the dir forwarded the request";
13114184Sgabeblack@google.com  int SilentAcks, default="0", desc="silent acks from the full-bit directory";
13214184Sgabeblack@google.com
13314184Sgabeblack@google.com  bool functionalRead(Packet *pkt) {
13414184Sgabeblack@google.com    // The check below ensures that data is read only from messages that
13514184Sgabeblack@google.com    // actually hold data.
13614184Sgabeblack@google.com    if (Type == CoherenceResponseType:DATA ||
13714184Sgabeblack@google.com        Type == CoherenceResponseType:DATA_SHARED ||
13814184Sgabeblack@google.com        Type == CoherenceResponseType:DATA_EXCLUSIVE ||
13914184Sgabeblack@google.com        Type == CoherenceResponseType:WB_DIRTY ||
14014184Sgabeblack@google.com        Type == CoherenceResponseType:WB_EXCLUSIVE_DIRTY) {
14114184Sgabeblack@google.com        return testAndRead(addr, DataBlk, pkt);
14214184Sgabeblack@google.com    }
14314184Sgabeblack@google.com
14414184Sgabeblack@google.com    return false;
14514184Sgabeblack@google.com  }
14614184Sgabeblack@google.com
14714184Sgabeblack@google.com  bool functionalWrite(Packet *pkt) {
14814184Sgabeblack@google.com    // Message type does not matter since all messages are written.
14914184Sgabeblack@google.com    // If a protocol reads data from a packet that is not supposed
15014184Sgabeblack@google.com    // to hold the data, then the fault lies with the protocol.
15114184Sgabeblack@google.com    return testAndWrite(addr, DataBlk, pkt);
15214184Sgabeblack@google.com  }
15314184Sgabeblack@google.com}
15414184Sgabeblack@google.com
15514184Sgabeblack@google.comenumeration(DMARequestType, desc="...", default="DMARequestType_NULL") {
15614184Sgabeblack@google.com  READ,          desc="Memory Read";
15714184Sgabeblack@google.com  WRITE,         desc="Memory Write";
15814184Sgabeblack@google.com  NULL,          desc="Invalid";
15914184Sgabeblack@google.com}
16014184Sgabeblack@google.com
16114184Sgabeblack@google.comenumeration(DMAResponseType, desc="...", default="DMAResponseType_NULL") {
16214184Sgabeblack@google.com  DATA,          desc="DATA read";
16314184Sgabeblack@google.com  ACK,           desc="ACK write";
16414184Sgabeblack@google.com  NULL,          desc="Invalid";
16514184Sgabeblack@google.com}
16614184Sgabeblack@google.com
16714184Sgabeblack@google.comstructure(DMARequestMsg, desc="...", interface="Message") {
16814184Sgabeblack@google.com  DMARequestType Type,       desc="Request type (read/write)";
16914184Sgabeblack@google.com  Addr PhysicalAddress,   desc="Physical address for this request";
17014184Sgabeblack@google.com  Addr LineAddress,       desc="Line address for this request";
17114184Sgabeblack@google.com  MachineID Requestor,            desc="Node who initiated the request";
17214184Sgabeblack@google.com  NetDest Destination,       desc="Destination";
17314184Sgabeblack@google.com  DataBlock DataBlk,         desc="DataBlk attached to this request";
17414184Sgabeblack@google.com  int Len,                   desc="The length of the request";
17514184Sgabeblack@google.com  MessageSizeType MessageSize, desc="size category of the message";
17614184Sgabeblack@google.com
17714184Sgabeblack@google.com  bool functionalRead(Packet *pkt) {
17814184Sgabeblack@google.com    return testAndRead(LineAddress, DataBlk, pkt);
17914184Sgabeblack@google.com  }
18014184Sgabeblack@google.com
18114184Sgabeblack@google.com  bool functionalWrite(Packet *pkt) {
18214184Sgabeblack@google.com    return testAndWrite(LineAddress, DataBlk, pkt);
18314184Sgabeblack@google.com  }
18414184Sgabeblack@google.com}
18514184Sgabeblack@google.com
18614184Sgabeblack@google.comstructure(DMAResponseMsg, desc="...", interface="Message") {
18714184Sgabeblack@google.com  DMAResponseType Type,      desc="Response type (DATA/ACK)";
18814184Sgabeblack@google.com  Addr PhysicalAddress,   desc="Physical address for this request";
18914184Sgabeblack@google.com  Addr LineAddress,       desc="Line address for this request";
19014184Sgabeblack@google.com  NetDest Destination,       desc="Destination";
19114184Sgabeblack@google.com  DataBlock DataBlk,         desc="DataBlk attached to this request";
19214184Sgabeblack@google.com  MessageSizeType MessageSize, desc="size category of the message";
19314184Sgabeblack@google.com
19414184Sgabeblack@google.com  bool functionalRead(Packet *pkt) {
19514184Sgabeblack@google.com    return testAndRead(LineAddress, DataBlk, pkt);
19614184Sgabeblack@google.com  }
19714184Sgabeblack@google.com
19814184Sgabeblack@google.com  bool functionalWrite(Packet *pkt) {
19914184Sgabeblack@google.com    return testAndWrite(LineAddress, DataBlk, pkt);
20014184Sgabeblack@google.com  }
20114184Sgabeblack@google.com}
202