114184Sgabeblack@google.com/* 214184Sgabeblack@google.com * Copyright (c) 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.com// Various class of messages that can be exchanged between the L0 and the L1 3014184Sgabeblack@google.com// controllers. 3114184Sgabeblack@google.comenumeration(CoherenceClass, desc="...") { 3214184Sgabeblack@google.com GETX, desc="Get eXclusive"; 3314184Sgabeblack@google.com UPGRADE, desc="UPGRADE to exclusive"; 3414184Sgabeblack@google.com GETS, desc="Get Shared"; 3514184Sgabeblack@google.com GET_INSTR, desc="Get Instruction"; 3614184Sgabeblack@google.com INV, desc="INValidate"; 3714184Sgabeblack@google.com PUTX, desc="Replacement message"; 3814184Sgabeblack@google.com 3914184Sgabeblack@google.com WB_ACK, desc="Writeback ack"; 4014184Sgabeblack@google.com 4114184Sgabeblack@google.com // Request types for sending data and acks from L0 to L1 cache 4214184Sgabeblack@google.com // when an invalidation message is received. 4314184Sgabeblack@google.com INV_DATA; 4414184Sgabeblack@google.com INV_ACK; 4514184Sgabeblack@google.com 4614184Sgabeblack@google.com DATA, desc="Data block for L1 cache in S state"; 4714184Sgabeblack@google.com DATA_EXCLUSIVE, desc="Data block for L1 cache in M/E state"; 4814184Sgabeblack@google.com ACK, desc="Generic invalidate ack"; 4914184Sgabeblack@google.com 5014184Sgabeblack@google.com // This is a special case in which the L1 cache lost permissions to the 5114184Sgabeblack@google.com // shared block before it got the data. So the L0 cache can use the data 5214184Sgabeblack@google.com // but not store it. 5314184Sgabeblack@google.com STALE_DATA; 5414184Sgabeblack@google.com} 5514184Sgabeblack@google.com 5614184Sgabeblack@google.com// Class for messages sent between the L0 and the L1 controllers. 5714184Sgabeblack@google.comstructure(CoherenceMsg, desc="...", interface="Message") { 5814184Sgabeblack@google.com Addr addr, desc="Physical address of the cache block"; 5914184Sgabeblack@google.com CoherenceClass Class, desc="Type of message (GetS, GetX, PutX, etc)"; 6014184Sgabeblack@google.com RubyAccessMode AccessMode, desc="user/supervisor access type"; 6114184Sgabeblack@google.com MachineID Sender, desc="What component sent this message"; 6214184Sgabeblack@google.com MachineID Dest, desc="What machine receives this message"; 6314184Sgabeblack@google.com MessageSizeType MessageSize, desc="size category of the message"; 6414184Sgabeblack@google.com DataBlock DataBlk, desc="Data for the cache line (if PUTX)"; 6514184Sgabeblack@google.com bool Dirty, default="false", desc="Dirty bit"; 6614184Sgabeblack@google.com 6714184Sgabeblack@google.com bool functionalRead(Packet *pkt) { 6814184Sgabeblack@google.com // Only PUTX messages contains the data block 6914184Sgabeblack@google.com if (Class == CoherenceClass:PUTX) { 7014184Sgabeblack@google.com return testAndRead(addr, DataBlk, pkt); 7114184Sgabeblack@google.com } 7214184Sgabeblack@google.com 7314184Sgabeblack@google.com return false; 7414184Sgabeblack@google.com } 7514184Sgabeblack@google.com 7614184Sgabeblack@google.com bool functionalWrite(Packet *pkt) { 7714184Sgabeblack@google.com // No check on message type required since the protocol should 7814184Sgabeblack@google.com // read data from those messages that contain the block 7914184Sgabeblack@google.com return testAndWrite(addr, DataBlk, pkt); 8014184Sgabeblack@google.com } 8114184Sgabeblack@google.com} 82