gem5 v24.0.0.0
Loading...
Searching...
No Matches
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"
41
42namespace sc_gem5
43{
44
45/*
46 * Common sensitivity interface.
47 */
48
49void
54
55bool
57{
58 satisfy();
59 return true;
60}
61
62bool
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
81bool
86
87
88/*
89 * Dynamic vs. static sensitivity.
90 */
91
92void
93DynamicSensitivity::addToEvent(const ::sc_core::sc_event *e)
94{
96}
97
98void
99DynamicSensitivity::delFromEvent(const ::sc_core::sc_event *e)
100{
102}
103
104void
105StaticSensitivity::addToEvent(const ::sc_core::sc_event *e)
106{
108}
109
110void
111StaticSensitivity::delFromEvent(const ::sc_core::sc_event *e)
112{
114}
115
116
117/*
118 * Static sensitivities.
119 */
120
121void
123{
124 auto s = new StaticSensitivityEvent(p, e);
125 s->addToEvent(s->event);
126 p->addStatic(s);
127}
128
129void
131{
132 auto s = new StaticSensitivityInterface(p, i);
133 s->addToEvent(s->event);
134 p->addStatic(s);
135}
136
137void
139{
140 auto s = new StaticSensitivityPort(p);
141 Port *port = Port::fromPort(pb);
142 port->sensitive(s);
143 p->addStatic(s);
144}
145
146void
148{
149 auto s = new StaticSensitivityExport(p, exp);
150 s->addToEvent(s->event);
151 p->addStatic(s);
152}
153
154void
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
169
171 Process *p, const sc_core::sc_export_base *exp) :
173 SensitivityEvent(p, &exp->get_interface()->default_event())
174{}
175
176const ::sc_core::sc_event &
181
182
183/*
184 * Dynamic sensitivities.
185 */
186
187void
189{
190 auto s = new DynamicSensitivityEvent(p, e);
191 s->addToEvent(s->event);
192 p->setDynamic(s);
193}
194
195void
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
222
224{
225 if (list->autoDelete) {
227 "sc_event_or_list can never be busy in gem5 implementation");
228 delete list;
229 }
230}
231
232bool
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
253
255{
256 if (list->autoDelete) {
258 "sc_event_and_list can never be busy in gem5 implementation");
259 delete list;
260 }
261}
262
263bool
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
const sc_core::sc_event_and_list * list
DynamicSensitivityEventAndList(Process *p, const sc_core::sc_event_and_list *eal)
const sc_core::sc_event_or_list * list
DynamicSensitivityEventOrList(Process *p, const sc_core::sc_event_or_list *eol)
void addToEvent(const ::sc_core::sc_event *e) override
void delFromEvent(const ::sc_core::sc_event *e) override
void addSensitivity(StaticSensitivity *s) const
Definition event.hh:103
static Event * getFromScEvent(sc_core::sc_event *e)
Definition event.hh:91
void delSensitivity(StaticSensitivity *s) const
Definition event.hh:111
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
bool notify(Event *e)
virtual bool notifyWork(Event *e)
StaticSensitivityExport(Process *p, const sc_core::sc_export_base *exp)
const ::sc_core::sc_event & find(::sc_core::sc_interface *i)
const sc_core::sc_event_finder * finder
StaticSensitivityInterface(Process *p, const sc_core::sc_interface *i)
void addToEvent(const ::sc_core::sc_event *e) override
void delFromEvent(const ::sc_core::sc_event *e) override
int f(int a, int b)
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition logging.hh:214
const char SC_ID_IMMEDIATE_SELF_NOTIFICATION_[]
Definition messages.cc:89
void newStaticSensitivityInterface(Process *p, const sc_core::sc_interface *i)
void newStaticSensitivityFinder(Process *p, const sc_core::sc_event_finder *f)
void newStaticSensitivityEvent(Process *p, const sc_core::sc_event *e)
void newStaticSensitivityPort(Process *p, const sc_core::sc_port_base *pb)
void newDynamicSensitivityEvent(Process *p, const sc_core::sc_event *e)
void newDynamicSensitivityEventAndList(Process *p, const sc_core::sc_event_and_list *eal)
Scheduler scheduler
Definition scheduler.cc:494
void newDynamicSensitivityEventOrList(Process *p, const sc_core::sc_event_or_list *eol)
void newStaticSensitivityExport(Process *p, const sc_core::sc_export_base *exp)
#define SC_REPORT_WARNING(msg_type, msg)

Generated on Tue Jun 18 2024 16:24:06 for gem5 by doxygen 1.11.0