gem5  v20.1.0.0
sc_event.cc
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 #include "systemc/core/event.hh"
31 
32 namespace sc_core
33 {
34 
35 
36 /*
37  * sc_event_and_list
38  */
39 
40 sc_event_and_list::sc_event_and_list() : autoDelete(false), busy(0) {}
41 
43  events(eal.events), autoDelete(false), busy(0)
44 {}
45 
47 {
48  insert(e);
49 }
50 
52  autoDelete(auto_delete), busy(0)
53 {}
54 
56 
59 {
60  events = eal.events;
61  return *this;
62 }
63 
64 int
66 {
67  return events.size();
68 }
69 
70 void
72 {
73  events.swap(eal.events);
74 }
75 
78 {
79  insert(e);
80  return *this;
81 }
82 
85 {
86  insert(eal);
87  return *this;
88 }
89 
92 {
93  sc_event_and_expr expr;
94  expr.insert(*this);
95  expr.insert(e);
96  return expr;
97 }
98 
101 {
102  sc_event_and_expr expr;
103  expr.insert(*this);
104  expr.insert(eal);
105  return expr;
106 }
107 
108 void
110 {
111  events.insert(&e);
112 }
113 
114 void
116 {
117  events.insert(eal.events.begin(), eal.events.end());
118 }
119 
120 
121 /*
122  * sc_event_or_list
123  */
124 
125 sc_event_or_list::sc_event_or_list() : autoDelete(false), busy(0) {}
126 
128  events(eol.events), autoDelete(false), busy(0)
129 {}
130 
132 {
133  insert(e);
134 }
135 
137  autoDelete(auto_delete), busy(0)
138 {}
139 
142 {
143  events = eol.events;
144  return *this;
145 }
146 
148 
149 int
151 {
152  return events.size();
153 }
154 
155 void
157 {
158  events.swap(eol.events);
159 }
160 
163 {
164  insert(e);
165  return *this;
166 }
167 
170 {
171  insert(eol);
172  return *this;
173 }
174 
177 {
178  sc_event_or_expr expr;
179  expr.insert(*this);
180  expr.insert(e);
181  return expr;
182 }
183 
186 {
187  sc_event_or_expr expr;
188  expr.insert(*this);
189  expr.insert(eol);
190  return expr;
191 }
192 
193 void
195 {
196  events.insert(&e);
197 }
198 
199 void
201 {
202  events.insert(eol.events.begin(), eol.events.end());
203 }
204 
205 
206 /*
207  * sc_event_and_expr
208  */
209 
210 // Move semantics
212  list(e.list)
213 {
214  e.list = nullptr;
215 }
216 
217 sc_event_and_expr::operator const sc_event_and_list &() const
218 {
219  sc_event_and_list *temp = list;
220  list = nullptr;
221  return *temp;
222 }
223 
224 void
226 {
227  assert(list);
228  list->insert(e);
229 }
230 
231 void
233 {
234  assert(list);
235  list->insert(eal);
236 }
237 
239 
241 
244 {
245  expr.insert(e);
246  return expr;
247 }
248 
249 sc_event_and_expr
251 {
252  expr.insert(eal);
253  return expr;
254 }
255 
256 
257 /*
258  * sc_event_or_expr
259  */
260 
261 // Move semantics
263  list(e.list)
264 {
265  e.list = nullptr;
266 }
267 
268 sc_event_or_expr::operator const sc_event_or_list &() const
269 {
270  sc_event_or_list *temp = list;
271  list = NULL;
272  return *temp;
273 }
274 
275 void
277 {
278  assert(list);
279  list->insert(e);
280 }
281 
282 void
284 {
285  assert(list);
286  list->insert(eol);
287 }
288 
290 
292 
295 {
296  expr.insert(e);
297  return expr;
298 }
299 
300 sc_event_or_expr
302 {
303  expr.insert(eol);
304  return expr;
305 }
306 
307 
308 /*
309  * sc_event
310  */
311 
313  _gem5_event(new ::sc_gem5::Event(
314  this, sc_core::sc_gen_unique_name("event")))
315 {}
316 
317 sc_event::sc_event(const char *_name) :
318  _gem5_event(new ::sc_gem5::Event(this, _name))
319 {}
320 
322 
323 const char *sc_event::name() const { return _gem5_event->name().c_str(); }
324 const char *
326 {
327  return _gem5_event->basename().c_str();
328 }
329 bool sc_event::in_hierarchy() const { return _gem5_event->inHierarchy(); }
330 
331 sc_object *
333 {
334  return _gem5_event->getParentObject();
335 }
336 
341 bool sc_event::triggered() const { return _gem5_event->triggered(); }
342 void
344 {
346 }
347 void
349 {
351 }
352 
355 {
356  sc_event_and_expr expr;
357  expr.insert(*this);
358  expr.insert(e);
359  return expr;
360 }
361 
364 {
365  sc_event_and_expr expr;
366  expr.insert(*this);
367  expr.insert(eal);
368  return expr;
369 }
370 
373 {
374  sc_event_or_expr expr;
375  expr.insert(*this);
376  expr.insert(e);
377  return expr;
378 }
379 
382 {
383  sc_event_or_expr expr;
384  expr.insert(*this);
385  expr.insert(eol);
386  return expr;
387 }
388 
390  _gem5_event(new ::sc_gem5::Event(
392  "$$$internal kernel event$$$"), true))
393 {}
394 
395 sc_event::sc_event(bool, const char *_name) :
396  _gem5_event(new ::sc_gem5::Event(
397  this,
398  (std::string("$$$internal kernel event$$$") + _name).c_str(),
399  true))
400 {}
401 
404 {
406 }
407 
408 sc_event *
409 sc_find_event(const char *name)
410 {
411  std::string str(name);
413  return it == ::sc_gem5::allEvents.end() ? nullptr : *it;
414 }
415 
416 } // namespace sc_core
417 
418 namespace sc_gem5
419 {
420 
421 InternalScEvent::InternalScEvent() : sc_event(true) {}
422 InternalScEvent::InternalScEvent(const char *_name) : sc_event(true, _name) {}
423 
424 } // namespace sc_gem5
sc_gem5::Event::getParentObject
sc_core::sc_object * getParentObject() const
Definition: event.cc:132
sc_core::sc_event_and_list::operator&=
sc_event_and_list & operator&=(const sc_event &)
Definition: sc_event.cc:77
sc_core::sc_event_or_list::size
int size() const
Definition: sc_event.cc:150
sc_gem5::Event::cancel
void cancel()
Definition: event.cc:196
sc_core::sc_event::get_parent_object
sc_object * get_parent_object() const
Definition: sc_event.cc:332
sc_core::operator|
sc_event_or_expr operator|(sc_event_or_expr expr, sc_event const &e)
Definition: sc_event.cc:294
sc_core::sc_event_and_list::size
int size() const
Definition: sc_event.cc:65
sc_core::sc_event_or_list::operator|=
sc_event_or_list & operator|=(const sc_event &)
Definition: sc_event.cc:162
sc_core::sc_event::in_hierarchy
bool in_hierarchy() const
Definition: sc_event.cc:329
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_core::sc_event_or_expr
Definition: sc_event.hh:147
sc_core::sc_event::basename
const char * basename() const
Definition: sc_event.cc:325
sc_core::sc_event_and_expr::~sc_event_and_expr
~sc_event_and_expr()
Definition: sc_event.cc:238
sc_core::sc_event_and_list
Definition: sc_event.hh:61
sc_core::sc_event_or_list
Definition: sc_event.hh:93
sc_gem5::EventsIt
Events::iterator EventsIt
Definition: object.hh:45
sc_gem5::Event::notify
void notify(StaticSensitivities &senses)
Definition: event.cc:138
sc_core::sc_event_or_expr::insert
void insert(sc_event const &e) const
Definition: sc_event.cc:276
sc_core::SC_ZERO_TIME
const sc_time SC_ZERO_TIME
Definition: sc_time.cc:290
sc_dt::list
static scfx_rep_node * list
Definition: scfx_rep.cc:368
sc_core::sc_event_or_list::operator=
sc_event_or_list & operator=(const sc_event_or_list &)
Definition: sc_event.cc:141
sc_core::sc_event::~sc_event
~sc_event()
Definition: sc_event.cc:321
std::vector
STL vector class.
Definition: stl.hh:37
sc_core::sc_event_or_expr::sc_event_or_expr
sc_event_or_expr()
Definition: sc_event.cc:291
sc_core::sc_event_or_list::operator|
sc_event_or_expr operator|(const sc_event &) const
Definition: sc_event.cc:176
sc_core::sc_find_event
sc_event * sc_find_event(const char *name)
Definition: sc_event.cc:409
sc_core::sc_event_or_list::insert
void insert(sc_event const &e)
Definition: sc_event.cc:194
sc_core::sc_event_and_list::swap
void swap(sc_event_and_list &)
Definition: sc_event.cc:71
sc_core::sc_event_and_list::operator&
sc_event_and_expr operator&(const sc_event &) const
Definition: sc_event.cc:91
sc_event.hh
sc_core::sc_event_and_list::operator=
sc_event_and_list & operator=(const sc_event_and_list &)
Definition: sc_event.cc:58
sc_core::sc_event::notify_delayed
void notify_delayed()
Definition: sc_event.cc:343
sc_core::sc_event_and_expr::insert
void insert(sc_event const &e) const
Definition: sc_event.cc:225
sc_core::operator&
sc_event_and_expr operator&(sc_event_and_expr expr, sc_event const &e)
Definition: sc_event.cc:243
Event
Definition: eventq.hh:246
sc_core::sc_event
Definition: sc_event.hh:169
ArmISA::d
Bitfield< 9 > d
Definition: miscregs_types.hh:60
sc_core::sc_event_and_expr
Definition: sc_event.hh:125
sc_core::sc_time
Definition: sc_time.hh:49
sc_core::sc_event::name
const char * name() const
Definition: sc_event.cc:323
sc_core::sc_event::triggered
bool triggered() const
Definition: sc_event.cc:341
sc_gem5::allEvents
Events allEvents
Definition: event.cc:219
sc_core::sc_event_or_list::~sc_event_or_list
~sc_event_or_list()
Definition: sc_event.cc:147
sc_core::sc_event::operator|
sc_event_or_expr operator|(const sc_event &) const
Definition: sc_event.cc:372
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_core::sc_event_and_list::insert
void insert(sc_event const &e)
Definition: sc_event.cc:109
sc_core::sc_gen_unique_name
const char * sc_gen_unique_name(const char *seed)
Definition: sc_module.cc:820
sc_gem5::Event::inHierarchy
bool inHierarchy() const
Definition: event.cc:126
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_module.hh
sc_core::sc_event::notify
void notify()
Definition: sc_event.cc:337
ArmISA::e
Bitfield< 9 > e
Definition: miscregs_types.hh:61
sc_core::sc_event_and_list::events
std::set< const sc_event * > events
Definition: sc_event.hh:88
ArmISA::u
Bitfield< 22 > u
Definition: miscregs_types.hh:348
sc_core::sc_event_and_list::sc_event_and_list
sc_event_and_list()
Definition: sc_event.cc:40
sc_core::sc_event_or_expr::~sc_event_or_expr
~sc_event_or_expr()
Definition: sc_event.cc:289
std
Overload hash function for BasicBlockRange type.
Definition: vec_reg.hh:587
sc_core::sc_event_and_expr::sc_event_and_expr
sc_event_and_expr()
Definition: sc_event.cc:240
sc_core::sc_event::cancel
void cancel()
Definition: sc_event.cc:340
ArmISA::t
Bitfield< 5 > t
Definition: miscregs_types.hh:67
sc_gem5::InternalScEvent::InternalScEvent
InternalScEvent()
Definition: sc_event.cc:421
sc_core::sc_event::_gem5_event
::sc_gem5::Event * _gem5_event
Definition: sc_event.hh:209
sc_gem5::topLevelEvents
Events topLevelEvents
Definition: event.cc:218
sc_core::sc_event_or_list::events
std::set< const sc_event * > events
Definition: sc_event.hh:120
sc_gem5
Definition: sc_clock.cc:42
event.hh
sc_core::sc_event_or_list::swap
void swap(sc_event_or_list &)
Definition: sc_event.cc:156
sc_gem5::Event::basename
const std::string & basename() const
Definition: event.cc:120
sc_core::sc_event_and_expr::list
sc_event_and_list * list
Definition: sc_event.hh:141
sc_core::sc_event_or_expr::list
sc_event_or_list * list
Definition: sc_event.hh:163
sc_core::sc_event_or_list::sc_event_or_list
sc_event_or_list()
Definition: sc_event.cc:125
sc_core::sc_get_top_level_events
const std::vector< sc_event * > & sc_get_top_level_events()
Definition: sc_event.cc:403
sc_core::sc_event::sc_event
sc_event()
Definition: sc_event.cc:312
sc_core::sc_event_and_list::~sc_event_and_list
~sc_event_and_list()
Definition: sc_event.cc:55
sc_core::sc_event::operator&
sc_event_and_expr operator&(const sc_event &) const
Definition: sc_event.cc:354

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