Sequencer.hh revision 7039
16145Snate@binkert.org/* 26145Snate@binkert.org * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 36145Snate@binkert.org * All rights reserved. 46145Snate@binkert.org * 56145Snate@binkert.org * Redistribution and use in source and binary forms, with or without 66145Snate@binkert.org * modification, are permitted provided that the following conditions are 76145Snate@binkert.org * met: redistributions of source code must retain the above copyright 86145Snate@binkert.org * notice, this list of conditions and the following disclaimer; 96145Snate@binkert.org * redistributions in binary form must reproduce the above copyright 106145Snate@binkert.org * notice, this list of conditions and the following disclaimer in the 116145Snate@binkert.org * documentation and/or other materials provided with the distribution; 126145Snate@binkert.org * neither the name of the copyright holders nor the names of its 136145Snate@binkert.org * contributors may be used to endorse or promote products derived from 146145Snate@binkert.org * this software without specific prior written permission. 156145Snate@binkert.org * 166145Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 176145Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 186145Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 196145Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 206145Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 216145Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 226145Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 236145Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 246145Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 256145Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 266145Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 276145Snate@binkert.org */ 286145Snate@binkert.org 297039Snate@binkert.org#ifndef __MEM_RUBY_SYSTEM_SEQUENCER_HH__ 307039Snate@binkert.org#define __MEM_RUBY_SYSTEM_SEQUENCER_HH__ 316145Snate@binkert.org 327039Snate@binkert.org#include "mem/gems_common/Map.hh" 337039Snate@binkert.org#include "mem/protocol/AccessModeType.hh" 346154Snate@binkert.org#include "mem/protocol/CacheRequestType.hh" 356154Snate@binkert.org#include "mem/protocol/GenericMachineType.hh" 366154Snate@binkert.org#include "mem/protocol/PrefetchBit.hh" 377039Snate@binkert.org#include "mem/ruby/common/Address.hh" 387039Snate@binkert.org#include "mem/ruby/common/Consumer.hh" 397039Snate@binkert.org#include "mem/ruby/common/Global.hh" 406285Snate@binkert.org#include "mem/ruby/system/RubyPort.hh" 416145Snate@binkert.org 426145Snate@binkert.orgclass DataBlock; 436145Snate@binkert.orgclass CacheMsg; 446145Snate@binkert.orgclass MachineID; 456285Snate@binkert.orgclass CacheMemory; 466876Ssteve.reinhardt@amd.com 476876Ssteve.reinhardt@amd.comclass RubySequencerParams; 486145Snate@binkert.org 497039Snate@binkert.orgstruct SequencerRequest 507039Snate@binkert.org{ 517039Snate@binkert.org RubyRequest ruby_request; 527039Snate@binkert.org Time issue_time; 536285Snate@binkert.org 547039Snate@binkert.org SequencerRequest(const RubyRequest & _ruby_request, Time _issue_time) 557039Snate@binkert.org : ruby_request(_ruby_request), issue_time(_issue_time) 567039Snate@binkert.org {} 576285Snate@binkert.org}; 586285Snate@binkert.org 596763SBrad.Beckmann@amd.comstd::ostream& operator<<(std::ostream& out, const SequencerRequest& obj); 606763SBrad.Beckmann@amd.com 617039Snate@binkert.orgclass Sequencer : public RubyPort, public Consumer 627039Snate@binkert.org{ 637039Snate@binkert.org public: 646876Ssteve.reinhardt@amd.com typedef RubySequencerParams Params; 657039Snate@binkert.org Sequencer(const Params *); 667039Snate@binkert.org ~Sequencer(); 676145Snate@binkert.org 687039Snate@binkert.org // Public Methods 697039Snate@binkert.org void wakeup(); // Used only for deadlock detection 706145Snate@binkert.org 717039Snate@binkert.org void printConfig(ostream& out) const; 726145Snate@binkert.org 737039Snate@binkert.org void printProgress(ostream& out) const; 746145Snate@binkert.org 757039Snate@binkert.org void writeCallback(const Address& address, DataBlock& data); 767039Snate@binkert.org void readCallback(const Address& address, DataBlock& data); 776145Snate@binkert.org 787039Snate@binkert.org RequestStatus makeRequest(const RubyRequest & request); 797039Snate@binkert.org RequestStatus getRequestStatus(const RubyRequest& request); 807039Snate@binkert.org bool empty() const; 816145Snate@binkert.org 827039Snate@binkert.org void print(ostream& out) const; 837039Snate@binkert.org void printStats(ostream & out) const; 847039Snate@binkert.org void checkCoherence(const Address& address); 856145Snate@binkert.org 867039Snate@binkert.org void removeRequest(SequencerRequest* request); 876145Snate@binkert.org 887039Snate@binkert.org private: 897039Snate@binkert.org bool tryCacheAccess(const Address& addr, CacheRequestType type, 907039Snate@binkert.org const Address& pc, AccessModeType access_mode, 917039Snate@binkert.org int size, DataBlock*& data_ptr); 927039Snate@binkert.org void issueRequest(const RubyRequest& request); 936145Snate@binkert.org 947039Snate@binkert.org void hitCallback(SequencerRequest* request, DataBlock& data); 957039Snate@binkert.org bool insertRequest(SequencerRequest* request); 966285Snate@binkert.org 976145Snate@binkert.org 987039Snate@binkert.org // Private copy constructor and assignment operator 997039Snate@binkert.org Sequencer(const Sequencer& obj); 1007039Snate@binkert.org Sequencer& operator=(const Sequencer& obj); 1016145Snate@binkert.org 1027039Snate@binkert.org private: 1037039Snate@binkert.org int m_max_outstanding_requests; 1047039Snate@binkert.org int m_deadlock_threshold; 1056145Snate@binkert.org 1067039Snate@binkert.org CacheMemory* m_dataCache_ptr; 1077039Snate@binkert.org CacheMemory* m_instCache_ptr; 1086285Snate@binkert.org 1097039Snate@binkert.org Map<Address, SequencerRequest*> m_writeRequestTable; 1107039Snate@binkert.org Map<Address, SequencerRequest*> m_readRequestTable; 1117039Snate@binkert.org // Global outstanding request count, across all request tables 1127039Snate@binkert.org int m_outstanding_count; 1137039Snate@binkert.org bool m_deadlock_check_scheduled; 1146145Snate@binkert.org 1157039Snate@binkert.org int m_store_waiting_on_load_cycles; 1167039Snate@binkert.org int m_store_waiting_on_store_cycles; 1177039Snate@binkert.org int m_load_waiting_on_store_cycles; 1187039Snate@binkert.org int m_load_waiting_on_load_cycles; 1196859Sdrh5@cs.wisc.edu 1207039Snate@binkert.org bool m_usingRubyTester; 1216886SBrad.Beckmann@amd.com 1227039Snate@binkert.org class SequencerWakeupEvent : public Event 1237039Snate@binkert.org { 1247039Snate@binkert.org private: 1257039Snate@binkert.org Sequencer *m_sequencer_ptr; 1266899SBrad.Beckmann@amd.com 1277039Snate@binkert.org public: 1287039Snate@binkert.org SequencerWakeupEvent(Sequencer *_seq) : m_sequencer_ptr(_seq) {} 1297039Snate@binkert.org void process() { m_sequencer_ptr->wakeup(); } 1307039Snate@binkert.org const char *description() const { return "Sequencer deadlock check"; } 1317039Snate@binkert.org }; 1326886SBrad.Beckmann@amd.com 1337039Snate@binkert.org SequencerWakeupEvent deadlockCheckEvent; 1346145Snate@binkert.org}; 1356145Snate@binkert.org 1367039Snate@binkert.orginline ostream& 1377039Snate@binkert.orgoperator<<(ostream& out, const Sequencer& obj) 1386145Snate@binkert.org{ 1397039Snate@binkert.org obj.print(out); 1407039Snate@binkert.org out << flush; 1417039Snate@binkert.org return out; 1426145Snate@binkert.org} 1436145Snate@binkert.org 1447039Snate@binkert.org#endif // __MEM_RUBY_SYSTEM_SEQUENCER_HH__ 1456145Snate@binkert.org 146