Sequencer.hh revision 6154
17008Snate@binkert.org 27008Snate@binkert.org/* 37008Snate@binkert.org * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 47008Snate@binkert.org * All rights reserved. 57008Snate@binkert.org * 67008Snate@binkert.org * Redistribution and use in source and binary forms, with or without 77008Snate@binkert.org * modification, are permitted provided that the following conditions are 87008Snate@binkert.org * met: redistributions of source code must retain the above copyright 97008Snate@binkert.org * notice, this list of conditions and the following disclaimer; 107008Snate@binkert.org * redistributions in binary form must reproduce the above copyright 117008Snate@binkert.org * notice, this list of conditions and the following disclaimer in the 127008Snate@binkert.org * documentation and/or other materials provided with the distribution; 137008Snate@binkert.org * neither the name of the copyright holders nor the names of its 147008Snate@binkert.org * contributors may be used to endorse or promote products derived from 157008Snate@binkert.org * this software without specific prior written permission. 167008Snate@binkert.org * 177008Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 187008Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 197008Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 207008Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 217008Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 227008Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 237008Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 247008Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 257008Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 267008Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 277008Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 286285Snate@binkert.org */ 297039Snate@binkert.org 307039Snate@binkert.org/* 316285Snate@binkert.org * $Id: Sequencer.h 1.70 2006/09/27 14:56:41-05:00 bobba@s1-01.cs.wisc.edu $ 326285Snate@binkert.org * 337039Snate@binkert.org * Description: 346285Snate@binkert.org * 356285Snate@binkert.org */ 366876Ssteve.reinhardt@amd.com 377039Snate@binkert.org#ifndef SEQUENCER_H 386285Snate@binkert.org#define SEQUENCER_H 396285Snate@binkert.org 406285Snate@binkert.org#include "mem/ruby/common/Global.hh" 417039Snate@binkert.org#include "mem/ruby/config/RubyConfig.hh" 427039Snate@binkert.org#include "mem/ruby/common/Consumer.hh" 436285Snate@binkert.org#include "mem/protocol/CacheRequestType.hh" 447039Snate@binkert.org#include "mem/protocol/AccessModeType.hh" 457039Snate@binkert.org#include "mem/protocol/GenericMachineType.hh" 467039Snate@binkert.org#include "mem/protocol/PrefetchBit.hh" 476285Snate@binkert.org#include "mem/gems_common/Map.hh" 486285Snate@binkert.org#include "mem/packet.hh" 497039Snate@binkert.org 507039Snate@binkert.orgclass DataBlock; 516285Snate@binkert.orgclass AbstractChip; 527039Snate@binkert.orgclass CacheMsg; 537039Snate@binkert.orgclass Address; 547039Snate@binkert.orgclass MachineID; 557039Snate@binkert.org 567039Snate@binkert.orgclass Sequencer : public Consumer { 577039Snate@binkert.orgpublic: 587039Snate@binkert.org // Constructors 597039Snate@binkert.org Sequencer(AbstractChip* chip_ptr, int version); 607039Snate@binkert.org 617039Snate@binkert.org // Destructor 627039Snate@binkert.org ~Sequencer(); 637039Snate@binkert.org 647039Snate@binkert.org // Public Methods 657039Snate@binkert.org void wakeup(); // Used only for deadlock detection 667039Snate@binkert.org 677039Snate@binkert.org static void printConfig(ostream& out); 687039Snate@binkert.org 697039Snate@binkert.org // returns total number of outstanding request (includes prefetches) 707039Snate@binkert.org int getNumberOutstanding(); 717039Snate@binkert.org // return only total number of outstanding demand requests 727039Snate@binkert.org int getNumberOutstandingDemand(); 736285Snate@binkert.org // return only total number of outstanding prefetch requests 747039Snate@binkert.org int getNumberOutstandingPrefetch(); 757039Snate@binkert.org 766285Snate@binkert.org // remove load/store request from queue 777039Snate@binkert.org void removeLoadRequest(const Address & addr, int thread); 787039Snate@binkert.org void removeStoreRequest(const Address & addr, int thread); 797039Snate@binkert.org 807039Snate@binkert.org void printProgress(ostream& out) const; 817039Snate@binkert.org 827039Snate@binkert.org // returns a pointer to the request in the request tables 837039Snate@binkert.org CacheMsg & getReadRequest( const Address & addr, int thread ); 846285Snate@binkert.org CacheMsg & getWriteRequest( const Address & addr, int thread ); 857039Snate@binkert.org 867039Snate@binkert.org void writeCallback(const Address& address, DataBlock& data); 877039Snate@binkert.org void readCallback(const Address& address, DataBlock& data); 887039Snate@binkert.org void writeCallback(const Address& address); 897039Snate@binkert.org void readCallback(const Address& address); 906888SBrad.Beckmann@amd.com void writeCallback(const Address& address, DataBlock& data, GenericMachineType respondingMach, PrefetchBit pf, int thread); 917039Snate@binkert.org void readCallback(const Address& address, DataBlock& data, GenericMachineType respondingMach, PrefetchBit pf, int thread); 927039Snate@binkert.org void writeCallback(const Address& address, DataBlock& data, GenericMachineType respondingMach, int thread); 936888SBrad.Beckmann@amd.com void readCallback(const Address& address, DataBlock& data, GenericMachineType respondingMach, int thread); 947039Snate@binkert.org 957039Snate@binkert.org // returns the thread ID of the request 967039Snate@binkert.org int getRequestThreadID(const Address & addr); 976888SBrad.Beckmann@amd.com // returns the physical address of the request 987039Snate@binkert.org Address getRequestPhysicalAddress(const Address & lineaddr); 997039Snate@binkert.org // returns whether a request is a prefetch request 1007039Snate@binkert.org bool isPrefetchRequest(const Address & lineaddr); 1016285Snate@binkert.org 1027039Snate@binkert.org //notifies driver of debug print 1036285Snate@binkert.org void printDebug(); 1046285Snate@binkert.org 1057039Snate@binkert.org // called by Tester or Simics 1067039Snate@binkert.org void makeRequest(const Packet* pkt, void* data); 1076285Snate@binkert.org void makeRequest(const CacheMsg& request); // depricate this function 1087039Snate@binkert.org bool doRequest(const CacheMsg& request); 1097039Snate@binkert.org void issueRequest(const CacheMsg& request); 1107039Snate@binkert.org bool isReady(const Packet* pkt) const; 1117039Snate@binkert.org bool isReady(const CacheMsg& request) const; // depricate this function 1127039Snate@binkert.org bool empty() const; 1137039Snate@binkert.org void resetRequestTime(const Address& addr, int thread); 1147039Snate@binkert.org Address getLogicalAddressOfRequest(Address address, int thread); 1156285Snate@binkert.org AccessModeType getAccessModeOfRequest(Address address, int thread); 1167039Snate@binkert.org //uint64 getSequenceNumberOfRequest(Address addr, int thread); 1177039Snate@binkert.org 1187039Snate@binkert.org void print(ostream& out) const; 1196888SBrad.Beckmann@amd.com void checkCoherence(const Address& address); 1207039Snate@binkert.org 1217039Snate@binkert.org bool getRubyMemoryValue(const Address& addr, char* value, unsigned int size_in_bytes); 1226888SBrad.Beckmann@amd.com bool setRubyMemoryValue(const Address& addr, char *value, unsigned int size_in_bytes); 1237039Snate@binkert.org 1247039Snate@binkert.org void removeRequest(const CacheMsg& request); 1256888SBrad.Beckmann@amd.comprivate: 1267039Snate@binkert.org // Private Methods 1277039Snate@binkert.org bool tryCacheAccess(const Address& addr, CacheRequestType type, const Address& pc, AccessModeType access_mode, int size, DataBlock*& data_ptr); 1287039Snate@binkert.org // void conflictCallback(const CacheMsg& request, GenericMachineType respondingMach, int thread); 1297039Snate@binkert.org void hitCallback(const CacheMsg& request, DataBlock& data, GenericMachineType respondingMach, int thread); 1307039Snate@binkert.org bool insertRequest(const CacheMsg& request); 1316888SBrad.Beckmann@amd.com 1327039Snate@binkert.org 1337039Snate@binkert.org // Private copy constructor and assignment operator 1347039Snate@binkert.org Sequencer(const Sequencer& obj); 1357039Snate@binkert.org Sequencer& operator=(const Sequencer& obj); 1367039Snate@binkert.org 1377039Snate@binkert.org // Data Members (m_ prefix) 1387039Snate@binkert.org AbstractChip* m_chip_ptr; 1397039Snate@binkert.org 1406888SBrad.Beckmann@amd.com // indicates what processor on the chip this sequencer is associated with 1417039Snate@binkert.org int m_version; 1427039Snate@binkert.org 1437039Snate@binkert.org // One request table per SMT thread 1446285Snate@binkert.org Map<Address, CacheMsg>** m_writeRequestTable_ptr; 1456285Snate@binkert.org Map<Address, CacheMsg>** m_readRequestTable_ptr; 1467039Snate@binkert.org // Global outstanding request count, across all request tables 1477039Snate@binkert.org int m_outstanding_count; 1486285Snate@binkert.org bool m_deadlock_check_scheduled; 1497039Snate@binkert.org 1507039Snate@binkert.org}; 1517039Snate@binkert.org 1527039Snate@binkert.org// Output operator declaration 1537039Snate@binkert.orgostream& operator<<(ostream& out, const Sequencer& obj); 1547039Snate@binkert.org 1557039Snate@binkert.org// ******************* Definitions ******************* 1567039Snate@binkert.org 1577039Snate@binkert.org// Output operator definition 1586285Snate@binkert.orgextern inline 1596285Snate@binkert.orgostream& operator<<(ostream& out, const Sequencer& obj) 1607039Snate@binkert.org{ 1617039Snate@binkert.org obj.print(out); 1626285Snate@binkert.org out << flush; 1637039Snate@binkert.org return out; 1646285Snate@binkert.org} 1656285Snate@binkert.org 1667039Snate@binkert.org#endif //SEQUENCER_H 1677055Snate@binkert.org 1686285Snate@binkert.org