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 {
45214300Sjqu32@wisc.edu                Addr victim := L2cache.cacheProbe(in_msg.addr);
45314300Sjqu32@wisc.edu                trigger(Event:L2_Replacement, victim, getCacheEntry(victim));
45414184Sgabeblack@google.com            }
45514184Sgabeblack@google.com          } else if (in_msg.Type == CoherenceResponseType:INV) {
45614184Sgabeblack@google.com            trigger(Event:L1_INV, in_msg.addr, cache_entry);
45714184Sgabeblack@google.com          } else {
45814184Sgabeblack@google.com            error("Unexpected message");
45914184Sgabeblack@google.com          }
46014184Sgabeblack@google.com        } else {
46114184Sgabeblack@google.com          if (in_msg.Type == CoherenceResponseType:ACK) {
46214184Sgabeblack@google.com            assert(in_msg.Tokens < (max_tokens() / 2));
46314184Sgabeblack@google.com            trigger(Event:Ack_All_Tokens, in_msg.addr, cache_entry);
46414184Sgabeblack@google.com          } else if (in_msg.Type == CoherenceResponseType:DATA_OWNER ||
46514184Sgabeblack@google.com                     in_msg.Type == CoherenceResponseType:DATA_SHARED) {
46614184Sgabeblack@google.com            trigger(Event:Data_All_Tokens, in_msg.addr, cache_entry);
46714184Sgabeblack@google.com          } else if (in_msg.Type == CoherenceResponseType:WB_TOKENS ||
46814184Sgabeblack@google.com                     in_msg.Type == CoherenceResponseType:WB_OWNED ||
46914184Sgabeblack@google.com                     in_msg.Type == CoherenceResponseType:WB_SHARED_DATA) {
47014184Sgabeblack@google.com            if (L2cache.cacheAvail(in_msg.addr) || is_valid(cache_entry)) {
47114184Sgabeblack@google.com
47214184Sgabeblack@google.com              // either room is available or the block is already present
47314184Sgabeblack@google.com
47414184Sgabeblack@google.com              if (in_msg.Type == CoherenceResponseType:WB_TOKENS) {
47514184Sgabeblack@google.com                assert(in_msg.Dirty == false);
47614184Sgabeblack@google.com                assert(  (getState(cache_entry, in_msg.addr) != State:NP)
47714184Sgabeblack@google.com                      && (getState(cache_entry, in_msg.addr) != State:I) );
47814184Sgabeblack@google.com                trigger(Event:Writeback_All_Tokens, in_msg.addr, cache_entry);
47914184Sgabeblack@google.com              } else if (in_msg.Type == CoherenceResponseType:WB_SHARED_DATA) {
48014184Sgabeblack@google.com                assert(in_msg.Dirty == false);
48114184Sgabeblack@google.com                trigger(Event:Writeback_All_Tokens, in_msg.addr, cache_entry);
48214184Sgabeblack@google.com              }
48314184Sgabeblack@google.com              else if (in_msg.Type == CoherenceResponseType:WB_OWNED) {
48414184Sgabeblack@google.com                trigger(Event:Writeback_All_Tokens, in_msg.addr, cache_entry);
48514184Sgabeblack@google.com              }
48614184Sgabeblack@google.com            }
48714184Sgabeblack@google.com            else {
48814300Sjqu32@wisc.edu                Addr victim := L2cache.cacheProbe(in_msg.addr);
48914300Sjqu32@wisc.edu                trigger(Event:L2_Replacement, victim, getCacheEntry(victim));
49014184Sgabeblack@google.com            }
49114184Sgabeblack@google.com          } else if (in_msg.Type == CoherenceResponseType:INV) {
49214184Sgabeblack@google.com            trigger(Event:L1_INV, in_msg.addr, cache_entry);
49314184Sgabeblack@google.com          } else {
49414184Sgabeblack@google.com            DPRINTF(RubySlicc, "%s\n", in_msg.Type);
49514184Sgabeblack@google.com            error("Unexpected message");
49614184Sgabeblack@google.com          }
49714184Sgabeblack@google.com        }
49814184Sgabeblack@google.com      }
49914184Sgabeblack@google.com    }
50014184Sgabeblack@google.com  }
50114184Sgabeblack@google.com
50214184Sgabeblack@google.com
50314184Sgabeblack@google.com  // ACTIONS
50414184Sgabeblack@google.com
50514184Sgabeblack@google.com  action(a_broadcastLocalRequest, "a", desc="broadcast local request globally") {
50614184Sgabeblack@google.com
50714184Sgabeblack@google.com    peek(L1requestNetwork_in, RequestMsg) {
50814184Sgabeblack@google.com
50914184Sgabeblack@google.com     // if this is a retry or no local sharers, broadcast normally
51014184Sgabeblack@google.com        enqueue(globalRequestNetwork_out, RequestMsg, l2_request_latency) {
51114184Sgabeblack@google.com           out_msg.addr := in_msg.addr;
51214184Sgabeblack@google.com           out_msg.Type := in_msg.Type;
51314184Sgabeblack@google.com           out_msg.Requestor := in_msg.Requestor;
51414184Sgabeblack@google.com           out_msg.RetryNum := in_msg.RetryNum;
51514184Sgabeblack@google.com
51614184Sgabeblack@google.com           //
51714184Sgabeblack@google.com           // If a statically shared L2 cache, then no other L2 caches can
51814184Sgabeblack@google.com           // store the block
51914184Sgabeblack@google.com           //
52014184Sgabeblack@google.com           //out_msg.Destination.broadcast(MachineType:L2Cache);
52114184Sgabeblack@google.com           //out_msg.Destination.addNetDest(getAllPertinentL2Banks(address));
52214184Sgabeblack@google.com           //out_msg.Destination.remove(map_L1CacheMachId_to_L2Cache(address, in_msg.Requestor));
52314184Sgabeblack@google.com
52414184Sgabeblack@google.com           out_msg.Destination.add(mapAddressToMachine(address, MachineType:Directory));
52514184Sgabeblack@google.com           out_msg.MessageSize := MessageSizeType:Request_Control;
52614184Sgabeblack@google.com           out_msg.AccessMode := in_msg.AccessMode;
52714184Sgabeblack@google.com           out_msg.Prefetch := in_msg.Prefetch;
52814184Sgabeblack@google.com        } //enqueue
52914184Sgabeblack@google.com      // } // if
53014184Sgabeblack@google.com
53114184Sgabeblack@google.com         //profile_filter_action(0);
53214184Sgabeblack@google.com    } // peek
53314184Sgabeblack@google.com  } //action
53414184Sgabeblack@google.com
53514184Sgabeblack@google.com
53614184Sgabeblack@google.com  action(bb_bounceResponse, "\b", desc="Bounce tokens and data to memory") {
53714184Sgabeblack@google.com    peek(responseNetwork_in, ResponseMsg) {
53814184Sgabeblack@google.com      // FIXME, should use a 3rd vnet
53914184Sgabeblack@google.com      enqueue(responseNetwork_out, ResponseMsg, 1) {
54014184Sgabeblack@google.com        out_msg.addr := address;
54114184Sgabeblack@google.com        out_msg.Type := in_msg.Type;
54214184Sgabeblack@google.com        out_msg.Sender := machineID;
54314184Sgabeblack@google.com        out_msg.Destination.add(mapAddressToMachine(address, MachineType:Directory));
54414184Sgabeblack@google.com        out_msg.Tokens := in_msg.Tokens;
54514184Sgabeblack@google.com        out_msg.MessageSize := in_msg.MessageSize;
54614184Sgabeblack@google.com        out_msg.DataBlk := in_msg.DataBlk;
54714184Sgabeblack@google.com        out_msg.Dirty := in_msg.Dirty;
54814184Sgabeblack@google.com      }
54914184Sgabeblack@google.com    }
55014184Sgabeblack@google.com  }
55114184Sgabeblack@google.com
55214184Sgabeblack@google.com  action(c_cleanReplacement, "c", desc="Issue clean writeback") {
55314184Sgabeblack@google.com    assert(is_valid(cache_entry));
55414184Sgabeblack@google.com    if (cache_entry.Tokens > 0) {
55514184Sgabeblack@google.com      enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
55614184Sgabeblack@google.com        out_msg.addr := address;
55714184Sgabeblack@google.com        out_msg.Type := CoherenceResponseType:ACK;
55814184Sgabeblack@google.com        out_msg.Sender := machineID;
55914184Sgabeblack@google.com        out_msg.Destination.add(mapAddressToMachine(address, MachineType:Directory));
56014184Sgabeblack@google.com        out_msg.Tokens := cache_entry.Tokens;
56114184Sgabeblack@google.com        out_msg.MessageSize := MessageSizeType:Writeback_Control;
56214184Sgabeblack@google.com      }
56314184Sgabeblack@google.com      cache_entry.Tokens := 0;
56414184Sgabeblack@google.com    }
56514184Sgabeblack@google.com  }
56614184Sgabeblack@google.com
56714184Sgabeblack@google.com  action(cc_dirtyReplacement, "\c", desc="Issue dirty writeback") {
56814184Sgabeblack@google.com    assert(is_valid(cache_entry));
56914184Sgabeblack@google.com    enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
57014184Sgabeblack@google.com      out_msg.addr := address;
57114184Sgabeblack@google.com      out_msg.Sender := machineID;
57214184Sgabeblack@google.com      out_msg.Destination.add(mapAddressToMachine(address, MachineType:Directory));
57314184Sgabeblack@google.com      out_msg.Tokens := cache_entry.Tokens;
57414184Sgabeblack@google.com      out_msg.DataBlk := cache_entry.DataBlk;
57514184Sgabeblack@google.com      out_msg.Dirty := cache_entry.Dirty;
57614184Sgabeblack@google.com
57714184Sgabeblack@google.com      if (cache_entry.Dirty) {
57814184Sgabeblack@google.com        out_msg.MessageSize := MessageSizeType:Writeback_Data;
57914184Sgabeblack@google.com        out_msg.Type := CoherenceResponseType:DATA_OWNER;
58014184Sgabeblack@google.com      } else {
58114184Sgabeblack@google.com        out_msg.MessageSize := MessageSizeType:Writeback_Control;
58214184Sgabeblack@google.com        out_msg.Type := CoherenceResponseType:ACK_OWNER;
58314184Sgabeblack@google.com      }
58414184Sgabeblack@google.com    }
58514184Sgabeblack@google.com    cache_entry.Tokens := 0;
58614184Sgabeblack@google.com  }
58714184Sgabeblack@google.com
58814184Sgabeblack@google.com  action(d_sendDataWithTokens, "d", desc="Send data and a token from cache to requestor") {
58914184Sgabeblack@google.com    peek(requestNetwork_in, RequestMsg) {
59014184Sgabeblack@google.com      assert(is_valid(cache_entry));
59114184Sgabeblack@google.com      if (cache_entry.Tokens > (N_tokens + (max_tokens() / 2))) {
59214184Sgabeblack@google.com        enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
59314184Sgabeblack@google.com          out_msg.addr := address;
59414184Sgabeblack@google.com          out_msg.Type := CoherenceResponseType:DATA_SHARED;
59514184Sgabeblack@google.com          out_msg.Sender := machineID;
59614184Sgabeblack@google.com          out_msg.Destination.add(in_msg.Requestor);
59714184Sgabeblack@google.com          out_msg.Tokens := N_tokens;
59814184Sgabeblack@google.com          out_msg.DataBlk := cache_entry.DataBlk;
59914184Sgabeblack@google.com          out_msg.Dirty := false;
60014184Sgabeblack@google.com          out_msg.MessageSize := MessageSizeType:Response_Data;
60114184Sgabeblack@google.com        }
60214184Sgabeblack@google.com        cache_entry.Tokens := cache_entry.Tokens - N_tokens;
60314184Sgabeblack@google.com      }
60414184Sgabeblack@google.com      else {
60514184Sgabeblack@google.com        enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
60614184Sgabeblack@google.com          out_msg.addr := address;
60714184Sgabeblack@google.com          out_msg.Type := CoherenceResponseType:DATA_SHARED;
60814184Sgabeblack@google.com          out_msg.Sender := machineID;
60914184Sgabeblack@google.com          out_msg.Destination.add(in_msg.Requestor);
61014184Sgabeblack@google.com          out_msg.Tokens := 1;
61114184Sgabeblack@google.com          out_msg.DataBlk := cache_entry.DataBlk;
61214184Sgabeblack@google.com          out_msg.Dirty := false;
61314184Sgabeblack@google.com          out_msg.MessageSize := MessageSizeType:Response_Data;
61414184Sgabeblack@google.com        }
61514184Sgabeblack@google.com        cache_entry.Tokens := cache_entry.Tokens - 1;
61614184Sgabeblack@google.com      }
61714184Sgabeblack@google.com    }
61814184Sgabeblack@google.com  }
61914184Sgabeblack@google.com
62014184Sgabeblack@google.com  action(dd_sendDataWithAllTokens, "\d", desc="Send data and all tokens from cache to requestor") {
62114184Sgabeblack@google.com    assert(is_valid(cache_entry));
62214184Sgabeblack@google.com    peek(requestNetwork_in, RequestMsg) {
62314184Sgabeblack@google.com      enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
62414184Sgabeblack@google.com        out_msg.addr := address;
62514184Sgabeblack@google.com        out_msg.Type := CoherenceResponseType:DATA_OWNER;
62614184Sgabeblack@google.com        out_msg.Sender := machineID;
62714184Sgabeblack@google.com        out_msg.Destination.add(in_msg.Requestor);
62814184Sgabeblack@google.com        assert(cache_entry.Tokens >= 1);
62914184Sgabeblack@google.com        out_msg.Tokens := cache_entry.Tokens;
63014184Sgabeblack@google.com        out_msg.DataBlk := cache_entry.DataBlk;
63114184Sgabeblack@google.com        out_msg.Dirty := cache_entry.Dirty;
63214184Sgabeblack@google.com        out_msg.MessageSize := MessageSizeType:Response_Data;
63314184Sgabeblack@google.com      }
63414184Sgabeblack@google.com    }
63514184Sgabeblack@google.com    cache_entry.Tokens := 0;
63614184Sgabeblack@google.com  }
63714184Sgabeblack@google.com
63814184Sgabeblack@google.com  action(e_sendAckWithCollectedTokens, "e", desc="Send ack with the tokens we've collected thus far.") {
63914184Sgabeblack@google.com    assert(is_valid(cache_entry));
64014184Sgabeblack@google.com    if (cache_entry.Tokens > 0) {
64114184Sgabeblack@google.com      enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
64214184Sgabeblack@google.com        out_msg.addr := address;
64314184Sgabeblack@google.com        out_msg.Type := CoherenceResponseType:ACK;
64414184Sgabeblack@google.com        out_msg.Sender := machineID;
64514184Sgabeblack@google.com        out_msg.Destination.add(persistentTable.findSmallest(address));
64614184Sgabeblack@google.com        assert(cache_entry.Tokens >= 1);
64714184Sgabeblack@google.com        out_msg.Tokens := cache_entry.Tokens;
64814184Sgabeblack@google.com        out_msg.MessageSize := MessageSizeType:Response_Control;
64914184Sgabeblack@google.com      }
65014184Sgabeblack@google.com    }
65114184Sgabeblack@google.com    cache_entry.Tokens := 0;
65214184Sgabeblack@google.com  }
65314184Sgabeblack@google.com
65414184Sgabeblack@google.com  action(ee_sendDataWithAllTokens, "\e", desc="Send data and all tokens from cache to starver") {
65514184Sgabeblack@google.com    assert(is_valid(cache_entry));
65614184Sgabeblack@google.com    enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
65714184Sgabeblack@google.com      out_msg.addr := address;
65814184Sgabeblack@google.com      out_msg.Type := CoherenceResponseType:DATA_OWNER;
65914184Sgabeblack@google.com      out_msg.Sender := machineID;
66014184Sgabeblack@google.com      out_msg.Destination.add(persistentTable.findSmallest(address));
66114184Sgabeblack@google.com      assert(cache_entry.Tokens >= 1);
66214184Sgabeblack@google.com      out_msg.Tokens := cache_entry.Tokens;
66314184Sgabeblack@google.com      out_msg.DataBlk := cache_entry.DataBlk;
66414184Sgabeblack@google.com      out_msg.Dirty := cache_entry.Dirty;
66514184Sgabeblack@google.com      out_msg.MessageSize := MessageSizeType:Response_Data;
66614184Sgabeblack@google.com    }
66714184Sgabeblack@google.com    cache_entry.Tokens := 0;
66814184Sgabeblack@google.com  }
66914184Sgabeblack@google.com
67014184Sgabeblack@google.com  action(f_sendAckWithAllButOneTokens, "f", desc="Send ack with all our tokens but one to starver.") {
67114184Sgabeblack@google.com    //assert(persistentTable.findSmallest(address) != id); // Make sure we never bounce tokens to ourself
67214184Sgabeblack@google.com    assert(is_valid(cache_entry));
67314184Sgabeblack@google.com    assert(cache_entry.Tokens > 0);
67414184Sgabeblack@google.com    if (cache_entry.Tokens > 1) {
67514184Sgabeblack@google.com      enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
67614184Sgabeblack@google.com        out_msg.addr := address;
67714184Sgabeblack@google.com        out_msg.Type := CoherenceResponseType:ACK;
67814184Sgabeblack@google.com        out_msg.Sender := machineID;
67914184Sgabeblack@google.com        out_msg.Destination.add(persistentTable.findSmallest(address));
68014184Sgabeblack@google.com        assert(cache_entry.Tokens >= 1);
68114184Sgabeblack@google.com        out_msg.Tokens := cache_entry.Tokens - 1;
68214184Sgabeblack@google.com        out_msg.MessageSize := MessageSizeType:Response_Control;
68314184Sgabeblack@google.com      }
68414184Sgabeblack@google.com    }
68514184Sgabeblack@google.com    cache_entry.Tokens := 1;
68614184Sgabeblack@google.com  }
68714184Sgabeblack@google.com
68814184Sgabeblack@google.com  action(ff_sendDataWithAllButOneTokens, "\f", desc="Send data and out tokens but one to starver") {
68914184Sgabeblack@google.com    //assert(persistentTable.findSmallest(address) != id); // Make sure we never bounce tokens to ourself
69014184Sgabeblack@google.com    assert(is_valid(cache_entry));
69114184Sgabeblack@google.com    assert(cache_entry.Tokens > (max_tokens() / 2) + 1);
69214184Sgabeblack@google.com    enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
69314184Sgabeblack@google.com        out_msg.addr := address;
69414184Sgabeblack@google.com        out_msg.Type := CoherenceResponseType:DATA_OWNER;
69514184Sgabeblack@google.com        out_msg.Sender := machineID;
69614184Sgabeblack@google.com        out_msg.Destination.add(persistentTable.findSmallest(address));
69714184Sgabeblack@google.com        out_msg.Tokens := cache_entry.Tokens - 1;
69814184Sgabeblack@google.com        out_msg.DataBlk := cache_entry.DataBlk;
69914184Sgabeblack@google.com        out_msg.Dirty := cache_entry.Dirty;
70014184Sgabeblack@google.com        out_msg.MessageSize := MessageSizeType:Response_Data;
70114184Sgabeblack@google.com    }
70214184Sgabeblack@google.com    cache_entry.Tokens := 1;
70314184Sgabeblack@google.com  }
70414184Sgabeblack@google.com
70514184Sgabeblack@google.com  action(fa_sendDataWithAllTokens, "fa", desc="Send data and out tokens but one to starver") {
70614184Sgabeblack@google.com    //assert(persistentTable.findSmallest(address) != id); // Make sure we never bounce tokens to ourself
70714184Sgabeblack@google.com    assert(is_valid(cache_entry));
70814184Sgabeblack@google.com    assert(cache_entry.Tokens == (max_tokens() / 2) + 1);
70914184Sgabeblack@google.com    enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
71014184Sgabeblack@google.com        out_msg.addr := address;
71114184Sgabeblack@google.com        out_msg.Type := CoherenceResponseType:DATA_OWNER;
71214184Sgabeblack@google.com        out_msg.Sender := machineID;
71314184Sgabeblack@google.com        out_msg.Destination.add(persistentTable.findSmallest(address));
71414184Sgabeblack@google.com        out_msg.Tokens := cache_entry.Tokens;
71514184Sgabeblack@google.com        out_msg.DataBlk := cache_entry.DataBlk;
71614184Sgabeblack@google.com        out_msg.Dirty := cache_entry.Dirty;
71714184Sgabeblack@google.com        out_msg.MessageSize := MessageSizeType:Response_Data;
71814184Sgabeblack@google.com    }
71914184Sgabeblack@google.com    cache_entry.Tokens := 0;
72014184Sgabeblack@google.com  }
72114184Sgabeblack@google.com
72214184Sgabeblack@google.com
72314184Sgabeblack@google.com
72414184Sgabeblack@google.com  action(gg_bounceResponseToStarver, "\g", desc="Redirect response to starving processor") {
72514184Sgabeblack@google.com    // assert(persistentTable.isLocked(address));
72614184Sgabeblack@google.com    peek(responseNetwork_in, ResponseMsg) {
72714184Sgabeblack@google.com      // FIXME, should use a 3rd vnet in some cases
72814184Sgabeblack@google.com      enqueue(responseNetwork_out, ResponseMsg, 1) {
72914184Sgabeblack@google.com        out_msg.addr := address;
73014184Sgabeblack@google.com        out_msg.Type := in_msg.Type;
73114184Sgabeblack@google.com        out_msg.Sender := machineID;
73214184Sgabeblack@google.com        out_msg.Destination.add(persistentTable.findSmallest(address));
73314184Sgabeblack@google.com        out_msg.Tokens := in_msg.Tokens;
73414184Sgabeblack@google.com        out_msg.DataBlk := in_msg.DataBlk;
73514184Sgabeblack@google.com        out_msg.Dirty := in_msg.Dirty;
73614184Sgabeblack@google.com        out_msg.MessageSize := in_msg.MessageSize;
73714184Sgabeblack@google.com      }
73814184Sgabeblack@google.com    }
73914184Sgabeblack@google.com  }
74014184Sgabeblack@google.com
74114184Sgabeblack@google.com  action(gg_bounceWBSharedToStarver, "\gg", desc="Redirect response to starving processor") {
74214184Sgabeblack@google.com    //assert(persistentTable.isLocked(address));
74314184Sgabeblack@google.com    peek(responseNetwork_in, ResponseMsg) {
74414184Sgabeblack@google.com      // FIXME, should use a 3rd vnet in some cases
74514184Sgabeblack@google.com      enqueue(responseNetwork_out, ResponseMsg, 1) {
74614184Sgabeblack@google.com        out_msg.addr := address;
74714184Sgabeblack@google.com        if (in_msg.Type == CoherenceResponseType:WB_SHARED_DATA) {
74814184Sgabeblack@google.com          out_msg.Type := CoherenceResponseType:DATA_SHARED;
74914184Sgabeblack@google.com        } else {
75014184Sgabeblack@google.com          assert(in_msg.Tokens < (max_tokens() / 2));
75114184Sgabeblack@google.com          out_msg.Type := CoherenceResponseType:ACK;
75214184Sgabeblack@google.com        }
75314184Sgabeblack@google.com        out_msg.Sender := machineID;
75414184Sgabeblack@google.com        out_msg.Destination.add(persistentTable.findSmallest(address));
75514184Sgabeblack@google.com        out_msg.Tokens := in_msg.Tokens;
75614184Sgabeblack@google.com        out_msg.DataBlk := in_msg.DataBlk;
75714184Sgabeblack@google.com        out_msg.Dirty := in_msg.Dirty;
75814184Sgabeblack@google.com        out_msg.MessageSize := in_msg.MessageSize;
75914184Sgabeblack@google.com      }
76014184Sgabeblack@google.com    }
76114184Sgabeblack@google.com  }
76214184Sgabeblack@google.com
76314184Sgabeblack@google.com  action(gg_bounceWBOwnedToStarver, "\ggg", desc="Redirect response to starving processor") {
76414184Sgabeblack@google.com    // assert(persistentTable.isLocked(address));
76514184Sgabeblack@google.com    peek(responseNetwork_in, ResponseMsg) {
76614184Sgabeblack@google.com      // FIXME, should use a 3rd vnet in some cases
76714184Sgabeblack@google.com      enqueue(responseNetwork_out, ResponseMsg, 1) {
76814184Sgabeblack@google.com        out_msg.addr := address;
76914184Sgabeblack@google.com        out_msg.Type := CoherenceResponseType:DATA_OWNER;
77014184Sgabeblack@google.com        out_msg.Sender := machineID;
77114184Sgabeblack@google.com        out_msg.Destination.add(persistentTable.findSmallest(address));
77214184Sgabeblack@google.com        out_msg.Tokens := in_msg.Tokens;
77314184Sgabeblack@google.com        out_msg.DataBlk := in_msg.DataBlk;
77414184Sgabeblack@google.com        out_msg.Dirty := in_msg.Dirty;
77514184Sgabeblack@google.com        out_msg.MessageSize := in_msg.MessageSize;
77614184Sgabeblack@google.com      }
77714184Sgabeblack@google.com    }
77814184Sgabeblack@google.com  }
77914184Sgabeblack@google.com
78014184Sgabeblack@google.com
78114184Sgabeblack@google.com  action(h_updateFilterFromL1HintOrWB, "h", desc="update filter from received writeback") {
78214184Sgabeblack@google.com    peek(responseNetwork_in, ResponseMsg) {
78314184Sgabeblack@google.com      removeSharer(in_msg.addr, machineIDToNodeID(in_msg.Sender));
78414184Sgabeblack@google.com    }
78514184Sgabeblack@google.com  }
78614184Sgabeblack@google.com
78714184Sgabeblack@google.com  action(j_forwardTransientRequestToLocalSharers, "j", desc="Forward external transient request to local sharers") {
78814184Sgabeblack@google.com    peek(requestNetwork_in, RequestMsg) {
78914184Sgabeblack@google.com      if (filtering_enabled && in_msg.RetryNum == 0 && sharersExist(in_msg.addr) == false) {
79014184Sgabeblack@google.com        //profile_filter_action(1);
79114184Sgabeblack@google.com        DPRINTF(RubySlicc, "filtered message, Retry Num: %d\n",
79214184Sgabeblack@google.com                in_msg.RetryNum);
79314184Sgabeblack@google.com      }
79414184Sgabeblack@google.com      else {
79514184Sgabeblack@google.com        enqueue(localRequestNetwork_out, RequestMsg, l2_response_latency ) {
79614184Sgabeblack@google.com           out_msg.addr := in_msg.addr;
79714184Sgabeblack@google.com           out_msg.Requestor := in_msg.Requestor;
79814184Sgabeblack@google.com
79914184Sgabeblack@google.com           //
80014184Sgabeblack@google.com           // Currently assuming only one chip so all L1s are local
80114184Sgabeblack@google.com           //
80214184Sgabeblack@google.com           //out_msg.Destination := getLocalL1IDs(machineID);
80314184Sgabeblack@google.com           out_msg.Destination.broadcast(MachineType:L1Cache);
80414184Sgabeblack@google.com           out_msg.Destination.remove(in_msg.Requestor);
80514184Sgabeblack@google.com
80614184Sgabeblack@google.com           out_msg.Type := in_msg.Type;
80714184Sgabeblack@google.com           out_msg.isLocal := false;
80814184Sgabeblack@google.com           out_msg.MessageSize := MessageSizeType:Broadcast_Control;
80914184Sgabeblack@google.com           out_msg.AccessMode := in_msg.AccessMode;
81014184Sgabeblack@google.com           out_msg.Prefetch := in_msg.Prefetch;
81114184Sgabeblack@google.com        }
81214184Sgabeblack@google.com        //profile_filter_action(0);
81314184Sgabeblack@google.com      }
81414184Sgabeblack@google.com    }
81514184Sgabeblack@google.com  }
81614184Sgabeblack@google.com
81714184Sgabeblack@google.com  action(k_dataFromL2CacheToL1Requestor, "k", desc="Send data and a token from cache to L1 requestor") {
81814184Sgabeblack@google.com    peek(L1requestNetwork_in, RequestMsg) {
81914184Sgabeblack@google.com      assert(is_valid(cache_entry));
82014184Sgabeblack@google.com      assert(cache_entry.Tokens > 0);
82114184Sgabeblack@google.com      enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
82214184Sgabeblack@google.com        out_msg.addr := address;
82314184Sgabeblack@google.com        out_msg.Type := CoherenceResponseType:DATA_SHARED;
82414184Sgabeblack@google.com        out_msg.Sender := machineID;
82514184Sgabeblack@google.com        out_msg.Destination.add(in_msg.Requestor);
82614184Sgabeblack@google.com        out_msg.DataBlk := cache_entry.DataBlk;
82714184Sgabeblack@google.com        out_msg.Dirty := false;
82814184Sgabeblack@google.com        out_msg.MessageSize := MessageSizeType:ResponseL2hit_Data;
82914184Sgabeblack@google.com        out_msg.Tokens := 1;
83014184Sgabeblack@google.com      }
83114184Sgabeblack@google.com      cache_entry.Tokens := cache_entry.Tokens - 1;
83214184Sgabeblack@google.com    }
83314184Sgabeblack@google.com  }
83414184Sgabeblack@google.com
83514184Sgabeblack@google.com  action(k_dataOwnerFromL2CacheToL1Requestor, "\k", desc="Send data and a token from cache to L1 requestor") {
83614184Sgabeblack@google.com    peek(L1requestNetwork_in, RequestMsg) {
83714184Sgabeblack@google.com      assert(is_valid(cache_entry));
83814184Sgabeblack@google.com      assert(cache_entry.Tokens == (max_tokens() / 2) + 1);
83914184Sgabeblack@google.com      enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
84014184Sgabeblack@google.com        out_msg.addr := address;
84114184Sgabeblack@google.com        out_msg.Type := CoherenceResponseType:DATA_OWNER;
84214184Sgabeblack@google.com        out_msg.Sender := machineID;
84314184Sgabeblack@google.com        out_msg.Destination.add(in_msg.Requestor);
84414184Sgabeblack@google.com        out_msg.DataBlk := cache_entry.DataBlk;
84514184Sgabeblack@google.com        out_msg.Dirty := cache_entry.Dirty;
84614184Sgabeblack@google.com        out_msg.MessageSize := MessageSizeType:ResponseL2hit_Data;
84714184Sgabeblack@google.com        out_msg.Tokens := cache_entry.Tokens;
84814184Sgabeblack@google.com      }
84914184Sgabeblack@google.com      cache_entry.Tokens := 0;
85014184Sgabeblack@google.com    }
85114184Sgabeblack@google.com  }
85214184Sgabeblack@google.com
85314184Sgabeblack@google.com  action(k_dataAndAllTokensFromL2CacheToL1Requestor, "\kk", desc="Send data and a token from cache to L1 requestor") {
85414184Sgabeblack@google.com    peek(L1requestNetwork_in, RequestMsg) {
85514184Sgabeblack@google.com      assert(is_valid(cache_entry));
85614184Sgabeblack@google.com//      assert(cache_entry.Tokens == max_tokens());
85714184Sgabeblack@google.com      enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
85814184Sgabeblack@google.com        out_msg.addr := address;
85914184Sgabeblack@google.com        out_msg.Type := CoherenceResponseType:DATA_OWNER;
86014184Sgabeblack@google.com        out_msg.Sender := machineID;
86114184Sgabeblack@google.com        out_msg.Destination.add(in_msg.Requestor);
86214184Sgabeblack@google.com        out_msg.DataBlk := cache_entry.DataBlk;
86314184Sgabeblack@google.com        out_msg.Dirty := cache_entry.Dirty;
86414184Sgabeblack@google.com        out_msg.MessageSize := MessageSizeType:ResponseL2hit_Data;
86514184Sgabeblack@google.com        //out_msg.Tokens := max_tokens();
86614184Sgabeblack@google.com        out_msg.Tokens := cache_entry.Tokens;
86714184Sgabeblack@google.com      }
86814184Sgabeblack@google.com      cache_entry.Tokens := 0;
86914184Sgabeblack@google.com    }
87014184Sgabeblack@google.com  }
87114184Sgabeblack@google.com
87214184Sgabeblack@google.com  action(l_popPersistentQueue, "l", desc="Pop persistent queue.") {
87314184Sgabeblack@google.com    persistentNetwork_in.dequeue(clockEdge());
87414184Sgabeblack@google.com  }
87514184Sgabeblack@google.com
87614184Sgabeblack@google.com  action(m_popRequestQueue, "m", desc="Pop request queue.") {
87714184Sgabeblack@google.com    requestNetwork_in.dequeue(clockEdge());
87814184Sgabeblack@google.com  }
87914184Sgabeblack@google.com
88014184Sgabeblack@google.com  action(n_popResponseQueue, "n", desc="Pop response queue") {
88114184Sgabeblack@google.com    responseNetwork_in.dequeue(clockEdge());
88214184Sgabeblack@google.com  }
88314184Sgabeblack@google.com
88414184Sgabeblack@google.com  action(o_popL1RequestQueue, "o", desc="Pop L1 request queue.") {
88514184Sgabeblack@google.com    L1requestNetwork_in.dequeue(clockEdge());
88614184Sgabeblack@google.com  }
88714184Sgabeblack@google.com
88814184Sgabeblack@google.com
88914184Sgabeblack@google.com  action(q_updateTokensFromResponse, "q", desc="Update the token count based on the incoming response message") {
89014184Sgabeblack@google.com    peek(responseNetwork_in, ResponseMsg) {
89114184Sgabeblack@google.com      assert(is_valid(cache_entry));
89214184Sgabeblack@google.com      assert(in_msg.Tokens != 0);
89314184Sgabeblack@google.com      cache_entry.Tokens := cache_entry.Tokens + in_msg.Tokens;
89414184Sgabeblack@google.com
89514184Sgabeblack@google.com      // this should ideally be in u_writeDataToCache, but Writeback_All_Tokens
89614184Sgabeblack@google.com      //  may not trigger this action.
89714184Sgabeblack@google.com      if ( (in_msg.Type == CoherenceResponseType:DATA_OWNER || in_msg.Type == CoherenceResponseType:WB_OWNED) && in_msg.Dirty) {
89814184Sgabeblack@google.com        cache_entry.Dirty := true;
89914184Sgabeblack@google.com      }
90014184Sgabeblack@google.com    }
90114184Sgabeblack@google.com  }
90214184Sgabeblack@google.com
90314184Sgabeblack@google.com  action(r_markNewSharer, "r", desc="Mark the new local sharer from local request message") {
90414184Sgabeblack@google.com    peek(L1requestNetwork_in, RequestMsg) {
90514184Sgabeblack@google.com      if (machineIDToMachineType(in_msg.Requestor) == MachineType:L1Cache) {
90614184Sgabeblack@google.com        if (in_msg.Type == CoherenceRequestType:GETX) {
90714184Sgabeblack@google.com          setNewWriter(in_msg.addr, machineIDToNodeID(in_msg.Requestor));
90814184Sgabeblack@google.com        } else if (in_msg.Type == CoherenceRequestType:GETS) {
90914184Sgabeblack@google.com          addNewSharer(in_msg.addr, machineIDToNodeID(in_msg.Requestor));
91014184Sgabeblack@google.com        }
91114184Sgabeblack@google.com      }
91214184Sgabeblack@google.com    }
91314184Sgabeblack@google.com  }
91414184Sgabeblack@google.com
91514184Sgabeblack@google.com  action(r_clearExclusive, "\rrr", desc="clear exclusive bit") {
91614184Sgabeblack@google.com    clearExclusiveBitIfExists(address);
91714184Sgabeblack@google.com  }
91814184Sgabeblack@google.com
91914184Sgabeblack@google.com  action(r_setMRU, "\rr", desc="manually set the MRU bit for cache line" ) {
92014184Sgabeblack@google.com    peek(L1requestNetwork_in, RequestMsg) {
92114184Sgabeblack@google.com      if ((machineIDToMachineType(in_msg.Requestor) == MachineType:L1Cache) &&
92214184Sgabeblack@google.com          (is_valid(cache_entry))) {
92314184Sgabeblack@google.com        L2cache.setMRU(address);
92414184Sgabeblack@google.com      }
92514184Sgabeblack@google.com    }
92614184Sgabeblack@google.com  }
92714184Sgabeblack@google.com
92814184Sgabeblack@google.com  action(t_sendAckWithCollectedTokens, "t", desc="Send ack with the tokens we've collected thus far.") {
92914184Sgabeblack@google.com    assert(is_valid(cache_entry));
93014184Sgabeblack@google.com    if (cache_entry.Tokens > 0) {
93114184Sgabeblack@google.com      peek(requestNetwork_in, RequestMsg) {
93214184Sgabeblack@google.com        enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
93314184Sgabeblack@google.com          out_msg.addr := address;
93414184Sgabeblack@google.com          out_msg.Type := CoherenceResponseType:ACK;
93514184Sgabeblack@google.com          out_msg.Sender := machineID;
93614184Sgabeblack@google.com          out_msg.Destination.add(in_msg.Requestor);
93714184Sgabeblack@google.com          assert(cache_entry.Tokens >= 1);
93814184Sgabeblack@google.com          out_msg.Tokens := cache_entry.Tokens;
93914184Sgabeblack@google.com          out_msg.MessageSize := MessageSizeType:Response_Control;
94014184Sgabeblack@google.com        }
94114184Sgabeblack@google.com      }
94214184Sgabeblack@google.com    }
94314184Sgabeblack@google.com    cache_entry.Tokens := 0;
94414184Sgabeblack@google.com  }
94514184Sgabeblack@google.com
94614184Sgabeblack@google.com  action(tt_sendLocalAckWithCollectedTokens, "tt", desc="Send ack with the tokens we've collected thus far.") {
94714184Sgabeblack@google.com    assert(is_valid(cache_entry));
94814184Sgabeblack@google.com    if (cache_entry.Tokens > 0) {
94914184Sgabeblack@google.com      peek(L1requestNetwork_in, RequestMsg) {
95014184Sgabeblack@google.com        enqueue(responseNetwork_out, ResponseMsg, l2_response_latency) {
95114184Sgabeblack@google.com          out_msg.addr := address;
95214184Sgabeblack@google.com          out_msg.Type := CoherenceResponseType:ACK;
95314184Sgabeblack@google.com          out_msg.Sender := machineID;
95414184Sgabeblack@google.com          out_msg.Destination.add(in_msg.Requestor);
95514184Sgabeblack@google.com          assert(cache_entry.Tokens >= 1);
95614184Sgabeblack@google.com          out_msg.Tokens := cache_entry.Tokens;
95714184Sgabeblack@google.com          out_msg.MessageSize := MessageSizeType:Response_Control;
95814184Sgabeblack@google.com        }
95914184Sgabeblack@google.com      }
96014184Sgabeblack@google.com    }
96114184Sgabeblack@google.com    cache_entry.Tokens := 0;
96214184Sgabeblack@google.com  }
96314184Sgabeblack@google.com
96414184Sgabeblack@google.com  action(u_writeDataToCache, "u", desc="Write data to cache") {
96514184Sgabeblack@google.com    peek(responseNetwork_in, ResponseMsg) {
96614184Sgabeblack@google.com      assert(is_valid(cache_entry));
96714184Sgabeblack@google.com      cache_entry.DataBlk := in_msg.DataBlk;
96814184Sgabeblack@google.com      if ((cache_entry.Dirty == false) && in_msg.Dirty) {
96914184Sgabeblack@google.com        cache_entry.Dirty := in_msg.Dirty;
97014184Sgabeblack@google.com      }
97114184Sgabeblack@google.com    }
97214184Sgabeblack@google.com  }
97314184Sgabeblack@google.com
97414184Sgabeblack@google.com  action(vv_allocateL2CacheBlock, "\v", desc="Set L2 cache tag equal to tag of block B.") {
97514184Sgabeblack@google.com    set_cache_entry(L2cache.allocate(address, new Entry));
97614184Sgabeblack@google.com  }
97714184Sgabeblack@google.com
97814184Sgabeblack@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.") {
97914184Sgabeblack@google.com    L2cache.deallocate(address);
98014184Sgabeblack@google.com    unset_cache_entry();
98114184Sgabeblack@google.com  }
98214184Sgabeblack@google.com
98314184Sgabeblack@google.com  action(uu_profileMiss, "\um", desc="Profile the demand miss") {
98414184Sgabeblack@google.com      ++L2cache.demand_misses;
98514184Sgabeblack@google.com  }
98614184Sgabeblack@google.com
98714184Sgabeblack@google.com  action(uu_profileHit, "\uh", desc="Profile the demand hit") {
98814184Sgabeblack@google.com      ++L2cache.demand_hits;
98914184Sgabeblack@google.com  }
99014184Sgabeblack@google.com
99114184Sgabeblack@google.com  action(w_assertIncomingDataAndCacheDataMatch, "w", desc="Assert that the incoming data and the data in the cache match") {
99214184Sgabeblack@google.com    peek(responseNetwork_in, ResponseMsg) {
99314184Sgabeblack@google.com      if (in_msg.Type != CoherenceResponseType:ACK &&
99414184Sgabeblack@google.com          in_msg.Type != CoherenceResponseType:WB_TOKENS) {
99514184Sgabeblack@google.com        assert(is_valid(cache_entry));
99614184Sgabeblack@google.com        assert(cache_entry.DataBlk == in_msg.DataBlk);
99714184Sgabeblack@google.com      }
99814184Sgabeblack@google.com    }
99914184Sgabeblack@google.com  }
100014184Sgabeblack@google.com
100114184Sgabeblack@google.com
100214184Sgabeblack@google.com  //*****************************************************
100314184Sgabeblack@google.com  // TRANSITIONS
100414184Sgabeblack@google.com  //*****************************************************
100514184Sgabeblack@google.com
100614184Sgabeblack@google.com  transition({NP, I, S, O, M, I_L, S_L}, L1_INV) {
100714184Sgabeblack@google.com
100814184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
100914184Sgabeblack@google.com    n_popResponseQueue;
101014184Sgabeblack@google.com  }
101114184Sgabeblack@google.com
101214184Sgabeblack@google.com  transition({NP, I, S, O, M}, Own_Lock_or_Unlock) {
101314184Sgabeblack@google.com    l_popPersistentQueue;
101414184Sgabeblack@google.com  }
101514184Sgabeblack@google.com
101614184Sgabeblack@google.com
101714184Sgabeblack@google.com  // Transitions from NP
101814184Sgabeblack@google.com
101914184Sgabeblack@google.com  transition(NP, {Transient_GETX, Transient_GETS}) {
102014184Sgabeblack@google.com    // forward message to local sharers
102114184Sgabeblack@google.com    r_clearExclusive;
102214184Sgabeblack@google.com    j_forwardTransientRequestToLocalSharers;
102314184Sgabeblack@google.com    m_popRequestQueue;
102414184Sgabeblack@google.com  }
102514184Sgabeblack@google.com
102614184Sgabeblack@google.com
102714184Sgabeblack@google.com  transition(NP,  {L1_GETS, L1_GETX}) {
102814184Sgabeblack@google.com    a_broadcastLocalRequest;
102914184Sgabeblack@google.com    r_markNewSharer;
103014184Sgabeblack@google.com    uu_profileMiss;
103114184Sgabeblack@google.com    o_popL1RequestQueue;
103214184Sgabeblack@google.com  }
103314184Sgabeblack@google.com
103414184Sgabeblack@google.com  transition(NP, {Ack, Data_Shared, Data_Owner, Data_All_Tokens}) {
103514184Sgabeblack@google.com    bb_bounceResponse;
103614184Sgabeblack@google.com    n_popResponseQueue;
103714184Sgabeblack@google.com  }
103814184Sgabeblack@google.com
103914184Sgabeblack@google.com  transition(NP, Writeback_Shared_Data, S) {
104014184Sgabeblack@google.com    vv_allocateL2CacheBlock;
104114184Sgabeblack@google.com    u_writeDataToCache;
104214184Sgabeblack@google.com    q_updateTokensFromResponse;
104314184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
104414184Sgabeblack@google.com    n_popResponseQueue;
104514184Sgabeblack@google.com  }
104614184Sgabeblack@google.com
104714184Sgabeblack@google.com  transition(NP, Writeback_Tokens, I) {
104814184Sgabeblack@google.com    vv_allocateL2CacheBlock;
104914184Sgabeblack@google.com    q_updateTokensFromResponse;
105014184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
105114184Sgabeblack@google.com    n_popResponseQueue;
105214184Sgabeblack@google.com  }
105314184Sgabeblack@google.com
105414184Sgabeblack@google.com  transition(NP, Writeback_All_Tokens, M) {
105514184Sgabeblack@google.com    vv_allocateL2CacheBlock;
105614184Sgabeblack@google.com    u_writeDataToCache;
105714184Sgabeblack@google.com    q_updateTokensFromResponse;
105814184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
105914184Sgabeblack@google.com    n_popResponseQueue;
106014184Sgabeblack@google.com  }
106114184Sgabeblack@google.com
106214184Sgabeblack@google.com  transition(NP, Writeback_Owned, O) {
106314184Sgabeblack@google.com    vv_allocateL2CacheBlock;
106414184Sgabeblack@google.com    u_writeDataToCache;
106514184Sgabeblack@google.com    q_updateTokensFromResponse;
106614184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
106714184Sgabeblack@google.com    n_popResponseQueue;
106814184Sgabeblack@google.com  }
106914184Sgabeblack@google.com
107014184Sgabeblack@google.com
107114184Sgabeblack@google.com  transition(NP,
107214184Sgabeblack@google.com             {Persistent_GETX, Persistent_GETS, Persistent_GETS_Last_Token},
107314184Sgabeblack@google.com             I_L) {
107414184Sgabeblack@google.com    l_popPersistentQueue;
107514184Sgabeblack@google.com  }
107614184Sgabeblack@google.com
107714184Sgabeblack@google.com  // Transitions from Idle
107814184Sgabeblack@google.com
107914184Sgabeblack@google.com  transition(I, {L1_GETS, L1_GETS_Last_Token}) {
108014184Sgabeblack@google.com    a_broadcastLocalRequest;
108114184Sgabeblack@google.com    tt_sendLocalAckWithCollectedTokens;  // send any tokens we have collected
108214184Sgabeblack@google.com    r_markNewSharer;
108314184Sgabeblack@google.com    uu_profileMiss;
108414184Sgabeblack@google.com    o_popL1RequestQueue;
108514184Sgabeblack@google.com  }
108614184Sgabeblack@google.com
108714184Sgabeblack@google.com  transition(I, L1_GETX) {
108814184Sgabeblack@google.com    a_broadcastLocalRequest;
108914184Sgabeblack@google.com    tt_sendLocalAckWithCollectedTokens; // send any tokens we have collected
109014184Sgabeblack@google.com    r_markNewSharer;
109114184Sgabeblack@google.com    uu_profileMiss;
109214184Sgabeblack@google.com    o_popL1RequestQueue;
109314184Sgabeblack@google.com  }
109414184Sgabeblack@google.com
109514184Sgabeblack@google.com  transition(I, L2_Replacement) {
109614184Sgabeblack@google.com    c_cleanReplacement; // Only needed in some cases
109714184Sgabeblack@google.com    rr_deallocateL2CacheBlock;
109814184Sgabeblack@google.com  }
109914184Sgabeblack@google.com
110014184Sgabeblack@google.com  transition(I, {Transient_GETX, Transient_GETS, Transient_GETS_Last_Token}) {
110114184Sgabeblack@google.com    r_clearExclusive;
110214184Sgabeblack@google.com    t_sendAckWithCollectedTokens;
110314184Sgabeblack@google.com    j_forwardTransientRequestToLocalSharers;
110414184Sgabeblack@google.com    m_popRequestQueue;
110514184Sgabeblack@google.com  }
110614184Sgabeblack@google.com
110714184Sgabeblack@google.com  transition(I,
110814184Sgabeblack@google.com             {Persistent_GETX, Persistent_GETS, Persistent_GETS_Last_Token},
110914184Sgabeblack@google.com             I_L) {
111014184Sgabeblack@google.com    e_sendAckWithCollectedTokens;
111114184Sgabeblack@google.com    l_popPersistentQueue;
111214184Sgabeblack@google.com  }
111314184Sgabeblack@google.com
111414184Sgabeblack@google.com
111514184Sgabeblack@google.com  transition(I, Ack) {
111614184Sgabeblack@google.com    q_updateTokensFromResponse;
111714184Sgabeblack@google.com    n_popResponseQueue;
111814184Sgabeblack@google.com  }
111914184Sgabeblack@google.com
112014184Sgabeblack@google.com  transition(I, Data_Shared, S) {
112114184Sgabeblack@google.com    u_writeDataToCache;
112214184Sgabeblack@google.com    q_updateTokensFromResponse;
112314184Sgabeblack@google.com    n_popResponseQueue;
112414184Sgabeblack@google.com  }
112514184Sgabeblack@google.com
112614184Sgabeblack@google.com  transition(I, Writeback_Shared_Data, S) {
112714184Sgabeblack@google.com    u_writeDataToCache;
112814184Sgabeblack@google.com    q_updateTokensFromResponse;
112914184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
113014184Sgabeblack@google.com    n_popResponseQueue;
113114184Sgabeblack@google.com  }
113214184Sgabeblack@google.com
113314184Sgabeblack@google.com  transition(I, Writeback_Tokens) {
113414184Sgabeblack@google.com    q_updateTokensFromResponse;
113514184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
113614184Sgabeblack@google.com    n_popResponseQueue;
113714184Sgabeblack@google.com  }
113814184Sgabeblack@google.com
113914184Sgabeblack@google.com  transition(I, Data_Owner, O) {
114014184Sgabeblack@google.com    u_writeDataToCache;
114114184Sgabeblack@google.com    q_updateTokensFromResponse;
114214184Sgabeblack@google.com    n_popResponseQueue;
114314184Sgabeblack@google.com  }
114414184Sgabeblack@google.com
114514184Sgabeblack@google.com  transition(I, Writeback_Owned, O) {
114614184Sgabeblack@google.com    u_writeDataToCache;
114714184Sgabeblack@google.com    q_updateTokensFromResponse;
114814184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
114914184Sgabeblack@google.com    n_popResponseQueue;
115014184Sgabeblack@google.com  }
115114184Sgabeblack@google.com
115214184Sgabeblack@google.com  transition(I, Data_All_Tokens, M) {
115314184Sgabeblack@google.com    u_writeDataToCache;
115414184Sgabeblack@google.com    q_updateTokensFromResponse;
115514184Sgabeblack@google.com    n_popResponseQueue;
115614184Sgabeblack@google.com  }
115714184Sgabeblack@google.com
115814184Sgabeblack@google.com
115914184Sgabeblack@google.com  transition(I, Writeback_All_Tokens, M) {
116014184Sgabeblack@google.com    u_writeDataToCache;
116114184Sgabeblack@google.com    q_updateTokensFromResponse;
116214184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
116314184Sgabeblack@google.com    n_popResponseQueue;
116414184Sgabeblack@google.com  }
116514184Sgabeblack@google.com
116614184Sgabeblack@google.com  // Transitions from Shared
116714184Sgabeblack@google.com
116814184Sgabeblack@google.com  transition(S, L2_Replacement, I) {
116914184Sgabeblack@google.com    c_cleanReplacement;
117014184Sgabeblack@google.com    rr_deallocateL2CacheBlock;
117114184Sgabeblack@google.com  }
117214184Sgabeblack@google.com
117314184Sgabeblack@google.com  transition(S, Transient_GETX, I) {
117414184Sgabeblack@google.com    r_clearExclusive;
117514184Sgabeblack@google.com    t_sendAckWithCollectedTokens;
117614184Sgabeblack@google.com    j_forwardTransientRequestToLocalSharers;
117714184Sgabeblack@google.com    m_popRequestQueue;
117814184Sgabeblack@google.com  }
117914184Sgabeblack@google.com
118014184Sgabeblack@google.com  transition(S, {Transient_GETS, Transient_GETS_Last_Token}) {
118114184Sgabeblack@google.com    j_forwardTransientRequestToLocalSharers;
118214184Sgabeblack@google.com    r_clearExclusive;
118314184Sgabeblack@google.com    m_popRequestQueue;
118414184Sgabeblack@google.com  }
118514184Sgabeblack@google.com
118614184Sgabeblack@google.com  transition(S, Persistent_GETX, I_L) {
118714184Sgabeblack@google.com    e_sendAckWithCollectedTokens;
118814184Sgabeblack@google.com    l_popPersistentQueue;
118914184Sgabeblack@google.com  }
119014184Sgabeblack@google.com
119114184Sgabeblack@google.com
119214184Sgabeblack@google.com  transition(S, {Persistent_GETS, Persistent_GETS_Last_Token}, S_L) {
119314184Sgabeblack@google.com    f_sendAckWithAllButOneTokens;
119414184Sgabeblack@google.com    l_popPersistentQueue;
119514184Sgabeblack@google.com  }
119614184Sgabeblack@google.com
119714184Sgabeblack@google.com
119814184Sgabeblack@google.com  transition(S, Ack) {
119914184Sgabeblack@google.com    q_updateTokensFromResponse;
120014184Sgabeblack@google.com    n_popResponseQueue;
120114184Sgabeblack@google.com  }
120214184Sgabeblack@google.com
120314184Sgabeblack@google.com  transition(S, Data_Shared) {
120414184Sgabeblack@google.com    w_assertIncomingDataAndCacheDataMatch;
120514184Sgabeblack@google.com    q_updateTokensFromResponse;
120614184Sgabeblack@google.com    n_popResponseQueue;
120714184Sgabeblack@google.com  }
120814184Sgabeblack@google.com
120914184Sgabeblack@google.com  transition(S, Writeback_Tokens) {
121014184Sgabeblack@google.com    q_updateTokensFromResponse;
121114184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
121214184Sgabeblack@google.com    n_popResponseQueue;
121314184Sgabeblack@google.com  }
121414184Sgabeblack@google.com
121514184Sgabeblack@google.com  transition(S, Writeback_Shared_Data) {
121614184Sgabeblack@google.com    w_assertIncomingDataAndCacheDataMatch;
121714184Sgabeblack@google.com    q_updateTokensFromResponse;
121814184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
121914184Sgabeblack@google.com    n_popResponseQueue;
122014184Sgabeblack@google.com  }
122114184Sgabeblack@google.com
122214184Sgabeblack@google.com
122314184Sgabeblack@google.com  transition(S, Data_Owner, O) {
122414184Sgabeblack@google.com    w_assertIncomingDataAndCacheDataMatch;
122514184Sgabeblack@google.com    q_updateTokensFromResponse;
122614184Sgabeblack@google.com    n_popResponseQueue;
122714184Sgabeblack@google.com  }
122814184Sgabeblack@google.com
122914184Sgabeblack@google.com  transition(S, Writeback_Owned, O) {
123014184Sgabeblack@google.com    w_assertIncomingDataAndCacheDataMatch;
123114184Sgabeblack@google.com    q_updateTokensFromResponse;
123214184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
123314184Sgabeblack@google.com    n_popResponseQueue;
123414184Sgabeblack@google.com  }
123514184Sgabeblack@google.com
123614184Sgabeblack@google.com  transition(S, Data_All_Tokens, M) {
123714184Sgabeblack@google.com    w_assertIncomingDataAndCacheDataMatch;
123814184Sgabeblack@google.com    q_updateTokensFromResponse;
123914184Sgabeblack@google.com    n_popResponseQueue;
124014184Sgabeblack@google.com  }
124114184Sgabeblack@google.com
124214184Sgabeblack@google.com  transition(S, Writeback_All_Tokens,  M) {
124314184Sgabeblack@google.com    w_assertIncomingDataAndCacheDataMatch;
124414184Sgabeblack@google.com    q_updateTokensFromResponse;
124514184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
124614184Sgabeblack@google.com    n_popResponseQueue;
124714184Sgabeblack@google.com  }
124814184Sgabeblack@google.com
124914184Sgabeblack@google.com  transition(S, L1_GETX, I) {
125014184Sgabeblack@google.com    a_broadcastLocalRequest;
125114184Sgabeblack@google.com    tt_sendLocalAckWithCollectedTokens;
125214184Sgabeblack@google.com    r_markNewSharer;
125314184Sgabeblack@google.com    r_setMRU;
125414184Sgabeblack@google.com    uu_profileMiss;
125514184Sgabeblack@google.com    o_popL1RequestQueue;
125614184Sgabeblack@google.com  }
125714184Sgabeblack@google.com
125814184Sgabeblack@google.com
125914184Sgabeblack@google.com  transition(S, L1_GETS) {
126014184Sgabeblack@google.com    k_dataFromL2CacheToL1Requestor;
126114184Sgabeblack@google.com    r_markNewSharer;
126214184Sgabeblack@google.com    r_setMRU;
126314184Sgabeblack@google.com    uu_profileHit;
126414184Sgabeblack@google.com    o_popL1RequestQueue;
126514184Sgabeblack@google.com  }
126614184Sgabeblack@google.com
126714184Sgabeblack@google.com  transition(S, L1_GETS_Last_Token, I) {
126814184Sgabeblack@google.com
126914184Sgabeblack@google.com    k_dataFromL2CacheToL1Requestor;
127014184Sgabeblack@google.com    r_markNewSharer;
127114184Sgabeblack@google.com    r_setMRU;
127214184Sgabeblack@google.com    uu_profileHit;
127314184Sgabeblack@google.com    o_popL1RequestQueue;
127414184Sgabeblack@google.com  }
127514184Sgabeblack@google.com
127614184Sgabeblack@google.com  // Transitions from Owned
127714184Sgabeblack@google.com
127814184Sgabeblack@google.com  transition(O, L2_Replacement, I) {
127914184Sgabeblack@google.com    cc_dirtyReplacement;
128014184Sgabeblack@google.com    rr_deallocateL2CacheBlock;
128114184Sgabeblack@google.com  }
128214184Sgabeblack@google.com
128314184Sgabeblack@google.com  transition(O, Transient_GETX, I) {
128414184Sgabeblack@google.com    r_clearExclusive;
128514184Sgabeblack@google.com    dd_sendDataWithAllTokens;
128614184Sgabeblack@google.com    j_forwardTransientRequestToLocalSharers;
128714184Sgabeblack@google.com    m_popRequestQueue;
128814184Sgabeblack@google.com  }
128914184Sgabeblack@google.com
129014184Sgabeblack@google.com  transition(O, Persistent_GETX, I_L) {
129114184Sgabeblack@google.com    ee_sendDataWithAllTokens;
129214184Sgabeblack@google.com    l_popPersistentQueue;
129314184Sgabeblack@google.com  }
129414184Sgabeblack@google.com
129514184Sgabeblack@google.com  transition(O, Persistent_GETS, S_L) {
129614184Sgabeblack@google.com    ff_sendDataWithAllButOneTokens;
129714184Sgabeblack@google.com    l_popPersistentQueue;
129814184Sgabeblack@google.com  }
129914184Sgabeblack@google.com
130014184Sgabeblack@google.com  transition(O, Persistent_GETS_Last_Token, I_L) {
130114184Sgabeblack@google.com    fa_sendDataWithAllTokens;
130214184Sgabeblack@google.com    l_popPersistentQueue;
130314184Sgabeblack@google.com  }
130414184Sgabeblack@google.com
130514184Sgabeblack@google.com  transition(O, Transient_GETS) {
130614184Sgabeblack@google.com    // send multiple tokens
130714184Sgabeblack@google.com    r_clearExclusive;
130814184Sgabeblack@google.com    d_sendDataWithTokens;
130914184Sgabeblack@google.com    m_popRequestQueue;
131014184Sgabeblack@google.com  }
131114184Sgabeblack@google.com
131214184Sgabeblack@google.com  transition(O, Transient_GETS_Last_Token) {
131314184Sgabeblack@google.com    // WAIT FOR IT TO GO PERSISTENT
131414184Sgabeblack@google.com    r_clearExclusive;
131514184Sgabeblack@google.com    m_popRequestQueue;
131614184Sgabeblack@google.com  }
131714184Sgabeblack@google.com
131814184Sgabeblack@google.com  transition(O, Ack) {
131914184Sgabeblack@google.com    q_updateTokensFromResponse;
132014184Sgabeblack@google.com    n_popResponseQueue;
132114184Sgabeblack@google.com  }
132214184Sgabeblack@google.com
132314184Sgabeblack@google.com  transition(O, Ack_All_Tokens, M) {
132414184Sgabeblack@google.com    q_updateTokensFromResponse;
132514184Sgabeblack@google.com    n_popResponseQueue;
132614184Sgabeblack@google.com  }
132714184Sgabeblack@google.com
132814184Sgabeblack@google.com  transition(O, Data_Shared) {
132914184Sgabeblack@google.com    w_assertIncomingDataAndCacheDataMatch;
133014184Sgabeblack@google.com    q_updateTokensFromResponse;
133114184Sgabeblack@google.com    n_popResponseQueue;
133214184Sgabeblack@google.com  }
133314184Sgabeblack@google.com
133414184Sgabeblack@google.com
133514184Sgabeblack@google.com  transition(O, {Writeback_Tokens, Writeback_Shared_Data}) {
133614184Sgabeblack@google.com    w_assertIncomingDataAndCacheDataMatch;
133714184Sgabeblack@google.com    q_updateTokensFromResponse;
133814184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
133914184Sgabeblack@google.com    n_popResponseQueue;
134014184Sgabeblack@google.com  }
134114184Sgabeblack@google.com
134214184Sgabeblack@google.com  transition(O, Data_All_Tokens, M) {
134314184Sgabeblack@google.com    w_assertIncomingDataAndCacheDataMatch;
134414184Sgabeblack@google.com    q_updateTokensFromResponse;
134514184Sgabeblack@google.com    n_popResponseQueue;
134614184Sgabeblack@google.com  }
134714184Sgabeblack@google.com
134814184Sgabeblack@google.com  transition(O, Writeback_All_Tokens, M) {
134914184Sgabeblack@google.com    w_assertIncomingDataAndCacheDataMatch;
135014184Sgabeblack@google.com    q_updateTokensFromResponse;
135114184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
135214184Sgabeblack@google.com    n_popResponseQueue;
135314184Sgabeblack@google.com  }
135414184Sgabeblack@google.com
135514184Sgabeblack@google.com  transition(O, L1_GETS) {
135614184Sgabeblack@google.com    k_dataFromL2CacheToL1Requestor;
135714184Sgabeblack@google.com    r_markNewSharer;
135814184Sgabeblack@google.com    r_setMRU;
135914184Sgabeblack@google.com    uu_profileHit;
136014184Sgabeblack@google.com    o_popL1RequestQueue;
136114184Sgabeblack@google.com  }
136214184Sgabeblack@google.com
136314184Sgabeblack@google.com  transition(O, L1_GETS_Last_Token, I) {
136414184Sgabeblack@google.com    k_dataOwnerFromL2CacheToL1Requestor;
136514184Sgabeblack@google.com    r_markNewSharer;
136614184Sgabeblack@google.com    r_setMRU;
136714184Sgabeblack@google.com    uu_profileHit;
136814184Sgabeblack@google.com    o_popL1RequestQueue;
136914184Sgabeblack@google.com  }
137014184Sgabeblack@google.com
137114184Sgabeblack@google.com  transition(O, L1_GETX, I) {
137214184Sgabeblack@google.com    a_broadcastLocalRequest;
137314184Sgabeblack@google.com    k_dataAndAllTokensFromL2CacheToL1Requestor;
137414184Sgabeblack@google.com    r_markNewSharer;
137514184Sgabeblack@google.com    r_setMRU;
137614184Sgabeblack@google.com    uu_profileMiss;
137714184Sgabeblack@google.com    o_popL1RequestQueue;
137814184Sgabeblack@google.com  }
137914184Sgabeblack@google.com
138014184Sgabeblack@google.com  // Transitions from M
138114184Sgabeblack@google.com
138214184Sgabeblack@google.com  transition(M, L2_Replacement, I) {
138314184Sgabeblack@google.com    cc_dirtyReplacement;
138414184Sgabeblack@google.com    rr_deallocateL2CacheBlock;
138514184Sgabeblack@google.com  }
138614184Sgabeblack@google.com
138714184Sgabeblack@google.com  // MRM_DEBUG:  Give up all tokens even for GETS? ???
138814184Sgabeblack@google.com  transition(M, {Transient_GETX, Transient_GETS}, I) {
138914184Sgabeblack@google.com    r_clearExclusive;
139014184Sgabeblack@google.com    dd_sendDataWithAllTokens;
139114184Sgabeblack@google.com    m_popRequestQueue;
139214184Sgabeblack@google.com  }
139314184Sgabeblack@google.com
139414184Sgabeblack@google.com  transition(M, {Persistent_GETS, Persistent_GETX}, I_L) {
139514184Sgabeblack@google.com    ee_sendDataWithAllTokens;
139614184Sgabeblack@google.com    l_popPersistentQueue;
139714184Sgabeblack@google.com  }
139814184Sgabeblack@google.com
139914184Sgabeblack@google.com
140014184Sgabeblack@google.com  transition(M, L1_GETS, O) {
140114184Sgabeblack@google.com    k_dataFromL2CacheToL1Requestor;
140214184Sgabeblack@google.com    r_markNewSharer;
140314184Sgabeblack@google.com    r_setMRU;
140414184Sgabeblack@google.com    uu_profileHit;
140514184Sgabeblack@google.com    o_popL1RequestQueue;
140614184Sgabeblack@google.com  }
140714184Sgabeblack@google.com
140814184Sgabeblack@google.com  transition(M, L1_GETX, I) {
140914184Sgabeblack@google.com    k_dataAndAllTokensFromL2CacheToL1Requestor;
141014184Sgabeblack@google.com    r_markNewSharer;
141114184Sgabeblack@google.com    r_setMRU;
141214184Sgabeblack@google.com    uu_profileHit;
141314184Sgabeblack@google.com    o_popL1RequestQueue;
141414184Sgabeblack@google.com  }
141514184Sgabeblack@google.com
141614184Sgabeblack@google.com
141714184Sgabeblack@google.com  //Transitions from locked states
141814184Sgabeblack@google.com
141914184Sgabeblack@google.com  transition({I_L, S_L}, Ack) {
142014184Sgabeblack@google.com    gg_bounceResponseToStarver;
142114184Sgabeblack@google.com    n_popResponseQueue;
142214184Sgabeblack@google.com  }
142314184Sgabeblack@google.com
142414184Sgabeblack@google.com  transition({I_L, S_L}, {Data_Shared, Data_Owner, Data_All_Tokens}) {
142514184Sgabeblack@google.com    gg_bounceResponseToStarver;
142614184Sgabeblack@google.com    n_popResponseQueue;
142714184Sgabeblack@google.com  }
142814184Sgabeblack@google.com
142914184Sgabeblack@google.com  transition({I_L, S_L}, {Writeback_Tokens, Writeback_Shared_Data}) {
143014184Sgabeblack@google.com    gg_bounceWBSharedToStarver;
143114184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
143214184Sgabeblack@google.com    n_popResponseQueue;
143314184Sgabeblack@google.com  }
143414184Sgabeblack@google.com
143514184Sgabeblack@google.com  transition({I_L, S_L}, {Writeback_Owned, Writeback_All_Tokens}) {
143614184Sgabeblack@google.com    gg_bounceWBOwnedToStarver;
143714184Sgabeblack@google.com    h_updateFilterFromL1HintOrWB;
143814184Sgabeblack@google.com    n_popResponseQueue;
143914184Sgabeblack@google.com  }
144014184Sgabeblack@google.com
144114184Sgabeblack@google.com  transition(S_L, L2_Replacement, I) {
144214184Sgabeblack@google.com    c_cleanReplacement;
144314184Sgabeblack@google.com    rr_deallocateL2CacheBlock;
144414184Sgabeblack@google.com  }
144514184Sgabeblack@google.com
144614184Sgabeblack@google.com  transition(I_L, L2_Replacement, I) {
144714184Sgabeblack@google.com    rr_deallocateL2CacheBlock;
144814184Sgabeblack@google.com  }
144914184Sgabeblack@google.com
145014184Sgabeblack@google.com  transition(I_L, Own_Lock_or_Unlock, I) {
145114184Sgabeblack@google.com    l_popPersistentQueue;
145214184Sgabeblack@google.com  }
145314184Sgabeblack@google.com
145414184Sgabeblack@google.com  transition(S_L, Own_Lock_or_Unlock, S) {
145514184Sgabeblack@google.com    l_popPersistentQueue;
145614184Sgabeblack@google.com  }
145714184Sgabeblack@google.com
145814184Sgabeblack@google.com  transition({I_L, S_L}, {Transient_GETS_Last_Token, Transient_GETS, Transient_GETX}) {
145914184Sgabeblack@google.com    r_clearExclusive;
146014184Sgabeblack@google.com    m_popRequestQueue;
146114184Sgabeblack@google.com  }
146214184Sgabeblack@google.com
146314184Sgabeblack@google.com  transition(I_L, {L1_GETX, L1_GETS}) {
146414184Sgabeblack@google.com    a_broadcastLocalRequest;
146514184Sgabeblack@google.com    r_markNewSharer;
146614184Sgabeblack@google.com    uu_profileMiss;
146714184Sgabeblack@google.com    o_popL1RequestQueue;
146814184Sgabeblack@google.com  }
146914184Sgabeblack@google.com
147014184Sgabeblack@google.com  transition(S_L, L1_GETX, I_L) {
147114184Sgabeblack@google.com    a_broadcastLocalRequest;
147214184Sgabeblack@google.com    tt_sendLocalAckWithCollectedTokens;
147314184Sgabeblack@google.com    r_markNewSharer;
147414184Sgabeblack@google.com    r_setMRU;
147514184Sgabeblack@google.com    uu_profileMiss;
147614184Sgabeblack@google.com    o_popL1RequestQueue;
147714184Sgabeblack@google.com  }
147814184Sgabeblack@google.com
147914184Sgabeblack@google.com  transition(S_L, L1_GETS) {
148014184Sgabeblack@google.com    k_dataFromL2CacheToL1Requestor;
148114184Sgabeblack@google.com    r_markNewSharer;
148214184Sgabeblack@google.com    r_setMRU;
148314184Sgabeblack@google.com    uu_profileHit;
148414184Sgabeblack@google.com    o_popL1RequestQueue;
148514184Sgabeblack@google.com  }
148614184Sgabeblack@google.com
148714184Sgabeblack@google.com  transition(S_L, L1_GETS_Last_Token, I_L) {
148814184Sgabeblack@google.com    k_dataFromL2CacheToL1Requestor;
148914184Sgabeblack@google.com    r_markNewSharer;
149014184Sgabeblack@google.com    r_setMRU;
149114184Sgabeblack@google.com    uu_profileHit;
149214184Sgabeblack@google.com    o_popL1RequestQueue;
149314184Sgabeblack@google.com  }
149414184Sgabeblack@google.com
149514184Sgabeblack@google.com  transition(S_L, Persistent_GETX, I_L) {
149614184Sgabeblack@google.com    e_sendAckWithCollectedTokens;
149714184Sgabeblack@google.com    l_popPersistentQueue;
149814184Sgabeblack@google.com  }
149914184Sgabeblack@google.com
150014184Sgabeblack@google.com  transition(S_L, {Persistent_GETS, Persistent_GETS_Last_Token}) {
150114184Sgabeblack@google.com    l_popPersistentQueue;
150214184Sgabeblack@google.com  }
150314184Sgabeblack@google.com
150414184Sgabeblack@google.com  transition(I_L, {Persistent_GETX, Persistent_GETS}) {
150514184Sgabeblack@google.com    l_popPersistentQueue;
150614184Sgabeblack@google.com  }
150714184Sgabeblack@google.com}
1508