event.hh revision 13206
112047Schristian.menard@tu-dresden.de/*
212047Schristian.menard@tu-dresden.de * Copyright 2018 Google, Inc.
312047Schristian.menard@tu-dresden.de *
412047Schristian.menard@tu-dresden.de * Redistribution and use in source and binary forms, with or without
512047Schristian.menard@tu-dresden.de * modification, are permitted provided that the following conditions are
612047Schristian.menard@tu-dresden.de * met: redistributions of source code must retain the above copyright
712047Schristian.menard@tu-dresden.de * notice, this list of conditions and the following disclaimer;
812047Schristian.menard@tu-dresden.de * redistributions in binary form must reproduce the above copyright
912047Schristian.menard@tu-dresden.de * notice, this list of conditions and the following disclaimer in the
1012047Schristian.menard@tu-dresden.de * documentation and/or other materials provided with the distribution;
1112047Schristian.menard@tu-dresden.de * neither the name of the copyright holders nor the names of its
1212047Schristian.menard@tu-dresden.de * contributors may be used to endorse or promote products derived from
1312047Schristian.menard@tu-dresden.de * this software without specific prior written permission.
1412047Schristian.menard@tu-dresden.de *
1512047Schristian.menard@tu-dresden.de * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1612047Schristian.menard@tu-dresden.de * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1712047Schristian.menard@tu-dresden.de * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1812047Schristian.menard@tu-dresden.de * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1912047Schristian.menard@tu-dresden.de * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2012047Schristian.menard@tu-dresden.de * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2112047Schristian.menard@tu-dresden.de * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2212047Schristian.menard@tu-dresden.de * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2312047Schristian.menard@tu-dresden.de * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2412047Schristian.menard@tu-dresden.de * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2512047Schristian.menard@tu-dresden.de * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2612047Schristian.menard@tu-dresden.de *
2712047Schristian.menard@tu-dresden.de * Authors: Gabe Black
2812047Schristian.menard@tu-dresden.de */
2912047Schristian.menard@tu-dresden.de
3012047Schristian.menard@tu-dresden.de#ifndef __SYSTEMC_CORE_EVENT_HH__
3112047Schristian.menard@tu-dresden.de#define __SYSTEMC_CORE_EVENT_HH__
3212047Schristian.menard@tu-dresden.de
3312047Schristian.menard@tu-dresden.de#include <list>
3412047Schristian.menard@tu-dresden.de#include <string>
3512047Schristian.menard@tu-dresden.de#include <vector>
3612047Schristian.menard@tu-dresden.de
3712047Schristian.menard@tu-dresden.de#include "sim/eventq.hh"
3812047Schristian.menard@tu-dresden.de#include "systemc/core/list.hh"
3912047Schristian.menard@tu-dresden.de#include "systemc/core/object.hh"
4012047Schristian.menard@tu-dresden.de#include "systemc/core/process.hh"
4112047Schristian.menard@tu-dresden.de#include "systemc/core/sched_event.hh"
4212047Schristian.menard@tu-dresden.de#include "systemc/core/sensitivity.hh"
4312047Schristian.menard@tu-dresden.de#include "systemc/ext/core/sc_prim.hh"
4412047Schristian.menard@tu-dresden.de#include "systemc/ext/core/sc_time.hh"
4512047Schristian.menard@tu-dresden.de
4612047Schristian.menard@tu-dresden.denamespace sc_core
4712047Schristian.menard@tu-dresden.de{
4812047Schristian.menard@tu-dresden.de
4912047Schristian.menard@tu-dresden.declass sc_event;
5012047Schristian.menard@tu-dresden.de
5112047Schristian.menard@tu-dresden.de} // namespace sc_core
5212047Schristian.menard@tu-dresden.de
5312047Schristian.menard@tu-dresden.denamespace sc_gem5
5412047Schristian.menard@tu-dresden.de{
5512047Schristian.menard@tu-dresden.de
5612047Schristian.menard@tu-dresden.detypedef std::vector<sc_core::sc_event *> Events;
5712047Schristian.menard@tu-dresden.de
5812047Schristian.menard@tu-dresden.declass Sensitivity;
5912047Schristian.menard@tu-dresden.de
6012047Schristian.menard@tu-dresden.declass Event
6112047Schristian.menard@tu-dresden.de{
6212047Schristian.menard@tu-dresden.de  public:
6312047Schristian.menard@tu-dresden.de    Event(sc_core::sc_event *_sc_event);
6412047Schristian.menard@tu-dresden.de    Event(sc_core::sc_event *_sc_event, const char *_basename);
6512047Schristian.menard@tu-dresden.de
6612047Schristian.menard@tu-dresden.de    ~Event();
6712047Schristian.menard@tu-dresden.de
6812047Schristian.menard@tu-dresden.de    sc_core::sc_event *sc_event() { return _sc_event; }
6912047Schristian.menard@tu-dresden.de
7012047Schristian.menard@tu-dresden.de    const std::string &name() const;
7112047Schristian.menard@tu-dresden.de    const std::string &basename() const;
7212047Schristian.menard@tu-dresden.de    bool inHierarchy() const;
7312047Schristian.menard@tu-dresden.de    sc_core::sc_object *getParentObject() const;
7412047Schristian.menard@tu-dresden.de
7512047Schristian.menard@tu-dresden.de    void notify();
7612047Schristian.menard@tu-dresden.de    void notify(const sc_core::sc_time &t);
7712047Schristian.menard@tu-dresden.de    void
7812047Schristian.menard@tu-dresden.de    notify(double d, sc_core::sc_time_unit &u)
7912047Schristian.menard@tu-dresden.de    {
8012047Schristian.menard@tu-dresden.de        notify(sc_core::sc_time(d, u));
8112047Schristian.menard@tu-dresden.de    }
8212047Schristian.menard@tu-dresden.de    void cancel();
8312047Schristian.menard@tu-dresden.de
8412047Schristian.menard@tu-dresden.de    bool triggered() const;
8512047Schristian.menard@tu-dresden.de
8612047Schristian.menard@tu-dresden.de    static Event *
8712047Schristian.menard@tu-dresden.de    getFromScEvent(sc_core::sc_event *e)
8812047Schristian.menard@tu-dresden.de    {
8912183Sjungma@eit.uni-kl.de        return e->_gem5_event;
9012183Sjungma@eit.uni-kl.de    }
9112047Schristian.menard@tu-dresden.de
9212047Schristian.menard@tu-dresden.de    static const Event *
9312047Schristian.menard@tu-dresden.de    getFromScEvent(const sc_core::sc_event *e)
9412047Schristian.menard@tu-dresden.de    {
9512047Schristian.menard@tu-dresden.de        return e->_gem5_event;
9612047Schristian.menard@tu-dresden.de    }
9712047Schristian.menard@tu-dresden.de
9812047Schristian.menard@tu-dresden.de    void
9912047Schristian.menard@tu-dresden.de    addSensitivity(StaticSensitivity *s) const
10012047Schristian.menard@tu-dresden.de    {
10112047Schristian.menard@tu-dresden.de        // Insert static sensitivities in reverse order to match Accellera's
10212047Schristian.menard@tu-dresden.de        // implementation.
10312047Schristian.menard@tu-dresden.de        staticSensitivities.insert(staticSensitivities.begin(), s);
10412047Schristian.menard@tu-dresden.de    }
10512047Schristian.menard@tu-dresden.de    void
10612047Schristian.menard@tu-dresden.de    delSensitivity(StaticSensitivity *s) const
10712047Schristian.menard@tu-dresden.de    {
10812047Schristian.menard@tu-dresden.de        for (auto &t: staticSensitivities) {
10912047Schristian.menard@tu-dresden.de            if (t == s) {
11012047Schristian.menard@tu-dresden.de                t = staticSensitivities.back();
11112047Schristian.menard@tu-dresden.de                staticSensitivities.pop_back();
11212047Schristian.menard@tu-dresden.de                break;
11312047Schristian.menard@tu-dresden.de            }
11412047Schristian.menard@tu-dresden.de        }
11512047Schristian.menard@tu-dresden.de    }
11612047Schristian.menard@tu-dresden.de    void
11712047Schristian.menard@tu-dresden.de    addSensitivity(DynamicSensitivity *s) const
11812047Schristian.menard@tu-dresden.de    {
11912047Schristian.menard@tu-dresden.de        dynamicSensitivities.push_back(s);
12012047Schristian.menard@tu-dresden.de    }
12112047Schristian.menard@tu-dresden.de    void
12212047Schristian.menard@tu-dresden.de    delSensitivity(DynamicSensitivity *s) const
12312047Schristian.menard@tu-dresden.de    {
12412047Schristian.menard@tu-dresden.de        for (auto &t: dynamicSensitivities) {
12512047Schristian.menard@tu-dresden.de            if (t == s) {
12612047Schristian.menard@tu-dresden.de                t = dynamicSensitivities.back();
12712047Schristian.menard@tu-dresden.de                dynamicSensitivities.pop_back();
12812047Schristian.menard@tu-dresden.de                break;
12912047Schristian.menard@tu-dresden.de            }
13012047Schristian.menard@tu-dresden.de        }
13112047Schristian.menard@tu-dresden.de    }
13212047Schristian.menard@tu-dresden.de
13312047Schristian.menard@tu-dresden.de  private:
13412047Schristian.menard@tu-dresden.de    sc_core::sc_event *_sc_event;
13512047Schristian.menard@tu-dresden.de
13612047Schristian.menard@tu-dresden.de    std::string _basename;
13712047Schristian.menard@tu-dresden.de    std::string _name;
13812047Schristian.menard@tu-dresden.de    bool _inHierarchy;
13912047Schristian.menard@tu-dresden.de
14012047Schristian.menard@tu-dresden.de    sc_core::sc_object *parent;
14112047Schristian.menard@tu-dresden.de
14212047Schristian.menard@tu-dresden.de    ScEvent delayedNotify;
14312047Schristian.menard@tu-dresden.de
14412047Schristian.menard@tu-dresden.de    mutable StaticSensitivities staticSensitivities;
14512047Schristian.menard@tu-dresden.de    mutable DynamicSensitivities dynamicSensitivities;
14612047Schristian.menard@tu-dresden.de};
14712047Schristian.menard@tu-dresden.de
14812047Schristian.menard@tu-dresden.deextern Events topLevelEvents;
14912047Schristian.menard@tu-dresden.deextern Events allEvents;
15012047Schristian.menard@tu-dresden.de
15112047Schristian.menard@tu-dresden.deEventsIt findEvent(const std::string &name);
15212047Schristian.menard@tu-dresden.de
15312047Schristian.menard@tu-dresden.de} // namespace sc_gem5
15412047Schristian.menard@tu-dresden.de
15512047Schristian.menard@tu-dresden.de#endif  //__SYSTEMC_CORE_EVENT_HH__
15612047Schristian.menard@tu-dresden.de