RubySystem.hh revision 11523
16313Sgblack@eecs.umich.edu/* 214128Sgiacomo.travaglini@arm.com * Copyright (c) 1999-2012 Mark D. Hill and David A. Wood 37093Sgblack@eecs.umich.edu * All rights reserved. 47093Sgblack@eecs.umich.edu * 57093Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without 67093Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are 77093Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright 87093Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer; 97093Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright 107093Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the 117093Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution; 127093Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its 137093Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from 146313Sgblack@eecs.umich.edu * this software without specific prior written permission. 156313Sgblack@eecs.umich.edu * 166313Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 176313Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 186313Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 196313Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 206313Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 216313Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 226313Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 236313Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 246313Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 256313Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 266313Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 276313Sgblack@eecs.umich.edu */ 286313Sgblack@eecs.umich.edu 296313Sgblack@eecs.umich.edu/* 306313Sgblack@eecs.umich.edu * Contains all of the various parts of the system we are simulating. 316313Sgblack@eecs.umich.edu * Performs allocation, deallocation, and setup of all the major 326313Sgblack@eecs.umich.edu * components of the system 336313Sgblack@eecs.umich.edu */ 346313Sgblack@eecs.umich.edu 356313Sgblack@eecs.umich.edu#ifndef __MEM_RUBY_SYSTEM_SYSTEM_HH__ 366313Sgblack@eecs.umich.edu#define __MEM_RUBY_SYSTEM_SYSTEM_HH__ 376313Sgblack@eecs.umich.edu 386313Sgblack@eecs.umich.edu#include "base/callback.hh" 396313Sgblack@eecs.umich.edu#include "base/output.hh" 406313Sgblack@eecs.umich.edu#include "mem/packet.hh" 416313Sgblack@eecs.umich.edu#include "mem/ruby/profiler/Profiler.hh" 426313Sgblack@eecs.umich.edu#include "mem/ruby/slicc_interface/AbstractController.hh" 436313Sgblack@eecs.umich.edu#include "mem/ruby/system/CacheRecorder.hh" 447404SAli.Saidi@ARM.com#include "params/RubySystem.hh" 456313Sgblack@eecs.umich.edu#include "sim/clocked_object.hh" 4610461SAndreas.Sandberg@ARM.com 4712479SCurtis.Dunham@arm.comclass Network; 486333Sgblack@eecs.umich.educlass AbstractController; 4910037SARM gem5 Developers 507404SAli.Saidi@ARM.comclass RubySystem : public ClockedObject 516313Sgblack@eecs.umich.edu{ 5212109SRekai.GonzalezAlberquilla@arm.com public: 538232Snate@binkert.org class RubyEvent : public Event 5412109SRekai.GonzalezAlberquilla@arm.com { 559384SAndreas.Sandberg@arm.com public: 5611165SRekai.GonzalezAlberquilla@arm.com RubyEvent(RubySystem* _ruby_system) 576313Sgblack@eecs.umich.edu { 589384SAndreas.Sandberg@arm.com m_ruby_system = _ruby_system; 5910461SAndreas.Sandberg@ARM.com } 606333Sgblack@eecs.umich.edu private: 616313Sgblack@eecs.umich.edu void process(); 626313Sgblack@eecs.umich.edu 636313Sgblack@eecs.umich.edu RubySystem* m_ruby_system; 646313Sgblack@eecs.umich.edu }; 656313Sgblack@eecs.umich.edu 669384SAndreas.Sandberg@arm.com friend class RubyEvent; 676313Sgblack@eecs.umich.edu 686313Sgblack@eecs.umich.edu typedef RubySystemParams Params; 6910037SARM gem5 Developers RubySystem(const Params *p); 7010037SARM gem5 Developers ~RubySystem(); 7110037SARM gem5 Developers 7211165SRekai.GonzalezAlberquilla@arm.com // config accessors 7311165SRekai.GonzalezAlberquilla@arm.com static int getRandomization() { return m_randomization; } 7412109SRekai.GonzalezAlberquilla@arm.com static uint32_t getBlockSizeBytes() { return m_block_size_bytes; } 7511165SRekai.GonzalezAlberquilla@arm.com static uint32_t getBlockSizeBits() { return m_block_size_bits; } 7610461SAndreas.Sandberg@ARM.com static uint32_t getMemorySizeBits() { return m_memory_size_bits; } 7710461SAndreas.Sandberg@ARM.com static bool getWarmupEnabled() { return m_warmup_enabled; } 7810461SAndreas.Sandberg@ARM.com static bool getCooldownEnabled() { return m_cooldown_enabled; } 7910461SAndreas.Sandberg@ARM.com 8010461SAndreas.Sandberg@ARM.com SimpleMemory *getPhysMem() { return m_phys_mem; } 8110461SAndreas.Sandberg@ARM.com Cycles getStartCycle() { return m_start_cycle; } 8210844Sandreas.sandberg@arm.com bool getAccessBackingStore() { return m_access_backing_store; } 8310844Sandreas.sandberg@arm.com 8410844Sandreas.sandberg@arm.com // Public Methods 8513531Sjairo.balart@metempsy.com Profiler* 8613531Sjairo.balart@metempsy.com getProfiler() 8713531Sjairo.balart@metempsy.com { 8810037SARM gem5 Developers assert(m_profiler != NULL); 8911771SCurtis.Dunham@arm.com return m_profiler; 9010037SARM gem5 Developers } 9110037SARM gem5 Developers 9210037SARM gem5 Developers void regStats() override { 9313173Sgiacomo.travaglini@arm.com ClockedObject::regStats(); 9410037SARM gem5 Developers m_profiler->regStats(name()); 9513531Sjairo.balart@metempsy.com } 9613114Sgiacomo.travaglini@arm.com void collateStats() { m_profiler->collateStats(); } 9713759Sgiacomo.gabrielli@arm.com void resetStats() override; 9814133Sjordi.vaquero@metempsy.com 9914128Sgiacomo.travaglini@arm.com void memWriteback() override; 10013759Sgiacomo.gabrielli@arm.com void serialize(CheckpointOut &cp) const override; 10113759Sgiacomo.gabrielli@arm.com void unserialize(CheckpointIn &cp) override; 10213759Sgiacomo.gabrielli@arm.com void drainResume() override; 10310037SARM gem5 Developers void process(); 10412714Sgiacomo.travaglini@arm.com void startup() override; 10512714Sgiacomo.travaglini@arm.com bool functionalRead(Packet *ptr); 10612714Sgiacomo.travaglini@arm.com bool functionalWrite(Packet *ptr); 10712714Sgiacomo.travaglini@arm.com 10812714Sgiacomo.travaglini@arm.com void registerNetwork(Network*); 10912714Sgiacomo.travaglini@arm.com void registerAbstractController(AbstractController*); 11014000Sgiacomo.travaglini@arm.com 11114000Sgiacomo.travaglini@arm.com bool eventQueueEmpty() { return eventq->empty(); } 11212478SCurtis.Dunham@arm.com void enqueueRubyEvent(Tick tick) 11310037SARM gem5 Developers { 11412477SCurtis.Dunham@arm.com RubyEvent* e = new RubyEvent(this); 11512477SCurtis.Dunham@arm.com schedule(e, tick); 11612478SCurtis.Dunham@arm.com } 11712478SCurtis.Dunham@arm.com 11812478SCurtis.Dunham@arm.com private: 11912478SCurtis.Dunham@arm.com // Private copy constructor and assignment operator 12012478SCurtis.Dunham@arm.com RubySystem(const RubySystem& obj); 12112478SCurtis.Dunham@arm.com RubySystem& operator=(const RubySystem& obj); 12212478SCurtis.Dunham@arm.com 12312478SCurtis.Dunham@arm.com void makeCacheRecorder(uint8_t *uncompressed_trace, 12412478SCurtis.Dunham@arm.com uint64_t cache_trace_size, 12512478SCurtis.Dunham@arm.com uint64_t block_size_bytes); 12612478SCurtis.Dunham@arm.com 12712478SCurtis.Dunham@arm.com static void readCompressedTrace(std::string filename, 12812478SCurtis.Dunham@arm.com uint8_t *&raw_data, 12912478SCurtis.Dunham@arm.com uint64_t &uncompressed_trace_size); 13012478SCurtis.Dunham@arm.com static void writeCompressedTrace(uint8_t *raw_data, std::string file, 13112478SCurtis.Dunham@arm.com uint64_t uncompressed_trace_size); 13210037SARM gem5 Developers 13310037SARM gem5 Developers private: 13412477SCurtis.Dunham@arm.com // configuration parameters 13512479SCurtis.Dunham@arm.com static bool m_randomization; 13612477SCurtis.Dunham@arm.com static uint32_t m_block_size_bytes; 13712477SCurtis.Dunham@arm.com static uint32_t m_block_size_bits; 13812477SCurtis.Dunham@arm.com static uint32_t m_memory_size_bits; 13912479SCurtis.Dunham@arm.com 14012477SCurtis.Dunham@arm.com static bool m_warmup_enabled; 14112477SCurtis.Dunham@arm.com static unsigned m_systems_to_warmup; 14212477SCurtis.Dunham@arm.com static bool m_cooldown_enabled; 14312477SCurtis.Dunham@arm.com SimpleMemory *m_phys_mem; 14412477SCurtis.Dunham@arm.com const bool m_access_backing_store; 14512477SCurtis.Dunham@arm.com 14612477SCurtis.Dunham@arm.com Network* m_network; 14712478SCurtis.Dunham@arm.com std::vector<AbstractController *> m_abs_cntrl_vec; 14812478SCurtis.Dunham@arm.com Cycles m_start_cycle; 14912478SCurtis.Dunham@arm.com 15012478SCurtis.Dunham@arm.com public: 15112478SCurtis.Dunham@arm.com Profiler* m_profiler; 15212478SCurtis.Dunham@arm.com CacheRecorder* m_cache_recorder; 15312478SCurtis.Dunham@arm.com std::vector<std::map<uint32_t, AbstractController *> > m_abstract_controls; 15412478SCurtis.Dunham@arm.com}; 15512478SCurtis.Dunham@arm.com 15612478SCurtis.Dunham@arm.comclass RubyStatsCallback : public Callback 15712478SCurtis.Dunham@arm.com{ 15812478SCurtis.Dunham@arm.com private: 15912478SCurtis.Dunham@arm.com RubySystem *m_ruby_system; 16012478SCurtis.Dunham@arm.com 16112478SCurtis.Dunham@arm.com public: 16212478SCurtis.Dunham@arm.com virtual ~RubyStatsCallback() {} 16312479SCurtis.Dunham@arm.com RubyStatsCallback(RubySystem *system) : m_ruby_system(system) {} 16412479SCurtis.Dunham@arm.com void process() { m_ruby_system->collateStats(); } 16512479SCurtis.Dunham@arm.com}; 16612479SCurtis.Dunham@arm.com 16712479SCurtis.Dunham@arm.com#endif // __MEM_RUBY_SYSTEM_SYSTEM_HH__ 16812479SCurtis.Dunham@arm.com