Sequencer.hh revision 6285
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/config/RubyConfig.hh"
426154Snate@binkert.org#include "mem/ruby/common/Consumer.hh"
436154Snate@binkert.org#include "mem/protocol/CacheRequestType.hh"
446154Snate@binkert.org#include "mem/protocol/AccessModeType.hh"
456154Snate@binkert.org#include "mem/protocol/GenericMachineType.hh"
466154Snate@binkert.org#include "mem/protocol/PrefetchBit.hh"
476285Snate@binkert.org#include "mem/ruby/system/RubyPort.hh"
486154Snate@binkert.org#include "mem/gems_common/Map.hh"
496285Snate@binkert.org#include "mem/ruby/common/Address.hh"
506145Snate@binkert.org
516145Snate@binkert.orgclass DataBlock;
526145Snate@binkert.orgclass CacheMsg;
536145Snate@binkert.orgclass MachineID;
546285Snate@binkert.orgclass CacheMemory;
556285Snate@binkert.orgclass AbstractController;
566145Snate@binkert.org
576285Snate@binkert.orgstruct SequencerRequest {
586285Snate@binkert.org  RubyRequest ruby_request;
596285Snate@binkert.org  int64_t id;
606285Snate@binkert.org  Time issue_time;
616285Snate@binkert.org
626285Snate@binkert.org  SequencerRequest(const RubyRequest & _ruby_request, int64_t _id, Time _issue_time)
636285Snate@binkert.org    : ruby_request(_ruby_request), id(_id), issue_time(_issue_time)
646285Snate@binkert.org  {}
656285Snate@binkert.org};
666285Snate@binkert.org
676285Snate@binkert.orgclass Sequencer : public Consumer, public RubyPort {
686145Snate@binkert.orgpublic:
696145Snate@binkert.org  // Constructors
706285Snate@binkert.org  Sequencer(const string & name);
716285Snate@binkert.org  void init(const vector<string> & argv);
726145Snate@binkert.org
736145Snate@binkert.org  // Destructor
746145Snate@binkert.org  ~Sequencer();
756145Snate@binkert.org
766145Snate@binkert.org  // Public Methods
776145Snate@binkert.org  void wakeup(); // Used only for deadlock detection
786145Snate@binkert.org
796285Snate@binkert.org  void printConfig(ostream& out) const;
806145Snate@binkert.org
816145Snate@binkert.org  void printProgress(ostream& out) const;
826145Snate@binkert.org
836145Snate@binkert.org  void writeCallback(const Address& address, DataBlock& data);
846145Snate@binkert.org  void readCallback(const Address& address, DataBlock& data);
856145Snate@binkert.org
866145Snate@binkert.org  // called by Tester or Simics
876285Snate@binkert.org  int64_t makeRequest(const RubyRequest & request);
886285Snate@binkert.org  bool isReady(const RubyRequest& request) const;
896145Snate@binkert.org  bool empty() const;
906145Snate@binkert.org
916145Snate@binkert.org  void print(ostream& out) const;
926145Snate@binkert.org  void checkCoherence(const Address& address);
936145Snate@binkert.org
946285Snate@binkert.org  //  bool getRubyMemoryValue(const Address& addr, char* value, unsigned int size_in_bytes);
956285Snate@binkert.org  //  bool setRubyMemoryValue(const Address& addr, char *value, unsigned int size_in_bytes);
966145Snate@binkert.org
976285Snate@binkert.org  void removeRequest(SequencerRequest* request);
986145Snate@binkert.orgprivate:
996145Snate@binkert.org  // Private Methods
1006145Snate@binkert.org  bool tryCacheAccess(const Address& addr, CacheRequestType type, const Address& pc, AccessModeType access_mode, int size, DataBlock*& data_ptr);
1016285Snate@binkert.org  void issueRequest(const RubyRequest& request);
1026285Snate@binkert.org
1036285Snate@binkert.org  void hitCallback(SequencerRequest* request, DataBlock& data);
1046285Snate@binkert.org  bool insertRequest(SequencerRequest* request);
1056145Snate@binkert.org
1066145Snate@binkert.org
1076145Snate@binkert.org  // Private copy constructor and assignment operator
1086145Snate@binkert.org  Sequencer(const Sequencer& obj);
1096145Snate@binkert.org  Sequencer& operator=(const Sequencer& obj);
1106145Snate@binkert.org
1116285Snate@binkert.orgprivate:
1126285Snate@binkert.org  int m_max_outstanding_requests;
1136285Snate@binkert.org  int m_deadlock_threshold;
1146285Snate@binkert.org
1156285Snate@binkert.org  AbstractController* m_controller;
1166285Snate@binkert.org  MessageBuffer* m_mandatory_q_ptr;
1176285Snate@binkert.org  CacheMemory* m_dataCache_ptr;
1186285Snate@binkert.org  CacheMemory* m_instCache_ptr;
1196145Snate@binkert.org
1206145Snate@binkert.org  // indicates what processor on the chip this sequencer is associated with
1216145Snate@binkert.org  int m_version;
1226285Snate@binkert.org  int m_controller_type;
1236145Snate@binkert.org
1246285Snate@binkert.org  Map<Address, SequencerRequest*> m_writeRequestTable;
1256285Snate@binkert.org  Map<Address, SequencerRequest*> m_readRequestTable;
1266145Snate@binkert.org  // Global outstanding request count, across all request tables
1276145Snate@binkert.org  int m_outstanding_count;
1286145Snate@binkert.org  bool m_deadlock_check_scheduled;
1296145Snate@binkert.org
1306145Snate@binkert.org};
1316145Snate@binkert.org
1326145Snate@binkert.org// Output operator declaration
1336145Snate@binkert.orgostream& operator<<(ostream& out, const Sequencer& obj);
1346145Snate@binkert.org
1356145Snate@binkert.org// ******************* Definitions *******************
1366145Snate@binkert.org
1376145Snate@binkert.org// Output operator definition
1386145Snate@binkert.orgextern inline
1396145Snate@binkert.orgostream& operator<<(ostream& out, const Sequencer& obj)
1406145Snate@binkert.org{
1416145Snate@binkert.org  obj.print(out);
1426145Snate@binkert.org  out << flush;
1436145Snate@binkert.org  return out;
1446145Snate@binkert.org}
1456145Snate@binkert.org
1466145Snate@binkert.org#endif //SEQUENCER_H
1476145Snate@binkert.org
148