gem5  v22.1.0.0
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 
39 namespace sc_core
40 {
41 
42 class sc_event;
43 class sc_event_and_list;
44 class sc_event_or_list;
45 class sc_event_finder;
46 class sc_export_base;
47 class sc_interface;
48 class sc_port_base;
49 
50 } // namespace sc_core
51 
52 namespace sc_gem5
53 {
54 
55 class Process;
56 class 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 
80  enum Category
81  {
83  Dynamic
84  };
85 
86  virtual Category category() = 0;
87 
88  bool ofMethod();
89 };
90 
91 
92 /*
93  * Dynamic vs. static sensitivity.
94  */
95 
96 class 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 
111 class 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 
130 class 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 
143 class 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)
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 
175 void newStaticSensitivityEvent(Process *p, const sc_core::sc_event *e);
177 void 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 
185  public StaticSensitivity, public SensitivityEvent
186 {
187  friend void newStaticSensitivityEvent(
188  Process *p, const sc_core::sc_event *e);
189 
190  protected:
193  {}
194 };
195 
197  public StaticSensitivity, public SensitivityEvent
198 {
199  friend void newStaticSensitivityInterface(
200  Process *p, const sc_core::sc_interface *i);
201  protected:
203 };
204 
206  public StaticSensitivity, public SensitivityEvents
207 {
208  friend void newStaticSensitivityPort(
209  Process *p, const sc_core::sc_port_base *pb);
210 
211  protected:
214  {}
215 };
216 
218  public StaticSensitivity, public SensitivityEvent
219 {
220  private:
221  friend void newStaticSensitivityExport(
222  Process *p, const sc_core::sc_export_base *exp);
223 
225 };
226 
227 
229  public StaticSensitivity, public SensitivityEvents
230 {
231  private:
233 
234  friend void newStaticSensitivityFinder(
236 
239  {}
240 
241  public:
242  const ::sc_core::sc_event &find(::sc_core::sc_interface *i);
243 };
244 
245 
246 /*
247  * Dynamic sensitivities.
248  */
249 
250 void 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 
257  public DynamicSensitivity, public SensitivityEvent
258 {
259  private:
260  friend void newDynamicSensitivityEvent(
261  Process *p, const sc_core::sc_event *e);
262 
265  {}
266 };
267 
270 {
271  private:
273  Process *p, const sc_core::sc_event_or_list *eol);
274 
276  Process *p, const sc_core::sc_event_or_list *eol);
278 
279  bool notifyWork(Event *e) override;
280 
282 };
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.
289 {
290  private:
292  Process *p, const sc_core::sc_event_and_list *eal);
293 
295  Process *p, const sc_core::sc_event_and_list *eal);
297 
298  bool notifyWork(Event *e) override;
299 
301 };
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)
Definition: sensitivity.cc:205
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
friend void newDynamicSensitivityEventOrList(Process *p, const sc_core::sc_event_or_list *eol)
Definition: sensitivity.cc:196
friend void newDynamicSensitivityEvent(Process *p, const sc_core::sc_event *e)
Definition: sensitivity.cc:188
DynamicSensitivityEvent(Process *p, const sc_core::sc_event *e)
Definition: sensitivity.hh:263
Category category() override
Definition: sensitivity.hh:105
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
const ::sc_core::sc_event * event
Definition: sensitivity.hh:133
SensitivityEvent(Process *p, const ::sc_core::sc_event *e=nullptr)
Definition: sensitivity.hh:135
SensitivityEvents(Process *p, const std::set< const ::sc_core::sc_event * > &s)
Definition: sensitivity.hh:149
std::set< const ::sc_core::sc_event * > events
Definition: sensitivity.hh:146
void addEvent(const ::sc_core::sc_event *event)
Definition: sensitivity.hh:163
virtual void delFromEvent(const ::sc_core::sc_event *e)=0
virtual ~Sensitivity()
Definition: sensitivity.hh:68
virtual void clear()=0
virtual void addToEvent(const ::sc_core::sc_event *e)=0
bool notify(Event *e)
Definition: sensitivity.cc:63
Sensitivity(Process *p)
Definition: sensitivity.hh:67
virtual bool notifyWork(Event *e)
Definition: sensitivity.cc:56
virtual Category category()=0
friend void newStaticSensitivityEvent(Process *p, const sc_core::sc_event *e)
Definition: sensitivity.cc:122
StaticSensitivityEvent(Process *p, const sc_core::sc_event *e)
Definition: sensitivity.hh:191
StaticSensitivityExport(Process *p, const sc_core::sc_export_base *exp)
Definition: sensitivity.cc:170
friend void newStaticSensitivityExport(Process *p, const sc_core::sc_export_base *exp)
Definition: sensitivity.cc:147
friend void newStaticSensitivityFinder(Process *p, const sc_core::sc_event_finder *f)
Definition: sensitivity.cc:155
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
StaticSensitivityFinder(Process *p, const sc_core::sc_event_finder *f)
Definition: sensitivity.hh:237
StaticSensitivityInterface(Process *p, const sc_core::sc_interface *i)
Definition: sensitivity.cc:164
friend void newStaticSensitivityInterface(Process *p, const sc_core::sc_interface *i)
Definition: sensitivity.cc:130
friend void newStaticSensitivityPort(Process *p, const sc_core::sc_port_base *pb)
Definition: sensitivity.cc:138
Category category() override
Definition: sensitivity.hh:120
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
Bitfield< 7 > i
Definition: misc_types.hh:67
Bitfield< 9 > e
Definition: misc_types.hh:65
Bitfield< 10, 5 > event
Bitfield< 1 > s
Definition: pagetable.hh:64
Bitfield< 56 > f
Definition: pagetable.hh:53
Bitfield< 54 > p
Definition: pagetable.hh:70
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
std::vector< StaticSensitivity * > StaticSensitivities
Definition: sensitivity.hh:123
std::vector< DynamicSensitivity * > DynamicSensitivities
Definition: sensitivity.hh:108
void newDynamicSensitivityEventAndList(Process *p, const sc_core::sc_event_and_list *eal)
Definition: sensitivity.cc:205
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

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