sc_module.cc revision 13285:86dc66ffac35
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/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    if (sc_is_running()) {
226        SC_REPORT_ERROR("(E529) insert module failed", "simulation running");
227        std::cout << "Running!\n";
228    }
229    if (::sc_gem5::scheduler.elaborationDone()) {
230        SC_REPORT_ERROR("(E529) insert module failed", "elaboration done");
231        std::cout << "Elaboration done!\n";
232    }
233}
234
235sc_module::sc_module(const sc_module_name &) : sc_module() {}
236sc_module::sc_module(const char *_name) : sc_module(sc_module_name(_name))
237{
238    _gem5_module->deprecatedConstructor();
239    SC_REPORT_WARNING("(W569) sc_module(const char*), "
240            "sc_module(const std::string&) have been deprecated, use "
241            "sc_module(const sc_module_name&)", _name);
242}
243sc_module::sc_module(const std::string &_name) :
244    sc_module(sc_module_name(_name.c_str()))
245{
246    _gem5_module->deprecatedConstructor();
247    SC_REPORT_WARNING("(W569) sc_module(const char*), "
248            "sc_module(const std::string&) have been deprecated, use "
249            "sc_module(const sc_module_name&)", _name.c_str());
250}
251
252void
253sc_module::end_module()
254{
255    _gem5_module->endModule();
256}
257
258void
259sc_module::reset_signal_is(const sc_in<bool> &port, bool val)
260{
261    sc_gem5::newResetSensitivityPort(
262            ::sc_gem5::Process::newest(), &port, val, true);
263}
264
265void
266sc_module::reset_signal_is(const sc_inout<bool> &port, bool val)
267{
268    sc_gem5::newResetSensitivityPort(
269            ::sc_gem5::Process::newest(), &port, val, true);
270}
271
272void
273sc_module::reset_signal_is(const sc_out<bool> &port, bool val)
274{
275    sc_gem5::newResetSensitivityPort(
276            ::sc_gem5::Process::newest(), &port, val, true);
277}
278
279void
280sc_module::reset_signal_is(const sc_signal_in_if<bool> &signal, bool val)
281{
282    sc_gem5::newResetSensitivitySignal(
283            ::sc_gem5::Process::newest(), &signal, val, true);
284}
285
286
287void
288sc_module::async_reset_signal_is(const sc_in<bool> &port, bool val)
289{
290    sc_gem5::newResetSensitivityPort(
291            ::sc_gem5::Process::newest(), &port, val, false);
292}
293
294void
295sc_module::async_reset_signal_is(const sc_inout<bool> &port, bool val)
296{
297    sc_gem5::newResetSensitivityPort(
298            ::sc_gem5::Process::newest(), &port, val, false);
299}
300
301void
302sc_module::async_reset_signal_is(const sc_out<bool> &port, bool val)
303{
304    sc_gem5::newResetSensitivityPort(
305            ::sc_gem5::Process::newest(), &port, val, false);
306}
307
308void
309sc_module::async_reset_signal_is(const sc_signal_in_if<bool> &signal, bool val)
310{
311    sc_gem5::newResetSensitivitySignal(
312            ::sc_gem5::Process::newest(), &signal, val, false);
313}
314
315
316void
317sc_module::dont_initialize()
318{
319    ::sc_gem5::Process::newest()->dontInitialize(true);
320}
321
322void
323sc_module::set_stack_size(size_t size)
324{
325    ::sc_gem5::Process::newest()->setStackSize(size);
326}
327
328
329void sc_module::next_trigger() { ::sc_core::next_trigger(); }
330
331void
332sc_module::next_trigger(const sc_event &e)
333{
334    ::sc_core::next_trigger(e);
335}
336
337void
338sc_module::next_trigger(const sc_event_or_list &eol)
339{
340    ::sc_core::next_trigger(eol);
341}
342
343void
344sc_module::next_trigger(const sc_event_and_list &eal)
345{
346    ::sc_core::next_trigger(eal);
347}
348
349void
350sc_module::next_trigger(const sc_time &t)
351{
352    ::sc_core::next_trigger(t);
353}
354
355void
356sc_module::next_trigger(double d, sc_time_unit u)
357{
358    ::sc_core::next_trigger(d, u);
359}
360
361void
362sc_module::next_trigger(const sc_time &t, const sc_event &e)
363{
364    ::sc_core::next_trigger(t, e);
365}
366
367void
368sc_module::next_trigger(double d, sc_time_unit u, const sc_event &e)
369{
370    ::sc_core::next_trigger(d, u, e);
371}
372
373void
374sc_module::next_trigger(const sc_time &t, const sc_event_or_list &eol)
375{
376    ::sc_core::next_trigger(t, eol);
377}
378
379void
380sc_module::next_trigger(double d, sc_time_unit u, const sc_event_or_list &eol)
381{
382    ::sc_core::next_trigger(d, u, eol);
383}
384
385void
386sc_module::next_trigger(const sc_time &t, const sc_event_and_list &eal)
387{
388    ::sc_core::next_trigger(t, eal);
389}
390
391void
392sc_module::next_trigger(double d, sc_time_unit u, const sc_event_and_list &eal)
393{
394    ::sc_core::next_trigger(d, u, eal);
395}
396
397
398bool
399sc_module::timed_out()
400{
401    return ::sc_core::timed_out();
402}
403
404
405void
406sc_module::wait()
407{
408    ::sc_core::wait();
409}
410
411void
412sc_module::wait(int i)
413{
414    ::sc_core::wait(i);
415}
416
417void
418sc_module::wait(const sc_event &e)
419{
420    ::sc_core::wait(e);
421}
422
423void
424sc_module::wait(const sc_event_or_list &eol)
425{
426    ::sc_core::wait(eol);
427}
428
429void
430sc_module::wait(const sc_event_and_list &eal)
431{
432    ::sc_core::wait(eal);
433}
434
435void
436sc_module::wait(const sc_time &t)
437{
438    ::sc_core::wait(t);
439}
440
441void
442sc_module::wait(double d, sc_time_unit u)
443{
444    ::sc_core::wait(d, u);
445}
446
447void
448sc_module::wait(const sc_time &t, const sc_event &e)
449{
450    ::sc_core::wait(t, e);
451}
452
453void
454sc_module::wait(double d, sc_time_unit u, const sc_event &e)
455{
456    ::sc_core::wait(d, u, e);
457}
458
459void
460sc_module::wait(const sc_time &t, const sc_event_or_list &eol)
461{
462    ::sc_core::wait(t, eol);
463}
464
465void
466sc_module::wait(double d, sc_time_unit u, const sc_event_or_list &eol)
467{
468    ::sc_core::wait(d, u, eol);
469}
470
471void
472sc_module::wait(const sc_time &t, const sc_event_and_list &eal)
473{
474    ::sc_core::wait(t, eal);
475}
476
477void
478sc_module::wait(double d, sc_time_unit u, const sc_event_and_list &eal)
479{
480    ::sc_core::wait(d, u, eal);
481}
482
483
484void
485sc_module::halt()
486{
487    ::sc_core::halt();
488}
489
490void
491sc_module::at_posedge(const sc_signal_in_if<bool> &s)
492{
493    ::sc_core::at_posedge(s);
494}
495
496void
497sc_module::at_posedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
498{
499    ::sc_core::at_posedge(s);
500}
501
502void
503sc_module::at_negedge(const sc_signal_in_if<bool> &s)
504{
505    ::sc_core::at_negedge(s);
506}
507
508void
509sc_module::at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
510{
511    ::sc_core::at_negedge(s);
512}
513
514
515void
516next_trigger()
517{
518    sc_gem5::Process *p = sc_gem5::scheduler.current();
519    p->cancelTimeout();
520    p->clearDynamic();
521}
522
523void
524next_trigger(const sc_event &e)
525{
526    sc_gem5::Process *p = sc_gem5::scheduler.current();
527    p->cancelTimeout();
528    ::sc_gem5::newDynamicSensitivityEvent(p, &e);
529}
530
531void
532next_trigger(const sc_event_or_list &eol)
533{
534    sc_gem5::Process *p = sc_gem5::scheduler.current();
535    p->cancelTimeout();
536    ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol);
537}
538
539void
540next_trigger(const sc_event_and_list &eal)
541{
542    sc_gem5::Process *p = sc_gem5::scheduler.current();
543    p->cancelTimeout();
544    ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal);
545}
546
547void
548next_trigger(const sc_time &t)
549{
550    sc_gem5::Process *p = sc_gem5::scheduler.current();
551    p->setTimeout(t);
552    p->clearDynamic();
553}
554
555void
556next_trigger(double d, sc_time_unit u)
557{
558    next_trigger(sc_time(d, u));
559}
560
561void
562next_trigger(const sc_time &t, const sc_event &e)
563{
564    sc_gem5::Process *p = sc_gem5::scheduler.current();
565    p->setTimeout(t);
566    ::sc_gem5::newDynamicSensitivityEvent(p, &e);
567}
568
569void
570next_trigger(double d, sc_time_unit u, const sc_event &e)
571{
572    next_trigger(sc_time(d, u), e);
573}
574
575void
576next_trigger(const sc_time &t, const sc_event_or_list &eol)
577{
578    sc_gem5::Process *p = sc_gem5::scheduler.current();
579    p->setTimeout(t);
580    ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol);
581}
582
583void
584next_trigger(double d, sc_time_unit u, const sc_event_or_list &eol)
585{
586    next_trigger(sc_time(d, u), eol);
587}
588
589void
590next_trigger(const sc_time &t, const sc_event_and_list &eal)
591{
592    sc_gem5::Process *p = sc_gem5::scheduler.current();
593    p->setTimeout(t);
594    ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal);
595}
596
597void
598next_trigger(double d, sc_time_unit u, const sc_event_and_list &eal)
599{
600    next_trigger(sc_time(d, u), eal);
601}
602
603bool
604timed_out()
605{
606    ::sc_gem5::Process *p = sc_gem5::scheduler.current();
607    if (!p)
608        return false;
609    else
610        return p->timedOut();
611}
612
613
614namespace
615{
616
617bool
618waitErrorCheck(sc_gem5::Process *p)
619{
620    if (p->procKind() == SC_METHOD_PROC_) {
621        SC_REPORT_ERROR(
622                "(E519) wait() is only allowed in SC_THREADs and SC_CTHREADs",
623                "\n        in SC_METHODs use next_trigger() instead");
624        return true;
625    }
626    return false;
627}
628
629} // anonymous namespace
630
631void
632wait()
633{
634    sc_gem5::Process *p = sc_gem5::scheduler.current();
635    if (waitErrorCheck(p))
636        return;
637    p->cancelTimeout();
638    p->clearDynamic();
639    sc_gem5::scheduler.yield();
640}
641
642void
643wait(int n)
644{
645    if (n <= 0) {
646        std::string msg = csprintf("n = %d", n);
647        SC_REPORT_ERROR("(E525) wait(n) is only valid for n > 0", msg.c_str());
648    }
649    sc_gem5::Process *p = sc_gem5::scheduler.current();
650    p->waitCount(n - 1);
651    wait();
652}
653
654void
655wait(const sc_event &e)
656{
657    sc_gem5::Process *p = sc_gem5::scheduler.current();
658    if (waitErrorCheck(p))
659        return;
660    p->cancelTimeout();
661    ::sc_gem5::newDynamicSensitivityEvent(p, &e);
662    sc_gem5::scheduler.yield();
663}
664
665void
666wait(const sc_event_or_list &eol)
667{
668    sc_gem5::Process *p = sc_gem5::scheduler.current();
669    if (waitErrorCheck(p))
670        return;
671    p->cancelTimeout();
672    ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol);
673    sc_gem5::scheduler.yield();
674}
675
676void
677wait(const sc_event_and_list &eal)
678{
679    sc_gem5::Process *p = sc_gem5::scheduler.current();
680    if (waitErrorCheck(p))
681        return;
682    p->cancelTimeout();
683    ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal);
684    sc_gem5::scheduler.yield();
685}
686
687void
688wait(const sc_time &t)
689{
690    sc_gem5::Process *p = sc_gem5::scheduler.current();
691    if (waitErrorCheck(p))
692        return;
693    p->setTimeout(t);
694    p->clearDynamic();
695    sc_gem5::scheduler.yield();
696}
697
698void
699wait(double d, sc_time_unit u)
700{
701    wait(sc_time(d, u));
702}
703
704void
705wait(const sc_time &t, const sc_event &e)
706{
707    sc_gem5::Process *p = sc_gem5::scheduler.current();
708    if (waitErrorCheck(p))
709        return;
710    p->setTimeout(t);
711    ::sc_gem5::newDynamicSensitivityEvent(p, &e);
712    sc_gem5::scheduler.yield();
713}
714
715void
716wait(double d, sc_time_unit u, const sc_event &e)
717{
718    wait(sc_time(d, u), e);
719}
720
721void
722wait(const sc_time &t, const sc_event_or_list &eol)
723{
724    sc_gem5::Process *p = sc_gem5::scheduler.current();
725    if (waitErrorCheck(p))
726        return;
727    p->setTimeout(t);
728    ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol);
729    sc_gem5::scheduler.yield();
730}
731
732void
733wait(double d, sc_time_unit u, const sc_event_or_list &eol)
734{
735    wait(sc_time(d, u), eol);
736}
737
738void
739wait(const sc_time &t, const sc_event_and_list &eal)
740{
741    sc_gem5::Process *p = sc_gem5::scheduler.current();
742    if (waitErrorCheck(p))
743        return;
744    p->setTimeout(t);
745    ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal);
746    sc_gem5::scheduler.yield();
747}
748
749void
750wait(double d, sc_time_unit u, const sc_event_and_list &eal)
751{
752    wait(sc_time(d, u), eal);
753}
754
755void
756halt()
757{
758    ::sc_core::wait();
759    throw ::sc_gem5::ScHalt();
760}
761
762void
763at_posedge(const sc_signal_in_if<bool> &s)
764{
765    while (s.read())
766        wait();
767    while (!s.read())
768        wait();
769}
770
771void
772at_posedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
773{
774    while (s.read() == sc_dt::Log_1)
775        wait();
776    while (s.read() == sc_dt::Log_0)
777        wait();
778}
779
780void
781at_negedge(const sc_signal_in_if<bool> &s)
782{
783    while (!s.read())
784        wait();
785    while (s.read())
786        wait();
787}
788
789void
790at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
791{
792    while (s.read() == sc_dt::Log_0)
793        wait();
794    while (s.read() == sc_dt::Log_1)
795        wait();
796}
797
798const char *
799sc_gen_unique_name(const char *seed)
800{
801    auto mod = sc_gem5::pickParentModule();
802    if (mod)
803        return mod->uniqueName(seed);
804    sc_gem5::Process *p = sc_gem5::scheduler.current();
805    if (p)
806        return p->uniqueName(seed);
807    return ::sc_gem5::nameGen.gen(seed);
808}
809
810bool
811sc_hierarchical_name_exists(const char *name)
812{
813    return sc_gem5::findEvent(name) != sc_gem5::allEvents.end() ||
814        ::sc_gem5::findObject(name, sc_gem5::allObjects);
815}
816
817bool
818sc_start_of_simulation_invoked()
819{
820    return ::sc_gem5::kernel->startOfSimulationComplete();
821}
822
823bool
824sc_end_of_simulation_invoked()
825{
826    return ::sc_gem5::kernel->endOfSimulationComplete();
827}
828
829sc_module *
830sc_module_sc_new(sc_module *mod)
831{
832    static std::vector<std::unique_ptr<sc_module> > modules;
833    modules.emplace_back(mod);
834    return mod;
835}
836
837} // namespace sc_core
838