MESI_Three_Level-L1cache.sm revision 14300
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:L1Cache, "MESI Directory L1 Cache CMP") 3014184Sgabeblack@google.com : CacheMemory * cache; 3114184Sgabeblack@google.com int l2_select_num_bits; 3214184Sgabeblack@google.com Cycles l1_request_latency := 2; 3314184Sgabeblack@google.com Cycles l1_response_latency := 2; 3414184Sgabeblack@google.com Cycles to_l2_latency := 1; 3514184Sgabeblack@google.com 3614184Sgabeblack@google.com // Message Buffers between the L1 and the L0 Cache 3714184Sgabeblack@google.com // From the L1 cache to the L0 cache 3814184Sgabeblack@google.com MessageBuffer * bufferToL0, network="To"; 3914184Sgabeblack@google.com 4014184Sgabeblack@google.com // From the L0 cache to the L1 cache 4114184Sgabeblack@google.com MessageBuffer * bufferFromL0, network="From"; 4214184Sgabeblack@google.com 4314184Sgabeblack@google.com // Message queue from this L1 cache TO the network / L2 4414184Sgabeblack@google.com MessageBuffer * requestToL2, network="To", virtual_network="0", 4514184Sgabeblack@google.com vnet_type="request"; 4614184Sgabeblack@google.com 4714184Sgabeblack@google.com MessageBuffer * responseToL2, network="To", virtual_network="1", 4814184Sgabeblack@google.com vnet_type="response"; 4914184Sgabeblack@google.com MessageBuffer * unblockToL2, network="To", virtual_network="2", 5014184Sgabeblack@google.com vnet_type="unblock"; 5114184Sgabeblack@google.com 5214184Sgabeblack@google.com // To this L1 cache FROM the network / L2 5314184Sgabeblack@google.com MessageBuffer * requestFromL2, network="From", virtual_network="2", 5414184Sgabeblack@google.com vnet_type="request"; 5514184Sgabeblack@google.com MessageBuffer * responseFromL2, network="From", virtual_network="1", 5614184Sgabeblack@google.com vnet_type="response"; 5714184Sgabeblack@google.com 5814184Sgabeblack@google.com{ 5914184Sgabeblack@google.com // STATES 6014184Sgabeblack@google.com state_declaration(State, desc="Cache states", default="L1Cache_State_I") { 6114184Sgabeblack@google.com // Base states 6214184Sgabeblack@google.com I, AccessPermission:Invalid, desc="a L1 cache entry Idle"; 6314184Sgabeblack@google.com S, AccessPermission:Read_Only, desc="a L1 cache entry Shared"; 6414184Sgabeblack@google.com SS, AccessPermission:Read_Only, desc="a L1 cache entry Shared"; 6514184Sgabeblack@google.com E, AccessPermission:Read_Only, desc="a L1 cache entry Exclusive"; 6614184Sgabeblack@google.com EE, AccessPermission:Read_Write, desc="a L1 cache entry Exclusive"; 6714184Sgabeblack@google.com M, AccessPermission:Maybe_Stale, desc="a L1 cache entry Modified", format="!b"; 6814184Sgabeblack@google.com MM, AccessPermission:Read_Write, desc="a L1 cache entry Modified", format="!b"; 6914184Sgabeblack@google.com 7014184Sgabeblack@google.com // Transient States 7114184Sgabeblack@google.com IS, AccessPermission:Busy, desc="L1 idle, issued GETS, have not seen response yet"; 7214184Sgabeblack@google.com IM, AccessPermission:Busy, desc="L1 idle, issued GETX, have not seen response yet"; 7314184Sgabeblack@google.com SM, AccessPermission:Read_Only, desc="L1 idle, issued GETX, have not seen response yet"; 7414184Sgabeblack@google.com IS_I, AccessPermission:Busy, desc="L1 idle, issued GETS, saw Inv before data because directory doesn't block on GETS hit"; 7514184Sgabeblack@google.com M_I, AccessPermission:Busy, desc="L1 replacing, waiting for ACK"; 7614184Sgabeblack@google.com SINK_WB_ACK, AccessPermission:Busy, desc="This is to sink WB_Acks from L2"; 7714184Sgabeblack@google.com 7814184Sgabeblack@google.com // For all of the following states, invalidate 7914184Sgabeblack@google.com // message has been sent to L0 cache. The response 8014184Sgabeblack@google.com // from the L0 cache has not been seen yet. 8114184Sgabeblack@google.com S_IL0, AccessPermission:Busy; 8214184Sgabeblack@google.com E_IL0, AccessPermission:Busy; 8314184Sgabeblack@google.com M_IL0, AccessPermission:Busy; 8414184Sgabeblack@google.com MM_IL0, AccessPermission:Read_Write; 8514184Sgabeblack@google.com SM_IL0, AccessPermission:Busy; 8614184Sgabeblack@google.com } 8714184Sgabeblack@google.com 8814184Sgabeblack@google.com // EVENTS 8914184Sgabeblack@google.com enumeration(Event, desc="Cache events") { 9014184Sgabeblack@google.com // Requests from the L0 cache 9114184Sgabeblack@google.com Load, desc="Load request"; 9214184Sgabeblack@google.com Store, desc="Store request"; 9314184Sgabeblack@google.com WriteBack, desc="Writeback request"; 9414184Sgabeblack@google.com 9514184Sgabeblack@google.com // Responses from the L0 Cache 9614184Sgabeblack@google.com // L0 cache received the invalidation message 9714184Sgabeblack@google.com // and has sent the data. 9814184Sgabeblack@google.com L0_DataAck; 9914184Sgabeblack@google.com 10014184Sgabeblack@google.com Inv, desc="Invalidate request from L2 bank"; 10114184Sgabeblack@google.com 10214184Sgabeblack@google.com // internal generated request 10314184Sgabeblack@google.com // Invalidate the line in L0 due to own requirements 10414184Sgabeblack@google.com L0_Invalidate_Own; 10514184Sgabeblack@google.com // Invalidate the line in L0 due to some other cache's requirements 10614184Sgabeblack@google.com L0_Invalidate_Else; 10714184Sgabeblack@google.com // Invalidate the line in the cache due to some one else / space needs. 10814184Sgabeblack@google.com L1_Replacement; 10914184Sgabeblack@google.com 11014184Sgabeblack@google.com // other requests 11114184Sgabeblack@google.com Fwd_GETX, desc="GETX from other processor"; 11214184Sgabeblack@google.com Fwd_GETS, desc="GETS from other processor"; 11314184Sgabeblack@google.com 11414184Sgabeblack@google.com Data, desc="Data for processor"; 11514184Sgabeblack@google.com Data_Exclusive, desc="Data for processor"; 11614184Sgabeblack@google.com DataS_fromL1, desc="data for GETS request, need to unblock directory"; 11714184Sgabeblack@google.com Data_all_Acks, desc="Data for processor, all acks"; 11814184Sgabeblack@google.com 11914184Sgabeblack@google.com L0_Ack, desc="Ack for processor"; 12014184Sgabeblack@google.com Ack, desc="Ack for processor"; 12114184Sgabeblack@google.com Ack_all, desc="Last ack for processor"; 12214184Sgabeblack@google.com 12314184Sgabeblack@google.com WB_Ack, desc="Ack for replacement"; 12414184Sgabeblack@google.com } 12514184Sgabeblack@google.com 12614184Sgabeblack@google.com // TYPES 12714184Sgabeblack@google.com 12814184Sgabeblack@google.com // CacheEntry 12914184Sgabeblack@google.com structure(Entry, desc="...", interface="AbstractCacheEntry" ) { 13014184Sgabeblack@google.com State CacheState, desc="cache state"; 13114184Sgabeblack@google.com DataBlock DataBlk, desc="data for the block"; 13214184Sgabeblack@google.com bool Dirty, default="false", desc="data is dirty"; 13314184Sgabeblack@google.com } 13414184Sgabeblack@google.com 13514184Sgabeblack@google.com // TBE fields 13614184Sgabeblack@google.com structure(TBE, desc="...") { 13714184Sgabeblack@google.com Addr addr, desc="Physical address for this TBE"; 13814184Sgabeblack@google.com State TBEState, desc="Transient state"; 13914184Sgabeblack@google.com DataBlock DataBlk, desc="Buffer for the data block"; 14014184Sgabeblack@google.com bool Dirty, default="false", desc="data is dirty"; 14114184Sgabeblack@google.com int pendingAcks, default="0", desc="number of pending acks"; 14214184Sgabeblack@google.com } 14314184Sgabeblack@google.com 14414184Sgabeblack@google.com structure(TBETable, external="yes") { 14514184Sgabeblack@google.com TBE lookup(Addr); 14614184Sgabeblack@google.com void allocate(Addr); 14714184Sgabeblack@google.com void deallocate(Addr); 14814184Sgabeblack@google.com bool isPresent(Addr); 14914184Sgabeblack@google.com } 15014184Sgabeblack@google.com 15114184Sgabeblack@google.com TBETable TBEs, template="<L1Cache_TBE>", constructor="m_number_of_TBEs"; 15214184Sgabeblack@google.com 15314184Sgabeblack@google.com int l2_select_low_bit, default="RubySystem::getBlockSizeBits()"; 15414184Sgabeblack@google.com 15514184Sgabeblack@google.com Tick clockEdge(); 15614184Sgabeblack@google.com Cycles ticksToCycles(Tick t); 15714184Sgabeblack@google.com void set_cache_entry(AbstractCacheEntry a); 15814184Sgabeblack@google.com void unset_cache_entry(); 15914184Sgabeblack@google.com void set_tbe(TBE a); 16014184Sgabeblack@google.com void unset_tbe(); 16114184Sgabeblack@google.com void wakeUpBuffers(Addr a); 16214184Sgabeblack@google.com void wakeUpAllBuffers(Addr a); 16314184Sgabeblack@google.com void profileMsgDelay(int virtualNetworkType, Cycles c); 16414184Sgabeblack@google.com 16514184Sgabeblack@google.com // inclusive cache returns L1 entries only 16614184Sgabeblack@google.com Entry getCacheEntry(Addr addr), return_by_pointer="yes" { 16714184Sgabeblack@google.com Entry cache_entry := static_cast(Entry, "pointer", cache[addr]); 16814184Sgabeblack@google.com return cache_entry; 16914184Sgabeblack@google.com } 17014184Sgabeblack@google.com 17114184Sgabeblack@google.com State getState(TBE tbe, Entry cache_entry, Addr addr) { 17214184Sgabeblack@google.com if(is_valid(tbe)) { 17314184Sgabeblack@google.com return tbe.TBEState; 17414184Sgabeblack@google.com } else if (is_valid(cache_entry)) { 17514184Sgabeblack@google.com return cache_entry.CacheState; 17614184Sgabeblack@google.com } 17714184Sgabeblack@google.com return State:I; 17814184Sgabeblack@google.com } 17914184Sgabeblack@google.com 18014184Sgabeblack@google.com void setState(TBE tbe, Entry cache_entry, Addr addr, State state) { 18114184Sgabeblack@google.com // MUST CHANGE 18214184Sgabeblack@google.com if(is_valid(tbe)) { 18314184Sgabeblack@google.com tbe.TBEState := state; 18414184Sgabeblack@google.com } 18514184Sgabeblack@google.com 18614184Sgabeblack@google.com if (is_valid(cache_entry)) { 18714184Sgabeblack@google.com cache_entry.CacheState := state; 18814184Sgabeblack@google.com } 18914184Sgabeblack@google.com } 19014184Sgabeblack@google.com 19114184Sgabeblack@google.com AccessPermission getAccessPermission(Addr addr) { 19214184Sgabeblack@google.com TBE tbe := TBEs[addr]; 19314184Sgabeblack@google.com if(is_valid(tbe)) { 19414184Sgabeblack@google.com DPRINTF(RubySlicc, "%s\n", L1Cache_State_to_permission(tbe.TBEState)); 19514184Sgabeblack@google.com return L1Cache_State_to_permission(tbe.TBEState); 19614184Sgabeblack@google.com } 19714184Sgabeblack@google.com 19814184Sgabeblack@google.com Entry cache_entry := getCacheEntry(addr); 19914184Sgabeblack@google.com if(is_valid(cache_entry)) { 20014184Sgabeblack@google.com DPRINTF(RubySlicc, "%s\n", L1Cache_State_to_permission(cache_entry.CacheState)); 20114184Sgabeblack@google.com return L1Cache_State_to_permission(cache_entry.CacheState); 20214184Sgabeblack@google.com } 20314184Sgabeblack@google.com 20414184Sgabeblack@google.com DPRINTF(RubySlicc, "%s\n", AccessPermission:NotPresent); 20514184Sgabeblack@google.com return AccessPermission:NotPresent; 20614184Sgabeblack@google.com } 20714184Sgabeblack@google.com 20814184Sgabeblack@google.com void functionalRead(Addr addr, Packet *pkt) { 20914184Sgabeblack@google.com TBE tbe := TBEs[addr]; 21014184Sgabeblack@google.com if(is_valid(tbe)) { 21114184Sgabeblack@google.com testAndRead(addr, tbe.DataBlk, pkt); 21214184Sgabeblack@google.com } else { 21314184Sgabeblack@google.com testAndRead(addr, getCacheEntry(addr).DataBlk, pkt); 21414184Sgabeblack@google.com } 21514184Sgabeblack@google.com } 21614184Sgabeblack@google.com 21714184Sgabeblack@google.com int functionalWrite(Addr addr, Packet *pkt) { 21814184Sgabeblack@google.com int num_functional_writes := 0; 21914184Sgabeblack@google.com 22014184Sgabeblack@google.com TBE tbe := TBEs[addr]; 22114184Sgabeblack@google.com if(is_valid(tbe)) { 22214184Sgabeblack@google.com num_functional_writes := num_functional_writes + 22314184Sgabeblack@google.com testAndWrite(addr, tbe.DataBlk, pkt); 22414184Sgabeblack@google.com return num_functional_writes; 22514184Sgabeblack@google.com } 22614184Sgabeblack@google.com 22714184Sgabeblack@google.com num_functional_writes := num_functional_writes + 22814184Sgabeblack@google.com testAndWrite(addr, getCacheEntry(addr).DataBlk, pkt); 22914184Sgabeblack@google.com return num_functional_writes; 23014184Sgabeblack@google.com } 23114184Sgabeblack@google.com 23214184Sgabeblack@google.com void setAccessPermission(Entry cache_entry, Addr addr, State state) { 23314184Sgabeblack@google.com if (is_valid(cache_entry)) { 23414184Sgabeblack@google.com cache_entry.changePermission(L1Cache_State_to_permission(state)); 23514184Sgabeblack@google.com } 23614184Sgabeblack@google.com } 23714184Sgabeblack@google.com 23814184Sgabeblack@google.com Event mandatory_request_type_to_event(CoherenceClass type) { 23914184Sgabeblack@google.com if (type == CoherenceClass:GETS) { 24014184Sgabeblack@google.com return Event:Load; 24114184Sgabeblack@google.com } else if ((type == CoherenceClass:GETX) || 24214184Sgabeblack@google.com (type == CoherenceClass:UPGRADE)) { 24314184Sgabeblack@google.com return Event:Store; 24414184Sgabeblack@google.com } else if (type == CoherenceClass:PUTX) { 24514184Sgabeblack@google.com return Event:WriteBack; 24614184Sgabeblack@google.com } else { 24714184Sgabeblack@google.com error("Invalid RequestType"); 24814184Sgabeblack@google.com } 24914184Sgabeblack@google.com } 25014184Sgabeblack@google.com 25114184Sgabeblack@google.com int getPendingAcks(TBE tbe) { 25214184Sgabeblack@google.com return tbe.pendingAcks; 25314184Sgabeblack@google.com } 25414184Sgabeblack@google.com 25514184Sgabeblack@google.com bool inL0Cache(State state) { 25614184Sgabeblack@google.com if (state == State:S || state == State:E || state == State:M || 25714184Sgabeblack@google.com state == State:S_IL0 || state == State:E_IL0 || 25814184Sgabeblack@google.com state == State:M_IL0 || state == State:SM_IL0) { 25914184Sgabeblack@google.com return true; 26014184Sgabeblack@google.com } 26114184Sgabeblack@google.com 26214184Sgabeblack@google.com return false; 26314184Sgabeblack@google.com } 26414184Sgabeblack@google.com 26514184Sgabeblack@google.com out_port(requestNetwork_out, RequestMsg, requestToL2); 26614184Sgabeblack@google.com out_port(responseNetwork_out, ResponseMsg, responseToL2); 26714184Sgabeblack@google.com out_port(unblockNetwork_out, ResponseMsg, unblockToL2); 26814184Sgabeblack@google.com out_port(bufferToL0_out, CoherenceMsg, bufferToL0); 26914184Sgabeblack@google.com 27014184Sgabeblack@google.com // Response From the L2 Cache to this L1 cache 27114184Sgabeblack@google.com in_port(responseNetwork_in, ResponseMsg, responseFromL2, rank = 3) { 27214184Sgabeblack@google.com if (responseNetwork_in.isReady(clockEdge())) { 27314184Sgabeblack@google.com peek(responseNetwork_in, ResponseMsg) { 27414184Sgabeblack@google.com assert(in_msg.Destination.isElement(machineID)); 27514184Sgabeblack@google.com 27614184Sgabeblack@google.com Entry cache_entry := getCacheEntry(in_msg.addr); 27714184Sgabeblack@google.com TBE tbe := TBEs[in_msg.addr]; 27814184Sgabeblack@google.com 27914184Sgabeblack@google.com if(in_msg.Type == CoherenceResponseType:DATA_EXCLUSIVE) { 28014184Sgabeblack@google.com trigger(Event:Data_Exclusive, in_msg.addr, cache_entry, tbe); 28114184Sgabeblack@google.com } else if(in_msg.Type == CoherenceResponseType:DATA) { 28214184Sgabeblack@google.com if ((getState(tbe, cache_entry, in_msg.addr) == State:IS || 28314184Sgabeblack@google.com getState(tbe, cache_entry, in_msg.addr) == State:IS_I) && 28414184Sgabeblack@google.com machineIDToMachineType(in_msg.Sender) == MachineType:L1Cache) { 28514184Sgabeblack@google.com 28614184Sgabeblack@google.com trigger(Event:DataS_fromL1, in_msg.addr, cache_entry, tbe); 28714184Sgabeblack@google.com 28814184Sgabeblack@google.com } else if ( (getPendingAcks(tbe) - in_msg.AckCount) == 0 ) { 28914184Sgabeblack@google.com trigger(Event:Data_all_Acks, in_msg.addr, cache_entry, tbe); 29014184Sgabeblack@google.com } else { 29114184Sgabeblack@google.com trigger(Event:Data, in_msg.addr, cache_entry, tbe); 29214184Sgabeblack@google.com } 29314184Sgabeblack@google.com } else if (in_msg.Type == CoherenceResponseType:ACK) { 29414184Sgabeblack@google.com if ( (getPendingAcks(tbe) - in_msg.AckCount) == 0 ) { 29514184Sgabeblack@google.com trigger(Event:Ack_all, in_msg.addr, cache_entry, tbe); 29614184Sgabeblack@google.com } else { 29714184Sgabeblack@google.com trigger(Event:Ack, in_msg.addr, cache_entry, tbe); 29814184Sgabeblack@google.com } 29914184Sgabeblack@google.com } else if (in_msg.Type == CoherenceResponseType:WB_ACK) { 30014184Sgabeblack@google.com trigger(Event:WB_Ack, in_msg.addr, cache_entry, tbe); 30114184Sgabeblack@google.com } else { 30214184Sgabeblack@google.com error("Invalid L1 response type"); 30314184Sgabeblack@google.com } 30414184Sgabeblack@google.com } 30514184Sgabeblack@google.com } 30614184Sgabeblack@google.com } 30714184Sgabeblack@google.com 30814184Sgabeblack@google.com // Request to this L1 cache from the shared L2 30914184Sgabeblack@google.com in_port(requestNetwork_in, RequestMsg, requestFromL2, rank = 2) { 31014184Sgabeblack@google.com if(requestNetwork_in.isReady(clockEdge())) { 31114184Sgabeblack@google.com peek(requestNetwork_in, RequestMsg) { 31214184Sgabeblack@google.com assert(in_msg.Destination.isElement(machineID)); 31314184Sgabeblack@google.com Entry cache_entry := getCacheEntry(in_msg.addr); 31414184Sgabeblack@google.com TBE tbe := TBEs[in_msg.addr]; 31514184Sgabeblack@google.com 31614184Sgabeblack@google.com if (in_msg.Type == CoherenceRequestType:INV) { 31714184Sgabeblack@google.com if (is_valid(cache_entry) && inL0Cache(cache_entry.CacheState)) { 31814184Sgabeblack@google.com trigger(Event:L0_Invalidate_Else, in_msg.addr, 31914184Sgabeblack@google.com cache_entry, tbe); 32014184Sgabeblack@google.com } else { 32114184Sgabeblack@google.com trigger(Event:Inv, in_msg.addr, cache_entry, tbe); 32214184Sgabeblack@google.com } 32314184Sgabeblack@google.com } else if (in_msg.Type == CoherenceRequestType:GETX || 32414184Sgabeblack@google.com in_msg.Type == CoherenceRequestType:UPGRADE) { 32514184Sgabeblack@google.com if (is_valid(cache_entry) && inL0Cache(cache_entry.CacheState)) { 32614184Sgabeblack@google.com trigger(Event:L0_Invalidate_Else, in_msg.addr, 32714184Sgabeblack@google.com cache_entry, tbe); 32814184Sgabeblack@google.com } else { 32914184Sgabeblack@google.com trigger(Event:Fwd_GETX, in_msg.addr, cache_entry, tbe); 33014184Sgabeblack@google.com } 33114184Sgabeblack@google.com } else if (in_msg.Type == CoherenceRequestType:GETS) { 33214184Sgabeblack@google.com if (is_valid(cache_entry) && inL0Cache(cache_entry.CacheState)) { 33314184Sgabeblack@google.com trigger(Event:L0_Invalidate_Else, in_msg.addr, 33414184Sgabeblack@google.com cache_entry, tbe); 33514184Sgabeblack@google.com } else { 33614184Sgabeblack@google.com trigger(Event:Fwd_GETS, in_msg.addr, cache_entry, tbe); 33714184Sgabeblack@google.com } 33814184Sgabeblack@google.com } else { 33914184Sgabeblack@google.com error("Invalid forwarded request type"); 34014184Sgabeblack@google.com } 34114184Sgabeblack@google.com } 34214184Sgabeblack@google.com } 34314184Sgabeblack@google.com } 34414184Sgabeblack@google.com 34514184Sgabeblack@google.com // Requests to this L1 cache from the L0 cache. 34614184Sgabeblack@google.com in_port(messageBufferFromL0_in, CoherenceMsg, bufferFromL0, rank = 0) { 34714184Sgabeblack@google.com if (messageBufferFromL0_in.isReady(clockEdge())) { 34814184Sgabeblack@google.com peek(messageBufferFromL0_in, CoherenceMsg) { 34914184Sgabeblack@google.com Entry cache_entry := getCacheEntry(in_msg.addr); 35014184Sgabeblack@google.com TBE tbe := TBEs[in_msg.addr]; 35114184Sgabeblack@google.com 35214184Sgabeblack@google.com if(in_msg.Class == CoherenceClass:INV_DATA) { 35314184Sgabeblack@google.com trigger(Event:L0_DataAck, in_msg.addr, cache_entry, tbe); 35414184Sgabeblack@google.com } else if (in_msg.Class == CoherenceClass:INV_ACK) { 35514184Sgabeblack@google.com trigger(Event:L0_Ack, in_msg.addr, cache_entry, tbe); 35614184Sgabeblack@google.com } else { 35714184Sgabeblack@google.com if (is_valid(cache_entry)) { 35814184Sgabeblack@google.com trigger(mandatory_request_type_to_event(in_msg.Class), 35914184Sgabeblack@google.com in_msg.addr, cache_entry, tbe); 36014184Sgabeblack@google.com } else { 36114184Sgabeblack@google.com if (cache.cacheAvail(in_msg.addr)) { 36214184Sgabeblack@google.com // L1 does't have the line, but we have space for it 36314184Sgabeblack@google.com // in the L1 let's see if the L2 has it 36414184Sgabeblack@google.com trigger(mandatory_request_type_to_event(in_msg.Class), 36514184Sgabeblack@google.com in_msg.addr, cache_entry, tbe); 36614184Sgabeblack@google.com } else { 36714184Sgabeblack@google.com // No room in the L1, so we need to make room in the L1 36814300Sjqu32@wisc.edu Addr victim := cache.cacheProbe(in_msg.addr); 36914300Sjqu32@wisc.edu Entry victim_entry := getCacheEntry(victim); 37014300Sjqu32@wisc.edu TBE victim_tbe := TBEs[victim]; 37114184Sgabeblack@google.com 37214184Sgabeblack@google.com if (is_valid(victim_entry) && inL0Cache(victim_entry.CacheState)) { 37314184Sgabeblack@google.com trigger(Event:L0_Invalidate_Own, 37414300Sjqu32@wisc.edu victim, victim_entry, victim_tbe); 37514184Sgabeblack@google.com } else { 37614184Sgabeblack@google.com trigger(Event:L1_Replacement, 37714300Sjqu32@wisc.edu victim, victim_entry, victim_tbe); 37814184Sgabeblack@google.com } 37914184Sgabeblack@google.com } 38014184Sgabeblack@google.com } 38114184Sgabeblack@google.com } 38214184Sgabeblack@google.com } 38314184Sgabeblack@google.com } 38414184Sgabeblack@google.com } 38514184Sgabeblack@google.com 38614184Sgabeblack@google.com // ACTIONS 38714184Sgabeblack@google.com action(a_issueGETS, "a", desc="Issue GETS") { 38814184Sgabeblack@google.com peek(messageBufferFromL0_in, CoherenceMsg) { 38914184Sgabeblack@google.com enqueue(requestNetwork_out, RequestMsg, l1_request_latency) { 39014184Sgabeblack@google.com out_msg.addr := address; 39114184Sgabeblack@google.com out_msg.Type := CoherenceRequestType:GETS; 39214184Sgabeblack@google.com out_msg.Requestor := machineID; 39314184Sgabeblack@google.com out_msg.Destination.add(mapAddressToRange(address, MachineType:L2Cache, 39414184Sgabeblack@google.com l2_select_low_bit, l2_select_num_bits, clusterID)); 39514184Sgabeblack@google.com DPRINTF(RubySlicc, "address: %#x, destination: %s\n", 39614184Sgabeblack@google.com address, out_msg.Destination); 39714184Sgabeblack@google.com out_msg.MessageSize := MessageSizeType:Control; 39814184Sgabeblack@google.com out_msg.AccessMode := in_msg.AccessMode; 39914184Sgabeblack@google.com } 40014184Sgabeblack@google.com } 40114184Sgabeblack@google.com } 40214184Sgabeblack@google.com 40314184Sgabeblack@google.com action(b_issueGETX, "b", desc="Issue GETX") { 40414184Sgabeblack@google.com peek(messageBufferFromL0_in, CoherenceMsg) { 40514184Sgabeblack@google.com enqueue(requestNetwork_out, RequestMsg, l1_request_latency) { 40614184Sgabeblack@google.com out_msg.addr := address; 40714184Sgabeblack@google.com out_msg.Type := CoherenceRequestType:GETX; 40814184Sgabeblack@google.com out_msg.Requestor := machineID; 40914184Sgabeblack@google.com DPRINTF(RubySlicc, "%s\n", machineID); 41014184Sgabeblack@google.com out_msg.Destination.add(mapAddressToRange(address, MachineType:L2Cache, 41114184Sgabeblack@google.com l2_select_low_bit, l2_select_num_bits, clusterID)); 41214184Sgabeblack@google.com DPRINTF(RubySlicc, "address: %#x, destination: %s\n", 41314184Sgabeblack@google.com address, out_msg.Destination); 41414184Sgabeblack@google.com out_msg.MessageSize := MessageSizeType:Control; 41514184Sgabeblack@google.com out_msg.AccessMode := in_msg.AccessMode; 41614184Sgabeblack@google.com } 41714184Sgabeblack@google.com } 41814184Sgabeblack@google.com } 41914184Sgabeblack@google.com 42014184Sgabeblack@google.com action(c_issueUPGRADE, "c", desc="Issue GETX") { 42114184Sgabeblack@google.com peek(messageBufferFromL0_in, CoherenceMsg) { 42214184Sgabeblack@google.com enqueue(requestNetwork_out, RequestMsg, l1_request_latency) { 42314184Sgabeblack@google.com out_msg.addr := address; 42414184Sgabeblack@google.com out_msg.Type := CoherenceRequestType:UPGRADE; 42514184Sgabeblack@google.com out_msg.Requestor := machineID; 42614184Sgabeblack@google.com out_msg.Destination.add(mapAddressToRange(address, MachineType:L2Cache, 42714184Sgabeblack@google.com l2_select_low_bit, l2_select_num_bits, clusterID)); 42814184Sgabeblack@google.com DPRINTF(RubySlicc, "address: %#x, destination: %s\n", 42914184Sgabeblack@google.com address, out_msg.Destination); 43014184Sgabeblack@google.com out_msg.MessageSize := MessageSizeType:Control; 43114184Sgabeblack@google.com out_msg.AccessMode := in_msg.AccessMode; 43214184Sgabeblack@google.com } 43314184Sgabeblack@google.com } 43414184Sgabeblack@google.com } 43514184Sgabeblack@google.com 43614184Sgabeblack@google.com action(d_sendDataToRequestor, "d", desc="send data to requestor") { 43714184Sgabeblack@google.com peek(requestNetwork_in, RequestMsg) { 43814184Sgabeblack@google.com enqueue(responseNetwork_out, ResponseMsg, l1_response_latency) { 43914184Sgabeblack@google.com assert(is_valid(cache_entry)); 44014184Sgabeblack@google.com out_msg.addr := address; 44114184Sgabeblack@google.com out_msg.Type := CoherenceResponseType:DATA; 44214184Sgabeblack@google.com out_msg.DataBlk := cache_entry.DataBlk; 44314184Sgabeblack@google.com out_msg.Dirty := cache_entry.Dirty; 44414184Sgabeblack@google.com out_msg.Sender := machineID; 44514184Sgabeblack@google.com out_msg.Destination.add(in_msg.Requestor); 44614184Sgabeblack@google.com out_msg.MessageSize := MessageSizeType:Response_Data; 44714184Sgabeblack@google.com } 44814184Sgabeblack@google.com } 44914184Sgabeblack@google.com } 45014184Sgabeblack@google.com 45114184Sgabeblack@google.com action(d2_sendDataToL2, "d2", desc="send data to the L2 cache because of M downgrade") { 45214184Sgabeblack@google.com enqueue(responseNetwork_out, ResponseMsg, l1_response_latency) { 45314184Sgabeblack@google.com assert(is_valid(cache_entry)); 45414184Sgabeblack@google.com out_msg.addr := address; 45514184Sgabeblack@google.com out_msg.Type := CoherenceResponseType:DATA; 45614184Sgabeblack@google.com out_msg.DataBlk := cache_entry.DataBlk; 45714184Sgabeblack@google.com out_msg.Dirty := cache_entry.Dirty; 45814184Sgabeblack@google.com out_msg.Sender := machineID; 45914184Sgabeblack@google.com out_msg.Destination.add(mapAddressToRange(address, MachineType:L2Cache, 46014184Sgabeblack@google.com l2_select_low_bit, l2_select_num_bits, clusterID)); 46114184Sgabeblack@google.com out_msg.MessageSize := MessageSizeType:Response_Data; 46214184Sgabeblack@google.com } 46314184Sgabeblack@google.com } 46414184Sgabeblack@google.com 46514184Sgabeblack@google.com action(dt_sendDataToRequestor_fromTBE, "dt", desc="send data to requestor") { 46614184Sgabeblack@google.com peek(requestNetwork_in, RequestMsg) { 46714184Sgabeblack@google.com enqueue(responseNetwork_out, ResponseMsg, l1_response_latency) { 46814184Sgabeblack@google.com assert(is_valid(tbe)); 46914184Sgabeblack@google.com out_msg.addr := address; 47014184Sgabeblack@google.com out_msg.Type := CoherenceResponseType:DATA; 47114184Sgabeblack@google.com out_msg.DataBlk := tbe.DataBlk; 47214184Sgabeblack@google.com out_msg.Dirty := tbe.Dirty; 47314184Sgabeblack@google.com out_msg.Sender := machineID; 47414184Sgabeblack@google.com out_msg.Destination.add(in_msg.Requestor); 47514184Sgabeblack@google.com out_msg.MessageSize := MessageSizeType:Response_Data; 47614184Sgabeblack@google.com } 47714184Sgabeblack@google.com } 47814184Sgabeblack@google.com } 47914184Sgabeblack@google.com 48014184Sgabeblack@google.com action(d2t_sendDataToL2_fromTBE, "d2t", desc="send data to the L2 cache") { 48114184Sgabeblack@google.com enqueue(responseNetwork_out, ResponseMsg, l1_response_latency) { 48214184Sgabeblack@google.com assert(is_valid(tbe)); 48314184Sgabeblack@google.com out_msg.addr := address; 48414184Sgabeblack@google.com out_msg.Type := CoherenceResponseType:DATA; 48514184Sgabeblack@google.com out_msg.DataBlk := tbe.DataBlk; 48614184Sgabeblack@google.com out_msg.Dirty := tbe.Dirty; 48714184Sgabeblack@google.com out_msg.Sender := machineID; 48814184Sgabeblack@google.com out_msg.Destination.add(mapAddressToRange(address, MachineType:L2Cache, 48914184Sgabeblack@google.com l2_select_low_bit, l2_select_num_bits, clusterID)); 49014184Sgabeblack@google.com out_msg.MessageSize := MessageSizeType:Response_Data; 49114184Sgabeblack@google.com } 49214184Sgabeblack@google.com } 49314184Sgabeblack@google.com 49414184Sgabeblack@google.com action(e_sendAckToRequestor, "e", desc="send invalidate ack to requestor (could be L2 or L1)") { 49514184Sgabeblack@google.com peek(requestNetwork_in, RequestMsg) { 49614184Sgabeblack@google.com enqueue(responseNetwork_out, ResponseMsg, l1_response_latency) { 49714184Sgabeblack@google.com out_msg.addr := address; 49814184Sgabeblack@google.com out_msg.Type := CoherenceResponseType:ACK; 49914184Sgabeblack@google.com out_msg.Sender := machineID; 50014184Sgabeblack@google.com out_msg.Destination.add(in_msg.Requestor); 50114184Sgabeblack@google.com out_msg.MessageSize := MessageSizeType:Response_Control; 50214184Sgabeblack@google.com } 50314184Sgabeblack@google.com } 50414184Sgabeblack@google.com } 50514184Sgabeblack@google.com 50614184Sgabeblack@google.com action(f_sendDataToL2, "f", desc="send data to the L2 cache") { 50714184Sgabeblack@google.com enqueue(responseNetwork_out, ResponseMsg, l1_response_latency) { 50814184Sgabeblack@google.com assert(is_valid(cache_entry)); 50914184Sgabeblack@google.com out_msg.addr := address; 51014184Sgabeblack@google.com out_msg.Type := CoherenceResponseType:DATA; 51114184Sgabeblack@google.com out_msg.DataBlk := cache_entry.DataBlk; 51214184Sgabeblack@google.com out_msg.Dirty := cache_entry.Dirty; 51314184Sgabeblack@google.com out_msg.Sender := machineID; 51414184Sgabeblack@google.com out_msg.Destination.add(mapAddressToRange(address, MachineType:L2Cache, 51514184Sgabeblack@google.com l2_select_low_bit, l2_select_num_bits, clusterID)); 51614184Sgabeblack@google.com out_msg.MessageSize := MessageSizeType:Writeback_Data; 51714184Sgabeblack@google.com } 51814184Sgabeblack@google.com } 51914184Sgabeblack@google.com 52014184Sgabeblack@google.com action(ft_sendDataToL2_fromTBE, "ft", desc="send data to the L2 cache") { 52114184Sgabeblack@google.com enqueue(responseNetwork_out, ResponseMsg, l1_response_latency) { 52214184Sgabeblack@google.com assert(is_valid(tbe)); 52314184Sgabeblack@google.com out_msg.addr := address; 52414184Sgabeblack@google.com out_msg.Type := CoherenceResponseType:DATA; 52514184Sgabeblack@google.com out_msg.DataBlk := tbe.DataBlk; 52614184Sgabeblack@google.com out_msg.Dirty := tbe.Dirty; 52714184Sgabeblack@google.com out_msg.Sender := machineID; 52814184Sgabeblack@google.com out_msg.Destination.add(mapAddressToRange(address, MachineType:L2Cache, 52914184Sgabeblack@google.com l2_select_low_bit, l2_select_num_bits, clusterID)); 53014184Sgabeblack@google.com out_msg.MessageSize := MessageSizeType:Writeback_Data; 53114184Sgabeblack@google.com } 53214184Sgabeblack@google.com } 53314184Sgabeblack@google.com 53414184Sgabeblack@google.com action(fi_sendInvAck, "fi", desc="send data to the L2 cache") { 53514184Sgabeblack@google.com peek(requestNetwork_in, RequestMsg) { 53614184Sgabeblack@google.com enqueue(responseNetwork_out, ResponseMsg, l1_response_latency) { 53714184Sgabeblack@google.com out_msg.addr := address; 53814184Sgabeblack@google.com out_msg.Type := CoherenceResponseType:ACK; 53914184Sgabeblack@google.com out_msg.Sender := machineID; 54014184Sgabeblack@google.com out_msg.Destination.add(in_msg.Requestor); 54114184Sgabeblack@google.com out_msg.MessageSize := MessageSizeType:Response_Control; 54214184Sgabeblack@google.com out_msg.AckCount := 1; 54314184Sgabeblack@google.com } 54414184Sgabeblack@google.com } 54514184Sgabeblack@google.com } 54614184Sgabeblack@google.com 54714184Sgabeblack@google.com action(forward_eviction_to_L0, "\cc", desc="sends eviction information to the processor") { 54814184Sgabeblack@google.com enqueue(bufferToL0_out, CoherenceMsg, l1_request_latency) { 54914184Sgabeblack@google.com out_msg.addr := address; 55014184Sgabeblack@google.com out_msg.Class := CoherenceClass:INV; 55114184Sgabeblack@google.com out_msg.Sender := machineID; 55214184Sgabeblack@google.com out_msg.Dest := createMachineID(MachineType:L0Cache, version); 55314184Sgabeblack@google.com out_msg.MessageSize := MessageSizeType:Control; 55414184Sgabeblack@google.com } 55514184Sgabeblack@google.com } 55614184Sgabeblack@google.com 55714184Sgabeblack@google.com action(g_issuePUTX, "g", desc="send data to the L2 cache") { 55814184Sgabeblack@google.com enqueue(requestNetwork_out, RequestMsg, l1_response_latency) { 55914184Sgabeblack@google.com assert(is_valid(cache_entry)); 56014184Sgabeblack@google.com out_msg.addr := address; 56114184Sgabeblack@google.com out_msg.Type := CoherenceRequestType:PUTX; 56214184Sgabeblack@google.com out_msg.Dirty := cache_entry.Dirty; 56314184Sgabeblack@google.com out_msg.Requestor:= machineID; 56414184Sgabeblack@google.com out_msg.Destination.add(mapAddressToRange(address, MachineType:L2Cache, 56514184Sgabeblack@google.com l2_select_low_bit, l2_select_num_bits, clusterID)); 56614184Sgabeblack@google.com if (cache_entry.Dirty) { 56714184Sgabeblack@google.com out_msg.MessageSize := MessageSizeType:Writeback_Data; 56814184Sgabeblack@google.com out_msg.DataBlk := cache_entry.DataBlk; 56914184Sgabeblack@google.com } else { 57014184Sgabeblack@google.com out_msg.MessageSize := MessageSizeType:Writeback_Control; 57114184Sgabeblack@google.com } 57214184Sgabeblack@google.com } 57314184Sgabeblack@google.com } 57414184Sgabeblack@google.com 57514184Sgabeblack@google.com action(j_sendUnblock, "j", desc="send unblock to the L2 cache") { 57614184Sgabeblack@google.com enqueue(unblockNetwork_out, ResponseMsg, to_l2_latency) { 57714184Sgabeblack@google.com out_msg.addr := address; 57814184Sgabeblack@google.com out_msg.Type := CoherenceResponseType:UNBLOCK; 57914184Sgabeblack@google.com out_msg.Sender := machineID; 58014184Sgabeblack@google.com out_msg.Destination.add(mapAddressToRange(address, MachineType:L2Cache, 58114184Sgabeblack@google.com l2_select_low_bit, l2_select_num_bits, clusterID)); 58214184Sgabeblack@google.com out_msg.MessageSize := MessageSizeType:Response_Control; 58314184Sgabeblack@google.com DPRINTF(RubySlicc, "%#x\n", address); 58414184Sgabeblack@google.com } 58514184Sgabeblack@google.com } 58614184Sgabeblack@google.com 58714184Sgabeblack@google.com action(jj_sendExclusiveUnblock, "\j", desc="send unblock to the L2 cache") { 58814184Sgabeblack@google.com enqueue(unblockNetwork_out, ResponseMsg, to_l2_latency) { 58914184Sgabeblack@google.com out_msg.addr := address; 59014184Sgabeblack@google.com out_msg.Type := CoherenceResponseType:EXCLUSIVE_UNBLOCK; 59114184Sgabeblack@google.com out_msg.Sender := machineID; 59214184Sgabeblack@google.com out_msg.Destination.add(mapAddressToRange(address, MachineType:L2Cache, 59314184Sgabeblack@google.com l2_select_low_bit, l2_select_num_bits, clusterID)); 59414184Sgabeblack@google.com out_msg.MessageSize := MessageSizeType:Response_Control; 59514184Sgabeblack@google.com DPRINTF(RubySlicc, "%#x\n", address); 59614184Sgabeblack@google.com 59714184Sgabeblack@google.com } 59814184Sgabeblack@google.com } 59914184Sgabeblack@google.com 60014184Sgabeblack@google.com action(h_data_to_l0, "h", desc="If not prefetch, send data to the L0 cache.") { 60114184Sgabeblack@google.com enqueue(bufferToL0_out, CoherenceMsg, l1_response_latency) { 60214184Sgabeblack@google.com assert(is_valid(cache_entry)); 60314184Sgabeblack@google.com 60414184Sgabeblack@google.com out_msg.addr := address; 60514184Sgabeblack@google.com out_msg.Class := CoherenceClass:DATA; 60614184Sgabeblack@google.com out_msg.Sender := machineID; 60714184Sgabeblack@google.com out_msg.Dest := createMachineID(MachineType:L0Cache, version); 60814184Sgabeblack@google.com out_msg.DataBlk := cache_entry.DataBlk; 60914184Sgabeblack@google.com out_msg.MessageSize := MessageSizeType:Response_Data; 61014184Sgabeblack@google.com } 61114184Sgabeblack@google.com } 61214184Sgabeblack@google.com 61314184Sgabeblack@google.com action(hh_xdata_to_l0, "\h", desc="If not prefetch, notify sequencer that store completed.") { 61414184Sgabeblack@google.com enqueue(bufferToL0_out, CoherenceMsg, l1_response_latency) { 61514184Sgabeblack@google.com assert(is_valid(cache_entry)); 61614184Sgabeblack@google.com 61714184Sgabeblack@google.com out_msg.addr := address; 61814184Sgabeblack@google.com out_msg.Class := CoherenceClass:DATA_EXCLUSIVE; 61914184Sgabeblack@google.com out_msg.Sender := machineID; 62014184Sgabeblack@google.com out_msg.Dest := createMachineID(MachineType:L0Cache, version); 62114184Sgabeblack@google.com out_msg.DataBlk := cache_entry.DataBlk; 62214184Sgabeblack@google.com out_msg.Dirty := cache_entry.Dirty; 62314184Sgabeblack@google.com out_msg.MessageSize := MessageSizeType:Response_Data; 62414184Sgabeblack@google.com 62514184Sgabeblack@google.com //cache_entry.Dirty := true; 62614184Sgabeblack@google.com } 62714184Sgabeblack@google.com } 62814184Sgabeblack@google.com 62914184Sgabeblack@google.com action(h_stale_data_to_l0, "hs", desc="If not prefetch, send data to the L0 cache.") { 63014184Sgabeblack@google.com enqueue(bufferToL0_out, CoherenceMsg, l1_response_latency) { 63114184Sgabeblack@google.com assert(is_valid(cache_entry)); 63214184Sgabeblack@google.com 63314184Sgabeblack@google.com out_msg.addr := address; 63414184Sgabeblack@google.com out_msg.Class := CoherenceClass:STALE_DATA; 63514184Sgabeblack@google.com out_msg.Sender := machineID; 63614184Sgabeblack@google.com out_msg.Dest := createMachineID(MachineType:L0Cache, version); 63714184Sgabeblack@google.com out_msg.DataBlk := cache_entry.DataBlk; 63814184Sgabeblack@google.com out_msg.Dirty := cache_entry.Dirty; 63914184Sgabeblack@google.com out_msg.MessageSize := MessageSizeType:Response_Data; 64014184Sgabeblack@google.com } 64114184Sgabeblack@google.com } 64214184Sgabeblack@google.com 64314184Sgabeblack@google.com action(i_allocateTBE, "i", desc="Allocate TBE (number of invalidates=0)") { 64414184Sgabeblack@google.com check_allocate(TBEs); 64514184Sgabeblack@google.com assert(is_valid(cache_entry)); 64614184Sgabeblack@google.com TBEs.allocate(address); 64714184Sgabeblack@google.com set_tbe(TBEs[address]); 64814184Sgabeblack@google.com tbe.Dirty := cache_entry.Dirty; 64914184Sgabeblack@google.com tbe.DataBlk := cache_entry.DataBlk; 65014184Sgabeblack@google.com } 65114184Sgabeblack@google.com 65214184Sgabeblack@google.com action(k_popL0RequestQueue, "k", desc="Pop mandatory queue.") { 65314184Sgabeblack@google.com messageBufferFromL0_in.dequeue(clockEdge()); 65414184Sgabeblack@google.com } 65514184Sgabeblack@google.com 65614184Sgabeblack@google.com action(l_popL2RequestQueue, "l", 65714184Sgabeblack@google.com desc="Pop incoming request queue and profile the delay within this virtual network") { 65814184Sgabeblack@google.com Tick delay := requestNetwork_in.dequeue(clockEdge()); 65914184Sgabeblack@google.com profileMsgDelay(2, ticksToCycles(delay)); 66014184Sgabeblack@google.com } 66114184Sgabeblack@google.com 66214184Sgabeblack@google.com action(o_popL2ResponseQueue, "o", 66314184Sgabeblack@google.com desc="Pop Incoming Response queue and profile the delay within this virtual network") { 66414184Sgabeblack@google.com Tick delay := responseNetwork_in.dequeue(clockEdge()); 66514184Sgabeblack@google.com profileMsgDelay(1, ticksToCycles(delay)); 66614184Sgabeblack@google.com } 66714184Sgabeblack@google.com 66814184Sgabeblack@google.com action(s_deallocateTBE, "s", desc="Deallocate TBE") { 66914184Sgabeblack@google.com TBEs.deallocate(address); 67014184Sgabeblack@google.com unset_tbe(); 67114184Sgabeblack@google.com } 67214184Sgabeblack@google.com 67314184Sgabeblack@google.com action(u_writeDataFromL0Request, "ureql0", desc="Write data to cache") { 67414184Sgabeblack@google.com peek(messageBufferFromL0_in, CoherenceMsg) { 67514184Sgabeblack@google.com assert(is_valid(cache_entry)); 67614184Sgabeblack@google.com if (in_msg.Dirty) { 67714184Sgabeblack@google.com cache_entry.DataBlk := in_msg.DataBlk; 67814184Sgabeblack@google.com cache_entry.Dirty := in_msg.Dirty; 67914184Sgabeblack@google.com } 68014184Sgabeblack@google.com } 68114184Sgabeblack@google.com } 68214184Sgabeblack@google.com 68314184Sgabeblack@google.com action(u_writeDataFromL2Response, "uresl2", desc="Write data to cache") { 68414184Sgabeblack@google.com peek(responseNetwork_in, ResponseMsg) { 68514184Sgabeblack@google.com assert(is_valid(cache_entry)); 68614184Sgabeblack@google.com cache_entry.DataBlk := in_msg.DataBlk; 68714184Sgabeblack@google.com } 68814184Sgabeblack@google.com } 68914184Sgabeblack@google.com 69014184Sgabeblack@google.com action(u_writeDataFromL0Response, "uresl0", desc="Write data to cache") { 69114184Sgabeblack@google.com peek(messageBufferFromL0_in, CoherenceMsg) { 69214184Sgabeblack@google.com assert(is_valid(cache_entry)); 69314184Sgabeblack@google.com if (in_msg.Dirty) { 69414184Sgabeblack@google.com cache_entry.DataBlk := in_msg.DataBlk; 69514184Sgabeblack@google.com cache_entry.Dirty := in_msg.Dirty; 69614184Sgabeblack@google.com } 69714184Sgabeblack@google.com } 69814184Sgabeblack@google.com } 69914184Sgabeblack@google.com 70014184Sgabeblack@google.com action(q_updateAckCount, "q", desc="Update ack count") { 70114184Sgabeblack@google.com peek(responseNetwork_in, ResponseMsg) { 70214184Sgabeblack@google.com assert(is_valid(tbe)); 70314184Sgabeblack@google.com tbe.pendingAcks := tbe.pendingAcks - in_msg.AckCount; 70414184Sgabeblack@google.com APPEND_TRANSITION_COMMENT(in_msg.AckCount); 70514184Sgabeblack@google.com APPEND_TRANSITION_COMMENT(" p: "); 70614184Sgabeblack@google.com APPEND_TRANSITION_COMMENT(tbe.pendingAcks); 70714184Sgabeblack@google.com } 70814184Sgabeblack@google.com } 70914184Sgabeblack@google.com 71014184Sgabeblack@google.com action(ff_deallocateCacheBlock, "\f", 71114184Sgabeblack@google.com desc="Deallocate L1 cache block.") { 71214184Sgabeblack@google.com if (cache.isTagPresent(address)) { 71314184Sgabeblack@google.com cache.deallocate(address); 71414184Sgabeblack@google.com } 71514184Sgabeblack@google.com unset_cache_entry(); 71614184Sgabeblack@google.com } 71714184Sgabeblack@google.com 71814184Sgabeblack@google.com action(oo_allocateCacheBlock, "\o", desc="Set cache tag equal to tag of block B.") { 71914184Sgabeblack@google.com if (is_invalid(cache_entry)) { 72014184Sgabeblack@google.com set_cache_entry(cache.allocate(address, new Entry)); 72114184Sgabeblack@google.com } 72214184Sgabeblack@google.com } 72314184Sgabeblack@google.com 72414184Sgabeblack@google.com action(z0_stallAndWaitL0Queue, "\z0", desc="recycle L0 request queue") { 72514184Sgabeblack@google.com stall_and_wait(messageBufferFromL0_in, address); 72614184Sgabeblack@google.com } 72714184Sgabeblack@google.com 72814184Sgabeblack@google.com action(z2_stallAndWaitL2Queue, "\z2", desc="recycle L2 request queue") { 72914184Sgabeblack@google.com stall_and_wait(requestNetwork_in, address); 73014184Sgabeblack@google.com } 73114184Sgabeblack@google.com 73214184Sgabeblack@google.com action(kd_wakeUpDependents, "kd", desc="wake-up dependents") { 73314184Sgabeblack@google.com wakeUpAllBuffers(address); 73414184Sgabeblack@google.com } 73514184Sgabeblack@google.com 73614184Sgabeblack@google.com action(uu_profileMiss, "\um", desc="Profile the demand miss") { 73714184Sgabeblack@google.com ++cache.demand_misses; 73814184Sgabeblack@google.com } 73914184Sgabeblack@google.com 74014184Sgabeblack@google.com action(uu_profileHit, "\uh", desc="Profile the demand hit") { 74114184Sgabeblack@google.com ++cache.demand_hits; 74214184Sgabeblack@google.com } 74314184Sgabeblack@google.com 74414184Sgabeblack@google.com 74514184Sgabeblack@google.com //***************************************************** 74614184Sgabeblack@google.com // TRANSITIONS 74714184Sgabeblack@google.com //***************************************************** 74814184Sgabeblack@google.com 74914184Sgabeblack@google.com // Transitions for Load/Store/Replacement/WriteBack from transient states 75014184Sgabeblack@google.com transition({IS, IM, IS_I, M_I, SM, SINK_WB_ACK, S_IL0, M_IL0, E_IL0, MM_IL0}, 75114184Sgabeblack@google.com {Load, Store, L1_Replacement}) { 75214184Sgabeblack@google.com z0_stallAndWaitL0Queue; 75314184Sgabeblack@google.com } 75414184Sgabeblack@google.com 75514184Sgabeblack@google.com transition(I, Load, IS) { 75614184Sgabeblack@google.com oo_allocateCacheBlock; 75714184Sgabeblack@google.com i_allocateTBE; 75814184Sgabeblack@google.com a_issueGETS; 75914184Sgabeblack@google.com uu_profileMiss; 76014184Sgabeblack@google.com k_popL0RequestQueue; 76114184Sgabeblack@google.com } 76214184Sgabeblack@google.com 76314184Sgabeblack@google.com transition(I, Store, IM) { 76414184Sgabeblack@google.com oo_allocateCacheBlock; 76514184Sgabeblack@google.com i_allocateTBE; 76614184Sgabeblack@google.com b_issueGETX; 76714184Sgabeblack@google.com uu_profileMiss; 76814184Sgabeblack@google.com k_popL0RequestQueue; 76914184Sgabeblack@google.com } 77014184Sgabeblack@google.com 77114184Sgabeblack@google.com transition(I, Inv) { 77214184Sgabeblack@google.com fi_sendInvAck; 77314184Sgabeblack@google.com l_popL2RequestQueue; 77414184Sgabeblack@google.com } 77514184Sgabeblack@google.com 77614184Sgabeblack@google.com // Transitions from Shared 77714184Sgabeblack@google.com transition({S,SS}, Load, S) { 77814184Sgabeblack@google.com h_data_to_l0; 77914184Sgabeblack@google.com uu_profileHit; 78014184Sgabeblack@google.com k_popL0RequestQueue; 78114184Sgabeblack@google.com } 78214184Sgabeblack@google.com 78314184Sgabeblack@google.com transition(EE, Load, E) { 78414184Sgabeblack@google.com hh_xdata_to_l0; 78514184Sgabeblack@google.com uu_profileHit; 78614184Sgabeblack@google.com k_popL0RequestQueue; 78714184Sgabeblack@google.com } 78814184Sgabeblack@google.com 78914184Sgabeblack@google.com transition(MM, Load, M) { 79014184Sgabeblack@google.com hh_xdata_to_l0; 79114184Sgabeblack@google.com uu_profileHit; 79214184Sgabeblack@google.com k_popL0RequestQueue; 79314184Sgabeblack@google.com } 79414184Sgabeblack@google.com 79514184Sgabeblack@google.com transition({S,SS}, Store, SM) { 79614184Sgabeblack@google.com i_allocateTBE; 79714184Sgabeblack@google.com c_issueUPGRADE; 79814184Sgabeblack@google.com uu_profileMiss; 79914184Sgabeblack@google.com k_popL0RequestQueue; 80014184Sgabeblack@google.com } 80114184Sgabeblack@google.com 80214184Sgabeblack@google.com transition(SS, L1_Replacement, I) { 80314184Sgabeblack@google.com ff_deallocateCacheBlock; 80414184Sgabeblack@google.com } 80514184Sgabeblack@google.com 80614184Sgabeblack@google.com transition(S, {L0_Invalidate_Own, L0_Invalidate_Else}, S_IL0) { 80714184Sgabeblack@google.com forward_eviction_to_L0; 80814184Sgabeblack@google.com } 80914184Sgabeblack@google.com 81014184Sgabeblack@google.com transition(SS, Inv, I) { 81114184Sgabeblack@google.com fi_sendInvAck; 81214184Sgabeblack@google.com ff_deallocateCacheBlock; 81314184Sgabeblack@google.com l_popL2RequestQueue; 81414184Sgabeblack@google.com } 81514184Sgabeblack@google.com 81614184Sgabeblack@google.com // Transitions from Exclusive 81714184Sgabeblack@google.com 81814184Sgabeblack@google.com transition({EE,MM}, Store, M) { 81914184Sgabeblack@google.com hh_xdata_to_l0; 82014184Sgabeblack@google.com uu_profileHit; 82114184Sgabeblack@google.com k_popL0RequestQueue; 82214184Sgabeblack@google.com } 82314184Sgabeblack@google.com 82414184Sgabeblack@google.com transition(EE, L1_Replacement, M_I) { 82514184Sgabeblack@google.com // silent E replacement?? 82614184Sgabeblack@google.com i_allocateTBE; 82714184Sgabeblack@google.com g_issuePUTX; // send data, but hold in case forwarded request 82814184Sgabeblack@google.com ff_deallocateCacheBlock; 82914184Sgabeblack@google.com } 83014184Sgabeblack@google.com 83114184Sgabeblack@google.com transition(EE, Inv, I) { 83214184Sgabeblack@google.com // don't send data 83314184Sgabeblack@google.com fi_sendInvAck; 83414184Sgabeblack@google.com ff_deallocateCacheBlock; 83514184Sgabeblack@google.com l_popL2RequestQueue; 83614184Sgabeblack@google.com } 83714184Sgabeblack@google.com 83814184Sgabeblack@google.com transition(EE, Fwd_GETX, I) { 83914184Sgabeblack@google.com d_sendDataToRequestor; 84014184Sgabeblack@google.com ff_deallocateCacheBlock; 84114184Sgabeblack@google.com l_popL2RequestQueue; 84214184Sgabeblack@google.com } 84314184Sgabeblack@google.com 84414184Sgabeblack@google.com transition(EE, Fwd_GETS, SS) { 84514184Sgabeblack@google.com d_sendDataToRequestor; 84614184Sgabeblack@google.com d2_sendDataToL2; 84714184Sgabeblack@google.com l_popL2RequestQueue; 84814184Sgabeblack@google.com } 84914184Sgabeblack@google.com 85014184Sgabeblack@google.com transition(E, {L0_Invalidate_Own, L0_Invalidate_Else}, E_IL0) { 85114184Sgabeblack@google.com forward_eviction_to_L0; 85214184Sgabeblack@google.com } 85314184Sgabeblack@google.com 85414184Sgabeblack@google.com // Transitions from Modified 85514184Sgabeblack@google.com transition(MM, L1_Replacement, M_I) { 85614184Sgabeblack@google.com i_allocateTBE; 85714184Sgabeblack@google.com g_issuePUTX; // send data, but hold in case forwarded request 85814184Sgabeblack@google.com ff_deallocateCacheBlock; 85914184Sgabeblack@google.com } 86014184Sgabeblack@google.com 86114184Sgabeblack@google.com transition({M,E}, WriteBack, MM) { 86214184Sgabeblack@google.com u_writeDataFromL0Request; 86314184Sgabeblack@google.com k_popL0RequestQueue; 86414184Sgabeblack@google.com } 86514184Sgabeblack@google.com 86614184Sgabeblack@google.com transition(M_I, WB_Ack, I) { 86714184Sgabeblack@google.com s_deallocateTBE; 86814184Sgabeblack@google.com o_popL2ResponseQueue; 86914184Sgabeblack@google.com ff_deallocateCacheBlock; 87014184Sgabeblack@google.com kd_wakeUpDependents; 87114184Sgabeblack@google.com } 87214184Sgabeblack@google.com 87314184Sgabeblack@google.com transition(MM, Inv, I) { 87414184Sgabeblack@google.com f_sendDataToL2; 87514184Sgabeblack@google.com ff_deallocateCacheBlock; 87614184Sgabeblack@google.com l_popL2RequestQueue; 87714184Sgabeblack@google.com } 87814184Sgabeblack@google.com 87914184Sgabeblack@google.com transition(M_I, Inv, SINK_WB_ACK) { 88014184Sgabeblack@google.com ft_sendDataToL2_fromTBE; 88114184Sgabeblack@google.com l_popL2RequestQueue; 88214184Sgabeblack@google.com } 88314184Sgabeblack@google.com 88414184Sgabeblack@google.com transition(MM, Fwd_GETX, I) { 88514184Sgabeblack@google.com d_sendDataToRequestor; 88614184Sgabeblack@google.com ff_deallocateCacheBlock; 88714184Sgabeblack@google.com l_popL2RequestQueue; 88814184Sgabeblack@google.com } 88914184Sgabeblack@google.com 89014184Sgabeblack@google.com transition(MM, Fwd_GETS, SS) { 89114184Sgabeblack@google.com d_sendDataToRequestor; 89214184Sgabeblack@google.com d2_sendDataToL2; 89314184Sgabeblack@google.com l_popL2RequestQueue; 89414184Sgabeblack@google.com } 89514184Sgabeblack@google.com 89614184Sgabeblack@google.com transition(M, {L0_Invalidate_Own, L0_Invalidate_Else}, M_IL0) { 89714184Sgabeblack@google.com forward_eviction_to_L0; 89814184Sgabeblack@google.com } 89914184Sgabeblack@google.com 90014184Sgabeblack@google.com transition(M_I, Fwd_GETX, SINK_WB_ACK) { 90114184Sgabeblack@google.com dt_sendDataToRequestor_fromTBE; 90214184Sgabeblack@google.com l_popL2RequestQueue; 90314184Sgabeblack@google.com } 90414184Sgabeblack@google.com 90514184Sgabeblack@google.com transition(M_I, Fwd_GETS, SINK_WB_ACK) { 90614184Sgabeblack@google.com dt_sendDataToRequestor_fromTBE; 90714184Sgabeblack@google.com d2t_sendDataToL2_fromTBE; 90814184Sgabeblack@google.com l_popL2RequestQueue; 90914184Sgabeblack@google.com } 91014184Sgabeblack@google.com 91114184Sgabeblack@google.com // Transitions from IS 91214184Sgabeblack@google.com transition({IS,IS_I}, Inv, IS_I) { 91314184Sgabeblack@google.com fi_sendInvAck; 91414184Sgabeblack@google.com l_popL2RequestQueue; 91514184Sgabeblack@google.com } 91614184Sgabeblack@google.com 91714184Sgabeblack@google.com transition(IS, Data_all_Acks, S) { 91814184Sgabeblack@google.com u_writeDataFromL2Response; 91914184Sgabeblack@google.com h_data_to_l0; 92014184Sgabeblack@google.com s_deallocateTBE; 92114184Sgabeblack@google.com o_popL2ResponseQueue; 92214184Sgabeblack@google.com kd_wakeUpDependents; 92314184Sgabeblack@google.com } 92414184Sgabeblack@google.com 92514184Sgabeblack@google.com transition(IS_I, Data_all_Acks, I) { 92614184Sgabeblack@google.com u_writeDataFromL2Response; 92714184Sgabeblack@google.com h_stale_data_to_l0; 92814184Sgabeblack@google.com s_deallocateTBE; 92914184Sgabeblack@google.com ff_deallocateCacheBlock; 93014184Sgabeblack@google.com o_popL2ResponseQueue; 93114184Sgabeblack@google.com kd_wakeUpDependents; 93214184Sgabeblack@google.com } 93314184Sgabeblack@google.com 93414184Sgabeblack@google.com transition(IS, DataS_fromL1, S) { 93514184Sgabeblack@google.com u_writeDataFromL2Response; 93614184Sgabeblack@google.com j_sendUnblock; 93714184Sgabeblack@google.com h_data_to_l0; 93814184Sgabeblack@google.com s_deallocateTBE; 93914184Sgabeblack@google.com o_popL2ResponseQueue; 94014184Sgabeblack@google.com kd_wakeUpDependents; 94114184Sgabeblack@google.com } 94214184Sgabeblack@google.com 94314184Sgabeblack@google.com transition(IS_I, DataS_fromL1, I) { 94414184Sgabeblack@google.com u_writeDataFromL2Response; 94514184Sgabeblack@google.com j_sendUnblock; 94614184Sgabeblack@google.com h_stale_data_to_l0; 94714184Sgabeblack@google.com s_deallocateTBE; 94814184Sgabeblack@google.com ff_deallocateCacheBlock; 94914184Sgabeblack@google.com o_popL2ResponseQueue; 95014184Sgabeblack@google.com kd_wakeUpDependents; 95114184Sgabeblack@google.com } 95214184Sgabeblack@google.com 95314184Sgabeblack@google.com // directory is blocked when sending exclusive data 95414184Sgabeblack@google.com transition({IS,IS_I}, Data_Exclusive, E) { 95514184Sgabeblack@google.com u_writeDataFromL2Response; 95614184Sgabeblack@google.com hh_xdata_to_l0; 95714184Sgabeblack@google.com jj_sendExclusiveUnblock; 95814184Sgabeblack@google.com s_deallocateTBE; 95914184Sgabeblack@google.com o_popL2ResponseQueue; 96014184Sgabeblack@google.com kd_wakeUpDependents; 96114184Sgabeblack@google.com } 96214184Sgabeblack@google.com 96314184Sgabeblack@google.com // Transitions from IM 96414184Sgabeblack@google.com transition({IM,SM}, Inv, IM) { 96514184Sgabeblack@google.com fi_sendInvAck; 96614184Sgabeblack@google.com l_popL2RequestQueue; 96714184Sgabeblack@google.com } 96814184Sgabeblack@google.com 96914184Sgabeblack@google.com transition(IM, Data, SM) { 97014184Sgabeblack@google.com u_writeDataFromL2Response; 97114184Sgabeblack@google.com q_updateAckCount; 97214184Sgabeblack@google.com o_popL2ResponseQueue; 97314184Sgabeblack@google.com } 97414184Sgabeblack@google.com 97514184Sgabeblack@google.com transition(IM, Data_all_Acks, M) { 97614184Sgabeblack@google.com u_writeDataFromL2Response; 97714184Sgabeblack@google.com hh_xdata_to_l0; 97814184Sgabeblack@google.com jj_sendExclusiveUnblock; 97914184Sgabeblack@google.com s_deallocateTBE; 98014184Sgabeblack@google.com o_popL2ResponseQueue; 98114184Sgabeblack@google.com kd_wakeUpDependents; 98214184Sgabeblack@google.com } 98314184Sgabeblack@google.com 98414184Sgabeblack@google.com transition({SM, IM}, Ack) { 98514184Sgabeblack@google.com q_updateAckCount; 98614184Sgabeblack@google.com o_popL2ResponseQueue; 98714184Sgabeblack@google.com } 98814184Sgabeblack@google.com 98914184Sgabeblack@google.com transition(SM, Ack_all, M) { 99014184Sgabeblack@google.com jj_sendExclusiveUnblock; 99114184Sgabeblack@google.com hh_xdata_to_l0; 99214184Sgabeblack@google.com s_deallocateTBE; 99314184Sgabeblack@google.com o_popL2ResponseQueue; 99414184Sgabeblack@google.com kd_wakeUpDependents; 99514184Sgabeblack@google.com } 99614184Sgabeblack@google.com 99714184Sgabeblack@google.com transition(SM, L0_Invalidate_Else, SM_IL0) { 99814184Sgabeblack@google.com forward_eviction_to_L0; 99914184Sgabeblack@google.com } 100014184Sgabeblack@google.com 100114184Sgabeblack@google.com transition(SINK_WB_ACK, Inv){ 100214184Sgabeblack@google.com fi_sendInvAck; 100314184Sgabeblack@google.com l_popL2RequestQueue; 100414184Sgabeblack@google.com } 100514184Sgabeblack@google.com 100614184Sgabeblack@google.com transition(SINK_WB_ACK, WB_Ack, I){ 100714184Sgabeblack@google.com s_deallocateTBE; 100814184Sgabeblack@google.com o_popL2ResponseQueue; 100914184Sgabeblack@google.com ff_deallocateCacheBlock; 101014184Sgabeblack@google.com kd_wakeUpDependents; 101114184Sgabeblack@google.com } 101214184Sgabeblack@google.com 101314184Sgabeblack@google.com transition({M_IL0, E_IL0}, WriteBack, MM_IL0) { 101414184Sgabeblack@google.com u_writeDataFromL0Request; 101514184Sgabeblack@google.com k_popL0RequestQueue; 101614184Sgabeblack@google.com kd_wakeUpDependents; 101714184Sgabeblack@google.com } 101814184Sgabeblack@google.com 101914184Sgabeblack@google.com transition({M_IL0, E_IL0}, L0_DataAck, MM) { 102014184Sgabeblack@google.com u_writeDataFromL0Response; 102114184Sgabeblack@google.com k_popL0RequestQueue; 102214184Sgabeblack@google.com kd_wakeUpDependents; 102314184Sgabeblack@google.com } 102414184Sgabeblack@google.com 102514184Sgabeblack@google.com transition({M_IL0, MM_IL0}, L0_Ack, MM) { 102614184Sgabeblack@google.com k_popL0RequestQueue; 102714184Sgabeblack@google.com kd_wakeUpDependents; 102814184Sgabeblack@google.com } 102914184Sgabeblack@google.com 103014184Sgabeblack@google.com transition(E_IL0, L0_Ack, EE) { 103114184Sgabeblack@google.com k_popL0RequestQueue; 103214184Sgabeblack@google.com kd_wakeUpDependents; 103314184Sgabeblack@google.com } 103414184Sgabeblack@google.com 103514184Sgabeblack@google.com transition(S_IL0, L0_Ack, SS) { 103614184Sgabeblack@google.com k_popL0RequestQueue; 103714184Sgabeblack@google.com kd_wakeUpDependents; 103814184Sgabeblack@google.com } 103914184Sgabeblack@google.com 104014184Sgabeblack@google.com transition(SM_IL0, L0_Ack, IM) { 104114184Sgabeblack@google.com k_popL0RequestQueue; 104214184Sgabeblack@google.com kd_wakeUpDependents; 104314184Sgabeblack@google.com } 104414184Sgabeblack@google.com 104514184Sgabeblack@google.com transition({S_IL0, M_IL0, E_IL0, SM_IL0, SM}, L0_Invalidate_Own) { 104614184Sgabeblack@google.com z0_stallAndWaitL0Queue; 104714184Sgabeblack@google.com } 104814184Sgabeblack@google.com 104914184Sgabeblack@google.com transition({S_IL0, M_IL0, E_IL0, SM_IL0}, L0_Invalidate_Else) { 105014184Sgabeblack@google.com z2_stallAndWaitL2Queue; 105114184Sgabeblack@google.com } 105214184Sgabeblack@google.com 105314184Sgabeblack@google.com transition({S_IL0, M_IL0, E_IL0, MM_IL0}, {Inv, Fwd_GETX, Fwd_GETS}) { 105414184Sgabeblack@google.com z2_stallAndWaitL2Queue; 105514184Sgabeblack@google.com } 105614184Sgabeblack@google.com} 1057