Sequencer.hh revision 6162:cbd6debc4fd0
12SN/A
24039Sbinkertn@umich.edu/*
32SN/A * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
42SN/A * All rights reserved.
52SN/A *
62SN/A * Redistribution and use in source and binary forms, with or without
72SN/A * modification, are permitted provided that the following conditions are
82SN/A * met: redistributions of source code must retain the above copyright
92SN/A * notice, this list of conditions and the following disclaimer;
102SN/A * redistributions in binary form must reproduce the above copyright
112SN/A * notice, this list of conditions and the following disclaimer in the
122SN/A * documentation and/or other materials provided with the distribution;
132SN/A * neither the name of the copyright holders nor the names of its
142SN/A * contributors may be used to endorse or promote products derived from
152SN/A * this software without specific prior written permission.
162SN/A *
172SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
182SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
192SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
202SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
212SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
222SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
232SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
242SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
252SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
262SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
272665Ssaidi@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
282665Ssaidi@eecs.umich.edu */
292665Ssaidi@eecs.umich.edu
302SN/A/*
312SN/A * $Id: Sequencer.h 1.70 2006/09/27 14:56:41-05:00 bobba@s1-01.cs.wisc.edu $
321354SN/A *
331354SN/A * Description:
342SN/A *
354046Sbinkertn@umich.edu */
362SN/A
3756SN/A#ifndef SEQUENCER_H
388232Snate@binkert.org#define SEQUENCER_H
391031SN/A
406214Snate@binkert.org#include "mem/ruby/common/Global.hh"
414167Sbinkertn@umich.edu#include "mem/ruby/config/RubyConfig.hh"
422SN/A#include "mem/ruby/common/Consumer.hh"
432SN/A#include "mem/protocol/CacheRequestType.hh"
442SN/A#include "mem/protocol/AccessModeType.hh"
458232Snate@binkert.org#include "mem/protocol/GenericMachineType.hh"
468232Snate@binkert.org#include "mem/protocol/PrefetchBit.hh"
478232Snate@binkert.org#include "mem/gems_common/Map.hh"
484046Sbinkertn@umich.edu#include "mem/packet.hh"
494046Sbinkertn@umich.edu
502SN/Aclass DataBlock;
514046Sbinkertn@umich.educlass AbstractChip;
524046Sbinkertn@umich.educlass CacheMsg;
534046Sbinkertn@umich.educlass Address;
542SN/Aclass MachineID;
554046Sbinkertn@umich.edu
564046Sbinkertn@umich.educlass Sequencer : public Consumer {
572SN/Apublic:
584046Sbinkertn@umich.edu  // Constructors
594046Sbinkertn@umich.edu  Sequencer(AbstractChip* chip_ptr, int version);
604046Sbinkertn@umich.edu
612SN/A  // Destructor
627811Ssteve.reinhardt@amd.com  ~Sequencer();
634039Sbinkertn@umich.edu
641070SN/A  // Public Methods
651070SN/A  void wakeup(); // Used only for deadlock detection
661070SN/A
671070SN/A  static void printConfig(ostream& out);
681070SN/A
691070SN/A  // returns total number of outstanding request (includes prefetches)
701070SN/A  int getNumberOutstanding();
711070SN/A  // return only total number of outstanding demand requests
721070SN/A  int getNumberOutstandingDemand();
732SN/A  // return only total number of outstanding prefetch requests
742SN/A  int getNumberOutstandingPrefetch();
7510259SAndrew.Bardsley@arm.com
7610259SAndrew.Bardsley@arm.com  // remove load/store request from queue
7710259SAndrew.Bardsley@arm.com  void removeLoadRequest(const Address & addr, int thread);
7810259SAndrew.Bardsley@arm.com  void removeStoreRequest(const Address & addr, int thread);
7910259SAndrew.Bardsley@arm.com
8010259SAndrew.Bardsley@arm.com  void printProgress(ostream& out) const;
8110259SAndrew.Bardsley@arm.com
8210259SAndrew.Bardsley@arm.com  // returns a pointer to the request in the request tables
8310259SAndrew.Bardsley@arm.com  CacheMsg & getReadRequest( const Address & addr, int thread );
8410259SAndrew.Bardsley@arm.com  CacheMsg & getWriteRequest( const Address & addr, int thread );
8510259SAndrew.Bardsley@arm.com
8610259SAndrew.Bardsley@arm.com  void writeCallback(const Address& address, DataBlock& data);
8710259SAndrew.Bardsley@arm.com  void readCallback(const Address& address, DataBlock& data);
8810259SAndrew.Bardsley@arm.com  void writeCallback(const Address& address);
892SN/A  void readCallback(const Address& address);
902SN/A  void writeCallback(const Address& address, DataBlock& data, GenericMachineType respondingMach, PrefetchBit pf, int thread);
912SN/A  void readCallback(const Address& address, DataBlock& data, GenericMachineType respondingMach, PrefetchBit pf, int thread);
922SN/A  void writeCallback(const Address& address, DataBlock& data, GenericMachineType respondingMach, int thread);
932SN/A  void readCallback(const Address& address, DataBlock& data, GenericMachineType respondingMach, int thread);
942SN/A
952SN/A  // returns the thread ID of the request
962SN/A  int getRequestThreadID(const Address & addr);
972SN/A  // returns the physical address of the request
982SN/A  Address getRequestPhysicalAddress(const Address & lineaddr);
992SN/A  // returns whether a request is a prefetch request
1002SN/A  bool isPrefetchRequest(const Address & lineaddr);
1018232Snate@binkert.org
1022SN/A  //notifies driver of debug print
1034041Sbinkertn@umich.edu  void printDebug();
1048232Snate@binkert.org
1054041Sbinkertn@umich.edu  // called by Tester or Simics
1067823Ssteve.reinhardt@amd.com  void makeRequest(const Packet* pkt, void* data);
1072SN/A  void makeRequest(const CacheMsg& request); // depricate this function
1082SN/A  bool doRequest(const CacheMsg& request);
1094041Sbinkertn@umich.edu  void issueRequest(const CacheMsg& request);
1108232Snate@binkert.org  bool isReady(const Packet* pkt) const;
1114041Sbinkertn@umich.edu  bool isReady(const CacheMsg& request) const; // depricate this function
1127823Ssteve.reinhardt@amd.com  bool empty() const;
1132SN/A  void resetRequestTime(const Address& addr, int thread);
1142SN/A  Address getLogicalAddressOfRequest(Address address, int thread);
1158232Snate@binkert.org  AccessModeType getAccessModeOfRequest(Address address, int thread);
1168232Snate@binkert.org  //uint64 getSequenceNumberOfRequest(Address addr, int thread);
1175806Ssaidi@eecs.umich.edu
1188232Snate@binkert.org  void print(ostream& out) const;
1195806Ssaidi@eecs.umich.edu  void checkCoherence(const Address& address);
1205806Ssaidi@eecs.umich.edu
1214041Sbinkertn@umich.edu  bool getRubyMemoryValue(const Address& addr, char* value, unsigned int size_in_bytes);
1228232Snate@binkert.org  bool setRubyMemoryValue(const Address& addr, char *value, unsigned int size_in_bytes);
1234041Sbinkertn@umich.edu
1244041Sbinkertn@umich.edu  void removeRequest(const CacheMsg& request);
1252SN/Aprivate:
1262SN/A  // Private Methods
1274046Sbinkertn@umich.edu  bool tryCacheAccess(const Address& addr, CacheRequestType type, const Address& pc, AccessModeType access_mode, int size, DataBlock*& data_ptr);
1287823Ssteve.reinhardt@amd.com  //  void conflictCallback(const CacheMsg& request, GenericMachineType respondingMach, int thread);
1294046Sbinkertn@umich.edu  void hitCallback(const CacheMsg& request, DataBlock& data, GenericMachineType respondingMach, int thread);
1304046Sbinkertn@umich.edu  bool insertRequest(const CacheMsg& request);
1314041Sbinkertn@umich.edu
1327823Ssteve.reinhardt@amd.com
1332SN/A  // Private copy constructor and assignment operator
1342SN/A  Sequencer(const Sequencer& obj);
1354041Sbinkertn@umich.edu  Sequencer& operator=(const Sequencer& obj);
1364041Sbinkertn@umich.edu
137507SN/A  // Data Members (m_ prefix)
138507SN/A  AbstractChip* m_chip_ptr;
1392SN/A
1402SN/A  // indicates what processor on the chip this sequencer is associated with
1412SN/A  int m_version;
1424046Sbinkertn@umich.edu
1434041Sbinkertn@umich.edu  // One request table per SMT thread
1445806Ssaidi@eecs.umich.edu  Map<Address, CacheMsg>** m_writeRequestTable_ptr;
1454041Sbinkertn@umich.edu  Map<Address, CacheMsg>** m_readRequestTable_ptr;
1464046Sbinkertn@umich.edu  // Global outstanding request count, across all request tables
1474041Sbinkertn@umich.edu  int m_outstanding_count;
1484041Sbinkertn@umich.edu  bool m_deadlock_check_scheduled;
1492SN/A
1505543Ssaidi@eecs.umich.edu};
1512SN/A
1521354SN/A// Output operator declaration
153ostream& operator<<(ostream& out, const Sequencer& obj);
154
155// ******************* Definitions *******************
156
157// Output operator definition
158extern inline
159ostream& operator<<(ostream& out, const Sequencer& obj)
160{
161  obj.print(out);
162  out << flush;
163  return out;
164}
165
166#endif //SEQUENCER_H
167
168