sc_module.cc revision 13315
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"
3913288Sgabeblack@google.com#include "systemc/core/port.hh"
4012953Sgabeblack@google.com#include "systemc/core/process_types.hh"
4113260Sgabeblack@google.com#include "systemc/core/sensitivity.hh"
4213288Sgabeblack@google.com#include "systemc/ext/channel/sc_in.hh"
4313288Sgabeblack@google.com#include "systemc/ext/channel/sc_inout.hh"
4413288Sgabeblack@google.com#include "systemc/ext/channel/sc_out.hh"
4513155Sgabeblack@google.com#include "systemc/ext/channel/sc_signal_in_if.hh"
4612837Sgabeblack@google.com#include "systemc/ext/core/sc_module.hh"
4712951Sgabeblack@google.com#include "systemc/ext/core/sc_module_name.hh"
4813155Sgabeblack@google.com#include "systemc/ext/dt/bit/sc_logic.hh"
4913135Sgabeblack@google.com#include "systemc/ext/utils/sc_report_handler.hh"
5012837Sgabeblack@google.com
5112952Sgabeblack@google.comnamespace sc_gem5
5212952Sgabeblack@google.com{
5312952Sgabeblack@google.com
5412952Sgabeblack@google.comProcess *
5512952Sgabeblack@google.comnewMethodProcess(const char *name, ProcessFuncWrapper *func)
5612952Sgabeblack@google.com{
5713135Sgabeblack@google.com    Method *p = new Method(name, func);
5813135Sgabeblack@google.com    if (::sc_core::sc_is_running()) {
5913135Sgabeblack@google.com        std::string name = p->name();
6013135Sgabeblack@google.com        delete p;
6113135Sgabeblack@google.com        SC_REPORT_ERROR("(E541) call to SC_METHOD in sc_module while "
6213135Sgabeblack@google.com                "simulation running", name.c_str());
6313135Sgabeblack@google.com        return nullptr;
6413135Sgabeblack@google.com    }
6512993Sgabeblack@google.com    scheduler.reg(p);
6612993Sgabeblack@google.com    return p;
6712952Sgabeblack@google.com}
6812952Sgabeblack@google.com
6912952Sgabeblack@google.comProcess *
7012952Sgabeblack@google.comnewThreadProcess(const char *name, ProcessFuncWrapper *func)
7112952Sgabeblack@google.com{
7213135Sgabeblack@google.com    Thread *p = new Thread(name, func);
7313135Sgabeblack@google.com    if (::sc_core::sc_is_running()) {
7413135Sgabeblack@google.com        std::string name = p->name();
7513135Sgabeblack@google.com        delete p;
7613135Sgabeblack@google.com        SC_REPORT_ERROR("(E542) call to SC_THREAD in sc_module while "
7713135Sgabeblack@google.com                "simulation running", name.c_str());
7813135Sgabeblack@google.com        return nullptr;
7913135Sgabeblack@google.com    }
8012993Sgabeblack@google.com    scheduler.reg(p);
8112993Sgabeblack@google.com    return p;
8212952Sgabeblack@google.com}
8312952Sgabeblack@google.com
8412952Sgabeblack@google.comProcess *
8512952Sgabeblack@google.comnewCThreadProcess(const char *name, ProcessFuncWrapper *func)
8612952Sgabeblack@google.com{
8713135Sgabeblack@google.com    CThread *p = new CThread(name, func);
8813135Sgabeblack@google.com    if (::sc_core::sc_is_running()) {
8913135Sgabeblack@google.com        std::string name = p->name();
9013135Sgabeblack@google.com        delete p;
9113135Sgabeblack@google.com        SC_REPORT_ERROR("(E543) call to SC_CTHREAD in sc_module while "
9213135Sgabeblack@google.com                "simulation running", name.c_str());
9313135Sgabeblack@google.com        return nullptr;
9413135Sgabeblack@google.com    }
9512993Sgabeblack@google.com    scheduler.reg(p);
9613194Sgabeblack@google.com    p->dontInitialize(true);
9712993Sgabeblack@google.com    return p;
9812952Sgabeblack@google.com}
9912952Sgabeblack@google.com
10012952Sgabeblack@google.com} // namespace sc_gem5
10112952Sgabeblack@google.com
10212837Sgabeblack@google.comnamespace sc_core
10312837Sgabeblack@google.com{
10412837Sgabeblack@google.com
10513091Sgabeblack@google.comsc_bind_proxy::sc_bind_proxy(sc_interface &_interface) :
10612951Sgabeblack@google.com    _interface(&_interface), _port(nullptr)
10712951Sgabeblack@google.com{}
10812837Sgabeblack@google.com
10913091Sgabeblack@google.comsc_bind_proxy::sc_bind_proxy(sc_port_base &_port) :
11012951Sgabeblack@google.com    _interface(nullptr), _port(&_port)
11112951Sgabeblack@google.com{}
11212837Sgabeblack@google.com
11313091Sgabeblack@google.comconst sc_bind_proxy SC_BIND_PROXY_NUL(*(sc_port_base *)nullptr);
11412837Sgabeblack@google.com
11512982Sgabeblack@google.comsc_module::~sc_module() { delete _gem5_module; }
11612837Sgabeblack@google.com
11713091Sgabeblack@google.comconst sc_bind_proxy SC_BIND_PROXY_NIL(*(sc_port_base *)nullptr);
11812837Sgabeblack@google.com
11912837Sgabeblack@google.comvoid
12012837Sgabeblack@google.comsc_module::operator () (const sc_bind_proxy &p001,
12112837Sgabeblack@google.com                        const sc_bind_proxy &p002,
12212837Sgabeblack@google.com                        const sc_bind_proxy &p003,
12312837Sgabeblack@google.com                        const sc_bind_proxy &p004,
12412837Sgabeblack@google.com                        const sc_bind_proxy &p005,
12512837Sgabeblack@google.com                        const sc_bind_proxy &p006,
12612837Sgabeblack@google.com                        const sc_bind_proxy &p007,
12712837Sgabeblack@google.com                        const sc_bind_proxy &p008,
12812837Sgabeblack@google.com                        const sc_bind_proxy &p009,
12912837Sgabeblack@google.com                        const sc_bind_proxy &p010,
13012837Sgabeblack@google.com                        const sc_bind_proxy &p011,
13112837Sgabeblack@google.com                        const sc_bind_proxy &p012,
13212837Sgabeblack@google.com                        const sc_bind_proxy &p013,
13312837Sgabeblack@google.com                        const sc_bind_proxy &p014,
13412837Sgabeblack@google.com                        const sc_bind_proxy &p015,
13512837Sgabeblack@google.com                        const sc_bind_proxy &p016,
13612837Sgabeblack@google.com                        const sc_bind_proxy &p017,
13712837Sgabeblack@google.com                        const sc_bind_proxy &p018,
13812837Sgabeblack@google.com                        const sc_bind_proxy &p019,
13912837Sgabeblack@google.com                        const sc_bind_proxy &p020,
14012837Sgabeblack@google.com                        const sc_bind_proxy &p021,
14112837Sgabeblack@google.com                        const sc_bind_proxy &p022,
14212837Sgabeblack@google.com                        const sc_bind_proxy &p023,
14312837Sgabeblack@google.com                        const sc_bind_proxy &p024,
14412837Sgabeblack@google.com                        const sc_bind_proxy &p025,
14512837Sgabeblack@google.com                        const sc_bind_proxy &p026,
14612837Sgabeblack@google.com                        const sc_bind_proxy &p027,
14712837Sgabeblack@google.com                        const sc_bind_proxy &p028,
14812837Sgabeblack@google.com                        const sc_bind_proxy &p029,
14912837Sgabeblack@google.com                        const sc_bind_proxy &p030,
15012837Sgabeblack@google.com                        const sc_bind_proxy &p031,
15112837Sgabeblack@google.com                        const sc_bind_proxy &p032,
15212837Sgabeblack@google.com                        const sc_bind_proxy &p033,
15312837Sgabeblack@google.com                        const sc_bind_proxy &p034,
15412837Sgabeblack@google.com                        const sc_bind_proxy &p035,
15512837Sgabeblack@google.com                        const sc_bind_proxy &p036,
15612837Sgabeblack@google.com                        const sc_bind_proxy &p037,
15712837Sgabeblack@google.com                        const sc_bind_proxy &p038,
15812837Sgabeblack@google.com                        const sc_bind_proxy &p039,
15912837Sgabeblack@google.com                        const sc_bind_proxy &p040,
16012837Sgabeblack@google.com                        const sc_bind_proxy &p041,
16112837Sgabeblack@google.com                        const sc_bind_proxy &p042,
16212837Sgabeblack@google.com                        const sc_bind_proxy &p043,
16312837Sgabeblack@google.com                        const sc_bind_proxy &p044,
16412837Sgabeblack@google.com                        const sc_bind_proxy &p045,
16512837Sgabeblack@google.com                        const sc_bind_proxy &p046,
16612837Sgabeblack@google.com                        const sc_bind_proxy &p047,
16712837Sgabeblack@google.com                        const sc_bind_proxy &p048,
16812837Sgabeblack@google.com                        const sc_bind_proxy &p049,
16912837Sgabeblack@google.com                        const sc_bind_proxy &p050,
17012837Sgabeblack@google.com                        const sc_bind_proxy &p051,
17112837Sgabeblack@google.com                        const sc_bind_proxy &p052,
17212837Sgabeblack@google.com                        const sc_bind_proxy &p053,
17312837Sgabeblack@google.com                        const sc_bind_proxy &p054,
17412837Sgabeblack@google.com                        const sc_bind_proxy &p055,
17512837Sgabeblack@google.com                        const sc_bind_proxy &p056,
17612837Sgabeblack@google.com                        const sc_bind_proxy &p057,
17712837Sgabeblack@google.com                        const sc_bind_proxy &p058,
17812837Sgabeblack@google.com                        const sc_bind_proxy &p059,
17912837Sgabeblack@google.com                        const sc_bind_proxy &p060,
18012837Sgabeblack@google.com                        const sc_bind_proxy &p061,
18112837Sgabeblack@google.com                        const sc_bind_proxy &p062,
18212837Sgabeblack@google.com                        const sc_bind_proxy &p063,
18312837Sgabeblack@google.com                        const sc_bind_proxy &p064)
18412837Sgabeblack@google.com{
18513091Sgabeblack@google.com    std::vector<const ::sc_core::sc_bind_proxy *> proxies;
18613091Sgabeblack@google.com    auto insert = [&proxies](const ::sc_core::sc_bind_proxy &p) -> bool {
18713091Sgabeblack@google.com        if (!p.port() && !p.interface())
18813091Sgabeblack@google.com            return false;
18913091Sgabeblack@google.com        proxies.push_back(&p);
19013091Sgabeblack@google.com        return true;
19113091Sgabeblack@google.com    };
19213091Sgabeblack@google.com    insert(p001) && insert(p002) && insert(p003) && insert(p004) &&
19313091Sgabeblack@google.com    insert(p005) && insert(p006) && insert(p007) && insert(p008) &&
19413091Sgabeblack@google.com    insert(p009) && insert(p010) && insert(p011) && insert(p012) &&
19513091Sgabeblack@google.com    insert(p013) && insert(p014) && insert(p015) && insert(p016) &&
19613091Sgabeblack@google.com    insert(p017) && insert(p018) && insert(p019) && insert(p020) &&
19713091Sgabeblack@google.com    insert(p021) && insert(p022) && insert(p023) && insert(p024) &&
19813091Sgabeblack@google.com    insert(p025) && insert(p026) && insert(p027) && insert(p028) &&
19913091Sgabeblack@google.com    insert(p029) && insert(p030) && insert(p031) && insert(p032) &&
20013091Sgabeblack@google.com    insert(p033) && insert(p034) && insert(p035) && insert(p036) &&
20113091Sgabeblack@google.com    insert(p037) && insert(p038) && insert(p039) && insert(p040) &&
20213091Sgabeblack@google.com    insert(p041) && insert(p042) && insert(p043) && insert(p044) &&
20313091Sgabeblack@google.com    insert(p045) && insert(p046) && insert(p047) && insert(p048) &&
20413091Sgabeblack@google.com    insert(p049) && insert(p050) && insert(p051) && insert(p052) &&
20513091Sgabeblack@google.com    insert(p053) && insert(p054) && insert(p055) && insert(p056) &&
20613091Sgabeblack@google.com    insert(p057) && insert(p058) && insert(p059) && insert(p060) &&
20713091Sgabeblack@google.com    insert(p061) && insert(p062) && insert(p063) && insert(p064);
20813091Sgabeblack@google.com    _gem5_module->bindPorts(proxies);
20912837Sgabeblack@google.com}
21012837Sgabeblack@google.com
21113292Sgabeblack@google.comsc_module &
21213292Sgabeblack@google.comsc_module::operator << (sc_interface &iface)
21313292Sgabeblack@google.com{
21413292Sgabeblack@google.com    (*this)(iface);
21513292Sgabeblack@google.com    return *this;
21613292Sgabeblack@google.com}
21713292Sgabeblack@google.com
21813292Sgabeblack@google.comsc_module &
21913292Sgabeblack@google.comsc_module::operator << (sc_port_base &pb)
22013292Sgabeblack@google.com{
22113292Sgabeblack@google.com    (*this)(pb);
22213292Sgabeblack@google.com    return *this;
22313292Sgabeblack@google.com}
22413292Sgabeblack@google.com
22513292Sgabeblack@google.comsc_module &
22613292Sgabeblack@google.comsc_module::operator , (sc_interface &iface)
22713292Sgabeblack@google.com{
22813292Sgabeblack@google.com    (*this)(iface);
22913292Sgabeblack@google.com    return *this;
23013292Sgabeblack@google.com}
23113292Sgabeblack@google.com
23213292Sgabeblack@google.comsc_module &
23313292Sgabeblack@google.comsc_module::operator , (sc_port_base &pb)
23413292Sgabeblack@google.com{
23513292Sgabeblack@google.com    (*this)(pb);
23613292Sgabeblack@google.com    return *this;
23713292Sgabeblack@google.com}
23813292Sgabeblack@google.com
23912837Sgabeblack@google.comconst std::vector<sc_object *> &
24012837Sgabeblack@google.comsc_module::get_child_objects() const
24112837Sgabeblack@google.com{
24212951Sgabeblack@google.com    return _gem5_module->obj()->get_child_objects();
24312837Sgabeblack@google.com}
24412837Sgabeblack@google.com
24512837Sgabeblack@google.comconst std::vector<sc_event *> &
24612837Sgabeblack@google.comsc_module::get_child_events() const
24712837Sgabeblack@google.com{
24812951Sgabeblack@google.com    return _gem5_module->obj()->get_child_events();
24912837Sgabeblack@google.com}
25012837Sgabeblack@google.com
25112951Sgabeblack@google.comsc_module::sc_module() :
25213079Sgabeblack@google.com    sc_object(sc_gem5::newModuleChecked()->name()),
25312951Sgabeblack@google.com    _gem5_module(sc_gem5::currentModule())
25413284Sgabeblack@google.com{
25513284Sgabeblack@google.com    if (sc_is_running()) {
25613284Sgabeblack@google.com        SC_REPORT_ERROR("(E529) insert module failed", "simulation running");
25713284Sgabeblack@google.com        std::cout << "Running!\n";
25813284Sgabeblack@google.com    }
25913284Sgabeblack@google.com    if (::sc_gem5::scheduler.elaborationDone()) {
26013284Sgabeblack@google.com        SC_REPORT_ERROR("(E529) insert module failed", "elaboration done");
26113284Sgabeblack@google.com        std::cout << "Elaboration done!\n";
26213284Sgabeblack@google.com    }
26313284Sgabeblack@google.com}
26412837Sgabeblack@google.com
26512951Sgabeblack@google.comsc_module::sc_module(const sc_module_name &) : sc_module() {}
26613191Sgabeblack@google.comsc_module::sc_module(const char *_name) : sc_module(sc_module_name(_name))
26713191Sgabeblack@google.com{
26813191Sgabeblack@google.com    _gem5_module->deprecatedConstructor();
26913191Sgabeblack@google.com    SC_REPORT_WARNING("(W569) sc_module(const char*), "
27013191Sgabeblack@google.com            "sc_module(const std::string&) have been deprecated, use "
27113191Sgabeblack@google.com            "sc_module(const sc_module_name&)", _name);
27213191Sgabeblack@google.com}
27312951Sgabeblack@google.comsc_module::sc_module(const std::string &_name) :
27412951Sgabeblack@google.com    sc_module(sc_module_name(_name.c_str()))
27513191Sgabeblack@google.com{
27613191Sgabeblack@google.com    _gem5_module->deprecatedConstructor();
27713191Sgabeblack@google.com    SC_REPORT_WARNING("(W569) sc_module(const char*), "
27813191Sgabeblack@google.com            "sc_module(const std::string&) have been deprecated, use "
27913191Sgabeblack@google.com            "sc_module(const sc_module_name&)", _name.c_str());
28013191Sgabeblack@google.com}
28113191Sgabeblack@google.com
28213191Sgabeblack@google.comvoid
28313191Sgabeblack@google.comsc_module::end_module()
28413191Sgabeblack@google.com{
28513191Sgabeblack@google.com    _gem5_module->endModule();
28613191Sgabeblack@google.com}
28712928Sgabeblack@google.com
28812837Sgabeblack@google.comvoid
28913260Sgabeblack@google.comsc_module::reset_signal_is(const sc_in<bool> &port, bool val)
29012837Sgabeblack@google.com{
29113288Sgabeblack@google.com    ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), true, val);
29212837Sgabeblack@google.com}
29312837Sgabeblack@google.com
29412837Sgabeblack@google.comvoid
29513260Sgabeblack@google.comsc_module::reset_signal_is(const sc_inout<bool> &port, bool val)
29612837Sgabeblack@google.com{
29713288Sgabeblack@google.com    ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), true, val);
29812837Sgabeblack@google.com}
29912837Sgabeblack@google.com
30012837Sgabeblack@google.comvoid
30113260Sgabeblack@google.comsc_module::reset_signal_is(const sc_out<bool> &port, bool val)
30212837Sgabeblack@google.com{
30313288Sgabeblack@google.com    ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), true, val);
30412837Sgabeblack@google.com}
30512837Sgabeblack@google.com
30612837Sgabeblack@google.comvoid
30713260Sgabeblack@google.comsc_module::reset_signal_is(const sc_signal_in_if<bool> &signal, bool val)
30812837Sgabeblack@google.com{
30913288Sgabeblack@google.com    ::sc_gem5::newReset(&signal, ::sc_gem5::Process::newest(), true, val);
31012837Sgabeblack@google.com}
31112837Sgabeblack@google.com
31212837Sgabeblack@google.com
31312837Sgabeblack@google.comvoid
31413260Sgabeblack@google.comsc_module::async_reset_signal_is(const sc_in<bool> &port, bool val)
31512837Sgabeblack@google.com{
31613288Sgabeblack@google.com    ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), false, val);
31712837Sgabeblack@google.com}
31812837Sgabeblack@google.com
31912837Sgabeblack@google.comvoid
32013260Sgabeblack@google.comsc_module::async_reset_signal_is(const sc_inout<bool> &port, bool val)
32112837Sgabeblack@google.com{
32213288Sgabeblack@google.com    ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), false, val);
32312837Sgabeblack@google.com}
32412837Sgabeblack@google.com
32512837Sgabeblack@google.comvoid
32613260Sgabeblack@google.comsc_module::async_reset_signal_is(const sc_out<bool> &port, bool val)
32712837Sgabeblack@google.com{
32813288Sgabeblack@google.com    ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), false, val);
32912837Sgabeblack@google.com}
33012837Sgabeblack@google.com
33112837Sgabeblack@google.comvoid
33213260Sgabeblack@google.comsc_module::async_reset_signal_is(const sc_signal_in_if<bool> &signal, bool val)
33312837Sgabeblack@google.com{
33413288Sgabeblack@google.com    ::sc_gem5::newReset(&signal, ::sc_gem5::Process::newest(), false, val);
33512837Sgabeblack@google.com}
33612837Sgabeblack@google.com
33712837Sgabeblack@google.com
33812837Sgabeblack@google.comvoid
33912837Sgabeblack@google.comsc_module::dont_initialize()
34012837Sgabeblack@google.com{
34113315Sgabeblack@google.com    ::sc_gem5::Process *p = ::sc_gem5::Process::newest();
34213315Sgabeblack@google.com    if (p->procKind() == SC_CTHREAD_PROC_) {
34313315Sgabeblack@google.com        SC_REPORT_WARNING("(W524) dont_initialize() has no effect for "
34413315Sgabeblack@google.com                "SC_CTHREADs", "");
34513315Sgabeblack@google.com    }
34613315Sgabeblack@google.com    p->dontInitialize(true);
34712837Sgabeblack@google.com}
34812837Sgabeblack@google.com
34912837Sgabeblack@google.comvoid
35012953Sgabeblack@google.comsc_module::set_stack_size(size_t size)
35112837Sgabeblack@google.com{
35212953Sgabeblack@google.com    ::sc_gem5::Process::newest()->setStackSize(size);
35312837Sgabeblack@google.com}
35412837Sgabeblack@google.com
35512837Sgabeblack@google.com
35612951Sgabeblack@google.comvoid sc_module::next_trigger() { ::sc_core::next_trigger(); }
35712951Sgabeblack@google.com
35812837Sgabeblack@google.comvoid
35912951Sgabeblack@google.comsc_module::next_trigger(const sc_event &e)
36012837Sgabeblack@google.com{
36112951Sgabeblack@google.com    ::sc_core::next_trigger(e);
36212837Sgabeblack@google.com}
36312837Sgabeblack@google.com
36412837Sgabeblack@google.comvoid
36512951Sgabeblack@google.comsc_module::next_trigger(const sc_event_or_list &eol)
36612837Sgabeblack@google.com{
36712951Sgabeblack@google.com    ::sc_core::next_trigger(eol);
36812837Sgabeblack@google.com}
36912837Sgabeblack@google.com
37012837Sgabeblack@google.comvoid
37112951Sgabeblack@google.comsc_module::next_trigger(const sc_event_and_list &eal)
37212837Sgabeblack@google.com{
37312951Sgabeblack@google.com    ::sc_core::next_trigger(eal);
37412837Sgabeblack@google.com}
37512837Sgabeblack@google.com
37612837Sgabeblack@google.comvoid
37712951Sgabeblack@google.comsc_module::next_trigger(const sc_time &t)
37812837Sgabeblack@google.com{
37912951Sgabeblack@google.com    ::sc_core::next_trigger(t);
38012837Sgabeblack@google.com}
38112837Sgabeblack@google.com
38212837Sgabeblack@google.comvoid
38312951Sgabeblack@google.comsc_module::next_trigger(double d, sc_time_unit u)
38412837Sgabeblack@google.com{
38512951Sgabeblack@google.com    ::sc_core::next_trigger(d, u);
38612837Sgabeblack@google.com}
38712837Sgabeblack@google.com
38812837Sgabeblack@google.comvoid
38912951Sgabeblack@google.comsc_module::next_trigger(const sc_time &t, const sc_event &e)
39012837Sgabeblack@google.com{
39112951Sgabeblack@google.com    ::sc_core::next_trigger(t, e);
39212837Sgabeblack@google.com}
39312837Sgabeblack@google.com
39412837Sgabeblack@google.comvoid
39512951Sgabeblack@google.comsc_module::next_trigger(double d, sc_time_unit u, const sc_event &e)
39612837Sgabeblack@google.com{
39712951Sgabeblack@google.com    ::sc_core::next_trigger(d, u, e);
39812837Sgabeblack@google.com}
39912837Sgabeblack@google.com
40012837Sgabeblack@google.comvoid
40112951Sgabeblack@google.comsc_module::next_trigger(const sc_time &t, const sc_event_or_list &eol)
40212837Sgabeblack@google.com{
40312951Sgabeblack@google.com    ::sc_core::next_trigger(t, eol);
40412837Sgabeblack@google.com}
40512837Sgabeblack@google.com
40612837Sgabeblack@google.comvoid
40712951Sgabeblack@google.comsc_module::next_trigger(double d, sc_time_unit u, const sc_event_or_list &eol)
40812837Sgabeblack@google.com{
40912951Sgabeblack@google.com    ::sc_core::next_trigger(d, u, eol);
41012837Sgabeblack@google.com}
41112837Sgabeblack@google.com
41212837Sgabeblack@google.comvoid
41312951Sgabeblack@google.comsc_module::next_trigger(const sc_time &t, const sc_event_and_list &eal)
41412837Sgabeblack@google.com{
41512951Sgabeblack@google.com    ::sc_core::next_trigger(t, eal);
41612837Sgabeblack@google.com}
41712837Sgabeblack@google.com
41812837Sgabeblack@google.comvoid
41912951Sgabeblack@google.comsc_module::next_trigger(double d, sc_time_unit u, const sc_event_and_list &eal)
42012837Sgabeblack@google.com{
42112951Sgabeblack@google.com    ::sc_core::next_trigger(d, u, eal);
42212837Sgabeblack@google.com}
42312837Sgabeblack@google.com
42412837Sgabeblack@google.com
42512929Sgabeblack@google.combool
42612929Sgabeblack@google.comsc_module::timed_out()
42712929Sgabeblack@google.com{
42813189Sgabeblack@google.com    return ::sc_core::timed_out();
42912929Sgabeblack@google.com}
43012929Sgabeblack@google.com
43112929Sgabeblack@google.com
43212837Sgabeblack@google.comvoid
43312837Sgabeblack@google.comsc_module::wait()
43412837Sgabeblack@google.com{
43512951Sgabeblack@google.com    ::sc_core::wait();
43612837Sgabeblack@google.com}
43712837Sgabeblack@google.com
43812837Sgabeblack@google.comvoid
43912951Sgabeblack@google.comsc_module::wait(int i)
44012837Sgabeblack@google.com{
44112951Sgabeblack@google.com    ::sc_core::wait(i);
44212837Sgabeblack@google.com}
44312837Sgabeblack@google.com
44412837Sgabeblack@google.comvoid
44512951Sgabeblack@google.comsc_module::wait(const sc_event &e)
44612837Sgabeblack@google.com{
44712951Sgabeblack@google.com    ::sc_core::wait(e);
44812837Sgabeblack@google.com}
44912837Sgabeblack@google.com
45012837Sgabeblack@google.comvoid
45112951Sgabeblack@google.comsc_module::wait(const sc_event_or_list &eol)
45212837Sgabeblack@google.com{
45312951Sgabeblack@google.com    ::sc_core::wait(eol);
45412837Sgabeblack@google.com}
45512837Sgabeblack@google.com
45612837Sgabeblack@google.comvoid
45712951Sgabeblack@google.comsc_module::wait(const sc_event_and_list &eal)
45812837Sgabeblack@google.com{
45912951Sgabeblack@google.com    ::sc_core::wait(eal);
46012837Sgabeblack@google.com}
46112837Sgabeblack@google.com
46212837Sgabeblack@google.comvoid
46312951Sgabeblack@google.comsc_module::wait(const sc_time &t)
46412837Sgabeblack@google.com{
46512951Sgabeblack@google.com    ::sc_core::wait(t);
46612837Sgabeblack@google.com}
46712837Sgabeblack@google.com
46812837Sgabeblack@google.comvoid
46912951Sgabeblack@google.comsc_module::wait(double d, sc_time_unit u)
47012837Sgabeblack@google.com{
47112951Sgabeblack@google.com    ::sc_core::wait(d, u);
47212837Sgabeblack@google.com}
47312837Sgabeblack@google.com
47412837Sgabeblack@google.comvoid
47512951Sgabeblack@google.comsc_module::wait(const sc_time &t, const sc_event &e)
47612837Sgabeblack@google.com{
47712951Sgabeblack@google.com    ::sc_core::wait(t, e);
47812837Sgabeblack@google.com}
47912837Sgabeblack@google.com
48012837Sgabeblack@google.comvoid
48112951Sgabeblack@google.comsc_module::wait(double d, sc_time_unit u, const sc_event &e)
48212837Sgabeblack@google.com{
48312951Sgabeblack@google.com    ::sc_core::wait(d, u, e);
48412837Sgabeblack@google.com}
48512837Sgabeblack@google.com
48612837Sgabeblack@google.comvoid
48712951Sgabeblack@google.comsc_module::wait(const sc_time &t, const sc_event_or_list &eol)
48812837Sgabeblack@google.com{
48912951Sgabeblack@google.com    ::sc_core::wait(t, eol);
49012837Sgabeblack@google.com}
49112837Sgabeblack@google.com
49212837Sgabeblack@google.comvoid
49312951Sgabeblack@google.comsc_module::wait(double d, sc_time_unit u, const sc_event_or_list &eol)
49412837Sgabeblack@google.com{
49512951Sgabeblack@google.com    ::sc_core::wait(d, u, eol);
49612837Sgabeblack@google.com}
49712837Sgabeblack@google.com
49812837Sgabeblack@google.comvoid
49912951Sgabeblack@google.comsc_module::wait(const sc_time &t, const sc_event_and_list &eal)
50012837Sgabeblack@google.com{
50112951Sgabeblack@google.com    ::sc_core::wait(t, eal);
50212837Sgabeblack@google.com}
50312837Sgabeblack@google.com
50412837Sgabeblack@google.comvoid
50512951Sgabeblack@google.comsc_module::wait(double d, sc_time_unit u, const sc_event_and_list &eal)
50612837Sgabeblack@google.com{
50712951Sgabeblack@google.com    ::sc_core::wait(d, u, eal);
50812837Sgabeblack@google.com}
50912837Sgabeblack@google.com
51012837Sgabeblack@google.com
51112837Sgabeblack@google.comvoid
51212909Sgabeblack@google.comsc_module::halt()
51312909Sgabeblack@google.com{
51412951Sgabeblack@google.com    ::sc_core::halt();
51512909Sgabeblack@google.com}
51612909Sgabeblack@google.com
51712914Sgabeblack@google.comvoid
51812951Sgabeblack@google.comsc_module::at_posedge(const sc_signal_in_if<bool> &s)
51912914Sgabeblack@google.com{
52012951Sgabeblack@google.com    ::sc_core::at_posedge(s);
52112914Sgabeblack@google.com}
52212914Sgabeblack@google.com
52312914Sgabeblack@google.comvoid
52412951Sgabeblack@google.comsc_module::at_posedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
52512914Sgabeblack@google.com{
52612951Sgabeblack@google.com    ::sc_core::at_posedge(s);
52712914Sgabeblack@google.com}
52812914Sgabeblack@google.com
52912914Sgabeblack@google.comvoid
53012951Sgabeblack@google.comsc_module::at_negedge(const sc_signal_in_if<bool> &s)
53112914Sgabeblack@google.com{
53212951Sgabeblack@google.com    ::sc_core::at_negedge(s);
53312914Sgabeblack@google.com}
53412914Sgabeblack@google.com
53512914Sgabeblack@google.comvoid
53612951Sgabeblack@google.comsc_module::at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
53712914Sgabeblack@google.com{
53812951Sgabeblack@google.com    ::sc_core::at_negedge(s);
53912914Sgabeblack@google.com}
54012914Sgabeblack@google.com
54112909Sgabeblack@google.com
54212909Sgabeblack@google.comvoid
54312837Sgabeblack@google.comnext_trigger()
54412837Sgabeblack@google.com{
54512958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
54613206Sgabeblack@google.com    p->cancelTimeout();
54713206Sgabeblack@google.com    p->clearDynamic();
54812837Sgabeblack@google.com}
54912837Sgabeblack@google.com
55012837Sgabeblack@google.comvoid
55112958Sgabeblack@google.comnext_trigger(const sc_event &e)
55212837Sgabeblack@google.com{
55312958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
55413206Sgabeblack@google.com    p->cancelTimeout();
55513207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEvent(p, &e);
55612837Sgabeblack@google.com}
55712837Sgabeblack@google.com
55812837Sgabeblack@google.comvoid
55912958Sgabeblack@google.comnext_trigger(const sc_event_or_list &eol)
56012837Sgabeblack@google.com{
56112958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
56213206Sgabeblack@google.com    p->cancelTimeout();
56313207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol);
56412837Sgabeblack@google.com}
56512837Sgabeblack@google.com
56612837Sgabeblack@google.comvoid
56712958Sgabeblack@google.comnext_trigger(const sc_event_and_list &eal)
56812837Sgabeblack@google.com{
56912958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
57013206Sgabeblack@google.com    p->cancelTimeout();
57113207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal);
57212837Sgabeblack@google.com}
57312837Sgabeblack@google.com
57412837Sgabeblack@google.comvoid
57512958Sgabeblack@google.comnext_trigger(const sc_time &t)
57612837Sgabeblack@google.com{
57712958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
57813206Sgabeblack@google.com    p->setTimeout(t);
57913206Sgabeblack@google.com    p->clearDynamic();
58012837Sgabeblack@google.com}
58112837Sgabeblack@google.com
58212837Sgabeblack@google.comvoid
58312951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u)
58412837Sgabeblack@google.com{
58512951Sgabeblack@google.com    next_trigger(sc_time(d, u));
58612837Sgabeblack@google.com}
58712837Sgabeblack@google.com
58812837Sgabeblack@google.comvoid
58912958Sgabeblack@google.comnext_trigger(const sc_time &t, const sc_event &e)
59012837Sgabeblack@google.com{
59112958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
59213206Sgabeblack@google.com    p->setTimeout(t);
59313207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEvent(p, &e);
59412837Sgabeblack@google.com}
59512837Sgabeblack@google.com
59612837Sgabeblack@google.comvoid
59712951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u, const sc_event &e)
59812837Sgabeblack@google.com{
59912951Sgabeblack@google.com    next_trigger(sc_time(d, u), e);
60012837Sgabeblack@google.com}
60112837Sgabeblack@google.com
60212837Sgabeblack@google.comvoid
60312958Sgabeblack@google.comnext_trigger(const sc_time &t, const sc_event_or_list &eol)
60412837Sgabeblack@google.com{
60512958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
60613206Sgabeblack@google.com    p->setTimeout(t);
60713207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol);
60812837Sgabeblack@google.com}
60912837Sgabeblack@google.com
61012837Sgabeblack@google.comvoid
61112951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u, const sc_event_or_list &eol)
61212837Sgabeblack@google.com{
61312951Sgabeblack@google.com    next_trigger(sc_time(d, u), eol);
61412837Sgabeblack@google.com}
61512837Sgabeblack@google.com
61612837Sgabeblack@google.comvoid
61712958Sgabeblack@google.comnext_trigger(const sc_time &t, const sc_event_and_list &eal)
61812837Sgabeblack@google.com{
61912958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
62013206Sgabeblack@google.com    p->setTimeout(t);
62113207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal);
62212837Sgabeblack@google.com}
62312837Sgabeblack@google.com
62412837Sgabeblack@google.comvoid
62512951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u, const sc_event_and_list &eal)
62612837Sgabeblack@google.com{
62712951Sgabeblack@google.com    next_trigger(sc_time(d, u), eal);
62812837Sgabeblack@google.com}
62912837Sgabeblack@google.com
63012929Sgabeblack@google.combool
63112929Sgabeblack@google.comtimed_out()
63212929Sgabeblack@google.com{
63313189Sgabeblack@google.com    ::sc_gem5::Process *p = sc_gem5::scheduler.current();
63413189Sgabeblack@google.com    if (!p)
63513189Sgabeblack@google.com        return false;
63613189Sgabeblack@google.com    else
63713189Sgabeblack@google.com        return p->timedOut();
63812929Sgabeblack@google.com}
63912929Sgabeblack@google.com
64012837Sgabeblack@google.com
64113248Sgabeblack@google.comnamespace
64213248Sgabeblack@google.com{
64313248Sgabeblack@google.com
64413248Sgabeblack@google.combool
64513248Sgabeblack@google.comwaitErrorCheck(sc_gem5::Process *p)
64613248Sgabeblack@google.com{
64713248Sgabeblack@google.com    if (p->procKind() == SC_METHOD_PROC_) {
64813248Sgabeblack@google.com        SC_REPORT_ERROR(
64913248Sgabeblack@google.com                "(E519) wait() is only allowed in SC_THREADs and SC_CTHREADs",
65013248Sgabeblack@google.com                "\n        in SC_METHODs use next_trigger() instead");
65113248Sgabeblack@google.com        return true;
65213248Sgabeblack@google.com    }
65313248Sgabeblack@google.com    return false;
65413248Sgabeblack@google.com}
65513248Sgabeblack@google.com
65613248Sgabeblack@google.com} // anonymous namespace
65713248Sgabeblack@google.com
65812837Sgabeblack@google.comvoid
65912837Sgabeblack@google.comwait()
66012837Sgabeblack@google.com{
66112958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
66213248Sgabeblack@google.com    if (waitErrorCheck(p))
66313248Sgabeblack@google.com        return;
66413206Sgabeblack@google.com    p->cancelTimeout();
66513206Sgabeblack@google.com    p->clearDynamic();
66612958Sgabeblack@google.com    sc_gem5::scheduler.yield();
66712837Sgabeblack@google.com}
66812837Sgabeblack@google.com
66912837Sgabeblack@google.comvoid
67012958Sgabeblack@google.comwait(int n)
67112837Sgabeblack@google.com{
67213146Sgabeblack@google.com    if (n <= 0) {
67313146Sgabeblack@google.com        std::string msg = csprintf("n = %d", n);
67413146Sgabeblack@google.com        SC_REPORT_ERROR("(E525) wait(n) is only valid for n > 0", msg.c_str());
67513146Sgabeblack@google.com    }
67613260Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
67713260Sgabeblack@google.com    p->waitCount(n - 1);
67813260Sgabeblack@google.com    wait();
67912837Sgabeblack@google.com}
68012837Sgabeblack@google.com
68112837Sgabeblack@google.comvoid
68212958Sgabeblack@google.comwait(const sc_event &e)
68312837Sgabeblack@google.com{
68412958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
68513248Sgabeblack@google.com    if (waitErrorCheck(p))
68613248Sgabeblack@google.com        return;
68713206Sgabeblack@google.com    p->cancelTimeout();
68813207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEvent(p, &e);
68912958Sgabeblack@google.com    sc_gem5::scheduler.yield();
69012837Sgabeblack@google.com}
69112837Sgabeblack@google.com
69212837Sgabeblack@google.comvoid
69312958Sgabeblack@google.comwait(const sc_event_or_list &eol)
69412837Sgabeblack@google.com{
69512958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
69613248Sgabeblack@google.com    if (waitErrorCheck(p))
69713248Sgabeblack@google.com        return;
69813206Sgabeblack@google.com    p->cancelTimeout();
69913207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol);
70012958Sgabeblack@google.com    sc_gem5::scheduler.yield();
70112837Sgabeblack@google.com}
70212837Sgabeblack@google.com
70312837Sgabeblack@google.comvoid
70412958Sgabeblack@google.comwait(const sc_event_and_list &eal)
70512837Sgabeblack@google.com{
70612958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
70713248Sgabeblack@google.com    if (waitErrorCheck(p))
70813248Sgabeblack@google.com        return;
70913206Sgabeblack@google.com    p->cancelTimeout();
71013207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal);
71112958Sgabeblack@google.com    sc_gem5::scheduler.yield();
71212837Sgabeblack@google.com}
71312837Sgabeblack@google.com
71412837Sgabeblack@google.comvoid
71512958Sgabeblack@google.comwait(const sc_time &t)
71612837Sgabeblack@google.com{
71712958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
71813248Sgabeblack@google.com    if (waitErrorCheck(p))
71913248Sgabeblack@google.com        return;
72013206Sgabeblack@google.com    p->setTimeout(t);
72113206Sgabeblack@google.com    p->clearDynamic();
72212958Sgabeblack@google.com    sc_gem5::scheduler.yield();
72312837Sgabeblack@google.com}
72412837Sgabeblack@google.com
72512837Sgabeblack@google.comvoid
72612951Sgabeblack@google.comwait(double d, sc_time_unit u)
72712837Sgabeblack@google.com{
72812951Sgabeblack@google.com    wait(sc_time(d, u));
72912837Sgabeblack@google.com}
73012837Sgabeblack@google.com
73112837Sgabeblack@google.comvoid
73212958Sgabeblack@google.comwait(const sc_time &t, const sc_event &e)
73312837Sgabeblack@google.com{
73412958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
73513248Sgabeblack@google.com    if (waitErrorCheck(p))
73613248Sgabeblack@google.com        return;
73713206Sgabeblack@google.com    p->setTimeout(t);
73813207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEvent(p, &e);
73912958Sgabeblack@google.com    sc_gem5::scheduler.yield();
74012837Sgabeblack@google.com}
74112837Sgabeblack@google.com
74212837Sgabeblack@google.comvoid
74312951Sgabeblack@google.comwait(double d, sc_time_unit u, const sc_event &e)
74412837Sgabeblack@google.com{
74512951Sgabeblack@google.com    wait(sc_time(d, u), e);
74612837Sgabeblack@google.com}
74712837Sgabeblack@google.com
74812837Sgabeblack@google.comvoid
74912958Sgabeblack@google.comwait(const sc_time &t, const sc_event_or_list &eol)
75012837Sgabeblack@google.com{
75112958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
75213248Sgabeblack@google.com    if (waitErrorCheck(p))
75313248Sgabeblack@google.com        return;
75413206Sgabeblack@google.com    p->setTimeout(t);
75513207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol);
75612958Sgabeblack@google.com    sc_gem5::scheduler.yield();
75712837Sgabeblack@google.com}
75812837Sgabeblack@google.com
75912837Sgabeblack@google.comvoid
76012951Sgabeblack@google.comwait(double d, sc_time_unit u, const sc_event_or_list &eol)
76112837Sgabeblack@google.com{
76212951Sgabeblack@google.com    wait(sc_time(d, u), eol);
76312837Sgabeblack@google.com}
76412837Sgabeblack@google.com
76512837Sgabeblack@google.comvoid
76612958Sgabeblack@google.comwait(const sc_time &t, const sc_event_and_list &eal)
76712837Sgabeblack@google.com{
76812958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
76913248Sgabeblack@google.com    if (waitErrorCheck(p))
77013248Sgabeblack@google.com        return;
77113206Sgabeblack@google.com    p->setTimeout(t);
77213207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal);
77312958Sgabeblack@google.com    sc_gem5::scheduler.yield();
77412837Sgabeblack@google.com}
77512837Sgabeblack@google.com
77612837Sgabeblack@google.comvoid
77712951Sgabeblack@google.comwait(double d, sc_time_unit u, const sc_event_and_list &eal)
77812837Sgabeblack@google.com{
77912951Sgabeblack@google.com    wait(sc_time(d, u), eal);
78012837Sgabeblack@google.com}
78112837Sgabeblack@google.com
78212909Sgabeblack@google.comvoid
78312909Sgabeblack@google.comhalt()
78412909Sgabeblack@google.com{
78513175Sgabeblack@google.com    ::sc_core::wait();
78613175Sgabeblack@google.com    throw ::sc_gem5::ScHalt();
78712909Sgabeblack@google.com}
78812909Sgabeblack@google.com
78912914Sgabeblack@google.comvoid
79013155Sgabeblack@google.comat_posedge(const sc_signal_in_if<bool> &s)
79112914Sgabeblack@google.com{
79213155Sgabeblack@google.com    while (s.read())
79313155Sgabeblack@google.com        wait();
79413155Sgabeblack@google.com    while (!s.read())
79513155Sgabeblack@google.com        wait();
79612914Sgabeblack@google.com}
79712914Sgabeblack@google.com
79812914Sgabeblack@google.comvoid
79913155Sgabeblack@google.comat_posedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
80012914Sgabeblack@google.com{
80113155Sgabeblack@google.com    while (s.read() == sc_dt::Log_1)
80213155Sgabeblack@google.com        wait();
80313155Sgabeblack@google.com    while (s.read() == sc_dt::Log_0)
80413155Sgabeblack@google.com        wait();
80512914Sgabeblack@google.com}
80612914Sgabeblack@google.com
80712914Sgabeblack@google.comvoid
80813155Sgabeblack@google.comat_negedge(const sc_signal_in_if<bool> &s)
80912914Sgabeblack@google.com{
81013155Sgabeblack@google.com    while (!s.read())
81113155Sgabeblack@google.com        wait();
81213155Sgabeblack@google.com    while (s.read())
81313155Sgabeblack@google.com        wait();
81412914Sgabeblack@google.com}
81512914Sgabeblack@google.com
81612914Sgabeblack@google.comvoid
81713155Sgabeblack@google.comat_negedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
81812914Sgabeblack@google.com{
81913155Sgabeblack@google.com    while (s.read() == sc_dt::Log_0)
82013155Sgabeblack@google.com        wait();
82113155Sgabeblack@google.com    while (s.read() == sc_dt::Log_1)
82213155Sgabeblack@google.com        wait();
82312914Sgabeblack@google.com}
82412914Sgabeblack@google.com
82512837Sgabeblack@google.comconst char *
82613035Sgabeblack@google.comsc_gen_unique_name(const char *seed)
82712837Sgabeblack@google.com{
82813296Sgabeblack@google.com    if (!seed || seed[0] == '\0') {
82913296Sgabeblack@google.com        SC_REPORT_ERROR(
83013296Sgabeblack@google.com                "(E532) cannot generate unique name from null string", "");
83113296Sgabeblack@google.com        seed = "unnamed";
83213296Sgabeblack@google.com    }
83313296Sgabeblack@google.com
83413268Sgabeblack@google.com    auto mod = sc_gem5::pickParentModule();
83513285Sgabeblack@google.com    if (mod)
83613285Sgabeblack@google.com        return mod->uniqueName(seed);
83713296Sgabeblack@google.com
83813285Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
83913285Sgabeblack@google.com    if (p)
84013285Sgabeblack@google.com        return p->uniqueName(seed);
84113296Sgabeblack@google.com
84213303Sgabeblack@google.com    return ::sc_gem5::globalNameGen.gen(seed);
84312837Sgabeblack@google.com}
84412837Sgabeblack@google.com
84512837Sgabeblack@google.combool
84612930Sgabeblack@google.comsc_hierarchical_name_exists(const char *name)
84712930Sgabeblack@google.com{
84813280Sgabeblack@google.com    return sc_gem5::findEvent(name) != sc_gem5::allEvents.end() ||
84913280Sgabeblack@google.com        ::sc_gem5::findObject(name, sc_gem5::allObjects);
85012930Sgabeblack@google.com}
85112930Sgabeblack@google.com
85212930Sgabeblack@google.combool
85312837Sgabeblack@google.comsc_start_of_simulation_invoked()
85412837Sgabeblack@google.com{
85512982Sgabeblack@google.com    return ::sc_gem5::kernel->startOfSimulationComplete();
85612837Sgabeblack@google.com}
85712837Sgabeblack@google.com
85812837Sgabeblack@google.combool
85912837Sgabeblack@google.comsc_end_of_simulation_invoked()
86012837Sgabeblack@google.com{
86112982Sgabeblack@google.com    return ::sc_gem5::kernel->endOfSimulationComplete();
86212837Sgabeblack@google.com}
86312837Sgabeblack@google.com
86412901Sgabeblack@google.comsc_module *
86512901Sgabeblack@google.comsc_module_sc_new(sc_module *mod)
86612901Sgabeblack@google.com{
86712901Sgabeblack@google.com    static std::vector<std::unique_ptr<sc_module> > modules;
86812901Sgabeblack@google.com    modules.emplace_back(mod);
86912901Sgabeblack@google.com    return mod;
87012901Sgabeblack@google.com}
87112901Sgabeblack@google.com
87212837Sgabeblack@google.com} // namespace sc_core
873