gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  * Authors: Gabe Black
28  */
29 
30 #ifndef __SYSTEMC_CORE_EVENT_HH__
31 #define __SYSTEMC_CORE_EVENT_HH__
32 
33 #include <list>
34 #include <string>
35 #include <vector>
36 
37 #include "sim/eventq.hh"
38 #include "systemc/core/list.hh"
39 #include "systemc/core/object.hh"
40 #include "systemc/core/process.hh"
45 
46 namespace sc_core
47 {
48 
49 class sc_event;
50 
51 } // namespace sc_core
52 
53 namespace sc_gem5
54 {
55 
57 
58 class Sensitivity;
59 
60 class Event
61 {
62  public:
63  Event(sc_core::sc_event *_sc_event, bool internal=false);
64  Event(sc_core::sc_event *_sc_event, const char *_basename,
65  bool internal=false);
66 
67  ~Event();
68 
69  sc_core::sc_event *sc_event() { return _sc_event; }
70 
71  const std::string &name() const;
72  const std::string &basename() const;
73  bool inHierarchy() const;
74  sc_core::sc_object *getParentObject() const;
75 
76  void notify(StaticSensitivities &senses);
77  void notify(DynamicSensitivities &senses);
78 
79  void notify();
80  void notify(const sc_core::sc_time &t);
81  void
83  {
84  notify(sc_core::sc_time(d, u));
85  }
86  void notifyDelayed(const sc_core::sc_time &t);
87  void cancel();
88 
89  bool triggered() const;
90  uint64_t triggeredStamp() const { return _triggeredStamp; }
91 
92  static Event *
94  {
95  return e->_gem5_event;
96  }
97 
98  static const Event *
100  {
101  return e->_gem5_event;
102  }
103 
104  void
106  {
107  // Insert static sensitivities in reverse order to match Accellera's
108  // implementation.
109  auto &senses = s->ofMethod() ? staticSenseMethod : staticSenseThread;
110  senses.insert(senses.begin(), s);
111  }
112  void
114  {
115  auto &senses = s->ofMethod() ? staticSenseMethod : staticSenseThread;
116  for (auto &t: senses) {
117  if (t == s) {
118  t = senses.back();
119  senses.pop_back();
120  break;
121  }
122  }
123  }
124  void
126  {
127  auto &senses = s->ofMethod() ? dynamicSenseMethod : dynamicSenseThread;
128  senses.push_back(s);
129  }
130  void
132  {
133  auto &senses = s->ofMethod() ? dynamicSenseMethod : dynamicSenseThread;
134  for (auto &t: senses) {
135  if (t == s) {
136  t = senses.back();
137  senses.pop_back();
138  break;
139  }
140  }
141  }
142 
143  void clearParent();
144 
145  private:
147 
148  std::string _basename;
149  std::string _name;
151 
153 
155  mutable uint64_t _triggeredStamp;
156 
161 };
162 
163 extern Events topLevelEvents;
164 extern Events allEvents;
165 
166 EventsIt findEvent(const std::string &name);
167 
168 } // namespace sc_gem5
169 
170 #endif //__SYSTEMC_CORE_EVENT_HH__
std::string _name
Definition: event.hh:149
const std::string & name()
Definition: trace.cc:54
sc_time_unit
Definition: sc_time.hh:42
void addSensitivity(StaticSensitivity *s) const
Definition: event.hh:105
sc_core::sc_event * sc_event()
Definition: event.hh:69
void delSensitivity(DynamicSensitivity *s) const
Definition: event.hh:131
sc_core::sc_object * parent
Definition: event.hh:152
uint64_t _triggeredStamp
Definition: event.hh:155
Events
Definition: ide_disk.hh:140
::sc_gem5::Event * _gem5_event
Definition: sc_event.hh:211
void notify(double d, sc_core::sc_time_unit &u)
Definition: event.hh:82
EventsIt findEvent(const std::string &name)
Definition: event.cc:224
void delSensitivity(StaticSensitivity *s) const
Definition: event.hh:113
Bitfield< 4 > s
Bitfield< 22 > u
StaticSensitivities staticSenseMethod
Definition: event.hh:157
ScEvent delayedNotify
Definition: event.hh:154
Events allEvents
Definition: event.cc:221
Bitfield< 9 > d
Events topLevelEvents
Definition: event.cc:220
StaticSensitivities staticSenseThread
Definition: event.hh:158
Bitfield< 9 > e
std::string _basename
Definition: event.hh:148
static const Event * getFromScEvent(const sc_core::sc_event *e)
Definition: event.hh:99
DynamicSensitivities dynamicSenseThread
Definition: event.hh:160
sc_core::sc_event * _sc_event
Definition: event.hh:146
Events::iterator EventsIt
Definition: object.hh:47
Bitfield< 5 > t
bool _inHierarchy
Definition: event.hh:150
static Event * getFromScEvent(sc_core::sc_event *e)
Definition: event.hh:93
void addSensitivity(DynamicSensitivity *s) const
Definition: event.hh:125
DynamicSensitivities dynamicSenseMethod
Definition: event.hh:159
uint64_t triggeredStamp() const
Definition: event.hh:90

Generated on Fri Feb 28 2020 16:27:03 for gem5 by doxygen 1.8.13