Sequencer.hh revision 6151
16145Snate@binkert.org 26145Snate@binkert.org/* 36145Snate@binkert.org * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 46145Snate@binkert.org * All rights reserved. 56145Snate@binkert.org * 66145Snate@binkert.org * Redistribution and use in source and binary forms, with or without 76145Snate@binkert.org * modification, are permitted provided that the following conditions are 86145Snate@binkert.org * met: redistributions of source code must retain the above copyright 96145Snate@binkert.org * notice, this list of conditions and the following disclaimer; 106145Snate@binkert.org * redistributions in binary form must reproduce the above copyright 116145Snate@binkert.org * notice, this list of conditions and the following disclaimer in the 126145Snate@binkert.org * documentation and/or other materials provided with the distribution; 136145Snate@binkert.org * neither the name of the copyright holders nor the names of its 146145Snate@binkert.org * contributors may be used to endorse or promote products derived from 156145Snate@binkert.org * this software without specific prior written permission. 166145Snate@binkert.org * 176145Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 186145Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 196145Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 206145Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 216145Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 226145Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 236145Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 246145Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 256145Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 266145Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 276145Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 286145Snate@binkert.org */ 296145Snate@binkert.org 306145Snate@binkert.org/* 316145Snate@binkert.org * $Id: Sequencer.h 1.70 2006/09/27 14:56:41-05:00 bobba@s1-01.cs.wisc.edu $ 326145Snate@binkert.org * 336145Snate@binkert.org * Description: 346145Snate@binkert.org * 356145Snate@binkert.org */ 366145Snate@binkert.org 376145Snate@binkert.org#ifndef SEQUENCER_H 386145Snate@binkert.org#define SEQUENCER_H 396145Snate@binkert.org 406145Snate@binkert.org#include "Global.hh" 416145Snate@binkert.org#include "RubyConfig.hh" 426145Snate@binkert.org#include "Consumer.hh" 436145Snate@binkert.org#include "CacheRequestType.hh" 446145Snate@binkert.org#include "AccessModeType.hh" 456145Snate@binkert.org#include "GenericMachineType.hh" 466145Snate@binkert.org#include "PrefetchBit.hh" 476145Snate@binkert.org#include "Map.hh" 486151Sdrh5@cs.wisc.edu#include "packet.hh" 496145Snate@binkert.org 506145Snate@binkert.orgclass DataBlock; 516145Snate@binkert.orgclass AbstractChip; 526145Snate@binkert.orgclass CacheMsg; 536145Snate@binkert.orgclass Address; 546145Snate@binkert.orgclass MachineID; 556145Snate@binkert.org 566145Snate@binkert.orgclass Sequencer : public Consumer { 576145Snate@binkert.orgpublic: 586145Snate@binkert.org // Constructors 596145Snate@binkert.org Sequencer(AbstractChip* chip_ptr, int version); 606145Snate@binkert.org 616145Snate@binkert.org // Destructor 626145Snate@binkert.org ~Sequencer(); 636145Snate@binkert.org 646145Snate@binkert.org // Public Methods 656145Snate@binkert.org void wakeup(); // Used only for deadlock detection 666145Snate@binkert.org 676145Snate@binkert.org static void printConfig(ostream& out); 686145Snate@binkert.org 696145Snate@binkert.org // returns total number of outstanding request (includes prefetches) 706145Snate@binkert.org int getNumberOutstanding(); 716145Snate@binkert.org // return only total number of outstanding demand requests 726145Snate@binkert.org int getNumberOutstandingDemand(); 736145Snate@binkert.org // return only total number of outstanding prefetch requests 746145Snate@binkert.org int getNumberOutstandingPrefetch(); 756145Snate@binkert.org 766145Snate@binkert.org // remove load/store request from queue 776145Snate@binkert.org void removeLoadRequest(const Address & addr, int thread); 786145Snate@binkert.org void removeStoreRequest(const Address & addr, int thread); 796145Snate@binkert.org 806145Snate@binkert.org void printProgress(ostream& out) const; 816145Snate@binkert.org 826145Snate@binkert.org // returns a pointer to the request in the request tables 836145Snate@binkert.org CacheMsg & getReadRequest( const Address & addr, int thread ); 846145Snate@binkert.org CacheMsg & getWriteRequest( const Address & addr, int thread ); 856145Snate@binkert.org 866145Snate@binkert.org // called by Ruby when transaction completes 876145Snate@binkert.org void writeConflictCallback(const Address& address); 886145Snate@binkert.org void readConflictCallback(const Address& address); 896145Snate@binkert.org void writeConflictCallback(const Address& address, GenericMachineType respondingMach, int thread); 906145Snate@binkert.org void readConflictCallback(const Address& address, GenericMachineType respondingMach, int thread); 916145Snate@binkert.org 926145Snate@binkert.org void writeCallback(const Address& address, DataBlock& data); 936145Snate@binkert.org void readCallback(const Address& address, DataBlock& data); 946145Snate@binkert.org void writeCallback(const Address& address); 956145Snate@binkert.org void readCallback(const Address& address); 966145Snate@binkert.org void writeCallback(const Address& address, DataBlock& data, GenericMachineType respondingMach, PrefetchBit pf, int thread); 976145Snate@binkert.org void readCallback(const Address& address, DataBlock& data, GenericMachineType respondingMach, PrefetchBit pf, int thread); 986145Snate@binkert.org void writeCallback(const Address& address, DataBlock& data, GenericMachineType respondingMach, int thread); 996145Snate@binkert.org void readCallback(const Address& address, DataBlock& data, GenericMachineType respondingMach, int thread); 1006145Snate@binkert.org 1016145Snate@binkert.org // returns the thread ID of the request 1026145Snate@binkert.org int getRequestThreadID(const Address & addr); 1036145Snate@binkert.org // returns the physical address of the request 1046145Snate@binkert.org Address getRequestPhysicalAddress(const Address & lineaddr); 1056145Snate@binkert.org // returns whether a request is a prefetch request 1066145Snate@binkert.org bool isPrefetchRequest(const Address & lineaddr); 1076145Snate@binkert.org 1086145Snate@binkert.org //notifies driver of debug print 1096145Snate@binkert.org void printDebug(); 1106145Snate@binkert.org 1116145Snate@binkert.org // called by Tester or Simics 1126151Sdrh5@cs.wisc.edu void makeRequest(const Packet* pkt, void* data); 1136151Sdrh5@cs.wisc.edu void makeRequest(const CacheMsg& request); // depricate this function 1146145Snate@binkert.org bool doRequest(const CacheMsg& request); 1156145Snate@binkert.org void issueRequest(const CacheMsg& request); 1166151Sdrh5@cs.wisc.edu bool isReady(const Packet* pkt) const; 1176151Sdrh5@cs.wisc.edu bool isReady(const CacheMsg& request) const; // depricate this function 1186145Snate@binkert.org bool empty() const; 1196145Snate@binkert.org void resetRequestTime(const Address& addr, int thread); 1206145Snate@binkert.org Address getLogicalAddressOfRequest(Address address, int thread); 1216145Snate@binkert.org AccessModeType getAccessModeOfRequest(Address address, int thread); 1226145Snate@binkert.org //uint64 getSequenceNumberOfRequest(Address addr, int thread); 1236145Snate@binkert.org 1246145Snate@binkert.org void print(ostream& out) const; 1256145Snate@binkert.org void checkCoherence(const Address& address); 1266145Snate@binkert.org 1276145Snate@binkert.org bool getRubyMemoryValue(const Address& addr, char* value, unsigned int size_in_bytes); 1286145Snate@binkert.org bool setRubyMemoryValue(const Address& addr, char *value, unsigned int size_in_bytes); 1296145Snate@binkert.org 1306145Snate@binkert.org void removeRequest(const CacheMsg& request); 1316145Snate@binkert.orgprivate: 1326145Snate@binkert.org // Private Methods 1336145Snate@binkert.org bool tryCacheAccess(const Address& addr, CacheRequestType type, const Address& pc, AccessModeType access_mode, int size, DataBlock*& data_ptr); 1346145Snate@binkert.org void conflictCallback(const CacheMsg& request, GenericMachineType respondingMach, int thread); 1356145Snate@binkert.org void hitCallback(const CacheMsg& request, DataBlock& data, GenericMachineType respondingMach, int thread); 1366145Snate@binkert.org bool insertRequest(const CacheMsg& request); 1376145Snate@binkert.org 1386145Snate@binkert.org 1396145Snate@binkert.org // Private copy constructor and assignment operator 1406145Snate@binkert.org Sequencer(const Sequencer& obj); 1416145Snate@binkert.org Sequencer& operator=(const Sequencer& obj); 1426145Snate@binkert.org 1436145Snate@binkert.org // Data Members (m_ prefix) 1446145Snate@binkert.org AbstractChip* m_chip_ptr; 1456145Snate@binkert.org 1466145Snate@binkert.org // indicates what processor on the chip this sequencer is associated with 1476145Snate@binkert.org int m_version; 1486145Snate@binkert.org 1496145Snate@binkert.org // One request table per SMT thread 1506145Snate@binkert.org Map<Address, CacheMsg>** m_writeRequestTable_ptr; 1516145Snate@binkert.org Map<Address, CacheMsg>** m_readRequestTable_ptr; 1526145Snate@binkert.org // Global outstanding request count, across all request tables 1536145Snate@binkert.org int m_outstanding_count; 1546145Snate@binkert.org bool m_deadlock_check_scheduled; 1556145Snate@binkert.org 1566145Snate@binkert.org}; 1576145Snate@binkert.org 1586145Snate@binkert.org// Output operator declaration 1596145Snate@binkert.orgostream& operator<<(ostream& out, const Sequencer& obj); 1606145Snate@binkert.org 1616145Snate@binkert.org// ******************* Definitions ******************* 1626145Snate@binkert.org 1636145Snate@binkert.org// Output operator definition 1646145Snate@binkert.orgextern inline 1656145Snate@binkert.orgostream& operator<<(ostream& out, const Sequencer& obj) 1666145Snate@binkert.org{ 1676145Snate@binkert.org obj.print(out); 1686145Snate@binkert.org out << flush; 1696145Snate@binkert.org return out; 1706145Snate@binkert.org} 1716145Snate@binkert.org 1726145Snate@binkert.org#endif //SEQUENCER_H 1736145Snate@binkert.org 174