sc_module.hh revision 13785
112837Sgabeblack@google.com/* 212837Sgabeblack@google.com * Copyright 2018 Google, Inc. 312837Sgabeblack@google.com * 412837Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 512837Sgabeblack@google.com * modification, are permitted provided that the following conditions are 612837Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 712837Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 812837Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 912837Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 1012837Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 1112837Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 1212837Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 1312837Sgabeblack@google.com * this software without specific prior written permission. 1412837Sgabeblack@google.com * 1512837Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1612837Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1712837Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1812837Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1912837Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2012837Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2112837Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2212837Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2312837Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2412837Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2512837Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2612837Sgabeblack@google.com * 2712837Sgabeblack@google.com * Authors: Gabe Black 2812837Sgabeblack@google.com */ 2912837Sgabeblack@google.com 3012837Sgabeblack@google.com#ifndef __SYSTEMC_CORE_EXT_SC_MODULE_HH__ 3112837Sgabeblack@google.com#define __SYSTEMC_CORE_EXT_SC_MODULE_HH__ 3212837Sgabeblack@google.com 3313785Sgabeblack@google.com#include <string> 3412837Sgabeblack@google.com#include <vector> 3512837Sgabeblack@google.com 3612837Sgabeblack@google.com#include "sc_object.hh" 3713087Sgabeblack@google.com#include "sc_process_handle.hh" 3812837Sgabeblack@google.com#include "sc_sensitive.hh" 3912837Sgabeblack@google.com#include "sc_time.hh" 4012837Sgabeblack@google.com 4112914Sgabeblack@google.comnamespace sc_dt 4212914Sgabeblack@google.com{ 4312914Sgabeblack@google.com 4412914Sgabeblack@google.comclass sc_logic; 4512914Sgabeblack@google.com 4612914Sgabeblack@google.com} // namespace sc_dt 4712914Sgabeblack@google.com 4812951Sgabeblack@google.comnamespace sc_gem5 4912951Sgabeblack@google.com{ 5012951Sgabeblack@google.com 5112982Sgabeblack@google.comclass Kernel; 5212951Sgabeblack@google.comclass Module; 5312952Sgabeblack@google.comclass Process; 5412952Sgabeblack@google.comstruct ProcessFuncWrapper; 5512952Sgabeblack@google.com 5612952Sgabeblack@google.comProcess *newMethodProcess(const char *name, ProcessFuncWrapper *func); 5712952Sgabeblack@google.comProcess *newThreadProcess(const char *name, ProcessFuncWrapper *func); 5812952Sgabeblack@google.comProcess *newCThreadProcess(const char *name, ProcessFuncWrapper *func); 5912951Sgabeblack@google.com 6012951Sgabeblack@google.com} // namespace sc_gem5 6112951Sgabeblack@google.com 6213785Sgabeblack@google.com// Gem5 prototype 6313785Sgabeblack@google.comclass Port; 6413785Sgabeblack@google.com 6512837Sgabeblack@google.comnamespace sc_core 6612837Sgabeblack@google.com{ 6712837Sgabeblack@google.com 6812837Sgabeblack@google.comtemplate <class T> 6912837Sgabeblack@google.comclass sc_in; 7012837Sgabeblack@google.comtemplate <class T> 7112837Sgabeblack@google.comclass sc_out; 7212837Sgabeblack@google.comtemplate <class T> 7312837Sgabeblack@google.comclass sc_inout; 7412837Sgabeblack@google.comtemplate <class T> 7512837Sgabeblack@google.comclass sc_signal_in_if; 7612837Sgabeblack@google.com 7712837Sgabeblack@google.comclass sc_event; 7812837Sgabeblack@google.comclass sc_event_and_list; 7912837Sgabeblack@google.comclass sc_event_or_list; 8012837Sgabeblack@google.comclass sc_module_name; 8112837Sgabeblack@google.com 8212837Sgabeblack@google.comclass sc_bind_proxy 8312837Sgabeblack@google.com{ 8412951Sgabeblack@google.com private: 8513091Sgabeblack@google.com sc_interface *_interface; 8613091Sgabeblack@google.com sc_port_base *_port; 8712951Sgabeblack@google.com 8812837Sgabeblack@google.com public: 8913382Sgabeblack@google.com sc_bind_proxy(); 9013091Sgabeblack@google.com sc_bind_proxy(sc_interface &_interface); 9113091Sgabeblack@google.com sc_bind_proxy(sc_port_base &_port); 9213091Sgabeblack@google.com 9313091Sgabeblack@google.com sc_interface *interface() const { return _interface; } 9413091Sgabeblack@google.com sc_port_base *port() const { return _port; } 9512837Sgabeblack@google.com}; 9612837Sgabeblack@google.com 9712837Sgabeblack@google.comextern const sc_bind_proxy SC_BIND_PROXY_NIL; 9812837Sgabeblack@google.com 9912837Sgabeblack@google.comclass sc_module : public sc_object 10012837Sgabeblack@google.com{ 10112837Sgabeblack@google.com public: 10213785Sgabeblack@google.com // Gem5 specific extensions 10313785Sgabeblack@google.com virtual ::Port &gem5_getPort(const std::string &if_name, int idx=-1); 10413785Sgabeblack@google.com 10513785Sgabeblack@google.com public: 10612982Sgabeblack@google.com friend class ::sc_gem5::Kernel; 10713191Sgabeblack@google.com friend class ::sc_gem5::Module; 10812982Sgabeblack@google.com 10912837Sgabeblack@google.com virtual ~sc_module(); 11012837Sgabeblack@google.com 11112951Sgabeblack@google.com virtual const char *kind() const { return "sc_module"; } 11212837Sgabeblack@google.com 11312837Sgabeblack@google.com void operator () (const sc_bind_proxy &p001, 11412837Sgabeblack@google.com const sc_bind_proxy &p002 = SC_BIND_PROXY_NIL, 11512837Sgabeblack@google.com const sc_bind_proxy &p003 = SC_BIND_PROXY_NIL, 11612837Sgabeblack@google.com const sc_bind_proxy &p004 = SC_BIND_PROXY_NIL, 11712837Sgabeblack@google.com const sc_bind_proxy &p005 = SC_BIND_PROXY_NIL, 11812837Sgabeblack@google.com const sc_bind_proxy &p006 = SC_BIND_PROXY_NIL, 11912837Sgabeblack@google.com const sc_bind_proxy &p007 = SC_BIND_PROXY_NIL, 12012837Sgabeblack@google.com const sc_bind_proxy &p008 = SC_BIND_PROXY_NIL, 12112837Sgabeblack@google.com const sc_bind_proxy &p009 = SC_BIND_PROXY_NIL, 12212837Sgabeblack@google.com const sc_bind_proxy &p010 = SC_BIND_PROXY_NIL, 12312837Sgabeblack@google.com const sc_bind_proxy &p011 = SC_BIND_PROXY_NIL, 12412837Sgabeblack@google.com const sc_bind_proxy &p012 = SC_BIND_PROXY_NIL, 12512837Sgabeblack@google.com const sc_bind_proxy &p013 = SC_BIND_PROXY_NIL, 12612837Sgabeblack@google.com const sc_bind_proxy &p014 = SC_BIND_PROXY_NIL, 12712837Sgabeblack@google.com const sc_bind_proxy &p015 = SC_BIND_PROXY_NIL, 12812837Sgabeblack@google.com const sc_bind_proxy &p016 = SC_BIND_PROXY_NIL, 12912837Sgabeblack@google.com const sc_bind_proxy &p017 = SC_BIND_PROXY_NIL, 13012837Sgabeblack@google.com const sc_bind_proxy &p018 = SC_BIND_PROXY_NIL, 13112837Sgabeblack@google.com const sc_bind_proxy &p019 = SC_BIND_PROXY_NIL, 13212837Sgabeblack@google.com const sc_bind_proxy &p020 = SC_BIND_PROXY_NIL, 13312837Sgabeblack@google.com const sc_bind_proxy &p021 = SC_BIND_PROXY_NIL, 13412837Sgabeblack@google.com const sc_bind_proxy &p022 = SC_BIND_PROXY_NIL, 13512837Sgabeblack@google.com const sc_bind_proxy &p023 = SC_BIND_PROXY_NIL, 13612837Sgabeblack@google.com const sc_bind_proxy &p024 = SC_BIND_PROXY_NIL, 13712837Sgabeblack@google.com const sc_bind_proxy &p025 = SC_BIND_PROXY_NIL, 13812837Sgabeblack@google.com const sc_bind_proxy &p026 = SC_BIND_PROXY_NIL, 13912837Sgabeblack@google.com const sc_bind_proxy &p027 = SC_BIND_PROXY_NIL, 14012837Sgabeblack@google.com const sc_bind_proxy &p028 = SC_BIND_PROXY_NIL, 14112837Sgabeblack@google.com const sc_bind_proxy &p029 = SC_BIND_PROXY_NIL, 14212837Sgabeblack@google.com const sc_bind_proxy &p030 = SC_BIND_PROXY_NIL, 14312837Sgabeblack@google.com const sc_bind_proxy &p031 = SC_BIND_PROXY_NIL, 14412837Sgabeblack@google.com const sc_bind_proxy &p032 = SC_BIND_PROXY_NIL, 14512837Sgabeblack@google.com const sc_bind_proxy &p033 = SC_BIND_PROXY_NIL, 14612837Sgabeblack@google.com const sc_bind_proxy &p034 = SC_BIND_PROXY_NIL, 14712837Sgabeblack@google.com const sc_bind_proxy &p035 = SC_BIND_PROXY_NIL, 14812837Sgabeblack@google.com const sc_bind_proxy &p036 = SC_BIND_PROXY_NIL, 14912837Sgabeblack@google.com const sc_bind_proxy &p037 = SC_BIND_PROXY_NIL, 15012837Sgabeblack@google.com const sc_bind_proxy &p038 = SC_BIND_PROXY_NIL, 15112837Sgabeblack@google.com const sc_bind_proxy &p039 = SC_BIND_PROXY_NIL, 15212837Sgabeblack@google.com const sc_bind_proxy &p040 = SC_BIND_PROXY_NIL, 15312837Sgabeblack@google.com const sc_bind_proxy &p041 = SC_BIND_PROXY_NIL, 15412837Sgabeblack@google.com const sc_bind_proxy &p042 = SC_BIND_PROXY_NIL, 15512837Sgabeblack@google.com const sc_bind_proxy &p043 = SC_BIND_PROXY_NIL, 15612837Sgabeblack@google.com const sc_bind_proxy &p044 = SC_BIND_PROXY_NIL, 15712837Sgabeblack@google.com const sc_bind_proxy &p045 = SC_BIND_PROXY_NIL, 15812837Sgabeblack@google.com const sc_bind_proxy &p046 = SC_BIND_PROXY_NIL, 15912837Sgabeblack@google.com const sc_bind_proxy &p047 = SC_BIND_PROXY_NIL, 16012837Sgabeblack@google.com const sc_bind_proxy &p048 = SC_BIND_PROXY_NIL, 16112837Sgabeblack@google.com const sc_bind_proxy &p049 = SC_BIND_PROXY_NIL, 16212837Sgabeblack@google.com const sc_bind_proxy &p050 = SC_BIND_PROXY_NIL, 16312837Sgabeblack@google.com const sc_bind_proxy &p051 = SC_BIND_PROXY_NIL, 16412837Sgabeblack@google.com const sc_bind_proxy &p052 = SC_BIND_PROXY_NIL, 16512837Sgabeblack@google.com const sc_bind_proxy &p053 = SC_BIND_PROXY_NIL, 16612837Sgabeblack@google.com const sc_bind_proxy &p054 = SC_BIND_PROXY_NIL, 16712837Sgabeblack@google.com const sc_bind_proxy &p055 = SC_BIND_PROXY_NIL, 16812837Sgabeblack@google.com const sc_bind_proxy &p056 = SC_BIND_PROXY_NIL, 16912837Sgabeblack@google.com const sc_bind_proxy &p057 = SC_BIND_PROXY_NIL, 17012837Sgabeblack@google.com const sc_bind_proxy &p058 = SC_BIND_PROXY_NIL, 17112837Sgabeblack@google.com const sc_bind_proxy &p059 = SC_BIND_PROXY_NIL, 17212837Sgabeblack@google.com const sc_bind_proxy &p060 = SC_BIND_PROXY_NIL, 17312837Sgabeblack@google.com const sc_bind_proxy &p061 = SC_BIND_PROXY_NIL, 17412837Sgabeblack@google.com const sc_bind_proxy &p062 = SC_BIND_PROXY_NIL, 17512837Sgabeblack@google.com const sc_bind_proxy &p063 = SC_BIND_PROXY_NIL, 17612837Sgabeblack@google.com const sc_bind_proxy &p064 = SC_BIND_PROXY_NIL); 17712837Sgabeblack@google.com 17813292Sgabeblack@google.com // Deprecated 17913292Sgabeblack@google.com sc_module &operator << (sc_interface &); 18013292Sgabeblack@google.com sc_module &operator << (sc_port_base &); 18113292Sgabeblack@google.com sc_module &operator , (sc_interface &); 18213292Sgabeblack@google.com sc_module &operator , (sc_port_base &); 18313292Sgabeblack@google.com 18412837Sgabeblack@google.com virtual const std::vector<sc_object *> &get_child_objects() const; 18512837Sgabeblack@google.com virtual const std::vector<sc_event *> &get_child_events() const; 18612837Sgabeblack@google.com 18712837Sgabeblack@google.com protected: 18812837Sgabeblack@google.com sc_module(const sc_module_name &); 18912837Sgabeblack@google.com sc_module(); 19012837Sgabeblack@google.com 19112928Sgabeblack@google.com // Deprecated 19212928Sgabeblack@google.com sc_module(const char *); 19312928Sgabeblack@google.com sc_module(const std::string &); 19412928Sgabeblack@google.com 19512864Sgabeblack@google.com /* Deprecated, but used in the regression tests. */ 19613191Sgabeblack@google.com void end_module(); 19712864Sgabeblack@google.com 19812837Sgabeblack@google.com void reset_signal_is(const sc_in<bool> &, bool); 19912837Sgabeblack@google.com void reset_signal_is(const sc_inout<bool> &, bool); 20012837Sgabeblack@google.com void reset_signal_is(const sc_out<bool> &, bool); 20112837Sgabeblack@google.com void reset_signal_is(const sc_signal_in_if<bool> &, bool); 20212837Sgabeblack@google.com 20312837Sgabeblack@google.com void async_reset_signal_is(const sc_in<bool> &, bool); 20412837Sgabeblack@google.com void async_reset_signal_is(const sc_inout<bool> &, bool); 20512837Sgabeblack@google.com void async_reset_signal_is(const sc_out<bool> &, bool); 20612837Sgabeblack@google.com void async_reset_signal_is(const sc_signal_in_if<bool> &, bool); 20712837Sgabeblack@google.com 20812837Sgabeblack@google.com sc_sensitive sensitive; 20912837Sgabeblack@google.com 21012837Sgabeblack@google.com void dont_initialize(); 21112837Sgabeblack@google.com void set_stack_size(size_t); 21212837Sgabeblack@google.com 21312837Sgabeblack@google.com void next_trigger(); 21412837Sgabeblack@google.com void next_trigger(const sc_event &); 21512837Sgabeblack@google.com void next_trigger(const sc_event_or_list &); 21612837Sgabeblack@google.com void next_trigger(const sc_event_and_list &); 21712837Sgabeblack@google.com void next_trigger(const sc_time &); 21812837Sgabeblack@google.com void next_trigger(double, sc_time_unit); 21912837Sgabeblack@google.com void next_trigger(const sc_time &, const sc_event &); 22012837Sgabeblack@google.com void next_trigger(double, sc_time_unit, const sc_event &); 22112837Sgabeblack@google.com void next_trigger(const sc_time &, const sc_event_or_list &); 22212837Sgabeblack@google.com void next_trigger(double, sc_time_unit, const sc_event_or_list &); 22312837Sgabeblack@google.com void next_trigger(const sc_time &, const sc_event_and_list &); 22412837Sgabeblack@google.com void next_trigger(double, sc_time_unit, const sc_event_and_list &); 22512837Sgabeblack@google.com 22612929Sgabeblack@google.com // Nonstandard 22712929Sgabeblack@google.com bool timed_out(); 22812929Sgabeblack@google.com 22912837Sgabeblack@google.com void wait(); 23012837Sgabeblack@google.com void wait(int); 23112837Sgabeblack@google.com void wait(const sc_event &); 23212837Sgabeblack@google.com void wait(const sc_event_or_list &); 23312837Sgabeblack@google.com void wait(const sc_event_and_list &); 23412837Sgabeblack@google.com void wait(const sc_time &); 23512837Sgabeblack@google.com void wait(double, sc_time_unit); 23612837Sgabeblack@google.com void wait(const sc_time &, const sc_event &); 23712837Sgabeblack@google.com void wait(double, sc_time_unit, const sc_event &); 23812837Sgabeblack@google.com void wait(const sc_time &, const sc_event_or_list &); 23912837Sgabeblack@google.com void wait(double, sc_time_unit, const sc_event_or_list &); 24012837Sgabeblack@google.com void wait(const sc_time &, const sc_event_and_list &); 24112837Sgabeblack@google.com void wait(double, sc_time_unit, const sc_event_and_list &); 24212837Sgabeblack@google.com 24312914Sgabeblack@google.com // Nonstandard 24412909Sgabeblack@google.com void halt(); 24512914Sgabeblack@google.com void at_posedge(const sc_signal_in_if<bool> &); 24612914Sgabeblack@google.com void at_posedge(const sc_signal_in_if<sc_dt::sc_logic> &); 24712914Sgabeblack@google.com void at_negedge(const sc_signal_in_if<bool> &); 24812914Sgabeblack@google.com void at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &); 24912909Sgabeblack@google.com 25012837Sgabeblack@google.com virtual void before_end_of_elaboration() {} 25112837Sgabeblack@google.com virtual void end_of_elaboration() {} 25212837Sgabeblack@google.com virtual void start_of_simulation() {} 25312837Sgabeblack@google.com virtual void end_of_simulation() {} 25412837Sgabeblack@google.com 25512837Sgabeblack@google.com private: 25612951Sgabeblack@google.com sc_gem5::Module *_gem5_module; 25712951Sgabeblack@google.com 25812837Sgabeblack@google.com // Disabled 25912837Sgabeblack@google.com sc_module(const sc_module &) : sc_object() {}; 26012837Sgabeblack@google.com sc_module &operator = (const sc_module &) { return *this; } 26112837Sgabeblack@google.com}; 26212837Sgabeblack@google.com 26312837Sgabeblack@google.comvoid next_trigger(); 26412837Sgabeblack@google.comvoid next_trigger(const sc_event &); 26512837Sgabeblack@google.comvoid next_trigger(const sc_event_or_list &); 26612837Sgabeblack@google.comvoid next_trigger(const sc_event_and_list &); 26712837Sgabeblack@google.comvoid next_trigger(const sc_time &); 26812837Sgabeblack@google.comvoid next_trigger(double, sc_time_unit); 26912837Sgabeblack@google.comvoid next_trigger(const sc_time &, const sc_event &); 27012837Sgabeblack@google.comvoid next_trigger(double, sc_time_unit, const sc_event &); 27112837Sgabeblack@google.comvoid next_trigger(const sc_time &, const sc_event_or_list &); 27212837Sgabeblack@google.comvoid next_trigger(double, sc_time_unit, const sc_event_or_list &); 27312837Sgabeblack@google.comvoid next_trigger(const sc_time &, const sc_event_and_list &); 27412837Sgabeblack@google.comvoid next_trigger(double, sc_time_unit, const sc_event_and_list &); 27512837Sgabeblack@google.com 27612837Sgabeblack@google.comvoid wait(); 27712837Sgabeblack@google.comvoid wait(int); 27812837Sgabeblack@google.comvoid wait(const sc_event &); 27912837Sgabeblack@google.comvoid wait(const sc_event_or_list &); 28012837Sgabeblack@google.comvoid wait(const sc_event_and_list &); 28112837Sgabeblack@google.comvoid wait(const sc_time &); 28212837Sgabeblack@google.comvoid wait(double, sc_time_unit); 28312837Sgabeblack@google.comvoid wait(const sc_time &, const sc_event &); 28412837Sgabeblack@google.comvoid wait(double, sc_time_unit, const sc_event &); 28512837Sgabeblack@google.comvoid wait(const sc_time &, const sc_event_or_list &); 28612837Sgabeblack@google.comvoid wait(double, sc_time_unit, const sc_event_or_list &); 28712837Sgabeblack@google.comvoid wait(const sc_time &, const sc_event_and_list &); 28812837Sgabeblack@google.comvoid wait(double, sc_time_unit, const sc_event_and_list &); 28912837Sgabeblack@google.com 29012929Sgabeblack@google.com// Nonstandard 29112929Sgabeblack@google.combool timed_out(); 29212929Sgabeblack@google.com 29312837Sgabeblack@google.com#define SC_MODULE(name) struct name : ::sc_core::sc_module 29412837Sgabeblack@google.com 29512837Sgabeblack@google.com#define SC_CTOR(name) \ 29612837Sgabeblack@google.com typedef name SC_CURRENT_USER_MODULE; \ 29712837Sgabeblack@google.com name(::sc_core::sc_module_name) 29812837Sgabeblack@google.com 29912837Sgabeblack@google.com#define SC_HAS_PROCESS(name) typedef name SC_CURRENT_USER_MODULE 30012837Sgabeblack@google.com 30112952Sgabeblack@google.com#define SC_METHOD(name) \ 30212952Sgabeblack@google.com { \ 30312952Sgabeblack@google.com ::sc_gem5::Process *p = \ 30412952Sgabeblack@google.com ::sc_gem5::newMethodProcess( \ 30512952Sgabeblack@google.com #name, new ::sc_gem5::ProcessMemberFuncWrapper< \ 30612952Sgabeblack@google.com SC_CURRENT_USER_MODULE>(this, \ 30712952Sgabeblack@google.com &SC_CURRENT_USER_MODULE::name)); \ 30813135Sgabeblack@google.com if (p) \ 30913135Sgabeblack@google.com this->sensitive << p; \ 31012952Sgabeblack@google.com } 31112952Sgabeblack@google.com#define SC_THREAD(name) \ 31212952Sgabeblack@google.com { \ 31312952Sgabeblack@google.com ::sc_gem5::Process *p = \ 31412952Sgabeblack@google.com ::sc_gem5::newThreadProcess( \ 31512952Sgabeblack@google.com #name, new ::sc_gem5::ProcessMemberFuncWrapper< \ 31612952Sgabeblack@google.com SC_CURRENT_USER_MODULE>(this, \ 31712952Sgabeblack@google.com &SC_CURRENT_USER_MODULE::name)); \ 31813135Sgabeblack@google.com if (p) \ 31913135Sgabeblack@google.com this->sensitive << p; \ 32012952Sgabeblack@google.com } 32112952Sgabeblack@google.com#define SC_CTHREAD(name, clk) \ 32212952Sgabeblack@google.com { \ 32312952Sgabeblack@google.com ::sc_gem5::Process *p = \ 32412952Sgabeblack@google.com ::sc_gem5::newCThreadProcess( \ 32512952Sgabeblack@google.com #name, new ::sc_gem5::ProcessMemberFuncWrapper< \ 32612952Sgabeblack@google.com SC_CURRENT_USER_MODULE>(this, \ 32712952Sgabeblack@google.com &SC_CURRENT_USER_MODULE::name)); \ 32813210Sgabeblack@google.com if (p) \ 32913210Sgabeblack@google.com this->sensitive(p, clk); \ 33012952Sgabeblack@google.com } 33112837Sgabeblack@google.com 33212909Sgabeblack@google.com// Nonstandard 33312909Sgabeblack@google.com// Documentation for this is very scarce, but it looks like it's supposed to 33412909Sgabeblack@google.com// stop the currently executing cthread, or if a cthread isn't running report 33512909Sgabeblack@google.com// an error. 33612909Sgabeblack@google.comvoid halt(); 33712914Sgabeblack@google.comvoid at_posedge(const sc_signal_in_if<bool> &); 33812914Sgabeblack@google.comvoid at_posedge(const sc_signal_in_if<sc_dt::sc_logic> &); 33912914Sgabeblack@google.comvoid at_negedge(const sc_signal_in_if<bool> &); 34012914Sgabeblack@google.comvoid at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &); 34112909Sgabeblack@google.com 34212837Sgabeblack@google.comconst char *sc_gen_unique_name(const char *); 34312837Sgabeblack@google.com 34412930Sgabeblack@google.com// Nonstandard 34512930Sgabeblack@google.combool sc_hierarchical_name_exists(const char *name); 34612930Sgabeblack@google.com 34712837Sgabeblack@google.comtypedef sc_module sc_behavior; 34812837Sgabeblack@google.comtypedef sc_module sc_channel; 34912837Sgabeblack@google.com 35012837Sgabeblack@google.combool sc_start_of_simulation_invoked(); 35112837Sgabeblack@google.combool sc_end_of_simulation_invoked(); 35212837Sgabeblack@google.com 35312901Sgabeblack@google.com// Nonstandard 35412901Sgabeblack@google.com// Allocates a module of type x and records a pointer to it so that it gets 35512901Sgabeblack@google.com// destructed automatically at the end of the simulation. 35612901Sgabeblack@google.comsc_module *sc_module_sc_new(sc_module *); 35712901Sgabeblack@google.com#define SC_NEW(x) ::sc_core::sc_module_sc_new(new x); 35812901Sgabeblack@google.com 35912907Sgabeblack@google.com// Nonstandard 36013087Sgabeblack@google.com#define SC_WAIT() \ 36113087Sgabeblack@google.com ::sc_core::sc_set_location(__FILE__, __LINE__); \ 36213087Sgabeblack@google.com ::sc_core::wait(); \ 36313087Sgabeblack@google.com ::sc_core::sc_set_location(NULL, 0) 36412907Sgabeblack@google.com 36512907Sgabeblack@google.com// Nonstandard 36613087Sgabeblack@google.com#define SC_WAITN(n) \ 36713087Sgabeblack@google.com ::sc_core::sc_set_location(__FILE__, __LINE__); \ 36813087Sgabeblack@google.com ::sc_core::wait(n); \ 36913087Sgabeblack@google.com ::sc_core::sc_set_location(NULL, 0) 37012907Sgabeblack@google.com 37112907Sgabeblack@google.com// Nonstandard 37213087Sgabeblack@google.com#define SC_WAIT_UNTIL(expr) \ 37313087Sgabeblack@google.com do { SC_WAIT(); } while (!(expr)) 37412907Sgabeblack@google.com 37512837Sgabeblack@google.com} // namespace sc_core 37612837Sgabeblack@google.com 37712837Sgabeblack@google.com#endif //__SYSTEMC_EXT_CORE_SC_MODULE_HH__ 378