RubySystem.hh revision 10837
12810SN/A/* 212724Snikos.nikoleris@arm.com * Copyright (c) 1999-2012 Mark D. Hill and David A. Wood 38856Sandreas.hansson@arm.com * All rights reserved. 48856Sandreas.hansson@arm.com * 58856Sandreas.hansson@arm.com * Redistribution and use in source and binary forms, with or without 68856Sandreas.hansson@arm.com * modification, are permitted provided that the following conditions are 78856Sandreas.hansson@arm.com * met: redistributions of source code must retain the above copyright 88856Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer; 98856Sandreas.hansson@arm.com * redistributions in binary form must reproduce the above copyright 108856Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer in the 118856Sandreas.hansson@arm.com * documentation and/or other materials provided with the distribution; 128856Sandreas.hansson@arm.com * neither the name of the copyright holders nor the names of its 138856Sandreas.hansson@arm.com * contributors may be used to endorse or promote products derived from 142810SN/A * this software without specific prior written permission. 152810SN/A * 162810SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172810SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182810SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192810SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202810SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212810SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222810SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232810SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242810SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252810SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262810SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272810SN/A */ 282810SN/A 292810SN/A/* 302810SN/A * Contains all of the various parts of the system we are simulating. 312810SN/A * Performs allocation, deallocation, and setup of all the major 322810SN/A * components of the system 332810SN/A */ 342810SN/A 352810SN/A#ifndef __MEM_RUBY_SYSTEM_SYSTEM_HH__ 362810SN/A#define __MEM_RUBY_SYSTEM_SYSTEM_HH__ 372810SN/A 382810SN/A#include "base/callback.hh" 392810SN/A#include "base/output.hh" 402810SN/A#include "mem/ruby/profiler/Profiler.hh" 4112724Snikos.nikoleris@arm.com#include "mem/ruby/slicc_interface/AbstractController.hh" 422810SN/A#include "mem/ruby/system/CacheRecorder.hh" 432810SN/A#include "mem/packet.hh" 442810SN/A#include "params/RubySystem.hh" 452810SN/A#include "sim/clocked_object.hh" 462810SN/A 472810SN/Aclass Network; 482810SN/A 4911486Snikos.nikoleris@arm.comclass RubySystem : public ClockedObject 5011486Snikos.nikoleris@arm.com{ 5112724Snikos.nikoleris@arm.com public: 5212724Snikos.nikoleris@arm.com class RubyEvent : public Event 538232Snate@binkert.org { 5412724Snikos.nikoleris@arm.com public: 5512724Snikos.nikoleris@arm.com RubyEvent(RubySystem* _ruby_system) 5611486Snikos.nikoleris@arm.com { 5712724Snikos.nikoleris@arm.com ruby_system = _ruby_system; 5812724Snikos.nikoleris@arm.com } 5912724Snikos.nikoleris@arm.com private: 6012724Snikos.nikoleris@arm.com void process(); 6112724Snikos.nikoleris@arm.com 6212724Snikos.nikoleris@arm.com RubySystem* ruby_system; 6312724Snikos.nikoleris@arm.com }; 642810SN/A 652810SN/A friend class RubyEvent; 662810SN/A 678856Sandreas.hansson@arm.com typedef RubySystemParams Params; 688856Sandreas.hansson@arm.com RubySystem(const Params *p); 698856Sandreas.hansson@arm.com ~RubySystem(); 708922Swilliam.wang@arm.com 7112084Sspwilson2@wisc.edu // config accessors 7212084Sspwilson2@wisc.edu static int getRandomSeed() { return m_random_seed; } 738856Sandreas.hansson@arm.com static int getRandomization() { return m_randomization; } 748856Sandreas.hansson@arm.com static uint32_t getBlockSizeBytes() { return m_block_size_bytes; } 754475SN/A static uint32_t getBlockSizeBits() { return m_block_size_bits; } 7611053Sandreas.hansson@arm.com static uint32_t getMemorySizeBits() { return m_memory_size_bits; } 775034SN/A static bool getWarmupEnabled() { return m_warmup_enabled; } 7812724Snikos.nikoleris@arm.com static bool getCooldownEnabled() { return m_cooldown_enabled; } 7912724Snikos.nikoleris@arm.com 8011377Sandreas.hansson@arm.com SimpleMemory *getPhysMem() { return m_phys_mem; } 8111377Sandreas.hansson@arm.com const bool getAccessBackingStore() { return m_access_backing_store; } 8212724Snikos.nikoleris@arm.com 8312724Snikos.nikoleris@arm.com // Public Methods 8412724Snikos.nikoleris@arm.com Profiler* 8512724Snikos.nikoleris@arm.com getProfiler() 8612724Snikos.nikoleris@arm.com { 8712724Snikos.nikoleris@arm.com assert(m_profiler != NULL); 8812724Snikos.nikoleris@arm.com return m_profiler; 8912724Snikos.nikoleris@arm.com } 9011053Sandreas.hansson@arm.com 9111722Ssophiane.senni@gmail.com void regStats() { m_profiler->regStats(name()); } 9211722Ssophiane.senni@gmail.com void collateStats() { m_profiler->collateStats(); } 9311722Ssophiane.senni@gmail.com void resetStats(); 9411722Ssophiane.senni@gmail.com 959263Smrinmoy.ghosh@arm.com void serialize(std::ostream &os); 965034SN/A void unserialize(Checkpoint *cp, const std::string §ion); 9711331Sandreas.hansson@arm.com void process(); 9812724Snikos.nikoleris@arm.com void startup(); 9910884Sandreas.hansson@arm.com bool functionalRead(Packet *ptr); 1004626SN/A bool functionalWrite(Packet *ptr); 10110360Sandreas.hansson@arm.com 10211484Snikos.nikoleris@arm.com void registerNetwork(Network*); 1035034SN/A void registerAbstractController(AbstractController*); 1048883SAli.Saidi@ARM.com 1058833Sdam.sunwoo@arm.com bool eventQueueEmpty() { return eventq->empty(); } 1064458SN/A void enqueueRubyEvent(Tick tick) 10711377Sandreas.hansson@arm.com { 10811377Sandreas.hansson@arm.com RubyEvent* e = new RubyEvent(this); 10911377Sandreas.hansson@arm.com schedule(e, tick); 11011377Sandreas.hansson@arm.com } 11111377Sandreas.hansson@arm.com 11211377Sandreas.hansson@arm.com private: 11311331Sandreas.hansson@arm.com // Private copy constructor and assignment operator 11411331Sandreas.hansson@arm.com RubySystem(const RubySystem& obj); 11512724Snikos.nikoleris@arm.com RubySystem& operator=(const RubySystem& obj); 11612730Sodanrc@yahoo.com.br 11712724Snikos.nikoleris@arm.com void readCompressedTrace(std::string filename, 11812724Snikos.nikoleris@arm.com uint8_t *&raw_data, 11912724Snikos.nikoleris@arm.com uint64& uncompressed_trace_size); 12012724Snikos.nikoleris@arm.com void writeCompressedTrace(uint8_t *raw_data, std::string file, 12112724Snikos.nikoleris@arm.com uint64 uncompressed_trace_size); 12212724Snikos.nikoleris@arm.com 12312724Snikos.nikoleris@arm.com private: 12412724Snikos.nikoleris@arm.com // configuration parameters 12512724Snikos.nikoleris@arm.com static int m_random_seed; 12612724Snikos.nikoleris@arm.com static bool m_randomization; 12712724Snikos.nikoleris@arm.com static uint32_t m_block_size_bytes; 1282810SN/A static uint32_t m_block_size_bits; 1292810SN/A static uint32_t m_memory_size_bits; 1303013SN/A static bool m_warmup_enabled; 1318856Sandreas.hansson@arm.com static unsigned m_systems_to_warmup; 1322810SN/A static bool m_cooldown_enabled; 1333013SN/A SimpleMemory *m_phys_mem; 13410714Sandreas.hansson@arm.com const bool m_access_backing_store; 1352810SN/A 1369614Srene.dejong@arm.com Network* m_network; 1379614Srene.dejong@arm.com std::vector<AbstractController *> m_abs_cntrl_vec; 1389614Srene.dejong@arm.com 13910345SCurtis.Dunham@arm.com public: 14010714Sandreas.hansson@arm.com Profiler* m_profiler; 14110345SCurtis.Dunham@arm.com CacheRecorder* m_cache_recorder; 1429614Srene.dejong@arm.com}; 1432810SN/A 1442810SN/Aclass RubyStatsCallback : public Callback 1452810SN/A{ 1468856Sandreas.hansson@arm.com private: 1472810SN/A RubySystem *ruby_system; 1483013SN/A 14910714Sandreas.hansson@arm.com public: 1503013SN/A virtual ~RubyStatsCallback() {} 1518856Sandreas.hansson@arm.com RubyStatsCallback(RubySystem *system) : ruby_system(system) {} 15210714Sandreas.hansson@arm.com void process() { ruby_system->collateStats(); } 1538922Swilliam.wang@arm.com}; 1542897SN/A 1552810SN/A#endif // __MEM_RUBY_SYSTEM_SYSTEM_HH__ 1562810SN/A