RubySystem.hh revision 8436
16145SN/A/* 26386SN/A * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 37553SN/A * All rights reserved. 46386SN/A * 56386SN/A * Redistribution and use in source and binary forms, with or without 66386SN/A * modification, are permitted provided that the following conditions are 76386SN/A * met: redistributions of source code must retain the above copyright 86386SN/A * notice, this list of conditions and the following disclaimer; 96386SN/A * redistributions in binary form must reproduce the above copyright 106386SN/A * notice, this list of conditions and the following disclaimer in the 116386SN/A * documentation and/or other materials provided with the distribution; 126386SN/A * neither the name of the copyright holders nor the names of its 136386SN/A * contributors may be used to endorse or promote products derived from 146386SN/A * this software without specific prior written permission. 156386SN/A * 166386SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 176386SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 186386SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 196386SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 206386SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 216386SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 226386SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 236386SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 246386SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 256386SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 266386SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 276386SN/A */ 286386SN/A 296145SN/A/* 307632SBrad.Beckmann@amd.com * Contains all of the various parts of the system we are simulating. 318832SAli.Saidi@ARM.com * Performs allocation, deallocation, and setup of all the major 326145SN/A * components of the system 337553SN/A */ 348832SAli.Saidi@ARM.com 358832SAli.Saidi@ARM.com#ifndef __MEM_RUBY_SYSTEM_SYSTEM_HH__ 366145SN/A#define __MEM_RUBY_SYSTEM_SYSTEM_HH__ 377553SN/A 387553SN/A#include "base/callback.hh" 396145SN/A#include "mem/ruby/common/Global.hh" 406145SN/A#include "mem/ruby/eventqueue/RubyEventQueue.hh" 4111320Ssteve.reinhardt@amd.com#include "mem/ruby/system/RubyPort.hh" 427553SN/A#include "mem/ruby/slicc_interface/AbstractController.hh" 436145SN/A#include "params/RubySystem.hh" 447553SN/A#include "sim/sim_object.hh" 457553SN/A 466145SN/Aclass AbstractController; 47class AbstractMemory; 48class CacheRecorder; 49class MemoryVector; 50class Network; 51class Profiler; 52class Tracer; 53 54/* 55 * This defines the number of longs (32-bits on 32 bit machines, 56 * 64-bit on 64-bit AMD machines) to use to hold the set... 57 * the default is 4, allowing 128 or 256 different members 58 * of the set. 59 * 60 * This should never need to be changed for correctness reasons, 61 * though increasing it will increase performance for larger 62 * set sizes at the cost of a (much) larger memory footprint 63 * 64 */ 65const int NUMBER_WORDS_PER_SET = 1; 66 67class RubySystem : public SimObject 68{ 69 public: 70 typedef RubySystemParams Params; 71 RubySystem(const Params *p); 72 ~RubySystem(); 73 74 // config accessors 75 static int getRandomSeed() { return m_random_seed; } 76 static int getRandomization() { return m_randomization; } 77 static int getBlockSizeBytes() { return m_block_size_bytes; } 78 static int getBlockSizeBits() { return m_block_size_bits; } 79 static uint64 getMemorySizeBytes() { return m_memory_size_bytes; } 80 static int getMemorySizeBits() { return m_memory_size_bits; } 81 82 // Public Methods 83 static Network* 84 getNetwork() 85 { 86 assert(m_network_ptr != NULL); 87 return m_network_ptr; 88 } 89 90 static RubyEventQueue* 91 getEventQueue() 92 { 93 return g_eventQueue_ptr; 94 } 95 96 Profiler* 97 getProfiler() 98 { 99 assert(m_profiler_ptr != NULL); 100 return m_profiler_ptr; 101 } 102 103 static Tracer* 104 getTracer() 105 { 106 assert(m_tracer_ptr != NULL); 107 return m_tracer_ptr; 108 } 109 110 static MemoryVector* 111 getMemoryVector() 112 { 113 assert(m_mem_vec_ptr != NULL); 114 return m_mem_vec_ptr; 115 } 116 117 void recordCacheContents(CacheRecorder& tr) const; 118 static void printConfig(std::ostream& out); 119 static void printStats(std::ostream& out); 120 void clearStats() const; 121 122 uint64 getInstructionCount(int thread) { return 1; } 123 static uint64 124 getCycleCount(int thread) 125 { 126 return g_eventQueue_ptr->getTime(); 127 } 128 129 void print(std::ostream& out) const; 130 131 virtual void serialize(std::ostream &os); 132 virtual void unserialize(Checkpoint *cp, const std::string §ion); 133 134 void registerNetwork(Network*); 135 void registerProfiler(Profiler*); 136 void registerTracer(Tracer*); 137 void registerAbstractMemory(AbstractMemory*); 138 void registerAbstractController(AbstractController*); 139 140 private: 141 // Private copy constructor and assignment operator 142 RubySystem(const RubySystem& obj); 143 RubySystem& operator=(const RubySystem& obj); 144 145 void init(); 146 147 static void printSystemConfig(std::ostream& out); 148 149 private: 150 // configuration parameters 151 static int m_random_seed; 152 static bool m_randomization; 153 static Tick m_clock; 154 static int m_block_size_bytes; 155 static int m_block_size_bits; 156 static uint64 m_memory_size_bytes; 157 static int m_memory_size_bits; 158 159 static Network* m_network_ptr; 160 161 public: 162 static Profiler* m_profiler_ptr; 163 static Tracer* m_tracer_ptr; 164 static MemoryVector* m_mem_vec_ptr; 165 std::vector<AbstractController*> m_abs_cntrl_vec; 166}; 167 168inline std::ostream& 169operator<<(std::ostream& out, const RubySystem& obj) 170{ 171 //obj.print(out); 172 out << std::flush; 173 return out; 174} 175 176class RubyExitCallback : public Callback 177{ 178 private: 179 std::string stats_filename; 180 181 public: 182 virtual ~RubyExitCallback() {} 183 184 RubyExitCallback(const std::string& _stats_filename) 185 { 186 stats_filename = _stats_filename; 187 } 188 189 virtual void process(); 190}; 191 192#endif // __MEM_RUBY_SYSTEM_SYSTEM_HH__ 193