gem5 v24.0.0.0
Loading...
Searching...
No Matches
sensitivity.hh
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
28#ifndef __SYSTEMC_CORE_SENSITIVITY_HH__
29#define __SYSTEMC_CORE_SENSITIVITY_HH__
30
31#include <set>
32#include <vector>
33
34#include "sim/eventq.hh"
38
39namespace sc_core
40{
41
42class sc_event;
43class sc_event_and_list;
44class sc_event_or_list;
45class sc_event_finder;
46class sc_export_base;
47class sc_interface;
48class sc_port_base;
49
50} // namespace sc_core
51
52namespace sc_gem5
53{
54
55class Process;
56class Event;
57
58/*
59 * Common sensitivity interface.
60 */
61
63{
64 protected:
66
68 virtual ~Sensitivity() {}
69
70 virtual void addToEvent(const ::sc_core::sc_event *e) = 0;
71 virtual void delFromEvent(const ::sc_core::sc_event *e) = 0;
72
73 public:
74 virtual void clear() = 0;
75
76 void satisfy();
77 virtual bool notifyWork(Event *e);
78 bool notify(Event *e);
79
81 {
84 };
85
86 virtual Category category() = 0;
87
88 bool ofMethod();
89};
90
91
92/*
93 * Dynamic vs. static sensitivity.
94 */
95
96class DynamicSensitivity : virtual public Sensitivity
97{
98 protected:
100
101 void addToEvent(const ::sc_core::sc_event *e) override;
102 void delFromEvent(const ::sc_core::sc_event *e) override;
103
104 public:
105 Category category() override { return Dynamic; }
106};
107
109
110
111class StaticSensitivity : virtual public Sensitivity
112{
113 protected:
115
116 void addToEvent(const ::sc_core::sc_event *e) override;
117 void delFromEvent(const ::sc_core::sc_event *e) override;
118
119 public:
120 Category category() override { return Static; }
121};
122
124
125
126/*
127 * Sensitivity to an event or events, which can be static or dynamic.
128 */
129
130class SensitivityEvent : virtual public Sensitivity
131{
132 protected:
133 const ::sc_core::sc_event *event;
134
135 SensitivityEvent(Process *p, const ::sc_core::sc_event *e=nullptr) :
136 Sensitivity(p), event(e)
137 {}
138
139 public:
140 void clear() override { delFromEvent(event); }
141};
142
143class SensitivityEvents : virtual public Sensitivity
144{
145 protected:
146 std::set<const ::sc_core::sc_event *> events;
147
150 Process *p, const std::set<const ::sc_core::sc_event *> &s) :
151 Sensitivity(p), events(s)
152 {}
153
154 public:
155 void
156 clear() override
157 {
158 for (auto event: events)
159 delFromEvent(event);
160 }
161
162 void
163 addEvent(const ::sc_core::sc_event *event)
164 {
165 events.insert(event);
166 addToEvent(event);
167 }
168};
169
170
171/*
172 * Static sensitivities.
173 */
174
175void newStaticSensitivityEvent(Process *p, const sc_core::sc_event *e);
177void newStaticSensitivityPort(Process *p, const sc_core::sc_port_base *pb);
179 Process *p, const sc_core::sc_export_base *exp);
181 Process *p, const sc_core::sc_event_finder *f);
182
183
186{
187 friend void newStaticSensitivityEvent(
188 Process *p, const sc_core::sc_event *e);
189
190 protected:
194};
195
198{
200 Process *p, const sc_core::sc_interface *i);
201 protected:
203};
204
207{
208 friend void newStaticSensitivityPort(
209 Process *p, const sc_core::sc_port_base *pb);
210
211 protected:
215};
216
219{
220 private:
221 friend void newStaticSensitivityExport(
222 Process *p, const sc_core::sc_export_base *exp);
223
225};
226
227
230{
231 private:
233
234 friend void newStaticSensitivityFinder(
236
240
241 public:
242 const ::sc_core::sc_event &find(::sc_core::sc_interface *i);
243};
244
245
246/*
247 * Dynamic sensitivities.
248 */
249
250void newDynamicSensitivityEvent(Process *p, const sc_core::sc_event *e);
252 Process *p, const sc_core::sc_event_or_list *eol);
254 Process *p, const sc_core::sc_event_and_list *eal);
255
258{
259 private:
260 friend void newDynamicSensitivityEvent(
261 Process *p, const sc_core::sc_event *e);
262
266};
267
283
284//XXX This sensitivity can't be reused. To reset it, it has to be deleted and
285//recreated. That works for dynamic sensitivities, but not for static.
286//Fortunately processes can't be statically sensitive to sc_event_and_lists.
302
303} // namespace sc_gem5
304
305#endif //__SYSTEMC_CORE_SENSITIVITY_HH__
friend void newDynamicSensitivityEventAndList(Process *p, const sc_core::sc_event_and_list *eal)
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)
friend void newDynamicSensitivityEventOrList(Process *p, const sc_core::sc_event_or_list *eol)
friend void newDynamicSensitivityEvent(Process *p, const sc_core::sc_event *e)
DynamicSensitivityEvent(Process *p, const sc_core::sc_event *e)
Category category() override
void addToEvent(const ::sc_core::sc_event *e) override
void delFromEvent(const ::sc_core::sc_event *e) override
const ::sc_core::sc_event * event
SensitivityEvent(Process *p, const ::sc_core::sc_event *e=nullptr)
SensitivityEvents(Process *p, const std::set< const ::sc_core::sc_event * > &s)
std::set< const ::sc_core::sc_event * > events
void addEvent(const ::sc_core::sc_event *event)
virtual void delFromEvent(const ::sc_core::sc_event *e)=0
virtual void clear()=0
virtual void addToEvent(const ::sc_core::sc_event *e)=0
bool notify(Event *e)
Sensitivity(Process *p)
virtual bool notifyWork(Event *e)
virtual Category category()=0
friend void newStaticSensitivityEvent(Process *p, const sc_core::sc_event *e)
StaticSensitivityEvent(Process *p, const sc_core::sc_event *e)
StaticSensitivityExport(Process *p, const sc_core::sc_export_base *exp)
friend void newStaticSensitivityExport(Process *p, const sc_core::sc_export_base *exp)
const ::sc_core::sc_event & find(::sc_core::sc_interface *i)
friend void newStaticSensitivityFinder(Process *p, const sc_core::sc_event_finder *f)
const sc_core::sc_event_finder * finder
StaticSensitivityFinder(Process *p, const sc_core::sc_event_finder *f)
StaticSensitivityInterface(Process *p, const sc_core::sc_interface *i)
friend void newStaticSensitivityInterface(Process *p, const sc_core::sc_interface *i)
friend void newStaticSensitivityPort(Process *p, const sc_core::sc_port_base *pb)
Category category() override
void addToEvent(const ::sc_core::sc_event *e) override
void delFromEvent(const ::sc_core::sc_event *e) override
STL vector class.
Definition stl.hh:37
int f(int a, int b)
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)
std::vector< StaticSensitivity * > StaticSensitivities
std::vector< DynamicSensitivity * > DynamicSensitivities
void newDynamicSensitivityEventAndList(Process *p, const sc_core::sc_event_and_list *eal)
void newDynamicSensitivityEventOrList(Process *p, const sc_core::sc_event_or_list *eol)
void newStaticSensitivityExport(Process *p, const sc_core::sc_export_base *exp)

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