RubySystem.hh revision 6285
1
2/*
3 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30/*
31 * System.hh
32 *
33 * Description: Contains all of the various parts of the system we are
34 * simulating.  Performs allocation, deallocation, and setup of all
35 * the major components of the system
36 *
37 * $Id$
38 *
39 */
40
41#ifndef SYSTEM_H
42#define SYSTEM_H
43
44#include "mem/ruby/system/RubyPort.hh"
45#include "mem/ruby/common/Global.hh"
46#include "mem/gems_common/Vector.hh"
47#include "mem/ruby/eventqueue/RubyEventQueue.hh"
48#include <map>
49
50class Profiler;
51class Network;
52class CacheRecorder;
53class Tracer;
54class Sequencer;
55class DMASequencer;
56class MemoryVector;
57class AbstractController;
58class MessageBuffer;
59class CacheMemory;
60class DirectoryMemory;
61class Topology;
62class MemoryControl;
63
64struct RubyObjConf {
65  string type;
66  string name;
67  vector<string> argv;
68  RubyObjConf(string _type, string _name, vector<string> _argv)
69    : type(_type), name(_name), argv(_argv)
70  {}
71};
72
73class RubySystem {
74public:
75  static RubySystem* create(const vector <RubyObjConf> & sys_conf);
76  // Destructor
77  ~RubySystem();
78
79  // config accessors
80  static int getRandomSeed() { return m_random_seed; }
81  static int getRandomization() { return m_randomization; }
82  static int getTechNm() { return m_tech_nm; }
83  static int getFreqMhz() { return m_freq_mhz; }
84  static int getBlockSizeBytes() { return m_block_size_bytes; }
85  static int getBlockSizeBits() { return m_block_size_bits; }
86  static uint64 getMemorySizeBytes() { return m_memory_size_bytes; }
87  static int getMemorySizeBits() { return m_memory_size_bits; }
88
89  // Public Methods
90  static RubyPort* getPortOnly(const string & name) {
91    assert(m_ports.count(name) == 1); return m_ports[name]; }
92  static RubyPort* getPort(const string & name, void (*hit_callback)(int64_t)) {
93    assert(m_ports.count(name) == 1); m_ports[name]->registerHitCallback(hit_callback); return m_ports[name]; }
94  static Network* getNetwork() { assert(m_network_ptr != NULL); return m_network_ptr; }
95  static Topology* getTopology(const string & name) { assert(m_topologies.count(name) == 1); return m_topologies[name]; }
96  static CacheMemory* getCache(const string & name) { assert(m_caches.count(name) == 1); return m_caches[name]; }
97  static DirectoryMemory* getDirectory(const string & name) { assert(m_directories.count(name) == 1); return m_directories[name]; }
98  static MemoryControl* getMemoryControl(const string & name) { assert(m_memorycontrols.count(name) == 1); return m_memorycontrols[name]; }
99  static Sequencer* getSequencer(const string & name) { assert(m_sequencers.count(name) == 1); return m_sequencers[name]; }
100  static DMASequencer* getDMASequencer(const string & name) { assert(m_dma_sequencers.count(name) == 1); return m_dma_sequencers[name]; }
101  static AbstractController* getController(const string & name) { assert(m_controllers.count(name) == 1); return m_controllers[name]; }
102
103  static RubyEventQueue* getEventQueue() { return g_eventQueue_ptr; }
104
105  static int getNumberOfDirectories() { return m_directories.size(); }
106  static int getNumberOfSequencers() { return m_sequencers.size(); }
107
108  Profiler* getProfiler() {assert(m_profiler_ptr != NULL); return m_profiler_ptr; }
109  Tracer* getTracer() { assert(m_tracer_ptr != NULL); return m_tracer_ptr; }
110  static MemoryVector* getMemoryVector() { assert(m_mem_vec_ptr != NULL); return m_mem_vec_ptr;}
111
112  void recordCacheContents(CacheRecorder& tr) const;
113  static void printConfig(ostream& out);
114  static void printStats(ostream& out);
115  void clearStats() const;
116
117  uint64 getInstructionCount(int thread) { return 1; }
118  static uint64 getCycleCount(int thread) { return g_eventQueue_ptr->getTime(); }
119
120  void print(ostream& out) const;
121  /*
122#ifdef CHECK_COHERENCE
123  void checkGlobalCoherenceInvariant(const Address& addr);
124#endif
125  */
126
127private:
128  // Constructors
129  RubySystem(const vector <RubyObjConf> & cfg_file);
130
131  // Private copy constructor and assignment operator
132  RubySystem(const RubySystem& obj);
133  RubySystem& operator=(const RubySystem& obj);
134
135  void init(const vector<string> & argv);
136
137  static void printSystemConfig(ostream& out);
138
139private:
140  // configuration parameters
141  static int m_random_seed;
142  static bool m_randomization;
143  static int m_tech_nm;
144  static int m_freq_mhz;
145  static int m_block_size_bytes;
146  static int m_block_size_bits;
147  static uint64 m_memory_size_bytes;
148  static int m_memory_size_bits;
149
150  // Data Members (m_ prefix)
151  static Network* m_network_ptr;
152  static map< string, Topology* > m_topologies;
153  static map< string, RubyPort* > m_ports;
154  static map< string, CacheMemory* > m_caches;
155  static map< string, DirectoryMemory* > m_directories;
156  static map< string, Sequencer* > m_sequencers;
157  static map< string, DMASequencer* > m_dma_sequencers;
158  static map< string, AbstractController* > m_controllers;
159  static map< string, MemoryControl* > m_memorycontrols;
160
161  //added by SS
162  //static map< string, Tracer* > m_tracers;
163
164  static Profiler* m_profiler_ptr;
165  static Tracer* m_tracer_ptr;
166  static MemoryVector* m_mem_vec_ptr;
167};
168
169// Output operator declaration
170ostream& operator<<(ostream& out, const RubySystem& obj);
171
172// ******************* Definitions *******************
173
174// Output operator definition
175inline
176ostream& operator<<(ostream& out, const RubySystem& obj)
177{
178//  obj.print(out);
179  out << flush;
180  return out;
181}
182
183#endif //SYSTEM_H
184
185
186
187