sc_module.cc revision 13175
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); 8913060Sgabeblack@google.com p->dontInitialize(); 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() {} 22412951Sgabeblack@google.comsc_module::sc_module(const char *_name) : sc_module(sc_module_name(_name)) {} 22512951Sgabeblack@google.comsc_module::sc_module(const std::string &_name) : 22612951Sgabeblack@google.com sc_module(sc_module_name(_name.c_str())) 22712951Sgabeblack@google.com{} 22812928Sgabeblack@google.com 22912837Sgabeblack@google.comvoid 23012837Sgabeblack@google.comsc_module::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::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::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::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::async_reset_signal_is(const sc_in<bool> &, bool) 25612837Sgabeblack@google.com{ 25712837Sgabeblack@google.com warn("%s not implemented.\n", __PRETTY_FUNCTION__); 25812837Sgabeblack@google.com} 25912837Sgabeblack@google.com 26012837Sgabeblack@google.comvoid 26112837Sgabeblack@google.comsc_module::async_reset_signal_is(const sc_inout<bool> &, bool) 26212837Sgabeblack@google.com{ 26312837Sgabeblack@google.com warn("%s not implemented.\n", __PRETTY_FUNCTION__); 26412837Sgabeblack@google.com} 26512837Sgabeblack@google.com 26612837Sgabeblack@google.comvoid 26712837Sgabeblack@google.comsc_module::async_reset_signal_is(const sc_out<bool> &, bool) 26812837Sgabeblack@google.com{ 26912837Sgabeblack@google.com warn("%s not implemented.\n", __PRETTY_FUNCTION__); 27012837Sgabeblack@google.com} 27112837Sgabeblack@google.com 27212837Sgabeblack@google.comvoid 27312837Sgabeblack@google.comsc_module::async_reset_signal_is(const sc_signal_in_if<bool> &, bool) 27412837Sgabeblack@google.com{ 27512837Sgabeblack@google.com warn("%s not implemented.\n", __PRETTY_FUNCTION__); 27612837Sgabeblack@google.com} 27712837Sgabeblack@google.com 27812837Sgabeblack@google.com 27912837Sgabeblack@google.comvoid 28012837Sgabeblack@google.comsc_module::dont_initialize() 28112837Sgabeblack@google.com{ 28212953Sgabeblack@google.com ::sc_gem5::Process::newest()->dontInitialize(); 28312837Sgabeblack@google.com} 28412837Sgabeblack@google.com 28512837Sgabeblack@google.comvoid 28612953Sgabeblack@google.comsc_module::set_stack_size(size_t size) 28712837Sgabeblack@google.com{ 28812953Sgabeblack@google.com ::sc_gem5::Process::newest()->setStackSize(size); 28912837Sgabeblack@google.com} 29012837Sgabeblack@google.com 29112837Sgabeblack@google.com 29212951Sgabeblack@google.comvoid sc_module::next_trigger() { ::sc_core::next_trigger(); } 29312951Sgabeblack@google.com 29412837Sgabeblack@google.comvoid 29512951Sgabeblack@google.comsc_module::next_trigger(const sc_event &e) 29612837Sgabeblack@google.com{ 29712951Sgabeblack@google.com ::sc_core::next_trigger(e); 29812837Sgabeblack@google.com} 29912837Sgabeblack@google.com 30012837Sgabeblack@google.comvoid 30112951Sgabeblack@google.comsc_module::next_trigger(const sc_event_or_list &eol) 30212837Sgabeblack@google.com{ 30312951Sgabeblack@google.com ::sc_core::next_trigger(eol); 30412837Sgabeblack@google.com} 30512837Sgabeblack@google.com 30612837Sgabeblack@google.comvoid 30712951Sgabeblack@google.comsc_module::next_trigger(const sc_event_and_list &eal) 30812837Sgabeblack@google.com{ 30912951Sgabeblack@google.com ::sc_core::next_trigger(eal); 31012837Sgabeblack@google.com} 31112837Sgabeblack@google.com 31212837Sgabeblack@google.comvoid 31312951Sgabeblack@google.comsc_module::next_trigger(const sc_time &t) 31412837Sgabeblack@google.com{ 31512951Sgabeblack@google.com ::sc_core::next_trigger(t); 31612837Sgabeblack@google.com} 31712837Sgabeblack@google.com 31812837Sgabeblack@google.comvoid 31912951Sgabeblack@google.comsc_module::next_trigger(double d, sc_time_unit u) 32012837Sgabeblack@google.com{ 32112951Sgabeblack@google.com ::sc_core::next_trigger(d, u); 32212837Sgabeblack@google.com} 32312837Sgabeblack@google.com 32412837Sgabeblack@google.comvoid 32512951Sgabeblack@google.comsc_module::next_trigger(const sc_time &t, const sc_event &e) 32612837Sgabeblack@google.com{ 32712951Sgabeblack@google.com ::sc_core::next_trigger(t, e); 32812837Sgabeblack@google.com} 32912837Sgabeblack@google.com 33012837Sgabeblack@google.comvoid 33112951Sgabeblack@google.comsc_module::next_trigger(double d, sc_time_unit u, const sc_event &e) 33212837Sgabeblack@google.com{ 33312951Sgabeblack@google.com ::sc_core::next_trigger(d, u, e); 33412837Sgabeblack@google.com} 33512837Sgabeblack@google.com 33612837Sgabeblack@google.comvoid 33712951Sgabeblack@google.comsc_module::next_trigger(const sc_time &t, const sc_event_or_list &eol) 33812837Sgabeblack@google.com{ 33912951Sgabeblack@google.com ::sc_core::next_trigger(t, eol); 34012837Sgabeblack@google.com} 34112837Sgabeblack@google.com 34212837Sgabeblack@google.comvoid 34312951Sgabeblack@google.comsc_module::next_trigger(double d, sc_time_unit u, const sc_event_or_list &eol) 34412837Sgabeblack@google.com{ 34512951Sgabeblack@google.com ::sc_core::next_trigger(d, u, eol); 34612837Sgabeblack@google.com} 34712837Sgabeblack@google.com 34812837Sgabeblack@google.comvoid 34912951Sgabeblack@google.comsc_module::next_trigger(const sc_time &t, const sc_event_and_list &eal) 35012837Sgabeblack@google.com{ 35112951Sgabeblack@google.com ::sc_core::next_trigger(t, eal); 35212837Sgabeblack@google.com} 35312837Sgabeblack@google.com 35412837Sgabeblack@google.comvoid 35512951Sgabeblack@google.comsc_module::next_trigger(double d, sc_time_unit u, const sc_event_and_list &eal) 35612837Sgabeblack@google.com{ 35712951Sgabeblack@google.com ::sc_core::next_trigger(d, u, eal); 35812837Sgabeblack@google.com} 35912837Sgabeblack@google.com 36012837Sgabeblack@google.com 36112929Sgabeblack@google.combool 36212929Sgabeblack@google.comsc_module::timed_out() 36312929Sgabeblack@google.com{ 36412929Sgabeblack@google.com warn("%s not implemented.\n", __PRETTY_FUNCTION__); 36512929Sgabeblack@google.com return false; 36612929Sgabeblack@google.com} 36712929Sgabeblack@google.com 36812929Sgabeblack@google.com 36912837Sgabeblack@google.comvoid 37012837Sgabeblack@google.comsc_module::wait() 37112837Sgabeblack@google.com{ 37212951Sgabeblack@google.com ::sc_core::wait(); 37312837Sgabeblack@google.com} 37412837Sgabeblack@google.com 37512837Sgabeblack@google.comvoid 37612951Sgabeblack@google.comsc_module::wait(int i) 37712837Sgabeblack@google.com{ 37812951Sgabeblack@google.com ::sc_core::wait(i); 37912837Sgabeblack@google.com} 38012837Sgabeblack@google.com 38112837Sgabeblack@google.comvoid 38212951Sgabeblack@google.comsc_module::wait(const sc_event &e) 38312837Sgabeblack@google.com{ 38412951Sgabeblack@google.com ::sc_core::wait(e); 38512837Sgabeblack@google.com} 38612837Sgabeblack@google.com 38712837Sgabeblack@google.comvoid 38812951Sgabeblack@google.comsc_module::wait(const sc_event_or_list &eol) 38912837Sgabeblack@google.com{ 39012951Sgabeblack@google.com ::sc_core::wait(eol); 39112837Sgabeblack@google.com} 39212837Sgabeblack@google.com 39312837Sgabeblack@google.comvoid 39412951Sgabeblack@google.comsc_module::wait(const sc_event_and_list &eal) 39512837Sgabeblack@google.com{ 39612951Sgabeblack@google.com ::sc_core::wait(eal); 39712837Sgabeblack@google.com} 39812837Sgabeblack@google.com 39912837Sgabeblack@google.comvoid 40012951Sgabeblack@google.comsc_module::wait(const sc_time &t) 40112837Sgabeblack@google.com{ 40212951Sgabeblack@google.com ::sc_core::wait(t); 40312837Sgabeblack@google.com} 40412837Sgabeblack@google.com 40512837Sgabeblack@google.comvoid 40612951Sgabeblack@google.comsc_module::wait(double d, sc_time_unit u) 40712837Sgabeblack@google.com{ 40812951Sgabeblack@google.com ::sc_core::wait(d, u); 40912837Sgabeblack@google.com} 41012837Sgabeblack@google.com 41112837Sgabeblack@google.comvoid 41212951Sgabeblack@google.comsc_module::wait(const sc_time &t, const sc_event &e) 41312837Sgabeblack@google.com{ 41412951Sgabeblack@google.com ::sc_core::wait(t, e); 41512837Sgabeblack@google.com} 41612837Sgabeblack@google.com 41712837Sgabeblack@google.comvoid 41812951Sgabeblack@google.comsc_module::wait(double d, sc_time_unit u, const sc_event &e) 41912837Sgabeblack@google.com{ 42012951Sgabeblack@google.com ::sc_core::wait(d, u, e); 42112837Sgabeblack@google.com} 42212837Sgabeblack@google.com 42312837Sgabeblack@google.comvoid 42412951Sgabeblack@google.comsc_module::wait(const sc_time &t, const sc_event_or_list &eol) 42512837Sgabeblack@google.com{ 42612951Sgabeblack@google.com ::sc_core::wait(t, eol); 42712837Sgabeblack@google.com} 42812837Sgabeblack@google.com 42912837Sgabeblack@google.comvoid 43012951Sgabeblack@google.comsc_module::wait(double d, sc_time_unit u, const sc_event_or_list &eol) 43112837Sgabeblack@google.com{ 43212951Sgabeblack@google.com ::sc_core::wait(d, u, eol); 43312837Sgabeblack@google.com} 43412837Sgabeblack@google.com 43512837Sgabeblack@google.comvoid 43612951Sgabeblack@google.comsc_module::wait(const sc_time &t, const sc_event_and_list &eal) 43712837Sgabeblack@google.com{ 43812951Sgabeblack@google.com ::sc_core::wait(t, eal); 43912837Sgabeblack@google.com} 44012837Sgabeblack@google.com 44112837Sgabeblack@google.comvoid 44212951Sgabeblack@google.comsc_module::wait(double d, sc_time_unit u, const sc_event_and_list &eal) 44312837Sgabeblack@google.com{ 44412951Sgabeblack@google.com ::sc_core::wait(d, u, eal); 44512837Sgabeblack@google.com} 44612837Sgabeblack@google.com 44712837Sgabeblack@google.com 44812837Sgabeblack@google.comvoid 44912909Sgabeblack@google.comsc_module::halt() 45012909Sgabeblack@google.com{ 45112951Sgabeblack@google.com ::sc_core::halt(); 45212909Sgabeblack@google.com} 45312909Sgabeblack@google.com 45412914Sgabeblack@google.comvoid 45512951Sgabeblack@google.comsc_module::at_posedge(const sc_signal_in_if<bool> &s) 45612914Sgabeblack@google.com{ 45712951Sgabeblack@google.com ::sc_core::at_posedge(s); 45812914Sgabeblack@google.com} 45912914Sgabeblack@google.com 46012914Sgabeblack@google.comvoid 46112951Sgabeblack@google.comsc_module::at_posedge(const sc_signal_in_if<sc_dt::sc_logic> &s) 46212914Sgabeblack@google.com{ 46312951Sgabeblack@google.com ::sc_core::at_posedge(s); 46412914Sgabeblack@google.com} 46512914Sgabeblack@google.com 46612914Sgabeblack@google.comvoid 46712951Sgabeblack@google.comsc_module::at_negedge(const sc_signal_in_if<bool> &s) 46812914Sgabeblack@google.com{ 46912951Sgabeblack@google.com ::sc_core::at_negedge(s); 47012914Sgabeblack@google.com} 47112914Sgabeblack@google.com 47212914Sgabeblack@google.comvoid 47312951Sgabeblack@google.comsc_module::at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &s) 47412914Sgabeblack@google.com{ 47512951Sgabeblack@google.com ::sc_core::at_negedge(s); 47612914Sgabeblack@google.com} 47712914Sgabeblack@google.com 47812909Sgabeblack@google.com 47912909Sgabeblack@google.comvoid 48012837Sgabeblack@google.comnext_trigger() 48112837Sgabeblack@google.com{ 48212958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 48312958Sgabeblack@google.com p->setDynamic(nullptr); 48412837Sgabeblack@google.com} 48512837Sgabeblack@google.com 48612837Sgabeblack@google.comvoid 48712958Sgabeblack@google.comnext_trigger(const sc_event &e) 48812837Sgabeblack@google.com{ 48912958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 49012958Sgabeblack@google.com p->setDynamic(new ::sc_gem5::SensitivityEvent(p, &e)); 49112837Sgabeblack@google.com} 49212837Sgabeblack@google.com 49312837Sgabeblack@google.comvoid 49412958Sgabeblack@google.comnext_trigger(const sc_event_or_list &eol) 49512837Sgabeblack@google.com{ 49612958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 49712958Sgabeblack@google.com p->setDynamic(new ::sc_gem5::SensitivityEventOrList(p, &eol)); 49812837Sgabeblack@google.com} 49912837Sgabeblack@google.com 50012837Sgabeblack@google.comvoid 50112958Sgabeblack@google.comnext_trigger(const sc_event_and_list &eal) 50212837Sgabeblack@google.com{ 50312958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 50412958Sgabeblack@google.com p->setDynamic(new ::sc_gem5::SensitivityEventAndList(p, &eal)); 50512837Sgabeblack@google.com} 50612837Sgabeblack@google.com 50712837Sgabeblack@google.comvoid 50812958Sgabeblack@google.comnext_trigger(const sc_time &t) 50912837Sgabeblack@google.com{ 51012958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 51112958Sgabeblack@google.com p->setDynamic(new ::sc_gem5::SensitivityTimeout(p, t)); 51212837Sgabeblack@google.com} 51312837Sgabeblack@google.com 51412837Sgabeblack@google.comvoid 51512951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u) 51612837Sgabeblack@google.com{ 51712951Sgabeblack@google.com next_trigger(sc_time(d, u)); 51812837Sgabeblack@google.com} 51912837Sgabeblack@google.com 52012837Sgabeblack@google.comvoid 52112958Sgabeblack@google.comnext_trigger(const sc_time &t, const sc_event &e) 52212837Sgabeblack@google.com{ 52312958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 52412958Sgabeblack@google.com p->setDynamic(new ::sc_gem5::SensitivityTimeoutAndEvent(p, t, &e)); 52512837Sgabeblack@google.com} 52612837Sgabeblack@google.com 52712837Sgabeblack@google.comvoid 52812951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u, const sc_event &e) 52912837Sgabeblack@google.com{ 53012951Sgabeblack@google.com next_trigger(sc_time(d, u), e); 53112837Sgabeblack@google.com} 53212837Sgabeblack@google.com 53312837Sgabeblack@google.comvoid 53412958Sgabeblack@google.comnext_trigger(const sc_time &t, const sc_event_or_list &eol) 53512837Sgabeblack@google.com{ 53612958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 53712958Sgabeblack@google.com p->setDynamic( 53812958Sgabeblack@google.com new ::sc_gem5::SensitivityTimeoutAndEventOrList(p, t, &eol)); 53912837Sgabeblack@google.com} 54012837Sgabeblack@google.com 54112837Sgabeblack@google.comvoid 54212951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u, const sc_event_or_list &eol) 54312837Sgabeblack@google.com{ 54412951Sgabeblack@google.com next_trigger(sc_time(d, u), eol); 54512837Sgabeblack@google.com} 54612837Sgabeblack@google.com 54712837Sgabeblack@google.comvoid 54812958Sgabeblack@google.comnext_trigger(const sc_time &t, const sc_event_and_list &eal) 54912837Sgabeblack@google.com{ 55012958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 55112958Sgabeblack@google.com p->setDynamic( 55212958Sgabeblack@google.com new ::sc_gem5::SensitivityTimeoutAndEventAndList(p, t, &eal)); 55312837Sgabeblack@google.com} 55412837Sgabeblack@google.com 55512837Sgabeblack@google.comvoid 55612951Sgabeblack@google.comnext_trigger(double d, sc_time_unit u, const sc_event_and_list &eal) 55712837Sgabeblack@google.com{ 55812951Sgabeblack@google.com next_trigger(sc_time(d, u), eal); 55912837Sgabeblack@google.com} 56012837Sgabeblack@google.com 56112929Sgabeblack@google.combool 56212929Sgabeblack@google.comtimed_out() 56312929Sgabeblack@google.com{ 56412929Sgabeblack@google.com warn("%s not implemented.\n", __PRETTY_FUNCTION__); 56512929Sgabeblack@google.com return false; 56612929Sgabeblack@google.com} 56712929Sgabeblack@google.com 56812837Sgabeblack@google.com 56912837Sgabeblack@google.comvoid 57012837Sgabeblack@google.comwait() 57112837Sgabeblack@google.com{ 57212958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 57312958Sgabeblack@google.com p->setDynamic(nullptr); 57412958Sgabeblack@google.com sc_gem5::scheduler.yield(); 57512837Sgabeblack@google.com} 57612837Sgabeblack@google.com 57712837Sgabeblack@google.comvoid 57812958Sgabeblack@google.comwait(int n) 57912837Sgabeblack@google.com{ 58013146Sgabeblack@google.com if (n <= 0) { 58113146Sgabeblack@google.com std::string msg = csprintf("n = %d", n); 58213146Sgabeblack@google.com SC_REPORT_ERROR("(E525) wait(n) is only valid for n > 0", msg.c_str()); 58313146Sgabeblack@google.com } 58412958Sgabeblack@google.com for (int i = 0; i < n; i++) 58512958Sgabeblack@google.com wait(); 58612837Sgabeblack@google.com} 58712837Sgabeblack@google.com 58812837Sgabeblack@google.comvoid 58912958Sgabeblack@google.comwait(const sc_event &e) 59012837Sgabeblack@google.com{ 59112958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 59212958Sgabeblack@google.com p->setDynamic(new ::sc_gem5::SensitivityEvent(p, &e)); 59312958Sgabeblack@google.com sc_gem5::scheduler.yield(); 59412837Sgabeblack@google.com} 59512837Sgabeblack@google.com 59612837Sgabeblack@google.comvoid 59712958Sgabeblack@google.comwait(const sc_event_or_list &eol) 59812837Sgabeblack@google.com{ 59912958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 60012958Sgabeblack@google.com p->setDynamic(new ::sc_gem5::SensitivityEventOrList(p, &eol)); 60112958Sgabeblack@google.com sc_gem5::scheduler.yield(); 60212837Sgabeblack@google.com} 60312837Sgabeblack@google.com 60412837Sgabeblack@google.comvoid 60512958Sgabeblack@google.comwait(const sc_event_and_list &eal) 60612837Sgabeblack@google.com{ 60712958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 60812958Sgabeblack@google.com p->setDynamic(new ::sc_gem5::SensitivityEventAndList(p, &eal)); 60912958Sgabeblack@google.com sc_gem5::scheduler.yield(); 61012837Sgabeblack@google.com} 61112837Sgabeblack@google.com 61212837Sgabeblack@google.comvoid 61312958Sgabeblack@google.comwait(const sc_time &t) 61412837Sgabeblack@google.com{ 61512958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 61612958Sgabeblack@google.com p->setDynamic(new ::sc_gem5::SensitivityTimeout(p, t)); 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) 62212837Sgabeblack@google.com{ 62312951Sgabeblack@google.com wait(sc_time(d, u)); 62412837Sgabeblack@google.com} 62512837Sgabeblack@google.com 62612837Sgabeblack@google.comvoid 62712958Sgabeblack@google.comwait(const sc_time &t, const sc_event &e) 62812837Sgabeblack@google.com{ 62912958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 63012958Sgabeblack@google.com p->setDynamic(new ::sc_gem5::SensitivityTimeoutAndEvent(p, t, &e)); 63112958Sgabeblack@google.com sc_gem5::scheduler.yield(); 63212837Sgabeblack@google.com} 63312837Sgabeblack@google.com 63412837Sgabeblack@google.comvoid 63512951Sgabeblack@google.comwait(double d, sc_time_unit u, const sc_event &e) 63612837Sgabeblack@google.com{ 63712951Sgabeblack@google.com wait(sc_time(d, u), e); 63812837Sgabeblack@google.com} 63912837Sgabeblack@google.com 64012837Sgabeblack@google.comvoid 64112958Sgabeblack@google.comwait(const sc_time &t, const sc_event_or_list &eol) 64212837Sgabeblack@google.com{ 64312958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 64412958Sgabeblack@google.com p->setDynamic( 64512958Sgabeblack@google.com new ::sc_gem5::SensitivityTimeoutAndEventOrList(p, t, &eol)); 64612958Sgabeblack@google.com sc_gem5::scheduler.yield(); 64712837Sgabeblack@google.com} 64812837Sgabeblack@google.com 64912837Sgabeblack@google.comvoid 65012951Sgabeblack@google.comwait(double d, sc_time_unit u, const sc_event_or_list &eol) 65112837Sgabeblack@google.com{ 65212951Sgabeblack@google.com wait(sc_time(d, u), eol); 65312837Sgabeblack@google.com} 65412837Sgabeblack@google.com 65512837Sgabeblack@google.comvoid 65612958Sgabeblack@google.comwait(const sc_time &t, const sc_event_and_list &eal) 65712837Sgabeblack@google.com{ 65812958Sgabeblack@google.com sc_gem5::Process *p = sc_gem5::scheduler.current(); 65912958Sgabeblack@google.com p->setDynamic( 66012958Sgabeblack@google.com new ::sc_gem5::SensitivityTimeoutAndEventAndList(p, t, &eal)); 66112958Sgabeblack@google.com sc_gem5::scheduler.yield(); 66212837Sgabeblack@google.com} 66312837Sgabeblack@google.com 66412837Sgabeblack@google.comvoid 66512951Sgabeblack@google.comwait(double d, sc_time_unit u, const sc_event_and_list &eal) 66612837Sgabeblack@google.com{ 66712951Sgabeblack@google.com wait(sc_time(d, u), eal); 66812837Sgabeblack@google.com} 66912837Sgabeblack@google.com 67012909Sgabeblack@google.comvoid 67112909Sgabeblack@google.comhalt() 67212909Sgabeblack@google.com{ 67313175Sgabeblack@google.com ::sc_core::wait(); 67413175Sgabeblack@google.com throw ::sc_gem5::ScHalt(); 67512909Sgabeblack@google.com} 67612909Sgabeblack@google.com 67712914Sgabeblack@google.comvoid 67813155Sgabeblack@google.comat_posedge(const sc_signal_in_if<bool> &s) 67912914Sgabeblack@google.com{ 68013155Sgabeblack@google.com while (s.read()) 68113155Sgabeblack@google.com wait(); 68213155Sgabeblack@google.com while (!s.read()) 68313155Sgabeblack@google.com wait(); 68412914Sgabeblack@google.com} 68512914Sgabeblack@google.com 68612914Sgabeblack@google.comvoid 68713155Sgabeblack@google.comat_posedge(const sc_signal_in_if<sc_dt::sc_logic> &s) 68812914Sgabeblack@google.com{ 68913155Sgabeblack@google.com while (s.read() == sc_dt::Log_1) 69013155Sgabeblack@google.com wait(); 69113155Sgabeblack@google.com while (s.read() == sc_dt::Log_0) 69213155Sgabeblack@google.com wait(); 69312914Sgabeblack@google.com} 69412914Sgabeblack@google.com 69512914Sgabeblack@google.comvoid 69613155Sgabeblack@google.comat_negedge(const sc_signal_in_if<bool> &s) 69712914Sgabeblack@google.com{ 69813155Sgabeblack@google.com while (!s.read()) 69913155Sgabeblack@google.com wait(); 70013155Sgabeblack@google.com while (s.read()) 70113155Sgabeblack@google.com wait(); 70212914Sgabeblack@google.com} 70312914Sgabeblack@google.com 70412914Sgabeblack@google.comvoid 70513155Sgabeblack@google.comat_negedge(const sc_signal_in_if<sc_dt::sc_logic> &s) 70612914Sgabeblack@google.com{ 70713155Sgabeblack@google.com while (s.read() == sc_dt::Log_0) 70813155Sgabeblack@google.com wait(); 70913155Sgabeblack@google.com while (s.read() == sc_dt::Log_1) 71013155Sgabeblack@google.com wait(); 71112914Sgabeblack@google.com} 71212914Sgabeblack@google.com 71312837Sgabeblack@google.comconst char * 71413035Sgabeblack@google.comsc_gen_unique_name(const char *seed) 71512837Sgabeblack@google.com{ 71613035Sgabeblack@google.com ::sc_gem5::Module *mod = ::sc_gem5::currentModule(); 71713035Sgabeblack@google.com return mod ? mod->uniqueName(seed) : 71813035Sgabeblack@google.com ::sc_gem5::nameGen.gen(seed); 71912837Sgabeblack@google.com} 72012837Sgabeblack@google.com 72112837Sgabeblack@google.combool 72212930Sgabeblack@google.comsc_hierarchical_name_exists(const char *name) 72312930Sgabeblack@google.com{ 72412930Sgabeblack@google.com warn("%s not implemented.\n", __PRETTY_FUNCTION__); 72512930Sgabeblack@google.com return false; 72612930Sgabeblack@google.com} 72712930Sgabeblack@google.com 72812930Sgabeblack@google.combool 72912837Sgabeblack@google.comsc_start_of_simulation_invoked() 73012837Sgabeblack@google.com{ 73112982Sgabeblack@google.com return ::sc_gem5::kernel->startOfSimulationComplete(); 73212837Sgabeblack@google.com} 73312837Sgabeblack@google.com 73412837Sgabeblack@google.combool 73512837Sgabeblack@google.comsc_end_of_simulation_invoked() 73612837Sgabeblack@google.com{ 73712982Sgabeblack@google.com return ::sc_gem5::kernel->endOfSimulationComplete(); 73812837Sgabeblack@google.com} 73912837Sgabeblack@google.com 74012901Sgabeblack@google.comsc_module * 74112901Sgabeblack@google.comsc_module_sc_new(sc_module *mod) 74212901Sgabeblack@google.com{ 74312901Sgabeblack@google.com static std::vector<std::unique_ptr<sc_module> > modules; 74412901Sgabeblack@google.com modules.emplace_back(mod); 74512901Sgabeblack@google.com return mod; 74612901Sgabeblack@google.com} 74712901Sgabeblack@google.com 74812837Sgabeblack@google.com} // namespace sc_core 749