sc_module.cc revision 13280
112837Sgabeblack@google.com/*
212837Sgabeblack@google.com * Copyright 2018 Google, Inc.
312837Sgabeblack@google.com *
412837Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
512837Sgabeblack@google.com * modification, are permitted provided that the following conditions are
612837Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
712837Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
812837Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
912837Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
1012837Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
1112837Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
1212837Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
1312837Sgabeblack@google.com * this software without specific prior written permission.
1412837Sgabeblack@google.com *
1512837Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1612837Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1712837Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1812837Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1912837Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2012837Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2112837Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2212837Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2312837Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2412837Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2512837Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2612837Sgabeblack@google.com *
2712837Sgabeblack@google.com * Authors: Gabe Black
2812837Sgabeblack@google.com */
2912837Sgabeblack@google.com
3012901Sgabeblack@google.com#include <memory>
3113135Sgabeblack@google.com#include <string>
3212901Sgabeblack@google.com#include <vector>
3312901Sgabeblack@google.com
3412837Sgabeblack@google.com#include "base/logging.hh"
3513280Sgabeblack@google.com#include "systemc/core/event.hh"
3612982Sgabeblack@google.com#include "systemc/core/kernel.hh"
3712951Sgabeblack@google.com#include "systemc/core/module.hh"
3813280Sgabeblack@google.com#include "systemc/core/object.hh"
3912953Sgabeblack@google.com#include "systemc/core/process_types.hh"
4013260Sgabeblack@google.com#include "systemc/core/sensitivity.hh"
4113155Sgabeblack@google.com#include "systemc/ext/channel/sc_signal_in_if.hh"
4212837Sgabeblack@google.com#include "systemc/ext/core/sc_module.hh"
4312951Sgabeblack@google.com#include "systemc/ext/core/sc_module_name.hh"
4413155Sgabeblack@google.com#include "systemc/ext/dt/bit/sc_logic.hh"
4513135Sgabeblack@google.com#include "systemc/ext/utils/sc_report_handler.hh"
4612837Sgabeblack@google.com
4712952Sgabeblack@google.comnamespace sc_gem5
4812952Sgabeblack@google.com{
4912952Sgabeblack@google.com
5012952Sgabeblack@google.comProcess *
5112952Sgabeblack@google.comnewMethodProcess(const char *name, ProcessFuncWrapper *func)
5212952Sgabeblack@google.com{
5313135Sgabeblack@google.com    Method *p = new Method(name, func);
5413135Sgabeblack@google.com    if (::sc_core::sc_is_running()) {
5513135Sgabeblack@google.com        std::string name = p->name();
5613135Sgabeblack@google.com        delete p;
5713135Sgabeblack@google.com        SC_REPORT_ERROR("(E541) call to SC_METHOD in sc_module while "
5813135Sgabeblack@google.com                "simulation running", name.c_str());
5913135Sgabeblack@google.com        return nullptr;
6013135Sgabeblack@google.com    }
6112993Sgabeblack@google.com    scheduler.reg(p);
6212993Sgabeblack@google.com    return p;
6312952Sgabeblack@google.com}
6412952Sgabeblack@google.com
6512952Sgabeblack@google.comProcess *
6612952Sgabeblack@google.comnewThreadProcess(const char *name, ProcessFuncWrapper *func)
6712952Sgabeblack@google.com{
6813135Sgabeblack@google.com    Thread *p = new Thread(name, func);
6913135Sgabeblack@google.com    if (::sc_core::sc_is_running()) {
7013135Sgabeblack@google.com        std::string name = p->name();
7113135Sgabeblack@google.com        delete p;
7213135Sgabeblack@google.com        SC_REPORT_ERROR("(E542) call to SC_THREAD in sc_module while "
7313135Sgabeblack@google.com                "simulation running", name.c_str());
7413135Sgabeblack@google.com        return nullptr;
7513135Sgabeblack@google.com    }
7612993Sgabeblack@google.com    scheduler.reg(p);
7712993Sgabeblack@google.com    return p;
7812952Sgabeblack@google.com}
7912952Sgabeblack@google.com
8012952Sgabeblack@google.comProcess *
8112952Sgabeblack@google.comnewCThreadProcess(const char *name, ProcessFuncWrapper *func)
8212952Sgabeblack@google.com{
8313135Sgabeblack@google.com    CThread *p = new CThread(name, func);
8413135Sgabeblack@google.com    if (::sc_core::sc_is_running()) {
8513135Sgabeblack@google.com        std::string name = p->name();
8613135Sgabeblack@google.com        delete p;
8713135Sgabeblack@google.com        SC_REPORT_ERROR("(E543) call to SC_CTHREAD in sc_module while "
8813135Sgabeblack@google.com                "simulation running", name.c_str());
8913135Sgabeblack@google.com        return nullptr;
9013135Sgabeblack@google.com    }
9112993Sgabeblack@google.com    scheduler.reg(p);
9213194Sgabeblack@google.com    p->dontInitialize(true);
9312993Sgabeblack@google.com    return p;
9412952Sgabeblack@google.com}
9512952Sgabeblack@google.com
9613035Sgabeblack@google.comUniqueNameGen nameGen;
9713035Sgabeblack@google.com
9812952Sgabeblack@google.com} // namespace sc_gem5
9912952Sgabeblack@google.com
10012837Sgabeblack@google.comnamespace sc_core
10112837Sgabeblack@google.com{
10212837Sgabeblack@google.com
10313091Sgabeblack@google.comsc_bind_proxy::sc_bind_proxy(sc_interface &_interface) :
10412951Sgabeblack@google.com    _interface(&_interface), _port(nullptr)
10512951Sgabeblack@google.com{}
10612837Sgabeblack@google.com
10713091Sgabeblack@google.comsc_bind_proxy::sc_bind_proxy(sc_port_base &_port) :
10812951Sgabeblack@google.com    _interface(nullptr), _port(&_port)
10912951Sgabeblack@google.com{}
11012837Sgabeblack@google.com
11113091Sgabeblack@google.comconst sc_bind_proxy SC_BIND_PROXY_NUL(*(sc_port_base *)nullptr);
11212837Sgabeblack@google.com
11312982Sgabeblack@google.comsc_module::~sc_module() { delete _gem5_module; }
11412837Sgabeblack@google.com
11513091Sgabeblack@google.comconst sc_bind_proxy SC_BIND_PROXY_NIL(*(sc_port_base *)nullptr);
11612837Sgabeblack@google.com
11712837Sgabeblack@google.comvoid
11812837Sgabeblack@google.comsc_module::operator () (const sc_bind_proxy &p001,
11912837Sgabeblack@google.com                        const sc_bind_proxy &p002,
12012837Sgabeblack@google.com                        const sc_bind_proxy &p003,
12112837Sgabeblack@google.com                        const sc_bind_proxy &p004,
12212837Sgabeblack@google.com                        const sc_bind_proxy &p005,
12312837Sgabeblack@google.com                        const sc_bind_proxy &p006,
12412837Sgabeblack@google.com                        const sc_bind_proxy &p007,
12512837Sgabeblack@google.com                        const sc_bind_proxy &p008,
12612837Sgabeblack@google.com                        const sc_bind_proxy &p009,
12712837Sgabeblack@google.com                        const sc_bind_proxy &p010,
12812837Sgabeblack@google.com                        const sc_bind_proxy &p011,
12912837Sgabeblack@google.com                        const sc_bind_proxy &p012,
13012837Sgabeblack@google.com                        const sc_bind_proxy &p013,
13112837Sgabeblack@google.com                        const sc_bind_proxy &p014,
13212837Sgabeblack@google.com                        const sc_bind_proxy &p015,
13312837Sgabeblack@google.com                        const sc_bind_proxy &p016,
13412837Sgabeblack@google.com                        const sc_bind_proxy &p017,
13512837Sgabeblack@google.com                        const sc_bind_proxy &p018,
13612837Sgabeblack@google.com                        const sc_bind_proxy &p019,
13712837Sgabeblack@google.com                        const sc_bind_proxy &p020,
13812837Sgabeblack@google.com                        const sc_bind_proxy &p021,
13912837Sgabeblack@google.com                        const sc_bind_proxy &p022,
14012837Sgabeblack@google.com                        const sc_bind_proxy &p023,
14112837Sgabeblack@google.com                        const sc_bind_proxy &p024,
14212837Sgabeblack@google.com                        const sc_bind_proxy &p025,
14312837Sgabeblack@google.com                        const sc_bind_proxy &p026,
14412837Sgabeblack@google.com                        const sc_bind_proxy &p027,
14512837Sgabeblack@google.com                        const sc_bind_proxy &p028,
14612837Sgabeblack@google.com                        const sc_bind_proxy &p029,
14712837Sgabeblack@google.com                        const sc_bind_proxy &p030,
14812837Sgabeblack@google.com                        const sc_bind_proxy &p031,
14912837Sgabeblack@google.com                        const sc_bind_proxy &p032,
15012837Sgabeblack@google.com                        const sc_bind_proxy &p033,
15112837Sgabeblack@google.com                        const sc_bind_proxy &p034,
15212837Sgabeblack@google.com                        const sc_bind_proxy &p035,
15312837Sgabeblack@google.com                        const sc_bind_proxy &p036,
15412837Sgabeblack@google.com                        const sc_bind_proxy &p037,
15512837Sgabeblack@google.com                        const sc_bind_proxy &p038,
15612837Sgabeblack@google.com                        const sc_bind_proxy &p039,
15712837Sgabeblack@google.com                        const sc_bind_proxy &p040,
15812837Sgabeblack@google.com                        const sc_bind_proxy &p041,
15912837Sgabeblack@google.com                        const sc_bind_proxy &p042,
16012837Sgabeblack@google.com                        const sc_bind_proxy &p043,
16112837Sgabeblack@google.com                        const sc_bind_proxy &p044,
16212837Sgabeblack@google.com                        const sc_bind_proxy &p045,
16312837Sgabeblack@google.com                        const sc_bind_proxy &p046,
16412837Sgabeblack@google.com                        const sc_bind_proxy &p047,
16512837Sgabeblack@google.com                        const sc_bind_proxy &p048,
16612837Sgabeblack@google.com                        const sc_bind_proxy &p049,
16712837Sgabeblack@google.com                        const sc_bind_proxy &p050,
16812837Sgabeblack@google.com                        const sc_bind_proxy &p051,
16912837Sgabeblack@google.com                        const sc_bind_proxy &p052,
17012837Sgabeblack@google.com                        const sc_bind_proxy &p053,
17112837Sgabeblack@google.com                        const sc_bind_proxy &p054,
17212837Sgabeblack@google.com                        const sc_bind_proxy &p055,
17312837Sgabeblack@google.com                        const sc_bind_proxy &p056,
17412837Sgabeblack@google.com                        const sc_bind_proxy &p057,
17512837Sgabeblack@google.com                        const sc_bind_proxy &p058,
17612837Sgabeblack@google.com                        const sc_bind_proxy &p059,
17712837Sgabeblack@google.com                        const sc_bind_proxy &p060,
17812837Sgabeblack@google.com                        const sc_bind_proxy &p061,
17912837Sgabeblack@google.com                        const sc_bind_proxy &p062,
18012837Sgabeblack@google.com                        const sc_bind_proxy &p063,
18112837Sgabeblack@google.com                        const sc_bind_proxy &p064)
18212837Sgabeblack@google.com{
18313091Sgabeblack@google.com    std::vector<const ::sc_core::sc_bind_proxy *> proxies;
18413091Sgabeblack@google.com    auto insert = [&proxies](const ::sc_core::sc_bind_proxy &p) -> bool {
18513091Sgabeblack@google.com        if (!p.port() && !p.interface())
18613091Sgabeblack@google.com            return false;
18713091Sgabeblack@google.com        proxies.push_back(&p);
18813091Sgabeblack@google.com        return true;
18913091Sgabeblack@google.com    };
19013091Sgabeblack@google.com    insert(p001) && insert(p002) && insert(p003) && insert(p004) &&
19113091Sgabeblack@google.com    insert(p005) && insert(p006) && insert(p007) && insert(p008) &&
19213091Sgabeblack@google.com    insert(p009) && insert(p010) && insert(p011) && insert(p012) &&
19313091Sgabeblack@google.com    insert(p013) && insert(p014) && insert(p015) && insert(p016) &&
19413091Sgabeblack@google.com    insert(p017) && insert(p018) && insert(p019) && insert(p020) &&
19513091Sgabeblack@google.com    insert(p021) && insert(p022) && insert(p023) && insert(p024) &&
19613091Sgabeblack@google.com    insert(p025) && insert(p026) && insert(p027) && insert(p028) &&
19713091Sgabeblack@google.com    insert(p029) && insert(p030) && insert(p031) && insert(p032) &&
19813091Sgabeblack@google.com    insert(p033) && insert(p034) && insert(p035) && insert(p036) &&
19913091Sgabeblack@google.com    insert(p037) && insert(p038) && insert(p039) && insert(p040) &&
20013091Sgabeblack@google.com    insert(p041) && insert(p042) && insert(p043) && insert(p044) &&
20113091Sgabeblack@google.com    insert(p045) && insert(p046) && insert(p047) && insert(p048) &&
20213091Sgabeblack@google.com    insert(p049) && insert(p050) && insert(p051) && insert(p052) &&
20313091Sgabeblack@google.com    insert(p053) && insert(p054) && insert(p055) && insert(p056) &&
20413091Sgabeblack@google.com    insert(p057) && insert(p058) && insert(p059) && insert(p060) &&
20513091Sgabeblack@google.com    insert(p061) && insert(p062) && insert(p063) && insert(p064);
20613091Sgabeblack@google.com    _gem5_module->bindPorts(proxies);
20712837Sgabeblack@google.com}
20812837Sgabeblack@google.com
20912837Sgabeblack@google.comconst std::vector<sc_object *> &
21012837Sgabeblack@google.comsc_module::get_child_objects() const
21112837Sgabeblack@google.com{
21212951Sgabeblack@google.com    return _gem5_module->obj()->get_child_objects();
21312837Sgabeblack@google.com}
21412837Sgabeblack@google.com
21512837Sgabeblack@google.comconst std::vector<sc_event *> &
21612837Sgabeblack@google.comsc_module::get_child_events() const
21712837Sgabeblack@google.com{
21812951Sgabeblack@google.com    return _gem5_module->obj()->get_child_events();
21912837Sgabeblack@google.com}
22012837Sgabeblack@google.com
22112951Sgabeblack@google.comsc_module::sc_module() :
22213079Sgabeblack@google.com    sc_object(sc_gem5::newModuleChecked()->name()),
22312951Sgabeblack@google.com    _gem5_module(sc_gem5::currentModule())
22412951Sgabeblack@google.com{}
22512837Sgabeblack@google.com
22612951Sgabeblack@google.comsc_module::sc_module(const sc_module_name &) : sc_module() {}
22713191Sgabeblack@google.comsc_module::sc_module(const char *_name) : sc_module(sc_module_name(_name))
22813191Sgabeblack@google.com{
22913191Sgabeblack@google.com    _gem5_module->deprecatedConstructor();
23013191Sgabeblack@google.com    SC_REPORT_WARNING("(W569) sc_module(const char*), "
23113191Sgabeblack@google.com            "sc_module(const std::string&) have been deprecated, use "
23213191Sgabeblack@google.com            "sc_module(const sc_module_name&)", _name);
23313191Sgabeblack@google.com}
23412951Sgabeblack@google.comsc_module::sc_module(const std::string &_name) :
23512951Sgabeblack@google.com    sc_module(sc_module_name(_name.c_str()))
23613191Sgabeblack@google.com{
23713191Sgabeblack@google.com    _gem5_module->deprecatedConstructor();
23813191Sgabeblack@google.com    SC_REPORT_WARNING("(W569) sc_module(const char*), "
23913191Sgabeblack@google.com            "sc_module(const std::string&) have been deprecated, use "
24013191Sgabeblack@google.com            "sc_module(const sc_module_name&)", _name.c_str());
24113191Sgabeblack@google.com}
24213191Sgabeblack@google.com
24313191Sgabeblack@google.comvoid
24413191Sgabeblack@google.comsc_module::end_module()
24513191Sgabeblack@google.com{
24613191Sgabeblack@google.com    _gem5_module->endModule();
24713191Sgabeblack@google.com}
24812928Sgabeblack@google.com
24912837Sgabeblack@google.comvoid
25013260Sgabeblack@google.comsc_module::reset_signal_is(const sc_in<bool> &port, bool val)
25112837Sgabeblack@google.com{
25213260Sgabeblack@google.com    sc_gem5::newResetSensitivityPort(
25313260Sgabeblack@google.com            ::sc_gem5::Process::newest(), &port, val, true);
25412837Sgabeblack@google.com}
25512837Sgabeblack@google.com
25612837Sgabeblack@google.comvoid
25713260Sgabeblack@google.comsc_module::reset_signal_is(const sc_inout<bool> &port, bool val)
25812837Sgabeblack@google.com{
25913260Sgabeblack@google.com    sc_gem5::newResetSensitivityPort(
26013260Sgabeblack@google.com            ::sc_gem5::Process::newest(), &port, val, true);
26112837Sgabeblack@google.com}
26212837Sgabeblack@google.com
26312837Sgabeblack@google.comvoid
26413260Sgabeblack@google.comsc_module::reset_signal_is(const sc_out<bool> &port, bool val)
26512837Sgabeblack@google.com{
26613260Sgabeblack@google.com    sc_gem5::newResetSensitivityPort(
26713260Sgabeblack@google.com            ::sc_gem5::Process::newest(), &port, val, true);
26812837Sgabeblack@google.com}
26912837Sgabeblack@google.com
27012837Sgabeblack@google.comvoid
27113260Sgabeblack@google.comsc_module::reset_signal_is(const sc_signal_in_if<bool> &signal, bool val)
27212837Sgabeblack@google.com{
27313260Sgabeblack@google.com    sc_gem5::newResetSensitivitySignal(
27413260Sgabeblack@google.com            ::sc_gem5::Process::newest(), &signal, val, true);
27512837Sgabeblack@google.com}
27612837Sgabeblack@google.com
27712837Sgabeblack@google.com
27812837Sgabeblack@google.comvoid
27913260Sgabeblack@google.comsc_module::async_reset_signal_is(const sc_in<bool> &port, bool val)
28012837Sgabeblack@google.com{
28113260Sgabeblack@google.com    sc_gem5::newResetSensitivityPort(
28213260Sgabeblack@google.com            ::sc_gem5::Process::newest(), &port, val, false);
28312837Sgabeblack@google.com}
28412837Sgabeblack@google.com
28512837Sgabeblack@google.comvoid
28613260Sgabeblack@google.comsc_module::async_reset_signal_is(const sc_inout<bool> &port, bool val)
28712837Sgabeblack@google.com{
28813260Sgabeblack@google.com    sc_gem5::newResetSensitivityPort(
28913260Sgabeblack@google.com            ::sc_gem5::Process::newest(), &port, val, false);
29012837Sgabeblack@google.com}
29112837Sgabeblack@google.com
29212837Sgabeblack@google.comvoid
29313260Sgabeblack@google.comsc_module::async_reset_signal_is(const sc_out<bool> &port, bool val)
29412837Sgabeblack@google.com{
29513260Sgabeblack@google.com    sc_gem5::newResetSensitivityPort(
29613260Sgabeblack@google.com            ::sc_gem5::Process::newest(), &port, val, false);
29712837Sgabeblack@google.com}
29812837Sgabeblack@google.com
29912837Sgabeblack@google.comvoid
30013260Sgabeblack@google.comsc_module::async_reset_signal_is(const sc_signal_in_if<bool> &signal, bool val)
30112837Sgabeblack@google.com{
30213260Sgabeblack@google.com    sc_gem5::newResetSensitivitySignal(
30313260Sgabeblack@google.com            ::sc_gem5::Process::newest(), &signal, val, false);
30412837Sgabeblack@google.com}
30512837Sgabeblack@google.com
30612837Sgabeblack@google.com
30712837Sgabeblack@google.comvoid
30812837Sgabeblack@google.comsc_module::dont_initialize()
30912837Sgabeblack@google.com{
31013194Sgabeblack@google.com    ::sc_gem5::Process::newest()->dontInitialize(true);
31112837Sgabeblack@google.com}
31212837Sgabeblack@google.com
31312837Sgabeblack@google.comvoid
31412953Sgabeblack@google.comsc_module::set_stack_size(size_t size)
31512837Sgabeblack@google.com{
31612953Sgabeblack@google.com    ::sc_gem5::Process::newest()->setStackSize(size);
31712837Sgabeblack@google.com}
31812837Sgabeblack@google.com
31912837Sgabeblack@google.com
32012951Sgabeblack@google.comvoid sc_module::next_trigger() { ::sc_core::next_trigger(); }
32112951Sgabeblack@google.com
32212837Sgabeblack@google.comvoid
32312951Sgabeblack@google.comsc_module::next_trigger(const sc_event &e)
32412837Sgabeblack@google.com{
32512951Sgabeblack@google.com    ::sc_core::next_trigger(e);
32612837Sgabeblack@google.com}
32712837Sgabeblack@google.com
32812837Sgabeblack@google.comvoid
32912951Sgabeblack@google.comsc_module::next_trigger(const sc_event_or_list &eol)
33012837Sgabeblack@google.com{
33112951Sgabeblack@google.com    ::sc_core::next_trigger(eol);
33212837Sgabeblack@google.com}
33312837Sgabeblack@google.com
33412837Sgabeblack@google.comvoid
33512951Sgabeblack@google.comsc_module::next_trigger(const sc_event_and_list &eal)
33612837Sgabeblack@google.com{
33712951Sgabeblack@google.com    ::sc_core::next_trigger(eal);
33812837Sgabeblack@google.com}
33912837Sgabeblack@google.com
34012837Sgabeblack@google.comvoid
34112951Sgabeblack@google.comsc_module::next_trigger(const sc_time &t)
34212837Sgabeblack@google.com{
34312951Sgabeblack@google.com    ::sc_core::next_trigger(t);
34412837Sgabeblack@google.com}
34512837Sgabeblack@google.com
34612837Sgabeblack@google.comvoid
34712951Sgabeblack@google.comsc_module::next_trigger(double d, sc_time_unit u)
34812837Sgabeblack@google.com{
34912951Sgabeblack@google.com    ::sc_core::next_trigger(d, u);
35012837Sgabeblack@google.com}
35112837Sgabeblack@google.com
35212837Sgabeblack@google.comvoid
35312951Sgabeblack@google.comsc_module::next_trigger(const sc_time &t, const sc_event &e)
35412837Sgabeblack@google.com{
35512951Sgabeblack@google.com    ::sc_core::next_trigger(t, e);
35612837Sgabeblack@google.com}
35712837Sgabeblack@google.com
35812837Sgabeblack@google.comvoid
35912951Sgabeblack@google.comsc_module::next_trigger(double d, sc_time_unit u, const sc_event &e)
36012837Sgabeblack@google.com{
36112951Sgabeblack@google.com    ::sc_core::next_trigger(d, u, e);
36212837Sgabeblack@google.com}
36312837Sgabeblack@google.com
36412837Sgabeblack@google.comvoid
36512951Sgabeblack@google.comsc_module::next_trigger(const sc_time &t, const sc_event_or_list &eol)
36612837Sgabeblack@google.com{
36712951Sgabeblack@google.com    ::sc_core::next_trigger(t, eol);
36812837Sgabeblack@google.com}
36912837Sgabeblack@google.com
37012837Sgabeblack@google.comvoid
37112951Sgabeblack@google.comsc_module::next_trigger(double d, sc_time_unit u, const sc_event_or_list &eol)
37212837Sgabeblack@google.com{
37312951Sgabeblack@google.com    ::sc_core::next_trigger(d, u, eol);
37412837Sgabeblack@google.com}
37512837Sgabeblack@google.com
37612837Sgabeblack@google.comvoid
37712951Sgabeblack@google.comsc_module::next_trigger(const sc_time &t, const sc_event_and_list &eal)
37812837Sgabeblack@google.com{
37912951Sgabeblack@google.com    ::sc_core::next_trigger(t, eal);
38012837Sgabeblack@google.com}
38112837Sgabeblack@google.com
38212837Sgabeblack@google.comvoid
38312951Sgabeblack@google.comsc_module::next_trigger(double d, sc_time_unit u, const sc_event_and_list &eal)
38412837Sgabeblack@google.com{
38512951Sgabeblack@google.com    ::sc_core::next_trigger(d, u, eal);
38612837Sgabeblack@google.com}
38712837Sgabeblack@google.com
38812837Sgabeblack@google.com
38912929Sgabeblack@google.combool
39012929Sgabeblack@google.comsc_module::timed_out()
39112929Sgabeblack@google.com{
39213189Sgabeblack@google.com    return ::sc_core::timed_out();
39312929Sgabeblack@google.com}
39412929Sgabeblack@google.com
39512929Sgabeblack@google.com
39612837Sgabeblack@google.comvoid
39712837Sgabeblack@google.comsc_module::wait()
39812837Sgabeblack@google.com{
39912951Sgabeblack@google.com    ::sc_core::wait();
40012837Sgabeblack@google.com}
40112837Sgabeblack@google.com
40212837Sgabeblack@google.comvoid
40312951Sgabeblack@google.comsc_module::wait(int i)
40412837Sgabeblack@google.com{
40512951Sgabeblack@google.com    ::sc_core::wait(i);
40612837Sgabeblack@google.com}
40712837Sgabeblack@google.com
40812837Sgabeblack@google.comvoid
40912951Sgabeblack@google.comsc_module::wait(const sc_event &e)
41012837Sgabeblack@google.com{
41112951Sgabeblack@google.com    ::sc_core::wait(e);
41212837Sgabeblack@google.com}
41312837Sgabeblack@google.com
41412837Sgabeblack@google.comvoid
41512951Sgabeblack@google.comsc_module::wait(const sc_event_or_list &eol)
41612837Sgabeblack@google.com{
41712951Sgabeblack@google.com    ::sc_core::wait(eol);
41812837Sgabeblack@google.com}
41912837Sgabeblack@google.com
42012837Sgabeblack@google.comvoid
42112951Sgabeblack@google.comsc_module::wait(const sc_event_and_list &eal)
42212837Sgabeblack@google.com{
42312951Sgabeblack@google.com    ::sc_core::wait(eal);
42412837Sgabeblack@google.com}
42512837Sgabeblack@google.com
42612837Sgabeblack@google.comvoid
42712951Sgabeblack@google.comsc_module::wait(const sc_time &t)
42812837Sgabeblack@google.com{
42912951Sgabeblack@google.com    ::sc_core::wait(t);
43012837Sgabeblack@google.com}
43112837Sgabeblack@google.com
43212837Sgabeblack@google.comvoid
43312951Sgabeblack@google.comsc_module::wait(double d, sc_time_unit u)
43412837Sgabeblack@google.com{
43512951Sgabeblack@google.com    ::sc_core::wait(d, u);
43612837Sgabeblack@google.com}
43712837Sgabeblack@google.com
43812837Sgabeblack@google.comvoid
43912951Sgabeblack@google.comsc_module::wait(const sc_time &t, const sc_event &e)
44012837Sgabeblack@google.com{
44112951Sgabeblack@google.com    ::sc_core::wait(t, e);
44212837Sgabeblack@google.com}
44312837Sgabeblack@google.com
44412837Sgabeblack@google.comvoid
44512951Sgabeblack@google.comsc_module::wait(double d, sc_time_unit u, const sc_event &e)
44612837Sgabeblack@google.com{
44712951Sgabeblack@google.com    ::sc_core::wait(d, u, e);
44812837Sgabeblack@google.com}
44912837Sgabeblack@google.com
45012837Sgabeblack@google.comvoid
45112951Sgabeblack@google.comsc_module::wait(const sc_time &t, const sc_event_or_list &eol)
45212837Sgabeblack@google.com{
45312951Sgabeblack@google.com    ::sc_core::wait(t, eol);
45412837Sgabeblack@google.com}
45512837Sgabeblack@google.com
45612837Sgabeblack@google.comvoid
45712951Sgabeblack@google.comsc_module::wait(double d, sc_time_unit u, const sc_event_or_list &eol)
45812837Sgabeblack@google.com{
45912951Sgabeblack@google.com    ::sc_core::wait(d, u, eol);
46012837Sgabeblack@google.com}
46112837Sgabeblack@google.com
46212837Sgabeblack@google.comvoid
46312951Sgabeblack@google.comsc_module::wait(const sc_time &t, const sc_event_and_list &eal)
46412837Sgabeblack@google.com{
46512951Sgabeblack@google.com    ::sc_core::wait(t, eal);
46612837Sgabeblack@google.com}
46712837Sgabeblack@google.com
46812837Sgabeblack@google.comvoid
46912951Sgabeblack@google.comsc_module::wait(double d, sc_time_unit u, const sc_event_and_list &eal)
47012837Sgabeblack@google.com{
47112951Sgabeblack@google.com    ::sc_core::wait(d, u, eal);
47212837Sgabeblack@google.com}
47312837Sgabeblack@google.com
47412837Sgabeblack@google.com
47512837Sgabeblack@google.comvoid
47612909Sgabeblack@google.comsc_module::halt()
47712909Sgabeblack@google.com{
47812951Sgabeblack@google.com    ::sc_core::halt();
47912909Sgabeblack@google.com}
48012909Sgabeblack@google.com
48112914Sgabeblack@google.comvoid
48212951Sgabeblack@google.comsc_module::at_posedge(const sc_signal_in_if<bool> &s)
48312914Sgabeblack@google.com{
48412951Sgabeblack@google.com    ::sc_core::at_posedge(s);
48512914Sgabeblack@google.com}
48612914Sgabeblack@google.com
48712914Sgabeblack@google.comvoid
48812951Sgabeblack@google.comsc_module::at_posedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
48912914Sgabeblack@google.com{
49012951Sgabeblack@google.com    ::sc_core::at_posedge(s);
49112914Sgabeblack@google.com}
49212914Sgabeblack@google.com
49312914Sgabeblack@google.comvoid
49412951Sgabeblack@google.comsc_module::at_negedge(const sc_signal_in_if<bool> &s)
49512914Sgabeblack@google.com{
49612951Sgabeblack@google.com    ::sc_core::at_negedge(s);
49712914Sgabeblack@google.com}
49812914Sgabeblack@google.com
49912914Sgabeblack@google.comvoid
50012951Sgabeblack@google.comsc_module::at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
50112914Sgabeblack@google.com{
50212951Sgabeblack@google.com    ::sc_core::at_negedge(s);
50312914Sgabeblack@google.com}
50412914Sgabeblack@google.com
50512909Sgabeblack@google.com
50612909Sgabeblack@google.comvoid
50712837Sgabeblack@google.comnext_trigger()
50812837Sgabeblack@google.com{
50912958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
51013206Sgabeblack@google.com    p->cancelTimeout();
51113206Sgabeblack@google.com    p->clearDynamic();
51212837Sgabeblack@google.com}
51312837Sgabeblack@google.com
51412837Sgabeblack@google.comvoid
51512958Sgabeblack@google.comnext_trigger(const sc_event &e)
51612837Sgabeblack@google.com{
51712958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
51813206Sgabeblack@google.com    p->cancelTimeout();
51913207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEvent(p, &e);
52012837Sgabeblack@google.com}
52112837Sgabeblack@google.com
52212837Sgabeblack@google.comvoid
52312958Sgabeblack@google.comnext_trigger(const sc_event_or_list &eol)
52412837Sgabeblack@google.com{
52512958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
52613206Sgabeblack@google.com    p->cancelTimeout();
52713207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol);
52812837Sgabeblack@google.com}
52912837Sgabeblack@google.com
53012837Sgabeblack@google.comvoid
53112958Sgabeblack@google.comnext_trigger(const sc_event_and_list &eal)
53212837Sgabeblack@google.com{
53312958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
53413206Sgabeblack@google.com    p->cancelTimeout();
53513207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal);
53612837Sgabeblack@google.com}
53712837Sgabeblack@google.com
53812837Sgabeblack@google.comvoid
53912958Sgabeblack@google.comnext_trigger(const sc_time &t)
54012837Sgabeblack@google.com{
54112958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
54213206Sgabeblack@google.com    p->setTimeout(t);
54313206Sgabeblack@google.com    p->clearDynamic();
54412837Sgabeblack@google.com}
54512837Sgabeblack@google.com
54612837Sgabeblack@google.comvoid
54712951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u)
54812837Sgabeblack@google.com{
54912951Sgabeblack@google.com    next_trigger(sc_time(d, u));
55012837Sgabeblack@google.com}
55112837Sgabeblack@google.com
55212837Sgabeblack@google.comvoid
55312958Sgabeblack@google.comnext_trigger(const sc_time &t, const sc_event &e)
55412837Sgabeblack@google.com{
55512958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
55613206Sgabeblack@google.com    p->setTimeout(t);
55713207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEvent(p, &e);
55812837Sgabeblack@google.com}
55912837Sgabeblack@google.com
56012837Sgabeblack@google.comvoid
56112951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u, const sc_event &e)
56212837Sgabeblack@google.com{
56312951Sgabeblack@google.com    next_trigger(sc_time(d, u), e);
56412837Sgabeblack@google.com}
56512837Sgabeblack@google.com
56612837Sgabeblack@google.comvoid
56712958Sgabeblack@google.comnext_trigger(const sc_time &t, const sc_event_or_list &eol)
56812837Sgabeblack@google.com{
56912958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
57013206Sgabeblack@google.com    p->setTimeout(t);
57113207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol);
57212837Sgabeblack@google.com}
57312837Sgabeblack@google.com
57412837Sgabeblack@google.comvoid
57512951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u, const sc_event_or_list &eol)
57612837Sgabeblack@google.com{
57712951Sgabeblack@google.com    next_trigger(sc_time(d, u), eol);
57812837Sgabeblack@google.com}
57912837Sgabeblack@google.com
58012837Sgabeblack@google.comvoid
58112958Sgabeblack@google.comnext_trigger(const sc_time &t, const sc_event_and_list &eal)
58212837Sgabeblack@google.com{
58312958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
58413206Sgabeblack@google.com    p->setTimeout(t);
58513207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal);
58612837Sgabeblack@google.com}
58712837Sgabeblack@google.com
58812837Sgabeblack@google.comvoid
58912951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u, const sc_event_and_list &eal)
59012837Sgabeblack@google.com{
59112951Sgabeblack@google.com    next_trigger(sc_time(d, u), eal);
59212837Sgabeblack@google.com}
59312837Sgabeblack@google.com
59412929Sgabeblack@google.combool
59512929Sgabeblack@google.comtimed_out()
59612929Sgabeblack@google.com{
59713189Sgabeblack@google.com    ::sc_gem5::Process *p = sc_gem5::scheduler.current();
59813189Sgabeblack@google.com    if (!p)
59913189Sgabeblack@google.com        return false;
60013189Sgabeblack@google.com    else
60113189Sgabeblack@google.com        return p->timedOut();
60212929Sgabeblack@google.com}
60312929Sgabeblack@google.com
60412837Sgabeblack@google.com
60513248Sgabeblack@google.comnamespace
60613248Sgabeblack@google.com{
60713248Sgabeblack@google.com
60813248Sgabeblack@google.combool
60913248Sgabeblack@google.comwaitErrorCheck(sc_gem5::Process *p)
61013248Sgabeblack@google.com{
61113248Sgabeblack@google.com    if (p->procKind() == SC_METHOD_PROC_) {
61213248Sgabeblack@google.com        SC_REPORT_ERROR(
61313248Sgabeblack@google.com                "(E519) wait() is only allowed in SC_THREADs and SC_CTHREADs",
61413248Sgabeblack@google.com                "\n        in SC_METHODs use next_trigger() instead");
61513248Sgabeblack@google.com        return true;
61613248Sgabeblack@google.com    }
61713248Sgabeblack@google.com    return false;
61813248Sgabeblack@google.com}
61913248Sgabeblack@google.com
62013248Sgabeblack@google.com} // anonymous namespace
62113248Sgabeblack@google.com
62212837Sgabeblack@google.comvoid
62312837Sgabeblack@google.comwait()
62412837Sgabeblack@google.com{
62512958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
62613248Sgabeblack@google.com    if (waitErrorCheck(p))
62713248Sgabeblack@google.com        return;
62813206Sgabeblack@google.com    p->cancelTimeout();
62913206Sgabeblack@google.com    p->clearDynamic();
63012958Sgabeblack@google.com    sc_gem5::scheduler.yield();
63112837Sgabeblack@google.com}
63212837Sgabeblack@google.com
63312837Sgabeblack@google.comvoid
63412958Sgabeblack@google.comwait(int n)
63512837Sgabeblack@google.com{
63613146Sgabeblack@google.com    if (n <= 0) {
63713146Sgabeblack@google.com        std::string msg = csprintf("n = %d", n);
63813146Sgabeblack@google.com        SC_REPORT_ERROR("(E525) wait(n) is only valid for n > 0", msg.c_str());
63913146Sgabeblack@google.com    }
64013260Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
64113260Sgabeblack@google.com    p->waitCount(n - 1);
64213260Sgabeblack@google.com    wait();
64312837Sgabeblack@google.com}
64412837Sgabeblack@google.com
64512837Sgabeblack@google.comvoid
64612958Sgabeblack@google.comwait(const sc_event &e)
64712837Sgabeblack@google.com{
64812958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
64913248Sgabeblack@google.com    if (waitErrorCheck(p))
65013248Sgabeblack@google.com        return;
65113206Sgabeblack@google.com    p->cancelTimeout();
65213207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEvent(p, &e);
65312958Sgabeblack@google.com    sc_gem5::scheduler.yield();
65412837Sgabeblack@google.com}
65512837Sgabeblack@google.com
65612837Sgabeblack@google.comvoid
65712958Sgabeblack@google.comwait(const sc_event_or_list &eol)
65812837Sgabeblack@google.com{
65912958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
66013248Sgabeblack@google.com    if (waitErrorCheck(p))
66113248Sgabeblack@google.com        return;
66213206Sgabeblack@google.com    p->cancelTimeout();
66313207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol);
66412958Sgabeblack@google.com    sc_gem5::scheduler.yield();
66512837Sgabeblack@google.com}
66612837Sgabeblack@google.com
66712837Sgabeblack@google.comvoid
66812958Sgabeblack@google.comwait(const sc_event_and_list &eal)
66912837Sgabeblack@google.com{
67012958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
67113248Sgabeblack@google.com    if (waitErrorCheck(p))
67213248Sgabeblack@google.com        return;
67313206Sgabeblack@google.com    p->cancelTimeout();
67413207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal);
67512958Sgabeblack@google.com    sc_gem5::scheduler.yield();
67612837Sgabeblack@google.com}
67712837Sgabeblack@google.com
67812837Sgabeblack@google.comvoid
67912958Sgabeblack@google.comwait(const sc_time &t)
68012837Sgabeblack@google.com{
68112958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
68213248Sgabeblack@google.com    if (waitErrorCheck(p))
68313248Sgabeblack@google.com        return;
68413206Sgabeblack@google.com    p->setTimeout(t);
68513206Sgabeblack@google.com    p->clearDynamic();
68612958Sgabeblack@google.com    sc_gem5::scheduler.yield();
68712837Sgabeblack@google.com}
68812837Sgabeblack@google.com
68912837Sgabeblack@google.comvoid
69012951Sgabeblack@google.comwait(double d, sc_time_unit u)
69112837Sgabeblack@google.com{
69212951Sgabeblack@google.com    wait(sc_time(d, u));
69312837Sgabeblack@google.com}
69412837Sgabeblack@google.com
69512837Sgabeblack@google.comvoid
69612958Sgabeblack@google.comwait(const sc_time &t, const sc_event &e)
69712837Sgabeblack@google.com{
69812958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
69913248Sgabeblack@google.com    if (waitErrorCheck(p))
70013248Sgabeblack@google.com        return;
70113206Sgabeblack@google.com    p->setTimeout(t);
70213207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEvent(p, &e);
70312958Sgabeblack@google.com    sc_gem5::scheduler.yield();
70412837Sgabeblack@google.com}
70512837Sgabeblack@google.com
70612837Sgabeblack@google.comvoid
70712951Sgabeblack@google.comwait(double d, sc_time_unit u, const sc_event &e)
70812837Sgabeblack@google.com{
70912951Sgabeblack@google.com    wait(sc_time(d, u), e);
71012837Sgabeblack@google.com}
71112837Sgabeblack@google.com
71212837Sgabeblack@google.comvoid
71312958Sgabeblack@google.comwait(const sc_time &t, const sc_event_or_list &eol)
71412837Sgabeblack@google.com{
71512958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
71613248Sgabeblack@google.com    if (waitErrorCheck(p))
71713248Sgabeblack@google.com        return;
71813206Sgabeblack@google.com    p->setTimeout(t);
71913207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol);
72012958Sgabeblack@google.com    sc_gem5::scheduler.yield();
72112837Sgabeblack@google.com}
72212837Sgabeblack@google.com
72312837Sgabeblack@google.comvoid
72412951Sgabeblack@google.comwait(double d, sc_time_unit u, const sc_event_or_list &eol)
72512837Sgabeblack@google.com{
72612951Sgabeblack@google.com    wait(sc_time(d, u), eol);
72712837Sgabeblack@google.com}
72812837Sgabeblack@google.com
72912837Sgabeblack@google.comvoid
73012958Sgabeblack@google.comwait(const sc_time &t, const sc_event_and_list &eal)
73112837Sgabeblack@google.com{
73212958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
73313248Sgabeblack@google.com    if (waitErrorCheck(p))
73413248Sgabeblack@google.com        return;
73513206Sgabeblack@google.com    p->setTimeout(t);
73613207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal);
73712958Sgabeblack@google.com    sc_gem5::scheduler.yield();
73812837Sgabeblack@google.com}
73912837Sgabeblack@google.com
74012837Sgabeblack@google.comvoid
74112951Sgabeblack@google.comwait(double d, sc_time_unit u, const sc_event_and_list &eal)
74212837Sgabeblack@google.com{
74312951Sgabeblack@google.com    wait(sc_time(d, u), eal);
74412837Sgabeblack@google.com}
74512837Sgabeblack@google.com
74612909Sgabeblack@google.comvoid
74712909Sgabeblack@google.comhalt()
74812909Sgabeblack@google.com{
74913175Sgabeblack@google.com    ::sc_core::wait();
75013175Sgabeblack@google.com    throw ::sc_gem5::ScHalt();
75112909Sgabeblack@google.com}
75212909Sgabeblack@google.com
75312914Sgabeblack@google.comvoid
75413155Sgabeblack@google.comat_posedge(const sc_signal_in_if<bool> &s)
75512914Sgabeblack@google.com{
75613155Sgabeblack@google.com    while (s.read())
75713155Sgabeblack@google.com        wait();
75813155Sgabeblack@google.com    while (!s.read())
75913155Sgabeblack@google.com        wait();
76012914Sgabeblack@google.com}
76112914Sgabeblack@google.com
76212914Sgabeblack@google.comvoid
76313155Sgabeblack@google.comat_posedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
76412914Sgabeblack@google.com{
76513155Sgabeblack@google.com    while (s.read() == sc_dt::Log_1)
76613155Sgabeblack@google.com        wait();
76713155Sgabeblack@google.com    while (s.read() == sc_dt::Log_0)
76813155Sgabeblack@google.com        wait();
76912914Sgabeblack@google.com}
77012914Sgabeblack@google.com
77112914Sgabeblack@google.comvoid
77213155Sgabeblack@google.comat_negedge(const sc_signal_in_if<bool> &s)
77312914Sgabeblack@google.com{
77413155Sgabeblack@google.com    while (!s.read())
77513155Sgabeblack@google.com        wait();
77613155Sgabeblack@google.com    while (s.read())
77713155Sgabeblack@google.com        wait();
77812914Sgabeblack@google.com}
77912914Sgabeblack@google.com
78012914Sgabeblack@google.comvoid
78113155Sgabeblack@google.comat_negedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
78212914Sgabeblack@google.com{
78313155Sgabeblack@google.com    while (s.read() == sc_dt::Log_0)
78413155Sgabeblack@google.com        wait();
78513155Sgabeblack@google.com    while (s.read() == sc_dt::Log_1)
78613155Sgabeblack@google.com        wait();
78712914Sgabeblack@google.com}
78812914Sgabeblack@google.com
78912837Sgabeblack@google.comconst char *
79013035Sgabeblack@google.comsc_gen_unique_name(const char *seed)
79112837Sgabeblack@google.com{
79213268Sgabeblack@google.com    auto mod = sc_gem5::pickParentModule();
79313035Sgabeblack@google.com    return mod ? mod->uniqueName(seed) :
79413035Sgabeblack@google.com        ::sc_gem5::nameGen.gen(seed);
79512837Sgabeblack@google.com}
79612837Sgabeblack@google.com
79712837Sgabeblack@google.combool
79812930Sgabeblack@google.comsc_hierarchical_name_exists(const char *name)
79912930Sgabeblack@google.com{
80013280Sgabeblack@google.com    return sc_gem5::findEvent(name) != sc_gem5::allEvents.end() ||
80113280Sgabeblack@google.com        ::sc_gem5::findObject(name, sc_gem5::allObjects);
80212930Sgabeblack@google.com}
80312930Sgabeblack@google.com
80412930Sgabeblack@google.combool
80512837Sgabeblack@google.comsc_start_of_simulation_invoked()
80612837Sgabeblack@google.com{
80712982Sgabeblack@google.com    return ::sc_gem5::kernel->startOfSimulationComplete();
80812837Sgabeblack@google.com}
80912837Sgabeblack@google.com
81012837Sgabeblack@google.combool
81112837Sgabeblack@google.comsc_end_of_simulation_invoked()
81212837Sgabeblack@google.com{
81312982Sgabeblack@google.com    return ::sc_gem5::kernel->endOfSimulationComplete();
81412837Sgabeblack@google.com}
81512837Sgabeblack@google.com
81612901Sgabeblack@google.comsc_module *
81712901Sgabeblack@google.comsc_module_sc_new(sc_module *mod)
81812901Sgabeblack@google.com{
81912901Sgabeblack@google.com    static std::vector<std::unique_ptr<sc_module> > modules;
82012901Sgabeblack@google.com    modules.emplace_back(mod);
82112901Sgabeblack@google.com    return mod;
82212901Sgabeblack@google.com}
82312901Sgabeblack@google.com
82412837Sgabeblack@google.com} // namespace sc_core
825