Sequencer.hh revision 6145
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"
486145Snate@binkert.org
496145Snate@binkert.orgclass DataBlock;
506145Snate@binkert.orgclass AbstractChip;
516145Snate@binkert.orgclass CacheMsg;
526145Snate@binkert.orgclass Address;
536145Snate@binkert.orgclass MachineID;
546145Snate@binkert.org
556145Snate@binkert.orgclass Sequencer : public Consumer {
566145Snate@binkert.orgpublic:
576145Snate@binkert.org  // Constructors
586145Snate@binkert.org  Sequencer(AbstractChip* chip_ptr, int version);
596145Snate@binkert.org
606145Snate@binkert.org  // Destructor
616145Snate@binkert.org  ~Sequencer();
626145Snate@binkert.org
636145Snate@binkert.org  // Public Methods
646145Snate@binkert.org  void wakeup(); // Used only for deadlock detection
656145Snate@binkert.org
666145Snate@binkert.org  static void printConfig(ostream& out);
676145Snate@binkert.org
686145Snate@binkert.org  // returns total number of outstanding request (includes prefetches)
696145Snate@binkert.org  int getNumberOutstanding();
706145Snate@binkert.org  // return only total number of outstanding demand requests
716145Snate@binkert.org  int getNumberOutstandingDemand();
726145Snate@binkert.org  // return only total number of outstanding prefetch requests
736145Snate@binkert.org  int getNumberOutstandingPrefetch();
746145Snate@binkert.org
756145Snate@binkert.org  // remove load/store request from queue
766145Snate@binkert.org  void removeLoadRequest(const Address & addr, int thread);
776145Snate@binkert.org  void removeStoreRequest(const Address & addr, int thread);
786145Snate@binkert.org
796145Snate@binkert.org  void printProgress(ostream& out) const;
806145Snate@binkert.org
816145Snate@binkert.org  // returns a pointer to the request in the request tables
826145Snate@binkert.org  CacheMsg & getReadRequest( const Address & addr, int thread );
836145Snate@binkert.org  CacheMsg & getWriteRequest( const Address & addr, int thread );
846145Snate@binkert.org
856145Snate@binkert.org  // called by Ruby when transaction completes
866145Snate@binkert.org  void writeConflictCallback(const Address& address);
876145Snate@binkert.org  void readConflictCallback(const Address& address);
886145Snate@binkert.org  void writeConflictCallback(const Address& address, GenericMachineType respondingMach, int thread);
896145Snate@binkert.org  void readConflictCallback(const Address& address, GenericMachineType respondingMach, int thread);
906145Snate@binkert.org
916145Snate@binkert.org  void writeCallback(const Address& address, DataBlock& data);
926145Snate@binkert.org  void readCallback(const Address& address, DataBlock& data);
936145Snate@binkert.org  void writeCallback(const Address& address);
946145Snate@binkert.org  void readCallback(const Address& address);
956145Snate@binkert.org  void writeCallback(const Address& address, DataBlock& data, GenericMachineType respondingMach, PrefetchBit pf, int thread);
966145Snate@binkert.org  void readCallback(const Address& address, DataBlock& data, GenericMachineType respondingMach, PrefetchBit pf, int thread);
976145Snate@binkert.org  void writeCallback(const Address& address, DataBlock& data, GenericMachineType respondingMach, int thread);
986145Snate@binkert.org  void readCallback(const Address& address, DataBlock& data, GenericMachineType respondingMach, int thread);
996145Snate@binkert.org
1006145Snate@binkert.org  // returns the thread ID of the request
1016145Snate@binkert.org  int getRequestThreadID(const Address & addr);
1026145Snate@binkert.org  // returns the physical address of the request
1036145Snate@binkert.org  Address getRequestPhysicalAddress(const Address & lineaddr);
1046145Snate@binkert.org  // returns whether a request is a prefetch request
1056145Snate@binkert.org  bool isPrefetchRequest(const Address & lineaddr);
1066145Snate@binkert.org
1076145Snate@binkert.org  //notifies driver of debug print
1086145Snate@binkert.org  void printDebug();
1096145Snate@binkert.org
1106145Snate@binkert.org  // called by Tester or Simics
1116145Snate@binkert.org  void makeRequest(const CacheMsg& request);
1126145Snate@binkert.org  bool doRequest(const CacheMsg& request);
1136145Snate@binkert.org  void issueRequest(const CacheMsg& request);
1146145Snate@binkert.org  bool isReady(const CacheMsg& request) const;
1156145Snate@binkert.org  bool empty() const;
1166145Snate@binkert.org  void resetRequestTime(const Address& addr, int thread);
1176145Snate@binkert.org  Address getLogicalAddressOfRequest(Address address, int thread);
1186145Snate@binkert.org  AccessModeType getAccessModeOfRequest(Address address, int thread);
1196145Snate@binkert.org  //uint64 getSequenceNumberOfRequest(Address addr, int thread);
1206145Snate@binkert.org
1216145Snate@binkert.org  void print(ostream& out) const;
1226145Snate@binkert.org  void checkCoherence(const Address& address);
1236145Snate@binkert.org
1246145Snate@binkert.org  bool getRubyMemoryValue(const Address& addr, char* value, unsigned int size_in_bytes);
1256145Snate@binkert.org  bool setRubyMemoryValue(const Address& addr, char *value, unsigned int size_in_bytes);
1266145Snate@binkert.org
1276145Snate@binkert.org  void removeRequest(const CacheMsg& request);
1286145Snate@binkert.orgprivate:
1296145Snate@binkert.org  // Private Methods
1306145Snate@binkert.org  bool tryCacheAccess(const Address& addr, CacheRequestType type, const Address& pc, AccessModeType access_mode, int size, DataBlock*& data_ptr);
1316145Snate@binkert.org  void conflictCallback(const CacheMsg& request, GenericMachineType respondingMach, int thread);
1326145Snate@binkert.org  void hitCallback(const CacheMsg& request, DataBlock& data, GenericMachineType respondingMach, int thread);
1336145Snate@binkert.org  bool insertRequest(const CacheMsg& request);
1346145Snate@binkert.org
1356145Snate@binkert.org
1366145Snate@binkert.org  // Private copy constructor and assignment operator
1376145Snate@binkert.org  Sequencer(const Sequencer& obj);
1386145Snate@binkert.org  Sequencer& operator=(const Sequencer& obj);
1396145Snate@binkert.org
1406145Snate@binkert.org  // Data Members (m_ prefix)
1416145Snate@binkert.org  AbstractChip* m_chip_ptr;
1426145Snate@binkert.org
1436145Snate@binkert.org  // indicates what processor on the chip this sequencer is associated with
1446145Snate@binkert.org  int m_version;
1456145Snate@binkert.org
1466145Snate@binkert.org  // One request table per SMT thread
1476145Snate@binkert.org  Map<Address, CacheMsg>** m_writeRequestTable_ptr;
1486145Snate@binkert.org  Map<Address, CacheMsg>** m_readRequestTable_ptr;
1496145Snate@binkert.org  // Global outstanding request count, across all request tables
1506145Snate@binkert.org  int m_outstanding_count;
1516145Snate@binkert.org  bool m_deadlock_check_scheduled;
1526145Snate@binkert.org
1536145Snate@binkert.org};
1546145Snate@binkert.org
1556145Snate@binkert.org// Output operator declaration
1566145Snate@binkert.orgostream& operator<<(ostream& out, const Sequencer& obj);
1576145Snate@binkert.org
1586145Snate@binkert.org// ******************* Definitions *******************
1596145Snate@binkert.org
1606145Snate@binkert.org// Output operator definition
1616145Snate@binkert.orgextern inline
1626145Snate@binkert.orgostream& operator<<(ostream& out, const Sequencer& obj)
1636145Snate@binkert.org{
1646145Snate@binkert.org  obj.print(out);
1656145Snate@binkert.org  out << flush;
1666145Snate@binkert.org  return out;
1676145Snate@binkert.org}
1686145Snate@binkert.org
1696145Snate@binkert.org#endif //SEQUENCER_H
1706145Snate@binkert.org
171