Sequencer.hh revision 6763
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/*
316284Snate@binkert.org * $Id: Sequencer.hh 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
406154Snate@binkert.org#include "mem/ruby/common/Global.hh"
416154Snate@binkert.org#include "mem/ruby/common/Consumer.hh"
426154Snate@binkert.org#include "mem/protocol/CacheRequestType.hh"
436154Snate@binkert.org#include "mem/protocol/AccessModeType.hh"
446154Snate@binkert.org#include "mem/protocol/GenericMachineType.hh"
456154Snate@binkert.org#include "mem/protocol/PrefetchBit.hh"
466285Snate@binkert.org#include "mem/ruby/system/RubyPort.hh"
476154Snate@binkert.org#include "mem/gems_common/Map.hh"
486285Snate@binkert.org#include "mem/ruby/common/Address.hh"
496145Snate@binkert.org
506145Snate@binkert.orgclass DataBlock;
516145Snate@binkert.orgclass CacheMsg;
526145Snate@binkert.orgclass MachineID;
536285Snate@binkert.orgclass CacheMemory;
546285Snate@binkert.orgclass AbstractController;
556145Snate@binkert.org
566285Snate@binkert.orgstruct SequencerRequest {
576285Snate@binkert.org  RubyRequest ruby_request;
586285Snate@binkert.org  int64_t id;
596285Snate@binkert.org  Time issue_time;
606285Snate@binkert.org
616285Snate@binkert.org  SequencerRequest(const RubyRequest & _ruby_request, int64_t _id, Time _issue_time)
626285Snate@binkert.org    : ruby_request(_ruby_request), id(_id), issue_time(_issue_time)
636285Snate@binkert.org  {}
646285Snate@binkert.org};
656285Snate@binkert.org
666763SBrad.Beckmann@amd.comstd::ostream& operator<<(std::ostream& out, const SequencerRequest& obj);
676763SBrad.Beckmann@amd.com
686285Snate@binkert.orgclass Sequencer : public Consumer, public RubyPort {
696145Snate@binkert.orgpublic:
706145Snate@binkert.org  // Constructors
716285Snate@binkert.org  Sequencer(const string & name);
726285Snate@binkert.org  void init(const vector<string> & argv);
736145Snate@binkert.org
746145Snate@binkert.org  // Destructor
756145Snate@binkert.org  ~Sequencer();
766145Snate@binkert.org
776145Snate@binkert.org  // Public Methods
786145Snate@binkert.org  void wakeup(); // Used only for deadlock detection
796145Snate@binkert.org
806285Snate@binkert.org  void printConfig(ostream& out) const;
816145Snate@binkert.org
826145Snate@binkert.org  void printProgress(ostream& out) const;
836145Snate@binkert.org
846145Snate@binkert.org  void writeCallback(const Address& address, DataBlock& data);
856145Snate@binkert.org  void readCallback(const Address& address, DataBlock& data);
866145Snate@binkert.org
876145Snate@binkert.org  // called by Tester or Simics
886285Snate@binkert.org  int64_t makeRequest(const RubyRequest & request);
896505Spdudnik@gmail.com  bool isReady(const RubyRequest& request);
906145Snate@binkert.org  bool empty() const;
916145Snate@binkert.org
926145Snate@binkert.org  void print(ostream& out) const;
936145Snate@binkert.org  void checkCoherence(const Address& address);
946145Snate@binkert.org
956285Snate@binkert.org  //  bool getRubyMemoryValue(const Address& addr, char* value, unsigned int size_in_bytes);
966285Snate@binkert.org  //  bool setRubyMemoryValue(const Address& addr, char *value, unsigned int size_in_bytes);
976145Snate@binkert.org
986285Snate@binkert.org  void removeRequest(SequencerRequest* request);
996145Snate@binkert.orgprivate:
1006145Snate@binkert.org  // Private Methods
1016145Snate@binkert.org  bool tryCacheAccess(const Address& addr, CacheRequestType type, const Address& pc, AccessModeType access_mode, int size, DataBlock*& data_ptr);
1026285Snate@binkert.org  void issueRequest(const RubyRequest& request);
1036285Snate@binkert.org
1046285Snate@binkert.org  void hitCallback(SequencerRequest* request, DataBlock& data);
1056285Snate@binkert.org  bool insertRequest(SequencerRequest* request);
1066145Snate@binkert.org
1076145Snate@binkert.org
1086145Snate@binkert.org  // Private copy constructor and assignment operator
1096145Snate@binkert.org  Sequencer(const Sequencer& obj);
1106145Snate@binkert.org  Sequencer& operator=(const Sequencer& obj);
1116145Snate@binkert.org
1126285Snate@binkert.orgprivate:
1136285Snate@binkert.org  int m_max_outstanding_requests;
1146285Snate@binkert.org  int m_deadlock_threshold;
1156285Snate@binkert.org
1166285Snate@binkert.org  AbstractController* m_controller;
1176285Snate@binkert.org  MessageBuffer* m_mandatory_q_ptr;
1186285Snate@binkert.org  CacheMemory* m_dataCache_ptr;
1196285Snate@binkert.org  CacheMemory* m_instCache_ptr;
1206145Snate@binkert.org
1216145Snate@binkert.org  // indicates what processor on the chip this sequencer is associated with
1226145Snate@binkert.org  int m_version;
1236285Snate@binkert.org  int m_controller_type;
1246145Snate@binkert.org
1256285Snate@binkert.org  Map<Address, SequencerRequest*> m_writeRequestTable;
1266285Snate@binkert.org  Map<Address, SequencerRequest*> m_readRequestTable;
1276145Snate@binkert.org  // Global outstanding request count, across all request tables
1286145Snate@binkert.org  int m_outstanding_count;
1296145Snate@binkert.org  bool m_deadlock_check_scheduled;
1306505Spdudnik@gmail.com  int m_servicing_atomic;
1316505Spdudnik@gmail.com  int m_atomics_counter;
1326145Snate@binkert.org};
1336145Snate@binkert.org
1346145Snate@binkert.org// Output operator declaration
1356145Snate@binkert.orgostream& operator<<(ostream& out, const Sequencer& obj);
1366145Snate@binkert.org
1376145Snate@binkert.org// ******************* Definitions *******************
1386145Snate@binkert.org
1396145Snate@binkert.org// Output operator definition
1406145Snate@binkert.orgextern inline
1416145Snate@binkert.orgostream& operator<<(ostream& out, const Sequencer& obj)
1426145Snate@binkert.org{
1436145Snate@binkert.org  obj.print(out);
1446145Snate@binkert.org  out << flush;
1456145Snate@binkert.org  return out;
1466145Snate@binkert.org}
1476145Snate@binkert.org
1486145Snate@binkert.org#endif //SEQUENCER_H
1496145Snate@binkert.org
150