Merge Ruby Stuff
[gem5.git] / src / mem / ruby / system / System.hh
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 * RubySystem.h
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/common/Global.hh"
45 #include "mem/gems_common/Vector.hh"
46 #include "mem/ruby/common/Address.hh"
47 #include "mem/ruby/config/RubyConfig.hh"
48 #include "mem/protocol/MachineType.hh"
49 #include "mem/ruby/slicc_interface/AbstractChip.hh"
50
51 class Profiler;
52 class Network;
53 class Driver;
54 class CacheRecorder;
55 class Tracer;
56 class Sequencer;
57 class XactIsolationChecker;
58 class XactCommitArbiter;
59 class XactVisualizer;
60 class TransactionInterfaceManager;
61
62 class RubySystem {
63 public:
64 // Constructors
65 RubySystem();
66 RubySystem(Driver* _driver); // used when driver is already instantiated (e.g. M5's RubyMem)
67
68 // Destructor
69 ~RubySystem();
70
71 // Public Methods
72 int getNumProcessors() { return RubyConfig::numberOfProcessors(); }
73 int getNumMemories() { return RubyConfig::numberOfMemories(); }
74 Profiler* getProfiler() { return m_profiler_ptr; }
75 Driver* getDriver() { assert(m_driver_ptr != NULL); return m_driver_ptr; }
76 Tracer* getTracer() { assert(m_tracer_ptr != NULL); return m_tracer_ptr; }
77 Network* getNetwork() { assert(m_network_ptr != NULL); return m_network_ptr; }
78 XactIsolationChecker* getXactIsolationChecker() { assert(m_xact_isolation_checker!= NULL); return m_xact_isolation_checker;}
79 XactCommitArbiter* getXactCommitArbiter() { assert(m_xact_commit_arbiter!= NULL); return m_xact_commit_arbiter;}
80 XactVisualizer* getXactVisualizer() { assert(m_xact_visualizer!= NULL); return m_xact_visualizer;}
81
82 AbstractChip* getChip(int chipNumber) const { assert(m_chip_vector[chipNumber] != NULL); return m_chip_vector[chipNumber];}
83 Sequencer* getSequencer(int procNumber) const {
84 assert(procNumber < RubyConfig::numberOfProcessors());
85 return m_chip_vector[procNumber/RubyConfig::numberOfProcsPerChip()]->getSequencer(procNumber%RubyConfig::numberOfProcsPerChip());
86 }
87 TransactionInterfaceManager* getTransactionInterfaceManager(int procNumber) const {
88 return m_chip_vector[procNumber/RubyConfig::numberOfProcsPerChip()]->getTransactionInterfaceManager(procNumber%RubyConfig::numberOfProcsPerChip());
89 }
90 void recordCacheContents(CacheRecorder& tr) const;
91 void printConfig(ostream& out) const;
92 void printStats(ostream& out);
93 void clearStats() const;
94
95 void print(ostream& out) const;
96 #ifdef CHECK_COHERENCE
97 void checkGlobalCoherenceInvariant(const Address& addr);
98 #endif
99
100 private:
101 // Private Methods
102 void init();
103 void createDriver();
104
105 // Private copy constructor and assignment operator
106 RubySystem(const RubySystem& obj);
107 RubySystem& operator=(const RubySystem& obj);
108
109 // Data Members (m_ prefix)
110 Network* m_network_ptr;
111 Vector<AbstractChip*> m_chip_vector;
112 Profiler* m_profiler_ptr;
113 bool m_preinitialized_driver;
114 Driver* m_driver_ptr;
115 Tracer* m_tracer_ptr;
116 XactIsolationChecker *m_xact_isolation_checker;
117 XactCommitArbiter *m_xact_commit_arbiter;
118 XactVisualizer *m_xact_visualizer;
119 };
120
121 // Output operator declaration
122 ostream& operator<<(ostream& out, const RubySystem& obj);
123
124 // ******************* Definitions *******************
125
126 // Output operator definition
127 inline
128 ostream& operator<<(ostream& out, const RubySystem& obj)
129 {
130 // obj.print(out);
131 out << flush;
132 return out;
133 }
134
135 #endif //SYSTEM_H
136
137
138