RubySystem.hh revision 9504
11881Sbinkertn@umich.edu/* 21881Sbinkertn@umich.edu * Copyright (c) 1999-2012 Mark D. Hill and David A. Wood 31881Sbinkertn@umich.edu * All rights reserved. 41881Sbinkertn@umich.edu * 51881Sbinkertn@umich.edu * Redistribution and use in source and binary forms, with or without 61881Sbinkertn@umich.edu * modification, are permitted provided that the following conditions are 71881Sbinkertn@umich.edu * met: redistributions of source code must retain the above copyright 81881Sbinkertn@umich.edu * notice, this list of conditions and the following disclaimer; 91881Sbinkertn@umich.edu * redistributions in binary form must reproduce the above copyright 101881Sbinkertn@umich.edu * notice, this list of conditions and the following disclaimer in the 111881Sbinkertn@umich.edu * documentation and/or other materials provided with the distribution; 121881Sbinkertn@umich.edu * neither the name of the copyright holders nor the names of its 131881Sbinkertn@umich.edu * contributors may be used to endorse or promote products derived from 141881Sbinkertn@umich.edu * this software without specific prior written permission. 151881Sbinkertn@umich.edu * 161881Sbinkertn@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 171881Sbinkertn@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 181881Sbinkertn@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 191881Sbinkertn@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 201881Sbinkertn@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 211881Sbinkertn@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 221881Sbinkertn@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 231881Sbinkertn@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 241881Sbinkertn@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 251881Sbinkertn@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 261881Sbinkertn@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 271881Sbinkertn@umich.edu */ 281881Sbinkertn@umich.edu 291917Sbinkertn@umich.edu/* 301917Sbinkertn@umich.edu * Contains all of the various parts of the system we are simulating. 311917Sbinkertn@umich.edu * Performs allocation, deallocation, and setup of all the major 321917Sbinkertn@umich.edu * components of the system 331917Sbinkertn@umich.edu */ 341917Sbinkertn@umich.edu 351917Sbinkertn@umich.edu#ifndef __MEM_RUBY_SYSTEM_SYSTEM_HH__ 361917Sbinkertn@umich.edu#define __MEM_RUBY_SYSTEM_SYSTEM_HH__ 371917Sbinkertn@umich.edu 381917Sbinkertn@umich.edu#include "base/callback.hh" 391917Sbinkertn@umich.edu#include "base/output.hh" 401917Sbinkertn@umich.edu#include "mem/packet.hh" 411917Sbinkertn@umich.edu#include "mem/ruby/common/Global.hh" 421917Sbinkertn@umich.edu#include "mem/ruby/recorder/CacheRecorder.hh" 431917Sbinkertn@umich.edu#include "mem/ruby/slicc_interface/AbstractController.hh" 441917Sbinkertn@umich.edu#include "mem/ruby/system/MemoryVector.hh" 451917Sbinkertn@umich.edu#include "mem/ruby/system/SparseMemory.hh" 461917Sbinkertn@umich.edu#include "params/RubySystem.hh" 471917Sbinkertn@umich.edu#include "sim/clocked_object.hh" 481917Sbinkertn@umich.edu 491917Sbinkertn@umich.educlass Network; 501917Sbinkertn@umich.educlass Profiler; 511917Sbinkertn@umich.educlass MemoryControl; 521917Sbinkertn@umich.edu 531917Sbinkertn@umich.educlass RubySystem : public ClockedObject 541917Sbinkertn@umich.edu{ 551917Sbinkertn@umich.edu public: 561917Sbinkertn@umich.edu class RubyEvent : public Event 571917Sbinkertn@umich.edu { 581917Sbinkertn@umich.edu public: 591917Sbinkertn@umich.edu RubyEvent(RubySystem* _ruby_system) 601917Sbinkertn@umich.edu { 611917Sbinkertn@umich.edu ruby_system = _ruby_system; 621917Sbinkertn@umich.edu } 631917Sbinkertn@umich.edu private: 641917Sbinkertn@umich.edu void process(); 651917Sbinkertn@umich.edu 661917Sbinkertn@umich.edu RubySystem* ruby_system; 671917Sbinkertn@umich.edu }; 681917Sbinkertn@umich.edu 691917Sbinkertn@umich.edu friend class RubyEvent; 701917Sbinkertn@umich.edu 711917Sbinkertn@umich.edu typedef RubySystemParams Params; 721917Sbinkertn@umich.edu RubySystem(const Params *p); 731917Sbinkertn@umich.edu ~RubySystem(); 741917Sbinkertn@umich.edu 751917Sbinkertn@umich.edu // config accessors 761917Sbinkertn@umich.edu static int getRandomSeed() { return m_random_seed; } 771917Sbinkertn@umich.edu static int getRandomization() { return m_randomization; } 781917Sbinkertn@umich.edu static uint32_t getBlockSizeBytes() { return m_block_size_bytes; } 791917Sbinkertn@umich.edu static uint32_t getBlockSizeBits() { return m_block_size_bits; } 801917Sbinkertn@umich.edu static uint64_t getMemorySizeBytes() { return m_memory_size_bytes; } 811917Sbinkertn@umich.edu static uint32_t getMemorySizeBits() { return m_memory_size_bits; } 821917Sbinkertn@umich.edu Cycles getTime() const { return curCycle(); } 831917Sbinkertn@umich.edu 841917Sbinkertn@umich.edu // Public Methods 851917Sbinkertn@umich.edu Network* 861917Sbinkertn@umich.edu getNetwork() 871917Sbinkertn@umich.edu { 881917Sbinkertn@umich.edu assert(m_network_ptr != NULL); 891917Sbinkertn@umich.edu return m_network_ptr; 901917Sbinkertn@umich.edu } 911917Sbinkertn@umich.edu 921917Sbinkertn@umich.edu Profiler* 931917Sbinkertn@umich.edu getProfiler() 941917Sbinkertn@umich.edu { 951917Sbinkertn@umich.edu assert(m_profiler_ptr != NULL); 961917Sbinkertn@umich.edu return m_profiler_ptr; 971917Sbinkertn@umich.edu } 981917Sbinkertn@umich.edu 991917Sbinkertn@umich.edu MemoryVector* 1001917Sbinkertn@umich.edu getMemoryVector() 1011917Sbinkertn@umich.edu { 1021917Sbinkertn@umich.edu assert(m_mem_vec_ptr != NULL); 1031917Sbinkertn@umich.edu return m_mem_vec_ptr; 1041917Sbinkertn@umich.edu } 1051917Sbinkertn@umich.edu 1061917Sbinkertn@umich.edu void printStats(std::ostream& out); 1071917Sbinkertn@umich.edu void resetStats(); 1081917Sbinkertn@umich.edu 1091917Sbinkertn@umich.edu uint64 getInstructionCount(int thread) { return 1; } 1101917Sbinkertn@umich.edu 1111917Sbinkertn@umich.edu void print(std::ostream& out) const; 1121917Sbinkertn@umich.edu 1131917Sbinkertn@umich.edu void serialize(std::ostream &os); 1141917Sbinkertn@umich.edu void unserialize(Checkpoint *cp, const std::string §ion); 1151917Sbinkertn@umich.edu void process(); 1161917Sbinkertn@umich.edu void startup(); 1171917Sbinkertn@umich.edu bool functionalRead(Packet *ptr); 1181596SN/A bool functionalWrite(Packet *ptr); 1191596SN/A 1201596SN/A void registerNetwork(Network*); 1211596SN/A void registerProfiler(Profiler*); 1221596SN/A void registerAbstractController(AbstractController*); 1231596SN/A void registerSparseMemory(SparseMemory*); 1241596SN/A void registerMemController(MemoryControl *mc); 1251596SN/A 1261596SN/A bool eventQueueEmpty() { return eventq->empty(); } 1271596SN/A void enqueueRubyEvent(Tick tick) 1281917Sbinkertn@umich.edu { 1291917Sbinkertn@umich.edu RubyEvent* e = new RubyEvent(this); 1301596SN/A schedule(e, tick); 1311917Sbinkertn@umich.edu } 1321596SN/A 1331596SN/A private: 1341596SN/A // Private copy constructor and assignment operator 1351917Sbinkertn@umich.edu RubySystem(const RubySystem& obj); 1361917Sbinkertn@umich.edu RubySystem& operator=(const RubySystem& obj); 1371596SN/A 1381596SN/A void init(); 1391596SN/A 1401596SN/A void readCompressedTrace(std::string filename, 1411596SN/A uint8_t *&raw_data, 1421596SN/A uint64& uncompressed_trace_size); 1431596SN/A void writeCompressedTrace(uint8_t *raw_data, std::string file, 1441596SN/A uint64 uncompressed_trace_size); 1451596SN/A 1461596SN/A private: 1471596SN/A // configuration parameters 1481596SN/A static int m_random_seed; 1491596SN/A static bool m_randomization; 1501596SN/A static uint32_t m_block_size_bytes; 1511596SN/A static uint32_t m_block_size_bits; 1521596SN/A static uint64_t m_memory_size_bytes; 1531596SN/A static uint32_t m_memory_size_bits; 1541596SN/A 1551596SN/A Network* m_network_ptr; 1561596SN/A std::vector<MemoryControl *> m_memory_controller_vec; 1571596SN/A std::vector<AbstractController *> m_abs_cntrl_vec; 1581596SN/A 1591596SN/A public: 1601596SN/A Profiler* m_profiler_ptr; 1611596SN/A MemoryVector* m_mem_vec_ptr; 1621596SN/A bool m_warmup_enabled; 1631596SN/A bool m_cooldown_enabled; 1641596SN/A CacheRecorder* m_cache_recorder; 1651596SN/A std::vector<SparseMemory*> m_sparse_memory_vector; 1661596SN/A}; 1671596SN/A 1681596SN/Ainline std::ostream& 1691917Sbinkertn@umich.eduoperator<<(std::ostream& out, const RubySystem& obj) 1701917Sbinkertn@umich.edu{ 1711596SN/A //obj.print(out); 1721596SN/A out << std::flush; 1731596SN/A return out; 1741917Sbinkertn@umich.edu} 1751917Sbinkertn@umich.edu 1761917Sbinkertn@umich.educlass RubyDumpStatsCallback : public Callback 1771596SN/A{ 1781596SN/A private: 1791917Sbinkertn@umich.edu std::ostream *os; 1801596SN/A RubySystem *ruby_system; 1811596SN/A 1821596SN/A public: 1831596SN/A virtual ~RubyDumpStatsCallback() {} 1841596SN/A 1851596SN/A RubyDumpStatsCallback(const std::string& _stats_filename, 1861596SN/A RubySystem *system) 1871596SN/A { 1881917Sbinkertn@umich.edu os = simout.create(_stats_filename); 1891596SN/A ruby_system = system; 1901596SN/A } 1911596SN/A 1921596SN/A void process(); 1931917Sbinkertn@umich.edu}; 1941917Sbinkertn@umich.edu 1951917Sbinkertn@umich.edu#endif // __MEM_RUBY_SYSTEM_SYSTEM_HH__ 1961596SN/A