RubySystem.hh revision 11523
16145SN/A/* 28688SN/A * Copyright (c) 1999-2012 Mark D. Hill and David A. Wood 36145SN/A * All rights reserved. 46145SN/A * 56145SN/A * Redistribution and use in source and binary forms, with or without 66145SN/A * modification, are permitted provided that the following conditions are 76145SN/A * met: redistributions of source code must retain the above copyright 86145SN/A * notice, this list of conditions and the following disclaimer; 96145SN/A * redistributions in binary form must reproduce the above copyright 106145SN/A * notice, this list of conditions and the following disclaimer in the 116145SN/A * documentation and/or other materials provided with the distribution; 126145SN/A * neither the name of the copyright holders nor the names of its 136145SN/A * contributors may be used to endorse or promote products derived from 146145SN/A * this software without specific prior written permission. 156145SN/A * 166145SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 176145SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 186145SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 196145SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 206145SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 216145SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 226145SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 236145SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 246145SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 256145SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 266145SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 276145SN/A */ 286145SN/A 296145SN/A/* 307039SN/A * Contains all of the various parts of the system we are simulating. 317039SN/A * Performs allocation, deallocation, and setup of all the major 327039SN/A * components of the system 336145SN/A */ 346145SN/A 357039SN/A#ifndef __MEM_RUBY_SYSTEM_SYSTEM_HH__ 367039SN/A#define __MEM_RUBY_SYSTEM_SYSTEM_HH__ 376145SN/A 387039SN/A#include "base/callback.hh" 399350SN/A#include "base/output.hh" 4011108Sdavid.hashe@amd.com#include "mem/packet.hh" 4110301SN/A#include "mem/ruby/profiler/Profiler.hh" 4210301SN/A#include "mem/ruby/slicc_interface/AbstractController.hh" 4310301SN/A#include "mem/ruby/system/CacheRecorder.hh" 447039SN/A#include "params/RubySystem.hh" 459206SN/A#include "sim/clocked_object.hh" 466145SN/A 477039SN/Aclass Network; 4810920SN/Aclass AbstractController; 496285SN/A 509206SN/Aclass RubySystem : public ClockedObject 517039SN/A{ 527039SN/A public: 538688SN/A class RubyEvent : public Event 548688SN/A { 558688SN/A public: 568688SN/A RubyEvent(RubySystem* _ruby_system) 578688SN/A { 5810919SN/A m_ruby_system = _ruby_system; 598688SN/A } 608688SN/A private: 618688SN/A void process(); 628688SN/A 6310919SN/A RubySystem* m_ruby_system; 648688SN/A }; 658688SN/A 668688SN/A friend class RubyEvent; 678688SN/A 686876SN/A typedef RubySystemParams Params; 696876SN/A RubySystem(const Params *p); 707039SN/A ~RubySystem(); 716145SN/A 727039SN/A // config accessors 737039SN/A static int getRandomization() { return m_randomization; } 749504SN/A static uint32_t getBlockSizeBytes() { return m_block_size_bytes; } 759504SN/A static uint32_t getBlockSizeBits() { return m_block_size_bits; } 769504SN/A static uint32_t getMemorySizeBits() { return m_memory_size_bits; } 7710837SN/A static bool getWarmupEnabled() { return m_warmup_enabled; } 7810837SN/A static bool getCooldownEnabled() { return m_cooldown_enabled; } 796285SN/A 8010525SN/A SimpleMemory *getPhysMem() { return m_phys_mem; } 8110918SN/A Cycles getStartCycle() { return m_start_cycle; } 8211294Sandreas.hansson@arm.com bool getAccessBackingStore() { return m_access_backing_store; } 8310525SN/A 847039SN/A // Public Methods 857039SN/A Profiler* 867039SN/A getProfiler() 877039SN/A { 8810012SN/A assert(m_profiler != NULL); 8910012SN/A return m_profiler; 907039SN/A } 916285SN/A 9211523Sdavid.guillen@arm.com void regStats() override { 9311523Sdavid.guillen@arm.com ClockedObject::regStats(); 9411523Sdavid.guillen@arm.com m_profiler->regStats(name()); 9511523Sdavid.guillen@arm.com } 9610012SN/A void collateStats() { m_profiler->collateStats(); } 9711169Sandreas.hansson@arm.com void resetStats() override; 986285SN/A 9911169Sandreas.hansson@arm.com void memWriteback() override; 10011168Sandreas.hansson@arm.com void serialize(CheckpointOut &cp) const override; 10111168Sandreas.hansson@arm.com void unserialize(CheckpointIn &cp) override; 10211168Sandreas.hansson@arm.com void drainResume() override; 1038688SN/A void process(); 10411169Sandreas.hansson@arm.com void startup() override; 1059270SN/A bool functionalRead(Packet *ptr); 1069270SN/A bool functionalWrite(Packet *ptr); 1077562SN/A 1088436SN/A void registerNetwork(Network*); 1098436SN/A void registerAbstractController(AbstractController*); 1108436SN/A 1118937SN/A bool eventQueueEmpty() { return eventq->empty(); } 1128937SN/A void enqueueRubyEvent(Tick tick) 1138937SN/A { 1148937SN/A RubyEvent* e = new RubyEvent(this); 1158937SN/A schedule(e, tick); 1168937SN/A } 1178937SN/A 1187039SN/A private: 1197039SN/A // Private copy constructor and assignment operator 1207039SN/A RubySystem(const RubySystem& obj); 1217039SN/A RubySystem& operator=(const RubySystem& obj); 1226285SN/A 12310991SN/A void makeCacheRecorder(uint8_t *uncompressed_trace, 12411061SN/A uint64_t cache_trace_size, 12511061SN/A uint64_t block_size_bytes); 12610991SN/A 12711060SN/A static void readCompressedTrace(std::string filename, 12811060SN/A uint8_t *&raw_data, 12911061SN/A uint64_t &uncompressed_trace_size); 13011060SN/A static void writeCompressedTrace(uint8_t *raw_data, std::string file, 13111061SN/A uint64_t uncompressed_trace_size); 1327039SN/A 1337039SN/A private: 1347039SN/A // configuration parameters 1357039SN/A static bool m_randomization; 1369504SN/A static uint32_t m_block_size_bytes; 1379504SN/A static uint32_t m_block_size_bits; 1389504SN/A static uint32_t m_memory_size_bits; 13910919SN/A 14010837SN/A static bool m_warmup_enabled; 14110837SN/A static unsigned m_systems_to_warmup; 14210837SN/A static bool m_cooldown_enabled; 14310525SN/A SimpleMemory *m_phys_mem; 14410706SN/A const bool m_access_backing_store; 1457039SN/A 14610012SN/A Network* m_network; 1479300SN/A std::vector<AbstractController *> m_abs_cntrl_vec; 14810918SN/A Cycles m_start_cycle; 1499103SN/A 1507039SN/A public: 15110012SN/A Profiler* m_profiler; 1528688SN/A CacheRecorder* m_cache_recorder; 15310920SN/A std::vector<std::map<uint32_t, AbstractController *> > m_abstract_controls; 1546145SN/A}; 1556145SN/A 15610012SN/Aclass RubyStatsCallback : public Callback 1576895SN/A{ 1586895SN/A private: 15910919SN/A RubySystem *m_ruby_system; 1606895SN/A 1616895SN/A public: 16210012SN/A virtual ~RubyStatsCallback() {} 16310919SN/A RubyStatsCallback(RubySystem *system) : m_ruby_system(system) {} 16410919SN/A void process() { m_ruby_system->collateStats(); } 1656895SN/A}; 1666895SN/A 1677039SN/A#endif // __MEM_RUBY_SYSTEM_SYSTEM_HH__ 168