gem5  v20.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
sensitivity.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 
29 
30 #include "systemc/core/event.hh"
31 #include "systemc/core/port.hh"
32 #include "systemc/core/process.hh"
41 
42 namespace sc_gem5
43 {
44 
45 /*
46  * Common sensitivity interface.
47  */
48 
49 void
51 {
53 }
54 
55 bool
57 {
58  satisfy();
59  return true;
60 }
61 
62 bool
64 {
65  if (scheduler.current() == process) {
66  static bool warned = false;
67  if (!warned) {
69  process->name());
70  warned = true;
71  }
72  return false;
73  }
74 
75  if (process->disabled())
76  return false;
77 
78  return notifyWork(e);
79 }
80 
81 bool
83 {
85 }
86 
87 
88 /*
89  * Dynamic vs. static sensitivity.
90  */
91 
92 void
93 DynamicSensitivity::addToEvent(const ::sc_core::sc_event *e)
94 {
96 }
97 
98 void
99 DynamicSensitivity::delFromEvent(const ::sc_core::sc_event *e)
100 {
102 }
103 
104 void
105 StaticSensitivity::addToEvent(const ::sc_core::sc_event *e)
106 {
108 }
109 
110 void
111 StaticSensitivity::delFromEvent(const ::sc_core::sc_event *e)
112 {
114 }
115 
116 
117 /*
118  * Static sensitivities.
119  */
120 
121 void
123 {
124  auto s = new StaticSensitivityEvent(p, e);
125  s->addToEvent(s->event);
126  p->addStatic(s);
127 }
128 
129 void
131 {
132  auto s = new StaticSensitivityInterface(p, i);
133  s->addToEvent(s->event);
134  p->addStatic(s);
135 }
136 
137 void
139 {
140  auto s = new StaticSensitivityPort(p);
141  Port *port = Port::fromPort(pb);
142  port->sensitive(s);
143  p->addStatic(s);
144 }
145 
146 void
148 {
149  auto s = new StaticSensitivityExport(p, exp);
150  s->addToEvent(s->event);
151  p->addStatic(s);
152 }
153 
154 void
156 {
157  auto s = new StaticSensitivityFinder(p, f);
158  Port *port = Port::fromPort(f->port());
159  port->sensitive(s);
160  p->addStatic(s);
161 }
162 
163 
165  Process *p, const sc_core::sc_interface *i) :
167  SensitivityEvent(p, &i->default_event())
168 {}
169 
171  Process *p, const sc_core::sc_export_base *exp) :
173  SensitivityEvent(p, &exp->get_interface()->default_event())
174 {}
175 
176 const ::sc_core::sc_event &
178 {
179  return finder->find_event(i);
180 }
181 
182 
183 /*
184  * Dynamic sensitivities.
185  */
186 
187 void
189 {
190  auto s = new DynamicSensitivityEvent(p, e);
191  s->addToEvent(s->event);
192  p->setDynamic(s);
193 }
194 
195 void
197  Process *p, const sc_core::sc_event_or_list *eol)
198 {
199  auto s = new DynamicSensitivityEventOrList(p, eol);
200  for (auto event: s->events)
201  s->addToEvent(event);
202  p->setDynamic(s);
203 }
204 
206  Process *p, const sc_core::sc_event_and_list *eal)
207 {
208  auto s = new DynamicSensitivityEventAndList(p, eal);
209  for (auto event: s->events)
210  s->addToEvent(event);
211  p->setDynamic(s);
212 }
213 
214 
216  Process *p, const sc_core::sc_event_or_list *eol) :
217  Sensitivity(p), DynamicSensitivity(p), SensitivityEvents(p, eol->events)
218 {}
219 
220 bool
222 {
223  events.erase(e->sc_event());
224 
225  // All the other events need this deleted from their lists since this
226  // sensitivity has been satisfied without them triggering.
227  for (auto le: events)
228  delFromEvent(le);
229 
230  satisfy();
231  return true;
232 }
233 
235  Process *p, const sc_core::sc_event_and_list *eal) :
237 {}
238 
239 bool
241 {
242  events.erase(e->sc_event());
243 
244  // This sensitivity is satisfied if all events have triggered.
245  if (events.empty())
246  satisfy();
247 
248  return true;
249 }
250 
251 } // namespace sc_gem5
void newDynamicSensitivityEventOrList(Process *p, const sc_core::sc_event_or_list *eol)
Definition: sensitivity.cc:196
void delFromEvent(const ::sc_core::sc_event *e) override
Definition: sensitivity.cc:111
void addStatic(StaticSensitivity *)
Definition: process.cc:282
Bitfield< 8 > le
Definition: misc.hh:664
Bitfield< 7 > i
void addSensitivity(StaticSensitivity *s) const
Definition: event.hh:103
const ::sc_core::sc_event * event
Definition: sensitivity.hh:133
sc_core::sc_event * sc_event()
Definition: event.hh:67
bool notifyWork(Event *e) override
Definition: sensitivity.cc:221
StaticSensitivityExport(Process *p, const sc_core::sc_export_base *exp)
Definition: sensitivity.cc:170
void newStaticSensitivityInterface(Process *p, const sc_core::sc_interface *i)
Definition: sensitivity.cc:130
DynamicSensitivityEventOrList(Process *p, const sc_core::sc_event_or_list *eol)
Definition: sensitivity.cc:215
virtual ::sc_core::sc_curr_proc_kind procKind() const =0
void satisfySensitivity(Sensitivity *)
Definition: process.cc:332
const char * name() const
Definition: sc_object.cc:44
const ::sc_core::sc_event & find(::sc_core::sc_interface *i)
Definition: sensitivity.cc:177
DynamicSensitivityEventAndList(Process *p, const sc_core::sc_event_and_list *eal)
Definition: sensitivity.cc:234
std::set< const ::sc_core::sc_event * > events
Definition: sensitivity.hh:146
bool disabled() const
Definition: process.hh:79
void newStaticSensitivityExport(Process *p, const sc_core::sc_export_base *exp)
Definition: sensitivity.cc:147
#define SC_REPORT_WARNING(msg_type, msg)
Bitfield< 6 > f
void newDynamicSensitivityEventAndList(Process *p, const sc_core::sc_event_and_list *eal)
Definition: sensitivity.cc:205
void newStaticSensitivityPort(Process *p, const sc_core::sc_port_base *pb)
Definition: sensitivity.cc:138
void delSensitivity(StaticSensitivity *s) const
Definition: event.hh:111
StaticSensitivityInterface(Process *p, const sc_core::sc_interface *i)
Definition: sensitivity.cc:164
Bitfield< 4 > s
Process * current()
Definition: scheduler.hh:170
void sensitive(StaticSensitivityPort *port)
Definition: port.cc:67
Scheduler scheduler
Definition: scheduler.cc:489
void newStaticSensitivityFinder(Process *p, const sc_core::sc_event_finder *f)
Definition: sensitivity.cc:155
void newStaticSensitivityEvent(Process *p, const sc_core::sc_event *e)
Definition: sensitivity.cc:122
void addToEvent(const ::sc_core::sc_event *e) override
Definition: sensitivity.cc:93
static Port * fromPort(const ::sc_core::sc_port_base *pb)
Definition: port.hh:121
const char SC_ID_IMMEDIATE_SELF_NOTIFICATION_[]
Definition: messages.cc:89
bool notify(Event *e)
Definition: sensitivity.cc:63
Bitfield< 9 > e
void newDynamicSensitivityEvent(Process *p, const sc_core::sc_event *e)
Definition: sensitivity.cc:188
virtual const sc_port_base * port() const =0
virtual bool notifyWork(Event *e)
Definition: sensitivity.cc:56
bool notifyWork(Event *e) override
Definition: sensitivity.cc:240
void setDynamic(DynamicSensitivity *)
Definition: process.cc:288
static Event * getFromScEvent(sc_core::sc_event *e)
Definition: event.hh:91
void delFromEvent(const ::sc_core::sc_event *e) override
Definition: sensitivity.cc:99
Bitfield< 0 > p
void addToEvent(const ::sc_core::sc_event *e) override
Definition: sensitivity.cc:105

Generated on Thu May 28 2020 16:21:35 for gem5 by doxygen 1.8.13