sc_event.hh revision 12955
112837Sgabeblack@google.com/* 212837Sgabeblack@google.com * Copyright 2018 Google, Inc. 312837Sgabeblack@google.com * 412837Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 512837Sgabeblack@google.com * modification, are permitted provided that the following conditions are 612837Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 712837Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 812837Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 912837Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 1012837Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 1112837Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 1212837Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 1312837Sgabeblack@google.com * this software without specific prior written permission. 1412837Sgabeblack@google.com * 1512837Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1612837Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1712837Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1812837Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1912837Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2012837Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2112837Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2212837Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2312837Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2412837Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2512837Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2612837Sgabeblack@google.com * 2712837Sgabeblack@google.com * Authors: Gabe Black 2812837Sgabeblack@google.com */ 2912837Sgabeblack@google.com 3012837Sgabeblack@google.com#ifndef __SYSTEMC_EXT_CORE_SC_EVENT_HH__ 3112837Sgabeblack@google.com#define __SYSTEMC_EXT_CORE_SC_EVENT_HH__ 3212837Sgabeblack@google.com 3312955Sgabeblack@google.com#include <set> 3412837Sgabeblack@google.com#include <vector> 3512837Sgabeblack@google.com 3612837Sgabeblack@google.com#include "sc_time.hh" 3712837Sgabeblack@google.com 3812955Sgabeblack@google.comnamespace sc_gem5 3912955Sgabeblack@google.com{ 4012955Sgabeblack@google.com 4112955Sgabeblack@google.comclass Event; 4212955Sgabeblack@google.com 4312955Sgabeblack@google.com} 4412955Sgabeblack@google.com 4512837Sgabeblack@google.comnamespace sc_core 4612837Sgabeblack@google.com{ 4712837Sgabeblack@google.com 4812837Sgabeblack@google.comclass sc_event; 4912837Sgabeblack@google.comclass sc_event_and_expr; 5012837Sgabeblack@google.comclass sc_event_or_expr; 5112924Sgabeblack@google.comclass sc_interface; 5212837Sgabeblack@google.comclass sc_object; 5312837Sgabeblack@google.comclass sc_port_base; 5412837Sgabeblack@google.com 5512837Sgabeblack@google.comclass sc_event_finder 5612837Sgabeblack@google.com{ 5712837Sgabeblack@google.com protected: 5812837Sgabeblack@google.com void warn_unimpl(const char *func) const; 5912924Sgabeblack@google.com 6012924Sgabeblack@google.com public: 6112924Sgabeblack@google.com // Should be "implementation defined" but used in the tests. 6212924Sgabeblack@google.com virtual const sc_event &find_event(sc_interface *if_p=NULL) const = 0; 6312837Sgabeblack@google.com}; 6412837Sgabeblack@google.com 6512837Sgabeblack@google.comtemplate <class IF> 6612837Sgabeblack@google.comclass sc_event_finder_t : public sc_event_finder 6712837Sgabeblack@google.com{ 6812837Sgabeblack@google.com public: 6912837Sgabeblack@google.com sc_event_finder_t(const sc_port_base &, 7012837Sgabeblack@google.com const sc_event & (IF::*event_method)() const) 7112837Sgabeblack@google.com { 7212837Sgabeblack@google.com warn_unimpl(__PRETTY_FUNCTION__); 7312837Sgabeblack@google.com } 7412924Sgabeblack@google.com 7512924Sgabeblack@google.com const sc_event & 7612924Sgabeblack@google.com find_event(sc_interface *if_p=NULL) const override 7712924Sgabeblack@google.com { 7812924Sgabeblack@google.com warn_unimpl(__PRETTY_FUNCTION__); 7912924Sgabeblack@google.com return *(const sc_event *)nullptr; 8012924Sgabeblack@google.com } 8112837Sgabeblack@google.com}; 8212837Sgabeblack@google.com 8312837Sgabeblack@google.comclass sc_event_and_list 8412837Sgabeblack@google.com{ 8512837Sgabeblack@google.com public: 8612837Sgabeblack@google.com sc_event_and_list(); 8712837Sgabeblack@google.com sc_event_and_list(const sc_event_and_list &); 8812837Sgabeblack@google.com sc_event_and_list(const sc_event &); 8912837Sgabeblack@google.com sc_event_and_list &operator = (const sc_event_and_list &); 9012955Sgabeblack@google.com ~sc_event_and_list(); 9112837Sgabeblack@google.com 9212837Sgabeblack@google.com int size() const; 9312837Sgabeblack@google.com void swap(sc_event_and_list &); 9412837Sgabeblack@google.com 9512837Sgabeblack@google.com sc_event_and_list &operator &= (const sc_event &); 9612837Sgabeblack@google.com sc_event_and_list &operator &= (const sc_event_and_list &); 9712837Sgabeblack@google.com 9812837Sgabeblack@google.com sc_event_and_expr operator & (const sc_event &) const; 9912837Sgabeblack@google.com sc_event_and_expr operator & (const sc_event_and_list &); 10012955Sgabeblack@google.com 10112955Sgabeblack@google.com private: 10212955Sgabeblack@google.com friend class sc_event_and_expr; 10312955Sgabeblack@google.com 10412955Sgabeblack@google.com explicit sc_event_and_list(bool auto_delete); 10512955Sgabeblack@google.com 10612955Sgabeblack@google.com void insert(sc_event const &e); 10712955Sgabeblack@google.com void insert(sc_event_and_list const &eal); 10812955Sgabeblack@google.com 10912955Sgabeblack@google.com std::set<const sc_event *> events; 11012955Sgabeblack@google.com bool autoDelete; 11112955Sgabeblack@google.com mutable unsigned busy; 11212837Sgabeblack@google.com}; 11312837Sgabeblack@google.com 11412837Sgabeblack@google.comclass sc_event_or_list 11512837Sgabeblack@google.com{ 11612837Sgabeblack@google.com public: 11712837Sgabeblack@google.com sc_event_or_list(); 11812837Sgabeblack@google.com sc_event_or_list(const sc_event_or_list &); 11912837Sgabeblack@google.com sc_event_or_list(const sc_event &); 12012837Sgabeblack@google.com sc_event_or_list& operator = (const sc_event_or_list &); 12112837Sgabeblack@google.com ~sc_event_or_list(); 12212837Sgabeblack@google.com 12312837Sgabeblack@google.com int size() const; 12412837Sgabeblack@google.com void swap(sc_event_or_list &); 12512837Sgabeblack@google.com 12612837Sgabeblack@google.com sc_event_or_list &operator |= (const sc_event &); 12712837Sgabeblack@google.com sc_event_or_list &operator |= (const sc_event_or_list &); 12812837Sgabeblack@google.com 12912837Sgabeblack@google.com sc_event_or_expr operator | (const sc_event &) const; 13012837Sgabeblack@google.com sc_event_or_expr operator | (const sc_event_or_list &) const; 13112955Sgabeblack@google.com 13212955Sgabeblack@google.com private: 13312955Sgabeblack@google.com friend class sc_event_or_expr; 13412955Sgabeblack@google.com 13512955Sgabeblack@google.com explicit sc_event_or_list(bool auto_delete); 13612955Sgabeblack@google.com 13712955Sgabeblack@google.com void insert(sc_event const &e); 13812955Sgabeblack@google.com void insert(sc_event_or_list const &eol); 13912955Sgabeblack@google.com 14012955Sgabeblack@google.com std::set<const sc_event *> events; 14112955Sgabeblack@google.com bool autoDelete; 14212955Sgabeblack@google.com mutable unsigned busy; 14312837Sgabeblack@google.com}; 14412837Sgabeblack@google.com 14512837Sgabeblack@google.comclass sc_event_and_expr 14612837Sgabeblack@google.com{ 14712837Sgabeblack@google.com public: 14812955Sgabeblack@google.com sc_event_and_expr(sc_event_and_expr const &e); 14912837Sgabeblack@google.com operator const sc_event_and_list &() const; 15012955Sgabeblack@google.com 15112955Sgabeblack@google.com void insert(sc_event const &e) const; 15212955Sgabeblack@google.com void insert(sc_event_and_list const &eal) const; 15312955Sgabeblack@google.com 15412955Sgabeblack@google.com ~sc_event_and_expr(); 15512955Sgabeblack@google.com 15612955Sgabeblack@google.com private: 15712955Sgabeblack@google.com friend class sc_event_and_list; 15812955Sgabeblack@google.com friend class sc_event; 15912955Sgabeblack@google.com 16012955Sgabeblack@google.com sc_event_and_expr(); 16112955Sgabeblack@google.com mutable sc_event_and_list *list; 16212837Sgabeblack@google.com}; 16312837Sgabeblack@google.com 16412837Sgabeblack@google.comsc_event_and_expr operator & (sc_event_and_expr, sc_event const &); 16512837Sgabeblack@google.comsc_event_and_expr operator & (sc_event_and_expr, sc_event_and_list const &); 16612837Sgabeblack@google.com 16712837Sgabeblack@google.comclass sc_event_or_expr 16812837Sgabeblack@google.com{ 16912837Sgabeblack@google.com public: 17012955Sgabeblack@google.com sc_event_or_expr(sc_event_or_expr const &e); 17112837Sgabeblack@google.com operator const sc_event_or_list &() const; 17212955Sgabeblack@google.com 17312955Sgabeblack@google.com void insert(sc_event const &e) const; 17412955Sgabeblack@google.com void insert(sc_event_or_list const &eol) const; 17512955Sgabeblack@google.com 17612955Sgabeblack@google.com ~sc_event_or_expr(); 17712955Sgabeblack@google.com 17812955Sgabeblack@google.com private: 17912955Sgabeblack@google.com friend class sc_event_or_list; 18012955Sgabeblack@google.com friend class sc_event; 18112955Sgabeblack@google.com 18212955Sgabeblack@google.com sc_event_or_expr(); 18312955Sgabeblack@google.com mutable sc_event_or_list *list; 18412837Sgabeblack@google.com}; 18512837Sgabeblack@google.com 18612837Sgabeblack@google.comsc_event_or_expr operator | (sc_event_or_expr, sc_event const &); 18712837Sgabeblack@google.comsc_event_or_expr operator | (sc_event_or_expr, sc_event_or_list const &); 18812837Sgabeblack@google.com 18912837Sgabeblack@google.comclass sc_event 19012837Sgabeblack@google.com{ 19112837Sgabeblack@google.com public: 19212837Sgabeblack@google.com sc_event(); 19312837Sgabeblack@google.com explicit sc_event(const char *); 19412837Sgabeblack@google.com ~sc_event(); 19512837Sgabeblack@google.com 19612837Sgabeblack@google.com const char *name() const; 19712837Sgabeblack@google.com const char *basename() const; 19812837Sgabeblack@google.com bool in_hierarchy() const; 19912837Sgabeblack@google.com sc_object *get_parent_object() const; 20012837Sgabeblack@google.com 20112837Sgabeblack@google.com void notify(); 20212837Sgabeblack@google.com void notify(const sc_time &); 20312837Sgabeblack@google.com void notify(double, sc_time_unit); 20412837Sgabeblack@google.com void cancel(); 20512837Sgabeblack@google.com 20612900Sgabeblack@google.com // Nonstandard 20712900Sgabeblack@google.com // Returns whether this event is currently triggered. 20812900Sgabeblack@google.com bool triggered() const; 20912900Sgabeblack@google.com 21012915Sgabeblack@google.com // Deprecated 21112915Sgabeblack@google.com void notify_delayed(); 21212915Sgabeblack@google.com void notify_delayed(const sc_time &); 21312915Sgabeblack@google.com 21412837Sgabeblack@google.com sc_event_and_expr operator & (const sc_event &) const; 21512837Sgabeblack@google.com sc_event_and_expr operator & (const sc_event_and_list &) const; 21612837Sgabeblack@google.com sc_event_or_expr operator | (const sc_event &) const; 21712837Sgabeblack@google.com sc_event_or_expr operator | (const sc_event_or_list &) const; 21812837Sgabeblack@google.com 21912837Sgabeblack@google.com private: 22012837Sgabeblack@google.com // Disabled 22112837Sgabeblack@google.com sc_event(const sc_event &) {} 22212837Sgabeblack@google.com sc_event &operator = (const sc_event &) { return *this; } 22312955Sgabeblack@google.com 22412955Sgabeblack@google.com friend class ::sc_gem5::Event; 22512955Sgabeblack@google.com ::sc_gem5::Event *_gem5_event; 22612837Sgabeblack@google.com}; 22712837Sgabeblack@google.com 22812837Sgabeblack@google.comconst std::vector<sc_event *> &sc_get_top_level_events(); 22912837Sgabeblack@google.comsc_event *sc_find_event(const char *); 23012837Sgabeblack@google.com 23112837Sgabeblack@google.com} // namespace sc_core 23212837Sgabeblack@google.com 23312837Sgabeblack@google.com#endif //__SYSTEMC_EXT_CORE_SC_INTERFACE_HH__ 234