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__
42 class SensitivityEventAndList;
43 class SensitivityEventOrList;
51 class sc_event_and_expr;
52 class sc_event_or_expr;
60 void warn_unimpl(const char *func) const;
63 // Should be "implementation defined" but used in the tests.
64 virtual const sc_event &find_event(sc_interface *if_p=NULL) const = 0;
68 class sc_event_finder_t : public sc_event_finder
71 sc_event_finder_t(const sc_port_base &,
72 const sc_event & (IF::*event_method)() const)
74 warn_unimpl(__PRETTY_FUNCTION__);
78 find_event(sc_interface *if_p=NULL) const override
80 warn_unimpl(__PRETTY_FUNCTION__);
81 return *(const sc_event *)nullptr;
85 class sc_event_and_list
89 sc_event_and_list(const sc_event_and_list &);
90 sc_event_and_list(const sc_event &);
91 sc_event_and_list &operator = (const sc_event_and_list &);
95 void swap(sc_event_and_list &);
97 sc_event_and_list &operator &= (const sc_event &);
98 sc_event_and_list &operator &= (const sc_event_and_list &);
100 sc_event_and_expr operator & (const sc_event &) const;
101 sc_event_and_expr operator & (const sc_event_and_list &);
104 friend class sc_event_and_expr;
105 friend class sc_gem5::SensitivityEventAndList;
107 explicit sc_event_and_list(bool auto_delete);
109 void insert(sc_event const &e);
110 void insert(sc_event_and_list const &eal);
112 std::set<const sc_event *> events;
114 mutable unsigned busy;
117 class sc_event_or_list
121 sc_event_or_list(const sc_event_or_list &);
122 sc_event_or_list(const sc_event &);
123 sc_event_or_list& operator = (const sc_event_or_list &);
127 void swap(sc_event_or_list &);
129 sc_event_or_list &operator |= (const sc_event &);
130 sc_event_or_list &operator |= (const sc_event_or_list &);
132 sc_event_or_expr operator | (const sc_event &) const;
133 sc_event_or_expr operator | (const sc_event_or_list &) const;
136 friend class sc_event_or_expr;
137 friend class sc_gem5::SensitivityEventOrList;
139 explicit sc_event_or_list(bool auto_delete);
141 void insert(sc_event const &e);
142 void insert(sc_event_or_list const &eol);
144 std::set<const sc_event *> events;
146 mutable unsigned busy;
149 class sc_event_and_expr
152 sc_event_and_expr(sc_event_and_expr const &e);
153 operator const sc_event_and_list &() const;
155 void insert(sc_event const &e) const;
156 void insert(sc_event_and_list const &eal) const;
158 ~sc_event_and_expr();
161 friend class sc_event_and_list;
162 friend class sc_event;
165 mutable sc_event_and_list *list;
168 sc_event_and_expr operator & (sc_event_and_expr, sc_event const &);
169 sc_event_and_expr operator & (sc_event_and_expr, sc_event_and_list const &);
171 class sc_event_or_expr
174 sc_event_or_expr(sc_event_or_expr const &e);
175 operator const sc_event_or_list &() const;
177 void insert(sc_event const &e) const;
178 void insert(sc_event_or_list const &eol) const;
183 friend class sc_event_or_list;
184 friend class sc_event;
187 mutable sc_event_or_list *list;
190 sc_event_or_expr operator | (sc_event_or_expr, sc_event const &);
191 sc_event_or_expr operator | (sc_event_or_expr, sc_event_or_list const &);
197 explicit sc_event(const char *);
200 const char *name() const;
201 const char *basename() const;
202 bool in_hierarchy() const;
203 sc_object *get_parent_object() const;
206 void notify(const sc_time &);
207 void notify(double, sc_time_unit);
211 // Returns whether this event is currently triggered.
212 bool triggered() const;
215 void notify_delayed();
216 void notify_delayed(const sc_time &);
218 sc_event_and_expr operator & (const sc_event &) const;
219 sc_event_and_expr operator & (const sc_event_and_list &) const;
220 sc_event_or_expr operator | (const sc_event &) const;
221 sc_event_or_expr operator | (const sc_event_or_list &) const;
225 sc_event(const sc_event &) {}
226 sc_event &operator = (const sc_event &) { return *this; }
228 friend class ::sc_gem5::Event;
229 ::sc_gem5::Event *_gem5_event;
232 const std::vector<sc_event *> &sc_get_top_level_events();
233 sc_event *sc_find_event(const char *);
235 } // namespace sc_core
237 #endif //__SYSTEMC_EXT_CORE_SC_INTERFACE_HH__