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