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

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