event.hh revision 12955
12SN/A/*
21762SN/A * Copyright 2018 Google, Inc.
32SN/A *
42SN/A * Redistribution and use in source and binary forms, with or without
52SN/A * modification, are permitted provided that the following conditions are
62SN/A * met: redistributions of source code must retain the above copyright
72SN/A * notice, this list of conditions and the following disclaimer;
82SN/A * redistributions in binary form must reproduce the above copyright
92SN/A * notice, this list of conditions and the following disclaimer in the
102SN/A * documentation and/or other materials provided with the distribution;
112SN/A * neither the name of the copyright holders nor the names of its
122SN/A * contributors may be used to endorse or promote products derived from
132SN/A * this software without specific prior written permission.
142SN/A *
152SN/A * 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 *
272665Ssaidi@eecs.umich.edu * Authors: Gabe Black
282665Ssaidi@eecs.umich.edu */
292665Ssaidi@eecs.umich.edu
302SN/A#ifndef __SYSTEMC_CORE_EVENT_HH__
312SN/A#define __SYSTEMC_CORE_EVENT_HH__
322SN/A
332SN/A#include <string>
342SN/A#include <vector>
352SN/A
361354SN/A#include "systemc/core/list.hh"
371354SN/A#include "systemc/core/object.hh"
382SN/A#include "systemc/ext/core/sc_prim.hh"
392SN/A#include "systemc/ext/core/sc_time.hh"
402SN/A
412SN/Anamespace sc_core
422SN/A{
432SN/A
442SN/Aclass sc_event;
452SN/A
4656SN/A} // namespace sc_core
472SN/A
4856SN/Anamespace sc_gem5
491354SN/A{
5056SN/A
512SN/Atypedef std::vector<sc_core::sc_event *> Events;
522SN/A
532SN/Aclass Event
541354SN/A{
551354SN/A  public:
561354SN/A    Event(sc_core::sc_event *_sc_event);
571354SN/A    Event(sc_core::sc_event *_sc_event, const char *_basename);
581354SN/A
591354SN/A    ~Event();
601354SN/A
611354SN/A    sc_core::sc_event *sc_event() { return _sc_event; }
621354SN/A
631354SN/A    const std::string &name() const;
641354SN/A    const std::string &basename() const;
651354SN/A    bool inHierarchy() const;
661354SN/A    sc_core::sc_object *getParentObject() const;
672SN/A
682SN/A    void notify();
692SN/A    void notify(const sc_core::sc_time &t);
702SN/A    void
712SN/A    notify(double d, sc_core::sc_time_unit &u)
72395SN/A    {
732SN/A        notify(sc_core::sc_time(d, u));
742SN/A    }
752SN/A    void cancel();
762SN/A
772SN/A    bool triggered() const;
782SN/A
792SN/A    static Event *
802SN/A    getFromScEvent(sc_core::sc_event *e)
812SN/A    {
822SN/A        return e->_gem5_event;
832SN/A    }
842SN/A
852SN/A    static const Event *
862SN/A    getFromScEvent(const sc_core::sc_event *e)
872SN/A    {
882SN/A        return e->_gem5_event;
892SN/A    }
902SN/A
912SN/A  private:
92237SN/A    sc_core::sc_event *_sc_event;
932667Sstever@eecs.umich.edu
942667Sstever@eecs.umich.edu    std::string _basename;
952SN/A    std::string _name;
962SN/A    bool _inHierarchy;
972SN/A
982SN/A    sc_core::sc_object *parent;
992SN/A    EventsIt parentIt;
1002SN/A};
1012SN/A
1022SN/Aextern Events topLevelEvents;
1032SN/Aextern Events allEvents;
1042SN/A
1052SN/AEventsIt findEvent(const std::string &name);
1062SN/A
1072SN/A} // namespace sc_gem5
1082SN/A
1092SN/A#endif  //__SYSTEMC_CORE_EVENT_HH__
1102SN/A