RubySystem.hh revision 11294
11689SN/A/* 29783Sandreas.hansson@arm.com * Copyright (c) 1999-2012 Mark D. Hill and David A. Wood 310239Sbinhpham@cs.rutgers.edu * All rights reserved. 47598Sminkyu.jeong@arm.com * 57598Sminkyu.jeong@arm.com * Redistribution and use in source and binary forms, with or without 67598Sminkyu.jeong@arm.com * modification, are permitted provided that the following conditions are 77598Sminkyu.jeong@arm.com * met: redistributions of source code must retain the above copyright 87598Sminkyu.jeong@arm.com * notice, this list of conditions and the following disclaimer; 97598Sminkyu.jeong@arm.com * redistributions in binary form must reproduce the above copyright 107598Sminkyu.jeong@arm.com * notice, this list of conditions and the following disclaimer in the 117598Sminkyu.jeong@arm.com * documentation and/or other materials provided with the distribution; 127598Sminkyu.jeong@arm.com * neither the name of the copyright holders nor the names of its 137598Sminkyu.jeong@arm.com * contributors may be used to endorse or promote products derived from 147598Sminkyu.jeong@arm.com * this software without specific prior written permission. 152326SN/A * 161689SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 171689SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 181689SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 191689SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 201689SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 211689SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 221689SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 231689SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 241689SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 251689SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 261689SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 271689SN/A */ 281689SN/A 291689SN/A/* 301689SN/A * Contains all of the various parts of the system we are simulating. 311689SN/A * Performs allocation, deallocation, and setup of all the major 321689SN/A * components of the system 331689SN/A */ 341689SN/A 351689SN/A#ifndef __MEM_RUBY_SYSTEM_SYSTEM_HH__ 361689SN/A#define __MEM_RUBY_SYSTEM_SYSTEM_HH__ 371689SN/A 381689SN/A#include "base/callback.hh" 391689SN/A#include "base/output.hh" 402665Ssaidi@eecs.umich.edu#include "mem/packet.hh" 412665Ssaidi@eecs.umich.edu#include "mem/ruby/profiler/Profiler.hh" 421689SN/A#include "mem/ruby/slicc_interface/AbstractController.hh" 431689SN/A#include "mem/ruby/system/CacheRecorder.hh" 449944Smatt.horsnell@ARM.com#include "params/RubySystem.hh" 459944Smatt.horsnell@ARM.com#include "sim/clocked_object.hh" 469944Smatt.horsnell@ARM.com 471060SN/Aclass Network; 481060SN/Aclass AbstractController; 491689SN/A 501060SN/Aclass RubySystem : public ClockedObject 511060SN/A{ 521060SN/A public: 538230Snate@binkert.org class RubyEvent : public Event 546658Snate@binkert.org { 558887Sgeoffrey.blake@arm.com public: 562292SN/A RubyEvent(RubySystem* _ruby_system) 571717SN/A { 588229Snate@binkert.org m_ruby_system = _ruby_system; 598232Snate@binkert.org } 609444SAndreas.Sandberg@ARM.com private: 618232Snate@binkert.org void process(); 629527SMatt.Horsnell@arm.com 635529Snate@binkert.org RubySystem* m_ruby_system; 641060SN/A }; 656221Snate@binkert.org 666221Snate@binkert.org friend class RubyEvent; 671681SN/A 685529Snate@binkert.org typedef RubySystemParams Params; 692873Sktlim@umich.edu RubySystem(const Params *p); 704329Sktlim@umich.edu ~RubySystem(); 714329Sktlim@umich.edu 724329Sktlim@umich.edu // config accessors 732292SN/A static int getRandomization() { return m_randomization; } 742292SN/A static uint32_t getBlockSizeBytes() { return m_block_size_bytes; } 752292SN/A static uint32_t getBlockSizeBits() { return m_block_size_bits; } 762292SN/A static uint32_t getMemorySizeBits() { return m_memory_size_bits; } 772820Sktlim@umich.edu static bool getWarmupEnabled() { return m_warmup_enabled; } 782292SN/A static bool getCooldownEnabled() { return m_cooldown_enabled; } 792820Sktlim@umich.edu 809444SAndreas.Sandberg@ARM.com SimpleMemory *getPhysMem() { return m_phys_mem; } 811060SN/A Cycles getStartCycle() { return m_start_cycle; } 8210172Sdam.sunwoo@arm.com bool getAccessBackingStore() { return m_access_backing_store; } 8310172Sdam.sunwoo@arm.com 8410172Sdam.sunwoo@arm.com // Public Methods 8510172Sdam.sunwoo@arm.com Profiler* 8610172Sdam.sunwoo@arm.com getProfiler() 8710172Sdam.sunwoo@arm.com { 8810172Sdam.sunwoo@arm.com assert(m_profiler != NULL); 8910172Sdam.sunwoo@arm.com return m_profiler; 9010172Sdam.sunwoo@arm.com } 9110172Sdam.sunwoo@arm.com 9210172Sdam.sunwoo@arm.com void regStats() override { m_profiler->regStats(name()); } 9310172Sdam.sunwoo@arm.com void collateStats() { m_profiler->collateStats(); } 9410172Sdam.sunwoo@arm.com void resetStats() override; 952292SN/A 962292SN/A void memWriteback() override; 972292SN/A void serialize(CheckpointOut &cp) const override; 981060SN/A void unserialize(CheckpointIn &cp) override; 991060SN/A void drainResume() override; 1001060SN/A void process(); 1011060SN/A void startup() override; 1021060SN/A bool functionalRead(Packet *ptr); 1031060SN/A bool functionalWrite(Packet *ptr); 1041681SN/A 1056221Snate@binkert.org void registerNetwork(Network*); 1066221Snate@binkert.org void registerAbstractController(AbstractController*); 1076221Snate@binkert.org 1082292SN/A bool eventQueueEmpty() { return eventq->empty(); } 1092292SN/A void enqueueRubyEvent(Tick tick) 1102292SN/A { 1112292SN/A RubyEvent* e = new RubyEvent(this); 11210328Smitch.hayenga@arm.com schedule(e, tick); 1132292SN/A } 1142292SN/A 1152292SN/A private: 1162292SN/A // Private copy constructor and assignment operator 1172292SN/A RubySystem(const RubySystem& obj); 1182292SN/A RubySystem& operator=(const RubySystem& obj); 1192292SN/A 1201060SN/A void makeCacheRecorder(uint8_t *uncompressed_trace, 1211060SN/A uint64_t cache_trace_size, 1221681SN/A uint64_t block_size_bytes); 1231062SN/A 12410023Smatt.horsnell@ARM.com static void readCompressedTrace(std::string filename, 12510023Smatt.horsnell@ARM.com uint8_t *&raw_data, 12610023Smatt.horsnell@ARM.com uint64_t &uncompressed_trace_size); 12710023Smatt.horsnell@ARM.com static void writeCompressedTrace(uint8_t *raw_data, std::string file, 12811246Sradhika.jagtap@ARM.com uint64_t uncompressed_trace_size); 12911246Sradhika.jagtap@ARM.com 13011246Sradhika.jagtap@ARM.com private: 13111246Sradhika.jagtap@ARM.com // configuration parameters 13211246Sradhika.jagtap@ARM.com static bool m_randomization; 13311246Sradhika.jagtap@ARM.com static uint32_t m_block_size_bytes; 13411246Sradhika.jagtap@ARM.com static uint32_t m_block_size_bits; 13511246Sradhika.jagtap@ARM.com static uint32_t m_memory_size_bits; 13611246Sradhika.jagtap@ARM.com 13711246Sradhika.jagtap@ARM.com static bool m_warmup_enabled; 13811246Sradhika.jagtap@ARM.com static unsigned m_systems_to_warmup; 13911246Sradhika.jagtap@ARM.com static bool m_cooldown_enabled; 14010023Smatt.horsnell@ARM.com SimpleMemory *m_phys_mem; 14110023Smatt.horsnell@ARM.com const bool m_access_backing_store; 14210023Smatt.horsnell@ARM.com 14310023Smatt.horsnell@ARM.com Network* m_network; 1442292SN/A std::vector<AbstractController *> m_abs_cntrl_vec; 1451062SN/A Cycles m_start_cycle; 1462301SN/A 1472301SN/A public: 1481062SN/A Profiler* m_profiler; 1492727Sktlim@umich.edu CacheRecorder* m_cache_recorder; 1501062SN/A std::vector<std::map<uint32_t, AbstractController *> > m_abstract_controls; 1511062SN/A}; 1521062SN/A 1531062SN/Aclass RubyStatsCallback : public Callback 1541062SN/A{ 1551062SN/A private: 1561062SN/A RubySystem *m_ruby_system; 1571062SN/A 1581062SN/A public: 1591062SN/A virtual ~RubyStatsCallback() {} 1601062SN/A RubyStatsCallback(RubySystem *system) : m_ruby_system(system) {} 1611062SN/A void process() { m_ruby_system->collateStats(); } 1621062SN/A}; 1631062SN/A 1641062SN/A#endif // __MEM_RUBY_SYSTEM_SYSTEM_HH__ 1651062SN/A