Sequencer.hh revision 6859
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 666285Snate@binkert.orgclass Sequencer : public Consumer, public RubyPort { 676145Snate@binkert.orgpublic: 686145Snate@binkert.org // Constructors 696285Snate@binkert.org Sequencer(const string & name); 706285Snate@binkert.org void init(const vector<string> & argv); 716145Snate@binkert.org 726145Snate@binkert.org // Destructor 736145Snate@binkert.org ~Sequencer(); 746145Snate@binkert.org 756145Snate@binkert.org // Public Methods 766145Snate@binkert.org void wakeup(); // Used only for deadlock detection 776145Snate@binkert.org 786285Snate@binkert.org void printConfig(ostream& out) const; 796145Snate@binkert.org 806145Snate@binkert.org void printProgress(ostream& out) const; 816145Snate@binkert.org 826145Snate@binkert.org void writeCallback(const Address& address, DataBlock& data); 836145Snate@binkert.org void readCallback(const Address& address, DataBlock& data); 846145Snate@binkert.org 856145Snate@binkert.org // called by Tester or Simics 866285Snate@binkert.org int64_t makeRequest(const RubyRequest & request); 876845Sdrh5@cs.wisc.edu int isReady(const RubyRequest& request); 886145Snate@binkert.org bool empty() const; 896145Snate@binkert.org 906145Snate@binkert.org void print(ostream& out) const; 916859Sdrh5@cs.wisc.edu void printStats(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; 1296846Spdudnik@cs.wisc.edu int m_atomic_reads; 1306846Spdudnik@cs.wisc.edu int m_atomic_writes; 1316859Sdrh5@cs.wisc.edu 1326859Sdrh5@cs.wisc.edu int m_store_waiting_on_load_cycles; 1336859Sdrh5@cs.wisc.edu int m_store_waiting_on_store_cycles; 1346859Sdrh5@cs.wisc.edu int m_load_waiting_on_store_cycles; 1356859Sdrh5@cs.wisc.edu int m_load_waiting_on_load_cycles; 1366145Snate@binkert.org}; 1376145Snate@binkert.org 1386145Snate@binkert.org// Output operator declaration 1396145Snate@binkert.orgostream& operator<<(ostream& out, const Sequencer& obj); 1406145Snate@binkert.org 1416145Snate@binkert.org// ******************* Definitions ******************* 1426145Snate@binkert.org 1436145Snate@binkert.org// Output operator definition 1446145Snate@binkert.orgextern inline 1456145Snate@binkert.orgostream& operator<<(ostream& out, const Sequencer& obj) 1466145Snate@binkert.org{ 1476145Snate@binkert.org obj.print(out); 1486145Snate@binkert.org out << flush; 1496145Snate@binkert.org return out; 1506145Snate@binkert.org} 1516145Snate@binkert.org 1526145Snate@binkert.org#endif //SEQUENCER_H 1536145Snate@binkert.org 154