gem5  v20.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) :
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
port.hh
sc_core::sc_port_base
Definition: sc_port.hh:74
sc_gem5::DynamicSensitivityEventAndList
Definition: sensitivity.hh:284
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
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
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
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
X86ISA::le
Bitfield< 8 > le
Definition: misc.hh:664
sc_gem5::newDynamicSensitivityEventOrList
void newDynamicSensitivityEventOrList(Process *p, const sc_core::sc_event_or_list *eol)
Definition: sensitivity.cc:196
sc_port.hh
sensitivity.hh
sc_gem5::Event::delSensitivity
void delSensitivity(StaticSensitivity *s) const
Definition: event.hh:111
sc_gem5::DynamicSensitivityEventOrList::notifyWork
bool notifyWork(Event *e) override
Definition: sensitivity.cc:221
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
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
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
MipsISA::event
Bitfield< 10, 5 > event
Definition: pra_constants.hh:297
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_gem5::Process::satisfySensitivity
void satisfySensitivity(Sensitivity *)
Definition: process.cc:332
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:234
ArmISA::e
Bitfield< 9 > e
Definition: miscregs_types.hh:61
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_out.hh
sc_gem5::SensitivityEvents
Definition: sensitivity.hh:143
sc_gem5::Scheduler::current
Process * current()
Definition: scheduler.hh:170
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:240
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_gem5::Process::procKind
virtual ::sc_core::sc_curr_proc_kind procKind() const =0
sc_gem5
Definition: sc_clock.cc:42
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
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
sc_gem5::scheduler
Scheduler scheduler
Definition: scheduler.cc:489
ArmISA::s
Bitfield< 4 > s
Definition: miscregs_types.hh:556
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
ArmISA::f
Bitfield< 6 > f
Definition: miscregs_types.hh:64

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