sc_module.cc revision 13091
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>
3112901Sgabeblack@google.com#include <vector>
3212901Sgabeblack@google.com
3312837Sgabeblack@google.com#include "base/logging.hh"
3412982Sgabeblack@google.com#include "systemc/core/kernel.hh"
3512951Sgabeblack@google.com#include "systemc/core/module.hh"
3612953Sgabeblack@google.com#include "systemc/core/process_types.hh"
3712837Sgabeblack@google.com#include "systemc/ext/core/sc_module.hh"
3812951Sgabeblack@google.com#include "systemc/ext/core/sc_module_name.hh"
3912837Sgabeblack@google.com
4012952Sgabeblack@google.comnamespace sc_gem5
4112952Sgabeblack@google.com{
4212952Sgabeblack@google.com
4312952Sgabeblack@google.comProcess *
4412952Sgabeblack@google.comnewMethodProcess(const char *name, ProcessFuncWrapper *func)
4512952Sgabeblack@google.com{
4612993Sgabeblack@google.com    Process *p = new Method(name, func);
4712993Sgabeblack@google.com    scheduler.reg(p);
4812993Sgabeblack@google.com    return p;
4912952Sgabeblack@google.com}
5012952Sgabeblack@google.com
5112952Sgabeblack@google.comProcess *
5212952Sgabeblack@google.comnewThreadProcess(const char *name, ProcessFuncWrapper *func)
5312952Sgabeblack@google.com{
5412993Sgabeblack@google.com    Process *p = new Thread(name, func);
5512993Sgabeblack@google.com    scheduler.reg(p);
5612993Sgabeblack@google.com    return p;
5712952Sgabeblack@google.com}
5812952Sgabeblack@google.com
5912952Sgabeblack@google.comProcess *
6012952Sgabeblack@google.comnewCThreadProcess(const char *name, ProcessFuncWrapper *func)
6112952Sgabeblack@google.com{
6212993Sgabeblack@google.com    Process *p = new CThread(name, func);
6312993Sgabeblack@google.com    scheduler.reg(p);
6413060Sgabeblack@google.com    p->dontInitialize();
6512993Sgabeblack@google.com    return p;
6612952Sgabeblack@google.com}
6712952Sgabeblack@google.com
6813035Sgabeblack@google.comUniqueNameGen nameGen;
6913035Sgabeblack@google.com
7012952Sgabeblack@google.com} // namespace sc_gem5
7112952Sgabeblack@google.com
7212837Sgabeblack@google.comnamespace sc_core
7312837Sgabeblack@google.com{
7412837Sgabeblack@google.com
7513091Sgabeblack@google.comsc_bind_proxy::sc_bind_proxy(sc_interface &_interface) :
7612951Sgabeblack@google.com    _interface(&_interface), _port(nullptr)
7712951Sgabeblack@google.com{}
7812837Sgabeblack@google.com
7913091Sgabeblack@google.comsc_bind_proxy::sc_bind_proxy(sc_port_base &_port) :
8012951Sgabeblack@google.com    _interface(nullptr), _port(&_port)
8112951Sgabeblack@google.com{}
8212837Sgabeblack@google.com
8313091Sgabeblack@google.comconst sc_bind_proxy SC_BIND_PROXY_NUL(*(sc_port_base *)nullptr);
8412837Sgabeblack@google.com
8512982Sgabeblack@google.comsc_module::~sc_module() { delete _gem5_module; }
8612837Sgabeblack@google.com
8713091Sgabeblack@google.comconst sc_bind_proxy SC_BIND_PROXY_NIL(*(sc_port_base *)nullptr);
8812837Sgabeblack@google.com
8912837Sgabeblack@google.comvoid
9012837Sgabeblack@google.comsc_module::operator () (const sc_bind_proxy &p001,
9112837Sgabeblack@google.com                        const sc_bind_proxy &p002,
9212837Sgabeblack@google.com                        const sc_bind_proxy &p003,
9312837Sgabeblack@google.com                        const sc_bind_proxy &p004,
9412837Sgabeblack@google.com                        const sc_bind_proxy &p005,
9512837Sgabeblack@google.com                        const sc_bind_proxy &p006,
9612837Sgabeblack@google.com                        const sc_bind_proxy &p007,
9712837Sgabeblack@google.com                        const sc_bind_proxy &p008,
9812837Sgabeblack@google.com                        const sc_bind_proxy &p009,
9912837Sgabeblack@google.com                        const sc_bind_proxy &p010,
10012837Sgabeblack@google.com                        const sc_bind_proxy &p011,
10112837Sgabeblack@google.com                        const sc_bind_proxy &p012,
10212837Sgabeblack@google.com                        const sc_bind_proxy &p013,
10312837Sgabeblack@google.com                        const sc_bind_proxy &p014,
10412837Sgabeblack@google.com                        const sc_bind_proxy &p015,
10512837Sgabeblack@google.com                        const sc_bind_proxy &p016,
10612837Sgabeblack@google.com                        const sc_bind_proxy &p017,
10712837Sgabeblack@google.com                        const sc_bind_proxy &p018,
10812837Sgabeblack@google.com                        const sc_bind_proxy &p019,
10912837Sgabeblack@google.com                        const sc_bind_proxy &p020,
11012837Sgabeblack@google.com                        const sc_bind_proxy &p021,
11112837Sgabeblack@google.com                        const sc_bind_proxy &p022,
11212837Sgabeblack@google.com                        const sc_bind_proxy &p023,
11312837Sgabeblack@google.com                        const sc_bind_proxy &p024,
11412837Sgabeblack@google.com                        const sc_bind_proxy &p025,
11512837Sgabeblack@google.com                        const sc_bind_proxy &p026,
11612837Sgabeblack@google.com                        const sc_bind_proxy &p027,
11712837Sgabeblack@google.com                        const sc_bind_proxy &p028,
11812837Sgabeblack@google.com                        const sc_bind_proxy &p029,
11912837Sgabeblack@google.com                        const sc_bind_proxy &p030,
12012837Sgabeblack@google.com                        const sc_bind_proxy &p031,
12112837Sgabeblack@google.com                        const sc_bind_proxy &p032,
12212837Sgabeblack@google.com                        const sc_bind_proxy &p033,
12312837Sgabeblack@google.com                        const sc_bind_proxy &p034,
12412837Sgabeblack@google.com                        const sc_bind_proxy &p035,
12512837Sgabeblack@google.com                        const sc_bind_proxy &p036,
12612837Sgabeblack@google.com                        const sc_bind_proxy &p037,
12712837Sgabeblack@google.com                        const sc_bind_proxy &p038,
12812837Sgabeblack@google.com                        const sc_bind_proxy &p039,
12912837Sgabeblack@google.com                        const sc_bind_proxy &p040,
13012837Sgabeblack@google.com                        const sc_bind_proxy &p041,
13112837Sgabeblack@google.com                        const sc_bind_proxy &p042,
13212837Sgabeblack@google.com                        const sc_bind_proxy &p043,
13312837Sgabeblack@google.com                        const sc_bind_proxy &p044,
13412837Sgabeblack@google.com                        const sc_bind_proxy &p045,
13512837Sgabeblack@google.com                        const sc_bind_proxy &p046,
13612837Sgabeblack@google.com                        const sc_bind_proxy &p047,
13712837Sgabeblack@google.com                        const sc_bind_proxy &p048,
13812837Sgabeblack@google.com                        const sc_bind_proxy &p049,
13912837Sgabeblack@google.com                        const sc_bind_proxy &p050,
14012837Sgabeblack@google.com                        const sc_bind_proxy &p051,
14112837Sgabeblack@google.com                        const sc_bind_proxy &p052,
14212837Sgabeblack@google.com                        const sc_bind_proxy &p053,
14312837Sgabeblack@google.com                        const sc_bind_proxy &p054,
14412837Sgabeblack@google.com                        const sc_bind_proxy &p055,
14512837Sgabeblack@google.com                        const sc_bind_proxy &p056,
14612837Sgabeblack@google.com                        const sc_bind_proxy &p057,
14712837Sgabeblack@google.com                        const sc_bind_proxy &p058,
14812837Sgabeblack@google.com                        const sc_bind_proxy &p059,
14912837Sgabeblack@google.com                        const sc_bind_proxy &p060,
15012837Sgabeblack@google.com                        const sc_bind_proxy &p061,
15112837Sgabeblack@google.com                        const sc_bind_proxy &p062,
15212837Sgabeblack@google.com                        const sc_bind_proxy &p063,
15312837Sgabeblack@google.com                        const sc_bind_proxy &p064)
15412837Sgabeblack@google.com{
15513091Sgabeblack@google.com    std::vector<const ::sc_core::sc_bind_proxy *> proxies;
15613091Sgabeblack@google.com    auto insert = [&proxies](const ::sc_core::sc_bind_proxy &p) -> bool {
15713091Sgabeblack@google.com        if (!p.port() && !p.interface())
15813091Sgabeblack@google.com            return false;
15913091Sgabeblack@google.com        proxies.push_back(&p);
16013091Sgabeblack@google.com        return true;
16113091Sgabeblack@google.com    };
16213091Sgabeblack@google.com    insert(p001) && insert(p002) && insert(p003) && insert(p004) &&
16313091Sgabeblack@google.com    insert(p005) && insert(p006) && insert(p007) && insert(p008) &&
16413091Sgabeblack@google.com    insert(p009) && insert(p010) && insert(p011) && insert(p012) &&
16513091Sgabeblack@google.com    insert(p013) && insert(p014) && insert(p015) && insert(p016) &&
16613091Sgabeblack@google.com    insert(p017) && insert(p018) && insert(p019) && insert(p020) &&
16713091Sgabeblack@google.com    insert(p021) && insert(p022) && insert(p023) && insert(p024) &&
16813091Sgabeblack@google.com    insert(p025) && insert(p026) && insert(p027) && insert(p028) &&
16913091Sgabeblack@google.com    insert(p029) && insert(p030) && insert(p031) && insert(p032) &&
17013091Sgabeblack@google.com    insert(p033) && insert(p034) && insert(p035) && insert(p036) &&
17113091Sgabeblack@google.com    insert(p037) && insert(p038) && insert(p039) && insert(p040) &&
17213091Sgabeblack@google.com    insert(p041) && insert(p042) && insert(p043) && insert(p044) &&
17313091Sgabeblack@google.com    insert(p045) && insert(p046) && insert(p047) && insert(p048) &&
17413091Sgabeblack@google.com    insert(p049) && insert(p050) && insert(p051) && insert(p052) &&
17513091Sgabeblack@google.com    insert(p053) && insert(p054) && insert(p055) && insert(p056) &&
17613091Sgabeblack@google.com    insert(p057) && insert(p058) && insert(p059) && insert(p060) &&
17713091Sgabeblack@google.com    insert(p061) && insert(p062) && insert(p063) && insert(p064);
17813091Sgabeblack@google.com    _gem5_module->bindPorts(proxies);
17912837Sgabeblack@google.com}
18012837Sgabeblack@google.com
18112837Sgabeblack@google.comconst std::vector<sc_object *> &
18212837Sgabeblack@google.comsc_module::get_child_objects() const
18312837Sgabeblack@google.com{
18412951Sgabeblack@google.com    return _gem5_module->obj()->get_child_objects();
18512837Sgabeblack@google.com}
18612837Sgabeblack@google.com
18712837Sgabeblack@google.comconst std::vector<sc_event *> &
18812837Sgabeblack@google.comsc_module::get_child_events() const
18912837Sgabeblack@google.com{
19012951Sgabeblack@google.com    return _gem5_module->obj()->get_child_events();
19112837Sgabeblack@google.com}
19212837Sgabeblack@google.com
19312951Sgabeblack@google.comsc_module::sc_module() :
19413079Sgabeblack@google.com    sc_object(sc_gem5::newModuleChecked()->name()),
19512951Sgabeblack@google.com    _gem5_module(sc_gem5::currentModule())
19612951Sgabeblack@google.com{}
19712837Sgabeblack@google.com
19812951Sgabeblack@google.comsc_module::sc_module(const sc_module_name &) : sc_module() {}
19912951Sgabeblack@google.comsc_module::sc_module(const char *_name) : sc_module(sc_module_name(_name)) {}
20012951Sgabeblack@google.comsc_module::sc_module(const std::string &_name) :
20112951Sgabeblack@google.com    sc_module(sc_module_name(_name.c_str()))
20212951Sgabeblack@google.com{}
20312928Sgabeblack@google.com
20412837Sgabeblack@google.comvoid
20512837Sgabeblack@google.comsc_module::reset_signal_is(const sc_in<bool> &, bool)
20612837Sgabeblack@google.com{
20712837Sgabeblack@google.com    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
20812837Sgabeblack@google.com}
20912837Sgabeblack@google.com
21012837Sgabeblack@google.comvoid
21112837Sgabeblack@google.comsc_module::reset_signal_is(const sc_inout<bool> &, bool)
21212837Sgabeblack@google.com{
21312837Sgabeblack@google.com    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
21412837Sgabeblack@google.com}
21512837Sgabeblack@google.com
21612837Sgabeblack@google.comvoid
21712837Sgabeblack@google.comsc_module::reset_signal_is(const sc_out<bool> &, bool)
21812837Sgabeblack@google.com{
21912837Sgabeblack@google.com    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
22012837Sgabeblack@google.com}
22112837Sgabeblack@google.com
22212837Sgabeblack@google.comvoid
22312837Sgabeblack@google.comsc_module::reset_signal_is(const sc_signal_in_if<bool> &, bool)
22412837Sgabeblack@google.com{
22512837Sgabeblack@google.com    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
22612837Sgabeblack@google.com}
22712837Sgabeblack@google.com
22812837Sgabeblack@google.com
22912837Sgabeblack@google.comvoid
23012837Sgabeblack@google.comsc_module::async_reset_signal_is(const sc_in<bool> &, bool)
23112837Sgabeblack@google.com{
23212837Sgabeblack@google.com    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
23312837Sgabeblack@google.com}
23412837Sgabeblack@google.com
23512837Sgabeblack@google.comvoid
23612837Sgabeblack@google.comsc_module::async_reset_signal_is(const sc_inout<bool> &, bool)
23712837Sgabeblack@google.com{
23812837Sgabeblack@google.com    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
23912837Sgabeblack@google.com}
24012837Sgabeblack@google.com
24112837Sgabeblack@google.comvoid
24212837Sgabeblack@google.comsc_module::async_reset_signal_is(const sc_out<bool> &, bool)
24312837Sgabeblack@google.com{
24412837Sgabeblack@google.com    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
24512837Sgabeblack@google.com}
24612837Sgabeblack@google.com
24712837Sgabeblack@google.comvoid
24812837Sgabeblack@google.comsc_module::async_reset_signal_is(const sc_signal_in_if<bool> &, bool)
24912837Sgabeblack@google.com{
25012837Sgabeblack@google.com    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
25112837Sgabeblack@google.com}
25212837Sgabeblack@google.com
25312837Sgabeblack@google.com
25412837Sgabeblack@google.comvoid
25512837Sgabeblack@google.comsc_module::dont_initialize()
25612837Sgabeblack@google.com{
25712953Sgabeblack@google.com    ::sc_gem5::Process::newest()->dontInitialize();
25812837Sgabeblack@google.com}
25912837Sgabeblack@google.com
26012837Sgabeblack@google.comvoid
26112953Sgabeblack@google.comsc_module::set_stack_size(size_t size)
26212837Sgabeblack@google.com{
26312953Sgabeblack@google.com    ::sc_gem5::Process::newest()->setStackSize(size);
26412837Sgabeblack@google.com}
26512837Sgabeblack@google.com
26612837Sgabeblack@google.com
26712951Sgabeblack@google.comvoid sc_module::next_trigger() { ::sc_core::next_trigger(); }
26812951Sgabeblack@google.com
26912837Sgabeblack@google.comvoid
27012951Sgabeblack@google.comsc_module::next_trigger(const sc_event &e)
27112837Sgabeblack@google.com{
27212951Sgabeblack@google.com    ::sc_core::next_trigger(e);
27312837Sgabeblack@google.com}
27412837Sgabeblack@google.com
27512837Sgabeblack@google.comvoid
27612951Sgabeblack@google.comsc_module::next_trigger(const sc_event_or_list &eol)
27712837Sgabeblack@google.com{
27812951Sgabeblack@google.com    ::sc_core::next_trigger(eol);
27912837Sgabeblack@google.com}
28012837Sgabeblack@google.com
28112837Sgabeblack@google.comvoid
28212951Sgabeblack@google.comsc_module::next_trigger(const sc_event_and_list &eal)
28312837Sgabeblack@google.com{
28412951Sgabeblack@google.com    ::sc_core::next_trigger(eal);
28512837Sgabeblack@google.com}
28612837Sgabeblack@google.com
28712837Sgabeblack@google.comvoid
28812951Sgabeblack@google.comsc_module::next_trigger(const sc_time &t)
28912837Sgabeblack@google.com{
29012951Sgabeblack@google.com    ::sc_core::next_trigger(t);
29112837Sgabeblack@google.com}
29212837Sgabeblack@google.com
29312837Sgabeblack@google.comvoid
29412951Sgabeblack@google.comsc_module::next_trigger(double d, sc_time_unit u)
29512837Sgabeblack@google.com{
29612951Sgabeblack@google.com    ::sc_core::next_trigger(d, u);
29712837Sgabeblack@google.com}
29812837Sgabeblack@google.com
29912837Sgabeblack@google.comvoid
30012951Sgabeblack@google.comsc_module::next_trigger(const sc_time &t, const sc_event &e)
30112837Sgabeblack@google.com{
30212951Sgabeblack@google.com    ::sc_core::next_trigger(t, e);
30312837Sgabeblack@google.com}
30412837Sgabeblack@google.com
30512837Sgabeblack@google.comvoid
30612951Sgabeblack@google.comsc_module::next_trigger(double d, sc_time_unit u, const sc_event &e)
30712837Sgabeblack@google.com{
30812951Sgabeblack@google.com    ::sc_core::next_trigger(d, u, e);
30912837Sgabeblack@google.com}
31012837Sgabeblack@google.com
31112837Sgabeblack@google.comvoid
31212951Sgabeblack@google.comsc_module::next_trigger(const sc_time &t, const sc_event_or_list &eol)
31312837Sgabeblack@google.com{
31412951Sgabeblack@google.com    ::sc_core::next_trigger(t, eol);
31512837Sgabeblack@google.com}
31612837Sgabeblack@google.com
31712837Sgabeblack@google.comvoid
31812951Sgabeblack@google.comsc_module::next_trigger(double d, sc_time_unit u, const sc_event_or_list &eol)
31912837Sgabeblack@google.com{
32012951Sgabeblack@google.com    ::sc_core::next_trigger(d, u, eol);
32112837Sgabeblack@google.com}
32212837Sgabeblack@google.com
32312837Sgabeblack@google.comvoid
32412951Sgabeblack@google.comsc_module::next_trigger(const sc_time &t, const sc_event_and_list &eal)
32512837Sgabeblack@google.com{
32612951Sgabeblack@google.com    ::sc_core::next_trigger(t, eal);
32712837Sgabeblack@google.com}
32812837Sgabeblack@google.com
32912837Sgabeblack@google.comvoid
33012951Sgabeblack@google.comsc_module::next_trigger(double d, sc_time_unit u, const sc_event_and_list &eal)
33112837Sgabeblack@google.com{
33212951Sgabeblack@google.com    ::sc_core::next_trigger(d, u, eal);
33312837Sgabeblack@google.com}
33412837Sgabeblack@google.com
33512837Sgabeblack@google.com
33612929Sgabeblack@google.combool
33712929Sgabeblack@google.comsc_module::timed_out()
33812929Sgabeblack@google.com{
33912929Sgabeblack@google.com    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
34012929Sgabeblack@google.com    return false;
34112929Sgabeblack@google.com}
34212929Sgabeblack@google.com
34312929Sgabeblack@google.com
34412837Sgabeblack@google.comvoid
34512837Sgabeblack@google.comsc_module::wait()
34612837Sgabeblack@google.com{
34712951Sgabeblack@google.com    ::sc_core::wait();
34812837Sgabeblack@google.com}
34912837Sgabeblack@google.com
35012837Sgabeblack@google.comvoid
35112951Sgabeblack@google.comsc_module::wait(int i)
35212837Sgabeblack@google.com{
35312951Sgabeblack@google.com    ::sc_core::wait(i);
35412837Sgabeblack@google.com}
35512837Sgabeblack@google.com
35612837Sgabeblack@google.comvoid
35712951Sgabeblack@google.comsc_module::wait(const sc_event &e)
35812837Sgabeblack@google.com{
35912951Sgabeblack@google.com    ::sc_core::wait(e);
36012837Sgabeblack@google.com}
36112837Sgabeblack@google.com
36212837Sgabeblack@google.comvoid
36312951Sgabeblack@google.comsc_module::wait(const sc_event_or_list &eol)
36412837Sgabeblack@google.com{
36512951Sgabeblack@google.com    ::sc_core::wait(eol);
36612837Sgabeblack@google.com}
36712837Sgabeblack@google.com
36812837Sgabeblack@google.comvoid
36912951Sgabeblack@google.comsc_module::wait(const sc_event_and_list &eal)
37012837Sgabeblack@google.com{
37112951Sgabeblack@google.com    ::sc_core::wait(eal);
37212837Sgabeblack@google.com}
37312837Sgabeblack@google.com
37412837Sgabeblack@google.comvoid
37512951Sgabeblack@google.comsc_module::wait(const sc_time &t)
37612837Sgabeblack@google.com{
37712951Sgabeblack@google.com    ::sc_core::wait(t);
37812837Sgabeblack@google.com}
37912837Sgabeblack@google.com
38012837Sgabeblack@google.comvoid
38112951Sgabeblack@google.comsc_module::wait(double d, sc_time_unit u)
38212837Sgabeblack@google.com{
38312951Sgabeblack@google.com    ::sc_core::wait(d, u);
38412837Sgabeblack@google.com}
38512837Sgabeblack@google.com
38612837Sgabeblack@google.comvoid
38712951Sgabeblack@google.comsc_module::wait(const sc_time &t, const sc_event &e)
38812837Sgabeblack@google.com{
38912951Sgabeblack@google.com    ::sc_core::wait(t, e);
39012837Sgabeblack@google.com}
39112837Sgabeblack@google.com
39212837Sgabeblack@google.comvoid
39312951Sgabeblack@google.comsc_module::wait(double d, sc_time_unit u, const sc_event &e)
39412837Sgabeblack@google.com{
39512951Sgabeblack@google.com    ::sc_core::wait(d, u, e);
39612837Sgabeblack@google.com}
39712837Sgabeblack@google.com
39812837Sgabeblack@google.comvoid
39912951Sgabeblack@google.comsc_module::wait(const sc_time &t, const sc_event_or_list &eol)
40012837Sgabeblack@google.com{
40112951Sgabeblack@google.com    ::sc_core::wait(t, eol);
40212837Sgabeblack@google.com}
40312837Sgabeblack@google.com
40412837Sgabeblack@google.comvoid
40512951Sgabeblack@google.comsc_module::wait(double d, sc_time_unit u, const sc_event_or_list &eol)
40612837Sgabeblack@google.com{
40712951Sgabeblack@google.com    ::sc_core::wait(d, u, eol);
40812837Sgabeblack@google.com}
40912837Sgabeblack@google.com
41012837Sgabeblack@google.comvoid
41112951Sgabeblack@google.comsc_module::wait(const sc_time &t, const sc_event_and_list &eal)
41212837Sgabeblack@google.com{
41312951Sgabeblack@google.com    ::sc_core::wait(t, eal);
41412837Sgabeblack@google.com}
41512837Sgabeblack@google.com
41612837Sgabeblack@google.comvoid
41712951Sgabeblack@google.comsc_module::wait(double d, sc_time_unit u, const sc_event_and_list &eal)
41812837Sgabeblack@google.com{
41912951Sgabeblack@google.com    ::sc_core::wait(d, u, eal);
42012837Sgabeblack@google.com}
42112837Sgabeblack@google.com
42212837Sgabeblack@google.com
42312837Sgabeblack@google.comvoid
42412909Sgabeblack@google.comsc_module::halt()
42512909Sgabeblack@google.com{
42612951Sgabeblack@google.com    ::sc_core::halt();
42712909Sgabeblack@google.com}
42812909Sgabeblack@google.com
42912914Sgabeblack@google.comvoid
43012951Sgabeblack@google.comsc_module::at_posedge(const sc_signal_in_if<bool> &s)
43112914Sgabeblack@google.com{
43212951Sgabeblack@google.com    ::sc_core::at_posedge(s);
43312914Sgabeblack@google.com}
43412914Sgabeblack@google.com
43512914Sgabeblack@google.comvoid
43612951Sgabeblack@google.comsc_module::at_posedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
43712914Sgabeblack@google.com{
43812951Sgabeblack@google.com    ::sc_core::at_posedge(s);
43912914Sgabeblack@google.com}
44012914Sgabeblack@google.com
44112914Sgabeblack@google.comvoid
44212951Sgabeblack@google.comsc_module::at_negedge(const sc_signal_in_if<bool> &s)
44312914Sgabeblack@google.com{
44412951Sgabeblack@google.com    ::sc_core::at_negedge(s);
44512914Sgabeblack@google.com}
44612914Sgabeblack@google.com
44712914Sgabeblack@google.comvoid
44812951Sgabeblack@google.comsc_module::at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
44912914Sgabeblack@google.com{
45012951Sgabeblack@google.com    ::sc_core::at_negedge(s);
45112914Sgabeblack@google.com}
45212914Sgabeblack@google.com
45312909Sgabeblack@google.com
45412909Sgabeblack@google.comvoid
45512837Sgabeblack@google.comnext_trigger()
45612837Sgabeblack@google.com{
45712958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
45812958Sgabeblack@google.com    p->setDynamic(nullptr);
45912837Sgabeblack@google.com}
46012837Sgabeblack@google.com
46112837Sgabeblack@google.comvoid
46212958Sgabeblack@google.comnext_trigger(const sc_event &e)
46312837Sgabeblack@google.com{
46412958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
46512958Sgabeblack@google.com    p->setDynamic(new ::sc_gem5::SensitivityEvent(p, &e));
46612837Sgabeblack@google.com}
46712837Sgabeblack@google.com
46812837Sgabeblack@google.comvoid
46912958Sgabeblack@google.comnext_trigger(const sc_event_or_list &eol)
47012837Sgabeblack@google.com{
47112958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
47212958Sgabeblack@google.com    p->setDynamic(new ::sc_gem5::SensitivityEventOrList(p, &eol));
47312837Sgabeblack@google.com}
47412837Sgabeblack@google.com
47512837Sgabeblack@google.comvoid
47612958Sgabeblack@google.comnext_trigger(const sc_event_and_list &eal)
47712837Sgabeblack@google.com{
47812958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
47912958Sgabeblack@google.com    p->setDynamic(new ::sc_gem5::SensitivityEventAndList(p, &eal));
48012837Sgabeblack@google.com}
48112837Sgabeblack@google.com
48212837Sgabeblack@google.comvoid
48312958Sgabeblack@google.comnext_trigger(const sc_time &t)
48412837Sgabeblack@google.com{
48512958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
48612958Sgabeblack@google.com    p->setDynamic(new ::sc_gem5::SensitivityTimeout(p, t));
48712837Sgabeblack@google.com}
48812837Sgabeblack@google.com
48912837Sgabeblack@google.comvoid
49012951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u)
49112837Sgabeblack@google.com{
49212951Sgabeblack@google.com    next_trigger(sc_time(d, u));
49312837Sgabeblack@google.com}
49412837Sgabeblack@google.com
49512837Sgabeblack@google.comvoid
49612958Sgabeblack@google.comnext_trigger(const sc_time &t, const sc_event &e)
49712837Sgabeblack@google.com{
49812958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
49912958Sgabeblack@google.com    p->setDynamic(new ::sc_gem5::SensitivityTimeoutAndEvent(p, t, &e));
50012837Sgabeblack@google.com}
50112837Sgabeblack@google.com
50212837Sgabeblack@google.comvoid
50312951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u, const sc_event &e)
50412837Sgabeblack@google.com{
50512951Sgabeblack@google.com    next_trigger(sc_time(d, u), e);
50612837Sgabeblack@google.com}
50712837Sgabeblack@google.com
50812837Sgabeblack@google.comvoid
50912958Sgabeblack@google.comnext_trigger(const sc_time &t, const sc_event_or_list &eol)
51012837Sgabeblack@google.com{
51112958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
51212958Sgabeblack@google.com    p->setDynamic(
51312958Sgabeblack@google.com            new ::sc_gem5::SensitivityTimeoutAndEventOrList(p, t, &eol));
51412837Sgabeblack@google.com}
51512837Sgabeblack@google.com
51612837Sgabeblack@google.comvoid
51712951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u, const sc_event_or_list &eol)
51812837Sgabeblack@google.com{
51912951Sgabeblack@google.com    next_trigger(sc_time(d, u), eol);
52012837Sgabeblack@google.com}
52112837Sgabeblack@google.com
52212837Sgabeblack@google.comvoid
52312958Sgabeblack@google.comnext_trigger(const sc_time &t, const sc_event_and_list &eal)
52412837Sgabeblack@google.com{
52512958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
52612958Sgabeblack@google.com    p->setDynamic(
52712958Sgabeblack@google.com            new ::sc_gem5::SensitivityTimeoutAndEventAndList(p, t, &eal));
52812837Sgabeblack@google.com}
52912837Sgabeblack@google.com
53012837Sgabeblack@google.comvoid
53112951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u, const sc_event_and_list &eal)
53212837Sgabeblack@google.com{
53312951Sgabeblack@google.com    next_trigger(sc_time(d, u), eal);
53412837Sgabeblack@google.com}
53512837Sgabeblack@google.com
53612929Sgabeblack@google.combool
53712929Sgabeblack@google.comtimed_out()
53812929Sgabeblack@google.com{
53912929Sgabeblack@google.com    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
54012929Sgabeblack@google.com    return false;
54112929Sgabeblack@google.com}
54212929Sgabeblack@google.com
54312837Sgabeblack@google.com
54412837Sgabeblack@google.comvoid
54512837Sgabeblack@google.comwait()
54612837Sgabeblack@google.com{
54712958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
54812958Sgabeblack@google.com    p->setDynamic(nullptr);
54912958Sgabeblack@google.com    sc_gem5::scheduler.yield();
55012837Sgabeblack@google.com}
55112837Sgabeblack@google.com
55212837Sgabeblack@google.comvoid
55312958Sgabeblack@google.comwait(int n)
55412837Sgabeblack@google.com{
55512958Sgabeblack@google.com    for (int i = 0; i < n; i++)
55612958Sgabeblack@google.com        wait();
55712837Sgabeblack@google.com}
55812837Sgabeblack@google.com
55912837Sgabeblack@google.comvoid
56012958Sgabeblack@google.comwait(const sc_event &e)
56112837Sgabeblack@google.com{
56212958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
56312958Sgabeblack@google.com    p->setDynamic(new ::sc_gem5::SensitivityEvent(p, &e));
56412958Sgabeblack@google.com    sc_gem5::scheduler.yield();
56512837Sgabeblack@google.com}
56612837Sgabeblack@google.com
56712837Sgabeblack@google.comvoid
56812958Sgabeblack@google.comwait(const sc_event_or_list &eol)
56912837Sgabeblack@google.com{
57012958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
57112958Sgabeblack@google.com    p->setDynamic(new ::sc_gem5::SensitivityEventOrList(p, &eol));
57212958Sgabeblack@google.com    sc_gem5::scheduler.yield();
57312837Sgabeblack@google.com}
57412837Sgabeblack@google.com
57512837Sgabeblack@google.comvoid
57612958Sgabeblack@google.comwait(const sc_event_and_list &eal)
57712837Sgabeblack@google.com{
57812958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
57912958Sgabeblack@google.com    p->setDynamic(new ::sc_gem5::SensitivityEventAndList(p, &eal));
58012958Sgabeblack@google.com    sc_gem5::scheduler.yield();
58112837Sgabeblack@google.com}
58212837Sgabeblack@google.com
58312837Sgabeblack@google.comvoid
58412958Sgabeblack@google.comwait(const sc_time &t)
58512837Sgabeblack@google.com{
58612958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
58712958Sgabeblack@google.com    p->setDynamic(new ::sc_gem5::SensitivityTimeout(p, t));
58812958Sgabeblack@google.com    sc_gem5::scheduler.yield();
58912837Sgabeblack@google.com}
59012837Sgabeblack@google.com
59112837Sgabeblack@google.comvoid
59212951Sgabeblack@google.comwait(double d, sc_time_unit u)
59312837Sgabeblack@google.com{
59412951Sgabeblack@google.com    wait(sc_time(d, u));
59512837Sgabeblack@google.com}
59612837Sgabeblack@google.com
59712837Sgabeblack@google.comvoid
59812958Sgabeblack@google.comwait(const sc_time &t, const sc_event &e)
59912837Sgabeblack@google.com{
60012958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
60112958Sgabeblack@google.com    p->setDynamic(new ::sc_gem5::SensitivityTimeoutAndEvent(p, t, &e));
60212958Sgabeblack@google.com    sc_gem5::scheduler.yield();
60312837Sgabeblack@google.com}
60412837Sgabeblack@google.com
60512837Sgabeblack@google.comvoid
60612951Sgabeblack@google.comwait(double d, sc_time_unit u, const sc_event &e)
60712837Sgabeblack@google.com{
60812951Sgabeblack@google.com    wait(sc_time(d, u), e);
60912837Sgabeblack@google.com}
61012837Sgabeblack@google.com
61112837Sgabeblack@google.comvoid
61212958Sgabeblack@google.comwait(const sc_time &t, const sc_event_or_list &eol)
61312837Sgabeblack@google.com{
61412958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
61512958Sgabeblack@google.com    p->setDynamic(
61612958Sgabeblack@google.com            new ::sc_gem5::SensitivityTimeoutAndEventOrList(p, t, &eol));
61712958Sgabeblack@google.com    sc_gem5::scheduler.yield();
61812837Sgabeblack@google.com}
61912837Sgabeblack@google.com
62012837Sgabeblack@google.comvoid
62112951Sgabeblack@google.comwait(double d, sc_time_unit u, const sc_event_or_list &eol)
62212837Sgabeblack@google.com{
62312951Sgabeblack@google.com    wait(sc_time(d, u), eol);
62412837Sgabeblack@google.com}
62512837Sgabeblack@google.com
62612837Sgabeblack@google.comvoid
62712958Sgabeblack@google.comwait(const sc_time &t, const sc_event_and_list &eal)
62812837Sgabeblack@google.com{
62912958Sgabeblack@google.com    sc_gem5::Process *p = sc_gem5::scheduler.current();
63012958Sgabeblack@google.com    p->setDynamic(
63112958Sgabeblack@google.com            new ::sc_gem5::SensitivityTimeoutAndEventAndList(p, t, &eal));
63212958Sgabeblack@google.com    sc_gem5::scheduler.yield();
63312837Sgabeblack@google.com}
63412837Sgabeblack@google.com
63512837Sgabeblack@google.comvoid
63612951Sgabeblack@google.comwait(double d, sc_time_unit u, const sc_event_and_list &eal)
63712837Sgabeblack@google.com{
63812951Sgabeblack@google.com    wait(sc_time(d, u), eal);
63912837Sgabeblack@google.com}
64012837Sgabeblack@google.com
64112909Sgabeblack@google.comvoid
64212909Sgabeblack@google.comhalt()
64312909Sgabeblack@google.com{
64412909Sgabeblack@google.com    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
64512909Sgabeblack@google.com}
64612909Sgabeblack@google.com
64712914Sgabeblack@google.comvoid
64812914Sgabeblack@google.comat_posedge(const sc_signal_in_if<bool> &)
64912914Sgabeblack@google.com{
65012914Sgabeblack@google.com    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
65112914Sgabeblack@google.com}
65212914Sgabeblack@google.com
65312914Sgabeblack@google.comvoid
65412914Sgabeblack@google.comat_posedge(const sc_signal_in_if<sc_dt::sc_logic> &)
65512914Sgabeblack@google.com{
65612914Sgabeblack@google.com    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
65712914Sgabeblack@google.com}
65812914Sgabeblack@google.com
65912914Sgabeblack@google.comvoid
66012914Sgabeblack@google.comat_negedge(const sc_signal_in_if<bool> &)
66112914Sgabeblack@google.com{
66212914Sgabeblack@google.com    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
66312914Sgabeblack@google.com}
66412914Sgabeblack@google.com
66512914Sgabeblack@google.comvoid
66612914Sgabeblack@google.comat_negedge(const sc_signal_in_if<sc_dt::sc_logic> &)
66712914Sgabeblack@google.com{
66812914Sgabeblack@google.com    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
66912914Sgabeblack@google.com}
67012914Sgabeblack@google.com
67112837Sgabeblack@google.comconst char *
67213035Sgabeblack@google.comsc_gen_unique_name(const char *seed)
67312837Sgabeblack@google.com{
67413035Sgabeblack@google.com    ::sc_gem5::Module *mod = ::sc_gem5::currentModule();
67513035Sgabeblack@google.com    return mod ? mod->uniqueName(seed) :
67613035Sgabeblack@google.com        ::sc_gem5::nameGen.gen(seed);
67712837Sgabeblack@google.com}
67812837Sgabeblack@google.com
67912837Sgabeblack@google.combool
68012930Sgabeblack@google.comsc_hierarchical_name_exists(const char *name)
68112930Sgabeblack@google.com{
68212930Sgabeblack@google.com    warn("%s not implemented.\n", __PRETTY_FUNCTION__);
68312930Sgabeblack@google.com    return false;
68412930Sgabeblack@google.com}
68512930Sgabeblack@google.com
68612930Sgabeblack@google.combool
68712837Sgabeblack@google.comsc_start_of_simulation_invoked()
68812837Sgabeblack@google.com{
68912982Sgabeblack@google.com    return ::sc_gem5::kernel->startOfSimulationComplete();
69012837Sgabeblack@google.com}
69112837Sgabeblack@google.com
69212837Sgabeblack@google.combool
69312837Sgabeblack@google.comsc_end_of_simulation_invoked()
69412837Sgabeblack@google.com{
69512982Sgabeblack@google.com    return ::sc_gem5::kernel->endOfSimulationComplete();
69612837Sgabeblack@google.com}
69712837Sgabeblack@google.com
69812901Sgabeblack@google.comsc_module *
69912901Sgabeblack@google.comsc_module_sc_new(sc_module *mod)
70012901Sgabeblack@google.com{
70112901Sgabeblack@google.com    static std::vector<std::unique_ptr<sc_module> > modules;
70212901Sgabeblack@google.com    modules.emplace_back(mod);
70312901Sgabeblack@google.com    return mod;
70412901Sgabeblack@google.com}
70512901Sgabeblack@google.com
70612837Sgabeblack@google.com} // namespace sc_core
707