sc_module.cc revision 13207
112837Sgabeblack@google.com/* 212837Sgabeblack@google.com * Copyright 2018 Google, Inc. 312837Sgabeblack@google.com * 412837Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 512837Sgabeblack@google.com * modification, are permitted provided that the following conditions are 612837Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 712837Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 812837Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 912837Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 1012837Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 1112837Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 1212837Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 1312837Sgabeblack@google.com * this software without specific prior written permission. 1412837Sgabeblack@google.com * 1512837Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1612837Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1712837Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1812837Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1912837Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2012837Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2112837Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2212837Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2312837Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2412837Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2512837Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2612837Sgabeblack@google.com * 2712837Sgabeblack@google.com * Authors: Gabe Black 2812837Sgabeblack@google.com */ 2912837Sgabeblack@google.com 3012901Sgabeblack@google.com#include <memory> 3113135Sgabeblack@google.com#include <string> 3212901Sgabeblack@google.com#include <vector> 3312901Sgabeblack@google.com 3412837Sgabeblack@google.com#include "base/logging.hh" 3512982Sgabeblack@google.com#include "systemc/core/kernel.hh" 3612951Sgabeblack@google.com#include "systemc/core/module.hh" 3712953Sgabeblack@google.com#include "systemc/core/process_types.hh" 3813155Sgabeblack@google.com#include "systemc/ext/channel/sc_signal_in_if.hh" 3912837Sgabeblack@google.com#include "systemc/ext/core/sc_module.hh" 4012951Sgabeblack@google.com#include "systemc/ext/core/sc_module_name.hh" 4113155Sgabeblack@google.com#include "systemc/ext/dt/bit/sc_logic.hh" 4213135Sgabeblack@google.com#include "systemc/ext/utils/sc_report_handler.hh" 4312837Sgabeblack@google.com 4412952Sgabeblack@google.comnamespace sc_gem5 4512952Sgabeblack@google.com{ 4612952Sgabeblack@google.com 4712952Sgabeblack@google.comProcess * 4812952Sgabeblack@google.comnewMethodProcess(const char *name, ProcessFuncWrapper *func) 4912952Sgabeblack@google.com{ 5013135Sgabeblack@google.com Method *p = new Method(name, func); 5113135Sgabeblack@google.com if (::sc_core::sc_is_running()) { 5213135Sgabeblack@google.com std::string name = p->name(); 5313135Sgabeblack@google.com delete p; 5413135Sgabeblack@google.com SC_REPORT_ERROR("(E541) call to SC_METHOD in sc_module while " 5513135Sgabeblack@google.com "simulation running", name.c_str()); 5613135Sgabeblack@google.com return nullptr; 5713135Sgabeblack@google.com } 5812993Sgabeblack@google.com scheduler.reg(p); 5912993Sgabeblack@google.com return p; 6012952Sgabeblack@google.com} 6112952Sgabeblack@google.com 6212952Sgabeblack@google.comProcess * 6312952Sgabeblack@google.comnewThreadProcess(const char *name, ProcessFuncWrapper *func) 6412952Sgabeblack@google.com{ 6513135Sgabeblack@google.com Thread *p = new Thread(name, func); 6613135Sgabeblack@google.com if (::sc_core::sc_is_running()) { 6713135Sgabeblack@google.com std::string name = p->name(); 6813135Sgabeblack@google.com delete p; 6913135Sgabeblack@google.com SC_REPORT_ERROR("(E542) call to SC_THREAD in sc_module while " 7013135Sgabeblack@google.com "simulation running", name.c_str()); 7113135Sgabeblack@google.com return nullptr; 7213135Sgabeblack@google.com } 7312993Sgabeblack@google.com scheduler.reg(p); 7412993Sgabeblack@google.com return p; 7512952Sgabeblack@google.com} 7612952Sgabeblack@google.com 7712952Sgabeblack@google.comProcess * 7812952Sgabeblack@google.comnewCThreadProcess(const char *name, ProcessFuncWrapper *func) 7912952Sgabeblack@google.com{ 8013135Sgabeblack@google.com CThread *p = new CThread(name, func); 8113135Sgabeblack@google.com if (::sc_core::sc_is_running()) { 8213135Sgabeblack@google.com std::string name = p->name(); 8313135Sgabeblack@google.com delete p; 8413135Sgabeblack@google.com SC_REPORT_ERROR("(E543) call to SC_CTHREAD in sc_module while " 8513135Sgabeblack@google.com "simulation running", name.c_str()); 8613135Sgabeblack@google.com return nullptr; 8713135Sgabeblack@google.com } 8812993Sgabeblack@google.com scheduler.reg(p); 8913194Sgabeblack@google.com p->dontInitialize(true); 9012993Sgabeblack@google.com return p; 9112952Sgabeblack@google.com} 9212952Sgabeblack@google.com 9313035Sgabeblack@google.comUniqueNameGen nameGen; 9413035Sgabeblack@google.com 9512952Sgabeblack@google.com} // namespace sc_gem5 9612952Sgabeblack@google.com 9712837Sgabeblack@google.comnamespace sc_core 9812837Sgabeblack@google.com{ 9912837Sgabeblack@google.com 10013091Sgabeblack@google.comsc_bind_proxy::sc_bind_proxy(sc_interface &_interface) : 10112951Sgabeblack@google.com _interface(&_interface), _port(nullptr) 10212951Sgabeblack@google.com{} 10312837Sgabeblack@google.com 10413091Sgabeblack@google.comsc_bind_proxy::sc_bind_proxy(sc_port_base &_port) : 10512951Sgabeblack@google.com _interface(nullptr), _port(&_port) 10612951Sgabeblack@google.com{} 10712837Sgabeblack@google.com 10813091Sgabeblack@google.comconst sc_bind_proxy SC_BIND_PROXY_NUL(*(sc_port_base *)nullptr); 10912837Sgabeblack@google.com 11012982Sgabeblack@google.comsc_module::~sc_module() { delete _gem5_module; } 11112837Sgabeblack@google.com 11213091Sgabeblack@google.comconst sc_bind_proxy SC_BIND_PROXY_NIL(*(sc_port_base *)nullptr); 11312837Sgabeblack@google.com 11412837Sgabeblack@google.comvoid 11512837Sgabeblack@google.comsc_module::operator () (const sc_bind_proxy &p001, 11612837Sgabeblack@google.com const sc_bind_proxy &p002, 11712837Sgabeblack@google.com const sc_bind_proxy &p003, 11812837Sgabeblack@google.com const sc_bind_proxy &p004, 11912837Sgabeblack@google.com const sc_bind_proxy &p005, 12012837Sgabeblack@google.com const sc_bind_proxy &p006, 12112837Sgabeblack@google.com const sc_bind_proxy &p007, 12212837Sgabeblack@google.com const sc_bind_proxy &p008, 12312837Sgabeblack@google.com const sc_bind_proxy &p009, 12412837Sgabeblack@google.com const sc_bind_proxy &p010, 12512837Sgabeblack@google.com const sc_bind_proxy &p011, 12612837Sgabeblack@google.com const sc_bind_proxy &p012, 12712837Sgabeblack@google.com const sc_bind_proxy &p013, 12812837Sgabeblack@google.com const sc_bind_proxy &p014, 12912837Sgabeblack@google.com const sc_bind_proxy &p015, 13012837Sgabeblack@google.com const sc_bind_proxy &p016, 13112837Sgabeblack@google.com const sc_bind_proxy &p017, 13212837Sgabeblack@google.com const sc_bind_proxy &p018, 13312837Sgabeblack@google.com const sc_bind_proxy &p019, 13412837Sgabeblack@google.com const sc_bind_proxy &p020, 13512837Sgabeblack@google.com const sc_bind_proxy &p021, 13612837Sgabeblack@google.com const sc_bind_proxy &p022, 13712837Sgabeblack@google.com const sc_bind_proxy &p023, 13812837Sgabeblack@google.com const sc_bind_proxy &p024, 13912837Sgabeblack@google.com const sc_bind_proxy &p025, 14012837Sgabeblack@google.com const sc_bind_proxy &p026, 14112837Sgabeblack@google.com const sc_bind_proxy &p027, 14212837Sgabeblack@google.com const sc_bind_proxy &p028, 14312837Sgabeblack@google.com const sc_bind_proxy &p029, 14412837Sgabeblack@google.com const sc_bind_proxy &p030, 14512837Sgabeblack@google.com const sc_bind_proxy &p031, 14612837Sgabeblack@google.com const sc_bind_proxy &p032, 14712837Sgabeblack@google.com const sc_bind_proxy &p033, 14812837Sgabeblack@google.com const sc_bind_proxy &p034, 14912837Sgabeblack@google.com const sc_bind_proxy &p035, 15012837Sgabeblack@google.com const sc_bind_proxy &p036, 15112837Sgabeblack@google.com const sc_bind_proxy &p037, 15212837Sgabeblack@google.com const sc_bind_proxy &p038, 15312837Sgabeblack@google.com const sc_bind_proxy &p039, 15412837Sgabeblack@google.com const sc_bind_proxy &p040, 15512837Sgabeblack@google.com const sc_bind_proxy &p041, 15612837Sgabeblack@google.com const sc_bind_proxy &p042, 15712837Sgabeblack@google.com const sc_bind_proxy &p043, 15812837Sgabeblack@google.com const sc_bind_proxy &p044, 15912837Sgabeblack@google.com const sc_bind_proxy &p045, 16012837Sgabeblack@google.com const sc_bind_proxy &p046, 16112837Sgabeblack@google.com const sc_bind_proxy &p047, 16212837Sgabeblack@google.com const sc_bind_proxy &p048, 16312837Sgabeblack@google.com const sc_bind_proxy &p049, 16412837Sgabeblack@google.com const sc_bind_proxy &p050, 16512837Sgabeblack@google.com const sc_bind_proxy &p051, 16612837Sgabeblack@google.com const sc_bind_proxy &p052, 16712837Sgabeblack@google.com const sc_bind_proxy &p053, 16812837Sgabeblack@google.com const sc_bind_proxy &p054, 16912837Sgabeblack@google.com const sc_bind_proxy &p055, 17012837Sgabeblack@google.com const sc_bind_proxy &p056, 17112837Sgabeblack@google.com const sc_bind_proxy &p057, 17212837Sgabeblack@google.com const sc_bind_proxy &p058, 17312837Sgabeblack@google.com const sc_bind_proxy &p059, 17412837Sgabeblack@google.com const sc_bind_proxy &p060, 17512837Sgabeblack@google.com const sc_bind_proxy &p061, 17612837Sgabeblack@google.com const sc_bind_proxy &p062, 17712837Sgabeblack@google.com const sc_bind_proxy &p063, 17812837Sgabeblack@google.com const sc_bind_proxy &p064) 17912837Sgabeblack@google.com{ 18013091Sgabeblack@google.com std::vector<const ::sc_core::sc_bind_proxy *> proxies; 18113091Sgabeblack@google.com auto insert = [&proxies](const ::sc_core::sc_bind_proxy &p) -> bool { 18213091Sgabeblack@google.com if (!p.port() && !p.interface()) 18313091Sgabeblack@google.com return false; 18413091Sgabeblack@google.com proxies.push_back(&p); 18513091Sgabeblack@google.com return true; 18613091Sgabeblack@google.com }; 18713091Sgabeblack@google.com insert(p001) && insert(p002) && insert(p003) && insert(p004) && 18813091Sgabeblack@google.com insert(p005) && insert(p006) && insert(p007) && insert(p008) && 18913091Sgabeblack@google.com insert(p009) && insert(p010) && insert(p011) && insert(p012) && 19013091Sgabeblack@google.com insert(p013) && insert(p014) && insert(p015) && insert(p016) && 19113091Sgabeblack@google.com insert(p017) && insert(p018) && insert(p019) && insert(p020) && 19213091Sgabeblack@google.com insert(p021) && insert(p022) && insert(p023) && insert(p024) && 19313091Sgabeblack@google.com insert(p025) && insert(p026) && insert(p027) && insert(p028) && 19413091Sgabeblack@google.com insert(p029) && insert(p030) && insert(p031) && insert(p032) && 19513091Sgabeblack@google.com insert(p033) && insert(p034) && insert(p035) && insert(p036) && 19613091Sgabeblack@google.com insert(p037) && insert(p038) && insert(p039) && insert(p040) && 19713091Sgabeblack@google.com insert(p041) && insert(p042) && insert(p043) && insert(p044) && 19813091Sgabeblack@google.com insert(p045) && insert(p046) && insert(p047) && insert(p048) && 19913091Sgabeblack@google.com insert(p049) && insert(p050) && insert(p051) && insert(p052) && 20013091Sgabeblack@google.com insert(p053) && insert(p054) && insert(p055) && insert(p056) && 20113091Sgabeblack@google.com insert(p057) && insert(p058) && insert(p059) && insert(p060) && 20213091Sgabeblack@google.com insert(p061) && insert(p062) && insert(p063) && insert(p064); 20313091Sgabeblack@google.com _gem5_module->bindPorts(proxies); 20412837Sgabeblack@google.com} 20512837Sgabeblack@google.com 20612837Sgabeblack@google.comconst std::vector<sc_object *> & 20712837Sgabeblack@google.comsc_module::get_child_objects() const 20812837Sgabeblack@google.com{ 20912951Sgabeblack@google.com return _gem5_module->obj()->get_child_objects(); 21012837Sgabeblack@google.com} 21112837Sgabeblack@google.com 21212837Sgabeblack@google.comconst std::vector<sc_event *> & 21312837Sgabeblack@google.comsc_module::get_child_events() const 21412837Sgabeblack@google.com{ 21512951Sgabeblack@google.com return _gem5_module->obj()->get_child_events(); 21612837Sgabeblack@google.com} 21712837Sgabeblack@google.com 21812951Sgabeblack@google.comsc_module::sc_module() : 21913079Sgabeblack@google.com sc_object(sc_gem5::newModuleChecked()->name()), 22012951Sgabeblack@google.com _gem5_module(sc_gem5::currentModule()) 22112951Sgabeblack@google.com{} 22212837Sgabeblack@google.com 22312951Sgabeblack@google.comsc_module::sc_module(const sc_module_name &) : sc_module() {} 22413191Sgabeblack@google.comsc_module::sc_module(const char *_name) : sc_module(sc_module_name(_name)) 22513191Sgabeblack@google.com{ 22613191Sgabeblack@google.com _gem5_module->deprecatedConstructor(); 22713191Sgabeblack@google.com SC_REPORT_WARNING("(W569) sc_module(const char*), " 22813191Sgabeblack@google.com "sc_module(const std::string&) have been deprecated, use " 22913191Sgabeblack@google.com "sc_module(const sc_module_name&)", _name); 23013191Sgabeblack@google.com} 23112951Sgabeblack@google.comsc_module::sc_module(const std::string &_name) : 23212951Sgabeblack@google.com sc_module(sc_module_name(_name.c_str())) 23313191Sgabeblack@google.com{ 23413191Sgabeblack@google.com _gem5_module->deprecatedConstructor(); 23513191Sgabeblack@google.com SC_REPORT_WARNING("(W569) sc_module(const char*), " 23613191Sgabeblack@google.com "sc_module(const std::string&) have been deprecated, use " 23713191Sgabeblack@google.com "sc_module(const sc_module_name&)", _name.c_str()); 23813191Sgabeblack@google.com} 23913191Sgabeblack@google.com 24013191Sgabeblack@google.comvoid 24113191Sgabeblack@google.comsc_module::end_module() 24213191Sgabeblack@google.com{ 24313191Sgabeblack@google.com _gem5_module->endModule(); 24413191Sgabeblack@google.com} 24512928Sgabeblack@google.com 24612837Sgabeblack@google.comvoid 24712837Sgabeblack@google.comsc_module::reset_signal_is(const sc_in<bool> &, bool) 24812837Sgabeblack@google.com{ 24912837Sgabeblack@google.com warn("%s not implemented.\n", __PRETTY_FUNCTION__); 25012837Sgabeblack@google.com} 25112837Sgabeblack@google.com 25212837Sgabeblack@google.comvoid 25312837Sgabeblack@google.comsc_module::reset_signal_is(const sc_inout<bool> &, bool) 25412837Sgabeblack@google.com{ 25512837Sgabeblack@google.com warn("%s not implemented.\n", __PRETTY_FUNCTION__); 25612837Sgabeblack@google.com} 25712837Sgabeblack@google.com 25812837Sgabeblack@google.comvoid 25912837Sgabeblack@google.comsc_module::reset_signal_is(const sc_out<bool> &, bool) 26012837Sgabeblack@google.com{ 26112837Sgabeblack@google.com warn("%s not implemented.\n", __PRETTY_FUNCTION__); 26212837Sgabeblack@google.com} 26312837Sgabeblack@google.com 26412837Sgabeblack@google.comvoid 26512837Sgabeblack@google.comsc_module::reset_signal_is(const sc_signal_in_if<bool> &, bool) 26612837Sgabeblack@google.com{ 26712837Sgabeblack@google.com warn("%s not implemented.\n", __PRETTY_FUNCTION__); 26812837Sgabeblack@google.com} 26912837Sgabeblack@google.com 27012837Sgabeblack@google.com 27112837Sgabeblack@google.comvoid 27212837Sgabeblack@google.comsc_module::async_reset_signal_is(const sc_in<bool> &, bool) 27312837Sgabeblack@google.com{ 27412837Sgabeblack@google.com warn("%s not implemented.\n", __PRETTY_FUNCTION__); 27512837Sgabeblack@google.com} 27612837Sgabeblack@google.com 27712837Sgabeblack@google.comvoid 27812837Sgabeblack@google.comsc_module::async_reset_signal_is(const sc_inout<bool> &, bool) 27912837Sgabeblack@google.com{ 28012837Sgabeblack@google.com warn("%s not implemented.\n", __PRETTY_FUNCTION__); 28112837Sgabeblack@google.com} 28212837Sgabeblack@google.com 28312837Sgabeblack@google.comvoid 28412837Sgabeblack@google.comsc_module::async_reset_signal_is(const sc_out<bool> &, bool) 28512837Sgabeblack@google.com{ 28612837Sgabeblack@google.com warn("%s not implemented.\n", __PRETTY_FUNCTION__); 28712837Sgabeblack@google.com} 28812837Sgabeblack@google.com 28912837Sgabeblack@google.comvoid 29012837Sgabeblack@google.comsc_module::async_reset_signal_is(const sc_signal_in_if<bool> &, bool) 29112837Sgabeblack@google.com{ 29212837Sgabeblack@google.com warn("%s not implemented.\n", __PRETTY_FUNCTION__); 29312837Sgabeblack@google.com} 29412837Sgabeblack@google.com 29512837Sgabeblack@google.com 29612837Sgabeblack@google.comvoid 29712837Sgabeblack@google.comsc_module::dont_initialize() 29812837Sgabeblack@google.com{ 29913194Sgabeblack@google.com ::sc_gem5::Process::newest()->dontInitialize(true); 30012837Sgabeblack@google.com} 30112837Sgabeblack@google.com 30212837Sgabeblack@google.comvoid 30312953Sgabeblack@google.comsc_module::set_stack_size(size_t size) 30412837Sgabeblack@google.com{ 30512953Sgabeblack@google.com ::sc_gem5::Process::newest()->setStackSize(size); 30612837Sgabeblack@google.com} 30712837Sgabeblack@google.com 30812837Sgabeblack@google.com 30912951Sgabeblack@google.comvoid sc_module::next_trigger() { ::sc_core::next_trigger(); } 31012951Sgabeblack@google.com 31112837Sgabeblack@google.comvoid 31212951Sgabeblack@google.comsc_module::next_trigger(const sc_event &e) 31312837Sgabeblack@google.com{ 31412951Sgabeblack@google.com ::sc_core::next_trigger(e); 31512837Sgabeblack@google.com} 31612837Sgabeblack@google.com 31712837Sgabeblack@google.comvoid 31812951Sgabeblack@google.comsc_module::next_trigger(const sc_event_or_list &eol) 31912837Sgabeblack@google.com{ 32012951Sgabeblack@google.com ::sc_core::next_trigger(eol); 32112837Sgabeblack@google.com} 32212837Sgabeblack@google.com 32312837Sgabeblack@google.comvoid 32412951Sgabeblack@google.comsc_module::next_trigger(const sc_event_and_list &eal) 32512837Sgabeblack@google.com{ 32612951Sgabeblack@google.com ::sc_core::next_trigger(eal); 32712837Sgabeblack@google.com} 32812837Sgabeblack@google.com 32912837Sgabeblack@google.comvoid 33012951Sgabeblack@google.comsc_module::next_trigger(const sc_time &t) 33112837Sgabeblack@google.com{ 33212951Sgabeblack@google.com ::sc_core::next_trigger(t); 33312837Sgabeblack@google.com} 33412837Sgabeblack@google.com 33512837Sgabeblack@google.comvoid 33612951Sgabeblack@google.comsc_module::next_trigger(double d, sc_time_unit u) 33712837Sgabeblack@google.com{ 33812951Sgabeblack@google.com ::sc_core::next_trigger(d, u); 33912837Sgabeblack@google.com} 34012837Sgabeblack@google.com 34112837Sgabeblack@google.comvoid 34212951Sgabeblack@google.comsc_module::next_trigger(const sc_time &t, const sc_event &e) 34312837Sgabeblack@google.com{ 34412951Sgabeblack@google.com ::sc_core::next_trigger(t, e); 34512837Sgabeblack@google.com} 34612837Sgabeblack@google.com 34712837Sgabeblack@google.comvoid 34812951Sgabeblack@google.comsc_module::next_trigger(double d, sc_time_unit u, const sc_event &e) 34912837Sgabeblack@google.com{ 35012951Sgabeblack@google.com ::sc_core::next_trigger(d, u, e); 35112837Sgabeblack@google.com} 35212837Sgabeblack@google.com 35312837Sgabeblack@google.comvoid 35412951Sgabeblack@google.comsc_module::next_trigger(const sc_time &t, const sc_event_or_list &eol) 35512837Sgabeblack@google.com{ 35612951Sgabeblack@google.com ::sc_core::next_trigger(t, eol); 35712837Sgabeblack@google.com} 35812837Sgabeblack@google.com 35912837Sgabeblack@google.comvoid 36012951Sgabeblack@google.comsc_module::next_trigger(double d, sc_time_unit u, const sc_event_or_list &eol) 36112837Sgabeblack@google.com{ 36212951Sgabeblack@google.com ::sc_core::next_trigger(d, u, eol); 36312837Sgabeblack@google.com} 36412837Sgabeblack@google.com 36512837Sgabeblack@google.comvoid 36612951Sgabeblack@google.comsc_module::next_trigger(const sc_time &t, const sc_event_and_list &eal) 36712837Sgabeblack@google.com{ 36812951Sgabeblack@google.com ::sc_core::next_trigger(t, eal); 36912837Sgabeblack@google.com} 37012837Sgabeblack@google.com 37112837Sgabeblack@google.comvoid 37212951Sgabeblack@google.comsc_module::next_trigger(double d, sc_time_unit u, const sc_event_and_list &eal) 37312837Sgabeblack@google.com{ 37412951Sgabeblack@google.com ::sc_core::next_trigger(d, u, eal); 37512837Sgabeblack@google.com} 37612837Sgabeblack@google.com 37712837Sgabeblack@google.com 37812929Sgabeblack@google.combool 37912929Sgabeblack@google.comsc_module::timed_out() 38012929Sgabeblack@google.com{ 38113189Sgabeblack@google.com return ::sc_core::timed_out(); 38212929Sgabeblack@google.com} 38312929Sgabeblack@google.com 38412929Sgabeblack@google.com 38512837Sgabeblack@google.comvoid 38612837Sgabeblack@google.comsc_module::wait() 38712837Sgabeblack@google.com{ 38812951Sgabeblack@google.com ::sc_core::wait(); 38912837Sgabeblack@google.com} 39012837Sgabeblack@google.com 39112837Sgabeblack@google.comvoid 39212951Sgabeblack@google.comsc_module::wait(int i) 39312837Sgabeblack@google.com{ 39412951Sgabeblack@google.com ::sc_core::wait(i); 39512837Sgabeblack@google.com} 39612837Sgabeblack@google.com 39712837Sgabeblack@google.comvoid 39812951Sgabeblack@google.comsc_module::wait(const sc_event &e) 39912837Sgabeblack@google.com{ 40012951Sgabeblack@google.com ::sc_core::wait(e); 40112837Sgabeblack@google.com} 40212837Sgabeblack@google.com 40312837Sgabeblack@google.comvoid 40412951Sgabeblack@google.comsc_module::wait(const sc_event_or_list &eol) 40512837Sgabeblack@google.com{ 40612951Sgabeblack@google.com ::sc_core::wait(eol); 40712837Sgabeblack@google.com} 40812837Sgabeblack@google.com 40912837Sgabeblack@google.comvoid 41012951Sgabeblack@google.comsc_module::wait(const sc_event_and_list &eal) 41112837Sgabeblack@google.com{ 41212951Sgabeblack@google.com ::sc_core::wait(eal); 41312837Sgabeblack@google.com} 41412837Sgabeblack@google.com 41512837Sgabeblack@google.comvoid 41612951Sgabeblack@google.comsc_module::wait(const sc_time &t) 41712837Sgabeblack@google.com{ 41812951Sgabeblack@google.com ::sc_core::wait(t); 41912837Sgabeblack@google.com} 42012837Sgabeblack@google.com 42112837Sgabeblack@google.comvoid 42212951Sgabeblack@google.comsc_module::wait(double d, sc_time_unit u) 42312837Sgabeblack@google.com{ 42412951Sgabeblack@google.com ::sc_core::wait(d, u); 42512837Sgabeblack@google.com} 42612837Sgabeblack@google.com 42712837Sgabeblack@google.comvoid 42812951Sgabeblack@google.comsc_module::wait(const sc_time &t, const sc_event &e) 42912837Sgabeblack@google.com{ 43012951Sgabeblack@google.com ::sc_core::wait(t, e); 43112837Sgabeblack@google.com} 43212837Sgabeblack@google.com 43312837Sgabeblack@google.comvoid 43412951Sgabeblack@google.comsc_module::wait(double d, sc_time_unit u, const sc_event &e) 43512837Sgabeblack@google.com{ 43612951Sgabeblack@google.com ::sc_core::wait(d, u, e); 43712837Sgabeblack@google.com} 43812837Sgabeblack@google.com 43912837Sgabeblack@google.comvoid 44012951Sgabeblack@google.comsc_module::wait(const sc_time &t, const sc_event_or_list &eol) 44112837Sgabeblack@google.com{ 44212951Sgabeblack@google.com ::sc_core::wait(t, eol); 44312837Sgabeblack@google.com} 44412837Sgabeblack@google.com 44512837Sgabeblack@google.comvoid 44612951Sgabeblack@google.comsc_module::wait(double d, sc_time_unit u, const sc_event_or_list &eol) 44712837Sgabeblack@google.com{ 44812951Sgabeblack@google.com ::sc_core::wait(d, u, eol); 44912837Sgabeblack@google.com} 45012837Sgabeblack@google.com 45112837Sgabeblack@google.comvoid 45212951Sgabeblack@google.comsc_module::wait(const sc_time &t, const sc_event_and_list &eal) 45312837Sgabeblack@google.com{ 45412951Sgabeblack@google.com ::sc_core::wait(t, eal); 45512837Sgabeblack@google.com} 45612837Sgabeblack@google.com 45712837Sgabeblack@google.comvoid 45812951Sgabeblack@google.comsc_module::wait(double d, sc_time_unit u, const sc_event_and_list &eal) 45912837Sgabeblack@google.com{ 46012951Sgabeblack@google.com ::sc_core::wait(d, u, eal); 46112837Sgabeblack@google.com} 46212837Sgabeblack@google.com 46312837Sgabeblack@google.com 46412837Sgabeblack@google.comvoid 46512909Sgabeblack@google.comsc_module::halt() 46612909Sgabeblack@google.com{ 46712951Sgabeblack@google.com ::sc_core::halt(); 46812909Sgabeblack@google.com} 46912909Sgabeblack@google.com 47012914Sgabeblack@google.comvoid 47112951Sgabeblack@google.comsc_module::at_posedge(const sc_signal_in_if<bool> &s) 47212914Sgabeblack@google.com{ 47312951Sgabeblack@google.com ::sc_core::at_posedge(s); 47412914Sgabeblack@google.com} 47512914Sgabeblack@google.com 47612914Sgabeblack@google.comvoid 47712951Sgabeblack@google.comsc_module::at_posedge(const sc_signal_in_if<sc_dt::sc_logic> &s) 47812914Sgabeblack@google.com{ 47912951Sgabeblack@google.com ::sc_core::at_posedge(s); 48012914Sgabeblack@google.com} 48112914Sgabeblack@google.com 48212914Sgabeblack@google.comvoid 48312951Sgabeblack@google.comsc_module::at_negedge(const sc_signal_in_if<bool> &s) 48412914Sgabeblack@google.com{ 48512951Sgabeblack@google.com ::sc_core::at_negedge(s); 48612914Sgabeblack@google.com} 48712914Sgabeblack@google.com 48812914Sgabeblack@google.comvoid 48912951Sgabeblack@google.comsc_module::at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &s) 49012914Sgabeblack@google.com{ 49112951Sgabeblack@google.com ::sc_core::at_negedge(s); 49212914Sgabeblack@google.com} 49312914Sgabeblack@google.com 49412909Sgabeblack@google.com 49512909Sgabeblack@google.comvoid 49612837Sgabeblack@google.comnext_trigger() 49712837Sgabeblack@google.com{ 49812958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 49913206Sgabeblack@google.com p->cancelTimeout(); 50013206Sgabeblack@google.com p->clearDynamic(); 50112837Sgabeblack@google.com} 50212837Sgabeblack@google.com 50312837Sgabeblack@google.comvoid 50412958Sgabeblack@google.comnext_trigger(const sc_event &e) 50512837Sgabeblack@google.com{ 50612958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 50713206Sgabeblack@google.com p->cancelTimeout(); 50813207Sgabeblack@google.com ::sc_gem5::newDynamicSensitivityEvent(p, &e); 50912837Sgabeblack@google.com} 51012837Sgabeblack@google.com 51112837Sgabeblack@google.comvoid 51212958Sgabeblack@google.comnext_trigger(const sc_event_or_list &eol) 51312837Sgabeblack@google.com{ 51412958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 51513206Sgabeblack@google.com p->cancelTimeout(); 51613207Sgabeblack@google.com ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol); 51712837Sgabeblack@google.com} 51812837Sgabeblack@google.com 51912837Sgabeblack@google.comvoid 52012958Sgabeblack@google.comnext_trigger(const sc_event_and_list &eal) 52112837Sgabeblack@google.com{ 52212958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 52313206Sgabeblack@google.com p->cancelTimeout(); 52413207Sgabeblack@google.com ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal); 52512837Sgabeblack@google.com} 52612837Sgabeblack@google.com 52712837Sgabeblack@google.comvoid 52812958Sgabeblack@google.comnext_trigger(const sc_time &t) 52912837Sgabeblack@google.com{ 53012958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 53113206Sgabeblack@google.com p->setTimeout(t); 53213206Sgabeblack@google.com p->clearDynamic(); 53312837Sgabeblack@google.com} 53412837Sgabeblack@google.com 53512837Sgabeblack@google.comvoid 53612951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u) 53712837Sgabeblack@google.com{ 53812951Sgabeblack@google.com next_trigger(sc_time(d, u)); 53912837Sgabeblack@google.com} 54012837Sgabeblack@google.com 54112837Sgabeblack@google.comvoid 54212958Sgabeblack@google.comnext_trigger(const sc_time &t, const sc_event &e) 54312837Sgabeblack@google.com{ 54412958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 54513206Sgabeblack@google.com p->setTimeout(t); 54613207Sgabeblack@google.com ::sc_gem5::newDynamicSensitivityEvent(p, &e); 54712837Sgabeblack@google.com} 54812837Sgabeblack@google.com 54912837Sgabeblack@google.comvoid 55012951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u, const sc_event &e) 55112837Sgabeblack@google.com{ 55212951Sgabeblack@google.com next_trigger(sc_time(d, u), e); 55312837Sgabeblack@google.com} 55412837Sgabeblack@google.com 55512837Sgabeblack@google.comvoid 55612958Sgabeblack@google.comnext_trigger(const sc_time &t, const sc_event_or_list &eol) 55712837Sgabeblack@google.com{ 55812958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 55913206Sgabeblack@google.com p->setTimeout(t); 56013207Sgabeblack@google.com ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol); 56112837Sgabeblack@google.com} 56212837Sgabeblack@google.com 56312837Sgabeblack@google.comvoid 56412951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u, const sc_event_or_list &eol) 56512837Sgabeblack@google.com{ 56612951Sgabeblack@google.com next_trigger(sc_time(d, u), eol); 56712837Sgabeblack@google.com} 56812837Sgabeblack@google.com 56912837Sgabeblack@google.comvoid 57012958Sgabeblack@google.comnext_trigger(const sc_time &t, const sc_event_and_list &eal) 57112837Sgabeblack@google.com{ 57212958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 57313206Sgabeblack@google.com p->setTimeout(t); 57413207Sgabeblack@google.com ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal); 57512837Sgabeblack@google.com} 57612837Sgabeblack@google.com 57712837Sgabeblack@google.comvoid 57812951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u, const sc_event_and_list &eal) 57912837Sgabeblack@google.com{ 58012951Sgabeblack@google.com next_trigger(sc_time(d, u), eal); 58112837Sgabeblack@google.com} 58212837Sgabeblack@google.com 58312929Sgabeblack@google.combool 58412929Sgabeblack@google.comtimed_out() 58512929Sgabeblack@google.com{ 58613189Sgabeblack@google.com ::sc_gem5::Process *p = sc_gem5::scheduler.current(); 58713189Sgabeblack@google.com if (!p) 58813189Sgabeblack@google.com return false; 58913189Sgabeblack@google.com else 59013189Sgabeblack@google.com return p->timedOut(); 59112929Sgabeblack@google.com} 59212929Sgabeblack@google.com 59312837Sgabeblack@google.com 59412837Sgabeblack@google.comvoid 59512837Sgabeblack@google.comwait() 59612837Sgabeblack@google.com{ 59712958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 59813206Sgabeblack@google.com p->cancelTimeout(); 59913206Sgabeblack@google.com p->clearDynamic(); 60012958Sgabeblack@google.com sc_gem5::scheduler.yield(); 60112837Sgabeblack@google.com} 60212837Sgabeblack@google.com 60312837Sgabeblack@google.comvoid 60412958Sgabeblack@google.comwait(int n) 60512837Sgabeblack@google.com{ 60613146Sgabeblack@google.com if (n <= 0) { 60713146Sgabeblack@google.com std::string msg = csprintf("n = %d", n); 60813146Sgabeblack@google.com SC_REPORT_ERROR("(E525) wait(n) is only valid for n > 0", msg.c_str()); 60913146Sgabeblack@google.com } 61012958Sgabeblack@google.com for (int i = 0; i < n; i++) 61112958Sgabeblack@google.com wait(); 61212837Sgabeblack@google.com} 61312837Sgabeblack@google.com 61412837Sgabeblack@google.comvoid 61512958Sgabeblack@google.comwait(const sc_event &e) 61612837Sgabeblack@google.com{ 61712958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 61813206Sgabeblack@google.com p->cancelTimeout(); 61913207Sgabeblack@google.com ::sc_gem5::newDynamicSensitivityEvent(p, &e); 62012958Sgabeblack@google.com sc_gem5::scheduler.yield(); 62112837Sgabeblack@google.com} 62212837Sgabeblack@google.com 62312837Sgabeblack@google.comvoid 62412958Sgabeblack@google.comwait(const sc_event_or_list &eol) 62512837Sgabeblack@google.com{ 62612958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 62713206Sgabeblack@google.com p->cancelTimeout(); 62813207Sgabeblack@google.com ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol); 62912958Sgabeblack@google.com sc_gem5::scheduler.yield(); 63012837Sgabeblack@google.com} 63112837Sgabeblack@google.com 63212837Sgabeblack@google.comvoid 63312958Sgabeblack@google.comwait(const sc_event_and_list &eal) 63412837Sgabeblack@google.com{ 63512958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 63613206Sgabeblack@google.com p->cancelTimeout(); 63713207Sgabeblack@google.com ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal); 63812958Sgabeblack@google.com sc_gem5::scheduler.yield(); 63912837Sgabeblack@google.com} 64012837Sgabeblack@google.com 64112837Sgabeblack@google.comvoid 64212958Sgabeblack@google.comwait(const sc_time &t) 64312837Sgabeblack@google.com{ 64412958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 64513206Sgabeblack@google.com p->setTimeout(t); 64613206Sgabeblack@google.com p->clearDynamic(); 64712958Sgabeblack@google.com sc_gem5::scheduler.yield(); 64812837Sgabeblack@google.com} 64912837Sgabeblack@google.com 65012837Sgabeblack@google.comvoid 65112951Sgabeblack@google.comwait(double d, sc_time_unit u) 65212837Sgabeblack@google.com{ 65312951Sgabeblack@google.com wait(sc_time(d, u)); 65412837Sgabeblack@google.com} 65512837Sgabeblack@google.com 65612837Sgabeblack@google.comvoid 65712958Sgabeblack@google.comwait(const sc_time &t, const sc_event &e) 65812837Sgabeblack@google.com{ 65912958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 66013206Sgabeblack@google.com p->setTimeout(t); 66113207Sgabeblack@google.com ::sc_gem5::newDynamicSensitivityEvent(p, &e); 66212958Sgabeblack@google.com sc_gem5::scheduler.yield(); 66312837Sgabeblack@google.com} 66412837Sgabeblack@google.com 66512837Sgabeblack@google.comvoid 66612951Sgabeblack@google.comwait(double d, sc_time_unit u, const sc_event &e) 66712837Sgabeblack@google.com{ 66812951Sgabeblack@google.com wait(sc_time(d, u), e); 66912837Sgabeblack@google.com} 67012837Sgabeblack@google.com 67112837Sgabeblack@google.comvoid 67212958Sgabeblack@google.comwait(const sc_time &t, const sc_event_or_list &eol) 67312837Sgabeblack@google.com{ 67412958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 67513206Sgabeblack@google.com p->setTimeout(t); 67613207Sgabeblack@google.com ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol); 67712958Sgabeblack@google.com sc_gem5::scheduler.yield(); 67812837Sgabeblack@google.com} 67912837Sgabeblack@google.com 68012837Sgabeblack@google.comvoid 68112951Sgabeblack@google.comwait(double d, sc_time_unit u, const sc_event_or_list &eol) 68212837Sgabeblack@google.com{ 68312951Sgabeblack@google.com wait(sc_time(d, u), eol); 68412837Sgabeblack@google.com} 68512837Sgabeblack@google.com 68612837Sgabeblack@google.comvoid 68712958Sgabeblack@google.comwait(const sc_time &t, const sc_event_and_list &eal) 68812837Sgabeblack@google.com{ 68912958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 69013206Sgabeblack@google.com p->setTimeout(t); 69113207Sgabeblack@google.com ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal); 69212958Sgabeblack@google.com sc_gem5::scheduler.yield(); 69312837Sgabeblack@google.com} 69412837Sgabeblack@google.com 69512837Sgabeblack@google.comvoid 69612951Sgabeblack@google.comwait(double d, sc_time_unit u, const sc_event_and_list &eal) 69712837Sgabeblack@google.com{ 69812951Sgabeblack@google.com wait(sc_time(d, u), eal); 69912837Sgabeblack@google.com} 70012837Sgabeblack@google.com 70112909Sgabeblack@google.comvoid 70212909Sgabeblack@google.comhalt() 70312909Sgabeblack@google.com{ 70413175Sgabeblack@google.com ::sc_core::wait(); 70513175Sgabeblack@google.com throw ::sc_gem5::ScHalt(); 70612909Sgabeblack@google.com} 70712909Sgabeblack@google.com 70812914Sgabeblack@google.comvoid 70913155Sgabeblack@google.comat_posedge(const sc_signal_in_if<bool> &s) 71012914Sgabeblack@google.com{ 71113155Sgabeblack@google.com while (s.read()) 71213155Sgabeblack@google.com wait(); 71313155Sgabeblack@google.com while (!s.read()) 71413155Sgabeblack@google.com wait(); 71512914Sgabeblack@google.com} 71612914Sgabeblack@google.com 71712914Sgabeblack@google.comvoid 71813155Sgabeblack@google.comat_posedge(const sc_signal_in_if<sc_dt::sc_logic> &s) 71912914Sgabeblack@google.com{ 72013155Sgabeblack@google.com while (s.read() == sc_dt::Log_1) 72113155Sgabeblack@google.com wait(); 72213155Sgabeblack@google.com while (s.read() == sc_dt::Log_0) 72313155Sgabeblack@google.com wait(); 72412914Sgabeblack@google.com} 72512914Sgabeblack@google.com 72612914Sgabeblack@google.comvoid 72713155Sgabeblack@google.comat_negedge(const sc_signal_in_if<bool> &s) 72812914Sgabeblack@google.com{ 72913155Sgabeblack@google.com while (!s.read()) 73013155Sgabeblack@google.com wait(); 73113155Sgabeblack@google.com while (s.read()) 73213155Sgabeblack@google.com wait(); 73312914Sgabeblack@google.com} 73412914Sgabeblack@google.com 73512914Sgabeblack@google.comvoid 73613155Sgabeblack@google.comat_negedge(const sc_signal_in_if<sc_dt::sc_logic> &s) 73712914Sgabeblack@google.com{ 73813155Sgabeblack@google.com while (s.read() == sc_dt::Log_0) 73913155Sgabeblack@google.com wait(); 74013155Sgabeblack@google.com while (s.read() == sc_dt::Log_1) 74113155Sgabeblack@google.com wait(); 74212914Sgabeblack@google.com} 74312914Sgabeblack@google.com 74412837Sgabeblack@google.comconst char * 74513035Sgabeblack@google.comsc_gen_unique_name(const char *seed) 74612837Sgabeblack@google.com{ 74713035Sgabeblack@google.com ::sc_gem5::Module *mod = ::sc_gem5::currentModule(); 74813035Sgabeblack@google.com return mod ? mod->uniqueName(seed) : 74913035Sgabeblack@google.com ::sc_gem5::nameGen.gen(seed); 75012837Sgabeblack@google.com} 75112837Sgabeblack@google.com 75212837Sgabeblack@google.combool 75312930Sgabeblack@google.comsc_hierarchical_name_exists(const char *name) 75412930Sgabeblack@google.com{ 75512930Sgabeblack@google.com warn("%s not implemented.\n", __PRETTY_FUNCTION__); 75612930Sgabeblack@google.com return false; 75712930Sgabeblack@google.com} 75812930Sgabeblack@google.com 75912930Sgabeblack@google.combool 76012837Sgabeblack@google.comsc_start_of_simulation_invoked() 76112837Sgabeblack@google.com{ 76212982Sgabeblack@google.com return ::sc_gem5::kernel->startOfSimulationComplete(); 76312837Sgabeblack@google.com} 76412837Sgabeblack@google.com 76512837Sgabeblack@google.combool 76612837Sgabeblack@google.comsc_end_of_simulation_invoked() 76712837Sgabeblack@google.com{ 76812982Sgabeblack@google.com return ::sc_gem5::kernel->endOfSimulationComplete(); 76912837Sgabeblack@google.com} 77012837Sgabeblack@google.com 77112901Sgabeblack@google.comsc_module * 77212901Sgabeblack@google.comsc_module_sc_new(sc_module *mod) 77312901Sgabeblack@google.com{ 77412901Sgabeblack@google.com static std::vector<std::unique_ptr<sc_module> > modules; 77512901Sgabeblack@google.com modules.emplace_back(mod); 77612901Sgabeblack@google.com return mod; 77712901Sgabeblack@google.com} 77812901Sgabeblack@google.com 77912837Sgabeblack@google.com} // namespace sc_core 780