sc_module.cc (13288:f1c04129f709) sc_module.cc (13292:0dc64d73b440)
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#include <memory>
31#include <string>
32#include <vector>
33
34#include "base/logging.hh"
35#include "systemc/core/event.hh"
36#include "systemc/core/kernel.hh"
37#include "systemc/core/module.hh"
38#include "systemc/core/object.hh"
39#include "systemc/core/port.hh"
40#include "systemc/core/process_types.hh"
41#include "systemc/core/sensitivity.hh"
42#include "systemc/ext/channel/sc_in.hh"
43#include "systemc/ext/channel/sc_inout.hh"
44#include "systemc/ext/channel/sc_out.hh"
45#include "systemc/ext/channel/sc_signal_in_if.hh"
46#include "systemc/ext/core/sc_module.hh"
47#include "systemc/ext/core/sc_module_name.hh"
48#include "systemc/ext/dt/bit/sc_logic.hh"
49#include "systemc/ext/utils/sc_report_handler.hh"
50
51namespace sc_gem5
52{
53
54Process *
55newMethodProcess(const char *name, ProcessFuncWrapper *func)
56{
57 Method *p = new Method(name, func);
58 if (::sc_core::sc_is_running()) {
59 std::string name = p->name();
60 delete p;
61 SC_REPORT_ERROR("(E541) call to SC_METHOD in sc_module while "
62 "simulation running", name.c_str());
63 return nullptr;
64 }
65 scheduler.reg(p);
66 return p;
67}
68
69Process *
70newThreadProcess(const char *name, ProcessFuncWrapper *func)
71{
72 Thread *p = new Thread(name, func);
73 if (::sc_core::sc_is_running()) {
74 std::string name = p->name();
75 delete p;
76 SC_REPORT_ERROR("(E542) call to SC_THREAD in sc_module while "
77 "simulation running", name.c_str());
78 return nullptr;
79 }
80 scheduler.reg(p);
81 return p;
82}
83
84Process *
85newCThreadProcess(const char *name, ProcessFuncWrapper *func)
86{
87 CThread *p = new CThread(name, func);
88 if (::sc_core::sc_is_running()) {
89 std::string name = p->name();
90 delete p;
91 SC_REPORT_ERROR("(E543) call to SC_CTHREAD in sc_module while "
92 "simulation running", name.c_str());
93 return nullptr;
94 }
95 scheduler.reg(p);
96 p->dontInitialize(true);
97 return p;
98}
99
100UniqueNameGen nameGen;
101
102} // namespace sc_gem5
103
104namespace sc_core
105{
106
107sc_bind_proxy::sc_bind_proxy(sc_interface &_interface) :
108 _interface(&_interface), _port(nullptr)
109{}
110
111sc_bind_proxy::sc_bind_proxy(sc_port_base &_port) :
112 _interface(nullptr), _port(&_port)
113{}
114
115const sc_bind_proxy SC_BIND_PROXY_NUL(*(sc_port_base *)nullptr);
116
117sc_module::~sc_module() { delete _gem5_module; }
118
119const sc_bind_proxy SC_BIND_PROXY_NIL(*(sc_port_base *)nullptr);
120
121void
122sc_module::operator () (const sc_bind_proxy &p001,
123 const sc_bind_proxy &p002,
124 const sc_bind_proxy &p003,
125 const sc_bind_proxy &p004,
126 const sc_bind_proxy &p005,
127 const sc_bind_proxy &p006,
128 const sc_bind_proxy &p007,
129 const sc_bind_proxy &p008,
130 const sc_bind_proxy &p009,
131 const sc_bind_proxy &p010,
132 const sc_bind_proxy &p011,
133 const sc_bind_proxy &p012,
134 const sc_bind_proxy &p013,
135 const sc_bind_proxy &p014,
136 const sc_bind_proxy &p015,
137 const sc_bind_proxy &p016,
138 const sc_bind_proxy &p017,
139 const sc_bind_proxy &p018,
140 const sc_bind_proxy &p019,
141 const sc_bind_proxy &p020,
142 const sc_bind_proxy &p021,
143 const sc_bind_proxy &p022,
144 const sc_bind_proxy &p023,
145 const sc_bind_proxy &p024,
146 const sc_bind_proxy &p025,
147 const sc_bind_proxy &p026,
148 const sc_bind_proxy &p027,
149 const sc_bind_proxy &p028,
150 const sc_bind_proxy &p029,
151 const sc_bind_proxy &p030,
152 const sc_bind_proxy &p031,
153 const sc_bind_proxy &p032,
154 const sc_bind_proxy &p033,
155 const sc_bind_proxy &p034,
156 const sc_bind_proxy &p035,
157 const sc_bind_proxy &p036,
158 const sc_bind_proxy &p037,
159 const sc_bind_proxy &p038,
160 const sc_bind_proxy &p039,
161 const sc_bind_proxy &p040,
162 const sc_bind_proxy &p041,
163 const sc_bind_proxy &p042,
164 const sc_bind_proxy &p043,
165 const sc_bind_proxy &p044,
166 const sc_bind_proxy &p045,
167 const sc_bind_proxy &p046,
168 const sc_bind_proxy &p047,
169 const sc_bind_proxy &p048,
170 const sc_bind_proxy &p049,
171 const sc_bind_proxy &p050,
172 const sc_bind_proxy &p051,
173 const sc_bind_proxy &p052,
174 const sc_bind_proxy &p053,
175 const sc_bind_proxy &p054,
176 const sc_bind_proxy &p055,
177 const sc_bind_proxy &p056,
178 const sc_bind_proxy &p057,
179 const sc_bind_proxy &p058,
180 const sc_bind_proxy &p059,
181 const sc_bind_proxy &p060,
182 const sc_bind_proxy &p061,
183 const sc_bind_proxy &p062,
184 const sc_bind_proxy &p063,
185 const sc_bind_proxy &p064)
186{
187 std::vector<const ::sc_core::sc_bind_proxy *> proxies;
188 auto insert = [&proxies](const ::sc_core::sc_bind_proxy &p) -> bool {
189 if (!p.port() && !p.interface())
190 return false;
191 proxies.push_back(&p);
192 return true;
193 };
194 insert(p001) && insert(p002) && insert(p003) && insert(p004) &&
195 insert(p005) && insert(p006) && insert(p007) && insert(p008) &&
196 insert(p009) && insert(p010) && insert(p011) && insert(p012) &&
197 insert(p013) && insert(p014) && insert(p015) && insert(p016) &&
198 insert(p017) && insert(p018) && insert(p019) && insert(p020) &&
199 insert(p021) && insert(p022) && insert(p023) && insert(p024) &&
200 insert(p025) && insert(p026) && insert(p027) && insert(p028) &&
201 insert(p029) && insert(p030) && insert(p031) && insert(p032) &&
202 insert(p033) && insert(p034) && insert(p035) && insert(p036) &&
203 insert(p037) && insert(p038) && insert(p039) && insert(p040) &&
204 insert(p041) && insert(p042) && insert(p043) && insert(p044) &&
205 insert(p045) && insert(p046) && insert(p047) && insert(p048) &&
206 insert(p049) && insert(p050) && insert(p051) && insert(p052) &&
207 insert(p053) && insert(p054) && insert(p055) && insert(p056) &&
208 insert(p057) && insert(p058) && insert(p059) && insert(p060) &&
209 insert(p061) && insert(p062) && insert(p063) && insert(p064);
210 _gem5_module->bindPorts(proxies);
211}
212
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#include <memory>
31#include <string>
32#include <vector>
33
34#include "base/logging.hh"
35#include "systemc/core/event.hh"
36#include "systemc/core/kernel.hh"
37#include "systemc/core/module.hh"
38#include "systemc/core/object.hh"
39#include "systemc/core/port.hh"
40#include "systemc/core/process_types.hh"
41#include "systemc/core/sensitivity.hh"
42#include "systemc/ext/channel/sc_in.hh"
43#include "systemc/ext/channel/sc_inout.hh"
44#include "systemc/ext/channel/sc_out.hh"
45#include "systemc/ext/channel/sc_signal_in_if.hh"
46#include "systemc/ext/core/sc_module.hh"
47#include "systemc/ext/core/sc_module_name.hh"
48#include "systemc/ext/dt/bit/sc_logic.hh"
49#include "systemc/ext/utils/sc_report_handler.hh"
50
51namespace sc_gem5
52{
53
54Process *
55newMethodProcess(const char *name, ProcessFuncWrapper *func)
56{
57 Method *p = new Method(name, func);
58 if (::sc_core::sc_is_running()) {
59 std::string name = p->name();
60 delete p;
61 SC_REPORT_ERROR("(E541) call to SC_METHOD in sc_module while "
62 "simulation running", name.c_str());
63 return nullptr;
64 }
65 scheduler.reg(p);
66 return p;
67}
68
69Process *
70newThreadProcess(const char *name, ProcessFuncWrapper *func)
71{
72 Thread *p = new Thread(name, func);
73 if (::sc_core::sc_is_running()) {
74 std::string name = p->name();
75 delete p;
76 SC_REPORT_ERROR("(E542) call to SC_THREAD in sc_module while "
77 "simulation running", name.c_str());
78 return nullptr;
79 }
80 scheduler.reg(p);
81 return p;
82}
83
84Process *
85newCThreadProcess(const char *name, ProcessFuncWrapper *func)
86{
87 CThread *p = new CThread(name, func);
88 if (::sc_core::sc_is_running()) {
89 std::string name = p->name();
90 delete p;
91 SC_REPORT_ERROR("(E543) call to SC_CTHREAD in sc_module while "
92 "simulation running", name.c_str());
93 return nullptr;
94 }
95 scheduler.reg(p);
96 p->dontInitialize(true);
97 return p;
98}
99
100UniqueNameGen nameGen;
101
102} // namespace sc_gem5
103
104namespace sc_core
105{
106
107sc_bind_proxy::sc_bind_proxy(sc_interface &_interface) :
108 _interface(&_interface), _port(nullptr)
109{}
110
111sc_bind_proxy::sc_bind_proxy(sc_port_base &_port) :
112 _interface(nullptr), _port(&_port)
113{}
114
115const sc_bind_proxy SC_BIND_PROXY_NUL(*(sc_port_base *)nullptr);
116
117sc_module::~sc_module() { delete _gem5_module; }
118
119const sc_bind_proxy SC_BIND_PROXY_NIL(*(sc_port_base *)nullptr);
120
121void
122sc_module::operator () (const sc_bind_proxy &p001,
123 const sc_bind_proxy &p002,
124 const sc_bind_proxy &p003,
125 const sc_bind_proxy &p004,
126 const sc_bind_proxy &p005,
127 const sc_bind_proxy &p006,
128 const sc_bind_proxy &p007,
129 const sc_bind_proxy &p008,
130 const sc_bind_proxy &p009,
131 const sc_bind_proxy &p010,
132 const sc_bind_proxy &p011,
133 const sc_bind_proxy &p012,
134 const sc_bind_proxy &p013,
135 const sc_bind_proxy &p014,
136 const sc_bind_proxy &p015,
137 const sc_bind_proxy &p016,
138 const sc_bind_proxy &p017,
139 const sc_bind_proxy &p018,
140 const sc_bind_proxy &p019,
141 const sc_bind_proxy &p020,
142 const sc_bind_proxy &p021,
143 const sc_bind_proxy &p022,
144 const sc_bind_proxy &p023,
145 const sc_bind_proxy &p024,
146 const sc_bind_proxy &p025,
147 const sc_bind_proxy &p026,
148 const sc_bind_proxy &p027,
149 const sc_bind_proxy &p028,
150 const sc_bind_proxy &p029,
151 const sc_bind_proxy &p030,
152 const sc_bind_proxy &p031,
153 const sc_bind_proxy &p032,
154 const sc_bind_proxy &p033,
155 const sc_bind_proxy &p034,
156 const sc_bind_proxy &p035,
157 const sc_bind_proxy &p036,
158 const sc_bind_proxy &p037,
159 const sc_bind_proxy &p038,
160 const sc_bind_proxy &p039,
161 const sc_bind_proxy &p040,
162 const sc_bind_proxy &p041,
163 const sc_bind_proxy &p042,
164 const sc_bind_proxy &p043,
165 const sc_bind_proxy &p044,
166 const sc_bind_proxy &p045,
167 const sc_bind_proxy &p046,
168 const sc_bind_proxy &p047,
169 const sc_bind_proxy &p048,
170 const sc_bind_proxy &p049,
171 const sc_bind_proxy &p050,
172 const sc_bind_proxy &p051,
173 const sc_bind_proxy &p052,
174 const sc_bind_proxy &p053,
175 const sc_bind_proxy &p054,
176 const sc_bind_proxy &p055,
177 const sc_bind_proxy &p056,
178 const sc_bind_proxy &p057,
179 const sc_bind_proxy &p058,
180 const sc_bind_proxy &p059,
181 const sc_bind_proxy &p060,
182 const sc_bind_proxy &p061,
183 const sc_bind_proxy &p062,
184 const sc_bind_proxy &p063,
185 const sc_bind_proxy &p064)
186{
187 std::vector<const ::sc_core::sc_bind_proxy *> proxies;
188 auto insert = [&proxies](const ::sc_core::sc_bind_proxy &p) -> bool {
189 if (!p.port() && !p.interface())
190 return false;
191 proxies.push_back(&p);
192 return true;
193 };
194 insert(p001) && insert(p002) && insert(p003) && insert(p004) &&
195 insert(p005) && insert(p006) && insert(p007) && insert(p008) &&
196 insert(p009) && insert(p010) && insert(p011) && insert(p012) &&
197 insert(p013) && insert(p014) && insert(p015) && insert(p016) &&
198 insert(p017) && insert(p018) && insert(p019) && insert(p020) &&
199 insert(p021) && insert(p022) && insert(p023) && insert(p024) &&
200 insert(p025) && insert(p026) && insert(p027) && insert(p028) &&
201 insert(p029) && insert(p030) && insert(p031) && insert(p032) &&
202 insert(p033) && insert(p034) && insert(p035) && insert(p036) &&
203 insert(p037) && insert(p038) && insert(p039) && insert(p040) &&
204 insert(p041) && insert(p042) && insert(p043) && insert(p044) &&
205 insert(p045) && insert(p046) && insert(p047) && insert(p048) &&
206 insert(p049) && insert(p050) && insert(p051) && insert(p052) &&
207 insert(p053) && insert(p054) && insert(p055) && insert(p056) &&
208 insert(p057) && insert(p058) && insert(p059) && insert(p060) &&
209 insert(p061) && insert(p062) && insert(p063) && insert(p064);
210 _gem5_module->bindPorts(proxies);
211}
212
213sc_module &
214sc_module::operator << (sc_interface &iface)
215{
216 (*this)(iface);
217 return *this;
218}
219
220sc_module &
221sc_module::operator << (sc_port_base &pb)
222{
223 (*this)(pb);
224 return *this;
225}
226
227sc_module &
228sc_module::operator , (sc_interface &iface)
229{
230 (*this)(iface);
231 return *this;
232}
233
234sc_module &
235sc_module::operator , (sc_port_base &pb)
236{
237 (*this)(pb);
238 return *this;
239}
240
213const std::vector<sc_object *> &
214sc_module::get_child_objects() const
215{
216 return _gem5_module->obj()->get_child_objects();
217}
218
219const std::vector<sc_event *> &
220sc_module::get_child_events() const
221{
222 return _gem5_module->obj()->get_child_events();
223}
224
225sc_module::sc_module() :
226 sc_object(sc_gem5::newModuleChecked()->name()),
227 _gem5_module(sc_gem5::currentModule())
228{
229 if (sc_is_running()) {
230 SC_REPORT_ERROR("(E529) insert module failed", "simulation running");
231 std::cout << "Running!\n";
232 }
233 if (::sc_gem5::scheduler.elaborationDone()) {
234 SC_REPORT_ERROR("(E529) insert module failed", "elaboration done");
235 std::cout << "Elaboration done!\n";
236 }
237}
238
239sc_module::sc_module(const sc_module_name &) : sc_module() {}
240sc_module::sc_module(const char *_name) : sc_module(sc_module_name(_name))
241{
242 _gem5_module->deprecatedConstructor();
243 SC_REPORT_WARNING("(W569) sc_module(const char*), "
244 "sc_module(const std::string&) have been deprecated, use "
245 "sc_module(const sc_module_name&)", _name);
246}
247sc_module::sc_module(const std::string &_name) :
248 sc_module(sc_module_name(_name.c_str()))
249{
250 _gem5_module->deprecatedConstructor();
251 SC_REPORT_WARNING("(W569) sc_module(const char*), "
252 "sc_module(const std::string&) have been deprecated, use "
253 "sc_module(const sc_module_name&)", _name.c_str());
254}
255
256void
257sc_module::end_module()
258{
259 _gem5_module->endModule();
260}
261
262void
263sc_module::reset_signal_is(const sc_in<bool> &port, bool val)
264{
265 ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), true, val);
266}
267
268void
269sc_module::reset_signal_is(const sc_inout<bool> &port, bool val)
270{
271 ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), true, val);
272}
273
274void
275sc_module::reset_signal_is(const sc_out<bool> &port, bool val)
276{
277 ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), true, val);
278}
279
280void
281sc_module::reset_signal_is(const sc_signal_in_if<bool> &signal, bool val)
282{
283 ::sc_gem5::newReset(&signal, ::sc_gem5::Process::newest(), true, val);
284}
285
286
287void
288sc_module::async_reset_signal_is(const sc_in<bool> &port, bool val)
289{
290 ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), false, val);
291}
292
293void
294sc_module::async_reset_signal_is(const sc_inout<bool> &port, bool val)
295{
296 ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), false, val);
297}
298
299void
300sc_module::async_reset_signal_is(const sc_out<bool> &port, bool val)
301{
302 ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), false, val);
303}
304
305void
306sc_module::async_reset_signal_is(const sc_signal_in_if<bool> &signal, bool val)
307{
308 ::sc_gem5::newReset(&signal, ::sc_gem5::Process::newest(), false, val);
309}
310
311
312void
313sc_module::dont_initialize()
314{
315 ::sc_gem5::Process::newest()->dontInitialize(true);
316}
317
318void
319sc_module::set_stack_size(size_t size)
320{
321 ::sc_gem5::Process::newest()->setStackSize(size);
322}
323
324
325void sc_module::next_trigger() { ::sc_core::next_trigger(); }
326
327void
328sc_module::next_trigger(const sc_event &e)
329{
330 ::sc_core::next_trigger(e);
331}
332
333void
334sc_module::next_trigger(const sc_event_or_list &eol)
335{
336 ::sc_core::next_trigger(eol);
337}
338
339void
340sc_module::next_trigger(const sc_event_and_list &eal)
341{
342 ::sc_core::next_trigger(eal);
343}
344
345void
346sc_module::next_trigger(const sc_time &t)
347{
348 ::sc_core::next_trigger(t);
349}
350
351void
352sc_module::next_trigger(double d, sc_time_unit u)
353{
354 ::sc_core::next_trigger(d, u);
355}
356
357void
358sc_module::next_trigger(const sc_time &t, const sc_event &e)
359{
360 ::sc_core::next_trigger(t, e);
361}
362
363void
364sc_module::next_trigger(double d, sc_time_unit u, const sc_event &e)
365{
366 ::sc_core::next_trigger(d, u, e);
367}
368
369void
370sc_module::next_trigger(const sc_time &t, const sc_event_or_list &eol)
371{
372 ::sc_core::next_trigger(t, eol);
373}
374
375void
376sc_module::next_trigger(double d, sc_time_unit u, const sc_event_or_list &eol)
377{
378 ::sc_core::next_trigger(d, u, eol);
379}
380
381void
382sc_module::next_trigger(const sc_time &t, const sc_event_and_list &eal)
383{
384 ::sc_core::next_trigger(t, eal);
385}
386
387void
388sc_module::next_trigger(double d, sc_time_unit u, const sc_event_and_list &eal)
389{
390 ::sc_core::next_trigger(d, u, eal);
391}
392
393
394bool
395sc_module::timed_out()
396{
397 return ::sc_core::timed_out();
398}
399
400
401void
402sc_module::wait()
403{
404 ::sc_core::wait();
405}
406
407void
408sc_module::wait(int i)
409{
410 ::sc_core::wait(i);
411}
412
413void
414sc_module::wait(const sc_event &e)
415{
416 ::sc_core::wait(e);
417}
418
419void
420sc_module::wait(const sc_event_or_list &eol)
421{
422 ::sc_core::wait(eol);
423}
424
425void
426sc_module::wait(const sc_event_and_list &eal)
427{
428 ::sc_core::wait(eal);
429}
430
431void
432sc_module::wait(const sc_time &t)
433{
434 ::sc_core::wait(t);
435}
436
437void
438sc_module::wait(double d, sc_time_unit u)
439{
440 ::sc_core::wait(d, u);
441}
442
443void
444sc_module::wait(const sc_time &t, const sc_event &e)
445{
446 ::sc_core::wait(t, e);
447}
448
449void
450sc_module::wait(double d, sc_time_unit u, const sc_event &e)
451{
452 ::sc_core::wait(d, u, e);
453}
454
455void
456sc_module::wait(const sc_time &t, const sc_event_or_list &eol)
457{
458 ::sc_core::wait(t, eol);
459}
460
461void
462sc_module::wait(double d, sc_time_unit u, const sc_event_or_list &eol)
463{
464 ::sc_core::wait(d, u, eol);
465}
466
467void
468sc_module::wait(const sc_time &t, const sc_event_and_list &eal)
469{
470 ::sc_core::wait(t, eal);
471}
472
473void
474sc_module::wait(double d, sc_time_unit u, const sc_event_and_list &eal)
475{
476 ::sc_core::wait(d, u, eal);
477}
478
479
480void
481sc_module::halt()
482{
483 ::sc_core::halt();
484}
485
486void
487sc_module::at_posedge(const sc_signal_in_if<bool> &s)
488{
489 ::sc_core::at_posedge(s);
490}
491
492void
493sc_module::at_posedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
494{
495 ::sc_core::at_posedge(s);
496}
497
498void
499sc_module::at_negedge(const sc_signal_in_if<bool> &s)
500{
501 ::sc_core::at_negedge(s);
502}
503
504void
505sc_module::at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
506{
507 ::sc_core::at_negedge(s);
508}
509
510
511void
512next_trigger()
513{
514 sc_gem5::Process *p = sc_gem5::scheduler.current();
515 p->cancelTimeout();
516 p->clearDynamic();
517}
518
519void
520next_trigger(const sc_event &e)
521{
522 sc_gem5::Process *p = sc_gem5::scheduler.current();
523 p->cancelTimeout();
524 ::sc_gem5::newDynamicSensitivityEvent(p, &e);
525}
526
527void
528next_trigger(const sc_event_or_list &eol)
529{
530 sc_gem5::Process *p = sc_gem5::scheduler.current();
531 p->cancelTimeout();
532 ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol);
533}
534
535void
536next_trigger(const sc_event_and_list &eal)
537{
538 sc_gem5::Process *p = sc_gem5::scheduler.current();
539 p->cancelTimeout();
540 ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal);
541}
542
543void
544next_trigger(const sc_time &t)
545{
546 sc_gem5::Process *p = sc_gem5::scheduler.current();
547 p->setTimeout(t);
548 p->clearDynamic();
549}
550
551void
552next_trigger(double d, sc_time_unit u)
553{
554 next_trigger(sc_time(d, u));
555}
556
557void
558next_trigger(const sc_time &t, const sc_event &e)
559{
560 sc_gem5::Process *p = sc_gem5::scheduler.current();
561 p->setTimeout(t);
562 ::sc_gem5::newDynamicSensitivityEvent(p, &e);
563}
564
565void
566next_trigger(double d, sc_time_unit u, const sc_event &e)
567{
568 next_trigger(sc_time(d, u), e);
569}
570
571void
572next_trigger(const sc_time &t, const sc_event_or_list &eol)
573{
574 sc_gem5::Process *p = sc_gem5::scheduler.current();
575 p->setTimeout(t);
576 ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol);
577}
578
579void
580next_trigger(double d, sc_time_unit u, const sc_event_or_list &eol)
581{
582 next_trigger(sc_time(d, u), eol);
583}
584
585void
586next_trigger(const sc_time &t, const sc_event_and_list &eal)
587{
588 sc_gem5::Process *p = sc_gem5::scheduler.current();
589 p->setTimeout(t);
590 ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal);
591}
592
593void
594next_trigger(double d, sc_time_unit u, const sc_event_and_list &eal)
595{
596 next_trigger(sc_time(d, u), eal);
597}
598
599bool
600timed_out()
601{
602 ::sc_gem5::Process *p = sc_gem5::scheduler.current();
603 if (!p)
604 return false;
605 else
606 return p->timedOut();
607}
608
609
610namespace
611{
612
613bool
614waitErrorCheck(sc_gem5::Process *p)
615{
616 if (p->procKind() == SC_METHOD_PROC_) {
617 SC_REPORT_ERROR(
618 "(E519) wait() is only allowed in SC_THREADs and SC_CTHREADs",
619 "\n in SC_METHODs use next_trigger() instead");
620 return true;
621 }
622 return false;
623}
624
625} // anonymous namespace
626
627void
628wait()
629{
630 sc_gem5::Process *p = sc_gem5::scheduler.current();
631 if (waitErrorCheck(p))
632 return;
633 p->cancelTimeout();
634 p->clearDynamic();
635 sc_gem5::scheduler.yield();
636}
637
638void
639wait(int n)
640{
641 if (n <= 0) {
642 std::string msg = csprintf("n = %d", n);
643 SC_REPORT_ERROR("(E525) wait(n) is only valid for n > 0", msg.c_str());
644 }
645 sc_gem5::Process *p = sc_gem5::scheduler.current();
646 p->waitCount(n - 1);
647 wait();
648}
649
650void
651wait(const sc_event &e)
652{
653 sc_gem5::Process *p = sc_gem5::scheduler.current();
654 if (waitErrorCheck(p))
655 return;
656 p->cancelTimeout();
657 ::sc_gem5::newDynamicSensitivityEvent(p, &e);
658 sc_gem5::scheduler.yield();
659}
660
661void
662wait(const sc_event_or_list &eol)
663{
664 sc_gem5::Process *p = sc_gem5::scheduler.current();
665 if (waitErrorCheck(p))
666 return;
667 p->cancelTimeout();
668 ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol);
669 sc_gem5::scheduler.yield();
670}
671
672void
673wait(const sc_event_and_list &eal)
674{
675 sc_gem5::Process *p = sc_gem5::scheduler.current();
676 if (waitErrorCheck(p))
677 return;
678 p->cancelTimeout();
679 ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal);
680 sc_gem5::scheduler.yield();
681}
682
683void
684wait(const sc_time &t)
685{
686 sc_gem5::Process *p = sc_gem5::scheduler.current();
687 if (waitErrorCheck(p))
688 return;
689 p->setTimeout(t);
690 p->clearDynamic();
691 sc_gem5::scheduler.yield();
692}
693
694void
695wait(double d, sc_time_unit u)
696{
697 wait(sc_time(d, u));
698}
699
700void
701wait(const sc_time &t, const sc_event &e)
702{
703 sc_gem5::Process *p = sc_gem5::scheduler.current();
704 if (waitErrorCheck(p))
705 return;
706 p->setTimeout(t);
707 ::sc_gem5::newDynamicSensitivityEvent(p, &e);
708 sc_gem5::scheduler.yield();
709}
710
711void
712wait(double d, sc_time_unit u, const sc_event &e)
713{
714 wait(sc_time(d, u), e);
715}
716
717void
718wait(const sc_time &t, const sc_event_or_list &eol)
719{
720 sc_gem5::Process *p = sc_gem5::scheduler.current();
721 if (waitErrorCheck(p))
722 return;
723 p->setTimeout(t);
724 ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol);
725 sc_gem5::scheduler.yield();
726}
727
728void
729wait(double d, sc_time_unit u, const sc_event_or_list &eol)
730{
731 wait(sc_time(d, u), eol);
732}
733
734void
735wait(const sc_time &t, const sc_event_and_list &eal)
736{
737 sc_gem5::Process *p = sc_gem5::scheduler.current();
738 if (waitErrorCheck(p))
739 return;
740 p->setTimeout(t);
741 ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal);
742 sc_gem5::scheduler.yield();
743}
744
745void
746wait(double d, sc_time_unit u, const sc_event_and_list &eal)
747{
748 wait(sc_time(d, u), eal);
749}
750
751void
752halt()
753{
754 ::sc_core::wait();
755 throw ::sc_gem5::ScHalt();
756}
757
758void
759at_posedge(const sc_signal_in_if<bool> &s)
760{
761 while (s.read())
762 wait();
763 while (!s.read())
764 wait();
765}
766
767void
768at_posedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
769{
770 while (s.read() == sc_dt::Log_1)
771 wait();
772 while (s.read() == sc_dt::Log_0)
773 wait();
774}
775
776void
777at_negedge(const sc_signal_in_if<bool> &s)
778{
779 while (!s.read())
780 wait();
781 while (s.read())
782 wait();
783}
784
785void
786at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
787{
788 while (s.read() == sc_dt::Log_0)
789 wait();
790 while (s.read() == sc_dt::Log_1)
791 wait();
792}
793
794const char *
795sc_gen_unique_name(const char *seed)
796{
797 auto mod = sc_gem5::pickParentModule();
798 if (mod)
799 return mod->uniqueName(seed);
800 sc_gem5::Process *p = sc_gem5::scheduler.current();
801 if (p)
802 return p->uniqueName(seed);
803 return ::sc_gem5::nameGen.gen(seed);
804}
805
806bool
807sc_hierarchical_name_exists(const char *name)
808{
809 return sc_gem5::findEvent(name) != sc_gem5::allEvents.end() ||
810 ::sc_gem5::findObject(name, sc_gem5::allObjects);
811}
812
813bool
814sc_start_of_simulation_invoked()
815{
816 return ::sc_gem5::kernel->startOfSimulationComplete();
817}
818
819bool
820sc_end_of_simulation_invoked()
821{
822 return ::sc_gem5::kernel->endOfSimulationComplete();
823}
824
825sc_module *
826sc_module_sc_new(sc_module *mod)
827{
828 static std::vector<std::unique_ptr<sc_module> > modules;
829 modules.emplace_back(mod);
830 return mod;
831}
832
833} // namespace sc_core
241const std::vector<sc_object *> &
242sc_module::get_child_objects() const
243{
244 return _gem5_module->obj()->get_child_objects();
245}
246
247const std::vector<sc_event *> &
248sc_module::get_child_events() const
249{
250 return _gem5_module->obj()->get_child_events();
251}
252
253sc_module::sc_module() :
254 sc_object(sc_gem5::newModuleChecked()->name()),
255 _gem5_module(sc_gem5::currentModule())
256{
257 if (sc_is_running()) {
258 SC_REPORT_ERROR("(E529) insert module failed", "simulation running");
259 std::cout << "Running!\n";
260 }
261 if (::sc_gem5::scheduler.elaborationDone()) {
262 SC_REPORT_ERROR("(E529) insert module failed", "elaboration done");
263 std::cout << "Elaboration done!\n";
264 }
265}
266
267sc_module::sc_module(const sc_module_name &) : sc_module() {}
268sc_module::sc_module(const char *_name) : sc_module(sc_module_name(_name))
269{
270 _gem5_module->deprecatedConstructor();
271 SC_REPORT_WARNING("(W569) sc_module(const char*), "
272 "sc_module(const std::string&) have been deprecated, use "
273 "sc_module(const sc_module_name&)", _name);
274}
275sc_module::sc_module(const std::string &_name) :
276 sc_module(sc_module_name(_name.c_str()))
277{
278 _gem5_module->deprecatedConstructor();
279 SC_REPORT_WARNING("(W569) sc_module(const char*), "
280 "sc_module(const std::string&) have been deprecated, use "
281 "sc_module(const sc_module_name&)", _name.c_str());
282}
283
284void
285sc_module::end_module()
286{
287 _gem5_module->endModule();
288}
289
290void
291sc_module::reset_signal_is(const sc_in<bool> &port, bool val)
292{
293 ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), true, val);
294}
295
296void
297sc_module::reset_signal_is(const sc_inout<bool> &port, bool val)
298{
299 ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), true, val);
300}
301
302void
303sc_module::reset_signal_is(const sc_out<bool> &port, bool val)
304{
305 ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), true, val);
306}
307
308void
309sc_module::reset_signal_is(const sc_signal_in_if<bool> &signal, bool val)
310{
311 ::sc_gem5::newReset(&signal, ::sc_gem5::Process::newest(), true, val);
312}
313
314
315void
316sc_module::async_reset_signal_is(const sc_in<bool> &port, bool val)
317{
318 ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), false, val);
319}
320
321void
322sc_module::async_reset_signal_is(const sc_inout<bool> &port, bool val)
323{
324 ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), false, val);
325}
326
327void
328sc_module::async_reset_signal_is(const sc_out<bool> &port, bool val)
329{
330 ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), false, val);
331}
332
333void
334sc_module::async_reset_signal_is(const sc_signal_in_if<bool> &signal, bool val)
335{
336 ::sc_gem5::newReset(&signal, ::sc_gem5::Process::newest(), false, val);
337}
338
339
340void
341sc_module::dont_initialize()
342{
343 ::sc_gem5::Process::newest()->dontInitialize(true);
344}
345
346void
347sc_module::set_stack_size(size_t size)
348{
349 ::sc_gem5::Process::newest()->setStackSize(size);
350}
351
352
353void sc_module::next_trigger() { ::sc_core::next_trigger(); }
354
355void
356sc_module::next_trigger(const sc_event &e)
357{
358 ::sc_core::next_trigger(e);
359}
360
361void
362sc_module::next_trigger(const sc_event_or_list &eol)
363{
364 ::sc_core::next_trigger(eol);
365}
366
367void
368sc_module::next_trigger(const sc_event_and_list &eal)
369{
370 ::sc_core::next_trigger(eal);
371}
372
373void
374sc_module::next_trigger(const sc_time &t)
375{
376 ::sc_core::next_trigger(t);
377}
378
379void
380sc_module::next_trigger(double d, sc_time_unit u)
381{
382 ::sc_core::next_trigger(d, u);
383}
384
385void
386sc_module::next_trigger(const sc_time &t, const sc_event &e)
387{
388 ::sc_core::next_trigger(t, e);
389}
390
391void
392sc_module::next_trigger(double d, sc_time_unit u, const sc_event &e)
393{
394 ::sc_core::next_trigger(d, u, e);
395}
396
397void
398sc_module::next_trigger(const sc_time &t, const sc_event_or_list &eol)
399{
400 ::sc_core::next_trigger(t, eol);
401}
402
403void
404sc_module::next_trigger(double d, sc_time_unit u, const sc_event_or_list &eol)
405{
406 ::sc_core::next_trigger(d, u, eol);
407}
408
409void
410sc_module::next_trigger(const sc_time &t, const sc_event_and_list &eal)
411{
412 ::sc_core::next_trigger(t, eal);
413}
414
415void
416sc_module::next_trigger(double d, sc_time_unit u, const sc_event_and_list &eal)
417{
418 ::sc_core::next_trigger(d, u, eal);
419}
420
421
422bool
423sc_module::timed_out()
424{
425 return ::sc_core::timed_out();
426}
427
428
429void
430sc_module::wait()
431{
432 ::sc_core::wait();
433}
434
435void
436sc_module::wait(int i)
437{
438 ::sc_core::wait(i);
439}
440
441void
442sc_module::wait(const sc_event &e)
443{
444 ::sc_core::wait(e);
445}
446
447void
448sc_module::wait(const sc_event_or_list &eol)
449{
450 ::sc_core::wait(eol);
451}
452
453void
454sc_module::wait(const sc_event_and_list &eal)
455{
456 ::sc_core::wait(eal);
457}
458
459void
460sc_module::wait(const sc_time &t)
461{
462 ::sc_core::wait(t);
463}
464
465void
466sc_module::wait(double d, sc_time_unit u)
467{
468 ::sc_core::wait(d, u);
469}
470
471void
472sc_module::wait(const sc_time &t, const sc_event &e)
473{
474 ::sc_core::wait(t, e);
475}
476
477void
478sc_module::wait(double d, sc_time_unit u, const sc_event &e)
479{
480 ::sc_core::wait(d, u, e);
481}
482
483void
484sc_module::wait(const sc_time &t, const sc_event_or_list &eol)
485{
486 ::sc_core::wait(t, eol);
487}
488
489void
490sc_module::wait(double d, sc_time_unit u, const sc_event_or_list &eol)
491{
492 ::sc_core::wait(d, u, eol);
493}
494
495void
496sc_module::wait(const sc_time &t, const sc_event_and_list &eal)
497{
498 ::sc_core::wait(t, eal);
499}
500
501void
502sc_module::wait(double d, sc_time_unit u, const sc_event_and_list &eal)
503{
504 ::sc_core::wait(d, u, eal);
505}
506
507
508void
509sc_module::halt()
510{
511 ::sc_core::halt();
512}
513
514void
515sc_module::at_posedge(const sc_signal_in_if<bool> &s)
516{
517 ::sc_core::at_posedge(s);
518}
519
520void
521sc_module::at_posedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
522{
523 ::sc_core::at_posedge(s);
524}
525
526void
527sc_module::at_negedge(const sc_signal_in_if<bool> &s)
528{
529 ::sc_core::at_negedge(s);
530}
531
532void
533sc_module::at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
534{
535 ::sc_core::at_negedge(s);
536}
537
538
539void
540next_trigger()
541{
542 sc_gem5::Process *p = sc_gem5::scheduler.current();
543 p->cancelTimeout();
544 p->clearDynamic();
545}
546
547void
548next_trigger(const sc_event &e)
549{
550 sc_gem5::Process *p = sc_gem5::scheduler.current();
551 p->cancelTimeout();
552 ::sc_gem5::newDynamicSensitivityEvent(p, &e);
553}
554
555void
556next_trigger(const sc_event_or_list &eol)
557{
558 sc_gem5::Process *p = sc_gem5::scheduler.current();
559 p->cancelTimeout();
560 ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol);
561}
562
563void
564next_trigger(const sc_event_and_list &eal)
565{
566 sc_gem5::Process *p = sc_gem5::scheduler.current();
567 p->cancelTimeout();
568 ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal);
569}
570
571void
572next_trigger(const sc_time &t)
573{
574 sc_gem5::Process *p = sc_gem5::scheduler.current();
575 p->setTimeout(t);
576 p->clearDynamic();
577}
578
579void
580next_trigger(double d, sc_time_unit u)
581{
582 next_trigger(sc_time(d, u));
583}
584
585void
586next_trigger(const sc_time &t, const sc_event &e)
587{
588 sc_gem5::Process *p = sc_gem5::scheduler.current();
589 p->setTimeout(t);
590 ::sc_gem5::newDynamicSensitivityEvent(p, &e);
591}
592
593void
594next_trigger(double d, sc_time_unit u, const sc_event &e)
595{
596 next_trigger(sc_time(d, u), e);
597}
598
599void
600next_trigger(const sc_time &t, const sc_event_or_list &eol)
601{
602 sc_gem5::Process *p = sc_gem5::scheduler.current();
603 p->setTimeout(t);
604 ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol);
605}
606
607void
608next_trigger(double d, sc_time_unit u, const sc_event_or_list &eol)
609{
610 next_trigger(sc_time(d, u), eol);
611}
612
613void
614next_trigger(const sc_time &t, const sc_event_and_list &eal)
615{
616 sc_gem5::Process *p = sc_gem5::scheduler.current();
617 p->setTimeout(t);
618 ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal);
619}
620
621void
622next_trigger(double d, sc_time_unit u, const sc_event_and_list &eal)
623{
624 next_trigger(sc_time(d, u), eal);
625}
626
627bool
628timed_out()
629{
630 ::sc_gem5::Process *p = sc_gem5::scheduler.current();
631 if (!p)
632 return false;
633 else
634 return p->timedOut();
635}
636
637
638namespace
639{
640
641bool
642waitErrorCheck(sc_gem5::Process *p)
643{
644 if (p->procKind() == SC_METHOD_PROC_) {
645 SC_REPORT_ERROR(
646 "(E519) wait() is only allowed in SC_THREADs and SC_CTHREADs",
647 "\n in SC_METHODs use next_trigger() instead");
648 return true;
649 }
650 return false;
651}
652
653} // anonymous namespace
654
655void
656wait()
657{
658 sc_gem5::Process *p = sc_gem5::scheduler.current();
659 if (waitErrorCheck(p))
660 return;
661 p->cancelTimeout();
662 p->clearDynamic();
663 sc_gem5::scheduler.yield();
664}
665
666void
667wait(int n)
668{
669 if (n <= 0) {
670 std::string msg = csprintf("n = %d", n);
671 SC_REPORT_ERROR("(E525) wait(n) is only valid for n > 0", msg.c_str());
672 }
673 sc_gem5::Process *p = sc_gem5::scheduler.current();
674 p->waitCount(n - 1);
675 wait();
676}
677
678void
679wait(const sc_event &e)
680{
681 sc_gem5::Process *p = sc_gem5::scheduler.current();
682 if (waitErrorCheck(p))
683 return;
684 p->cancelTimeout();
685 ::sc_gem5::newDynamicSensitivityEvent(p, &e);
686 sc_gem5::scheduler.yield();
687}
688
689void
690wait(const sc_event_or_list &eol)
691{
692 sc_gem5::Process *p = sc_gem5::scheduler.current();
693 if (waitErrorCheck(p))
694 return;
695 p->cancelTimeout();
696 ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol);
697 sc_gem5::scheduler.yield();
698}
699
700void
701wait(const sc_event_and_list &eal)
702{
703 sc_gem5::Process *p = sc_gem5::scheduler.current();
704 if (waitErrorCheck(p))
705 return;
706 p->cancelTimeout();
707 ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal);
708 sc_gem5::scheduler.yield();
709}
710
711void
712wait(const sc_time &t)
713{
714 sc_gem5::Process *p = sc_gem5::scheduler.current();
715 if (waitErrorCheck(p))
716 return;
717 p->setTimeout(t);
718 p->clearDynamic();
719 sc_gem5::scheduler.yield();
720}
721
722void
723wait(double d, sc_time_unit u)
724{
725 wait(sc_time(d, u));
726}
727
728void
729wait(const sc_time &t, const sc_event &e)
730{
731 sc_gem5::Process *p = sc_gem5::scheduler.current();
732 if (waitErrorCheck(p))
733 return;
734 p->setTimeout(t);
735 ::sc_gem5::newDynamicSensitivityEvent(p, &e);
736 sc_gem5::scheduler.yield();
737}
738
739void
740wait(double d, sc_time_unit u, const sc_event &e)
741{
742 wait(sc_time(d, u), e);
743}
744
745void
746wait(const sc_time &t, const sc_event_or_list &eol)
747{
748 sc_gem5::Process *p = sc_gem5::scheduler.current();
749 if (waitErrorCheck(p))
750 return;
751 p->setTimeout(t);
752 ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol);
753 sc_gem5::scheduler.yield();
754}
755
756void
757wait(double d, sc_time_unit u, const sc_event_or_list &eol)
758{
759 wait(sc_time(d, u), eol);
760}
761
762void
763wait(const sc_time &t, const sc_event_and_list &eal)
764{
765 sc_gem5::Process *p = sc_gem5::scheduler.current();
766 if (waitErrorCheck(p))
767 return;
768 p->setTimeout(t);
769 ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal);
770 sc_gem5::scheduler.yield();
771}
772
773void
774wait(double d, sc_time_unit u, const sc_event_and_list &eal)
775{
776 wait(sc_time(d, u), eal);
777}
778
779void
780halt()
781{
782 ::sc_core::wait();
783 throw ::sc_gem5::ScHalt();
784}
785
786void
787at_posedge(const sc_signal_in_if<bool> &s)
788{
789 while (s.read())
790 wait();
791 while (!s.read())
792 wait();
793}
794
795void
796at_posedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
797{
798 while (s.read() == sc_dt::Log_1)
799 wait();
800 while (s.read() == sc_dt::Log_0)
801 wait();
802}
803
804void
805at_negedge(const sc_signal_in_if<bool> &s)
806{
807 while (!s.read())
808 wait();
809 while (s.read())
810 wait();
811}
812
813void
814at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
815{
816 while (s.read() == sc_dt::Log_0)
817 wait();
818 while (s.read() == sc_dt::Log_1)
819 wait();
820}
821
822const char *
823sc_gen_unique_name(const char *seed)
824{
825 auto mod = sc_gem5::pickParentModule();
826 if (mod)
827 return mod->uniqueName(seed);
828 sc_gem5::Process *p = sc_gem5::scheduler.current();
829 if (p)
830 return p->uniqueName(seed);
831 return ::sc_gem5::nameGen.gen(seed);
832}
833
834bool
835sc_hierarchical_name_exists(const char *name)
836{
837 return sc_gem5::findEvent(name) != sc_gem5::allEvents.end() ||
838 ::sc_gem5::findObject(name, sc_gem5::allObjects);
839}
840
841bool
842sc_start_of_simulation_invoked()
843{
844 return ::sc_gem5::kernel->startOfSimulationComplete();
845}
846
847bool
848sc_end_of_simulation_invoked()
849{
850 return ::sc_gem5::kernel->endOfSimulationComplete();
851}
852
853sc_module *
854sc_module_sc_new(sc_module *mod)
855{
856 static std::vector<std::unique_ptr<sc_module> > modules;
857 modules.emplace_back(mod);
858 return mod;
859}
860
861} // namespace sc_core