114184Sgabeblack@google.com/* 214184Sgabeblack@google.com * Copyright (c) 2009-2012 Mark D. Hill and David A. Wood 314184Sgabeblack@google.com * Copyright (c) 2010-2012 Advanced Micro Devices, Inc. 414184Sgabeblack@google.com * All rights reserved. 514184Sgabeblack@google.com * 614184Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 714184Sgabeblack@google.com * modification, are permitted provided that the following conditions are 814184Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 914184Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 1014184Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 1114184Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 1214184Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 1314184Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 1414184Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 1514184Sgabeblack@google.com * this software without specific prior written permission. 1614184Sgabeblack@google.com * 1714184Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1814184Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1914184Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2014184Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2114184Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2214184Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2314184Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2414184Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2514184Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2614184Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2714184Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2814184Sgabeblack@google.com */ 2914184Sgabeblack@google.com 3014184Sgabeblack@google.commachine(MachineType:L1Cache, "MI Example L1 Cache") 3114184Sgabeblack@google.com : Sequencer * sequencer; 3214184Sgabeblack@google.com CacheMemory * cacheMemory; 3314184Sgabeblack@google.com Cycles cache_response_latency := 12; 3414184Sgabeblack@google.com Cycles issue_latency := 2; 3514184Sgabeblack@google.com bool send_evictions; 3614184Sgabeblack@google.com 3714184Sgabeblack@google.com // NETWORK BUFFERS 3814184Sgabeblack@google.com MessageBuffer * requestFromCache, network="To", virtual_network="2", 3914184Sgabeblack@google.com vnet_type="request"; 4014184Sgabeblack@google.com MessageBuffer * responseFromCache, network="To", virtual_network="4", 4114184Sgabeblack@google.com vnet_type="response"; 4214184Sgabeblack@google.com 4314184Sgabeblack@google.com MessageBuffer * forwardToCache, network="From", virtual_network="3", 4414184Sgabeblack@google.com vnet_type="forward"; 4514184Sgabeblack@google.com MessageBuffer * responseToCache, network="From", virtual_network="4", 4614184Sgabeblack@google.com vnet_type="response"; 4714184Sgabeblack@google.com 4814184Sgabeblack@google.com MessageBuffer * mandatoryQueue; 4914184Sgabeblack@google.com{ 5014184Sgabeblack@google.com // STATES 5114184Sgabeblack@google.com state_declaration(State, desc="Cache states") { 5214184Sgabeblack@google.com I, AccessPermission:Invalid, desc="Not Present/Invalid"; 5314184Sgabeblack@google.com II, AccessPermission:Busy, desc="Not Present/Invalid, issued PUT"; 5414184Sgabeblack@google.com M, AccessPermission:Read_Write, desc="Modified"; 5514184Sgabeblack@google.com MI, AccessPermission:Busy, desc="Modified, issued PUT"; 5614184Sgabeblack@google.com MII, AccessPermission:Busy, desc="Modified, issued PUTX, received nack"; 5714184Sgabeblack@google.com 5814184Sgabeblack@google.com IS, AccessPermission:Busy, desc="Issued request for LOAD/IFETCH"; 5914184Sgabeblack@google.com IM, AccessPermission:Busy, desc="Issued request for STORE/ATOMIC"; 6014184Sgabeblack@google.com } 6114184Sgabeblack@google.com 6214184Sgabeblack@google.com // EVENTS 6314184Sgabeblack@google.com enumeration(Event, desc="Cache events") { 6414184Sgabeblack@google.com // From processor 6514184Sgabeblack@google.com 6614184Sgabeblack@google.com Load, desc="Load request from processor"; 6714184Sgabeblack@google.com Ifetch, desc="Ifetch request from processor"; 6814184Sgabeblack@google.com Store, desc="Store request from processor"; 6914184Sgabeblack@google.com 7014184Sgabeblack@google.com Data, desc="Data from network"; 7114184Sgabeblack@google.com Fwd_GETX, desc="Forward from network"; 7214184Sgabeblack@google.com 7314184Sgabeblack@google.com Inv, desc="Invalidate request from dir"; 7414184Sgabeblack@google.com 7514184Sgabeblack@google.com Replacement, desc="Replace a block"; 7614184Sgabeblack@google.com Writeback_Ack, desc="Ack from the directory for a writeback"; 7714184Sgabeblack@google.com Writeback_Nack, desc="Nack from the directory for a writeback"; 7814184Sgabeblack@google.com } 7914184Sgabeblack@google.com 8014184Sgabeblack@google.com // STRUCTURE DEFINITIONS 8114184Sgabeblack@google.com // CacheEntry 8214184Sgabeblack@google.com structure(Entry, desc="...", interface="AbstractCacheEntry") { 8314184Sgabeblack@google.com State CacheState, desc="cache state"; 8414184Sgabeblack@google.com bool Dirty, desc="Is the data dirty (different than memory)?"; 8514184Sgabeblack@google.com DataBlock DataBlk, desc="Data in the block"; 8614184Sgabeblack@google.com } 8714184Sgabeblack@google.com 8814184Sgabeblack@google.com // TBE fields 8914184Sgabeblack@google.com structure(TBE, desc="...") { 9014184Sgabeblack@google.com State TBEState, desc="Transient state"; 9114184Sgabeblack@google.com DataBlock DataBlk, desc="data for the block, required for concurrent writebacks"; 9214184Sgabeblack@google.com } 9314184Sgabeblack@google.com 9414184Sgabeblack@google.com structure(TBETable, external="yes") { 9514184Sgabeblack@google.com TBE lookup(Addr); 9614184Sgabeblack@google.com void allocate(Addr); 9714184Sgabeblack@google.com void deallocate(Addr); 9814184Sgabeblack@google.com bool isPresent(Addr); 9914184Sgabeblack@google.com } 10014184Sgabeblack@google.com 10114184Sgabeblack@google.com 10214184Sgabeblack@google.com // STRUCTURES 10314184Sgabeblack@google.com TBETable TBEs, template="<L1Cache_TBE>", constructor="m_number_of_TBEs"; 10414184Sgabeblack@google.com 10514184Sgabeblack@google.com // PROTOTYPES 10614184Sgabeblack@google.com Tick clockEdge(); 10714184Sgabeblack@google.com Cycles ticksToCycles(Tick t); 10814184Sgabeblack@google.com void set_cache_entry(AbstractCacheEntry a); 10914184Sgabeblack@google.com void unset_cache_entry(); 11014184Sgabeblack@google.com void set_tbe(TBE b); 11114184Sgabeblack@google.com void unset_tbe(); 11214184Sgabeblack@google.com void profileMsgDelay(int virtualNetworkType, Cycles b); 11314184Sgabeblack@google.com MachineID mapAddressToMachine(Addr addr, MachineType mtype); 11414184Sgabeblack@google.com 11514184Sgabeblack@google.com Entry getCacheEntry(Addr address), return_by_pointer="yes" { 11614184Sgabeblack@google.com return static_cast(Entry, "pointer", cacheMemory.lookup(address)); 11714184Sgabeblack@google.com } 11814184Sgabeblack@google.com 11914184Sgabeblack@google.com // FUNCTIONS 12014184Sgabeblack@google.com Event mandatory_request_type_to_event(RubyRequestType type) { 12114184Sgabeblack@google.com if (type == RubyRequestType:LD) { 12214184Sgabeblack@google.com return Event:Load; 12314184Sgabeblack@google.com } else if (type == RubyRequestType:IFETCH) { 12414184Sgabeblack@google.com return Event:Ifetch; 12514184Sgabeblack@google.com } else if ((type == RubyRequestType:ST) || (type == RubyRequestType:ATOMIC)) { 12614184Sgabeblack@google.com return Event:Store; 12714184Sgabeblack@google.com } else { 12814184Sgabeblack@google.com error("Invalid RubyRequestType"); 12914184Sgabeblack@google.com } 13014184Sgabeblack@google.com } 13114184Sgabeblack@google.com 13214184Sgabeblack@google.com State getState(TBE tbe, Entry cache_entry, Addr addr) { 13314184Sgabeblack@google.com 13414184Sgabeblack@google.com if (is_valid(tbe)) { 13514184Sgabeblack@google.com return tbe.TBEState; 13614184Sgabeblack@google.com } 13714184Sgabeblack@google.com else if (is_valid(cache_entry)) { 13814184Sgabeblack@google.com return cache_entry.CacheState; 13914184Sgabeblack@google.com } 14014184Sgabeblack@google.com else { 14114184Sgabeblack@google.com return State:I; 14214184Sgabeblack@google.com } 14314184Sgabeblack@google.com } 14414184Sgabeblack@google.com 14514184Sgabeblack@google.com void setState(TBE tbe, Entry cache_entry, Addr addr, State state) { 14614184Sgabeblack@google.com 14714184Sgabeblack@google.com if (is_valid(tbe)) { 14814184Sgabeblack@google.com tbe.TBEState := state; 14914184Sgabeblack@google.com } 15014184Sgabeblack@google.com 15114184Sgabeblack@google.com if (is_valid(cache_entry)) { 15214184Sgabeblack@google.com cache_entry.CacheState := state; 15314184Sgabeblack@google.com } 15414184Sgabeblack@google.com } 15514184Sgabeblack@google.com 15614184Sgabeblack@google.com AccessPermission getAccessPermission(Addr addr) { 15714184Sgabeblack@google.com TBE tbe := TBEs[addr]; 15814184Sgabeblack@google.com if(is_valid(tbe)) { 15914184Sgabeblack@google.com return L1Cache_State_to_permission(tbe.TBEState); 16014184Sgabeblack@google.com } 16114184Sgabeblack@google.com 16214184Sgabeblack@google.com Entry cache_entry := getCacheEntry(addr); 16314184Sgabeblack@google.com if(is_valid(cache_entry)) { 16414184Sgabeblack@google.com return L1Cache_State_to_permission(cache_entry.CacheState); 16514184Sgabeblack@google.com } 16614184Sgabeblack@google.com 16714184Sgabeblack@google.com return AccessPermission:NotPresent; 16814184Sgabeblack@google.com } 16914184Sgabeblack@google.com 17014184Sgabeblack@google.com void setAccessPermission(Entry cache_entry, Addr addr, State state) { 17114184Sgabeblack@google.com if (is_valid(cache_entry)) { 17214184Sgabeblack@google.com cache_entry.changePermission(L1Cache_State_to_permission(state)); 17314184Sgabeblack@google.com } 17414184Sgabeblack@google.com } 17514184Sgabeblack@google.com 17614184Sgabeblack@google.com void functionalRead(Addr addr, Packet *pkt) { 17714184Sgabeblack@google.com TBE tbe := TBEs[addr]; 17814184Sgabeblack@google.com if(is_valid(tbe)) { 17914184Sgabeblack@google.com testAndRead(addr, tbe.DataBlk, pkt); 18014184Sgabeblack@google.com } else { 18114184Sgabeblack@google.com testAndRead(addr, getCacheEntry(addr).DataBlk, pkt); 18214184Sgabeblack@google.com } 18314184Sgabeblack@google.com } 18414184Sgabeblack@google.com 18514184Sgabeblack@google.com int functionalWrite(Addr addr, Packet *pkt) { 18614184Sgabeblack@google.com int num_functional_writes := 0; 18714184Sgabeblack@google.com 18814184Sgabeblack@google.com TBE tbe := TBEs[addr]; 18914184Sgabeblack@google.com if(is_valid(tbe)) { 19014184Sgabeblack@google.com num_functional_writes := num_functional_writes + 19114184Sgabeblack@google.com testAndWrite(addr, tbe.DataBlk, pkt); 19214184Sgabeblack@google.com return num_functional_writes; 19314184Sgabeblack@google.com } 19414184Sgabeblack@google.com 19514184Sgabeblack@google.com num_functional_writes := num_functional_writes + 19614184Sgabeblack@google.com testAndWrite(addr, getCacheEntry(addr).DataBlk, pkt); 19714184Sgabeblack@google.com return num_functional_writes; 19814184Sgabeblack@google.com } 19914184Sgabeblack@google.com 20014184Sgabeblack@google.com // NETWORK PORTS 20114184Sgabeblack@google.com 20214184Sgabeblack@google.com out_port(requestNetwork_out, RequestMsg, requestFromCache); 20314184Sgabeblack@google.com out_port(responseNetwork_out, ResponseMsg, responseFromCache); 20414184Sgabeblack@google.com 20514184Sgabeblack@google.com in_port(forwardRequestNetwork_in, RequestMsg, forwardToCache) { 20614184Sgabeblack@google.com if (forwardRequestNetwork_in.isReady(clockEdge())) { 20714184Sgabeblack@google.com peek(forwardRequestNetwork_in, RequestMsg, block_on="addr") { 20814184Sgabeblack@google.com 20914184Sgabeblack@google.com Entry cache_entry := getCacheEntry(in_msg.addr); 21014184Sgabeblack@google.com TBE tbe := TBEs[in_msg.addr]; 21114184Sgabeblack@google.com 21214184Sgabeblack@google.com if (in_msg.Type == CoherenceRequestType:GETX) { 21314184Sgabeblack@google.com trigger(Event:Fwd_GETX, in_msg.addr, cache_entry, tbe); 21414184Sgabeblack@google.com } 21514184Sgabeblack@google.com else if (in_msg.Type == CoherenceRequestType:WB_ACK) { 21614184Sgabeblack@google.com trigger(Event:Writeback_Ack, in_msg.addr, cache_entry, tbe); 21714184Sgabeblack@google.com } 21814184Sgabeblack@google.com else if (in_msg.Type == CoherenceRequestType:WB_NACK) { 21914184Sgabeblack@google.com trigger(Event:Writeback_Nack, in_msg.addr, cache_entry, tbe); 22014184Sgabeblack@google.com } 22114184Sgabeblack@google.com else if (in_msg.Type == CoherenceRequestType:INV) { 22214184Sgabeblack@google.com trigger(Event:Inv, in_msg.addr, cache_entry, tbe); 22314184Sgabeblack@google.com } 22414184Sgabeblack@google.com else { 22514184Sgabeblack@google.com error("Unexpected message"); 22614184Sgabeblack@google.com } 22714184Sgabeblack@google.com } 22814184Sgabeblack@google.com } 22914184Sgabeblack@google.com } 23014184Sgabeblack@google.com 23114184Sgabeblack@google.com in_port(responseNetwork_in, ResponseMsg, responseToCache) { 23214184Sgabeblack@google.com if (responseNetwork_in.isReady(clockEdge())) { 23314184Sgabeblack@google.com peek(responseNetwork_in, ResponseMsg, block_on="addr") { 23414184Sgabeblack@google.com 23514184Sgabeblack@google.com Entry cache_entry := getCacheEntry(in_msg.addr); 23614184Sgabeblack@google.com TBE tbe := TBEs[in_msg.addr]; 23714184Sgabeblack@google.com 23814184Sgabeblack@google.com if (in_msg.Type == CoherenceResponseType:DATA) { 23914184Sgabeblack@google.com trigger(Event:Data, in_msg.addr, cache_entry, tbe); 24014184Sgabeblack@google.com } 24114184Sgabeblack@google.com else { 24214184Sgabeblack@google.com error("Unexpected message"); 24314184Sgabeblack@google.com } 24414184Sgabeblack@google.com } 24514184Sgabeblack@google.com } 24614184Sgabeblack@google.com } 24714184Sgabeblack@google.com 24814184Sgabeblack@google.com // Mandatory Queue 24914184Sgabeblack@google.com in_port(mandatoryQueue_in, RubyRequest, mandatoryQueue, desc="...") { 25014184Sgabeblack@google.com if (mandatoryQueue_in.isReady(clockEdge())) { 25114184Sgabeblack@google.com peek(mandatoryQueue_in, RubyRequest, block_on="LineAddress") { 25214184Sgabeblack@google.com 25314184Sgabeblack@google.com Entry cache_entry := getCacheEntry(in_msg.LineAddress); 25414184Sgabeblack@google.com if (is_invalid(cache_entry) && 25514184Sgabeblack@google.com cacheMemory.cacheAvail(in_msg.LineAddress) == false ) { 25614184Sgabeblack@google.com // make room for the block 25714184Sgabeblack@google.com // Check if the line we want to evict is not locked 25814184Sgabeblack@google.com Addr addr := cacheMemory.cacheProbe(in_msg.LineAddress); 25914184Sgabeblack@google.com check_on_cache_probe(mandatoryQueue_in, addr); 26014184Sgabeblack@google.com trigger(Event:Replacement, addr, 26114184Sgabeblack@google.com getCacheEntry(addr), 26214184Sgabeblack@google.com TBEs[addr]); 26314184Sgabeblack@google.com } 26414184Sgabeblack@google.com else { 26514184Sgabeblack@google.com trigger(mandatory_request_type_to_event(in_msg.Type), in_msg.LineAddress, 26614184Sgabeblack@google.com cache_entry, TBEs[in_msg.LineAddress]); 26714184Sgabeblack@google.com } 26814184Sgabeblack@google.com } 26914184Sgabeblack@google.com } 27014184Sgabeblack@google.com } 27114184Sgabeblack@google.com 27214184Sgabeblack@google.com // ACTIONS 27314184Sgabeblack@google.com 27414184Sgabeblack@google.com action(a_issueRequest, "a", desc="Issue a request") { 27514184Sgabeblack@google.com enqueue(requestNetwork_out, RequestMsg, issue_latency) { 27614184Sgabeblack@google.com out_msg.addr := address; 27714184Sgabeblack@google.com out_msg.Type := CoherenceRequestType:GETX; 27814184Sgabeblack@google.com out_msg.Requestor := machineID; 27914184Sgabeblack@google.com out_msg.Destination.add(mapAddressToMachine(address, MachineType:Directory)); 28014184Sgabeblack@google.com out_msg.MessageSize := MessageSizeType:Control; 28114184Sgabeblack@google.com } 28214184Sgabeblack@google.com } 28314184Sgabeblack@google.com 28414184Sgabeblack@google.com action(b_issuePUT, "b", desc="Issue a PUT request") { 28514184Sgabeblack@google.com enqueue(requestNetwork_out, RequestMsg, issue_latency) { 28614184Sgabeblack@google.com assert(is_valid(cache_entry)); 28714184Sgabeblack@google.com out_msg.addr := address; 28814184Sgabeblack@google.com out_msg.Type := CoherenceRequestType:PUTX; 28914184Sgabeblack@google.com out_msg.Requestor := machineID; 29014184Sgabeblack@google.com out_msg.Destination.add(mapAddressToMachine(address, MachineType:Directory)); 29114184Sgabeblack@google.com out_msg.DataBlk := cache_entry.DataBlk; 29214184Sgabeblack@google.com out_msg.MessageSize := MessageSizeType:Data; 29314184Sgabeblack@google.com } 29414184Sgabeblack@google.com } 29514184Sgabeblack@google.com 29614184Sgabeblack@google.com action(e_sendData, "e", desc="Send data from cache to requestor") { 29714184Sgabeblack@google.com peek(forwardRequestNetwork_in, RequestMsg) { 29814184Sgabeblack@google.com enqueue(responseNetwork_out, ResponseMsg, cache_response_latency) { 29914184Sgabeblack@google.com assert(is_valid(cache_entry)); 30014184Sgabeblack@google.com out_msg.addr := address; 30114184Sgabeblack@google.com out_msg.Type := CoherenceResponseType:DATA; 30214184Sgabeblack@google.com out_msg.Sender := machineID; 30314184Sgabeblack@google.com out_msg.Destination.add(in_msg.Requestor); 30414184Sgabeblack@google.com out_msg.DataBlk := cache_entry.DataBlk; 30514184Sgabeblack@google.com out_msg.MessageSize := MessageSizeType:Response_Data; 30614184Sgabeblack@google.com } 30714184Sgabeblack@google.com } 30814184Sgabeblack@google.com } 30914184Sgabeblack@google.com 31014184Sgabeblack@google.com action(ee_sendDataFromTBE, "\e", desc="Send data from TBE to requestor") { 31114184Sgabeblack@google.com peek(forwardRequestNetwork_in, RequestMsg) { 31214184Sgabeblack@google.com enqueue(responseNetwork_out, ResponseMsg, cache_response_latency) { 31314184Sgabeblack@google.com assert(is_valid(tbe)); 31414184Sgabeblack@google.com out_msg.addr := address; 31514184Sgabeblack@google.com out_msg.Type := CoherenceResponseType:DATA; 31614184Sgabeblack@google.com out_msg.Sender := machineID; 31714184Sgabeblack@google.com out_msg.Destination.add(in_msg.Requestor); 31814184Sgabeblack@google.com out_msg.DataBlk := tbe.DataBlk; 31914184Sgabeblack@google.com out_msg.MessageSize := MessageSizeType:Response_Data; 32014184Sgabeblack@google.com } 32114184Sgabeblack@google.com } 32214184Sgabeblack@google.com } 32314184Sgabeblack@google.com 32414184Sgabeblack@google.com action(i_allocateL1CacheBlock, "i", desc="Allocate a cache block") { 32514184Sgabeblack@google.com if (is_valid(cache_entry)) { 32614184Sgabeblack@google.com } else { 32714184Sgabeblack@google.com set_cache_entry(cacheMemory.allocate(address, new Entry)); 32814184Sgabeblack@google.com } 32914184Sgabeblack@google.com } 33014184Sgabeblack@google.com 33114184Sgabeblack@google.com action(h_deallocateL1CacheBlock, "h", desc="deallocate a cache block") { 33214184Sgabeblack@google.com if (is_valid(cache_entry)) { 33314184Sgabeblack@google.com cacheMemory.deallocate(address); 33414184Sgabeblack@google.com unset_cache_entry(); 33514184Sgabeblack@google.com } 33614184Sgabeblack@google.com } 33714184Sgabeblack@google.com 33814184Sgabeblack@google.com action(m_popMandatoryQueue, "m", desc="Pop the mandatory request queue") { 33914184Sgabeblack@google.com mandatoryQueue_in.dequeue(clockEdge()); 34014184Sgabeblack@google.com } 34114184Sgabeblack@google.com 34214184Sgabeblack@google.com action(n_popResponseQueue, "n", desc="Pop the response queue") { 34314184Sgabeblack@google.com Tick delay := responseNetwork_in.dequeue(clockEdge()); 34414184Sgabeblack@google.com profileMsgDelay(1, ticksToCycles(delay)); 34514184Sgabeblack@google.com } 34614184Sgabeblack@google.com 34714184Sgabeblack@google.com action(o_popForwardedRequestQueue, "o", desc="Pop the forwarded request queue") { 34814184Sgabeblack@google.com Tick delay := forwardRequestNetwork_in.dequeue(clockEdge()); 34914184Sgabeblack@google.com profileMsgDelay(2, ticksToCycles(delay)); 35014184Sgabeblack@google.com } 35114184Sgabeblack@google.com 35214184Sgabeblack@google.com action(p_profileMiss, "pi", desc="Profile cache miss") { 35314184Sgabeblack@google.com ++cacheMemory.demand_misses; 35414184Sgabeblack@google.com } 35514184Sgabeblack@google.com 35614184Sgabeblack@google.com action(p_profileHit, "ph", desc="Profile cache miss") { 35714184Sgabeblack@google.com ++cacheMemory.demand_hits; 35814184Sgabeblack@google.com } 35914184Sgabeblack@google.com 36014184Sgabeblack@google.com action(r_load_hit, "r", desc="Notify sequencer the load completed.") { 36114184Sgabeblack@google.com assert(is_valid(cache_entry)); 36214184Sgabeblack@google.com DPRINTF(RubySlicc,"%s\n", cache_entry.DataBlk); 36314184Sgabeblack@google.com cacheMemory.setMRU(cache_entry); 36414184Sgabeblack@google.com sequencer.readCallback(address, cache_entry.DataBlk, false); 36514184Sgabeblack@google.com } 36614184Sgabeblack@google.com 36714184Sgabeblack@google.com action(rx_load_hit, "rx", desc="External load completed.") { 36814184Sgabeblack@google.com peek(responseNetwork_in, ResponseMsg) { 36914184Sgabeblack@google.com assert(is_valid(cache_entry)); 37014184Sgabeblack@google.com DPRINTF(RubySlicc,"%s\n", cache_entry.DataBlk); 37114184Sgabeblack@google.com cacheMemory.setMRU(cache_entry); 37214184Sgabeblack@google.com sequencer.readCallback(address, cache_entry.DataBlk, true, 37314184Sgabeblack@google.com machineIDToMachineType(in_msg.Sender)); 37414184Sgabeblack@google.com } 37514184Sgabeblack@google.com } 37614184Sgabeblack@google.com 37714184Sgabeblack@google.com action(s_store_hit, "s", desc="Notify sequencer that store completed.") { 37814184Sgabeblack@google.com assert(is_valid(cache_entry)); 37914184Sgabeblack@google.com DPRINTF(RubySlicc,"%s\n", cache_entry.DataBlk); 38014184Sgabeblack@google.com cacheMemory.setMRU(cache_entry); 38114184Sgabeblack@google.com sequencer.writeCallback(address, cache_entry.DataBlk, false); 38214184Sgabeblack@google.com } 38314184Sgabeblack@google.com 38414184Sgabeblack@google.com action(sx_store_hit, "sx", desc="External store completed.") { 38514184Sgabeblack@google.com peek(responseNetwork_in, ResponseMsg) { 38614184Sgabeblack@google.com assert(is_valid(cache_entry)); 38714184Sgabeblack@google.com DPRINTF(RubySlicc,"%s\n", cache_entry.DataBlk); 38814184Sgabeblack@google.com cacheMemory.setMRU(cache_entry); 38914184Sgabeblack@google.com sequencer.writeCallback(address, cache_entry.DataBlk, true, 39014184Sgabeblack@google.com machineIDToMachineType(in_msg.Sender)); 39114184Sgabeblack@google.com } 39214184Sgabeblack@google.com } 39314184Sgabeblack@google.com 39414184Sgabeblack@google.com action(u_writeDataToCache, "u", desc="Write data to the cache") { 39514184Sgabeblack@google.com peek(responseNetwork_in, ResponseMsg) { 39614184Sgabeblack@google.com assert(is_valid(cache_entry)); 39714184Sgabeblack@google.com cache_entry.DataBlk := in_msg.DataBlk; 39814184Sgabeblack@google.com } 39914184Sgabeblack@google.com } 40014184Sgabeblack@google.com 40114184Sgabeblack@google.com action(forward_eviction_to_cpu, "\cc", desc="sends eviction information to the processor") { 40214184Sgabeblack@google.com if (send_evictions) { 40314184Sgabeblack@google.com DPRINTF(RubySlicc, "Sending invalidation for %#x to the CPU\n", address); 40414184Sgabeblack@google.com sequencer.evictionCallback(address); 40514184Sgabeblack@google.com } 40614184Sgabeblack@google.com } 40714184Sgabeblack@google.com 40814184Sgabeblack@google.com action(v_allocateTBE, "v", desc="Allocate TBE") { 40914184Sgabeblack@google.com TBEs.allocate(address); 41014184Sgabeblack@google.com set_tbe(TBEs[address]); 41114184Sgabeblack@google.com } 41214184Sgabeblack@google.com 41314184Sgabeblack@google.com action(w_deallocateTBE, "w", desc="Deallocate TBE") { 41414184Sgabeblack@google.com TBEs.deallocate(address); 41514184Sgabeblack@google.com unset_tbe(); 41614184Sgabeblack@google.com } 41714184Sgabeblack@google.com 41814184Sgabeblack@google.com action(x_copyDataFromCacheToTBE, "x", desc="Copy data from cache to TBE") { 41914184Sgabeblack@google.com assert(is_valid(cache_entry)); 42014184Sgabeblack@google.com assert(is_valid(tbe)); 42114184Sgabeblack@google.com tbe.DataBlk := cache_entry.DataBlk; 42214184Sgabeblack@google.com } 42314184Sgabeblack@google.com 42414184Sgabeblack@google.com action(z_stall, "z", desc="stall") { 42514184Sgabeblack@google.com // do nothing 42614184Sgabeblack@google.com } 42714184Sgabeblack@google.com 42814184Sgabeblack@google.com // TRANSITIONS 42914184Sgabeblack@google.com 43014184Sgabeblack@google.com transition({IS, IM, MI, II, MII}, {Load, Ifetch, Store, Replacement}) { 43114184Sgabeblack@google.com z_stall; 43214184Sgabeblack@google.com } 43314184Sgabeblack@google.com 43414184Sgabeblack@google.com transition({IS, IM}, {Fwd_GETX, Inv}) { 43514184Sgabeblack@google.com z_stall; 43614184Sgabeblack@google.com } 43714184Sgabeblack@google.com 43814184Sgabeblack@google.com transition(MI, Inv) { 43914184Sgabeblack@google.com o_popForwardedRequestQueue; 44014184Sgabeblack@google.com } 44114184Sgabeblack@google.com 44214184Sgabeblack@google.com transition(M, Store) { 44314184Sgabeblack@google.com s_store_hit; 44414184Sgabeblack@google.com p_profileHit; 44514184Sgabeblack@google.com m_popMandatoryQueue; 44614184Sgabeblack@google.com } 44714184Sgabeblack@google.com 44814184Sgabeblack@google.com transition(M, {Load, Ifetch}) { 44914184Sgabeblack@google.com r_load_hit; 45014184Sgabeblack@google.com p_profileHit; 45114184Sgabeblack@google.com m_popMandatoryQueue; 45214184Sgabeblack@google.com } 45314184Sgabeblack@google.com 45414184Sgabeblack@google.com transition(I, Inv) { 45514184Sgabeblack@google.com o_popForwardedRequestQueue; 45614184Sgabeblack@google.com } 45714184Sgabeblack@google.com 45814184Sgabeblack@google.com transition(I, Store, IM) { 45914184Sgabeblack@google.com v_allocateTBE; 46014184Sgabeblack@google.com i_allocateL1CacheBlock; 46114184Sgabeblack@google.com a_issueRequest; 46214184Sgabeblack@google.com p_profileMiss; 46314184Sgabeblack@google.com m_popMandatoryQueue; 46414184Sgabeblack@google.com } 46514184Sgabeblack@google.com 46614184Sgabeblack@google.com transition(I, {Load, Ifetch}, IS) { 46714184Sgabeblack@google.com v_allocateTBE; 46814184Sgabeblack@google.com i_allocateL1CacheBlock; 46914184Sgabeblack@google.com a_issueRequest; 47014184Sgabeblack@google.com p_profileMiss; 47114184Sgabeblack@google.com m_popMandatoryQueue; 47214184Sgabeblack@google.com } 47314184Sgabeblack@google.com 47414184Sgabeblack@google.com transition(IS, Data, M) { 47514184Sgabeblack@google.com u_writeDataToCache; 47614184Sgabeblack@google.com rx_load_hit; 47714184Sgabeblack@google.com w_deallocateTBE; 47814184Sgabeblack@google.com n_popResponseQueue; 47914184Sgabeblack@google.com } 48014184Sgabeblack@google.com 48114184Sgabeblack@google.com transition(IM, Data, M) { 48214184Sgabeblack@google.com u_writeDataToCache; 48314184Sgabeblack@google.com sx_store_hit; 48414184Sgabeblack@google.com w_deallocateTBE; 48514184Sgabeblack@google.com n_popResponseQueue; 48614184Sgabeblack@google.com } 48714184Sgabeblack@google.com 48814184Sgabeblack@google.com transition(M, Fwd_GETX, I) { 48914184Sgabeblack@google.com e_sendData; 49014184Sgabeblack@google.com forward_eviction_to_cpu; 49114184Sgabeblack@google.com o_popForwardedRequestQueue; 49214184Sgabeblack@google.com } 49314184Sgabeblack@google.com 49414184Sgabeblack@google.com transition(I, Replacement) { 49514184Sgabeblack@google.com h_deallocateL1CacheBlock; 49614184Sgabeblack@google.com } 49714184Sgabeblack@google.com 49814184Sgabeblack@google.com transition(M, {Replacement,Inv}, MI) { 49914184Sgabeblack@google.com v_allocateTBE; 50014184Sgabeblack@google.com b_issuePUT; 50114184Sgabeblack@google.com x_copyDataFromCacheToTBE; 50214184Sgabeblack@google.com forward_eviction_to_cpu; 50314184Sgabeblack@google.com h_deallocateL1CacheBlock; 50414184Sgabeblack@google.com } 50514184Sgabeblack@google.com 50614184Sgabeblack@google.com transition(MI, Writeback_Ack, I) { 50714184Sgabeblack@google.com w_deallocateTBE; 50814184Sgabeblack@google.com o_popForwardedRequestQueue; 50914184Sgabeblack@google.com } 51014184Sgabeblack@google.com 51114184Sgabeblack@google.com transition(MI, Fwd_GETX, II) { 51214184Sgabeblack@google.com ee_sendDataFromTBE; 51314184Sgabeblack@google.com o_popForwardedRequestQueue; 51414184Sgabeblack@google.com } 51514184Sgabeblack@google.com 51614184Sgabeblack@google.com transition(MI, Writeback_Nack, MII) { 51714184Sgabeblack@google.com o_popForwardedRequestQueue; 51814184Sgabeblack@google.com } 51914184Sgabeblack@google.com 52014184Sgabeblack@google.com transition(MII, Fwd_GETX, I) { 52114184Sgabeblack@google.com ee_sendDataFromTBE; 52214184Sgabeblack@google.com w_deallocateTBE; 52314184Sgabeblack@google.com o_popForwardedRequestQueue; 52414184Sgabeblack@google.com } 52514184Sgabeblack@google.com 52614184Sgabeblack@google.com transition(II, Writeback_Nack, I) { 52714184Sgabeblack@google.com w_deallocateTBE; 52814184Sgabeblack@google.com o_popForwardedRequestQueue; 52914184Sgabeblack@google.com } 53014184Sgabeblack@google.com} 531