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
3413785Sgabeblack@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"
4613317Sgabeblack@google.com#include "systemc/ext/core/messages.hh"
4712837Sgabeblack@google.com#include "systemc/ext/core/sc_module.hh"
4812951Sgabeblack@google.com#include "systemc/ext/core/sc_module_name.hh"
4913155Sgabeblack@google.com#include "systemc/ext/dt/bit/sc_logic.hh"
5013135Sgabeblack@google.com#include "systemc/ext/utils/sc_report_handler.hh"
5112837Sgabeblack@google.com
5212952Sgabeblack@google.comnamespace sc_gem5
5312952Sgabeblack@google.com{
5412952Sgabeblack@google.com
5512952Sgabeblack@google.comProcess *
5612952Sgabeblack@google.comnewMethodProcess(const char *name, ProcessFuncWrapper *func)
5712952Sgabeblack@google.com{
5813135Sgabeblack@google.com    Method *p = new Method(name, func);
5913135Sgabeblack@google.com    if (::sc_core::sc_is_running()) {
6013135Sgabeblack@google.com        std::string name = p->name();
6113135Sgabeblack@google.com        delete p;
6213317Sgabeblack@google.com        SC_REPORT_ERROR(sc_core::SC_ID_MODULE_METHOD_AFTER_START_,
6313317Sgabeblack@google.com                name.c_str());
6413135Sgabeblack@google.com        return nullptr;
6513135Sgabeblack@google.com    }
6612993Sgabeblack@google.com    scheduler.reg(p);
6712993Sgabeblack@google.com    return p;
6812952Sgabeblack@google.com}
6912952Sgabeblack@google.com
7012952Sgabeblack@google.comProcess *
7112952Sgabeblack@google.comnewThreadProcess(const char *name, ProcessFuncWrapper *func)
7212952Sgabeblack@google.com{
7313135Sgabeblack@google.com    Thread *p = new Thread(name, func);
7413135Sgabeblack@google.com    if (::sc_core::sc_is_running()) {
7513135Sgabeblack@google.com        std::string name = p->name();
7613135Sgabeblack@google.com        delete p;
7713317Sgabeblack@google.com        SC_REPORT_ERROR(sc_core::SC_ID_MODULE_THREAD_AFTER_START_,
7813317Sgabeblack@google.com                name.c_str());
7913135Sgabeblack@google.com        return nullptr;
8013135Sgabeblack@google.com    }
8112993Sgabeblack@google.com    scheduler.reg(p);
8212993Sgabeblack@google.com    return p;
8312952Sgabeblack@google.com}
8412952Sgabeblack@google.com
8512952Sgabeblack@google.comProcess *
8612952Sgabeblack@google.comnewCThreadProcess(const char *name, ProcessFuncWrapper *func)
8712952Sgabeblack@google.com{
8813135Sgabeblack@google.com    CThread *p = new CThread(name, func);
8913135Sgabeblack@google.com    if (::sc_core::sc_is_running()) {
9013135Sgabeblack@google.com        std::string name = p->name();
9113135Sgabeblack@google.com        delete p;
9213317Sgabeblack@google.com        SC_REPORT_ERROR(sc_core::SC_ID_MODULE_CTHREAD_AFTER_START_,
9313317Sgabeblack@google.com                name.c_str());
9413135Sgabeblack@google.com        return nullptr;
9513135Sgabeblack@google.com    }
9612993Sgabeblack@google.com    scheduler.reg(p);
9713194Sgabeblack@google.com    p->dontInitialize(true);
9812993Sgabeblack@google.com    return p;
9912952Sgabeblack@google.com}
10012952Sgabeblack@google.com
10112952Sgabeblack@google.com} // namespace sc_gem5
10212952Sgabeblack@google.com
10312837Sgabeblack@google.comnamespace sc_core
10412837Sgabeblack@google.com{
10512837Sgabeblack@google.com
10613382Sgabeblack@google.comsc_bind_proxy::sc_bind_proxy() : _interface(nullptr), _port(nullptr) {}
10713382Sgabeblack@google.com
10813091Sgabeblack@google.comsc_bind_proxy::sc_bind_proxy(sc_interface &_interface) :
10912951Sgabeblack@google.com    _interface(&_interface), _port(nullptr)
11012951Sgabeblack@google.com{}
11112837Sgabeblack@google.com
11213091Sgabeblack@google.comsc_bind_proxy::sc_bind_proxy(sc_port_base &_port) :
11312951Sgabeblack@google.com    _interface(nullptr), _port(&_port)
11412951Sgabeblack@google.com{}
11512837Sgabeblack@google.com
11613382Sgabeblack@google.comconst sc_bind_proxy SC_BIND_PROXY_NIL;
11712837Sgabeblack@google.com
11813785Sgabeblack@google.com::Port &
11913785Sgabeblack@google.comsc_module::gem5_getPort(const std::string &if_name, int idx)
12013785Sgabeblack@google.com{
12113785Sgabeblack@google.com    fatal("%s does not have any port named %s\n", name(), if_name);
12213785Sgabeblack@google.com}
12313785Sgabeblack@google.com
12412982Sgabeblack@google.comsc_module::~sc_module() { delete _gem5_module; }
12512837Sgabeblack@google.com
12612837Sgabeblack@google.comvoid
12712837Sgabeblack@google.comsc_module::operator () (const sc_bind_proxy &p001,
12812837Sgabeblack@google.com                        const sc_bind_proxy &p002,
12912837Sgabeblack@google.com                        const sc_bind_proxy &p003,
13012837Sgabeblack@google.com                        const sc_bind_proxy &p004,
13112837Sgabeblack@google.com                        const sc_bind_proxy &p005,
13212837Sgabeblack@google.com                        const sc_bind_proxy &p006,
13312837Sgabeblack@google.com                        const sc_bind_proxy &p007,
13412837Sgabeblack@google.com                        const sc_bind_proxy &p008,
13512837Sgabeblack@google.com                        const sc_bind_proxy &p009,
13612837Sgabeblack@google.com                        const sc_bind_proxy &p010,
13712837Sgabeblack@google.com                        const sc_bind_proxy &p011,
13812837Sgabeblack@google.com                        const sc_bind_proxy &p012,
13912837Sgabeblack@google.com                        const sc_bind_proxy &p013,
14012837Sgabeblack@google.com                        const sc_bind_proxy &p014,
14112837Sgabeblack@google.com                        const sc_bind_proxy &p015,
14212837Sgabeblack@google.com                        const sc_bind_proxy &p016,
14312837Sgabeblack@google.com                        const sc_bind_proxy &p017,
14412837Sgabeblack@google.com                        const sc_bind_proxy &p018,
14512837Sgabeblack@google.com                        const sc_bind_proxy &p019,
14612837Sgabeblack@google.com                        const sc_bind_proxy &p020,
14712837Sgabeblack@google.com                        const sc_bind_proxy &p021,
14812837Sgabeblack@google.com                        const sc_bind_proxy &p022,
14912837Sgabeblack@google.com                        const sc_bind_proxy &p023,
15012837Sgabeblack@google.com                        const sc_bind_proxy &p024,
15112837Sgabeblack@google.com                        const sc_bind_proxy &p025,
15212837Sgabeblack@google.com                        const sc_bind_proxy &p026,
15312837Sgabeblack@google.com                        const sc_bind_proxy &p027,
15412837Sgabeblack@google.com                        const sc_bind_proxy &p028,
15512837Sgabeblack@google.com                        const sc_bind_proxy &p029,
15612837Sgabeblack@google.com                        const sc_bind_proxy &p030,
15712837Sgabeblack@google.com                        const sc_bind_proxy &p031,
15812837Sgabeblack@google.com                        const sc_bind_proxy &p032,
15912837Sgabeblack@google.com                        const sc_bind_proxy &p033,
16012837Sgabeblack@google.com                        const sc_bind_proxy &p034,
16112837Sgabeblack@google.com                        const sc_bind_proxy &p035,
16212837Sgabeblack@google.com                        const sc_bind_proxy &p036,
16312837Sgabeblack@google.com                        const sc_bind_proxy &p037,
16412837Sgabeblack@google.com                        const sc_bind_proxy &p038,
16512837Sgabeblack@google.com                        const sc_bind_proxy &p039,
16612837Sgabeblack@google.com                        const sc_bind_proxy &p040,
16712837Sgabeblack@google.com                        const sc_bind_proxy &p041,
16812837Sgabeblack@google.com                        const sc_bind_proxy &p042,
16912837Sgabeblack@google.com                        const sc_bind_proxy &p043,
17012837Sgabeblack@google.com                        const sc_bind_proxy &p044,
17112837Sgabeblack@google.com                        const sc_bind_proxy &p045,
17212837Sgabeblack@google.com                        const sc_bind_proxy &p046,
17312837Sgabeblack@google.com                        const sc_bind_proxy &p047,
17412837Sgabeblack@google.com                        const sc_bind_proxy &p048,
17512837Sgabeblack@google.com                        const sc_bind_proxy &p049,
17612837Sgabeblack@google.com                        const sc_bind_proxy &p050,
17712837Sgabeblack@google.com                        const sc_bind_proxy &p051,
17812837Sgabeblack@google.com                        const sc_bind_proxy &p052,
17912837Sgabeblack@google.com                        const sc_bind_proxy &p053,
18012837Sgabeblack@google.com                        const sc_bind_proxy &p054,
18112837Sgabeblack@google.com                        const sc_bind_proxy &p055,
18212837Sgabeblack@google.com                        const sc_bind_proxy &p056,
18312837Sgabeblack@google.com                        const sc_bind_proxy &p057,
18412837Sgabeblack@google.com                        const sc_bind_proxy &p058,
18512837Sgabeblack@google.com                        const sc_bind_proxy &p059,
18612837Sgabeblack@google.com                        const sc_bind_proxy &p060,
18712837Sgabeblack@google.com                        const sc_bind_proxy &p061,
18812837Sgabeblack@google.com                        const sc_bind_proxy &p062,
18912837Sgabeblack@google.com                        const sc_bind_proxy &p063,
19012837Sgabeblack@google.com                        const sc_bind_proxy &p064)
19112837Sgabeblack@google.com{
19213091Sgabeblack@google.com    std::vector<const ::sc_core::sc_bind_proxy *> proxies;
19313091Sgabeblack@google.com    auto insert = [&proxies](const ::sc_core::sc_bind_proxy &p) -> bool {
19413091Sgabeblack@google.com        if (!p.port() && !p.interface())
19513091Sgabeblack@google.com            return false;
19613091Sgabeblack@google.com        proxies.push_back(&p);
19713091Sgabeblack@google.com        return true;
19813091Sgabeblack@google.com    };
19913091Sgabeblack@google.com    insert(p001) && insert(p002) && insert(p003) && insert(p004) &&
20013091Sgabeblack@google.com    insert(p005) && insert(p006) && insert(p007) && insert(p008) &&
20113091Sgabeblack@google.com    insert(p009) && insert(p010) && insert(p011) && insert(p012) &&
20213091Sgabeblack@google.com    insert(p013) && insert(p014) && insert(p015) && insert(p016) &&
20313091Sgabeblack@google.com    insert(p017) && insert(p018) && insert(p019) && insert(p020) &&
20413091Sgabeblack@google.com    insert(p021) && insert(p022) && insert(p023) && insert(p024) &&
20513091Sgabeblack@google.com    insert(p025) && insert(p026) && insert(p027) && insert(p028) &&
20613091Sgabeblack@google.com    insert(p029) && insert(p030) && insert(p031) && insert(p032) &&
20713091Sgabeblack@google.com    insert(p033) && insert(p034) && insert(p035) && insert(p036) &&
20813091Sgabeblack@google.com    insert(p037) && insert(p038) && insert(p039) && insert(p040) &&
20913091Sgabeblack@google.com    insert(p041) && insert(p042) && insert(p043) && insert(p044) &&
21013091Sgabeblack@google.com    insert(p045) && insert(p046) && insert(p047) && insert(p048) &&
21113091Sgabeblack@google.com    insert(p049) && insert(p050) && insert(p051) && insert(p052) &&
21213091Sgabeblack@google.com    insert(p053) && insert(p054) && insert(p055) && insert(p056) &&
21313091Sgabeblack@google.com    insert(p057) && insert(p058) && insert(p059) && insert(p060) &&
21413091Sgabeblack@google.com    insert(p061) && insert(p062) && insert(p063) && insert(p064);
21513091Sgabeblack@google.com    _gem5_module->bindPorts(proxies);
21612837Sgabeblack@google.com}
21712837Sgabeblack@google.com
21813292Sgabeblack@google.comsc_module &
21913292Sgabeblack@google.comsc_module::operator << (sc_interface &iface)
22013292Sgabeblack@google.com{
22113292Sgabeblack@google.com    (*this)(iface);
22213292Sgabeblack@google.com    return *this;
22313292Sgabeblack@google.com}
22413292Sgabeblack@google.com
22513292Sgabeblack@google.comsc_module &
22613292Sgabeblack@google.comsc_module::operator << (sc_port_base &pb)
22713292Sgabeblack@google.com{
22813292Sgabeblack@google.com    (*this)(pb);
22913292Sgabeblack@google.com    return *this;
23013292Sgabeblack@google.com}
23113292Sgabeblack@google.com
23213292Sgabeblack@google.comsc_module &
23313292Sgabeblack@google.comsc_module::operator , (sc_interface &iface)
23413292Sgabeblack@google.com{
23513292Sgabeblack@google.com    (*this)(iface);
23613292Sgabeblack@google.com    return *this;
23713292Sgabeblack@google.com}
23813292Sgabeblack@google.com
23913292Sgabeblack@google.comsc_module &
24013292Sgabeblack@google.comsc_module::operator , (sc_port_base &pb)
24113292Sgabeblack@google.com{
24213292Sgabeblack@google.com    (*this)(pb);
24313292Sgabeblack@google.com    return *this;
24413292Sgabeblack@google.com}
24513292Sgabeblack@google.com
24612837Sgabeblack@google.comconst std::vector<sc_object *> &
24712837Sgabeblack@google.comsc_module::get_child_objects() const
24812837Sgabeblack@google.com{
24912951Sgabeblack@google.com    return _gem5_module->obj()->get_child_objects();
25012837Sgabeblack@google.com}
25112837Sgabeblack@google.com
25212837Sgabeblack@google.comconst std::vector<sc_event *> &
25312837Sgabeblack@google.comsc_module::get_child_events() const
25412837Sgabeblack@google.com{
25512951Sgabeblack@google.com    return _gem5_module->obj()->get_child_events();
25612837Sgabeblack@google.com}
25712837Sgabeblack@google.com
25812951Sgabeblack@google.comsc_module::sc_module() :
25913079Sgabeblack@google.com    sc_object(sc_gem5::newModuleChecked()->name()),
26012951Sgabeblack@google.com    _gem5_module(sc_gem5::currentModule())
26113284Sgabeblack@google.com{
26213317Sgabeblack@google.com    if (sc_is_running())
26313317Sgabeblack@google.com        SC_REPORT_ERROR(SC_ID_INSERT_MODULE_, "simulation running");
26413317Sgabeblack@google.com    if (::sc_gem5::scheduler.elaborationDone())
26513317Sgabeblack@google.com        SC_REPORT_ERROR(SC_ID_INSERT_MODULE_, "elaboration done");
26613284Sgabeblack@google.com}
26712837Sgabeblack@google.com
26812951Sgabeblack@google.comsc_module::sc_module(const sc_module_name &) : sc_module() {}
26913191Sgabeblack@google.comsc_module::sc_module(const char *_name) : sc_module(sc_module_name(_name))
27013191Sgabeblack@google.com{
27113191Sgabeblack@google.com    _gem5_module->deprecatedConstructor();
27213317Sgabeblack@google.com    SC_REPORT_WARNING(SC_ID_BAD_SC_MODULE_CONSTRUCTOR_, _name);
27313191Sgabeblack@google.com}
27412951Sgabeblack@google.comsc_module::sc_module(const std::string &_name) :
27512951Sgabeblack@google.com    sc_module(sc_module_name(_name.c_str()))
27613191Sgabeblack@google.com{
27713191Sgabeblack@google.com    _gem5_module->deprecatedConstructor();
27813317Sgabeblack@google.com    SC_REPORT_WARNING(SC_ID_BAD_SC_MODULE_CONSTRUCTOR_, _name.c_str());
27913191Sgabeblack@google.com}
28013191Sgabeblack@google.com
28113191Sgabeblack@google.comvoid
28213191Sgabeblack@google.comsc_module::end_module()
28313191Sgabeblack@google.com{
28413191Sgabeblack@google.com    _gem5_module->endModule();
28513191Sgabeblack@google.com}
28612928Sgabeblack@google.com
28712837Sgabeblack@google.comvoid
28813260Sgabeblack@google.comsc_module::reset_signal_is(const sc_in<bool> &port, bool val)
28912837Sgabeblack@google.com{
29013288Sgabeblack@google.com    ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), true, val);
29112837Sgabeblack@google.com}
29212837Sgabeblack@google.com
29312837Sgabeblack@google.comvoid
29413260Sgabeblack@google.comsc_module::reset_signal_is(const sc_inout<bool> &port, bool val)
29512837Sgabeblack@google.com{
29613288Sgabeblack@google.com    ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), true, val);
29712837Sgabeblack@google.com}
29812837Sgabeblack@google.com
29912837Sgabeblack@google.comvoid
30013260Sgabeblack@google.comsc_module::reset_signal_is(const sc_out<bool> &port, bool val)
30112837Sgabeblack@google.com{
30213288Sgabeblack@google.com    ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), true, val);
30312837Sgabeblack@google.com}
30412837Sgabeblack@google.com
30512837Sgabeblack@google.comvoid
30613260Sgabeblack@google.comsc_module::reset_signal_is(const sc_signal_in_if<bool> &signal, bool val)
30712837Sgabeblack@google.com{
30813288Sgabeblack@google.com    ::sc_gem5::newReset(&signal, ::sc_gem5::Process::newest(), true, val);
30912837Sgabeblack@google.com}
31012837Sgabeblack@google.com
31112837Sgabeblack@google.com
31212837Sgabeblack@google.comvoid
31313260Sgabeblack@google.comsc_module::async_reset_signal_is(const sc_in<bool> &port, bool val)
31412837Sgabeblack@google.com{
31513288Sgabeblack@google.com    ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), false, val);
31612837Sgabeblack@google.com}
31712837Sgabeblack@google.com
31812837Sgabeblack@google.comvoid
31913260Sgabeblack@google.comsc_module::async_reset_signal_is(const sc_inout<bool> &port, bool val)
32012837Sgabeblack@google.com{
32113288Sgabeblack@google.com    ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), false, val);
32212837Sgabeblack@google.com}
32312837Sgabeblack@google.com
32412837Sgabeblack@google.comvoid
32513260Sgabeblack@google.comsc_module::async_reset_signal_is(const sc_out<bool> &port, bool val)
32612837Sgabeblack@google.com{
32713288Sgabeblack@google.com    ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), false, val);
32812837Sgabeblack@google.com}
32912837Sgabeblack@google.com
33012837Sgabeblack@google.comvoid
33113260Sgabeblack@google.comsc_module::async_reset_signal_is(const sc_signal_in_if<bool> &signal, bool val)
33212837Sgabeblack@google.com{
33313288Sgabeblack@google.com    ::sc_gem5::newReset(&signal, ::sc_gem5::Process::newest(), false, val);
33412837Sgabeblack@google.com}
33512837Sgabeblack@google.com
33612837Sgabeblack@google.com
33712837Sgabeblack@google.comvoid
33812837Sgabeblack@google.comsc_module::dont_initialize()
33912837Sgabeblack@google.com{
34013315Sgabeblack@google.com    ::sc_gem5::Process *p = ::sc_gem5::Process::newest();
34113317Sgabeblack@google.com    if (p->procKind() == SC_CTHREAD_PROC_)
34213317Sgabeblack@google.com        SC_REPORT_WARNING(SC_ID_DONT_INITIALIZE_, "");
34313315Sgabeblack@google.com    p->dontInitialize(true);
34412837Sgabeblack@google.com}
34512837Sgabeblack@google.com
34612837Sgabeblack@google.comvoid
34712953Sgabeblack@google.comsc_module::set_stack_size(size_t size)
34812837Sgabeblack@google.com{
34912953Sgabeblack@google.com    ::sc_gem5::Process::newest()->setStackSize(size);
35012837Sgabeblack@google.com}
35112837Sgabeblack@google.com
35212837Sgabeblack@google.com
35312951Sgabeblack@google.comvoid sc_module::next_trigger() { ::sc_core::next_trigger(); }
35412951Sgabeblack@google.com
35512837Sgabeblack@google.comvoid
35612951Sgabeblack@google.comsc_module::next_trigger(const sc_event &e)
35712837Sgabeblack@google.com{
35812951Sgabeblack@google.com    ::sc_core::next_trigger(e);
35912837Sgabeblack@google.com}
36012837Sgabeblack@google.com
36112837Sgabeblack@google.comvoid
36212951Sgabeblack@google.comsc_module::next_trigger(const sc_event_or_list &eol)
36312837Sgabeblack@google.com{
36412951Sgabeblack@google.com    ::sc_core::next_trigger(eol);
36512837Sgabeblack@google.com}
36612837Sgabeblack@google.com
36712837Sgabeblack@google.comvoid
36812951Sgabeblack@google.comsc_module::next_trigger(const sc_event_and_list &eal)
36912837Sgabeblack@google.com{
37012951Sgabeblack@google.com    ::sc_core::next_trigger(eal);
37112837Sgabeblack@google.com}
37212837Sgabeblack@google.com
37312837Sgabeblack@google.comvoid
37412951Sgabeblack@google.comsc_module::next_trigger(const sc_time &t)
37512837Sgabeblack@google.com{
37612951Sgabeblack@google.com    ::sc_core::next_trigger(t);
37712837Sgabeblack@google.com}
37812837Sgabeblack@google.com
37912837Sgabeblack@google.comvoid
38012951Sgabeblack@google.comsc_module::next_trigger(double d, sc_time_unit u)
38112837Sgabeblack@google.com{
38212951Sgabeblack@google.com    ::sc_core::next_trigger(d, u);
38312837Sgabeblack@google.com}
38412837Sgabeblack@google.com
38512837Sgabeblack@google.comvoid
38612951Sgabeblack@google.comsc_module::next_trigger(const sc_time &t, const sc_event &e)
38712837Sgabeblack@google.com{
38812951Sgabeblack@google.com    ::sc_core::next_trigger(t, e);
38912837Sgabeblack@google.com}
39012837Sgabeblack@google.com
39112837Sgabeblack@google.comvoid
39212951Sgabeblack@google.comsc_module::next_trigger(double d, sc_time_unit u, const sc_event &e)
39312837Sgabeblack@google.com{
39412951Sgabeblack@google.com    ::sc_core::next_trigger(d, u, e);
39512837Sgabeblack@google.com}
39612837Sgabeblack@google.com
39712837Sgabeblack@google.comvoid
39812951Sgabeblack@google.comsc_module::next_trigger(const sc_time &t, const sc_event_or_list &eol)
39912837Sgabeblack@google.com{
40012951Sgabeblack@google.com    ::sc_core::next_trigger(t, eol);
40112837Sgabeblack@google.com}
40212837Sgabeblack@google.com
40312837Sgabeblack@google.comvoid
40412951Sgabeblack@google.comsc_module::next_trigger(double d, sc_time_unit u, const sc_event_or_list &eol)
40512837Sgabeblack@google.com{
40612951Sgabeblack@google.com    ::sc_core::next_trigger(d, u, eol);
40712837Sgabeblack@google.com}
40812837Sgabeblack@google.com
40912837Sgabeblack@google.comvoid
41012951Sgabeblack@google.comsc_module::next_trigger(const sc_time &t, const sc_event_and_list &eal)
41112837Sgabeblack@google.com{
41212951Sgabeblack@google.com    ::sc_core::next_trigger(t, eal);
41312837Sgabeblack@google.com}
41412837Sgabeblack@google.com
41512837Sgabeblack@google.comvoid
41612951Sgabeblack@google.comsc_module::next_trigger(double d, sc_time_unit u, const sc_event_and_list &eal)
41712837Sgabeblack@google.com{
41812951Sgabeblack@google.com    ::sc_core::next_trigger(d, u, eal);
41912837Sgabeblack@google.com}
42012837Sgabeblack@google.com
42112837Sgabeblack@google.com
42212929Sgabeblack@google.combool
42312929Sgabeblack@google.comsc_module::timed_out()
42412929Sgabeblack@google.com{
42513189Sgabeblack@google.com    return ::sc_core::timed_out();
42612929Sgabeblack@google.com}
42712929Sgabeblack@google.com
42812929Sgabeblack@google.com
42912837Sgabeblack@google.comvoid
43012837Sgabeblack@google.comsc_module::wait()
43112837Sgabeblack@google.com{
43212951Sgabeblack@google.com    ::sc_core::wait();
43312837Sgabeblack@google.com}
43412837Sgabeblack@google.com
43512837Sgabeblack@google.comvoid
43612951Sgabeblack@google.comsc_module::wait(int i)
43712837Sgabeblack@google.com{
43812951Sgabeblack@google.com    ::sc_core::wait(i);
43912837Sgabeblack@google.com}
44012837Sgabeblack@google.com
44112837Sgabeblack@google.comvoid
44212951Sgabeblack@google.comsc_module::wait(const sc_event &e)
44312837Sgabeblack@google.com{
44412951Sgabeblack@google.com    ::sc_core::wait(e);
44512837Sgabeblack@google.com}
44612837Sgabeblack@google.com
44712837Sgabeblack@google.comvoid
44812951Sgabeblack@google.comsc_module::wait(const sc_event_or_list &eol)
44912837Sgabeblack@google.com{
45012951Sgabeblack@google.com    ::sc_core::wait(eol);
45112837Sgabeblack@google.com}
45212837Sgabeblack@google.com
45312837Sgabeblack@google.comvoid
45412951Sgabeblack@google.comsc_module::wait(const sc_event_and_list &eal)
45512837Sgabeblack@google.com{
45612951Sgabeblack@google.com    ::sc_core::wait(eal);
45712837Sgabeblack@google.com}
45812837Sgabeblack@google.com
45912837Sgabeblack@google.comvoid
46012951Sgabeblack@google.comsc_module::wait(const sc_time &t)
46112837Sgabeblack@google.com{
46212951Sgabeblack@google.com    ::sc_core::wait(t);
46312837Sgabeblack@google.com}
46412837Sgabeblack@google.com
46512837Sgabeblack@google.comvoid
46612951Sgabeblack@google.comsc_module::wait(double d, sc_time_unit u)
46712837Sgabeblack@google.com{
46812951Sgabeblack@google.com    ::sc_core::wait(d, u);
46912837Sgabeblack@google.com}
47012837Sgabeblack@google.com
47112837Sgabeblack@google.comvoid
47212951Sgabeblack@google.comsc_module::wait(const sc_time &t, const sc_event &e)
47312837Sgabeblack@google.com{
47412951Sgabeblack@google.com    ::sc_core::wait(t, e);
47512837Sgabeblack@google.com}
47612837Sgabeblack@google.com
47712837Sgabeblack@google.comvoid
47812951Sgabeblack@google.comsc_module::wait(double d, sc_time_unit u, const sc_event &e)
47912837Sgabeblack@google.com{
48012951Sgabeblack@google.com    ::sc_core::wait(d, u, e);
48112837Sgabeblack@google.com}
48212837Sgabeblack@google.com
48312837Sgabeblack@google.comvoid
48412951Sgabeblack@google.comsc_module::wait(const sc_time &t, const sc_event_or_list &eol)
48512837Sgabeblack@google.com{
48612951Sgabeblack@google.com    ::sc_core::wait(t, eol);
48712837Sgabeblack@google.com}
48812837Sgabeblack@google.com
48912837Sgabeblack@google.comvoid
49012951Sgabeblack@google.comsc_module::wait(double d, sc_time_unit u, const sc_event_or_list &eol)
49112837Sgabeblack@google.com{
49212951Sgabeblack@google.com    ::sc_core::wait(d, u, eol);
49312837Sgabeblack@google.com}
49412837Sgabeblack@google.com
49512837Sgabeblack@google.comvoid
49612951Sgabeblack@google.comsc_module::wait(const sc_time &t, const sc_event_and_list &eal)
49712837Sgabeblack@google.com{
49812951Sgabeblack@google.com    ::sc_core::wait(t, eal);
49912837Sgabeblack@google.com}
50012837Sgabeblack@google.com
50112837Sgabeblack@google.comvoid
50212951Sgabeblack@google.comsc_module::wait(double d, sc_time_unit u, const sc_event_and_list &eal)
50312837Sgabeblack@google.com{
50412951Sgabeblack@google.com    ::sc_core::wait(d, u, eal);
50512837Sgabeblack@google.com}
50612837Sgabeblack@google.com
50712837Sgabeblack@google.com
50812837Sgabeblack@google.comvoid
50912909Sgabeblack@google.comsc_module::halt()
51012909Sgabeblack@google.com{
51112951Sgabeblack@google.com    ::sc_core::halt();
51212909Sgabeblack@google.com}
51312909Sgabeblack@google.com
51412914Sgabeblack@google.comvoid
51512951Sgabeblack@google.comsc_module::at_posedge(const sc_signal_in_if<bool> &s)
51612914Sgabeblack@google.com{
51712951Sgabeblack@google.com    ::sc_core::at_posedge(s);
51812914Sgabeblack@google.com}
51912914Sgabeblack@google.com
52012914Sgabeblack@google.comvoid
52112951Sgabeblack@google.comsc_module::at_posedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
52212914Sgabeblack@google.com{
52312951Sgabeblack@google.com    ::sc_core::at_posedge(s);
52412914Sgabeblack@google.com}
52512914Sgabeblack@google.com
52612914Sgabeblack@google.comvoid
52712951Sgabeblack@google.comsc_module::at_negedge(const sc_signal_in_if<bool> &s)
52812914Sgabeblack@google.com{
52912951Sgabeblack@google.com    ::sc_core::at_negedge(s);
53012914Sgabeblack@google.com}
53112914Sgabeblack@google.com
53212914Sgabeblack@google.comvoid
53312951Sgabeblack@google.comsc_module::at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
53412914Sgabeblack@google.com{
53512951Sgabeblack@google.com    ::sc_core::at_negedge(s);
53612914Sgabeblack@google.com}
53712914Sgabeblack@google.com
53812909Sgabeblack@google.com
53912909Sgabeblack@google.comvoid
54012837Sgabeblack@google.comnext_trigger()
54112837Sgabeblack@google.com{
54212958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
54313206Sgabeblack@google.com    p->cancelTimeout();
54413206Sgabeblack@google.com    p->clearDynamic();
54512837Sgabeblack@google.com}
54612837Sgabeblack@google.com
54712837Sgabeblack@google.comvoid
54812958Sgabeblack@google.comnext_trigger(const sc_event &e)
54912837Sgabeblack@google.com{
55012958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
55113206Sgabeblack@google.com    p->cancelTimeout();
55213207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEvent(p, &e);
55312837Sgabeblack@google.com}
55412837Sgabeblack@google.com
55512837Sgabeblack@google.comvoid
55612958Sgabeblack@google.comnext_trigger(const sc_event_or_list &eol)
55712837Sgabeblack@google.com{
55812958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
55913206Sgabeblack@google.com    p->cancelTimeout();
56013207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol);
56112837Sgabeblack@google.com}
56212837Sgabeblack@google.com
56312837Sgabeblack@google.comvoid
56412958Sgabeblack@google.comnext_trigger(const sc_event_and_list &eal)
56512837Sgabeblack@google.com{
56612958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
56713206Sgabeblack@google.com    p->cancelTimeout();
56813207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal);
56912837Sgabeblack@google.com}
57012837Sgabeblack@google.com
57112837Sgabeblack@google.comvoid
57212958Sgabeblack@google.comnext_trigger(const sc_time &t)
57312837Sgabeblack@google.com{
57412958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
57513206Sgabeblack@google.com    p->setTimeout(t);
57613206Sgabeblack@google.com    p->clearDynamic();
57712837Sgabeblack@google.com}
57812837Sgabeblack@google.com
57912837Sgabeblack@google.comvoid
58012951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u)
58112837Sgabeblack@google.com{
58212951Sgabeblack@google.com    next_trigger(sc_time(d, u));
58312837Sgabeblack@google.com}
58412837Sgabeblack@google.com
58512837Sgabeblack@google.comvoid
58612958Sgabeblack@google.comnext_trigger(const sc_time &t, const sc_event &e)
58712837Sgabeblack@google.com{
58812958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
58913206Sgabeblack@google.com    p->setTimeout(t);
59013207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEvent(p, &e);
59112837Sgabeblack@google.com}
59212837Sgabeblack@google.com
59312837Sgabeblack@google.comvoid
59412951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u, const sc_event &e)
59512837Sgabeblack@google.com{
59612951Sgabeblack@google.com    next_trigger(sc_time(d, u), e);
59712837Sgabeblack@google.com}
59812837Sgabeblack@google.com
59912837Sgabeblack@google.comvoid
60012958Sgabeblack@google.comnext_trigger(const sc_time &t, const sc_event_or_list &eol)
60112837Sgabeblack@google.com{
60212958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
60313206Sgabeblack@google.com    p->setTimeout(t);
60413207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol);
60512837Sgabeblack@google.com}
60612837Sgabeblack@google.com
60712837Sgabeblack@google.comvoid
60812951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u, const sc_event_or_list &eol)
60912837Sgabeblack@google.com{
61012951Sgabeblack@google.com    next_trigger(sc_time(d, u), eol);
61112837Sgabeblack@google.com}
61212837Sgabeblack@google.com
61312837Sgabeblack@google.comvoid
61412958Sgabeblack@google.comnext_trigger(const sc_time &t, const sc_event_and_list &eal)
61512837Sgabeblack@google.com{
61612958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
61713206Sgabeblack@google.com    p->setTimeout(t);
61813207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal);
61912837Sgabeblack@google.com}
62012837Sgabeblack@google.com
62112837Sgabeblack@google.comvoid
62212951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u, const sc_event_and_list &eal)
62312837Sgabeblack@google.com{
62412951Sgabeblack@google.com    next_trigger(sc_time(d, u), eal);
62512837Sgabeblack@google.com}
62612837Sgabeblack@google.com
62712929Sgabeblack@google.combool
62812929Sgabeblack@google.comtimed_out()
62912929Sgabeblack@google.com{
63013189Sgabeblack@google.com    ::sc_gem5::Process *p = sc_gem5::scheduler.current();
63113189Sgabeblack@google.com    if (!p)
63213189Sgabeblack@google.com        return false;
63313189Sgabeblack@google.com    else
63413189Sgabeblack@google.com        return p->timedOut();
63512929Sgabeblack@google.com}
63612929Sgabeblack@google.com
63712837Sgabeblack@google.com
63813248Sgabeblack@google.comnamespace
63913248Sgabeblack@google.com{
64013248Sgabeblack@google.com
64113248Sgabeblack@google.combool
64213248Sgabeblack@google.comwaitErrorCheck(sc_gem5::Process *p)
64313248Sgabeblack@google.com{
64413248Sgabeblack@google.com    if (p->procKind() == SC_METHOD_PROC_) {
64513317Sgabeblack@google.com        SC_REPORT_ERROR(SC_ID_WAIT_NOT_ALLOWED_,
64613248Sgabeblack@google.com                "\n        in SC_METHODs use next_trigger() instead");
64713248Sgabeblack@google.com        return true;
64813248Sgabeblack@google.com    }
64913248Sgabeblack@google.com    return false;
65013248Sgabeblack@google.com}
65113248Sgabeblack@google.com
65213248Sgabeblack@google.com} // anonymous namespace
65313248Sgabeblack@google.com
65412837Sgabeblack@google.comvoid
65512837Sgabeblack@google.comwait()
65612837Sgabeblack@google.com{
65712958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
65813248Sgabeblack@google.com    if (waitErrorCheck(p))
65913248Sgabeblack@google.com        return;
66013206Sgabeblack@google.com    p->cancelTimeout();
66113206Sgabeblack@google.com    p->clearDynamic();
66212958Sgabeblack@google.com    sc_gem5::scheduler.yield();
66312837Sgabeblack@google.com}
66412837Sgabeblack@google.com
66512837Sgabeblack@google.comvoid
66612958Sgabeblack@google.comwait(int n)
66712837Sgabeblack@google.com{
66813146Sgabeblack@google.com    if (n <= 0) {
66913146Sgabeblack@google.com        std::string msg = csprintf("n = %d", n);
67013317Sgabeblack@google.com        SC_REPORT_ERROR(SC_ID_WAIT_N_INVALID_, msg.c_str());
67113146Sgabeblack@google.com    }
67213260Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
67313260Sgabeblack@google.com    p->waitCount(n - 1);
67413260Sgabeblack@google.com    wait();
67512837Sgabeblack@google.com}
67612837Sgabeblack@google.com
67712837Sgabeblack@google.comvoid
67812958Sgabeblack@google.comwait(const sc_event &e)
67912837Sgabeblack@google.com{
68012958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
68113248Sgabeblack@google.com    if (waitErrorCheck(p))
68213248Sgabeblack@google.com        return;
68313206Sgabeblack@google.com    p->cancelTimeout();
68413207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEvent(p, &e);
68512958Sgabeblack@google.com    sc_gem5::scheduler.yield();
68612837Sgabeblack@google.com}
68712837Sgabeblack@google.com
68812837Sgabeblack@google.comvoid
68912958Sgabeblack@google.comwait(const sc_event_or_list &eol)
69012837Sgabeblack@google.com{
69112958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
69213248Sgabeblack@google.com    if (waitErrorCheck(p))
69313248Sgabeblack@google.com        return;
69413206Sgabeblack@google.com    p->cancelTimeout();
69513207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol);
69612958Sgabeblack@google.com    sc_gem5::scheduler.yield();
69712837Sgabeblack@google.com}
69812837Sgabeblack@google.com
69912837Sgabeblack@google.comvoid
70012958Sgabeblack@google.comwait(const sc_event_and_list &eal)
70112837Sgabeblack@google.com{
70212958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
70313248Sgabeblack@google.com    if (waitErrorCheck(p))
70413248Sgabeblack@google.com        return;
70513206Sgabeblack@google.com    p->cancelTimeout();
70613207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal);
70712958Sgabeblack@google.com    sc_gem5::scheduler.yield();
70812837Sgabeblack@google.com}
70912837Sgabeblack@google.com
71012837Sgabeblack@google.comvoid
71112958Sgabeblack@google.comwait(const sc_time &t)
71212837Sgabeblack@google.com{
71312958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
71413248Sgabeblack@google.com    if (waitErrorCheck(p))
71513248Sgabeblack@google.com        return;
71613206Sgabeblack@google.com    p->setTimeout(t);
71713206Sgabeblack@google.com    p->clearDynamic();
71812958Sgabeblack@google.com    sc_gem5::scheduler.yield();
71912837Sgabeblack@google.com}
72012837Sgabeblack@google.com
72112837Sgabeblack@google.comvoid
72212951Sgabeblack@google.comwait(double d, sc_time_unit u)
72312837Sgabeblack@google.com{
72412951Sgabeblack@google.com    wait(sc_time(d, u));
72512837Sgabeblack@google.com}
72612837Sgabeblack@google.com
72712837Sgabeblack@google.comvoid
72812958Sgabeblack@google.comwait(const sc_time &t, const sc_event &e)
72912837Sgabeblack@google.com{
73012958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
73113248Sgabeblack@google.com    if (waitErrorCheck(p))
73213248Sgabeblack@google.com        return;
73313206Sgabeblack@google.com    p->setTimeout(t);
73413207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEvent(p, &e);
73512958Sgabeblack@google.com    sc_gem5::scheduler.yield();
73612837Sgabeblack@google.com}
73712837Sgabeblack@google.com
73812837Sgabeblack@google.comvoid
73912951Sgabeblack@google.comwait(double d, sc_time_unit u, const sc_event &e)
74012837Sgabeblack@google.com{
74112951Sgabeblack@google.com    wait(sc_time(d, u), e);
74212837Sgabeblack@google.com}
74312837Sgabeblack@google.com
74412837Sgabeblack@google.comvoid
74512958Sgabeblack@google.comwait(const sc_time &t, const sc_event_or_list &eol)
74612837Sgabeblack@google.com{
74712958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
74813248Sgabeblack@google.com    if (waitErrorCheck(p))
74913248Sgabeblack@google.com        return;
75013206Sgabeblack@google.com    p->setTimeout(t);
75113207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol);
75212958Sgabeblack@google.com    sc_gem5::scheduler.yield();
75312837Sgabeblack@google.com}
75412837Sgabeblack@google.com
75512837Sgabeblack@google.comvoid
75612951Sgabeblack@google.comwait(double d, sc_time_unit u, const sc_event_or_list &eol)
75712837Sgabeblack@google.com{
75812951Sgabeblack@google.com    wait(sc_time(d, u), eol);
75912837Sgabeblack@google.com}
76012837Sgabeblack@google.com
76112837Sgabeblack@google.comvoid
76212958Sgabeblack@google.comwait(const sc_time &t, const sc_event_and_list &eal)
76312837Sgabeblack@google.com{
76412958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
76513248Sgabeblack@google.com    if (waitErrorCheck(p))
76613248Sgabeblack@google.com        return;
76713206Sgabeblack@google.com    p->setTimeout(t);
76813207Sgabeblack@google.com    ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal);
76912958Sgabeblack@google.com    sc_gem5::scheduler.yield();
77012837Sgabeblack@google.com}
77112837Sgabeblack@google.com
77212837Sgabeblack@google.comvoid
77312951Sgabeblack@google.comwait(double d, sc_time_unit u, const sc_event_and_list &eal)
77412837Sgabeblack@google.com{
77512951Sgabeblack@google.com    wait(sc_time(d, u), eal);
77612837Sgabeblack@google.com}
77712837Sgabeblack@google.com
77812909Sgabeblack@google.comvoid
77912909Sgabeblack@google.comhalt()
78012909Sgabeblack@google.com{
78113175Sgabeblack@google.com    ::sc_core::wait();
78213175Sgabeblack@google.com    throw ::sc_gem5::ScHalt();
78312909Sgabeblack@google.com}
78412909Sgabeblack@google.com
78512914Sgabeblack@google.comvoid
78613155Sgabeblack@google.comat_posedge(const sc_signal_in_if<bool> &s)
78712914Sgabeblack@google.com{
78813155Sgabeblack@google.com    while (s.read())
78913155Sgabeblack@google.com        wait();
79013155Sgabeblack@google.com    while (!s.read())
79113155Sgabeblack@google.com        wait();
79212914Sgabeblack@google.com}
79312914Sgabeblack@google.com
79412914Sgabeblack@google.comvoid
79513155Sgabeblack@google.comat_posedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
79612914Sgabeblack@google.com{
79713155Sgabeblack@google.com    while (s.read() == sc_dt::Log_1)
79813155Sgabeblack@google.com        wait();
79913155Sgabeblack@google.com    while (s.read() == sc_dt::Log_0)
80013155Sgabeblack@google.com        wait();
80112914Sgabeblack@google.com}
80212914Sgabeblack@google.com
80312914Sgabeblack@google.comvoid
80413155Sgabeblack@google.comat_negedge(const sc_signal_in_if<bool> &s)
80512914Sgabeblack@google.com{
80613155Sgabeblack@google.com    while (!s.read())
80713155Sgabeblack@google.com        wait();
80813155Sgabeblack@google.com    while (s.read())
80913155Sgabeblack@google.com        wait();
81012914Sgabeblack@google.com}
81112914Sgabeblack@google.com
81212914Sgabeblack@google.comvoid
81313155Sgabeblack@google.comat_negedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
81412914Sgabeblack@google.com{
81513155Sgabeblack@google.com    while (s.read() == sc_dt::Log_0)
81613155Sgabeblack@google.com        wait();
81713155Sgabeblack@google.com    while (s.read() == sc_dt::Log_1)
81813155Sgabeblack@google.com        wait();
81912914Sgabeblack@google.com}
82012914Sgabeblack@google.com
82112837Sgabeblack@google.comconst char *
82213035Sgabeblack@google.comsc_gen_unique_name(const char *seed)
82312837Sgabeblack@google.com{
82413296Sgabeblack@google.com    if (!seed || seed[0] == '\0') {
82513317Sgabeblack@google.com        SC_REPORT_ERROR(SC_ID_GEN_UNIQUE_NAME_, "");
82613296Sgabeblack@google.com        seed = "unnamed";
82713296Sgabeblack@google.com    }
82813296Sgabeblack@google.com
82913268Sgabeblack@google.com    auto mod = sc_gem5::pickParentModule();
83013285Sgabeblack@google.com    if (mod)
83113285Sgabeblack@google.com        return mod->uniqueName(seed);
83213296Sgabeblack@google.com
83313285Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
83413285Sgabeblack@google.com    if (p)
83513285Sgabeblack@google.com        return p->uniqueName(seed);
83613296Sgabeblack@google.com
83713303Sgabeblack@google.com    return ::sc_gem5::globalNameGen.gen(seed);
83812837Sgabeblack@google.com}
83912837Sgabeblack@google.com
84012837Sgabeblack@google.combool
84112930Sgabeblack@google.comsc_hierarchical_name_exists(const char *name)
84212930Sgabeblack@google.com{
84313280Sgabeblack@google.com    return sc_gem5::findEvent(name) != sc_gem5::allEvents.end() ||
84413280Sgabeblack@google.com        ::sc_gem5::findObject(name, sc_gem5::allObjects);
84512930Sgabeblack@google.com}
84612930Sgabeblack@google.com
84712930Sgabeblack@google.combool
84812837Sgabeblack@google.comsc_start_of_simulation_invoked()
84912837Sgabeblack@google.com{
85012982Sgabeblack@google.com    return ::sc_gem5::kernel->startOfSimulationComplete();
85112837Sgabeblack@google.com}
85212837Sgabeblack@google.com
85312837Sgabeblack@google.combool
85412837Sgabeblack@google.comsc_end_of_simulation_invoked()
85512837Sgabeblack@google.com{
85612982Sgabeblack@google.com    return ::sc_gem5::kernel->endOfSimulationComplete();
85712837Sgabeblack@google.com}
85812837Sgabeblack@google.com
85912901Sgabeblack@google.comsc_module *
86012901Sgabeblack@google.comsc_module_sc_new(sc_module *mod)
86112901Sgabeblack@google.com{
86212901Sgabeblack@google.com    static std::vector<std::unique_ptr<sc_module> > modules;
86312901Sgabeblack@google.com    modules.emplace_back(mod);
86412901Sgabeblack@google.com    return mod;
86512901Sgabeblack@google.com}
86612901Sgabeblack@google.com
86712837Sgabeblack@google.com} // namespace sc_core
868