MOESI_CMP_token-L2cache.sm revision 14184
114184Sgabeblack@google.com/*
214184Sgabeblack@google.com * Copyright (c) 1999-2013 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
2914184Sgabeblack@google.commachine(MachineType:L2Cache, "Token protocol")
3014184Sgabeblack@google.com : CacheMemory * L2cache;
3114184Sgabeblack@google.com   int N_tokens;
3214184Sgabeblack@google.com   Cycles l2_request_latency := 5;
3314184Sgabeblack@google.com   Cycles l2_response_latency := 5;
3414184Sgabeblack@google.com   bool filtering_enabled := "True";
3514184Sgabeblack@google.com
3614184Sgabeblack@google.com   // L2 BANK QUEUES
3714184Sgabeblack@google.com   // From local bank of L2 cache TO the network
3814184Sgabeblack@google.com 
3914184Sgabeblack@google.com   // this L2 bank -> a local L1 || mod-directory
4014184Sgabeblack@google.com   MessageBuffer * responseFromL2Cache, network="To", virtual_network="4",
4114184Sgabeblack@google.com        vnet_type="response";
4214184Sgabeblack@google.com   // this L2 bank -> mod-directory
4314184Sgabeblack@google.com   MessageBuffer * GlobalRequestFromL2Cache, network="To", virtual_network="2",
4414184Sgabeblack@google.com        vnet_type="request";
4514184Sgabeblack@google.com   // this L2 bank -> a local L1
4614184Sgabeblack@google.com   MessageBuffer * L1RequestFromL2Cache, network="To", virtual_network="1",
4714184Sgabeblack@google.com        vnet_type="request";
4814184Sgabeblack@google.com 
4914184Sgabeblack@google.com 
5014184Sgabeblack@google.com   // FROM the network to this local bank of L2 cache
5114184Sgabeblack@google.com 
5214184Sgabeblack@google.com   // a local L1 || mod-directory -> this L2 bank
5314184Sgabeblack@google.com   MessageBuffer * responseToL2Cache, network="From", virtual_network="4",
5414184Sgabeblack@google.com        vnet_type="response";
5514184Sgabeblack@google.com   MessageBuffer * persistentToL2Cache, network="From", virtual_network="3",
5614184Sgabeblack@google.com        vnet_type="persistent";
5714184Sgabeblack@google.com   // mod-directory -> this L2 bank
5814184Sgabeblack@google.com   MessageBuffer * GlobalRequestToL2Cache, network="From", virtual_network="2",
5914184Sgabeblack@google.com        vnet_type="request";
6014184Sgabeblack@google.com   // a local L1 -> this L2 bank
6114184Sgabeblack@google.com   MessageBuffer * L1RequestToL2Cache, network="From", virtual_network="1",
6214184Sgabeblack@google.com        vnet_type="request";
6314184Sgabeblack@google.com
6414184Sgabeblack@google.com{
6514184Sgabeblack@google.com  // STATES
6614184Sgabeblack@google.com  state_declaration(State, desc="L2 Cache states", default="L2Cache_State_I") {
6714184Sgabeblack@google.com    // Base states
6814184Sgabeblack@google.com    NP, AccessPermission:Invalid, desc="Not Present";
6914184Sgabeblack@google.com    I, AccessPermission:Invalid, desc="Idle";
7014184Sgabeblack@google.com    S, AccessPermission:Read_Only, desc="Shared, not present in any local L1s";
7114184Sgabeblack@google.com    O, AccessPermission:Read_Only, desc="Owned, not present in any L1s";
7214184Sgabeblack@google.com    M, AccessPermission:Read_Write, desc="Modified, not present in any L1s";
7314184Sgabeblack@google.com
7414184Sgabeblack@google.com    // Locked states
7514184Sgabeblack@google.com    I_L, AccessPermission:Busy, "I^L", desc="Invalid, Locked";
7614184Sgabeblack@google.com    S_L, AccessPermission:Busy, "S^L", desc="Shared, Locked";
7714184Sgabeblack@google.com  }
7814184Sgabeblack@google.com
7914184Sgabeblack@google.com  // EVENTS
8014184Sgabeblack@google.com  enumeration(Event, desc="Cache events") {
8114184Sgabeblack@google.com
8214184Sgabeblack@google.com    // Requests
8314184Sgabeblack@google.com    L1_GETS,             desc="local L1 GETS request";
8414184Sgabeblack@google.com    L1_GETS_Last_Token,    desc="local L1 GETS request";
8514184Sgabeblack@google.com    L1_GETX,             desc="local L1 GETX request";
8614184Sgabeblack@google.com    L1_INV,              desc="L1 no longer has tokens";
8714184Sgabeblack@google.com    Transient_GETX,      desc="A GetX from another processor";
8814184Sgabeblack@google.com    Transient_GETS,      desc="A GetS from another processor";
8914184Sgabeblack@google.com    Transient_GETS_Last_Token,   desc="A GetS from another processor";
9014184Sgabeblack@google.com
9114184Sgabeblack@google.com    // events initiated by this L2
9214184Sgabeblack@google.com    L2_Replacement,     desc="L2 Replacement", format="!r";
9314184Sgabeblack@google.com
9414184Sgabeblack@google.com    // events of external L2 responses
9514184Sgabeblack@google.com
9614184Sgabeblack@google.com    // Responses
9714184Sgabeblack@google.com    Writeback_Tokens,               desc="Received a writeback from L1 with only tokens (no data)";
9814184Sgabeblack@google.com    Writeback_Shared_Data,               desc="Received a writeback from L1 that includes clean data";
9914184Sgabeblack@google.com    Writeback_All_Tokens,    desc="Received a writeback from L1";
10014184Sgabeblack@google.com    Writeback_Owned,                desc="Received a writeback from L1";
10114184Sgabeblack@google.com
10214184Sgabeblack@google.com
10314184Sgabeblack@google.com    Data_Shared,             desc="Received a data message, we are now a sharer";
10414184Sgabeblack@google.com    Data_Owner,              desc="Received a data message, we are now the owner";
10514184Sgabeblack@google.com    Data_All_Tokens,   desc="Received a data message, we are now the owner, we now have all the tokens";
10614184Sgabeblack@google.com    Ack,                     desc="Received an ack message";
10714184Sgabeblack@google.com    Ack_All_Tokens,          desc="Received an ack message, we now have all the tokens";
10814184Sgabeblack@google.com
10914184Sgabeblack@google.com    // Lock/Unlock
11014184Sgabeblack@google.com    Persistent_GETX,     desc="Another processor has priority to read/write";
11114184Sgabeblack@google.com    Persistent_GETS,     desc="Another processor has priority to read";
11214184Sgabeblack@google.com    Persistent_GETS_Last_Token, desc="Another processor has priority to read";
11314184Sgabeblack@google.com    Own_Lock_or_Unlock,  desc="This processor now has priority";
11414184Sgabeblack@google.com  }
11514184Sgabeblack@google.com
11614184Sgabeblack@google.com  // TYPES
11714184Sgabeblack@google.com
11814184Sgabeblack@google.com  // CacheEntry
11914184Sgabeblack@google.com  structure(Entry, desc="...", interface="AbstractCacheEntry") {
12014184Sgabeblack@google.com    State CacheState,        desc="cache state";
12114184Sgabeblack@google.com    bool Dirty,              desc="Is the data dirty (different than memory)?";
12214184Sgabeblack@google.com    int Tokens,              desc="The number of tokens we're holding for the line";
12314184Sgabeblack@google.com    DataBlock DataBlk,       desc="data for the block";
12414184Sgabeblack@google.com  }
12514184Sgabeblack@google.com
12614184Sgabeblack@google.com  structure(DirEntry, desc="...", interface="AbstractEntry") {
12714184Sgabeblack@google.com    Set Sharers,            desc="Set of the internal processors that want the block in shared state";
12814184Sgabeblack@google.com    bool exclusive, default="false", desc="if local exclusive is likely";
12914184Sgabeblack@google.com  }
13014184Sgabeblack@google.com
13114184Sgabeblack@google.com  structure(PerfectCacheMemory, external="yes") {
13214184Sgabeblack@google.com    void allocate(Addr);
13314184Sgabeblack@google.com    void deallocate(Addr);
13414184Sgabeblack@google.com    DirEntry lookup(Addr);
13514184Sgabeblack@google.com    bool isTagPresent(Addr);
13614184Sgabeblack@google.com  }
13714184Sgabeblack@google.com
13814184Sgabeblack@google.com  structure(PersistentTable, external="yes") {
13914184Sgabeblack@google.com    void persistentRequestLock(Addr, MachineID, AccessType);
14014184Sgabeblack@google.com    void persistentRequestUnlock(Addr, MachineID);
14114184Sgabeblack@google.com    MachineID findSmallest(Addr);
14214184Sgabeblack@google.com    AccessType typeOfSmallest(Addr);
14314184Sgabeblack@google.com    void markEntries(Addr);
14414184Sgabeblack@google.com    bool isLocked(Addr);
14514184Sgabeblack@google.com    int countStarvingForAddress(Addr);
14614184Sgabeblack@google.com    int countReadStarvingForAddress(Addr);
14714184Sgabeblack@google.com  }
14814184Sgabeblack@google.com
14914184Sgabeblack@google.com  PersistentTable persistentTable;
15014184Sgabeblack@google.com  PerfectCacheMemory localDirectory, template="<L2Cache_DirEntry>";
15114184Sgabeblack@google.com
15214184Sgabeblack@google.com  Tick clockEdge();
15314184Sgabeblack@google.com  void set_cache_entry(AbstractCacheEntry b);
15414184Sgabeblack@google.com  void unset_cache_entry();
15514184Sgabeblack@google.com  MachineID mapAddressToMachine(Addr addr, MachineType mtype);
15614184Sgabeblack@google.com
15714184Sgabeblack@google.com  Entry getCacheEntry(Addr address), return_by_pointer="yes" {
15814184Sgabeblack@google.com    Entry cache_entry := static_cast(Entry, "pointer", L2cache.lookup(address));
15914184Sgabeblack@google.com    return cache_entry;
16014184Sgabeblack@google.com  }
16114184Sgabeblack@google.com
16214184Sgabeblack@google.com  DirEntry getDirEntry(Addr address), return_by_pointer="yes" {
16314184Sgabeblack@google.com    return localDirectory.lookup(address);
16414184Sgabeblack@google.com  }
16514184Sgabeblack@google.com
16614184Sgabeblack@google.com  void functionalRead(Addr addr, Packet *pkt) {
16714184Sgabeblack@google.com    testAndRead(addr, getCacheEntry(addr).DataBlk, pkt);
16814184Sgabeblack@google.com  }
16914184Sgabeblack@google.com
17014184Sgabeblack@google.com  int functionalWrite(Addr addr, Packet *pkt) {
17114184Sgabeblack@google.com    int num_functional_writes := 0;
17214184Sgabeblack@google.com    num_functional_writes := num_functional_writes +
17314184Sgabeblack@google.com        testAndWrite(addr, getCacheEntry(addr).DataBlk, pkt);
17414184Sgabeblack@google.com    return num_functional_writes;
17514184Sgabeblack@google.com  }
17614184Sgabeblack@google.com
17714184Sgabeblack@google.com  int getTokens(Entry cache_entry) {
17814184Sgabeblack@google.com    if (is_valid(cache_entry)) {
17914184Sgabeblack@google.com      return cache_entry.Tokens;
18014184Sgabeblack@google.com    } else {
18114184Sgabeblack@google.com      return 0;
18214184Sgabeblack@google.com    }
18314184Sgabeblack@google.com  }
18414184Sgabeblack@google.com
18514184Sgabeblack@google.com  State getState(Entry cache_entry, Addr addr) {
18614184Sgabeblack@google.com    if (is_valid(cache_entry)) {
18714184Sgabeblack@google.com      return cache_entry.CacheState;
18814184Sgabeblack@google.com    } else if (persistentTable.isLocked(addr)) {
18914184Sgabeblack@google.com      return State:I_L;
19014184Sgabeblack@google.com    } else {
19114184Sgabeblack@google.com      return State:NP;
19214184Sgabeblack@google.com    }
19314184Sgabeblack@google.com  }
19414184Sgabeblack@google.com
19514184Sgabeblack@google.com  void setState(Entry cache_entry, Addr addr, State state) {
19614184Sgabeblack@google.com
19714184Sgabeblack@google.com    if (is_valid(cache_entry)) {
19814184Sgabeblack@google.com      // Make sure the token count is in range
19914184Sgabeblack@google.com      assert(cache_entry.Tokens >= 0);
20014184Sgabeblack@google.com      assert(cache_entry.Tokens <= max_tokens());
20114184Sgabeblack@google.com      assert(cache_entry.Tokens != (max_tokens() / 2));
20214184Sgabeblack@google.com
20314184Sgabeblack@google.com      // Make sure we have no tokens in L
20414184Sgabeblack@google.com      if ((state == State:I_L) ) {
20514184Sgabeblack@google.com        assert(cache_entry.Tokens == 0);
20614184Sgabeblack@google.com      }
20714184Sgabeblack@google.com
20814184Sgabeblack@google.com      // in M and E you have all the tokens
20914184Sgabeblack@google.com      if (state == State:M ) {
21014184Sgabeblack@google.com        assert(cache_entry.Tokens == max_tokens());
21114184Sgabeblack@google.com      }
21214184Sgabeblack@google.com
21314184Sgabeblack@google.com      // in NP you have no tokens
21414184Sgabeblack@google.com      if (state == State:NP) {
21514184Sgabeblack@google.com        assert(cache_entry.Tokens == 0);
21614184Sgabeblack@google.com      }
21714184Sgabeblack@google.com
21814184Sgabeblack@google.com      // You have at least one token in S-like states
21914184Sgabeblack@google.com      if (state == State:S ) {
22014184Sgabeblack@google.com        assert(cache_entry.Tokens > 0);
22114184Sgabeblack@google.com      }
22214184Sgabeblack@google.com
22314184Sgabeblack@google.com      // You have at least half the token in O-like states
22414184Sgabeblack@google.com      if (state == State:O ) {
22514184Sgabeblack@google.com        assert(cache_entry.Tokens > (max_tokens() / 2));
22614184Sgabeblack@google.com      }
22714184Sgabeblack@google.com
22814184Sgabeblack@google.com      cache_entry.CacheState := state;
22914184Sgabeblack@google.com    }
23014184Sgabeblack@google.com  }
23114184Sgabeblack@google.com
23214184Sgabeblack@google.com  AccessPermission getAccessPermission(Addr addr) {
23314184Sgabeblack@google.com    Entry cache_entry := getCacheEntry(addr);
23414184Sgabeblack@google.com    if(is_valid(cache_entry)) {
23514184Sgabeblack@google.com      return L2Cache_State_to_permission(cache_entry.CacheState);
23614184Sgabeblack@google.com    }
23714184Sgabeblack@google.com
23814184Sgabeblack@google.com    return AccessPermission:NotPresent;
23914184Sgabeblack@google.com  }
24014184Sgabeblack@google.com
24114184Sgabeblack@google.com  void setAccessPermission(Entry cache_entry, Addr addr, State state) {
24214184Sgabeblack@google.com    if (is_valid(cache_entry)) {
24314184Sgabeblack@google.com      cache_entry.changePermission(L2Cache_State_to_permission(state));
24414184Sgabeblack@google.com    }
24514184Sgabeblack@google.com  }
24614184Sgabeblack@google.com
24714184Sgabeblack@google.com  void removeSharer(Addr addr, NodeID id) {
24814184Sgabeblack@google.com
24914184Sgabeblack@google.com    if (localDirectory.isTagPresent(addr)) {
25014184Sgabeblack@google.com      DirEntry dir_entry := getDirEntry(addr);
25114184Sgabeblack@google.com      dir_entry.Sharers.remove(id);
25214184Sgabeblack@google.com      if (dir_entry.Sharers.count() == 0) {
25314184Sgabeblack@google.com        localDirectory.deallocate(addr);
25414184Sgabeblack@google.com      }
25514184Sgabeblack@google.com    }
25614184Sgabeblack@google.com  }
25714184Sgabeblack@google.com
25814184Sgabeblack@google.com  bool sharersExist(Addr addr) {
25914184Sgabeblack@google.com    if (localDirectory.isTagPresent(addr)) {
26014184Sgabeblack@google.com      DirEntry dir_entry := getDirEntry(addr);
26114184Sgabeblack@google.com      if (dir_entry.Sharers.count() > 0) {
26214184Sgabeblack@google.com        return true;
26314184Sgabeblack@google.com      }
26414184Sgabeblack@google.com      else {
26514184Sgabeblack@google.com        return false;
26614184Sgabeblack@google.com      }
26714184Sgabeblack@google.com    }
26814184Sgabeblack@google.com    else {
26914184Sgabeblack@google.com      return false;
27014184Sgabeblack@google.com    }
27114184Sgabeblack@google.com  }
27214184Sgabeblack@google.com
27314184Sgabeblack@google.com  bool exclusiveExists(Addr addr) {
27414184Sgabeblack@google.com    if (localDirectory.isTagPresent(addr)) {
27514184Sgabeblack@google.com      DirEntry dir_entry := getDirEntry(addr);
27614184Sgabeblack@google.com      if (dir_entry.exclusive) {
27714184Sgabeblack@google.com        return true;
27814184Sgabeblack@google.com      }
27914184Sgabeblack@google.com      else {
28014184Sgabeblack@google.com        return false;
28114184Sgabeblack@google.com      }
28214184Sgabeblack@google.com    }
28314184Sgabeblack@google.com    else {
28414184Sgabeblack@google.com      return false;
28514184Sgabeblack@google.com    }
28614184Sgabeblack@google.com  }
28714184Sgabeblack@google.com
28814184Sgabeblack@google.com  // assumes that caller will check to make sure tag is present
28914184Sgabeblack@google.com  Set getSharers(Addr addr) {
29014184Sgabeblack@google.com    DirEntry dir_entry := getDirEntry(addr);
29114184Sgabeblack@google.com    return dir_entry.Sharers;
29214184Sgabeblack@google.com  }
29314184Sgabeblack@google.com
29414184Sgabeblack@google.com  void setNewWriter(Addr addr, NodeID id) {
29514184Sgabeblack@google.com    if (localDirectory.isTagPresent(addr) == false) {
29614184Sgabeblack@google.com      localDirectory.allocate(addr);
29714184Sgabeblack@google.com    }
29814184Sgabeblack@google.com    DirEntry dir_entry := getDirEntry(addr);
29914184Sgabeblack@google.com    dir_entry.Sharers.clear();
30014184Sgabeblack@google.com    dir_entry.Sharers.add(id);
30114184Sgabeblack@google.com    dir_entry.exclusive := true;
30214184Sgabeblack@google.com  }
30314184Sgabeblack@google.com
30414184Sgabeblack@google.com  void addNewSharer(Addr addr, NodeID id) {
30514184Sgabeblack@google.com    if (localDirectory.isTagPresent(addr) == false) {
30614184Sgabeblack@google.com      localDirectory.allocate(addr);
30714184Sgabeblack@google.com    }
30814184Sgabeblack@google.com    DirEntry dir_entry := getDirEntry(addr);
30914184Sgabeblack@google.com    dir_entry.Sharers.add(id);
31014184Sgabeblack@google.com    // dir_entry.exclusive := false;
31114184Sgabeblack@google.com  }
31214184Sgabeblack@google.com
31314184Sgabeblack@google.com  void clearExclusiveBitIfExists(Addr addr) {
31414184Sgabeblack@google.com    if (localDirectory.isTagPresent(addr)) {
31514184Sgabeblack@google.com      DirEntry dir_entry := getDirEntry(addr);
31614184Sgabeblack@google.com      dir_entry.exclusive := false;
31714184Sgabeblack@google.com    }
31814184Sgabeblack@google.com  }
31914184Sgabeblack@google.com
32014184Sgabeblack@google.com  // ** OUT_PORTS **
32114184Sgabeblack@google.com  out_port(globalRequestNetwork_out, RequestMsg, GlobalRequestFromL2Cache);
32214184Sgabeblack@google.com  out_port(localRequestNetwork_out, RequestMsg, L1RequestFromL2Cache);
32314184Sgabeblack@google.com  out_port(responseNetwork_out, ResponseMsg, responseFromL2Cache);
32414184Sgabeblack@google.com
32514184Sgabeblack@google.com
32614184Sgabeblack@google.com
32714184Sgabeblack@google.com  // ** IN_PORTS **
32814184Sgabeblack@google.com
32914184Sgabeblack@google.com  // Persistent Network
33014184Sgabeblack@google.com  in_port(persistentNetwork_in, PersistentMsg, persistentToL2Cache) {
33114184Sgabeblack@google.com    if (persistentNetwork_in.isReady(clockEdge())) {
33214184Sgabeblack@google.com      peek(persistentNetwork_in, PersistentMsg) {
33314184Sgabeblack@google.com        assert(in_msg.Destination.isElement(machineID));
33414184Sgabeblack@google.com
33514184Sgabeblack@google.com        if (in_msg.Type == PersistentRequestType:GETX_PERSISTENT) {
33614184Sgabeblack@google.com          persistentTable.persistentRequestLock(in_msg.addr, in_msg.Requestor, AccessType:Write);
33714184Sgabeblack@google.com        } else if (in_msg.Type == PersistentRequestType:GETS_PERSISTENT) {
33814184Sgabeblack@google.com          persistentTable.persistentRequestLock(in_msg.addr, in_msg.Requestor, AccessType:Read);
33914184Sgabeblack@google.com        } else if (in_msg.Type == PersistentRequestType:DEACTIVATE_PERSISTENT) {
34014184Sgabeblack@google.com          persistentTable.persistentRequestUnlock(in_msg.addr, in_msg.Requestor);
34114184Sgabeblack@google.com        } else {
34214184Sgabeblack@google.com          error("Unexpected message");
34314184Sgabeblack@google.com        }
34414184Sgabeblack@google.com
34514184Sgabeblack@google.com        Entry cache_entry := getCacheEntry(in_msg.addr);
34614184Sgabeblack@google.com        // React to the message based on the current state of the table
34714184Sgabeblack@google.com        if (persistentTable.isLocked(in_msg.addr)) {
34814184Sgabeblack@google.com
34914184Sgabeblack@google.com          if (persistentTable.typeOfSmallest(in_msg.addr) == AccessType:Read) {
35014184Sgabeblack@google.com            if (getTokens(cache_entry) == 1 ||
35114184Sgabeblack@google.com                getTokens(cache_entry) == (max_tokens() / 2) + 1) {
35214184Sgabeblack@google.com              trigger(Event:Persistent_GETS_Last_Token, in_msg.addr,
35314184Sgabeblack@google.com                      cache_entry);
35414184Sgabeblack@google.com            } else {
35514184Sgabeblack@google.com              trigger(Event:Persistent_GETS, in_msg.addr, cache_entry);
35614184Sgabeblack@google.com            }
35714184Sgabeblack@google.com          } else {
35814184Sgabeblack@google.com            trigger(Event:Persistent_GETX, in_msg.addr, cache_entry);
35914184Sgabeblack@google.com          }
36014184Sgabeblack@google.com        }
36114184Sgabeblack@google.com        else {
36214184Sgabeblack@google.com            trigger(Event:Own_Lock_or_Unlock, in_msg.addr, cache_entry);
36314184Sgabeblack@google.com        }
36414184Sgabeblack@google.com      }
36514184Sgabeblack@google.com    }
36614184Sgabeblack@google.com  }
36714184Sgabeblack@google.com
36814184Sgabeblack@google.com
36914184Sgabeblack@google.com  // Request Network
37014184Sgabeblack@google.com  in_port(requestNetwork_in, RequestMsg, GlobalRequestToL2Cache) {
37114184Sgabeblack@google.com    if (requestNetwork_in.isReady(clockEdge())) {
37214184Sgabeblack@google.com      peek(requestNetwork_in, RequestMsg) {
37314184Sgabeblack@google.com        assert(in_msg.Destination.isElement(machineID));
37414184Sgabeblack@google.com
37514184Sgabeblack@google.com        Entry cache_entry := getCacheEntry(in_msg.addr);
37614184Sgabeblack@google.com        if (in_msg.Type == CoherenceRequestType:GETX) {
37714184Sgabeblack@google.com            trigger(Event:Transient_GETX, in_msg.addr, cache_entry);
37814184Sgabeblack@google.com        } else if (in_msg.Type == CoherenceRequestType:GETS) {
37914184Sgabeblack@google.com          if (getTokens(cache_entry) == 1) {
38014184Sgabeblack@google.com            trigger(Event:Transient_GETS_Last_Token, in_msg.addr,
38114184Sgabeblack@google.com                    cache_entry);
38214184Sgabeblack@google.com          }
38314184Sgabeblack@google.com          else {
38414184Sgabeblack@google.com            trigger(Event:Transient_GETS, in_msg.addr, cache_entry);
38514184Sgabeblack@google.com          }
38614184Sgabeblack@google.com        } else {
38714184Sgabeblack@google.com          error("Unexpected message");
38814184Sgabeblack@google.com        }
38914184Sgabeblack@google.com      }
39014184Sgabeblack@google.com    }
39114184Sgabeblack@google.com  }
39214184Sgabeblack@google.com
39314184Sgabeblack@google.com  in_port(L1requestNetwork_in, RequestMsg, L1RequestToL2Cache) {
39414184Sgabeblack@google.com    if (L1requestNetwork_in.isReady(clockEdge())) {
39514184Sgabeblack@google.com      peek(L1requestNetwork_in, RequestMsg) {
39614184Sgabeblack@google.com        assert(in_msg.Destination.isElement(machineID));
39714184Sgabeblack@google.com        Entry cache_entry := getCacheEntry(in_msg.addr);
39814184Sgabeblack@google.com        if (in_msg.Type == CoherenceRequestType:GETX) {
39914184Sgabeblack@google.com          trigger(Event:L1_GETX, in_msg.addr, cache_entry);
40014184Sgabeblack@google.com        } else if (in_msg.Type == CoherenceRequestType:GETS) {
40114184Sgabeblack@google.com          if (getTokens(cache_entry) == 1 ||
40214184Sgabeblack@google.com              getTokens(cache_entry) == (max_tokens() / 2) + 1) {
40314184Sgabeblack@google.com            trigger(Event:L1_GETS_Last_Token, in_msg.addr, cache_entry);
40414184Sgabeblack@google.com          }
40514184Sgabeblack@google.com          else {
40614184Sgabeblack@google.com            trigger(Event:L1_GETS, in_msg.addr, cache_entry);
40714184Sgabeblack@google.com          }
40814184Sgabeblack@google.com        } else {
40914184Sgabeblack@google.com          error("Unexpected message");
41014184Sgabeblack@google.com        }
41114184Sgabeblack@google.com      }
41214184Sgabeblack@google.com    }
41314184Sgabeblack@google.com  }
41414184Sgabeblack@google.com
41514184Sgabeblack@google.com
41614184Sgabeblack@google.com  // Response Network
41714184Sgabeblack@google.com  in_port(responseNetwork_in, ResponseMsg, responseToL2Cache) {
41814184Sgabeblack@google.com    if (responseNetwork_in.isReady(clockEdge())) {
41914184Sgabeblack@google.com      peek(responseNetwork_in, ResponseMsg) {
42014184Sgabeblack@google.com        assert(in_msg.Destination.isElement(machineID));
42114184Sgabeblack@google.com        Entry cache_entry := getCacheEntry(in_msg.addr);
42214184Sgabeblack@google.com
42314184Sgabeblack@google.com        if (getTokens(cache_entry) + in_msg.Tokens != max_tokens()) {
42414184Sgabeblack@google.com          if (in_msg.Type == CoherenceResponseType:ACK) {
42514184Sgabeblack@google.com            assert(in_msg.Tokens < (max_tokens() / 2));
42614184Sgabeblack@google.com            trigger(Event:Ack, in_msg.addr, cache_entry);
42714184Sgabeblack@google.com          } else if (in_msg.Type == CoherenceResponseType:DATA_OWNER) {
42814184Sgabeblack@google.com            trigger(Event:Data_Owner, in_msg.addr, cache_entry);
42914184Sgabeblack@google.com          } else if (in_msg.Type == CoherenceResponseType:DATA_SHARED) {
43014184Sgabeblack@google.com            trigger(Event:Data_Shared, in_msg.addr, cache_entry);
43114184Sgabeblack@google.com          } else if (in_msg.Type == CoherenceResponseType:WB_TOKENS ||
43214184Sgabeblack@google.com                     in_msg.Type == CoherenceResponseType:WB_OWNED ||
43314184Sgabeblack@google.com                     in_msg.Type == CoherenceResponseType:WB_SHARED_DATA) {
43414184Sgabeblack@google.com
43514184Sgabeblack@google.com            if (L2cache.cacheAvail(in_msg.addr) || is_valid(cache_entry)) {
43614184Sgabeblack@google.com
43714184Sgabeblack@google.com              // either room is available or the block is already present
43814184Sgabeblack@google.com
43914184Sgabeblack@google.com              if (in_msg.Type == CoherenceResponseType:WB_TOKENS) {
44014184Sgabeblack@google.com                assert(in_msg.Dirty == false);
44114184Sgabeblack@google.com                trigger(Event:Writeback_Tokens, in_msg.addr, cache_entry);
44214184Sgabeblack@google.com              } else if (in_msg.Type == CoherenceResponseType:WB_SHARED_DATA) {
44314184Sgabeblack@google.com                assert(in_msg.Dirty == false);
44414184Sgabeblack@google.com                trigger(Event:Writeback_Shared_Data, in_msg.addr, cache_entry);
44514184Sgabeblack@google.com              }
44614184Sgabeblack@google.com              else if (in_msg.Type == CoherenceResponseType:WB_OWNED) {
44714184Sgabeblack@google.com                //assert(in_msg.Dirty == false);
44814184Sgabeblack@google.com                trigger(Event:Writeback_Owned, in_msg.addr, cache_entry);
44914184Sgabeblack@google.com              }
45014184Sgabeblack@google.com            }
45114184Sgabeblack@google.com            else {
45214184Sgabeblack@google.com                trigger(Event:L2_Replacement,
45314184Sgabeblack@google.com                        L2cache.cacheProbe(in_msg.addr),
45414184Sgabeblack@google.com                        getCacheEntry(L2cache.cacheProbe(in_msg.addr)));
45514184Sgabeblack@google.com            }
45614184Sgabeblack@google.com          } else if (in_msg.Type == CoherenceResponseType:INV) {
45714184Sgabeblack@google.com            trigger(Event:L1_INV, in_msg.addr, cache_entry);
45814184Sgabeblack@google.com          } else {
45914184Sgabeblack@google.com            error("Unexpected message");
46014184Sgabeblack@google.com          }
46114184Sgabeblack@google.com        } else {
46214184Sgabeblack@google.com          if (in_msg.Type == CoherenceResponseType:ACK) {
46314184Sgabeblack@google.com            assert(in_msg.Tokens < (max_tokens() / 2));
46414184Sgabeblack@google.com            trigger(Event:Ack_All_Tokens, in_msg.addr, cache_entry);
46514184Sgabeblack@google.com          } else if (in_msg.Type == CoherenceResponseType:DATA_OWNER ||
46614184Sgabeblack@google.com                     in_msg.Type == CoherenceResponseType:DATA_SHARED) {
46714184Sgabeblack@google.com            trigger(Event:Data_All_Tokens, in_msg.addr, cache_entry);
46814184Sgabeblack@google.com          } else if (in_msg.Type == CoherenceResponseType:WB_TOKENS ||
46914184Sgabeblack@google.com                     in_msg.Type == CoherenceResponseType:WB_OWNED ||
47014184Sgabeblack@google.com                     in_msg.Type == CoherenceResponseType:WB_SHARED_DATA) {
47114184Sgabeblack@google.com            if (L2cache.cacheAvail(in_msg.addr) || is_valid(cache_entry)) {
47214184Sgabeblack@google.com
47314184Sgabeblack@google.com              // either room is available or the block is already present
47414184Sgabeblack@google.com
47514184Sgabeblack@google.com              if (in_msg.Type == CoherenceResponseType:WB_TOKENS) {
47614184Sgabeblack@google.com                assert(in_msg.Dirty == false);
47714184Sgabeblack@google.com                assert(  (getState(cache_entry, in_msg.addr) != State:NP)
47814184Sgabeblack@google.com                      && (getState(cache_entry, in_msg.addr) != State:I) );
47914184Sgabeblack@google.com                trigger(Event:Writeback_All_Tokens, in_msg.addr, cache_entry);
48014184Sgabeblack@google.com              } else if (in_msg.Type == CoherenceResponseType:WB_SHARED_DATA) {
48114184Sgabeblack@google.com                assert(in_msg.Dirty == false);
48214184Sgabeblack@google.com                trigger(Event:Writeback_All_Tokens, in_msg.addr, cache_entry);
48314184Sgabeblack@google.com              }
48414184Sgabeblack@google.com              else if (in_msg.Type == CoherenceResponseType:WB_OWNED) {
48514184Sgabeblack@google.com                trigger(Event:Writeback_All_Tokens, in_msg.addr, cache_entry);
48614184Sgabeblack@google.com              }
48714184Sgabeblack@google.com            }
48814184Sgabeblack@google.com            else {
48914184Sgabeblack@google.com                trigger(Event:L2_Replacement,
49014184Sgabeblack@google.com                        L2cache.cacheProbe(in_msg.addr),
49114184Sgabeblack@google.com                        getCacheEntry(L2cache.cacheProbe(in_msg.addr)));
49214184Sgabeblack@google.com            }
49314184Sgabeblack@google.com          } else if (in_msg.Type == CoherenceResponseType:INV) {
49414184Sgabeblack@google.com            trigger(Event:L1_INV, in_msg.addr, cache_entry);
49514184Sgabeblack@google.com          } else {
49614184Sgabeblack@google.com            DPRINTF(RubySlicc, "%s\n", in_msg.Type);
49714184Sgabeblack@google.com            error("Unexpected message");
49814184Sgabeblack@google.com          }
49914184Sgabeblack@google.com        }
50014184Sgabeblack@google.com      }
50114184Sgabeblack@google.com    }
50214184Sgabeblack@google.com  }
50314184Sgabeblack@google.com
50414184Sgabeblack@google.com
50514184Sgabeblack@google.com  // ACTIONS
50614184Sgabeblack@google.com
50714184Sgabeblack@google.com  action(a_broadcastLocalRequest, "a", desc="broadcast local request globally") {
50814184Sgabeblack@google.com
50914184Sgabeblack@google.com    peek(L1requestNetwork_in, RequestMsg) {
51014184Sgabeblack@google.com
51114184Sgabeblack@google.com     // if this is a retry or no local sharers, broadcast normally
51214184Sgabeblack@google.com        enqueue(globalRequestNetwork_out, RequestMsg, l2_request_latency) {
51314184Sgabeblack@google.com           out_msg.addr := in_msg.addr;
51414184Sgabeblack@google.com           out_msg.Type := in_msg.Type;
51514184Sgabeblack@google.com           out_msg.Requestor := in_msg.Requestor;
51614184Sgabeblack@google.com           out_msg.RetryNum := in_msg.RetryNum;
51714184Sgabeblack@google.com
51814184Sgabeblack@google.com           //
51914184Sgabeblack@google.com           // If a statically shared L2 cache, then no other L2 caches can
52014184Sgabeblack@google.com           // store the block
52114184Sgabeblack@google.com           //
52214184Sgabeblack@google.com           //out_msg.Destination.broadcast(MachineType:L2Cache);
52314184Sgabeblack@google.com           //out_msg.Destination.addNetDest(getAllPertinentL2Banks(address));
52414184Sgabeblack@google.com           //out_msg.Destination.remove(map_L1CacheMachId_to_L2Cache(address, in_msg.Requestor));
52514184Sgabeblack@google.com
52614184Sgabeblack@google.com           out_msg.Destination.add(mapAddressToMachine(address, MachineType:Directory));
52714184Sgabeblack@google.com           out_msg.MessageSize := MessageSizeType:Request_Control;
52814184Sgabeblack@google.com           out_msg.AccessMode := in_msg.AccessMode;
52914184Sgabeblack@google.com           out_msg.Prefetch := in_msg.Prefetch;
53014184Sgabeblack@google.com        } //enqueue
53114184Sgabeblack@google.com      // } // if
53214184Sgabeblack@google.com
53314184Sgabeblack@google.com         //profile_filter_action(0);
53414184Sgabeblack@google.com    } // peek
53514184Sgabeblack@google.com  } //action
53614184Sgabeblack@google.com
53714184Sgabeblack@google.com
53814184Sgabeblack@google.com  action(bb_bounceResponse, "\b", desc="Bounce tokens and data to memory") {
53914184Sgabeblack@google.com    peek(responseNetwork_in, ResponseMsg) {
54014184Sgabeblack@google.com      // FIXME, should use a 3rd vnet
54114184Sgabeblack@google.com      enqueue(responseNetwork_out, ResponseMsg, 1) {
54214184Sgabeblack@google.com        out_msg.addr := address;
54314184Sgabeblack@google.com        out_msg.Type := in_msg.Type;
54414184Sgabeblack@google.com        out_msg.Sender := machineID;
54514184Sgabeblack@google.com        out_msg.Destination.add(mapAddressToMachine(address, MachineType:Directory));
54614184Sgabeblack@google.com        out_msg.Tokens := in_msg.Tokens;
54714184Sgabeblack@google.com        out_msg.MessageSize := in_msg.MessageSize;
54814184Sgabeblack@google.com        out_msg.DataBlk := in_msg.DataBlk;
54914184Sgabeblack@google.com        out_msg.Dirty := in_msg.Dirty;
55014184Sgabeblack@google.com      }
55114184Sgabeblack@google.com    }
55214184Sgabeblack@google.com  }
55314184Sgabeblack@google.com
55414184Sgabeblack@google.com  action(c_cleanReplacement, "c", desc="Issue clean writeback") {
55514184Sgabeblack@google.com    assert(is_valid(cache_entry));
55614184Sgabeblack@google.com    if (cache_entry.Tokens > 0) {
55714184Sgabeblack@google.com      enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
55814184Sgabeblack@google.com        out_msg.addr := address;
55914184Sgabeblack@google.com        out_msg.Type := CoherenceResponseType:ACK;
56014184Sgabeblack@google.com        out_msg.Sender := machineID;
56114184Sgabeblack@google.com        out_msg.Destination.add(mapAddressToMachine(address, MachineType:Directory));
56214184Sgabeblack@google.com        out_msg.Tokens := cache_entry.Tokens;
56314184Sgabeblack@google.com        out_msg.MessageSize := MessageSizeType:Writeback_Control;
56414184Sgabeblack@google.com      }
56514184Sgabeblack@google.com      cache_entry.Tokens := 0;
56614184Sgabeblack@google.com    }
56714184Sgabeblack@google.com  }
56814184Sgabeblack@google.com
56914184Sgabeblack@google.com  action(cc_dirtyReplacement, "\c", desc="Issue dirty writeback") {
57014184Sgabeblack@google.com    assert(is_valid(cache_entry));
57114184Sgabeblack@google.com    enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
57214184Sgabeblack@google.com      out_msg.addr := address;
57314184Sgabeblack@google.com      out_msg.Sender := machineID;
57414184Sgabeblack@google.com      out_msg.Destination.add(mapAddressToMachine(address, MachineType:Directory));
57514184Sgabeblack@google.com      out_msg.Tokens := cache_entry.Tokens;
57614184Sgabeblack@google.com      out_msg.DataBlk := cache_entry.DataBlk;
57714184Sgabeblack@google.com      out_msg.Dirty := cache_entry.Dirty;
57814184Sgabeblack@google.com
57914184Sgabeblack@google.com      if (cache_entry.Dirty) {
58014184Sgabeblack@google.com        out_msg.MessageSize := MessageSizeType:Writeback_Data;
58114184Sgabeblack@google.com        out_msg.Type := CoherenceResponseType:DATA_OWNER;
58214184Sgabeblack@google.com      } else {
58314184Sgabeblack@google.com        out_msg.MessageSize := MessageSizeType:Writeback_Control;
58414184Sgabeblack@google.com        out_msg.Type := CoherenceResponseType:ACK_OWNER;
58514184Sgabeblack@google.com      }
58614184Sgabeblack@google.com    }
58714184Sgabeblack@google.com    cache_entry.Tokens := 0;
58814184Sgabeblack@google.com  }
58914184Sgabeblack@google.com
59014184Sgabeblack@google.com  action(d_sendDataWithTokens, "d", desc="Send data and a token from cache to requestor") {
59114184Sgabeblack@google.com    peek(requestNetwork_in, RequestMsg) {
59214184Sgabeblack@google.com      assert(is_valid(cache_entry));
59314184Sgabeblack@google.com      if (cache_entry.Tokens > (N_tokens + (max_tokens() / 2))) {
59414184Sgabeblack@google.com        enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
59514184Sgabeblack@google.com          out_msg.addr := address;
59614184Sgabeblack@google.com          out_msg.Type := CoherenceResponseType:DATA_SHARED;
59714184Sgabeblack@google.com          out_msg.Sender := machineID;
59814184Sgabeblack@google.com          out_msg.Destination.add(in_msg.Requestor);
59914184Sgabeblack@google.com          out_msg.Tokens := N_tokens;
60014184Sgabeblack@google.com          out_msg.DataBlk := cache_entry.DataBlk;
60114184Sgabeblack@google.com          out_msg.Dirty := false;
60214184Sgabeblack@google.com          out_msg.MessageSize := MessageSizeType:Response_Data;
60314184Sgabeblack@google.com        }
60414184Sgabeblack@google.com        cache_entry.Tokens := cache_entry.Tokens - N_tokens;
60514184Sgabeblack@google.com      }
60614184Sgabeblack@google.com      else {
60714184Sgabeblack@google.com        enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
60814184Sgabeblack@google.com          out_msg.addr := address;
60914184Sgabeblack@google.com          out_msg.Type := CoherenceResponseType:DATA_SHARED;
61014184Sgabeblack@google.com          out_msg.Sender := machineID;
61114184Sgabeblack@google.com          out_msg.Destination.add(in_msg.Requestor);
61214184Sgabeblack@google.com          out_msg.Tokens := 1;
61314184Sgabeblack@google.com          out_msg.DataBlk := cache_entry.DataBlk;
61414184Sgabeblack@google.com          out_msg.Dirty := false;
61514184Sgabeblack@google.com          out_msg.MessageSize := MessageSizeType:Response_Data;
61614184Sgabeblack@google.com        }
61714184Sgabeblack@google.com        cache_entry.Tokens := cache_entry.Tokens - 1;
61814184Sgabeblack@google.com      }
61914184Sgabeblack@google.com    }
62014184Sgabeblack@google.com  }
62114184Sgabeblack@google.com
62214184Sgabeblack@google.com  action(dd_sendDataWithAllTokens, "\d", desc="Send data and all tokens from cache to requestor") {
62314184Sgabeblack@google.com    assert(is_valid(cache_entry));
62414184Sgabeblack@google.com    peek(requestNetwork_in, RequestMsg) {
62514184Sgabeblack@google.com      enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
62614184Sgabeblack@google.com        out_msg.addr := address;
62714184Sgabeblack@google.com        out_msg.Type := CoherenceResponseType:DATA_OWNER;
62814184Sgabeblack@google.com        out_msg.Sender := machineID;
62914184Sgabeblack@google.com        out_msg.Destination.add(in_msg.Requestor);
63014184Sgabeblack@google.com        assert(cache_entry.Tokens >= 1);
63114184Sgabeblack@google.com        out_msg.Tokens := cache_entry.Tokens;
63214184Sgabeblack@google.com        out_msg.DataBlk := cache_entry.DataBlk;
63314184Sgabeblack@google.com        out_msg.Dirty := cache_entry.Dirty;
63414184Sgabeblack@google.com        out_msg.MessageSize := MessageSizeType:Response_Data;
63514184Sgabeblack@google.com      }
63614184Sgabeblack@google.com    }
63714184Sgabeblack@google.com    cache_entry.Tokens := 0;
63814184Sgabeblack@google.com  }
63914184Sgabeblack@google.com
64014184Sgabeblack@google.com  action(e_sendAckWithCollectedTokens, "e", desc="Send ack with the tokens we've collected thus far.") {
64114184Sgabeblack@google.com    assert(is_valid(cache_entry));
64214184Sgabeblack@google.com    if (cache_entry.Tokens > 0) {
64314184Sgabeblack@google.com      enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
64414184Sgabeblack@google.com        out_msg.addr := address;
64514184Sgabeblack@google.com        out_msg.Type := CoherenceResponseType:ACK;
64614184Sgabeblack@google.com        out_msg.Sender := machineID;
64714184Sgabeblack@google.com        out_msg.Destination.add(persistentTable.findSmallest(address));
64814184Sgabeblack@google.com        assert(cache_entry.Tokens >= 1);
64914184Sgabeblack@google.com        out_msg.Tokens := cache_entry.Tokens;
65014184Sgabeblack@google.com        out_msg.MessageSize := MessageSizeType:Response_Control;
65114184Sgabeblack@google.com      }
65214184Sgabeblack@google.com    }
65314184Sgabeblack@google.com    cache_entry.Tokens := 0;
65414184Sgabeblack@google.com  }
65514184Sgabeblack@google.com
65614184Sgabeblack@google.com  action(ee_sendDataWithAllTokens, "\e", desc="Send data and all tokens from cache to starver") {
65714184Sgabeblack@google.com    assert(is_valid(cache_entry));
65814184Sgabeblack@google.com    enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
65914184Sgabeblack@google.com      out_msg.addr := address;
66014184Sgabeblack@google.com      out_msg.Type := CoherenceResponseType:DATA_OWNER;
66114184Sgabeblack@google.com      out_msg.Sender := machineID;
66214184Sgabeblack@google.com      out_msg.Destination.add(persistentTable.findSmallest(address));
66314184Sgabeblack@google.com      assert(cache_entry.Tokens >= 1);
66414184Sgabeblack@google.com      out_msg.Tokens := cache_entry.Tokens;
66514184Sgabeblack@google.com      out_msg.DataBlk := cache_entry.DataBlk;
66614184Sgabeblack@google.com      out_msg.Dirty := cache_entry.Dirty;
66714184Sgabeblack@google.com      out_msg.MessageSize := MessageSizeType:Response_Data;
66814184Sgabeblack@google.com    }
66914184Sgabeblack@google.com    cache_entry.Tokens := 0;
67014184Sgabeblack@google.com  }
67114184Sgabeblack@google.com
67214184Sgabeblack@google.com  action(f_sendAckWithAllButOneTokens, "f", desc="Send ack with all our tokens but one to starver.") {
67314184Sgabeblack@google.com    //assert(persistentTable.findSmallest(address) != id); // Make sure we never bounce tokens to ourself
67414184Sgabeblack@google.com    assert(is_valid(cache_entry));
67514184Sgabeblack@google.com    assert(cache_entry.Tokens > 0);
67614184Sgabeblack@google.com    if (cache_entry.Tokens > 1) {
67714184Sgabeblack@google.com      enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
67814184Sgabeblack@google.com        out_msg.addr := address;
67914184Sgabeblack@google.com        out_msg.Type := CoherenceResponseType:ACK;
68014184Sgabeblack@google.com        out_msg.Sender := machineID;
68114184Sgabeblack@google.com        out_msg.Destination.add(persistentTable.findSmallest(address));
68214184Sgabeblack@google.com        assert(cache_entry.Tokens >= 1);
68314184Sgabeblack@google.com        out_msg.Tokens := cache_entry.Tokens - 1;
68414184Sgabeblack@google.com        out_msg.MessageSize := MessageSizeType:Response_Control;
68514184Sgabeblack@google.com      }
68614184Sgabeblack@google.com    }
68714184Sgabeblack@google.com    cache_entry.Tokens := 1;
68814184Sgabeblack@google.com  }
68914184Sgabeblack@google.com
69014184Sgabeblack@google.com  action(ff_sendDataWithAllButOneTokens, "\f", desc="Send data and out tokens but one to starver") {
69114184Sgabeblack@google.com    //assert(persistentTable.findSmallest(address) != id); // Make sure we never bounce tokens to ourself
69214184Sgabeblack@google.com    assert(is_valid(cache_entry));
69314184Sgabeblack@google.com    assert(cache_entry.Tokens > (max_tokens() / 2) + 1);
69414184Sgabeblack@google.com    enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
69514184Sgabeblack@google.com        out_msg.addr := address;
69614184Sgabeblack@google.com        out_msg.Type := CoherenceResponseType:DATA_OWNER;
69714184Sgabeblack@google.com        out_msg.Sender := machineID;
69814184Sgabeblack@google.com        out_msg.Destination.add(persistentTable.findSmallest(address));
69914184Sgabeblack@google.com        out_msg.Tokens := cache_entry.Tokens - 1;
70014184Sgabeblack@google.com        out_msg.DataBlk := cache_entry.DataBlk;
70114184Sgabeblack@google.com        out_msg.Dirty := cache_entry.Dirty;
70214184Sgabeblack@google.com        out_msg.MessageSize := MessageSizeType:Response_Data;
70314184Sgabeblack@google.com    }
70414184Sgabeblack@google.com    cache_entry.Tokens := 1;
70514184Sgabeblack@google.com  }
70614184Sgabeblack@google.com
70714184Sgabeblack@google.com  action(fa_sendDataWithAllTokens, "fa", desc="Send data and out tokens but one to starver") {
70814184Sgabeblack@google.com    //assert(persistentTable.findSmallest(address) != id); // Make sure we never bounce tokens to ourself
70914184Sgabeblack@google.com    assert(is_valid(cache_entry));
71014184Sgabeblack@google.com    assert(cache_entry.Tokens == (max_tokens() / 2) + 1);
71114184Sgabeblack@google.com    enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
71214184Sgabeblack@google.com        out_msg.addr := address;
71314184Sgabeblack@google.com        out_msg.Type := CoherenceResponseType:DATA_OWNER;
71414184Sgabeblack@google.com        out_msg.Sender := machineID;
71514184Sgabeblack@google.com        out_msg.Destination.add(persistentTable.findSmallest(address));
71614184Sgabeblack@google.com        out_msg.Tokens := cache_entry.Tokens;
71714184Sgabeblack@google.com        out_msg.DataBlk := cache_entry.DataBlk;
71814184Sgabeblack@google.com        out_msg.Dirty := cache_entry.Dirty;
71914184Sgabeblack@google.com        out_msg.MessageSize := MessageSizeType:Response_Data;
72014184Sgabeblack@google.com    }
72114184Sgabeblack@google.com    cache_entry.Tokens := 0;
72214184Sgabeblack@google.com  }
72314184Sgabeblack@google.com
72414184Sgabeblack@google.com
72514184Sgabeblack@google.com
72614184Sgabeblack@google.com  action(gg_bounceResponseToStarver, "\g", desc="Redirect response to starving processor") {
72714184Sgabeblack@google.com    // assert(persistentTable.isLocked(address));
72814184Sgabeblack@google.com    peek(responseNetwork_in, ResponseMsg) {
72914184Sgabeblack@google.com      // FIXME, should use a 3rd vnet in some cases
73014184Sgabeblack@google.com      enqueue(responseNetwork_out, ResponseMsg, 1) {
73114184Sgabeblack@google.com        out_msg.addr := address;
73214184Sgabeblack@google.com        out_msg.Type := in_msg.Type;
73314184Sgabeblack@google.com        out_msg.Sender := machineID;
73414184Sgabeblack@google.com        out_msg.Destination.add(persistentTable.findSmallest(address));
73514184Sgabeblack@google.com        out_msg.Tokens := in_msg.Tokens;
73614184Sgabeblack@google.com        out_msg.DataBlk := in_msg.DataBlk;
73714184Sgabeblack@google.com        out_msg.Dirty := in_msg.Dirty;
73814184Sgabeblack@google.com        out_msg.MessageSize := in_msg.MessageSize;
73914184Sgabeblack@google.com      }
74014184Sgabeblack@google.com    }
74114184Sgabeblack@google.com  }
74214184Sgabeblack@google.com
74314184Sgabeblack@google.com  action(gg_bounceWBSharedToStarver, "\gg", desc="Redirect response to starving processor") {
74414184Sgabeblack@google.com    //assert(persistentTable.isLocked(address));
74514184Sgabeblack@google.com    peek(responseNetwork_in, ResponseMsg) {
74614184Sgabeblack@google.com      // FIXME, should use a 3rd vnet in some cases
74714184Sgabeblack@google.com      enqueue(responseNetwork_out, ResponseMsg, 1) {
74814184Sgabeblack@google.com        out_msg.addr := address;
74914184Sgabeblack@google.com        if (in_msg.Type == CoherenceResponseType:WB_SHARED_DATA) {
75014184Sgabeblack@google.com          out_msg.Type := CoherenceResponseType:DATA_SHARED;
75114184Sgabeblack@google.com        } else {
75214184Sgabeblack@google.com          assert(in_msg.Tokens < (max_tokens() / 2));
75314184Sgabeblack@google.com          out_msg.Type := CoherenceResponseType:ACK;
75414184Sgabeblack@google.com        }
75514184Sgabeblack@google.com        out_msg.Sender := machineID;
75614184Sgabeblack@google.com        out_msg.Destination.add(persistentTable.findSmallest(address));
75714184Sgabeblack@google.com        out_msg.Tokens := in_msg.Tokens;
75814184Sgabeblack@google.com        out_msg.DataBlk := in_msg.DataBlk;
75914184Sgabeblack@google.com        out_msg.Dirty := in_msg.Dirty;
76014184Sgabeblack@google.com        out_msg.MessageSize := in_msg.MessageSize;
76114184Sgabeblack@google.com      }
76214184Sgabeblack@google.com    }
76314184Sgabeblack@google.com  }
76414184Sgabeblack@google.com
76514184Sgabeblack@google.com  action(gg_bounceWBOwnedToStarver, "\ggg", desc="Redirect response to starving processor") {
76614184Sgabeblack@google.com    // assert(persistentTable.isLocked(address));
76714184Sgabeblack@google.com    peek(responseNetwork_in, ResponseMsg) {
76814184Sgabeblack@google.com      // FIXME, should use a 3rd vnet in some cases
76914184Sgabeblack@google.com      enqueue(responseNetwork_out, ResponseMsg, 1) {
77014184Sgabeblack@google.com        out_msg.addr := address;
77114184Sgabeblack@google.com        out_msg.Type := CoherenceResponseType:DATA_OWNER;
77214184Sgabeblack@google.com        out_msg.Sender := machineID;
77314184Sgabeblack@google.com        out_msg.Destination.add(persistentTable.findSmallest(address));
77414184Sgabeblack@google.com        out_msg.Tokens := in_msg.Tokens;
77514184Sgabeblack@google.com        out_msg.DataBlk := in_msg.DataBlk;
77614184Sgabeblack@google.com        out_msg.Dirty := in_msg.Dirty;
77714184Sgabeblack@google.com        out_msg.MessageSize := in_msg.MessageSize;
77814184Sgabeblack@google.com      }
77914184Sgabeblack@google.com    }
78014184Sgabeblack@google.com  }
78114184Sgabeblack@google.com
78214184Sgabeblack@google.com
78314184Sgabeblack@google.com  action(h_updateFilterFromL1HintOrWB, "h", desc="update filter from received writeback") {
78414184Sgabeblack@google.com    peek(responseNetwork_in, ResponseMsg) {
78514184Sgabeblack@google.com      removeSharer(in_msg.addr, machineIDToNodeID(in_msg.Sender));
78614184Sgabeblack@google.com    }
78714184Sgabeblack@google.com  }
78814184Sgabeblack@google.com
78914184Sgabeblack@google.com  action(j_forwardTransientRequestToLocalSharers, "j", desc="Forward external transient request to local sharers") {
79014184Sgabeblack@google.com    peek(requestNetwork_in, RequestMsg) {
79114184Sgabeblack@google.com      if (filtering_enabled && in_msg.RetryNum == 0 && sharersExist(in_msg.addr) == false) {
79214184Sgabeblack@google.com        //profile_filter_action(1);
79314184Sgabeblack@google.com        DPRINTF(RubySlicc, "filtered message, Retry Num: %d\n",
79414184Sgabeblack@google.com                in_msg.RetryNum);
79514184Sgabeblack@google.com      }
79614184Sgabeblack@google.com      else {
79714184Sgabeblack@google.com        enqueue(localRequestNetwork_out, RequestMsg, l2_response_latency ) {
79814184Sgabeblack@google.com           out_msg.addr := in_msg.addr;
79914184Sgabeblack@google.com           out_msg.Requestor := in_msg.Requestor;
80014184Sgabeblack@google.com
80114184Sgabeblack@google.com           //
80214184Sgabeblack@google.com           // Currently assuming only one chip so all L1s are local
80314184Sgabeblack@google.com           //
80414184Sgabeblack@google.com           //out_msg.Destination := getLocalL1IDs(machineID);
80514184Sgabeblack@google.com           out_msg.Destination.broadcast(MachineType:L1Cache);
80614184Sgabeblack@google.com           out_msg.Destination.remove(in_msg.Requestor);
80714184Sgabeblack@google.com
80814184Sgabeblack@google.com           out_msg.Type := in_msg.Type;
80914184Sgabeblack@google.com           out_msg.isLocal := false;
81014184Sgabeblack@google.com           out_msg.MessageSize := MessageSizeType:Broadcast_Control;
81114184Sgabeblack@google.com           out_msg.AccessMode := in_msg.AccessMode;
81214184Sgabeblack@google.com           out_msg.Prefetch := in_msg.Prefetch;
81314184Sgabeblack@google.com        }
81414184Sgabeblack@google.com        //profile_filter_action(0);
81514184Sgabeblack@google.com      }
81614184Sgabeblack@google.com    }
81714184Sgabeblack@google.com  }
81814184Sgabeblack@google.com
81914184Sgabeblack@google.com  action(k_dataFromL2CacheToL1Requestor, "k", desc="Send data and a token from cache to L1 requestor") {
82014184Sgabeblack@google.com    peek(L1requestNetwork_in, RequestMsg) {
82114184Sgabeblack@google.com      assert(is_valid(cache_entry));
82214184Sgabeblack@google.com      assert(cache_entry.Tokens > 0);
82314184Sgabeblack@google.com      enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
82414184Sgabeblack@google.com        out_msg.addr := address;
82514184Sgabeblack@google.com        out_msg.Type := CoherenceResponseType:DATA_SHARED;
82614184Sgabeblack@google.com        out_msg.Sender := machineID;
82714184Sgabeblack@google.com        out_msg.Destination.add(in_msg.Requestor);
82814184Sgabeblack@google.com        out_msg.DataBlk := cache_entry.DataBlk;
82914184Sgabeblack@google.com        out_msg.Dirty := false;
83014184Sgabeblack@google.com        out_msg.MessageSize := MessageSizeType:ResponseL2hit_Data;
83114184Sgabeblack@google.com        out_msg.Tokens := 1;
83214184Sgabeblack@google.com      }
83314184Sgabeblack@google.com      cache_entry.Tokens := cache_entry.Tokens - 1;
83414184Sgabeblack@google.com    }
83514184Sgabeblack@google.com  }
83614184Sgabeblack@google.com
83714184Sgabeblack@google.com  action(k_dataOwnerFromL2CacheToL1Requestor, "\k", desc="Send data and a token from cache to L1 requestor") {
83814184Sgabeblack@google.com    peek(L1requestNetwork_in, RequestMsg) {
83914184Sgabeblack@google.com      assert(is_valid(cache_entry));
84014184Sgabeblack@google.com      assert(cache_entry.Tokens == (max_tokens() / 2) + 1);
84114184Sgabeblack@google.com      enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
84214184Sgabeblack@google.com        out_msg.addr := address;
84314184Sgabeblack@google.com        out_msg.Type := CoherenceResponseType:DATA_OWNER;
84414184Sgabeblack@google.com        out_msg.Sender := machineID;
84514184Sgabeblack@google.com        out_msg.Destination.add(in_msg.Requestor);
84614184Sgabeblack@google.com        out_msg.DataBlk := cache_entry.DataBlk;
84714184Sgabeblack@google.com        out_msg.Dirty := cache_entry.Dirty;
84814184Sgabeblack@google.com        out_msg.MessageSize := MessageSizeType:ResponseL2hit_Data;
84914184Sgabeblack@google.com        out_msg.Tokens := cache_entry.Tokens;
85014184Sgabeblack@google.com      }
85114184Sgabeblack@google.com      cache_entry.Tokens := 0;
85214184Sgabeblack@google.com    }
85314184Sgabeblack@google.com  }
85414184Sgabeblack@google.com
85514184Sgabeblack@google.com  action(k_dataAndAllTokensFromL2CacheToL1Requestor, "\kk", desc="Send data and a token from cache to L1 requestor") {
85614184Sgabeblack@google.com    peek(L1requestNetwork_in, RequestMsg) {
85714184Sgabeblack@google.com      assert(is_valid(cache_entry));
85814184Sgabeblack@google.com//      assert(cache_entry.Tokens == max_tokens());
85914184Sgabeblack@google.com      enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
86014184Sgabeblack@google.com        out_msg.addr := address;
86114184Sgabeblack@google.com        out_msg.Type := CoherenceResponseType:DATA_OWNER;
86214184Sgabeblack@google.com        out_msg.Sender := machineID;
86314184Sgabeblack@google.com        out_msg.Destination.add(in_msg.Requestor);
86414184Sgabeblack@google.com        out_msg.DataBlk := cache_entry.DataBlk;
86514184Sgabeblack@google.com        out_msg.Dirty := cache_entry.Dirty;
86614184Sgabeblack@google.com        out_msg.MessageSize := MessageSizeType:ResponseL2hit_Data;
86714184Sgabeblack@google.com        //out_msg.Tokens := max_tokens();
86814184Sgabeblack@google.com        out_msg.Tokens := cache_entry.Tokens;
86914184Sgabeblack@google.com      }
87014184Sgabeblack@google.com      cache_entry.Tokens := 0;
87114184Sgabeblack@google.com    }
87214184Sgabeblack@google.com  }
87314184Sgabeblack@google.com
87414184Sgabeblack@google.com  action(l_popPersistentQueue, "l", desc="Pop persistent queue.") {
87514184Sgabeblack@google.com    persistentNetwork_in.dequeue(clockEdge());
87614184Sgabeblack@google.com  }
87714184Sgabeblack@google.com
87814184Sgabeblack@google.com  action(m_popRequestQueue, "m", desc="Pop request queue.") {
87914184Sgabeblack@google.com    requestNetwork_in.dequeue(clockEdge());
88014184Sgabeblack@google.com  }
88114184Sgabeblack@google.com
88214184Sgabeblack@google.com  action(n_popResponseQueue, "n", desc="Pop response queue") {
88314184Sgabeblack@google.com    responseNetwork_in.dequeue(clockEdge());
88414184Sgabeblack@google.com  }
88514184Sgabeblack@google.com
88614184Sgabeblack@google.com  action(o_popL1RequestQueue, "o", desc="Pop L1 request queue.") {
88714184Sgabeblack@google.com    L1requestNetwork_in.dequeue(clockEdge());
88814184Sgabeblack@google.com  }
88914184Sgabeblack@google.com
89014184Sgabeblack@google.com
89114184Sgabeblack@google.com  action(q_updateTokensFromResponse, "q", desc="Update the token count based on the incoming response message") {
89214184Sgabeblack@google.com    peek(responseNetwork_in, ResponseMsg) {
89314184Sgabeblack@google.com      assert(is_valid(cache_entry));
89414184Sgabeblack@google.com      assert(in_msg.Tokens != 0);
89514184Sgabeblack@google.com      cache_entry.Tokens := cache_entry.Tokens + in_msg.Tokens;
89614184Sgabeblack@google.com
89714184Sgabeblack@google.com      // this should ideally be in u_writeDataToCache, but Writeback_All_Tokens
89814184Sgabeblack@google.com      //  may not trigger this action.
89914184Sgabeblack@google.com      if ( (in_msg.Type == CoherenceResponseType:DATA_OWNER || in_msg.Type == CoherenceResponseType:WB_OWNED) && in_msg.Dirty) {
90014184Sgabeblack@google.com        cache_entry.Dirty := true;
90114184Sgabeblack@google.com      }
90214184Sgabeblack@google.com    }
90314184Sgabeblack@google.com  }
90414184Sgabeblack@google.com
90514184Sgabeblack@google.com  action(r_markNewSharer, "r", desc="Mark the new local sharer from local request message") {
90614184Sgabeblack@google.com    peek(L1requestNetwork_in, RequestMsg) {
90714184Sgabeblack@google.com      if (machineIDToMachineType(in_msg.Requestor) == MachineType:L1Cache) {
90814184Sgabeblack@google.com        if (in_msg.Type == CoherenceRequestType:GETX) {
90914184Sgabeblack@google.com          setNewWriter(in_msg.addr, machineIDToNodeID(in_msg.Requestor));
91014184Sgabeblack@google.com        } else if (in_msg.Type == CoherenceRequestType:GETS) {
91114184Sgabeblack@google.com          addNewSharer(in_msg.addr, machineIDToNodeID(in_msg.Requestor));
91214184Sgabeblack@google.com        }
91314184Sgabeblack@google.com      }
91414184Sgabeblack@google.com    }
91514184Sgabeblack@google.com  }
91614184Sgabeblack@google.com
91714184Sgabeblack@google.com  action(r_clearExclusive, "\rrr", desc="clear exclusive bit") {
91814184Sgabeblack@google.com    clearExclusiveBitIfExists(address);
91914184Sgabeblack@google.com  }
92014184Sgabeblack@google.com
92114184Sgabeblack@google.com  action(r_setMRU, "\rr", desc="manually set the MRU bit for cache line" ) {
92214184Sgabeblack@google.com    peek(L1requestNetwork_in, RequestMsg) {
92314184Sgabeblack@google.com      if ((machineIDToMachineType(in_msg.Requestor) == MachineType:L1Cache) &&
92414184Sgabeblack@google.com          (is_valid(cache_entry))) {
92514184Sgabeblack@google.com        L2cache.setMRU(address);
92614184Sgabeblack@google.com      }
92714184Sgabeblack@google.com    }
92814184Sgabeblack@google.com  }
92914184Sgabeblack@google.com
93014184Sgabeblack@google.com  action(t_sendAckWithCollectedTokens, "t", desc="Send ack with the tokens we've collected thus far.") {
93114184Sgabeblack@google.com    assert(is_valid(cache_entry));
93214184Sgabeblack@google.com    if (cache_entry.Tokens > 0) {
93314184Sgabeblack@google.com      peek(requestNetwork_in, RequestMsg) {
93414184Sgabeblack@google.com        enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
93514184Sgabeblack@google.com          out_msg.addr := address;
93614184Sgabeblack@google.com          out_msg.Type := CoherenceResponseType:ACK;
93714184Sgabeblack@google.com          out_msg.Sender := machineID;
93814184Sgabeblack@google.com          out_msg.Destination.add(in_msg.Requestor);
93914184Sgabeblack@google.com          assert(cache_entry.Tokens >= 1);
94014184Sgabeblack@google.com          out_msg.Tokens := cache_entry.Tokens;
94114184Sgabeblack@google.com          out_msg.MessageSize := MessageSizeType:Response_Control;
94214184Sgabeblack@google.com        }
94314184Sgabeblack@google.com      }
94414184Sgabeblack@google.com    }
94514184Sgabeblack@google.com    cache_entry.Tokens := 0;
94614184Sgabeblack@google.com  }
94714184Sgabeblack@google.com
94814184Sgabeblack@google.com  action(tt_sendLocalAckWithCollectedTokens, "tt", desc="Send ack with the tokens we've collected thus far.") {
94914184Sgabeblack@google.com    assert(is_valid(cache_entry));
95014184Sgabeblack@google.com    if (cache_entry.Tokens > 0) {
95114184Sgabeblack@google.com      peek(L1requestNetwork_in, RequestMsg) {
95214184Sgabeblack@google.com        enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
95314184Sgabeblack@google.com          out_msg.addr := address;
95414184Sgabeblack@google.com          out_msg.Type := CoherenceResponseType:ACK;
95514184Sgabeblack@google.com          out_msg.Sender := machineID;
95614184Sgabeblack@google.com          out_msg.Destination.add(in_msg.Requestor);
95714184Sgabeblack@google.com          assert(cache_entry.Tokens >= 1);
95814184Sgabeblack@google.com          out_msg.Tokens := cache_entry.Tokens;
95914184Sgabeblack@google.com          out_msg.MessageSize := MessageSizeType:Response_Control;
96014184Sgabeblack@google.com        }
96114184Sgabeblack@google.com      }
96214184Sgabeblack@google.com    }
96314184Sgabeblack@google.com    cache_entry.Tokens := 0;
96414184Sgabeblack@google.com  }
96514184Sgabeblack@google.com
96614184Sgabeblack@google.com  action(u_writeDataToCache, "u", desc="Write data to cache") {
96714184Sgabeblack@google.com    peek(responseNetwork_in, ResponseMsg) {
96814184Sgabeblack@google.com      assert(is_valid(cache_entry));
96914184Sgabeblack@google.com      cache_entry.DataBlk := in_msg.DataBlk;
97014184Sgabeblack@google.com      if ((cache_entry.Dirty == false) && in_msg.Dirty) {
97114184Sgabeblack@google.com        cache_entry.Dirty := in_msg.Dirty;
97214184Sgabeblack@google.com      }
97314184Sgabeblack@google.com    }
97414184Sgabeblack@google.com  }
97514184Sgabeblack@google.com
97614184Sgabeblack@google.com  action(vv_allocateL2CacheBlock, "\v", desc="Set L2 cache tag equal to tag of block B.") {
97714184Sgabeblack@google.com    set_cache_entry(L2cache.allocate(address, new Entry));
97814184Sgabeblack@google.com  }
97914184Sgabeblack@google.com
98014184Sgabeblack@google.com  action(rr_deallocateL2CacheBlock, "\r", desc="Deallocate L2 cache block.  Sets the cache to not present, allowing a replacement in parallel with a fetch.") {
98114184Sgabeblack@google.com    L2cache.deallocate(address);
98214184Sgabeblack@google.com    unset_cache_entry();
98314184Sgabeblack@google.com  }
98414184Sgabeblack@google.com
98514184Sgabeblack@google.com  action(uu_profileMiss, "\um", desc="Profile the demand miss") {
98614184Sgabeblack@google.com      ++L2cache.demand_misses;
98714184Sgabeblack@google.com  }
98814184Sgabeblack@google.com
98914184Sgabeblack@google.com  action(uu_profileHit, "\uh", desc="Profile the demand hit") {
99014184Sgabeblack@google.com      ++L2cache.demand_hits;
99114184Sgabeblack@google.com  }
99214184Sgabeblack@google.com
99314184Sgabeblack@google.com  action(w_assertIncomingDataAndCacheDataMatch, "w", desc="Assert that the incoming data and the data in the cache match") {
99414184Sgabeblack@google.com    peek(responseNetwork_in, ResponseMsg) {
99514184Sgabeblack@google.com      if (in_msg.Type != CoherenceResponseType:ACK &&
99614184Sgabeblack@google.com          in_msg.Type != CoherenceResponseType:WB_TOKENS) {
99714184Sgabeblack@google.com        assert(is_valid(cache_entry));
99814184Sgabeblack@google.com        assert(cache_entry.DataBlk == in_msg.DataBlk);
99914184Sgabeblack@google.com      }
100014184Sgabeblack@google.com    }
100114184Sgabeblack@google.com  }
100214184Sgabeblack@google.com
100314184Sgabeblack@google.com
100414184Sgabeblack@google.com  //*****************************************************
100514184Sgabeblack@google.com  // TRANSITIONS
100614184Sgabeblack@google.com  //*****************************************************
100714184Sgabeblack@google.com
100814184Sgabeblack@google.com  transition({NP, I, S, O, M, I_L, S_L}, L1_INV) {
100914184Sgabeblack@google.com
101014184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
101114184Sgabeblack@google.com    n_popResponseQueue;
101214184Sgabeblack@google.com  }
101314184Sgabeblack@google.com
101414184Sgabeblack@google.com  transition({NP, I, S, O, M}, Own_Lock_or_Unlock) {
101514184Sgabeblack@google.com    l_popPersistentQueue;
101614184Sgabeblack@google.com  }
101714184Sgabeblack@google.com
101814184Sgabeblack@google.com
101914184Sgabeblack@google.com  // Transitions from NP
102014184Sgabeblack@google.com
102114184Sgabeblack@google.com  transition(NP, {Transient_GETX, Transient_GETS}) {
102214184Sgabeblack@google.com    // forward message to local sharers
102314184Sgabeblack@google.com    r_clearExclusive;
102414184Sgabeblack@google.com    j_forwardTransientRequestToLocalSharers;
102514184Sgabeblack@google.com    m_popRequestQueue;
102614184Sgabeblack@google.com  }
102714184Sgabeblack@google.com
102814184Sgabeblack@google.com
102914184Sgabeblack@google.com  transition(NP,  {L1_GETS, L1_GETX}) {
103014184Sgabeblack@google.com    a_broadcastLocalRequest;
103114184Sgabeblack@google.com    r_markNewSharer;
103214184Sgabeblack@google.com    uu_profileMiss;
103314184Sgabeblack@google.com    o_popL1RequestQueue;
103414184Sgabeblack@google.com  }
103514184Sgabeblack@google.com
103614184Sgabeblack@google.com  transition(NP, {Ack, Data_Shared, Data_Owner, Data_All_Tokens}) {
103714184Sgabeblack@google.com    bb_bounceResponse;
103814184Sgabeblack@google.com    n_popResponseQueue;
103914184Sgabeblack@google.com  }
104014184Sgabeblack@google.com
104114184Sgabeblack@google.com  transition(NP, Writeback_Shared_Data, S) {
104214184Sgabeblack@google.com    vv_allocateL2CacheBlock;
104314184Sgabeblack@google.com    u_writeDataToCache;
104414184Sgabeblack@google.com    q_updateTokensFromResponse;
104514184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
104614184Sgabeblack@google.com    n_popResponseQueue;
104714184Sgabeblack@google.com  }
104814184Sgabeblack@google.com
104914184Sgabeblack@google.com  transition(NP, Writeback_Tokens, I) {
105014184Sgabeblack@google.com    vv_allocateL2CacheBlock;
105114184Sgabeblack@google.com    q_updateTokensFromResponse;
105214184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
105314184Sgabeblack@google.com    n_popResponseQueue;
105414184Sgabeblack@google.com  }
105514184Sgabeblack@google.com
105614184Sgabeblack@google.com  transition(NP, Writeback_All_Tokens, M) {
105714184Sgabeblack@google.com    vv_allocateL2CacheBlock;
105814184Sgabeblack@google.com    u_writeDataToCache;
105914184Sgabeblack@google.com    q_updateTokensFromResponse;
106014184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
106114184Sgabeblack@google.com    n_popResponseQueue;
106214184Sgabeblack@google.com  }
106314184Sgabeblack@google.com
106414184Sgabeblack@google.com  transition(NP, Writeback_Owned, O) {
106514184Sgabeblack@google.com    vv_allocateL2CacheBlock;
106614184Sgabeblack@google.com    u_writeDataToCache;
106714184Sgabeblack@google.com    q_updateTokensFromResponse;
106814184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
106914184Sgabeblack@google.com    n_popResponseQueue;
107014184Sgabeblack@google.com  }
107114184Sgabeblack@google.com
107214184Sgabeblack@google.com
107314184Sgabeblack@google.com  transition(NP,
107414184Sgabeblack@google.com             {Persistent_GETX, Persistent_GETS, Persistent_GETS_Last_Token},
107514184Sgabeblack@google.com             I_L) {
107614184Sgabeblack@google.com    l_popPersistentQueue;
107714184Sgabeblack@google.com  }
107814184Sgabeblack@google.com
107914184Sgabeblack@google.com  // Transitions from Idle
108014184Sgabeblack@google.com
108114184Sgabeblack@google.com  transition(I, {L1_GETS, L1_GETS_Last_Token}) {
108214184Sgabeblack@google.com    a_broadcastLocalRequest;
108314184Sgabeblack@google.com    tt_sendLocalAckWithCollectedTokens;  // send any tokens we have collected
108414184Sgabeblack@google.com    r_markNewSharer;
108514184Sgabeblack@google.com    uu_profileMiss;
108614184Sgabeblack@google.com    o_popL1RequestQueue;
108714184Sgabeblack@google.com  }
108814184Sgabeblack@google.com
108914184Sgabeblack@google.com  transition(I, L1_GETX) {
109014184Sgabeblack@google.com    a_broadcastLocalRequest;
109114184Sgabeblack@google.com    tt_sendLocalAckWithCollectedTokens; // send any tokens we have collected
109214184Sgabeblack@google.com    r_markNewSharer;
109314184Sgabeblack@google.com    uu_profileMiss;
109414184Sgabeblack@google.com    o_popL1RequestQueue;
109514184Sgabeblack@google.com  }
109614184Sgabeblack@google.com
109714184Sgabeblack@google.com  transition(I, L2_Replacement) {
109814184Sgabeblack@google.com    c_cleanReplacement; // Only needed in some cases
109914184Sgabeblack@google.com    rr_deallocateL2CacheBlock;
110014184Sgabeblack@google.com  }
110114184Sgabeblack@google.com
110214184Sgabeblack@google.com  transition(I, {Transient_GETX, Transient_GETS, Transient_GETS_Last_Token}) {
110314184Sgabeblack@google.com    r_clearExclusive;
110414184Sgabeblack@google.com    t_sendAckWithCollectedTokens;
110514184Sgabeblack@google.com    j_forwardTransientRequestToLocalSharers;
110614184Sgabeblack@google.com    m_popRequestQueue;
110714184Sgabeblack@google.com  }
110814184Sgabeblack@google.com
110914184Sgabeblack@google.com  transition(I,
111014184Sgabeblack@google.com             {Persistent_GETX, Persistent_GETS, Persistent_GETS_Last_Token},
111114184Sgabeblack@google.com             I_L) {
111214184Sgabeblack@google.com    e_sendAckWithCollectedTokens;
111314184Sgabeblack@google.com    l_popPersistentQueue;
111414184Sgabeblack@google.com  }
111514184Sgabeblack@google.com
111614184Sgabeblack@google.com
111714184Sgabeblack@google.com  transition(I, Ack) {
111814184Sgabeblack@google.com    q_updateTokensFromResponse;
111914184Sgabeblack@google.com    n_popResponseQueue;
112014184Sgabeblack@google.com  }
112114184Sgabeblack@google.com
112214184Sgabeblack@google.com  transition(I, Data_Shared, S) {
112314184Sgabeblack@google.com    u_writeDataToCache;
112414184Sgabeblack@google.com    q_updateTokensFromResponse;
112514184Sgabeblack@google.com    n_popResponseQueue;
112614184Sgabeblack@google.com  }
112714184Sgabeblack@google.com
112814184Sgabeblack@google.com  transition(I, Writeback_Shared_Data, S) {
112914184Sgabeblack@google.com    u_writeDataToCache;
113014184Sgabeblack@google.com    q_updateTokensFromResponse;
113114184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
113214184Sgabeblack@google.com    n_popResponseQueue;
113314184Sgabeblack@google.com  }
113414184Sgabeblack@google.com
113514184Sgabeblack@google.com  transition(I, Writeback_Tokens) {
113614184Sgabeblack@google.com    q_updateTokensFromResponse;
113714184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
113814184Sgabeblack@google.com    n_popResponseQueue;
113914184Sgabeblack@google.com  }
114014184Sgabeblack@google.com
114114184Sgabeblack@google.com  transition(I, Data_Owner, O) {
114214184Sgabeblack@google.com    u_writeDataToCache;
114314184Sgabeblack@google.com    q_updateTokensFromResponse;
114414184Sgabeblack@google.com    n_popResponseQueue;
114514184Sgabeblack@google.com  }
114614184Sgabeblack@google.com
114714184Sgabeblack@google.com  transition(I, Writeback_Owned, O) {
114814184Sgabeblack@google.com    u_writeDataToCache;
114914184Sgabeblack@google.com    q_updateTokensFromResponse;
115014184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
115114184Sgabeblack@google.com    n_popResponseQueue;
115214184Sgabeblack@google.com  }
115314184Sgabeblack@google.com
115414184Sgabeblack@google.com  transition(I, Data_All_Tokens, M) {
115514184Sgabeblack@google.com    u_writeDataToCache;
115614184Sgabeblack@google.com    q_updateTokensFromResponse;
115714184Sgabeblack@google.com    n_popResponseQueue;
115814184Sgabeblack@google.com  }
115914184Sgabeblack@google.com
116014184Sgabeblack@google.com
116114184Sgabeblack@google.com  transition(I, Writeback_All_Tokens, M) {
116214184Sgabeblack@google.com    u_writeDataToCache;
116314184Sgabeblack@google.com    q_updateTokensFromResponse;
116414184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
116514184Sgabeblack@google.com    n_popResponseQueue;
116614184Sgabeblack@google.com  }
116714184Sgabeblack@google.com
116814184Sgabeblack@google.com  // Transitions from Shared
116914184Sgabeblack@google.com
117014184Sgabeblack@google.com  transition(S, L2_Replacement, I) {
117114184Sgabeblack@google.com    c_cleanReplacement;
117214184Sgabeblack@google.com    rr_deallocateL2CacheBlock;
117314184Sgabeblack@google.com  }
117414184Sgabeblack@google.com
117514184Sgabeblack@google.com  transition(S, Transient_GETX, I) {
117614184Sgabeblack@google.com    r_clearExclusive;
117714184Sgabeblack@google.com    t_sendAckWithCollectedTokens;
117814184Sgabeblack@google.com    j_forwardTransientRequestToLocalSharers;
117914184Sgabeblack@google.com    m_popRequestQueue;
118014184Sgabeblack@google.com  }
118114184Sgabeblack@google.com
118214184Sgabeblack@google.com  transition(S, {Transient_GETS, Transient_GETS_Last_Token}) {
118314184Sgabeblack@google.com    j_forwardTransientRequestToLocalSharers;
118414184Sgabeblack@google.com    r_clearExclusive;
118514184Sgabeblack@google.com    m_popRequestQueue;
118614184Sgabeblack@google.com  }
118714184Sgabeblack@google.com
118814184Sgabeblack@google.com  transition(S, Persistent_GETX, I_L) {
118914184Sgabeblack@google.com    e_sendAckWithCollectedTokens;
119014184Sgabeblack@google.com    l_popPersistentQueue;
119114184Sgabeblack@google.com  }
119214184Sgabeblack@google.com
119314184Sgabeblack@google.com
119414184Sgabeblack@google.com  transition(S, {Persistent_GETS, Persistent_GETS_Last_Token}, S_L) {
119514184Sgabeblack@google.com    f_sendAckWithAllButOneTokens;
119614184Sgabeblack@google.com    l_popPersistentQueue;
119714184Sgabeblack@google.com  }
119814184Sgabeblack@google.com
119914184Sgabeblack@google.com
120014184Sgabeblack@google.com  transition(S, Ack) {
120114184Sgabeblack@google.com    q_updateTokensFromResponse;
120214184Sgabeblack@google.com    n_popResponseQueue;
120314184Sgabeblack@google.com  }
120414184Sgabeblack@google.com
120514184Sgabeblack@google.com  transition(S, Data_Shared) {
120614184Sgabeblack@google.com    w_assertIncomingDataAndCacheDataMatch;
120714184Sgabeblack@google.com    q_updateTokensFromResponse;
120814184Sgabeblack@google.com    n_popResponseQueue;
120914184Sgabeblack@google.com  }
121014184Sgabeblack@google.com
121114184Sgabeblack@google.com  transition(S, Writeback_Tokens) {
121214184Sgabeblack@google.com    q_updateTokensFromResponse;
121314184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
121414184Sgabeblack@google.com    n_popResponseQueue;
121514184Sgabeblack@google.com  }
121614184Sgabeblack@google.com
121714184Sgabeblack@google.com  transition(S, Writeback_Shared_Data) {
121814184Sgabeblack@google.com    w_assertIncomingDataAndCacheDataMatch;
121914184Sgabeblack@google.com    q_updateTokensFromResponse;
122014184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
122114184Sgabeblack@google.com    n_popResponseQueue;
122214184Sgabeblack@google.com  }
122314184Sgabeblack@google.com
122414184Sgabeblack@google.com
122514184Sgabeblack@google.com  transition(S, Data_Owner, O) {
122614184Sgabeblack@google.com    w_assertIncomingDataAndCacheDataMatch;
122714184Sgabeblack@google.com    q_updateTokensFromResponse;
122814184Sgabeblack@google.com    n_popResponseQueue;
122914184Sgabeblack@google.com  }
123014184Sgabeblack@google.com
123114184Sgabeblack@google.com  transition(S, Writeback_Owned, O) {
123214184Sgabeblack@google.com    w_assertIncomingDataAndCacheDataMatch;
123314184Sgabeblack@google.com    q_updateTokensFromResponse;
123414184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
123514184Sgabeblack@google.com    n_popResponseQueue;
123614184Sgabeblack@google.com  }
123714184Sgabeblack@google.com
123814184Sgabeblack@google.com  transition(S, Data_All_Tokens, M) {
123914184Sgabeblack@google.com    w_assertIncomingDataAndCacheDataMatch;
124014184Sgabeblack@google.com    q_updateTokensFromResponse;
124114184Sgabeblack@google.com    n_popResponseQueue;
124214184Sgabeblack@google.com  }
124314184Sgabeblack@google.com
124414184Sgabeblack@google.com  transition(S, Writeback_All_Tokens,  M) {
124514184Sgabeblack@google.com    w_assertIncomingDataAndCacheDataMatch;
124614184Sgabeblack@google.com    q_updateTokensFromResponse;
124714184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
124814184Sgabeblack@google.com    n_popResponseQueue;
124914184Sgabeblack@google.com  }
125014184Sgabeblack@google.com
125114184Sgabeblack@google.com  transition(S, L1_GETX, I) {
125214184Sgabeblack@google.com    a_broadcastLocalRequest;
125314184Sgabeblack@google.com    tt_sendLocalAckWithCollectedTokens;
125414184Sgabeblack@google.com    r_markNewSharer;
125514184Sgabeblack@google.com    r_setMRU;
125614184Sgabeblack@google.com    uu_profileMiss;
125714184Sgabeblack@google.com    o_popL1RequestQueue;
125814184Sgabeblack@google.com  }
125914184Sgabeblack@google.com
126014184Sgabeblack@google.com
126114184Sgabeblack@google.com  transition(S, L1_GETS) {
126214184Sgabeblack@google.com    k_dataFromL2CacheToL1Requestor;
126314184Sgabeblack@google.com    r_markNewSharer;
126414184Sgabeblack@google.com    r_setMRU;
126514184Sgabeblack@google.com    uu_profileHit;
126614184Sgabeblack@google.com    o_popL1RequestQueue;
126714184Sgabeblack@google.com  }
126814184Sgabeblack@google.com
126914184Sgabeblack@google.com  transition(S, L1_GETS_Last_Token, I) {
127014184Sgabeblack@google.com
127114184Sgabeblack@google.com    k_dataFromL2CacheToL1Requestor;
127214184Sgabeblack@google.com    r_markNewSharer;
127314184Sgabeblack@google.com    r_setMRU;
127414184Sgabeblack@google.com    uu_profileHit;
127514184Sgabeblack@google.com    o_popL1RequestQueue;
127614184Sgabeblack@google.com  }
127714184Sgabeblack@google.com
127814184Sgabeblack@google.com  // Transitions from Owned
127914184Sgabeblack@google.com
128014184Sgabeblack@google.com  transition(O, L2_Replacement, I) {
128114184Sgabeblack@google.com    cc_dirtyReplacement;
128214184Sgabeblack@google.com    rr_deallocateL2CacheBlock;
128314184Sgabeblack@google.com  }
128414184Sgabeblack@google.com
128514184Sgabeblack@google.com  transition(O, Transient_GETX, I) {
128614184Sgabeblack@google.com    r_clearExclusive;
128714184Sgabeblack@google.com    dd_sendDataWithAllTokens;
128814184Sgabeblack@google.com    j_forwardTransientRequestToLocalSharers;
128914184Sgabeblack@google.com    m_popRequestQueue;
129014184Sgabeblack@google.com  }
129114184Sgabeblack@google.com
129214184Sgabeblack@google.com  transition(O, Persistent_GETX, I_L) {
129314184Sgabeblack@google.com    ee_sendDataWithAllTokens;
129414184Sgabeblack@google.com    l_popPersistentQueue;
129514184Sgabeblack@google.com  }
129614184Sgabeblack@google.com
129714184Sgabeblack@google.com  transition(O, Persistent_GETS, S_L) {
129814184Sgabeblack@google.com    ff_sendDataWithAllButOneTokens;
129914184Sgabeblack@google.com    l_popPersistentQueue;
130014184Sgabeblack@google.com  }
130114184Sgabeblack@google.com
130214184Sgabeblack@google.com  transition(O, Persistent_GETS_Last_Token, I_L) {
130314184Sgabeblack@google.com    fa_sendDataWithAllTokens;
130414184Sgabeblack@google.com    l_popPersistentQueue;
130514184Sgabeblack@google.com  }
130614184Sgabeblack@google.com
130714184Sgabeblack@google.com  transition(O, Transient_GETS) {
130814184Sgabeblack@google.com    // send multiple tokens
130914184Sgabeblack@google.com    r_clearExclusive;
131014184Sgabeblack@google.com    d_sendDataWithTokens;
131114184Sgabeblack@google.com    m_popRequestQueue;
131214184Sgabeblack@google.com  }
131314184Sgabeblack@google.com
131414184Sgabeblack@google.com  transition(O, Transient_GETS_Last_Token) {
131514184Sgabeblack@google.com    // WAIT FOR IT TO GO PERSISTENT
131614184Sgabeblack@google.com    r_clearExclusive;
131714184Sgabeblack@google.com    m_popRequestQueue;
131814184Sgabeblack@google.com  }
131914184Sgabeblack@google.com
132014184Sgabeblack@google.com  transition(O, Ack) {
132114184Sgabeblack@google.com    q_updateTokensFromResponse;
132214184Sgabeblack@google.com    n_popResponseQueue;
132314184Sgabeblack@google.com  }
132414184Sgabeblack@google.com
132514184Sgabeblack@google.com  transition(O, Ack_All_Tokens, M) {
132614184Sgabeblack@google.com    q_updateTokensFromResponse;
132714184Sgabeblack@google.com    n_popResponseQueue;
132814184Sgabeblack@google.com  }
132914184Sgabeblack@google.com
133014184Sgabeblack@google.com  transition(O, Data_Shared) {
133114184Sgabeblack@google.com    w_assertIncomingDataAndCacheDataMatch;
133214184Sgabeblack@google.com    q_updateTokensFromResponse;
133314184Sgabeblack@google.com    n_popResponseQueue;
133414184Sgabeblack@google.com  }
133514184Sgabeblack@google.com
133614184Sgabeblack@google.com
133714184Sgabeblack@google.com  transition(O, {Writeback_Tokens, Writeback_Shared_Data}) {
133814184Sgabeblack@google.com    w_assertIncomingDataAndCacheDataMatch;
133914184Sgabeblack@google.com    q_updateTokensFromResponse;
134014184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
134114184Sgabeblack@google.com    n_popResponseQueue;
134214184Sgabeblack@google.com  }
134314184Sgabeblack@google.com
134414184Sgabeblack@google.com  transition(O, Data_All_Tokens, M) {
134514184Sgabeblack@google.com    w_assertIncomingDataAndCacheDataMatch;
134614184Sgabeblack@google.com    q_updateTokensFromResponse;
134714184Sgabeblack@google.com    n_popResponseQueue;
134814184Sgabeblack@google.com  }
134914184Sgabeblack@google.com
135014184Sgabeblack@google.com  transition(O, Writeback_All_Tokens, M) {
135114184Sgabeblack@google.com    w_assertIncomingDataAndCacheDataMatch;
135214184Sgabeblack@google.com    q_updateTokensFromResponse;
135314184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
135414184Sgabeblack@google.com    n_popResponseQueue;
135514184Sgabeblack@google.com  }
135614184Sgabeblack@google.com
135714184Sgabeblack@google.com  transition(O, L1_GETS) {
135814184Sgabeblack@google.com    k_dataFromL2CacheToL1Requestor;
135914184Sgabeblack@google.com    r_markNewSharer;
136014184Sgabeblack@google.com    r_setMRU;
136114184Sgabeblack@google.com    uu_profileHit;
136214184Sgabeblack@google.com    o_popL1RequestQueue;
136314184Sgabeblack@google.com  }
136414184Sgabeblack@google.com
136514184Sgabeblack@google.com  transition(O, L1_GETS_Last_Token, I) {
136614184Sgabeblack@google.com    k_dataOwnerFromL2CacheToL1Requestor;
136714184Sgabeblack@google.com    r_markNewSharer;
136814184Sgabeblack@google.com    r_setMRU;
136914184Sgabeblack@google.com    uu_profileHit;
137014184Sgabeblack@google.com    o_popL1RequestQueue;
137114184Sgabeblack@google.com  }
137214184Sgabeblack@google.com
137314184Sgabeblack@google.com  transition(O, L1_GETX, I) {
137414184Sgabeblack@google.com    a_broadcastLocalRequest;
137514184Sgabeblack@google.com    k_dataAndAllTokensFromL2CacheToL1Requestor;
137614184Sgabeblack@google.com    r_markNewSharer;
137714184Sgabeblack@google.com    r_setMRU;
137814184Sgabeblack@google.com    uu_profileMiss;
137914184Sgabeblack@google.com    o_popL1RequestQueue;
138014184Sgabeblack@google.com  }
138114184Sgabeblack@google.com
138214184Sgabeblack@google.com  // Transitions from M
138314184Sgabeblack@google.com
138414184Sgabeblack@google.com  transition(M, L2_Replacement, I) {
138514184Sgabeblack@google.com    cc_dirtyReplacement;
138614184Sgabeblack@google.com    rr_deallocateL2CacheBlock;
138714184Sgabeblack@google.com  }
138814184Sgabeblack@google.com
138914184Sgabeblack@google.com  // MRM_DEBUG:  Give up all tokens even for GETS? ???
139014184Sgabeblack@google.com  transition(M, {Transient_GETX, Transient_GETS}, I) {
139114184Sgabeblack@google.com    r_clearExclusive;
139214184Sgabeblack@google.com    dd_sendDataWithAllTokens;
139314184Sgabeblack@google.com    m_popRequestQueue;
139414184Sgabeblack@google.com  }
139514184Sgabeblack@google.com
139614184Sgabeblack@google.com  transition(M, {Persistent_GETS, Persistent_GETX}, I_L) {
139714184Sgabeblack@google.com    ee_sendDataWithAllTokens;
139814184Sgabeblack@google.com    l_popPersistentQueue;
139914184Sgabeblack@google.com  }
140014184Sgabeblack@google.com
140114184Sgabeblack@google.com
140214184Sgabeblack@google.com  transition(M, L1_GETS, O) {
140314184Sgabeblack@google.com    k_dataFromL2CacheToL1Requestor;
140414184Sgabeblack@google.com    r_markNewSharer;
140514184Sgabeblack@google.com    r_setMRU;
140614184Sgabeblack@google.com    uu_profileHit;
140714184Sgabeblack@google.com    o_popL1RequestQueue;
140814184Sgabeblack@google.com  }
140914184Sgabeblack@google.com
141014184Sgabeblack@google.com  transition(M, L1_GETX, I) {
141114184Sgabeblack@google.com    k_dataAndAllTokensFromL2CacheToL1Requestor;
141214184Sgabeblack@google.com    r_markNewSharer;
141314184Sgabeblack@google.com    r_setMRU;
141414184Sgabeblack@google.com    uu_profileHit;
141514184Sgabeblack@google.com    o_popL1RequestQueue;
141614184Sgabeblack@google.com  }
141714184Sgabeblack@google.com
141814184Sgabeblack@google.com
141914184Sgabeblack@google.com  //Transitions from locked states
142014184Sgabeblack@google.com
142114184Sgabeblack@google.com  transition({I_L, S_L}, Ack) {
142214184Sgabeblack@google.com    gg_bounceResponseToStarver;
142314184Sgabeblack@google.com    n_popResponseQueue;
142414184Sgabeblack@google.com  }
142514184Sgabeblack@google.com
142614184Sgabeblack@google.com  transition({I_L, S_L}, {Data_Shared, Data_Owner, Data_All_Tokens}) {
142714184Sgabeblack@google.com    gg_bounceResponseToStarver;
142814184Sgabeblack@google.com    n_popResponseQueue;
142914184Sgabeblack@google.com  }
143014184Sgabeblack@google.com
143114184Sgabeblack@google.com  transition({I_L, S_L}, {Writeback_Tokens, Writeback_Shared_Data}) {
143214184Sgabeblack@google.com    gg_bounceWBSharedToStarver;
143314184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
143414184Sgabeblack@google.com    n_popResponseQueue;
143514184Sgabeblack@google.com  }
143614184Sgabeblack@google.com
143714184Sgabeblack@google.com  transition({I_L, S_L}, {Writeback_Owned, Writeback_All_Tokens}) {
143814184Sgabeblack@google.com    gg_bounceWBOwnedToStarver;
143914184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
144014184Sgabeblack@google.com    n_popResponseQueue;
144114184Sgabeblack@google.com  }
144214184Sgabeblack@google.com
144314184Sgabeblack@google.com  transition(S_L, L2_Replacement, I) {
144414184Sgabeblack@google.com    c_cleanReplacement;
144514184Sgabeblack@google.com    rr_deallocateL2CacheBlock;
144614184Sgabeblack@google.com  }
144714184Sgabeblack@google.com
144814184Sgabeblack@google.com  transition(I_L, L2_Replacement, I) {
144914184Sgabeblack@google.com    rr_deallocateL2CacheBlock;
145014184Sgabeblack@google.com  }
145114184Sgabeblack@google.com
145214184Sgabeblack@google.com  transition(I_L, Own_Lock_or_Unlock, I) {
145314184Sgabeblack@google.com    l_popPersistentQueue;
145414184Sgabeblack@google.com  }
145514184Sgabeblack@google.com
145614184Sgabeblack@google.com  transition(S_L, Own_Lock_or_Unlock, S) {
145714184Sgabeblack@google.com    l_popPersistentQueue;
145814184Sgabeblack@google.com  }
145914184Sgabeblack@google.com
146014184Sgabeblack@google.com  transition({I_L, S_L}, {Transient_GETS_Last_Token, Transient_GETS, Transient_GETX}) {
146114184Sgabeblack@google.com    r_clearExclusive;
146214184Sgabeblack@google.com    m_popRequestQueue;
146314184Sgabeblack@google.com  }
146414184Sgabeblack@google.com
146514184Sgabeblack@google.com  transition(I_L, {L1_GETX, L1_GETS}) {
146614184Sgabeblack@google.com    a_broadcastLocalRequest;
146714184Sgabeblack@google.com    r_markNewSharer;
146814184Sgabeblack@google.com    uu_profileMiss;
146914184Sgabeblack@google.com    o_popL1RequestQueue;
147014184Sgabeblack@google.com  }
147114184Sgabeblack@google.com
147214184Sgabeblack@google.com  transition(S_L, L1_GETX, I_L) {
147314184Sgabeblack@google.com    a_broadcastLocalRequest;
147414184Sgabeblack@google.com    tt_sendLocalAckWithCollectedTokens;
147514184Sgabeblack@google.com    r_markNewSharer;
147614184Sgabeblack@google.com    r_setMRU;
147714184Sgabeblack@google.com    uu_profileMiss;
147814184Sgabeblack@google.com    o_popL1RequestQueue;
147914184Sgabeblack@google.com  }
148014184Sgabeblack@google.com
148114184Sgabeblack@google.com  transition(S_L, L1_GETS) {
148214184Sgabeblack@google.com    k_dataFromL2CacheToL1Requestor;
148314184Sgabeblack@google.com    r_markNewSharer;
148414184Sgabeblack@google.com    r_setMRU;
148514184Sgabeblack@google.com    uu_profileHit;
148614184Sgabeblack@google.com    o_popL1RequestQueue;
148714184Sgabeblack@google.com  }
148814184Sgabeblack@google.com
148914184Sgabeblack@google.com  transition(S_L, L1_GETS_Last_Token, I_L) {
149014184Sgabeblack@google.com    k_dataFromL2CacheToL1Requestor;
149114184Sgabeblack@google.com    r_markNewSharer;
149214184Sgabeblack@google.com    r_setMRU;
149314184Sgabeblack@google.com    uu_profileHit;
149414184Sgabeblack@google.com    o_popL1RequestQueue;
149514184Sgabeblack@google.com  }
149614184Sgabeblack@google.com
149714184Sgabeblack@google.com  transition(S_L, Persistent_GETX, I_L) {
149814184Sgabeblack@google.com    e_sendAckWithCollectedTokens;
149914184Sgabeblack@google.com    l_popPersistentQueue;
150014184Sgabeblack@google.com  }
150114184Sgabeblack@google.com
150214184Sgabeblack@google.com  transition(S_L, {Persistent_GETS, Persistent_GETS_Last_Token}) {
150314184Sgabeblack@google.com    l_popPersistentQueue;
150414184Sgabeblack@google.com  }
150514184Sgabeblack@google.com
150614184Sgabeblack@google.com  transition(I_L, {Persistent_GETX, Persistent_GETS}) {
150714184Sgabeblack@google.com    l_popPersistentQueue;
150814184Sgabeblack@google.com  }
150914184Sgabeblack@google.com}
1510