Sequencer.hh revision 8171
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 327055Snate@binkert.org#include <iostream> 337055Snate@binkert.org 347455Snate@binkert.org#include "base/hashmap.hh" 358164Snilay@cs.wisc.edu#include "mem/protocol/RubyAccessMode.hh" 368165Snilay@cs.wisc.edu#include "mem/protocol/RubyRequestType.hh" 376154Snate@binkert.org#include "mem/protocol/GenericMachineType.hh" 386154Snate@binkert.org#include "mem/protocol/PrefetchBit.hh" 397039Snate@binkert.org#include "mem/ruby/common/Address.hh" 407039Snate@binkert.org#include "mem/ruby/common/Consumer.hh" 417039Snate@binkert.org#include "mem/ruby/common/Global.hh" 426285Snate@binkert.org#include "mem/ruby/system/RubyPort.hh" 436145Snate@binkert.org 446145Snate@binkert.orgclass DataBlock; 456145Snate@binkert.orgclass CacheMsg; 466145Snate@binkert.orgclass MachineID; 476285Snate@binkert.orgclass CacheMemory; 486876Ssteve.reinhardt@amd.com 496876Ssteve.reinhardt@amd.comclass RubySequencerParams; 506145Snate@binkert.org 517039Snate@binkert.orgstruct SequencerRequest 527039Snate@binkert.org{ 537039Snate@binkert.org RubyRequest ruby_request; 547039Snate@binkert.org Time issue_time; 556285Snate@binkert.org 567039Snate@binkert.org SequencerRequest(const RubyRequest & _ruby_request, Time _issue_time) 577039Snate@binkert.org : ruby_request(_ruby_request), issue_time(_issue_time) 587039Snate@binkert.org {} 596285Snate@binkert.org}; 606285Snate@binkert.org 616763SBrad.Beckmann@amd.comstd::ostream& operator<<(std::ostream& out, const SequencerRequest& obj); 626763SBrad.Beckmann@amd.com 637039Snate@binkert.orgclass Sequencer : public RubyPort, public Consumer 647039Snate@binkert.org{ 657039Snate@binkert.org public: 666876Ssteve.reinhardt@amd.com typedef RubySequencerParams Params; 677039Snate@binkert.org Sequencer(const Params *); 687039Snate@binkert.org ~Sequencer(); 696145Snate@binkert.org 707039Snate@binkert.org // Public Methods 717039Snate@binkert.org void wakeup(); // Used only for deadlock detection 726145Snate@binkert.org 737055Snate@binkert.org void printConfig(std::ostream& out) const; 746145Snate@binkert.org 757055Snate@binkert.org void printProgress(std::ostream& out) const; 766145Snate@binkert.org 777039Snate@binkert.org void writeCallback(const Address& address, DataBlock& data); 787546SBrad.Beckmann@amd.com 797546SBrad.Beckmann@amd.com void writeCallback(const Address& address, 807546SBrad.Beckmann@amd.com GenericMachineType mach, 817546SBrad.Beckmann@amd.com DataBlock& data); 827546SBrad.Beckmann@amd.com 837565SBrad.Beckmann@amd.com void writeCallback(const Address& address, 847565SBrad.Beckmann@amd.com GenericMachineType mach, 857565SBrad.Beckmann@amd.com DataBlock& data, 867565SBrad.Beckmann@amd.com Time initialRequestTime, 877565SBrad.Beckmann@amd.com Time forwardRequestTime, 887565SBrad.Beckmann@amd.com Time firstResponseTime); 897565SBrad.Beckmann@amd.com 907039Snate@binkert.org void readCallback(const Address& address, DataBlock& data); 916145Snate@binkert.org 927546SBrad.Beckmann@amd.com void readCallback(const Address& address, 937546SBrad.Beckmann@amd.com GenericMachineType mach, 947546SBrad.Beckmann@amd.com DataBlock& data); 957546SBrad.Beckmann@amd.com 967565SBrad.Beckmann@amd.com void readCallback(const Address& address, 977565SBrad.Beckmann@amd.com GenericMachineType mach, 987565SBrad.Beckmann@amd.com DataBlock& data, 997565SBrad.Beckmann@amd.com Time initialRequestTime, 1007565SBrad.Beckmann@amd.com Time forwardRequestTime, 1017565SBrad.Beckmann@amd.com Time firstResponseTime); 1027565SBrad.Beckmann@amd.com 1037039Snate@binkert.org RequestStatus makeRequest(const RubyRequest & request); 1047039Snate@binkert.org RequestStatus getRequestStatus(const RubyRequest& request); 1057039Snate@binkert.org bool empty() const; 1066145Snate@binkert.org 1077055Snate@binkert.org void print(std::ostream& out) const; 1087055Snate@binkert.org void printStats(std::ostream& out) const; 1097039Snate@binkert.org void checkCoherence(const Address& address); 1106145Snate@binkert.org 1117455Snate@binkert.org void markRemoved(); 1127039Snate@binkert.org void removeRequest(SequencerRequest* request); 1136145Snate@binkert.org 1147039Snate@binkert.org private: 1158165Snilay@cs.wisc.edu bool tryCacheAccess(const Address& addr, RubyRequestType type, 1168164Snilay@cs.wisc.edu const Address& pc, RubyAccessMode access_mode, 1177039Snate@binkert.org int size, DataBlock*& data_ptr); 1187039Snate@binkert.org void issueRequest(const RubyRequest& request); 1196145Snate@binkert.org 1207546SBrad.Beckmann@amd.com void hitCallback(SequencerRequest* request, 1217546SBrad.Beckmann@amd.com GenericMachineType mach, 1227560SBrad.Beckmann@amd.com DataBlock& data, 1237565SBrad.Beckmann@amd.com bool success, 1247565SBrad.Beckmann@amd.com Time initialRequestTime, 1257565SBrad.Beckmann@amd.com Time forwardRequestTime, 1267565SBrad.Beckmann@amd.com Time firstResponseTime); 1277546SBrad.Beckmann@amd.com 1287039Snate@binkert.org bool insertRequest(SequencerRequest* request); 1296285Snate@binkert.org 1307560SBrad.Beckmann@amd.com bool handleLlsc(const Address& address, SequencerRequest* request); 1316145Snate@binkert.org 1327039Snate@binkert.org // Private copy constructor and assignment operator 1337039Snate@binkert.org Sequencer(const Sequencer& obj); 1347039Snate@binkert.org Sequencer& operator=(const Sequencer& obj); 1356145Snate@binkert.org 1367039Snate@binkert.org private: 1377039Snate@binkert.org int m_max_outstanding_requests; 1387039Snate@binkert.org int m_deadlock_threshold; 1396145Snate@binkert.org 1407039Snate@binkert.org CacheMemory* m_dataCache_ptr; 1417039Snate@binkert.org CacheMemory* m_instCache_ptr; 1426285Snate@binkert.org 1437455Snate@binkert.org typedef m5::hash_map<Address, SequencerRequest*> RequestTable; 1447455Snate@binkert.org RequestTable m_writeRequestTable; 1457455Snate@binkert.org RequestTable m_readRequestTable; 1467039Snate@binkert.org // Global outstanding request count, across all request tables 1477039Snate@binkert.org int m_outstanding_count; 1487039Snate@binkert.org bool m_deadlock_check_scheduled; 1496145Snate@binkert.org 1507039Snate@binkert.org int m_store_waiting_on_load_cycles; 1517039Snate@binkert.org int m_store_waiting_on_store_cycles; 1527039Snate@binkert.org int m_load_waiting_on_store_cycles; 1537039Snate@binkert.org int m_load_waiting_on_load_cycles; 1546859Sdrh5@cs.wisc.edu 1558171Stushar@csail.mit.edu bool m_usingNetworkTester; 1568171Stushar@csail.mit.edu 1577039Snate@binkert.org class SequencerWakeupEvent : public Event 1587039Snate@binkert.org { 1597039Snate@binkert.org private: 1607039Snate@binkert.org Sequencer *m_sequencer_ptr; 1616899SBrad.Beckmann@amd.com 1627039Snate@binkert.org public: 1637039Snate@binkert.org SequencerWakeupEvent(Sequencer *_seq) : m_sequencer_ptr(_seq) {} 1647039Snate@binkert.org void process() { m_sequencer_ptr->wakeup(); } 1657039Snate@binkert.org const char *description() const { return "Sequencer deadlock check"; } 1667039Snate@binkert.org }; 1676886SBrad.Beckmann@amd.com 1687039Snate@binkert.org SequencerWakeupEvent deadlockCheckEvent; 1696145Snate@binkert.org}; 1706145Snate@binkert.org 1717055Snate@binkert.orginline std::ostream& 1727055Snate@binkert.orgoperator<<(std::ostream& out, const Sequencer& obj) 1736145Snate@binkert.org{ 1747039Snate@binkert.org obj.print(out); 1757055Snate@binkert.org out << std::flush; 1767039Snate@binkert.org return out; 1776145Snate@binkert.org} 1786145Snate@binkert.org 1797039Snate@binkert.org#endif // __MEM_RUBY_SYSTEM_SEQUENCER_HH__ 1806145Snate@binkert.org 181