gem5  v21.1.0.2
root.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Copyright (c) 2011 Advanced Micro Devices, Inc.
15  * All rights reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions are
19  * met: redistributions of source code must retain the above copyright
20  * notice, this list of conditions and the following disclaimer;
21  * redistributions in binary form must reproduce the above copyright
22  * notice, this list of conditions and the following disclaimer in the
23  * documentation and/or other materials provided with the distribution;
24  * neither the name of the copyright holders nor the names of its
25  * contributors may be used to endorse or promote products derived from
26  * this software without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  */
40 
51 #ifndef __SIM_ROOT_HH__
52 #define __SIM_ROOT_HH__
53 
54 #include "base/statistics.hh"
55 #include "base/time.hh"
56 #include "base/types.hh"
57 #include "params/Root.hh"
58 #include "sim/eventq.hh"
59 #include "sim/globals.hh"
60 #include "sim/sim_object.hh"
61 
62 namespace gem5
63 {
64 
65 class Root : public SimObject
66 {
67  private:
68  static Root *_root;
69 
70  protected:
71  bool _enabled;
75 
77 
79 
80  void timeSync();
82 
83  public:
92  static Root *
93  root()
94  {
95  assert(_root);
96  return _root;
97  }
98 
99  public: // Global statistics
100  struct RootStats : public statistics::Group
101  {
102  void resetStats() override;
103 
109 
112 
114 
115  private:
116  RootStats();
117 
118  RootStats(const RootStats &) = delete;
119  RootStats &operator=(const RootStats &) = delete;
120 
123  };
124 
125  public:
126 
128  bool timeSyncEnabled() const { return _enabled; }
130  const Time timeSyncPeriod() const { return _period; }
132  const Time timeSyncSpinThreshold() const { return _spinThreshold; }
133 
135  void timeSyncEnable(bool en);
137  void timeSyncPeriod(Time newPeriod);
139  void timeSyncSpinThreshold(Time newThreshold);
140 
141  PARAMS(Root);
142 
143  // The int parameter is ignored, it's just so we can define a custom
144  // create() method.
145  Root(const Params &p, int);
146 
149  void startup() override;
150 
151  void serialize(CheckpointOut &cp) const override;
152  void unserialize(CheckpointIn &cp) override;
153 };
154 
159 extern Root::RootStats &rootStats;
160 
161 } // namespace gem5
162 
163 #endif // __SIM_ROOT_HH__
gem5::Root::timeSyncEnable
void timeSyncEnable(bool en)
Enable or disable time syncing.
Definition: root.cc:144
gem5::Globals
Container for serializing global variables (not associated with any serialized object).
Definition: globals.hh:54
gem5::Root::RootStats::hostTickRate
statistics::Formula hostTickRate
Definition: root.hh:110
gem5::Root::timeSyncPeriod
const Time timeSyncPeriod() const
Retrieve the period for the sync event.
Definition: root.hh:130
gem5::Root::RootStats
Definition: root.hh:100
gem5::Root::RootStats::statTime
Time statTime
Definition: root.hh:121
gem5::Root::_periodTick
Tick _periodTick
Definition: root.hh:73
gem5::Root::_spinThreshold
Time _spinThreshold
Definition: root.hh:74
gem5::CheckpointIn
Definition: serialize.hh:68
gem5::rootStats
Root::RootStats & rootStats
Global simulator statistics that are not associated with a specific SimObject.
Definition: root.cc:58
time.hh
gem5::Root::timeSyncEnabled
bool timeSyncEnabled() const
Check whether time syncing is enabled.
Definition: root.hh:128
gem5::statistics::Formula
A formula for statistics that is calculated when printed.
Definition: statistics.hh:2536
gem5::Root::RootStats::hostSeconds
statistics::Value hostSeconds
Definition: root.hh:108
gem5::Root::_enabled
bool _enabled
Definition: root.hh:71
gem5::Root::RootStats::simTicks
statistics::Value simTicks
Definition: root.hh:105
gem5::Root::RootStats::hostMemory
statistics::Value hostMemory
Definition: root.hh:111
gem5::Root::_root
static Root * _root
Definition: root.hh:68
gem5::Root::RootStats::resetStats
void resetStats() override
Callback to reset stats.
Definition: root.cc:108
gem5::Root::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: root.cc:216
gem5::SimObject::Params
SimObjectParams Params
Definition: sim_object.hh:170
gem5::Root::startup
void startup() override
Schedule the timesync event at startup().
Definition: root.cc:200
gem5::Root::RootStats::instance
static RootStats instance
Definition: root.hh:113
sim_object.hh
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
statistics.hh
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::Root
Definition: root.hh:65
gem5::Root::timeSync
void timeSync()
Definition: root.cc:123
gem5::Root::_period
Time _period
Definition: root.hh:72
gem5::Time
Definition: time.hh:48
gem5::Root::RootStats::finalTick
statistics::Value finalTick
Definition: root.hh:106
gem5::ArmISA::en
Bitfield< 30 > en
Definition: misc_types.hh:460
gem5::SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:146
gem5::Root::timeSyncSpinThreshold
const Time timeSyncSpinThreshold() const
Retrieve the threshold for time remaining to spin wait.
Definition: root.hh:132
gem5::Root::PARAMS
PARAMS(Root)
gem5::Root::RootStats::operator=
RootStats & operator=(const RootStats &)=delete
gem5::Root::syncEvent
EventFunctionWrapper syncEvent
Definition: root.hh:81
gem5::EventFunctionWrapper
Definition: eventq.hh:1115
gem5::Root::globals
Globals globals
Definition: root.hh:78
gem5::Root::Root
Root(const Params &p, int)
Definition: root.cc:179
gem5::Root::RootStats::simSeconds
statistics::Formula simSeconds
Definition: root.hh:104
gem5::Root::RootStats::simFreq
statistics::Value simFreq
Definition: root.hh:107
types.hh
gem5::statistics::Value
Definition: statistics.hh:1979
gem5::statistics::Group
Statistics container.
Definition: group.hh:93
gem5::CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:66
gem5::Root::lastTime
Time lastTime
Definition: root.hh:76
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::Root::RootStats::RootStats
RootStats()
Definition: root.cc:60
gem5::Root::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: root.cc:206
gem5::Root::RootStats::startTick
Tick startTick
Definition: root.hh:122
gem5::Root::root
static Root * root()
Use this function to get a pointer to the single Root object in the simulation.
Definition: root.hh:93
globals.hh
eventq.hh

Generated on Tue Sep 21 2021 12:25:48 for gem5 by doxygen 1.8.17