gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  * Authors: Gabe Black
28  */
29 
30 #ifndef __SYSTEMC_CORE_SENSITIVITY_HH__
31 #define __SYSTEMC_CORE_SENSITIVITY_HH__
32 
33 #include <set>
34 #include <vector>
35 
36 #include "sim/eventq.hh"
40 
41 namespace sc_core
42 {
43 
44 class sc_event;
45 class sc_event_and_list;
46 class sc_event_or_list;
47 class sc_event_finder;
48 class sc_export_base;
49 class sc_interface;
50 class sc_port_base;
51 
52 } // namespace sc_core
53 
54 namespace sc_gem5
55 {
56 
57 class Process;
58 class Event;
59 
60 /*
61  * Common sensitivity interface.
62  */
63 
65 {
66  protected:
68 
69  Sensitivity(Process *p) : process(p) {}
70  virtual ~Sensitivity() {}
71 
72  virtual void addToEvent(const ::sc_core::sc_event *e) = 0;
73  virtual void delFromEvent(const ::sc_core::sc_event *e) = 0;
74 
75  public:
76  virtual void clear() = 0;
77 
78  void satisfy();
79  virtual bool notifyWork(Event *e);
80  bool notify(Event *e);
81 
82  enum Category
83  {
85  Dynamic
86  };
87 
88  virtual Category category() = 0;
89 
90  bool ofMethod();
91 };
92 
93 
94 /*
95  * Dynamic vs. static sensitivity.
96  */
97 
98 class DynamicSensitivity : virtual public Sensitivity
99 {
100  protected:
102 
103  void addToEvent(const ::sc_core::sc_event *e) override;
104  void delFromEvent(const ::sc_core::sc_event *e) override;
105 
106  public:
107  Category category() override { return Dynamic; }
108 };
109 
111 
112 
113 class StaticSensitivity : virtual public Sensitivity
114 {
115  protected:
117 
118  void addToEvent(const ::sc_core::sc_event *e) override;
119  void delFromEvent(const ::sc_core::sc_event *e) override;
120 
121  public:
122  Category category() override { return Static; }
123 };
124 
126 
127 
128 /*
129  * Sensitivity to an event or events, which can be static or dynamic.
130  */
131 
132 class SensitivityEvent : virtual public Sensitivity
133 {
134  protected:
135  const ::sc_core::sc_event *event;
136 
137  SensitivityEvent(Process *p, const ::sc_core::sc_event *e=nullptr) :
138  Sensitivity(p), event(e)
139  {}
140 
141  public:
142  void clear() override { delFromEvent(event); }
143 };
144 
145 class SensitivityEvents : virtual public Sensitivity
146 {
147  protected:
148  std::set<const ::sc_core::sc_event *> events;
149 
152  Process *p, const std::set<const ::sc_core::sc_event *> &s) :
153  Sensitivity(p), events(s)
154  {}
155 
156  public:
157  void
158  clear() override
159  {
160  for (auto event: events)
161  delFromEvent(event);
162  }
163 
164  void
165  addEvent(const ::sc_core::sc_event *event)
166  {
167  events.insert(event);
168  addToEvent(event);
169  }
170 };
171 
172 
173 /*
174  * Static sensitivities.
175  */
176 
181  Process *p, const sc_core::sc_export_base *exp);
183  Process *p, const sc_core::sc_event_finder *f);
184 
185 
187  public StaticSensitivity, public SensitivityEvent
188 {
189  friend void newStaticSensitivityEvent(
190  Process *p, const sc_core::sc_event *e);
191 
192  protected:
195  {}
196 };
197 
199  public StaticSensitivity, public SensitivityEvent
200 {
201  friend void newStaticSensitivityInterface(
202  Process *p, const sc_core::sc_interface *i);
203  protected:
205 };
206 
208  public StaticSensitivity, public SensitivityEvents
209 {
210  friend void newStaticSensitivityPort(
211  Process *p, const sc_core::sc_port_base *pb);
212 
213  protected:
216  {}
217 };
218 
220  public StaticSensitivity, public SensitivityEvent
221 {
222  private:
223  friend void newStaticSensitivityExport(
224  Process *p, const sc_core::sc_export_base *exp);
225 
227 };
228 
229 
231  public StaticSensitivity, public SensitivityEvents
232 {
233  private:
235 
236  friend void newStaticSensitivityFinder(
237  Process *p, const sc_core::sc_event_finder *f);
238 
240  Sensitivity(p), StaticSensitivity(p), SensitivityEvents(p), finder(f)
241  {}
242 
243  public:
244  const ::sc_core::sc_event &find(::sc_core::sc_interface *i);
245 };
246 
247 
248 /*
249  * Dynamic sensitivities.
250  */
251 
254  Process *p, const sc_core::sc_event_or_list *eol);
256  Process *p, const sc_core::sc_event_and_list *eal);
257 
259  public DynamicSensitivity, public SensitivityEvent
260 {
261  private:
262  friend void newDynamicSensitivityEvent(
263  Process *p, const sc_core::sc_event *e);
264 
267  {}
268 };
269 
272 {
273  private:
275  Process *p, const sc_core::sc_event_or_list *eol);
276 
278  Process *p, const sc_core::sc_event_or_list *eol);
279 
280  bool notifyWork(Event *e) override;
281 };
282 
283 //XXX This sensitivity can't be reused. To reset it, it has to be deleted and
284 //recreated. That works for dynamic sensitivities, but not for static.
285 //Fortunately processes can't be statically sensitive to sc_event_and_lists.
288 {
289  private:
291  Process *p, const sc_core::sc_event_and_list *eal);
292 
294  Process *p, const sc_core::sc_event_and_list *eal);
295 
296  bool notifyWork(Event *e) override;
297 };
298 
299 } // namespace sc_gem5
300 
301 #endif //__SYSTEMC_CORE_SENSITIVITY_HH__
void newDynamicSensitivityEventOrList(Process *p, const sc_core::sc_event_or_list *eol)
Definition: sensitivity.cc:198
Category category() override
Definition: sensitivity.hh:122
SensitivityEvents(Process *p, const std::set< const ::sc_core::sc_event *> &s)
Definition: sensitivity.hh:151
Bitfield< 7 > i
const ::sc_core::sc_event * event
Definition: sensitivity.hh:135
void newStaticSensitivityInterface(Process *p, const sc_core::sc_interface *i)
Definition: sensitivity.cc:132
std::set< const ::sc_core::sc_event * > events
Definition: sensitivity.hh:148
void newStaticSensitivityExport(Process *p, const sc_core::sc_export_base *exp)
Definition: sensitivity.cc:149
Bitfield< 6 > f
void newDynamicSensitivityEventAndList(Process *p, const sc_core::sc_event_and_list *eal)
Definition: sensitivity.cc:207
void newStaticSensitivityPort(Process *p, const sc_core::sc_port_base *pb)
Definition: sensitivity.cc:140
DynamicSensitivityEvent(Process *p, const sc_core::sc_event *e)
Definition: sensitivity.hh:265
Bitfield< 4 > s
StaticSensitivityEvent(Process *p, const sc_core::sc_event *e)
Definition: sensitivity.hh:193
virtual ~Sensitivity()
Definition: sensitivity.hh:70
void newStaticSensitivityFinder(Process *p, const sc_core::sc_event_finder *f)
Definition: sensitivity.cc:157
Bitfield< 10, 5 > event
void newStaticSensitivityEvent(Process *p, const sc_core::sc_event *e)
Definition: sensitivity.cc:124
void addEvent(const ::sc_core::sc_event *event)
Definition: sensitivity.hh:165
Sensitivity(Process *p)
Definition: sensitivity.hh:69
Bitfield< 9 > e
SensitivityEvent(Process *p, const ::sc_core::sc_event *e=nullptr)
Definition: sensitivity.hh:137
void newDynamicSensitivityEvent(Process *p, const sc_core::sc_event *e)
Definition: sensitivity.cc:190
Definition: eventq.hh:189
Category category() override
Definition: sensitivity.hh:107
std::vector< DynamicSensitivity * > DynamicSensitivities
Definition: sensitivity.hh:110
StaticSensitivityFinder(Process *p, const sc_core::sc_event_finder *f)
Definition: sensitivity.hh:239
Bitfield< 0 > p
const sc_core::sc_event_finder * finder
Definition: sensitivity.hh:234
std::vector< StaticSensitivity * > StaticSensitivities
Definition: sensitivity.hh:125

Generated on Fri Feb 28 2020 16:27:03 for gem5 by doxygen 1.8.13