2 * Copyright 2018 Google, Inc.
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.
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.
30 #ifndef __SYSTEMC_EXT_CORE_SC_EVENT_HH__
31 #define __SYSTEMC_EXT_CORE_SC_EVENT_HH__
44 class SensitivityEventAndList;
45 class SensitivityEventOrList;
53 class sc_event_and_expr;
54 class sc_event_or_expr;
62 virtual ~sc_event_finder() {}
65 // Should be "implementation defined" but used in the tests.
66 virtual const sc_event &find_event(sc_interface *if_p=NULL) const = 0;
70 class sc_event_finder_t : public sc_event_finder
73 sc_event_finder_t(const sc_port_base &p,
74 const sc_event & (IF::*_method)() const) :
77 _port = dynamic_cast<const sc_port_b<IF> *>(&p);
81 virtual ~sc_event_finder_t() {}
84 find_event(sc_interface *if_p=NULL) const override
86 const IF *iface = if_p ? dynamic_cast<const IF *>(if_p) :
87 dynamic_cast<const IF *>(_port->get_interface());
88 return (const_cast<IF *>(iface)->*_method)();
92 const sc_port_b<IF> *_port;
93 const sc_event &(IF::*_method)() const;
96 class sc_event_and_list
100 sc_event_and_list(const sc_event_and_list &);
101 sc_event_and_list(const sc_event &);
102 sc_event_and_list &operator = (const sc_event_and_list &);
103 ~sc_event_and_list();
106 void swap(sc_event_and_list &);
108 sc_event_and_list &operator &= (const sc_event &);
109 sc_event_and_list &operator &= (const sc_event_and_list &);
111 sc_event_and_expr operator & (const sc_event &) const;
112 sc_event_and_expr operator & (const sc_event_and_list &);
115 friend class sc_event_and_expr;
116 friend class sc_gem5::SensitivityEventAndList;
118 explicit sc_event_and_list(bool auto_delete);
120 void insert(sc_event const &e);
121 void insert(sc_event_and_list const &eal);
123 std::set<const sc_event *> events;
125 mutable unsigned busy;
128 class sc_event_or_list
132 sc_event_or_list(const sc_event_or_list &);
133 sc_event_or_list(const sc_event &);
134 sc_event_or_list& operator = (const sc_event_or_list &);
138 void swap(sc_event_or_list &);
140 sc_event_or_list &operator |= (const sc_event &);
141 sc_event_or_list &operator |= (const sc_event_or_list &);
143 sc_event_or_expr operator | (const sc_event &) const;
144 sc_event_or_expr operator | (const sc_event_or_list &) const;
147 friend class sc_event_or_expr;
148 friend class sc_gem5::SensitivityEventOrList;
150 explicit sc_event_or_list(bool auto_delete);
152 void insert(sc_event const &e);
153 void insert(sc_event_or_list const &eol);
155 std::set<const sc_event *> events;
157 mutable unsigned busy;
160 class sc_event_and_expr
163 sc_event_and_expr(sc_event_and_expr const &e);
164 operator const sc_event_and_list &() const;
166 void insert(sc_event const &e) const;
167 void insert(sc_event_and_list const &eal) const;
169 ~sc_event_and_expr();
172 friend class sc_event_and_list;
173 friend class sc_event;
176 mutable sc_event_and_list *list;
179 sc_event_and_expr operator & (sc_event_and_expr, sc_event const &);
180 sc_event_and_expr operator & (sc_event_and_expr, sc_event_and_list const &);
182 class sc_event_or_expr
185 sc_event_or_expr(sc_event_or_expr const &e);
186 operator const sc_event_or_list &() const;
188 void insert(sc_event const &e) const;
189 void insert(sc_event_or_list const &eol) const;
194 friend class sc_event_or_list;
195 friend class sc_event;
198 mutable sc_event_or_list *list;
201 sc_event_or_expr operator | (sc_event_or_expr, sc_event const &);
202 sc_event_or_expr operator | (sc_event_or_expr, sc_event_or_list const &);
208 explicit sc_event(const char *);
211 const char *name() const;
212 const char *basename() const;
213 bool in_hierarchy() const;
214 sc_object *get_parent_object() const;
217 void notify(const sc_time &);
218 void notify(double, sc_time_unit);
222 // Returns whether this event is currently triggered.
223 bool triggered() const;
226 void notify_delayed();
227 void notify_delayed(const sc_time &);
229 sc_event_and_expr operator & (const sc_event &) const;
230 sc_event_and_expr operator & (const sc_event_and_list &) const;
231 sc_event_or_expr operator | (const sc_event &) const;
232 sc_event_or_expr operator | (const sc_event_or_list &) const;
236 sc_event(const sc_event &) {}
237 sc_event &operator = (const sc_event &) { return *this; }
239 friend class ::sc_gem5::Event;
240 ::sc_gem5::Event *_gem5_event;
243 const std::vector<sc_event *> &sc_get_top_level_events();
244 sc_event *sc_find_event(const char *);
246 } // namespace sc_core
248 #endif //__SYSTEMC_EXT_CORE_SC_INTERFACE_HH__