gem5  v22.0.0.2
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  {
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__
sc_gem5::DynamicSensitivity::DynamicSensitivity
DynamicSensitivity(Process *p)
Definition: sensitivity.hh:99
sc_core::sc_port_base
Definition: sc_port.hh:74
sc_gem5::StaticSensitivity::StaticSensitivity
StaticSensitivity(Process *p)
Definition: sensitivity.hh:114
gem5::VegaISA::s
Bitfield< 1 > s
Definition: pagetable.hh:64
sc_gem5::DynamicSensitivityEventOrList::list
const sc_core::sc_event_or_list * list
Definition: sensitivity.hh:281
sc_gem5::DynamicSensitivityEventAndList::~DynamicSensitivityEventAndList
~DynamicSensitivityEventAndList()
Definition: sensitivity.cc:254
sc_gem5::DynamicSensitivityEventOrList::~DynamicSensitivityEventOrList
~DynamicSensitivityEventOrList()
Definition: sensitivity.cc:223
gem5::VegaISA::f
Bitfield< 56 > f
Definition: pagetable.hh:53
sc_gem5::DynamicSensitivityEventAndList
Definition: sensitivity.hh:287
sc_gem5::DynamicSensitivityEvent::newDynamicSensitivityEvent
friend void newDynamicSensitivityEvent(Process *p, const sc_core::sc_event *e)
Definition: sensitivity.cc:188
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::StaticSensitivities
std::vector< StaticSensitivity * > StaticSensitivities
Definition: sensitivity.hh:123
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
sc_gem5::DynamicSensitivityEventOrList::newDynamicSensitivityEventOrList
friend void newDynamicSensitivityEventOrList(Process *p, const sc_core::sc_event_or_list *eol)
Definition: sensitivity.cc:196
sc_gem5::StaticSensitivityExport::newStaticSensitivityExport
friend void newStaticSensitivityExport(Process *p, const sc_core::sc_export_base *exp)
Definition: sensitivity.cc:147
sc_gem5::StaticSensitivityFinder
Definition: sensitivity.hh:228
sc_gem5::SensitivityEvent::SensitivityEvent
SensitivityEvent(Process *p, const ::sc_core::sc_event *e=nullptr)
Definition: sensitivity.hh:135
sc_core
Definition: messages.cc:31
gem5::MipsISA::event
Bitfield< 10, 5 > event
Definition: pra_constants.hh:300
sc_gem5::Sensitivity::satisfy
void satisfy()
Definition: sensitivity.cc:50
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
gem5::ArmISA::e
Bitfield< 9 > e
Definition: misc_types.hh:65
sc_gem5::newDynamicSensitivityEventOrList
void newDynamicSensitivityEventOrList(Process *p, const sc_core::sc_event_or_list *eol)
Definition: sensitivity.cc:196
sc_port.hh
sc_gem5::StaticSensitivityPort::newStaticSensitivityPort
friend void newStaticSensitivityPort(Process *p, const sc_core::sc_port_base *pb)
Definition: sensitivity.cc:138
std::vector< DynamicSensitivity * >
sc_gem5::SensitivityEvents::clear
void clear() override
Definition: sensitivity.hh:156
sc_gem5::DynamicSensitivities
std::vector< DynamicSensitivity * > DynamicSensitivities
Definition: sensitivity.hh:108
sc_gem5::DynamicSensitivityEventAndList::list
const sc_core::sc_event_and_list * list
Definition: sensitivity.hh:300
sc_gem5::StaticSensitivityEvent::StaticSensitivityEvent
StaticSensitivityEvent(Process *p, const sc_core::sc_event *e)
Definition: sensitivity.hh:191
gem5::ArmISA::i
Bitfield< 7 > i
Definition: misc_types.hh:67
sc_gem5::DynamicSensitivityEventOrList::notifyWork
bool notifyWork(Event *e) override
Definition: sensitivity.cc:233
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::Sensitivity::~Sensitivity
virtual ~Sensitivity()
Definition: sensitivity.hh:68
sc_gem5::Sensitivity::delFromEvent
virtual void delFromEvent(const ::sc_core::sc_event *e)=0
sc_gem5::SensitivityEvents::addEvent
void addEvent(const ::sc_core::sc_event *event)
Definition: sensitivity.hh:163
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::StaticSensitivityInterface::newStaticSensitivityInterface
friend void newStaticSensitivityInterface(Process *p, const sc_core::sc_interface *i)
Definition: sensitivity.cc:130
gem5::VegaISA::p
Bitfield< 54 > p
Definition: pagetable.hh:70
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
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
sched_event.hh
sc_gem5::Sensitivity::notifyWork
virtual bool notifyWork(Event *e)
Definition: sensitivity.cc:56
sc_gem5::Sensitivity::Sensitivity
Sensitivity(Process *p)
Definition: sensitivity.hh:67
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_gem5::Sensitivity::category
virtual Category category()=0
sc_gem5::StaticSensitivityPort::StaticSensitivityPort
StaticSensitivityPort(Process *p)
Definition: sensitivity.hh:212
sc_gem5::StaticSensitivityEvent::newStaticSensitivityEvent
friend void newStaticSensitivityEvent(Process *p, const sc_core::sc_event *e)
Definition: sensitivity.cc:122
sc_gem5::SensitivityEvents::SensitivityEvents
SensitivityEvents(Process *p, const std::set< const ::sc_core::sc_event * > &s)
Definition: sensitivity.hh:149
sc_gem5::Process
Definition: process.hh:62
sc_module.hh
sc_gem5::DynamicSensitivityEvent::DynamicSensitivityEvent
DynamicSensitivityEvent(Process *p, const sc_core::sc_event *e)
Definition: sensitivity.hh:263
sc_gem5::DynamicSensitivityEventAndList::DynamicSensitivityEventAndList
DynamicSensitivityEventAndList(Process *p, const sc_core::sc_event_and_list *eal)
Definition: sensitivity.cc:246
sc_gem5::StaticSensitivityFinder::StaticSensitivityFinder
StaticSensitivityFinder(Process *p, const sc_core::sc_event_finder *f)
Definition: sensitivity.hh:237
sc_gem5::SensitivityEvent::event
const ::sc_core::sc_event * event
Definition: sensitivity.hh:133
sc_gem5::StaticSensitivity::addToEvent
void addToEvent(const ::sc_core::sc_event *e) override
Definition: sensitivity.cc:105
sc_gem5::Sensitivity::Category
Category
Definition: sensitivity.hh:80
sc_gem5::SensitivityEvents
Definition: sensitivity.hh:143
sc_gem5::newStaticSensitivityInterface
void newStaticSensitivityInterface(Process *p, const sc_core::sc_interface *i)
Definition: sensitivity.cc:130
sc_gem5::SensitivityEvents::SensitivityEvents
SensitivityEvents(Process *p)
Definition: sensitivity.hh:148
sc_gem5::StaticSensitivity::category
Category category() override
Definition: sensitivity.hh:120
sc_gem5::DynamicSensitivityEventAndList::notifyWork
bool notifyWork(Event *e) override
Definition: sensitivity.cc:264
sc_gem5::Sensitivity::notify
bool notify(Event *e)
Definition: sensitivity.cc:63
sc_gem5::DynamicSensitivityEvent
Definition: sensitivity.hh:256
sc_gem5
Definition: sc_clock.cc:41
sc_gem5::SensitivityEvent::clear
void clear() override
Definition: sensitivity.hh:140
sc_core::sc_event_finder
Definition: sc_event.hh:212
sc_gem5::StaticSensitivityFinder::newStaticSensitivityFinder
friend void newStaticSensitivityFinder(Process *p, const sc_core::sc_event_finder *f)
Definition: sensitivity.cc:155
sc_gem5::Sensitivity::addToEvent
virtual void addToEvent(const ::sc_core::sc_event *e)=0
sc_gem5::DynamicSensitivityEventOrList::DynamicSensitivityEventOrList
DynamicSensitivityEventOrList(Process *p, const sc_core::sc_event_or_list *eol)
Definition: sensitivity.cc:215
sc_gem5::Sensitivity::clear
virtual void clear()=0
sc_gem5::Sensitivity
Definition: sensitivity.hh:62
sc_gem5::Sensitivity::Static
@ Static
Definition: sensitivity.hh:82
sc_gem5::Sensitivity::Dynamic
@ Dynamic
Definition: sensitivity.hh:83
sc_gem5::DynamicSensitivityEventAndList::newDynamicSensitivityEventAndList
friend void newDynamicSensitivityEventAndList(Process *p, const sc_core::sc_event_and_list *eal)
Definition: sensitivity.cc:205
sc_gem5::DynamicSensitivity::category
Category category() override
Definition: sensitivity.hh:105
eventq.hh

Generated on Thu Jul 28 2022 13:32:37 for gem5 by doxygen 1.8.17