event.hh revision 13063
112955Sgabeblack@google.com/* 212955Sgabeblack@google.com * Copyright 2018 Google, Inc. 312955Sgabeblack@google.com * 412955Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 512955Sgabeblack@google.com * modification, are permitted provided that the following conditions are 612955Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 712955Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 812955Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 912955Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 1012955Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 1112955Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 1212955Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 1312955Sgabeblack@google.com * this software without specific prior written permission. 1412955Sgabeblack@google.com * 1512955Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1612955Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1712955Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1812955Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1912955Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2012955Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2112955Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2212955Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2312955Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2412955Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2512955Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2612955Sgabeblack@google.com * 2712955Sgabeblack@google.com * Authors: Gabe Black 2812955Sgabeblack@google.com */ 2912955Sgabeblack@google.com 3012955Sgabeblack@google.com#ifndef __SYSTEMC_CORE_EVENT_HH__ 3112955Sgabeblack@google.com#define __SYSTEMC_CORE_EVENT_HH__ 3212955Sgabeblack@google.com 3312957Sgabeblack@google.com#include <set> 3412955Sgabeblack@google.com#include <string> 3512955Sgabeblack@google.com#include <vector> 3612955Sgabeblack@google.com 3712957Sgabeblack@google.com#include "sim/eventq.hh" 3812955Sgabeblack@google.com#include "systemc/core/list.hh" 3912955Sgabeblack@google.com#include "systemc/core/object.hh" 4013063Sgabeblack@google.com#include "systemc/core/sched_event.hh" 4112955Sgabeblack@google.com#include "systemc/ext/core/sc_prim.hh" 4212955Sgabeblack@google.com#include "systemc/ext/core/sc_time.hh" 4312955Sgabeblack@google.com 4412955Sgabeblack@google.comnamespace sc_core 4512955Sgabeblack@google.com{ 4612955Sgabeblack@google.com 4712955Sgabeblack@google.comclass sc_event; 4812955Sgabeblack@google.com 4912955Sgabeblack@google.com} // namespace sc_core 5012955Sgabeblack@google.com 5112955Sgabeblack@google.comnamespace sc_gem5 5212955Sgabeblack@google.com{ 5312955Sgabeblack@google.com 5412955Sgabeblack@google.comtypedef std::vector<sc_core::sc_event *> Events; 5512955Sgabeblack@google.com 5612957Sgabeblack@google.comclass Sensitivity; 5712957Sgabeblack@google.com 5812955Sgabeblack@google.comclass Event 5912955Sgabeblack@google.com{ 6012955Sgabeblack@google.com public: 6112955Sgabeblack@google.com Event(sc_core::sc_event *_sc_event); 6212955Sgabeblack@google.com Event(sc_core::sc_event *_sc_event, const char *_basename); 6312955Sgabeblack@google.com 6412955Sgabeblack@google.com ~Event(); 6512955Sgabeblack@google.com 6612955Sgabeblack@google.com sc_core::sc_event *sc_event() { return _sc_event; } 6712955Sgabeblack@google.com 6812955Sgabeblack@google.com const std::string &name() const; 6912955Sgabeblack@google.com const std::string &basename() const; 7012955Sgabeblack@google.com bool inHierarchy() const; 7112955Sgabeblack@google.com sc_core::sc_object *getParentObject() const; 7212955Sgabeblack@google.com 7312955Sgabeblack@google.com void notify(); 7412955Sgabeblack@google.com void notify(const sc_core::sc_time &t); 7512955Sgabeblack@google.com void 7612955Sgabeblack@google.com notify(double d, sc_core::sc_time_unit &u) 7712955Sgabeblack@google.com { 7812955Sgabeblack@google.com notify(sc_core::sc_time(d, u)); 7912955Sgabeblack@google.com } 8012955Sgabeblack@google.com void cancel(); 8112955Sgabeblack@google.com 8212955Sgabeblack@google.com bool triggered() const; 8312955Sgabeblack@google.com 8412955Sgabeblack@google.com static Event * 8512955Sgabeblack@google.com getFromScEvent(sc_core::sc_event *e) 8612955Sgabeblack@google.com { 8712955Sgabeblack@google.com return e->_gem5_event; 8812955Sgabeblack@google.com } 8912955Sgabeblack@google.com 9012955Sgabeblack@google.com static const Event * 9112955Sgabeblack@google.com getFromScEvent(const sc_core::sc_event *e) 9212955Sgabeblack@google.com { 9312955Sgabeblack@google.com return e->_gem5_event; 9412955Sgabeblack@google.com } 9512955Sgabeblack@google.com 9612957Sgabeblack@google.com void addSensitivity(Sensitivity *s) const { sensitivities.insert(s); } 9712957Sgabeblack@google.com void delSensitivity(Sensitivity *s) const { sensitivities.erase(s); } 9812957Sgabeblack@google.com 9912955Sgabeblack@google.com private: 10012955Sgabeblack@google.com sc_core::sc_event *_sc_event; 10112955Sgabeblack@google.com 10212955Sgabeblack@google.com std::string _basename; 10312955Sgabeblack@google.com std::string _name; 10412955Sgabeblack@google.com bool _inHierarchy; 10512955Sgabeblack@google.com 10612955Sgabeblack@google.com sc_core::sc_object *parent; 10712957Sgabeblack@google.com 10813063Sgabeblack@google.com ScEvent delayedNotify; 10912957Sgabeblack@google.com 11012957Sgabeblack@google.com mutable std::set<Sensitivity *> sensitivities; 11112955Sgabeblack@google.com}; 11212955Sgabeblack@google.com 11312955Sgabeblack@google.comextern Events topLevelEvents; 11412955Sgabeblack@google.comextern Events allEvents; 11512955Sgabeblack@google.com 11612955Sgabeblack@google.comEventsIt findEvent(const std::string &name); 11712955Sgabeblack@google.com 11812955Sgabeblack@google.com} // namespace sc_gem5 11912955Sgabeblack@google.com 12012955Sgabeblack@google.com#endif //__SYSTEMC_CORE_EVENT_HH__ 121