sc_module.cc revision 13194
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(); 49912958Sgabeblack@google.com p->setDynamic(nullptr); 50012837Sgabeblack@google.com} 50112837Sgabeblack@google.com 50212837Sgabeblack@google.comvoid 50312958Sgabeblack@google.comnext_trigger(const sc_event &e) 50412837Sgabeblack@google.com{ 50512958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 50612958Sgabeblack@google.com p->setDynamic(new ::sc_gem5::SensitivityEvent(p, &e)); 50712837Sgabeblack@google.com} 50812837Sgabeblack@google.com 50912837Sgabeblack@google.comvoid 51012958Sgabeblack@google.comnext_trigger(const sc_event_or_list &eol) 51112837Sgabeblack@google.com{ 51212958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 51312958Sgabeblack@google.com p->setDynamic(new ::sc_gem5::SensitivityEventOrList(p, &eol)); 51412837Sgabeblack@google.com} 51512837Sgabeblack@google.com 51612837Sgabeblack@google.comvoid 51712958Sgabeblack@google.comnext_trigger(const sc_event_and_list &eal) 51812837Sgabeblack@google.com{ 51912958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 52012958Sgabeblack@google.com p->setDynamic(new ::sc_gem5::SensitivityEventAndList(p, &eal)); 52112837Sgabeblack@google.com} 52212837Sgabeblack@google.com 52312837Sgabeblack@google.comvoid 52412958Sgabeblack@google.comnext_trigger(const sc_time &t) 52512837Sgabeblack@google.com{ 52612958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 52712958Sgabeblack@google.com p->setDynamic(new ::sc_gem5::SensitivityTimeout(p, t)); 52812837Sgabeblack@google.com} 52912837Sgabeblack@google.com 53012837Sgabeblack@google.comvoid 53112951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u) 53212837Sgabeblack@google.com{ 53312951Sgabeblack@google.com next_trigger(sc_time(d, u)); 53412837Sgabeblack@google.com} 53512837Sgabeblack@google.com 53612837Sgabeblack@google.comvoid 53712958Sgabeblack@google.comnext_trigger(const sc_time &t, const sc_event &e) 53812837Sgabeblack@google.com{ 53912958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 54012958Sgabeblack@google.com p->setDynamic(new ::sc_gem5::SensitivityTimeoutAndEvent(p, t, &e)); 54112837Sgabeblack@google.com} 54212837Sgabeblack@google.com 54312837Sgabeblack@google.comvoid 54412951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u, const sc_event &e) 54512837Sgabeblack@google.com{ 54612951Sgabeblack@google.com next_trigger(sc_time(d, u), e); 54712837Sgabeblack@google.com} 54812837Sgabeblack@google.com 54912837Sgabeblack@google.comvoid 55012958Sgabeblack@google.comnext_trigger(const sc_time &t, const sc_event_or_list &eol) 55112837Sgabeblack@google.com{ 55212958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 55312958Sgabeblack@google.com p->setDynamic( 55412958Sgabeblack@google.com new ::sc_gem5::SensitivityTimeoutAndEventOrList(p, t, &eol)); 55512837Sgabeblack@google.com} 55612837Sgabeblack@google.com 55712837Sgabeblack@google.comvoid 55812951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u, const sc_event_or_list &eol) 55912837Sgabeblack@google.com{ 56012951Sgabeblack@google.com next_trigger(sc_time(d, u), eol); 56112837Sgabeblack@google.com} 56212837Sgabeblack@google.com 56312837Sgabeblack@google.comvoid 56412958Sgabeblack@google.comnext_trigger(const sc_time &t, const sc_event_and_list &eal) 56512837Sgabeblack@google.com{ 56612958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 56712958Sgabeblack@google.com p->setDynamic( 56812958Sgabeblack@google.com new ::sc_gem5::SensitivityTimeoutAndEventAndList(p, t, &eal)); 56912837Sgabeblack@google.com} 57012837Sgabeblack@google.com 57112837Sgabeblack@google.comvoid 57212951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u, const sc_event_and_list &eal) 57312837Sgabeblack@google.com{ 57412951Sgabeblack@google.com next_trigger(sc_time(d, u), eal); 57512837Sgabeblack@google.com} 57612837Sgabeblack@google.com 57712929Sgabeblack@google.combool 57812929Sgabeblack@google.comtimed_out() 57912929Sgabeblack@google.com{ 58013189Sgabeblack@google.com ::sc_gem5::Process *p = sc_gem5::scheduler.current(); 58113189Sgabeblack@google.com if (!p) 58213189Sgabeblack@google.com return false; 58313189Sgabeblack@google.com else 58413189Sgabeblack@google.com return p->timedOut(); 58512929Sgabeblack@google.com} 58612929Sgabeblack@google.com 58712837Sgabeblack@google.com 58812837Sgabeblack@google.comvoid 58912837Sgabeblack@google.comwait() 59012837Sgabeblack@google.com{ 59112958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 59212958Sgabeblack@google.com p->setDynamic(nullptr); 59312958Sgabeblack@google.com sc_gem5::scheduler.yield(); 59412837Sgabeblack@google.com} 59512837Sgabeblack@google.com 59612837Sgabeblack@google.comvoid 59712958Sgabeblack@google.comwait(int n) 59812837Sgabeblack@google.com{ 59913146Sgabeblack@google.com if (n <= 0) { 60013146Sgabeblack@google.com std::string msg = csprintf("n = %d", n); 60113146Sgabeblack@google.com SC_REPORT_ERROR("(E525) wait(n) is only valid for n > 0", msg.c_str()); 60213146Sgabeblack@google.com } 60312958Sgabeblack@google.com for (int i = 0; i < n; i++) 60412958Sgabeblack@google.com wait(); 60512837Sgabeblack@google.com} 60612837Sgabeblack@google.com 60712837Sgabeblack@google.comvoid 60812958Sgabeblack@google.comwait(const sc_event &e) 60912837Sgabeblack@google.com{ 61012958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 61112958Sgabeblack@google.com p->setDynamic(new ::sc_gem5::SensitivityEvent(p, &e)); 61212958Sgabeblack@google.com sc_gem5::scheduler.yield(); 61312837Sgabeblack@google.com} 61412837Sgabeblack@google.com 61512837Sgabeblack@google.comvoid 61612958Sgabeblack@google.comwait(const sc_event_or_list &eol) 61712837Sgabeblack@google.com{ 61812958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 61912958Sgabeblack@google.com p->setDynamic(new ::sc_gem5::SensitivityEventOrList(p, &eol)); 62012958Sgabeblack@google.com sc_gem5::scheduler.yield(); 62112837Sgabeblack@google.com} 62212837Sgabeblack@google.com 62312837Sgabeblack@google.comvoid 62412958Sgabeblack@google.comwait(const sc_event_and_list &eal) 62512837Sgabeblack@google.com{ 62612958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 62712958Sgabeblack@google.com p->setDynamic(new ::sc_gem5::SensitivityEventAndList(p, &eal)); 62812958Sgabeblack@google.com sc_gem5::scheduler.yield(); 62912837Sgabeblack@google.com} 63012837Sgabeblack@google.com 63112837Sgabeblack@google.comvoid 63212958Sgabeblack@google.comwait(const sc_time &t) 63312837Sgabeblack@google.com{ 63412958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 63512958Sgabeblack@google.com p->setDynamic(new ::sc_gem5::SensitivityTimeout(p, t)); 63612958Sgabeblack@google.com sc_gem5::scheduler.yield(); 63712837Sgabeblack@google.com} 63812837Sgabeblack@google.com 63912837Sgabeblack@google.comvoid 64012951Sgabeblack@google.comwait(double d, sc_time_unit u) 64112837Sgabeblack@google.com{ 64212951Sgabeblack@google.com wait(sc_time(d, u)); 64312837Sgabeblack@google.com} 64412837Sgabeblack@google.com 64512837Sgabeblack@google.comvoid 64612958Sgabeblack@google.comwait(const sc_time &t, const sc_event &e) 64712837Sgabeblack@google.com{ 64812958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 64912958Sgabeblack@google.com p->setDynamic(new ::sc_gem5::SensitivityTimeoutAndEvent(p, t, &e)); 65012958Sgabeblack@google.com sc_gem5::scheduler.yield(); 65112837Sgabeblack@google.com} 65212837Sgabeblack@google.com 65312837Sgabeblack@google.comvoid 65412951Sgabeblack@google.comwait(double d, sc_time_unit u, const sc_event &e) 65512837Sgabeblack@google.com{ 65612951Sgabeblack@google.com wait(sc_time(d, u), e); 65712837Sgabeblack@google.com} 65812837Sgabeblack@google.com 65912837Sgabeblack@google.comvoid 66012958Sgabeblack@google.comwait(const sc_time &t, const sc_event_or_list &eol) 66112837Sgabeblack@google.com{ 66212958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 66312958Sgabeblack@google.com p->setDynamic( 66412958Sgabeblack@google.com new ::sc_gem5::SensitivityTimeoutAndEventOrList(p, t, &eol)); 66512958Sgabeblack@google.com sc_gem5::scheduler.yield(); 66612837Sgabeblack@google.com} 66712837Sgabeblack@google.com 66812837Sgabeblack@google.comvoid 66912951Sgabeblack@google.comwait(double d, sc_time_unit u, const sc_event_or_list &eol) 67012837Sgabeblack@google.com{ 67112951Sgabeblack@google.com wait(sc_time(d, u), eol); 67212837Sgabeblack@google.com} 67312837Sgabeblack@google.com 67412837Sgabeblack@google.comvoid 67512958Sgabeblack@google.comwait(const sc_time &t, const sc_event_and_list &eal) 67612837Sgabeblack@google.com{ 67712958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 67812958Sgabeblack@google.com p->setDynamic( 67912958Sgabeblack@google.com new ::sc_gem5::SensitivityTimeoutAndEventAndList(p, t, &eal)); 68012958Sgabeblack@google.com sc_gem5::scheduler.yield(); 68112837Sgabeblack@google.com} 68212837Sgabeblack@google.com 68312837Sgabeblack@google.comvoid 68412951Sgabeblack@google.comwait(double d, sc_time_unit u, const sc_event_and_list &eal) 68512837Sgabeblack@google.com{ 68612951Sgabeblack@google.com wait(sc_time(d, u), eal); 68712837Sgabeblack@google.com} 68812837Sgabeblack@google.com 68912909Sgabeblack@google.comvoid 69012909Sgabeblack@google.comhalt() 69112909Sgabeblack@google.com{ 69213175Sgabeblack@google.com ::sc_core::wait(); 69313175Sgabeblack@google.com throw ::sc_gem5::ScHalt(); 69412909Sgabeblack@google.com} 69512909Sgabeblack@google.com 69612914Sgabeblack@google.comvoid 69713155Sgabeblack@google.comat_posedge(const sc_signal_in_if<bool> &s) 69812914Sgabeblack@google.com{ 69913155Sgabeblack@google.com while (s.read()) 70013155Sgabeblack@google.com wait(); 70113155Sgabeblack@google.com while (!s.read()) 70213155Sgabeblack@google.com wait(); 70312914Sgabeblack@google.com} 70412914Sgabeblack@google.com 70512914Sgabeblack@google.comvoid 70613155Sgabeblack@google.comat_posedge(const sc_signal_in_if<sc_dt::sc_logic> &s) 70712914Sgabeblack@google.com{ 70813155Sgabeblack@google.com while (s.read() == sc_dt::Log_1) 70913155Sgabeblack@google.com wait(); 71013155Sgabeblack@google.com while (s.read() == sc_dt::Log_0) 71113155Sgabeblack@google.com wait(); 71212914Sgabeblack@google.com} 71312914Sgabeblack@google.com 71412914Sgabeblack@google.comvoid 71513155Sgabeblack@google.comat_negedge(const sc_signal_in_if<bool> &s) 71612914Sgabeblack@google.com{ 71713155Sgabeblack@google.com while (!s.read()) 71813155Sgabeblack@google.com wait(); 71913155Sgabeblack@google.com while (s.read()) 72013155Sgabeblack@google.com wait(); 72112914Sgabeblack@google.com} 72212914Sgabeblack@google.com 72312914Sgabeblack@google.comvoid 72413155Sgabeblack@google.comat_negedge(const sc_signal_in_if<sc_dt::sc_logic> &s) 72512914Sgabeblack@google.com{ 72613155Sgabeblack@google.com while (s.read() == sc_dt::Log_0) 72713155Sgabeblack@google.com wait(); 72813155Sgabeblack@google.com while (s.read() == sc_dt::Log_1) 72913155Sgabeblack@google.com wait(); 73012914Sgabeblack@google.com} 73112914Sgabeblack@google.com 73212837Sgabeblack@google.comconst char * 73313035Sgabeblack@google.comsc_gen_unique_name(const char *seed) 73412837Sgabeblack@google.com{ 73513035Sgabeblack@google.com ::sc_gem5::Module *mod = ::sc_gem5::currentModule(); 73613035Sgabeblack@google.com return mod ? mod->uniqueName(seed) : 73713035Sgabeblack@google.com ::sc_gem5::nameGen.gen(seed); 73812837Sgabeblack@google.com} 73912837Sgabeblack@google.com 74012837Sgabeblack@google.combool 74112930Sgabeblack@google.comsc_hierarchical_name_exists(const char *name) 74212930Sgabeblack@google.com{ 74312930Sgabeblack@google.com warn("%s not implemented.\n", __PRETTY_FUNCTION__); 74412930Sgabeblack@google.com return false; 74512930Sgabeblack@google.com} 74612930Sgabeblack@google.com 74712930Sgabeblack@google.combool 74812837Sgabeblack@google.comsc_start_of_simulation_invoked() 74912837Sgabeblack@google.com{ 75012982Sgabeblack@google.com return ::sc_gem5::kernel->startOfSimulationComplete(); 75112837Sgabeblack@google.com} 75212837Sgabeblack@google.com 75312837Sgabeblack@google.combool 75412837Sgabeblack@google.comsc_end_of_simulation_invoked() 75512837Sgabeblack@google.com{ 75612982Sgabeblack@google.com return ::sc_gem5::kernel->endOfSimulationComplete(); 75712837Sgabeblack@google.com} 75812837Sgabeblack@google.com 75912901Sgabeblack@google.comsc_module * 76012901Sgabeblack@google.comsc_module_sc_new(sc_module *mod) 76112901Sgabeblack@google.com{ 76212901Sgabeblack@google.com static std::vector<std::unique_ptr<sc_module> > modules; 76312901Sgabeblack@google.com modules.emplace_back(mod); 76412901Sgabeblack@google.com return mod; 76512901Sgabeblack@google.com} 76612901Sgabeblack@google.com 76712837Sgabeblack@google.com} // namespace sc_core 768