RubySystem.hh revision 10920
14484Sbinkertn@umich.edu/* 24484Sbinkertn@umich.edu * Copyright (c) 1999-2012 Mark D. Hill and David A. Wood 34484Sbinkertn@umich.edu * All rights reserved. 44484Sbinkertn@umich.edu * 54484Sbinkertn@umich.edu * Redistribution and use in source and binary forms, with or without 64484Sbinkertn@umich.edu * modification, are permitted provided that the following conditions are 74484Sbinkertn@umich.edu * met: redistributions of source code must retain the above copyright 84484Sbinkertn@umich.edu * notice, this list of conditions and the following disclaimer; 94484Sbinkertn@umich.edu * redistributions in binary form must reproduce the above copyright 104484Sbinkertn@umich.edu * notice, this list of conditions and the following disclaimer in the 114484Sbinkertn@umich.edu * documentation and/or other materials provided with the distribution; 124484Sbinkertn@umich.edu * neither the name of the copyright holders nor the names of its 134484Sbinkertn@umich.edu * contributors may be used to endorse or promote products derived from 144484Sbinkertn@umich.edu * this software without specific prior written permission. 154484Sbinkertn@umich.edu * 164484Sbinkertn@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 174484Sbinkertn@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 184484Sbinkertn@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 194484Sbinkertn@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 204484Sbinkertn@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 214484Sbinkertn@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 224484Sbinkertn@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 234484Sbinkertn@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 244484Sbinkertn@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 254484Sbinkertn@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 264484Sbinkertn@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 274484Sbinkertn@umich.edu */ 284484Sbinkertn@umich.edu 294484Sbinkertn@umich.edu/* 304484Sbinkertn@umich.edu * Contains all of the various parts of the system we are simulating. 314494Ssaidi@eecs.umich.edu * Performs allocation, deallocation, and setup of all the major 324484Sbinkertn@umich.edu * components of the system 336121Snate@binkert.org */ 344484Sbinkertn@umich.edu 354484Sbinkertn@umich.edu#ifndef __MEM_RUBY_SYSTEM_SYSTEM_HH__ 364484Sbinkertn@umich.edu#define __MEM_RUBY_SYSTEM_SYSTEM_HH__ 374484Sbinkertn@umich.edu 384781Snate@binkert.org#include "base/callback.hh" 394484Sbinkertn@umich.edu#include "base/output.hh" 404484Sbinkertn@umich.edu#include "mem/ruby/profiler/Profiler.hh" 414484Sbinkertn@umich.edu#include "mem/ruby/slicc_interface/AbstractController.hh" 424484Sbinkertn@umich.edu#include "mem/ruby/system/CacheRecorder.hh" 434484Sbinkertn@umich.edu#include "mem/packet.hh" 444484Sbinkertn@umich.edu#include "params/RubySystem.hh" 454484Sbinkertn@umich.edu#include "sim/clocked_object.hh" 464484Sbinkertn@umich.edu 474484Sbinkertn@umich.educlass Network; 484484Sbinkertn@umich.educlass AbstractController; 494484Sbinkertn@umich.edu 504484Sbinkertn@umich.educlass RubySystem : public ClockedObject 514484Sbinkertn@umich.edu{ 524484Sbinkertn@umich.edu public: 534484Sbinkertn@umich.edu class RubyEvent : public Event 544484Sbinkertn@umich.edu { 554484Sbinkertn@umich.edu public: 564484Sbinkertn@umich.edu RubyEvent(RubySystem* _ruby_system) 574484Sbinkertn@umich.edu { 584484Sbinkertn@umich.edu m_ruby_system = _ruby_system; 594484Sbinkertn@umich.edu } 604484Sbinkertn@umich.edu private: 614484Sbinkertn@umich.edu void process(); 624484Sbinkertn@umich.edu 634484Sbinkertn@umich.edu RubySystem* m_ruby_system; 644484Sbinkertn@umich.edu }; 654484Sbinkertn@umich.edu 664484Sbinkertn@umich.edu friend class RubyEvent; 674484Sbinkertn@umich.edu 684484Sbinkertn@umich.edu typedef RubySystemParams Params; 694484Sbinkertn@umich.edu RubySystem(const Params *p); 704484Sbinkertn@umich.edu ~RubySystem(); 714484Sbinkertn@umich.edu 724484Sbinkertn@umich.edu // config accessors 734484Sbinkertn@umich.edu static int getRandomSeed() { return m_random_seed; } 744484Sbinkertn@umich.edu static int getRandomization() { return m_randomization; } 754484Sbinkertn@umich.edu static uint32_t getBlockSizeBytes() { return m_block_size_bytes; } 764484Sbinkertn@umich.edu static uint32_t getBlockSizeBits() { return m_block_size_bits; } 774484Sbinkertn@umich.edu static uint32_t getMemorySizeBits() { return m_memory_size_bits; } 784484Sbinkertn@umich.edu static bool getWarmupEnabled() { return m_warmup_enabled; } 794484Sbinkertn@umich.edu static bool getCooldownEnabled() { return m_cooldown_enabled; } 804484Sbinkertn@umich.edu 814484Sbinkertn@umich.edu SimpleMemory *getPhysMem() { return m_phys_mem; } 824484Sbinkertn@umich.edu Cycles getStartCycle() { return m_start_cycle; } 834484Sbinkertn@umich.edu const bool getAccessBackingStore() { return m_access_backing_store; } 844484Sbinkertn@umich.edu 854484Sbinkertn@umich.edu // Public Methods 864484Sbinkertn@umich.edu Profiler* 874484Sbinkertn@umich.edu getProfiler() 884484Sbinkertn@umich.edu { 894484Sbinkertn@umich.edu assert(m_profiler != NULL); 906121Snate@binkert.org return m_profiler; 916121Snate@binkert.org } 926121Snate@binkert.org 935765Snate@binkert.org void regStats() { m_profiler->regStats(name()); } 945765Snate@binkert.org void collateStats() { m_profiler->collateStats(); } 955765Snate@binkert.org void resetStats(); 965397Ssaidi@eecs.umich.edu 975274Ssaidi@eecs.umich.edu void serializeOld(CheckpointOut &cp) M5_ATTR_OVERRIDE; 984494Ssaidi@eecs.umich.edu void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; 994504Ssaidi@eecs.umich.edu void process(); 1004494Ssaidi@eecs.umich.edu void startup(); 1014494Ssaidi@eecs.umich.edu bool functionalRead(Packet *ptr); 1024496Ssaidi@eecs.umich.edu bool functionalWrite(Packet *ptr); 1034504Ssaidi@eecs.umich.edu 1044504Ssaidi@eecs.umich.edu void registerNetwork(Network*); 1054500Sbinkertn@umich.edu void registerAbstractController(AbstractController*); 1064500Sbinkertn@umich.edu 1074496Ssaidi@eecs.umich.edu bool eventQueueEmpty() { return eventq->empty(); } 1084496Ssaidi@eecs.umich.edu void enqueueRubyEvent(Tick tick) 1094487Sstever@eecs.umich.edu { 1104487Sstever@eecs.umich.edu RubyEvent* e = new RubyEvent(this); 1114484Sbinkertn@umich.edu schedule(e, tick); 1124484Sbinkertn@umich.edu } 1134484Sbinkertn@umich.edu 1144484Sbinkertn@umich.edu private: 1154484Sbinkertn@umich.edu // Private copy constructor and assignment operator 1164484Sbinkertn@umich.edu RubySystem(const RubySystem& obj); 1175601Snate@binkert.org RubySystem& operator=(const RubySystem& obj); 1185601Snate@binkert.org 1195601Snate@binkert.org void readCompressedTrace(std::string filename, 1205601Snate@binkert.org uint8_t *&raw_data, 1214484Sbinkertn@umich.edu uint64& uncompressed_trace_size); 1226121Snate@binkert.org void writeCompressedTrace(uint8_t *raw_data, std::string file, 1236121Snate@binkert.org uint64 uncompressed_trace_size); 1246121Snate@binkert.org 1254494Ssaidi@eecs.umich.edu private: 126 // configuration parameters 127 static int m_random_seed; 128 static bool m_randomization; 129 static uint32_t m_block_size_bytes; 130 static uint32_t m_block_size_bits; 131 static uint32_t m_memory_size_bits; 132 133 static bool m_warmup_enabled; 134 static unsigned m_systems_to_warmup; 135 static bool m_cooldown_enabled; 136 SimpleMemory *m_phys_mem; 137 const bool m_access_backing_store; 138 139 Network* m_network; 140 std::vector<AbstractController *> m_abs_cntrl_vec; 141 Cycles m_start_cycle; 142 143 public: 144 Profiler* m_profiler; 145 CacheRecorder* m_cache_recorder; 146 std::vector<std::map<uint32_t, AbstractController *> > m_abstract_controls; 147}; 148 149class RubyStatsCallback : public Callback 150{ 151 private: 152 RubySystem *m_ruby_system; 153 154 public: 155 virtual ~RubyStatsCallback() {} 156 RubyStatsCallback(RubySystem *system) : m_ruby_system(system) {} 157 void process() { m_ruby_system->collateStats(); } 158}; 159 160#endif // __MEM_RUBY_SYSTEM_SYSTEM_HH__ 161