gem5 v24.0.0.0
Loading...
Searching...
No Matches
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"
43
44namespace sc_core
45{
46
47class sc_event;
48
49} // namespace sc_core
50
51namespace sc_gem5
52{
53
55
56class Sensitivity;
57
58class 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
162extern Events allEvents;
163
164EventsIt findEvent(const std::string &name);
165
166} // namespace sc_gem5
167
168#endif //__SYSTEMC_CORE_EVENT_HH__
void notify()
Definition event.cc:158
StaticSensitivities staticSenseMethod
Definition event.hh:155
void addSensitivity(StaticSensitivity *s) const
Definition event.hh:103
bool triggered() const
Definition event.cc:202
sc_core::sc_event * sc_event()
Definition event.hh:67
DynamicSensitivities dynamicSenseMethod
Definition event.hh:157
uint64_t triggeredStamp() const
Definition event.hh:88
sc_core::sc_object * getParentObject() const
Definition event.cc:131
static Event * getFromScEvent(sc_core::sc_event *e)
Definition event.hh:91
StaticSensitivities staticSenseThread
Definition event.hh:156
const std::string & basename() const
Definition event.cc:119
void notify(double d, sc_core::sc_time_unit &u)
Definition event.hh:80
DynamicSensitivities dynamicSenseThread
Definition event.hh:158
void clearParent()
Definition event.cc:208
bool _inHierarchy
Definition event.hh:148
Event(sc_core::sc_event *_sc_event, bool internal=false)
Definition event.cc:43
bool inHierarchy() const
Definition event.cc:125
std::string _basename
Definition event.hh:146
void notifyDelayed(const sc_core::sc_time &t)
Definition event.cc:187
sc_core::sc_event * _sc_event
Definition event.hh:144
const std::string & name() const
Definition event.cc:113
ScEvent delayedNotify
Definition event.hh:152
void delSensitivity(StaticSensitivity *s) const
Definition event.hh:111
std::string _name
Definition event.hh:147
sc_core::sc_object * parent
Definition event.hh:150
void delSensitivity(DynamicSensitivity *s) const
Definition event.hh:129
void cancel()
Definition event.cc:195
static const Event * getFromScEvent(const sc_core::sc_event *e)
Definition event.hh:97
uint64_t _triggeredStamp
Definition event.hh:153
void addSensitivity(DynamicSensitivity *s) const
Definition event.hh:123
STL vector class.
Definition stl.hh:37
sc_time_unit
Definition sc_time.hh:40
std::vector< sc_core::sc_event * > Events
Definition event.hh:54
Events::iterator EventsIt
Definition object.hh:45
Events topLevelEvents
Definition event.cc:217
Events allEvents
Definition event.cc:218
EventsIt findEvent(const std::string &name)
Definition event.cc:221
const std::string & name()
Definition trace.cc:48

Generated on Tue Jun 18 2024 16:24:06 for gem5 by doxygen 1.11.0