event.hh revision 12955
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
3312955Sgabeblack@google.com#include <string>
3412955Sgabeblack@google.com#include <vector>
3512955Sgabeblack@google.com
3612955Sgabeblack@google.com#include "systemc/core/list.hh"
3712955Sgabeblack@google.com#include "systemc/core/object.hh"
3812955Sgabeblack@google.com#include "systemc/ext/core/sc_prim.hh"
3912955Sgabeblack@google.com#include "systemc/ext/core/sc_time.hh"
4012955Sgabeblack@google.com
4112955Sgabeblack@google.comnamespace sc_core
4212955Sgabeblack@google.com{
4312955Sgabeblack@google.com
4412955Sgabeblack@google.comclass sc_event;
4512955Sgabeblack@google.com
4612955Sgabeblack@google.com} // namespace sc_core
4712955Sgabeblack@google.com
4812955Sgabeblack@google.comnamespace sc_gem5
4912955Sgabeblack@google.com{
5012955Sgabeblack@google.com
5112955Sgabeblack@google.comtypedef std::vector<sc_core::sc_event *> Events;
5212955Sgabeblack@google.com
5312955Sgabeblack@google.comclass Event
5412955Sgabeblack@google.com{
5512955Sgabeblack@google.com  public:
5612955Sgabeblack@google.com    Event(sc_core::sc_event *_sc_event);
5712955Sgabeblack@google.com    Event(sc_core::sc_event *_sc_event, const char *_basename);
5812955Sgabeblack@google.com
5912955Sgabeblack@google.com    ~Event();
6012955Sgabeblack@google.com
6112955Sgabeblack@google.com    sc_core::sc_event *sc_event() { return _sc_event; }
6212955Sgabeblack@google.com
6312955Sgabeblack@google.com    const std::string &name() const;
6412955Sgabeblack@google.com    const std::string &basename() const;
6512955Sgabeblack@google.com    bool inHierarchy() const;
6612955Sgabeblack@google.com    sc_core::sc_object *getParentObject() const;
6712955Sgabeblack@google.com
6812955Sgabeblack@google.com    void notify();
6912955Sgabeblack@google.com    void notify(const sc_core::sc_time &t);
7012955Sgabeblack@google.com    void
7112955Sgabeblack@google.com    notify(double d, sc_core::sc_time_unit &u)
7212955Sgabeblack@google.com    {
7312955Sgabeblack@google.com        notify(sc_core::sc_time(d, u));
7412955Sgabeblack@google.com    }
7512955Sgabeblack@google.com    void cancel();
7612955Sgabeblack@google.com
7712955Sgabeblack@google.com    bool triggered() const;
7812955Sgabeblack@google.com
7912955Sgabeblack@google.com    static Event *
8012955Sgabeblack@google.com    getFromScEvent(sc_core::sc_event *e)
8112955Sgabeblack@google.com    {
8212955Sgabeblack@google.com        return e->_gem5_event;
8312955Sgabeblack@google.com    }
8412955Sgabeblack@google.com
8512955Sgabeblack@google.com    static const Event *
8612955Sgabeblack@google.com    getFromScEvent(const sc_core::sc_event *e)
8712955Sgabeblack@google.com    {
8812955Sgabeblack@google.com        return e->_gem5_event;
8912955Sgabeblack@google.com    }
9012955Sgabeblack@google.com
9112955Sgabeblack@google.com  private:
9212955Sgabeblack@google.com    sc_core::sc_event *_sc_event;
9312955Sgabeblack@google.com
9412955Sgabeblack@google.com    std::string _basename;
9512955Sgabeblack@google.com    std::string _name;
9612955Sgabeblack@google.com    bool _inHierarchy;
9712955Sgabeblack@google.com
9812955Sgabeblack@google.com    sc_core::sc_object *parent;
9912955Sgabeblack@google.com    EventsIt parentIt;
10012955Sgabeblack@google.com};
10112955Sgabeblack@google.com
10212955Sgabeblack@google.comextern Events topLevelEvents;
10312955Sgabeblack@google.comextern Events allEvents;
10412955Sgabeblack@google.com
10512955Sgabeblack@google.comEventsIt findEvent(const std::string &name);
10612955Sgabeblack@google.com
10712955Sgabeblack@google.com} // namespace sc_gem5
10812955Sgabeblack@google.com
10912955Sgabeblack@google.com#endif  //__SYSTEMC_CORE_EVENT_HH__
110