sc_prim.cc revision 13283
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
3012837Sgabeblack@google.com#include "base/logging.hh"
3112954Sgabeblack@google.com#include "systemc/core/channel.hh"
3213140Sgabeblack@google.com#include "systemc/core/scheduler.hh"
3313238Sgabeblack@google.com#include "systemc/ext/core/sc_main.hh"
3412837Sgabeblack@google.com#include "systemc/ext/core/sc_prim.hh"
3512837Sgabeblack@google.com
3613140Sgabeblack@google.comnamespace sc_gem5
3713140Sgabeblack@google.com{
3813140Sgabeblack@google.com
3913140Sgabeblack@google.comuint64_t getChangeStamp() { return scheduler.changeStamp(); }
4013140Sgabeblack@google.com
4113140Sgabeblack@google.com} // namespace sc_gem5
4213140Sgabeblack@google.com
4312837Sgabeblack@google.comnamespace sc_core
4412837Sgabeblack@google.com{
4512837Sgabeblack@google.com
4613238Sgabeblack@google.comsc_prim_channel::sc_prim_channel() : _gem5_channel(nullptr)
4713238Sgabeblack@google.com{
4813238Sgabeblack@google.com    if (sc_is_running()) {
4913238Sgabeblack@google.com        SC_REPORT_ERROR("(E113) insert primitive channel failed",
5013238Sgabeblack@google.com                "simulation running");
5113283Sgabeblack@google.com    }
5213283Sgabeblack@google.com    if (::sc_gem5::scheduler.elaborationDone()) {
5313238Sgabeblack@google.com        SC_REPORT_ERROR("(E113) insert primitive channel failed",
5413238Sgabeblack@google.com                "elaboration done");
5513238Sgabeblack@google.com    }
5613283Sgabeblack@google.com    _gem5_channel = new sc_gem5::Channel(this);
5713238Sgabeblack@google.com}
5812837Sgabeblack@google.com
5912954Sgabeblack@google.comsc_prim_channel::sc_prim_channel(const char *_name) :
6013238Sgabeblack@google.com    sc_object(_name), _gem5_channel(nullptr)
6113238Sgabeblack@google.com{
6213238Sgabeblack@google.com    if (sc_is_running()) {
6313238Sgabeblack@google.com        SC_REPORT_ERROR("(E113) insert primitive channel failed",
6413238Sgabeblack@google.com                "simulation running");
6513283Sgabeblack@google.com    }
6613283Sgabeblack@google.com    if (::sc_gem5::scheduler.elaborationDone()) {
6713238Sgabeblack@google.com        SC_REPORT_ERROR("(E113) insert primitive channel failed",
6813238Sgabeblack@google.com                "elaboration done");
6913238Sgabeblack@google.com    }
7013283Sgabeblack@google.com    _gem5_channel = new sc_gem5::Channel(this);
7113238Sgabeblack@google.com}
7212837Sgabeblack@google.com
7312954Sgabeblack@google.comsc_prim_channel::~sc_prim_channel() { delete _gem5_channel; }
7412837Sgabeblack@google.com
7512837Sgabeblack@google.comvoid
7612837Sgabeblack@google.comsc_prim_channel::request_update()
7712837Sgabeblack@google.com{
7812954Sgabeblack@google.com    _gem5_channel->requestUpdate();
7912837Sgabeblack@google.com}
8012837Sgabeblack@google.com
8112837Sgabeblack@google.comvoid
8212837Sgabeblack@google.comsc_prim_channel::async_request_update()
8312837Sgabeblack@google.com{
8412954Sgabeblack@google.com    _gem5_channel->asyncRequestUpdate();
8512837Sgabeblack@google.com}
8612837Sgabeblack@google.com
8712837Sgabeblack@google.comvoid
8812837Sgabeblack@google.comsc_prim_channel::next_trigger()
8912837Sgabeblack@google.com{
9012954Sgabeblack@google.com    ::sc_core::next_trigger();
9112837Sgabeblack@google.com}
9212837Sgabeblack@google.com
9312837Sgabeblack@google.comvoid
9412954Sgabeblack@google.comsc_prim_channel::next_trigger(const sc_event &e)
9512837Sgabeblack@google.com{
9612954Sgabeblack@google.com    ::sc_core::next_trigger(e);
9712837Sgabeblack@google.com}
9812837Sgabeblack@google.com
9912837Sgabeblack@google.comvoid
10012954Sgabeblack@google.comsc_prim_channel::next_trigger(const sc_event_or_list &eol)
10112837Sgabeblack@google.com{
10212954Sgabeblack@google.com    ::sc_core::next_trigger(eol);
10312837Sgabeblack@google.com}
10412837Sgabeblack@google.com
10512837Sgabeblack@google.comvoid
10612954Sgabeblack@google.comsc_prim_channel::next_trigger(const sc_event_and_list &eal)
10712837Sgabeblack@google.com{
10812954Sgabeblack@google.com    ::sc_core::next_trigger(eal);
10912837Sgabeblack@google.com}
11012837Sgabeblack@google.com
11112837Sgabeblack@google.comvoid
11212954Sgabeblack@google.comsc_prim_channel::next_trigger(const sc_time &t)
11312837Sgabeblack@google.com{
11412954Sgabeblack@google.com    ::sc_core::next_trigger(t);
11512837Sgabeblack@google.com}
11612837Sgabeblack@google.com
11712837Sgabeblack@google.comvoid
11812954Sgabeblack@google.comsc_prim_channel::next_trigger(double d, sc_time_unit u)
11912837Sgabeblack@google.com{
12012954Sgabeblack@google.com    ::sc_core::next_trigger(d, u);
12112837Sgabeblack@google.com}
12212837Sgabeblack@google.com
12312837Sgabeblack@google.comvoid
12412954Sgabeblack@google.comsc_prim_channel::next_trigger(const sc_time &t, const sc_event &e)
12512837Sgabeblack@google.com{
12612954Sgabeblack@google.com    ::sc_core::next_trigger(t, e);
12712837Sgabeblack@google.com}
12812837Sgabeblack@google.com
12912837Sgabeblack@google.comvoid
13012954Sgabeblack@google.comsc_prim_channel::next_trigger(double d, sc_time_unit u, const sc_event &e)
13112837Sgabeblack@google.com{
13212954Sgabeblack@google.com    ::sc_core::next_trigger(d, u, e);
13312837Sgabeblack@google.com}
13412837Sgabeblack@google.com
13512837Sgabeblack@google.comvoid
13612954Sgabeblack@google.comsc_prim_channel::next_trigger(const sc_time &t, const sc_event_or_list &eol)
13712837Sgabeblack@google.com{
13812954Sgabeblack@google.com    ::sc_core::next_trigger(t, eol);
13912837Sgabeblack@google.com}
14012837Sgabeblack@google.com
14112837Sgabeblack@google.comvoid
14212954Sgabeblack@google.comsc_prim_channel::next_trigger(
14312954Sgabeblack@google.com        double d, sc_time_unit u, const sc_event_or_list &eol)
14412837Sgabeblack@google.com{
14512954Sgabeblack@google.com    ::sc_core::next_trigger(d, u, eol);
14612837Sgabeblack@google.com}
14712837Sgabeblack@google.com
14812837Sgabeblack@google.comvoid
14912954Sgabeblack@google.comsc_prim_channel::next_trigger(const sc_time &t, const sc_event_and_list &eal)
15012837Sgabeblack@google.com{
15112954Sgabeblack@google.com    ::sc_core::next_trigger(t, eal);
15212837Sgabeblack@google.com}
15312837Sgabeblack@google.com
15412837Sgabeblack@google.comvoid
15512954Sgabeblack@google.comsc_prim_channel::next_trigger(
15612954Sgabeblack@google.com        double d, sc_time_unit u, const sc_event_and_list &eal)
15712837Sgabeblack@google.com{
15812954Sgabeblack@google.com    ::sc_core::next_trigger(d, u, eal);
15912837Sgabeblack@google.com}
16012837Sgabeblack@google.com
16112929Sgabeblack@google.combool
16212929Sgabeblack@google.comsc_prim_channel::timed_out()
16312929Sgabeblack@google.com{
16413189Sgabeblack@google.com    return ::sc_core::timed_out();
16512929Sgabeblack@google.com}
16612929Sgabeblack@google.com
16712837Sgabeblack@google.comvoid
16812837Sgabeblack@google.comsc_prim_channel::wait()
16912837Sgabeblack@google.com{
17012954Sgabeblack@google.com    ::sc_core::wait();
17112837Sgabeblack@google.com}
17212837Sgabeblack@google.com
17312837Sgabeblack@google.comvoid
17412954Sgabeblack@google.comsc_prim_channel::wait(int i)
17512837Sgabeblack@google.com{
17612954Sgabeblack@google.com    ::sc_core::wait(i);
17712837Sgabeblack@google.com}
17812837Sgabeblack@google.com
17912837Sgabeblack@google.comvoid
18012954Sgabeblack@google.comsc_prim_channel::wait(const sc_event &e)
18112837Sgabeblack@google.com{
18212954Sgabeblack@google.com    ::sc_core::wait(e);
18312837Sgabeblack@google.com}
18412837Sgabeblack@google.com
18512837Sgabeblack@google.comvoid
18612954Sgabeblack@google.comsc_prim_channel::wait(const sc_event_or_list &eol)
18712837Sgabeblack@google.com{
18812954Sgabeblack@google.com    ::sc_core::wait(eol);
18912837Sgabeblack@google.com}
19012837Sgabeblack@google.com
19112837Sgabeblack@google.comvoid
19212954Sgabeblack@google.comsc_prim_channel::wait(const sc_event_and_list &eal)
19312837Sgabeblack@google.com{
19412954Sgabeblack@google.com    ::sc_core::wait(eal);
19512837Sgabeblack@google.com}
19612837Sgabeblack@google.com
19712837Sgabeblack@google.comvoid
19812954Sgabeblack@google.comsc_prim_channel::wait(const sc_time &t)
19912837Sgabeblack@google.com{
20012954Sgabeblack@google.com    ::sc_core::wait(t);
20112837Sgabeblack@google.com}
20212837Sgabeblack@google.com
20312837Sgabeblack@google.comvoid
20412954Sgabeblack@google.comsc_prim_channel::wait(double d, sc_time_unit u)
20512837Sgabeblack@google.com{
20612954Sgabeblack@google.com    ::sc_core::wait(d, u);
20712837Sgabeblack@google.com}
20812837Sgabeblack@google.com
20912837Sgabeblack@google.comvoid
21012954Sgabeblack@google.comsc_prim_channel::wait(const sc_time &t, const sc_event &e)
21112837Sgabeblack@google.com{
21212954Sgabeblack@google.com    ::sc_core::wait(t, e);
21312837Sgabeblack@google.com}
21412837Sgabeblack@google.com
21512837Sgabeblack@google.comvoid
21612954Sgabeblack@google.comsc_prim_channel::wait(double d, sc_time_unit u, const sc_event &e)
21712837Sgabeblack@google.com{
21812954Sgabeblack@google.com    ::sc_core::wait(d, u, e);
21912837Sgabeblack@google.com}
22012837Sgabeblack@google.com
22112837Sgabeblack@google.comvoid
22212954Sgabeblack@google.comsc_prim_channel::wait(const sc_time &t, const sc_event_or_list &eol)
22312837Sgabeblack@google.com{
22412954Sgabeblack@google.com    ::sc_core::wait(t, eol);
22512837Sgabeblack@google.com}
22612837Sgabeblack@google.com
22712837Sgabeblack@google.comvoid
22812954Sgabeblack@google.comsc_prim_channel::wait(double d, sc_time_unit u, const sc_event_or_list &eol)
22912837Sgabeblack@google.com{
23012954Sgabeblack@google.com    ::sc_core::wait(d, u, eol);
23112837Sgabeblack@google.com}
23212837Sgabeblack@google.com
23312837Sgabeblack@google.comvoid
23412954Sgabeblack@google.comsc_prim_channel::wait(const sc_time &t, const sc_event_and_list &eal)
23512837Sgabeblack@google.com{
23612954Sgabeblack@google.com    ::sc_core::wait(t, eal);
23712837Sgabeblack@google.com}
23812837Sgabeblack@google.com
23912837Sgabeblack@google.comvoid
24012954Sgabeblack@google.comsc_prim_channel::wait(double d, sc_time_unit u, const sc_event_and_list &eal)
24112837Sgabeblack@google.com{
24212954Sgabeblack@google.com    ::sc_core::wait(d, u, eal);
24312837Sgabeblack@google.com}
24412837Sgabeblack@google.com
24512837Sgabeblack@google.com} // namespace sc_core
246