gem5  v22.0.0.1
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
port.hh
sc_core::sc_port_base
Definition: sc_port.hh:74
gem5::VegaISA::s
Bitfield< 1 > s
Definition: pagetable.hh:64
sc_gem5::DynamicSensitivityEventOrList::list
const sc_core::sc_event_or_list * list
Definition: sensitivity.hh:281
sc_gem5::DynamicSensitivityEventAndList::~DynamicSensitivityEventAndList
~DynamicSensitivityEventAndList()
Definition: sensitivity.cc:254
sc_gem5::DynamicSensitivityEventOrList::~DynamicSensitivityEventOrList
~DynamicSensitivityEventOrList()
Definition: sensitivity.cc:223
gem5::VegaISA::f
Bitfield< 56 > f
Definition: pagetable.hh:53
sc_gem5::Process::satisfySensitivity
void satisfySensitivity(Sensitivity *)
Definition: process.cc:332
sc_gem5::DynamicSensitivityEventAndList
Definition: sensitivity.hh:287
sc_gem5::StaticSensitivityEvent
Definition: sensitivity.hh:184
sc_gem5::Sensitivity::ofMethod
bool ofMethod()
Definition: sensitivity.cc:82
sc_gem5::StaticSensitivityInterface
Definition: sensitivity.hh:196
sc_gem5::newStaticSensitivityEvent
void newStaticSensitivityEvent(Process *p, const sc_core::sc_event *e)
Definition: sensitivity.cc:122
sc_gem5::DynamicSensitivity::addToEvent
void addToEvent(const ::sc_core::sc_event *e) override
Definition: sensitivity.cc:93
sc_gem5::DynamicSensitivity::delFromEvent
void delFromEvent(const ::sc_core::sc_event *e) override
Definition: sensitivity.cc:99
sc_core::sc_export_base
Definition: sc_export.hh:41
sc_gem5::SensitivityEvents::events
std::set< const ::sc_core::sc_event * > events
Definition: sensitivity.hh:146
sc_gem5::StaticSensitivityFinder
Definition: sensitivity.hh:228
sc_core::SC_ID_IMMEDIATE_SELF_NOTIFICATION_
const char SC_ID_IMMEDIATE_SELF_NOTIFICATION_[]
Definition: messages.cc:89
sc_gem5::Event::getFromScEvent
static Event * getFromScEvent(sc_core::sc_event *e)
Definition: event.hh:91
gem5::MipsISA::event
Bitfield< 10, 5 > event
Definition: pra_constants.hh:300
sc_gem5::Sensitivity::satisfy
void satisfy()
Definition: sensitivity.cc:50
sc_inout.hh
sc_core::sc_event_and_list
Definition: sc_event.hh:61
sc_core::sc_interface
Definition: sc_interface.hh:37
sc_gem5::Event
Definition: event.hh:58
sc_gem5::StaticSensitivityFinder::finder
const sc_core::sc_event_finder * finder
Definition: sensitivity.hh:232
sc_core::sc_event_or_list
Definition: sc_event.hh:93
gem5::ArmISA::e
Bitfield< 9 > e
Definition: misc_types.hh:65
sc_gem5::newDynamicSensitivityEventOrList
void newDynamicSensitivityEventOrList(Process *p, const sc_core::sc_event_or_list *eol)
Definition: sensitivity.cc:196
sc_port.hh
sc_dt::list
static scfx_rep_node * list
Definition: scfx_rep.cc:368
sensitivity.hh
sc_gem5::Event::delSensitivity
void delSensitivity(StaticSensitivity *s) const
Definition: event.hh:111
sc_gem5::DynamicSensitivityEventAndList::list
const sc_core::sc_event_and_list * list
Definition: sensitivity.hh:300
gem5::ArmISA::i
Bitfield< 7 > i
Definition: misc_types.hh:67
sc_gem5::DynamicSensitivityEventOrList::notifyWork
bool notifyWork(Event *e) override
Definition: sensitivity.cc:233
sc_gem5::newStaticSensitivityFinder
void newStaticSensitivityFinder(Process *p, const sc_core::sc_event_finder *f)
Definition: sensitivity.cc:155
sc_gem5::StaticSensitivity::delFromEvent
void delFromEvent(const ::sc_core::sc_event *e) override
Definition: sensitivity.cc:111
sc_gem5::StaticSensitivityExport::StaticSensitivityExport
StaticSensitivityExport(Process *p, const sc_core::sc_export_base *exp)
Definition: sensitivity.cc:170
sc_gem5::SensitivityEvent
Definition: sensitivity.hh:130
gem5::PowerISA::le
Bitfield< 0 > le
Definition: misc.hh:121
sc_core::sc_event_or_list::busy
unsigned busy
Definition: sc_event.hh:122
sc_gem5::Port::fromPort
static Port * fromPort(const ::sc_core::sc_port_base *pb)
Definition: port.hh:121
sc_gem5::newStaticSensitivityExport
void newStaticSensitivityExport(Process *p, const sc_core::sc_export_base *exp)
Definition: sensitivity.cc:147
sc_gem5::newDynamicSensitivityEvent
void newDynamicSensitivityEvent(Process *p, const sc_core::sc_event *e)
Definition: sensitivity.cc:188
gem5::VegaISA::p
Bitfield< 54 > p
Definition: pagetable.hh:70
sc_gem5::DynamicSensitivity
Definition: sensitivity.hh:96
sc_gem5::DynamicSensitivityEventOrList
Definition: sensitivity.hh:268
sc_core::sc_event
Definition: sc_event.hh:169
sc_gem5::newDynamicSensitivityEventAndList
void newDynamicSensitivityEventAndList(Process *p, const sc_core::sc_event_and_list *eal)
Definition: sensitivity.cc:205
sc_gem5::StaticSensitivityExport
Definition: sensitivity.hh:217
sc_gem5::StaticSensitivity
Definition: sensitivity.hh:111
sc_gem5::StaticSensitivityInterface::StaticSensitivityInterface
StaticSensitivityInterface(Process *p, const sc_core::sc_interface *i)
Definition: sensitivity.cc:164
sc_gem5::StaticSensitivityFinder::find
const ::sc_core::sc_event & find(::sc_core::sc_interface *i)
Definition: sensitivity.cc:177
sc_gem5::Sensitivity::process
Process * process
Definition: sensitivity.hh:65
sc_gem5::Process::disabled
bool disabled() const
Definition: process.hh:79
sc_gem5::Sensitivity::notifyWork
virtual bool notifyWork(Event *e)
Definition: sensitivity.cc:56
sc_core::SC_METHOD_PROC_
@ SC_METHOD_PROC_
Definition: sc_process_handle.hh:87
sc_gem5::newStaticSensitivityPort
void newStaticSensitivityPort(Process *p, const sc_core::sc_port_base *pb)
Definition: sensitivity.cc:138
sc_gem5::StaticSensitivityPort
Definition: sensitivity.hh:205
sc_interface.hh
messages.hh
sc_in.hh
sc_gem5::Process
Definition: process.hh:62
sc_core::sc_event_finder::find_event
virtual const sc_event & find_event(sc_interface *if_p=NULL) const =0
process.hh
sc_gem5::DynamicSensitivityEventAndList::DynamicSensitivityEventAndList
DynamicSensitivityEventAndList(Process *p, const sc_core::sc_event_and_list *eal)
Definition: sensitivity.cc:246
SC_REPORT_WARNING
#define SC_REPORT_WARNING(msg_type, msg)
Definition: sc_report_handler.hh:123
sc_gem5::StaticSensitivity::addToEvent
void addToEvent(const ::sc_core::sc_event *e) override
Definition: sensitivity.cc:105
sc_core::sc_event_and_list::busy
unsigned busy
Definition: sc_event.hh:90
sc_out.hh
panic_if
#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
sc_gem5::SensitivityEvents
Definition: sensitivity.hh:143
sc_core::sc_event_or_list::autoDelete
bool autoDelete
Definition: sc_event.hh:121
sc_gem5::Scheduler::current
Process * current()
Definition: scheduler.hh:185
sc_gem5::newStaticSensitivityInterface
void newStaticSensitivityInterface(Process *p, const sc_core::sc_interface *i)
Definition: sensitivity.cc:130
sc_core::sc_object::name
const char * name() const
Definition: sc_object.cc:44
sc_gem5::DynamicSensitivityEventAndList::notifyWork
bool notifyWork(Event *e) override
Definition: sensitivity.cc:264
sc_gem5::Port
Definition: port.hh:50
sc_gem5::Sensitivity::notify
bool notify(Event *e)
Definition: sensitivity.cc:63
sc_gem5::DynamicSensitivityEvent
Definition: sensitivity.hh:256
sc_core::sc_event_and_list::autoDelete
bool autoDelete
Definition: sc_event.hh:89
sc_gem5::Process::procKind
virtual ::sc_core::sc_curr_proc_kind procKind() const =0
sc_gem5
Definition: sc_clock.cc:41
event.hh
sc_export.hh
sc_gem5::Event::addSensitivity
void addSensitivity(StaticSensitivity *s) const
Definition: event.hh:103
sc_core::sc_event_finder
Definition: sc_event.hh:212
sc_gem5::scheduler
Scheduler scheduler
Definition: scheduler.cc:494
sc_gem5::Port::sensitive
void sensitive(StaticSensitivityPort *port)
Definition: port.cc:67
sc_gem5::DynamicSensitivityEventOrList::DynamicSensitivityEventOrList
DynamicSensitivityEventOrList(Process *p, const sc_core::sc_event_or_list *eol)
Definition: sensitivity.cc:215
scheduler.hh
sc_gem5::Sensitivity
Definition: sensitivity.hh:62

Generated on Sat Jun 18 2022 08:12:32 for gem5 by doxygen 1.8.17