1/* 2 * Copyright 2018 Google, Inc. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer; 8 * redistributions in binary form must reproduce the above copyright 9 * notice, this list of conditions and the following disclaimer in the 10 * documentation and/or other materials provided with the distribution; 11 * neither the name of the copyright holders nor the names of its 12 * contributors may be used to endorse or promote products derived from 13 * this software without specific prior written permission. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * 27 * Authors: Gabe Black 28 */ 29 30#ifndef __SYSTEMC_CORE_EVENT_HH__ 31#define __SYSTEMC_CORE_EVENT_HH__ 32 33#include <list> 34#include <string> 35#include <vector> 36 37#include "sim/eventq.hh" 38#include "systemc/core/list.hh" 39#include "systemc/core/object.hh" 40#include "systemc/core/process.hh" 41#include "systemc/core/sched_event.hh" 42#include "systemc/core/sensitivity.hh" 43#include "systemc/ext/core/sc_prim.hh" 44#include "systemc/ext/core/sc_time.hh" 45 46namespace sc_core 47{ 48 49class sc_event; 50 51} // namespace sc_core 52 53namespace sc_gem5 54{ 55 56typedef std::vector<sc_core::sc_event *> Events; 57 58class Sensitivity; 59 60class Event 61{ 62 public: 63 Event(sc_core::sc_event *_sc_event); 64 Event(sc_core::sc_event *_sc_event, const char *_basename); 65 66 ~Event(); 67 68 sc_core::sc_event *sc_event() { return _sc_event; } 69 70 const std::string &name() const; 71 const std::string &basename() const; 72 bool inHierarchy() const; 73 sc_core::sc_object *getParentObject() const; 74
| 1/* 2 * Copyright 2018 Google, Inc. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer; 8 * redistributions in binary form must reproduce the above copyright 9 * notice, this list of conditions and the following disclaimer in the 10 * documentation and/or other materials provided with the distribution; 11 * neither the name of the copyright holders nor the names of its 12 * contributors may be used to endorse or promote products derived from 13 * this software without specific prior written permission. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * 27 * Authors: Gabe Black 28 */ 29 30#ifndef __SYSTEMC_CORE_EVENT_HH__ 31#define __SYSTEMC_CORE_EVENT_HH__ 32 33#include <list> 34#include <string> 35#include <vector> 36 37#include "sim/eventq.hh" 38#include "systemc/core/list.hh" 39#include "systemc/core/object.hh" 40#include "systemc/core/process.hh" 41#include "systemc/core/sched_event.hh" 42#include "systemc/core/sensitivity.hh" 43#include "systemc/ext/core/sc_prim.hh" 44#include "systemc/ext/core/sc_time.hh" 45 46namespace sc_core 47{ 48 49class sc_event; 50 51} // namespace sc_core 52 53namespace sc_gem5 54{ 55 56typedef std::vector<sc_core::sc_event *> Events; 57 58class Sensitivity; 59 60class Event 61{ 62 public: 63 Event(sc_core::sc_event *_sc_event); 64 Event(sc_core::sc_event *_sc_event, const char *_basename); 65 66 ~Event(); 67 68 sc_core::sc_event *sc_event() { return _sc_event; } 69 70 const std::string &name() const; 71 const std::string &basename() const; 72 bool inHierarchy() const; 73 sc_core::sc_object *getParentObject() const; 74
|
| 75 void notify(StaticSensitivities &senses); 76 void notify(DynamicSensitivities &senses); 77
|
75 void notify(); 76 void notify(const sc_core::sc_time &t); 77 void 78 notify(double d, sc_core::sc_time_unit &u) 79 { 80 notify(sc_core::sc_time(d, u)); 81 } 82 void cancel(); 83 84 bool triggered() const; 85 86 static Event * 87 getFromScEvent(sc_core::sc_event *e) 88 { 89 return e->_gem5_event; 90 } 91 92 static const Event * 93 getFromScEvent(const sc_core::sc_event *e) 94 { 95 return e->_gem5_event; 96 } 97 98 void 99 addSensitivity(StaticSensitivity *s) const 100 { 101 // Insert static sensitivities in reverse order to match Accellera's 102 // implementation.
| 78 void notify(); 79 void notify(const sc_core::sc_time &t); 80 void 81 notify(double d, sc_core::sc_time_unit &u) 82 { 83 notify(sc_core::sc_time(d, u)); 84 } 85 void cancel(); 86 87 bool triggered() const; 88 89 static Event * 90 getFromScEvent(sc_core::sc_event *e) 91 { 92 return e->_gem5_event; 93 } 94 95 static const Event * 96 getFromScEvent(const sc_core::sc_event *e) 97 { 98 return e->_gem5_event; 99 } 100 101 void 102 addSensitivity(StaticSensitivity *s) const 103 { 104 // Insert static sensitivities in reverse order to match Accellera's 105 // implementation.
|
103 staticSensitivities.insert(staticSensitivities.begin(), s);
| 106 auto &senses = s->ofMethod() ? staticSenseMethod : staticSenseThread; 107 senses.insert(senses.begin(), s);
|
104 } 105 void 106 delSensitivity(StaticSensitivity *s) const 107 {
| 108 } 109 void 110 delSensitivity(StaticSensitivity *s) const 111 {
|
108 for (auto &t: staticSensitivities) {
| 112 auto &senses = s->ofMethod() ? staticSenseMethod : staticSenseThread; 113 for (auto &t: senses) {
|
109 if (t == s) {
| 114 if (t == s) {
|
110 t = staticSensitivities.back(); 111 staticSensitivities.pop_back();
| 115 t = senses.back(); 116 senses.pop_back();
|
112 break; 113 } 114 } 115 } 116 void 117 addSensitivity(DynamicSensitivity *s) const 118 {
| 117 break; 118 } 119 } 120 } 121 void 122 addSensitivity(DynamicSensitivity *s) const 123 {
|
119 dynamicSensitivities.push_back(s);
| 124 auto &senses = s->ofMethod() ? dynamicSenseMethod : dynamicSenseThread; 125 senses.push_back(s);
|
120 } 121 void 122 delSensitivity(DynamicSensitivity *s) const 123 {
| 126 } 127 void 128 delSensitivity(DynamicSensitivity *s) const 129 {
|
124 for (auto &t: dynamicSensitivities) {
| 130 auto &senses = s->ofMethod() ? dynamicSenseMethod : dynamicSenseThread; 131 for (auto &t: senses) {
|
125 if (t == s) {
| 132 if (t == s) {
|
126 t = dynamicSensitivities.back(); 127 dynamicSensitivities.pop_back();
| 133 t = senses.back(); 134 senses.pop_back();
|
128 break; 129 } 130 } 131 } 132 133 private: 134 sc_core::sc_event *_sc_event; 135 136 std::string _basename; 137 std::string _name; 138 bool _inHierarchy; 139 140 sc_core::sc_object *parent; 141 142 ScEvent delayedNotify; 143
| 135 break; 136 } 137 } 138 } 139 140 private: 141 sc_core::sc_event *_sc_event; 142 143 std::string _basename; 144 std::string _name; 145 bool _inHierarchy; 146 147 sc_core::sc_object *parent; 148 149 ScEvent delayedNotify; 150
|
144 mutable StaticSensitivities staticSensitivities; 145 mutable DynamicSensitivities dynamicSensitivities;
| 151 mutable StaticSensitivities staticSenseMethod; 152 mutable StaticSensitivities staticSenseThread; 153 mutable DynamicSensitivities dynamicSenseMethod; 154 mutable DynamicSensitivities dynamicSenseThread;
|
146}; 147 148extern Events topLevelEvents; 149extern Events allEvents; 150 151EventsIt findEvent(const std::string &name); 152 153} // namespace sc_gem5 154 155#endif //__SYSTEMC_CORE_EVENT_HH__
| 155}; 156 157extern Events topLevelEvents; 158extern Events allEvents; 159 160EventsIt findEvent(const std::string &name); 161 162} // namespace sc_gem5 163 164#endif //__SYSTEMC_CORE_EVENT_HH__
|