event.hh revision 13063
12SN/A/*
29955SGeoffrey.Blake@arm.com * Copyright 2018 Google, Inc.
39955SGeoffrey.Blake@arm.com *
49955SGeoffrey.Blake@arm.com * Redistribution and use in source and binary forms, with or without
59955SGeoffrey.Blake@arm.com * modification, are permitted provided that the following conditions are
69955SGeoffrey.Blake@arm.com * met: redistributions of source code must retain the above copyright
79955SGeoffrey.Blake@arm.com * notice, this list of conditions and the following disclaimer;
89955SGeoffrey.Blake@arm.com * redistributions in binary form must reproduce the above copyright
99955SGeoffrey.Blake@arm.com * notice, this list of conditions and the following disclaimer in the
109955SGeoffrey.Blake@arm.com * documentation and/or other materials provided with the distribution;
119955SGeoffrey.Blake@arm.com * neither the name of the copyright holders nor the names of its
129955SGeoffrey.Blake@arm.com * contributors may be used to endorse or promote products derived from
139955SGeoffrey.Blake@arm.com * this software without specific prior written permission.
141762SN/A *
157778Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
162SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
172SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
182SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
192SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
202SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
212SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
222SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
232SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
242SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
252SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
262SN/A *
272SN/A * Authors: Gabe Black
282SN/A */
292SN/A
302SN/A#ifndef __SYSTEMC_CORE_EVENT_HH__
312SN/A#define __SYSTEMC_CORE_EVENT_HH__
322SN/A
332SN/A#include <set>
342SN/A#include <string>
352SN/A#include <vector>
362SN/A
372SN/A#include "sim/eventq.hh"
382SN/A#include "systemc/core/list.hh"
392SN/A#include "systemc/core/object.hh"
402665Ssaidi@eecs.umich.edu#include "systemc/core/sched_event.hh"
412665Ssaidi@eecs.umich.edu#include "systemc/ext/core/sc_prim.hh"
422665Ssaidi@eecs.umich.edu#include "systemc/ext/core/sc_time.hh"
437778Sgblack@eecs.umich.edu
449955SGeoffrey.Blake@arm.comnamespace sc_core
452SN/A{
462SN/A
471078SN/Aclass sc_event;
481078SN/A
491078SN/A} // namespace sc_core
501114SN/A
511078SN/Anamespace sc_gem5
521114SN/A{
531114SN/A
541114SN/Atypedef std::vector<sc_core::sc_event *> Events;
556216Snate@binkert.org
561114SN/Aclass Sensitivity;
571078SN/A
581078SN/Aclass Event
591078SN/A{
601078SN/A  public:
611078SN/A    Event(sc_core::sc_event *_sc_event);
621078SN/A    Event(sc_core::sc_event *_sc_event, const char *_basename);
631078SN/A
641078SN/A    ~Event();
651078SN/A
661078SN/A    sc_core::sc_event *sc_event() { return _sc_event; }
671078SN/A
681078SN/A    const std::string &name() const;
691078SN/A    const std::string &basename() const;
701078SN/A    bool inHierarchy() const;
712SN/A    sc_core::sc_object *getParentObject() const;
721114SN/A
732SN/A    void notify();
741114SN/A    void notify(const sc_core::sc_time &t);
751114SN/A    void
761114SN/A    notify(double d, sc_core::sc_time_unit &u)
771114SN/A    {
781114SN/A        notify(sc_core::sc_time(d, u));
791114SN/A    }
801114SN/A    void cancel();
811078SN/A
821114SN/A    bool triggered() const;
831114SN/A
841114SN/A    static Event *
851114SN/A    getFromScEvent(sc_core::sc_event *e)
861114SN/A    {
871114SN/A        return e->_gem5_event;
881114SN/A    }
891079SN/A
901114SN/A    static const Event *
911114SN/A    getFromScEvent(const sc_core::sc_event *e)
921114SN/A    {
931114SN/A        return e->_gem5_event;
941114SN/A    }
951114SN/A
9610251Satgutier@umich.edu    void addSensitivity(Sensitivity *s) const { sensitivities.insert(s); }
9710251Satgutier@umich.edu    void delSensitivity(Sensitivity *s) const { sensitivities.erase(s); }
9810251Satgutier@umich.edu
9910251Satgutier@umich.edu  private:
10010251Satgutier@umich.edu    sc_core::sc_event *_sc_event;
10110251Satgutier@umich.edu
10210251Satgutier@umich.edu    std::string _basename;
10310251Satgutier@umich.edu    std::string _name;
10410251Satgutier@umich.edu    bool _inHierarchy;
10510251Satgutier@umich.edu
10610251Satgutier@umich.edu    sc_core::sc_object *parent;
10710251Satgutier@umich.edu
1081114SN/A    ScEvent delayedNotify;
1091137SN/A
1101137SN/A    mutable std::set<Sensitivity *> sensitivities;
1111137SN/A};
1121137SN/A
1131137SN/Aextern Events topLevelEvents;
1141137SN/Aextern Events allEvents;
1151137SN/A
1161137SN/AEventsIt findEvent(const std::string &name);
1171137SN/A
1181137SN/A} // namespace sc_gem5
1191137SN/A
1201137SN/A#endif  //__SYSTEMC_CORE_EVENT_HH__
1211137SN/A