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