gem5  v20.1.0.0
event.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2018 Google, Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met: redistributions of source code must retain the above copyright
7  * notice, this list of conditions and the following disclaimer;
8  * redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution;
11  * neither the name of the copyright holders nor the names of its
12  * contributors may be used to endorse or promote products derived from
13  * this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef __SYSTEMC_CORE_EVENT_HH__
29 #define __SYSTEMC_CORE_EVENT_HH__
30 
31 #include <list>
32 #include <string>
33 #include <vector>
34 
35 #include "sim/eventq.hh"
36 #include "systemc/core/list.hh"
37 #include "systemc/core/object.hh"
38 #include "systemc/core/process.hh"
43 
44 namespace sc_core
45 {
46 
47 class sc_event;
48 
49 } // namespace sc_core
50 
51 namespace sc_gem5
52 {
53 
55 
56 class Sensitivity;
57 
58 class Event
59 {
60  public:
61  Event(sc_core::sc_event *_sc_event, bool internal=false);
63  bool internal=false);
64 
65  ~Event();
66 
68 
69  const std::string &name() const;
70  const std::string &basename() const;
71  bool inHierarchy() const;
73 
74  void notify(StaticSensitivities &senses);
75  void notify(DynamicSensitivities &senses);
76 
77  void notify();
78  void notify(const sc_core::sc_time &t);
79  void
81  {
83  }
84  void notifyDelayed(const sc_core::sc_time &t);
85  void cancel();
86 
87  bool triggered() const;
88  uint64_t triggeredStamp() const { return _triggeredStamp; }
89 
90  static Event *
92  {
93  return e->_gem5_event;
94  }
95 
96  static const Event *
98  {
99  return e->_gem5_event;
100  }
101 
102  void
104  {
105  // Insert static sensitivities in reverse order to match Accellera's
106  // implementation.
107  auto &senses = s->ofMethod() ? staticSenseMethod : staticSenseThread;
108  senses.insert(senses.begin(), s);
109  }
110  void
112  {
113  auto &senses = s->ofMethod() ? staticSenseMethod : staticSenseThread;
114  for (auto &t: senses) {
115  if (t == s) {
116  t = senses.back();
117  senses.pop_back();
118  break;
119  }
120  }
121  }
122  void
124  {
125  auto &senses = s->ofMethod() ? dynamicSenseMethod : dynamicSenseThread;
126  senses.push_back(s);
127  }
128  void
130  {
131  auto &senses = s->ofMethod() ? dynamicSenseMethod : dynamicSenseThread;
132  for (auto &t: senses) {
133  if (t == s) {
134  t = senses.back();
135  senses.pop_back();
136  break;
137  }
138  }
139  }
140 
141  void clearParent();
142 
143  private:
145 
146  std::string _basename;
147  std::string _name;
149 
151 
153  mutable uint64_t _triggeredStamp;
154 
159 };
160 
161 extern Events topLevelEvents;
162 extern Events allEvents;
163 
164 EventsIt findEvent(const std::string &name);
165 
166 } // namespace sc_gem5
167 
168 #endif //__SYSTEMC_CORE_EVENT_HH__
sc_gem5::Event::getParentObject
sc_core::sc_object * getParentObject() const
Definition: event.cc:132
sc_gem5::Event::dynamicSenseThread
DynamicSensitivities dynamicSenseThread
Definition: event.hh:158
sc_gem5::Event::cancel
void cancel()
Definition: event.cc:196
sc_gem5::Event::notify
void notify(double d, sc_core::sc_time_unit &u)
Definition: event.hh:80
sc_gem5::Event::getFromScEvent
static Event * getFromScEvent(sc_core::sc_event *e)
Definition: event.hh:91
sc_gem5::Event::notifyDelayed
void notifyDelayed(const sc_core::sc_time &t)
Definition: event.cc:188
sc_core
Definition: messages.cc:31
sc_core::sc_time_unit
sc_time_unit
Definition: sc_time.hh:40
sc_gem5::Event
Definition: event.hh:58
sc_gem5::EventsIt
Events::iterator EventsIt
Definition: object.hh:45
sensitivity.hh
std::vector< sc_core::sc_event * >
sc_gem5::Event::delSensitivity
void delSensitivity(StaticSensitivity *s) const
Definition: event.hh:111
sc_gem5::Event::~Event
~Event()
Definition: event.cc:92
sc_gem5::Event::delayedNotify
ScEvent delayedNotify
Definition: event.hh:152
sc_gem5::Event::_triggeredStamp
uint64_t _triggeredStamp
Definition: event.hh:153
sc_gem5::Event::staticSenseThread
StaticSensitivities staticSenseThread
Definition: event.hh:156
sc_gem5::Event::parent
sc_core::sc_object * parent
Definition: event.hh:150
sc_gem5::DynamicSensitivity
Definition: sensitivity.hh:96
sc_core::sc_event
Definition: sc_event.hh:169
ArmISA::d
Bitfield< 9 > d
Definition: miscregs_types.hh:60
sc_gem5::StaticSensitivity
Definition: sensitivity.hh:111
sc_core::sc_time
Definition: sc_time.hh:49
sched_event.hh
sc_gem5::Event::Event
Event(sc_core::sc_event *_sc_event, bool internal=false)
Definition: event.cc:44
sc_gem5::allEvents
Events allEvents
Definition: event.cc:219
sc_gem5::Event::getFromScEvent
static const Event * getFromScEvent(const sc_core::sc_event *e)
Definition: event.hh:97
sc_gem5::Event::triggered
bool triggered() const
Definition: event.cc:203
sc_gem5::findEvent
EventsIt findEvent(const std::string &name)
Definition: event.cc:222
sc_gem5::Events
std::vector< sc_core::sc_event * > Events
Definition: event.hh:54
sc_gem5::Event::inHierarchy
bool inHierarchy() const
Definition: event.cc:126
sc_gem5::Event::staticSenseMethod
StaticSensitivities staticSenseMethod
Definition: event.hh:155
sc_gem5::Event::_basename
std::string _basename
Definition: event.hh:146
sc_gem5::Event::name
const std::string & name() const
Definition: event.cc:114
sc_core::sc_object
Definition: sc_object.hh:50
name
const std::string & name()
Definition: trace.cc:50
sc_gem5::Event::_inHierarchy
bool _inHierarchy
Definition: event.hh:148
process.hh
sc_gem5::Event::addSensitivity
void addSensitivity(DynamicSensitivity *s) const
Definition: event.hh:123
ArmISA::e
Bitfield< 9 > e
Definition: miscregs_types.hh:61
ArmISA::u
Bitfield< 22 > u
Definition: miscregs_types.hh:348
sc_gem5::Event::clearParent
void clearParent()
Definition: event.cc:209
ArmISA::t
Bitfield< 5 > t
Definition: miscregs_types.hh:67
sc_gem5::Event::dynamicSenseMethod
DynamicSensitivities dynamicSenseMethod
Definition: event.hh:157
list.hh
sc_gem5::Event::triggeredStamp
uint64_t triggeredStamp() const
Definition: event.hh:88
object.hh
sc_gem5::topLevelEvents
Events topLevelEvents
Definition: event.cc:218
sc_gem5::Event::_name
std::string _name
Definition: event.hh:147
sc_gem5
Definition: sc_clock.cc:42
sc_gem5::Event::addSensitivity
void addSensitivity(StaticSensitivity *s) const
Definition: event.hh:103
ArmISA::s
Bitfield< 4 > s
Definition: miscregs_types.hh:556
sc_gem5::Event::sc_event
sc_core::sc_event * sc_event()
Definition: event.hh:67
sc_prim.hh
sc_time.hh
sc_gem5::Event::delSensitivity
void delSensitivity(DynamicSensitivity *s) const
Definition: event.hh:129
sc_gem5::Event::basename
const std::string & basename() const
Definition: event.cc:120
sc_gem5::ScEvent
Definition: sched_event.hh:43
sc_gem5::Sensitivity
Definition: sensitivity.hh:62
sc_gem5::Event::notify
void notify()
Definition: event.cc:159
sc_gem5::Event::_sc_event
sc_core::sc_event * _sc_event
Definition: event.hh:144
eventq.hh

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