gem5  v20.1.0.0
root.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011 Advanced Micro Devices, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met: redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
39 #ifndef __SIM_ROOT_HH__
40 #define __SIM_ROOT_HH__
41 
42 #include "base/time.hh"
43 #include "params/Root.hh"
44 #include "sim/eventq.hh"
45 #include "sim/sim_object.hh"
46 
47 class Root : public SimObject
48 {
49  private:
50  static Root *_root;
51 
52  protected:
53  bool _enabled;
57 
59 
60  void timeSync();
62 
63  public:
72  static Root *
73  root()
74  {
75  assert(_root);
76  return _root;
77  }
78 
79  public:
80 
82  bool timeSyncEnabled() const { return _enabled; }
84  const Time timeSyncPeriod() const { return _period; }
86  const Time timeSyncSpinThreshold() const { return _spinThreshold; }
87 
89  void timeSyncEnable(bool en);
91  void timeSyncPeriod(Time newPeriod);
93  void timeSyncSpinThreshold(Time newThreshold);
94 
95  typedef RootParams Params;
96  const Params *
97  params() const
98  {
99  return dynamic_cast<const Params *>(_params);
100  }
101 
102  Root(Params *p);
103 
106  void startup() override;
107 
108  void serialize(CheckpointOut &cp) const override;
109 };
110 
111 #endif // __SIM_ROOT_HH__
Root::root
static Root * root()
Use this function to get a pointer to the single Root object in the simulation.
Definition: root.hh:73
Root::_period
Time _period
Definition: root.hh:54
time.hh
Root::timeSync
void timeSync()
Definition: root.cc:47
Root::timeSyncEnable
void timeSyncEnable(bool en)
Enable or disable time syncing.
Definition: root.cc:68
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
Root::params
const Params * params() const
Definition: root.hh:97
Root::_periodTick
Tick _periodTick
Definition: root.hh:55
Root
Definition: root.hh:47
Root::Root
Root(Params *p)
Definition: root.cc:103
EventFunctionWrapper
Definition: eventq.hh:1101
Root::_root
static Root * _root
Definition: root.hh:50
Root::_spinThreshold
Time _spinThreshold
Definition: root.hh:56
cp
Definition: cprintf.cc:40
Root::Params
RootParams Params
Definition: root.hh:95
Root::timeSyncEnabled
bool timeSyncEnabled() const
Check whether time syncing is enabled.
Definition: root.hh:82
Root::timeSyncPeriod
const Time timeSyncPeriod() const
Retrieve the period for the sync event.
Definition: root.hh:84
sim_object.hh
Root::startup
void startup() override
Schedule the timesync event at startup().
Definition: root.cc:118
Root::timeSyncSpinThreshold
const Time timeSyncSpinThreshold() const
Retrieve the threshold for time remaining to spin wait.
Definition: root.hh:86
ArmISA::en
Bitfield< 30 > en
Definition: miscregs_types.hh:455
Root::syncEvent
EventFunctionWrapper syncEvent
Definition: root.hh:61
SimObject::_params
const SimObjectParams * _params
Cached copy of the object parameters.
Definition: sim_object.hh:110
Time
Definition: time.hh:45
Root::_enabled
bool _enabled
Definition: root.hh:53
Root::lastTime
Time lastTime
Definition: root.hh:58
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
Root::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: root.cc:124
eventq.hh
SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:92

Generated on Wed Sep 30 2020 14:02:14 for gem5 by doxygen 1.8.17