gem5  v22.1.0.0
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),
219  SensitivityEvents(p, eol->events),
220  list(eol)
221 {}
222 
224 {
225  if (list->autoDelete) {
226  panic_if(list->busy,
227  "sc_event_or_list can never be busy in gem5 implementation");
228  delete list;
229  }
230 }
231 
232 bool
234 {
235  events.erase(e->sc_event());
236 
237  // All the other events need this deleted from their lists since this
238  // sensitivity has been satisfied without them triggering.
239  for (auto le: events)
240  delFromEvent(le);
241 
242  satisfy();
243  return true;
244 }
245 
247  Process *p, const sc_core::sc_event_and_list *eal) :
248  Sensitivity(p),
250  SensitivityEvents(p, eal->events),
251  list(eal)
252 {}
253 
255 {
256  if (list->autoDelete) {
257  panic_if(list->busy,
258  "sc_event_and_list can never be busy in gem5 implementation");
259  delete list;
260  }
261 }
262 
263 bool
265 {
266  events.erase(e->sc_event());
267 
268  // This sensitivity is satisfied if all events have triggered.
269  if (events.empty())
270  satisfy();
271 
272  return true;
273 }
274 
275 } // namespace sc_gem5
virtual const sc_event & find_event(sc_interface *if_p=NULL) const =0
const char * name() const
Definition: sc_object.cc:44
bool notifyWork(Event *e) override
Definition: sensitivity.cc:264
const sc_core::sc_event_and_list * list
Definition: sensitivity.hh:300
DynamicSensitivityEventAndList(Process *p, const sc_core::sc_event_and_list *eal)
Definition: sensitivity.cc:246
const sc_core::sc_event_or_list * list
Definition: sensitivity.hh:281
bool notifyWork(Event *e) override
Definition: sensitivity.cc:233
DynamicSensitivityEventOrList(Process *p, const sc_core::sc_event_or_list *eol)
Definition: sensitivity.cc:215
void addToEvent(const ::sc_core::sc_event *e) override
Definition: sensitivity.cc:93
void delFromEvent(const ::sc_core::sc_event *e) override
Definition: sensitivity.cc:99
void addSensitivity(StaticSensitivity *s) const
Definition: event.hh:103
void delSensitivity(StaticSensitivity *s) const
Definition: event.hh:111
static Event * getFromScEvent(sc_core::sc_event *e)
Definition: event.hh:91
void sensitive(StaticSensitivityPort *port)
Definition: port.cc:67
static Port * fromPort(const ::sc_core::sc_port_base *pb)
Definition: port.hh:121
virtual ::sc_core::sc_curr_proc_kind procKind() const =0
void satisfySensitivity(Sensitivity *)
Definition: process.cc:332
bool disabled() const
Definition: process.hh:79
Process * current()
Definition: scheduler.hh:185
std::set< const ::sc_core::sc_event * > events
Definition: sensitivity.hh:146
bool notify(Event *e)
Definition: sensitivity.cc:63
virtual bool notifyWork(Event *e)
Definition: sensitivity.cc:56
StaticSensitivityExport(Process *p, const sc_core::sc_export_base *exp)
Definition: sensitivity.cc:170
const ::sc_core::sc_event & find(::sc_core::sc_interface *i)
Definition: sensitivity.cc:177
const sc_core::sc_event_finder * finder
Definition: sensitivity.hh:232
StaticSensitivityInterface(Process *p, const sc_core::sc_interface *i)
Definition: sensitivity.cc:164
void addToEvent(const ::sc_core::sc_event *e) override
Definition: sensitivity.cc:105
void delFromEvent(const ::sc_core::sc_event *e) override
Definition: sensitivity.cc:111
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition: logging.hh:204
Bitfield< 7 > i
Definition: misc_types.hh:67
Bitfield< 9 > e
Definition: misc_types.hh:65
Bitfield< 10, 5 > event
Bitfield< 0 > le
Definition: misc.hh:126
Bitfield< 1 > s
Definition: pagetable.hh:64
Bitfield< 56 > f
Definition: pagetable.hh:53
Bitfield< 54 > p
Definition: pagetable.hh:70
const char SC_ID_IMMEDIATE_SELF_NOTIFICATION_[]
Definition: messages.cc:89
static scfx_rep_node * list
Definition: scfx_rep.cc:336
void newStaticSensitivityInterface(Process *p, const sc_core::sc_interface *i)
Definition: sensitivity.cc:130
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 newStaticSensitivityPort(Process *p, const sc_core::sc_port_base *pb)
Definition: sensitivity.cc:138
void newDynamicSensitivityEvent(Process *p, const sc_core::sc_event *e)
Definition: sensitivity.cc:188
void newDynamicSensitivityEventAndList(Process *p, const sc_core::sc_event_and_list *eal)
Definition: sensitivity.cc:205
Scheduler scheduler
Definition: scheduler.cc:494
void newDynamicSensitivityEventOrList(Process *p, const sc_core::sc_event_or_list *eol)
Definition: sensitivity.cc:196
void newStaticSensitivityExport(Process *p, const sc_core::sc_export_base *exp)
Definition: sensitivity.cc:147
#define SC_REPORT_WARNING(msg_type, msg)

Generated on Wed Dec 21 2022 10:22:40 for gem5 by doxygen 1.9.1