sc_module.hh revision 12901
12381SN/A/* 22592SN/A * Copyright 2018 Google, Inc. 32381SN/A * 42381SN/A * Redistribution and use in source and binary forms, with or without 52381SN/A * modification, are permitted provided that the following conditions are 62381SN/A * met: redistributions of source code must retain the above copyright 72381SN/A * notice, this list of conditions and the following disclaimer; 82381SN/A * redistributions in binary form must reproduce the above copyright 92381SN/A * notice, this list of conditions and the following disclaimer in the 102381SN/A * documentation and/or other materials provided with the distribution; 112381SN/A * neither the name of the copyright holders nor the names of its 122381SN/A * contributors may be used to endorse or promote products derived from 132381SN/A * this software without specific prior written permission. 142381SN/A * 152381SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 162381SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 172381SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 182381SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 192381SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 202381SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 212381SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 222381SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 232381SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 242381SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 252381SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 262381SN/A * 272665Ssaidi@eecs.umich.edu * Authors: Gabe Black 282665Ssaidi@eecs.umich.edu */ 292665Ssaidi@eecs.umich.edu 302665Ssaidi@eecs.umich.edu#ifndef __SYSTEMC_CORE_EXT_SC_MODULE_HH__ 312381SN/A#define __SYSTEMC_CORE_EXT_SC_MODULE_HH__ 322381SN/A 332381SN/A#include <vector> 342381SN/A 352662Sstever@eecs.umich.edu#include "sc_object.hh" 362381SN/A#include "sc_sensitive.hh" 372381SN/A#include "sc_time.hh" 382381SN/A 392381SN/Anamespace sc_core 402381SN/A{ 413348Sbinkertn@umich.edu 423348Sbinkertn@umich.edutemplate <class T> 433348Sbinkertn@umich.educlass sc_in; 442392SN/Atemplate <class T> 452980Sgblack@eecs.umich.educlass sc_out; 462394SN/Atemplate <class T> 472394SN/Aclass sc_inout; 482394SN/Atemplate <class T> 492394SN/Aclass sc_signal_in_if; 502394SN/A 512812Srdreslin@umich.educlass sc_event; 522812Srdreslin@umich.educlass sc_event_and_list; 532812Srdreslin@umich.educlass sc_event_or_list; 542812Srdreslin@umich.educlass sc_module_name; 552812Srdreslin@umich.edu 562812Srdreslin@umich.educlass sc_bind_proxy 572813Srdreslin@umich.edu{ 582813Srdreslin@umich.edu public: 592813Srdreslin@umich.edu sc_bind_proxy(const sc_interface &interface); 603074Srdreslin@umich.edu sc_bind_proxy(const sc_port_base &port); 612382SN/A}; 623208Srdreslin@umich.edu 633214Srdreslin@umich.eduextern const sc_bind_proxy SC_BIND_PROXY_NIL; 642381SN/A 652662Sstever@eecs.umich.educlass sc_module : public sc_object 662662Sstever@eecs.umich.edu{ 672662Sstever@eecs.umich.edu public: 682662Sstever@eecs.umich.edu virtual ~sc_module(); 692662Sstever@eecs.umich.edu 702381SN/A virtual const char *kind() const; 712641Sstever@eecs.umich.edu 722381SN/A void operator () (const sc_bind_proxy &p001, 732813Srdreslin@umich.edu const sc_bind_proxy &p002 = SC_BIND_PROXY_NIL, 742813Srdreslin@umich.edu const sc_bind_proxy &p003 = SC_BIND_PROXY_NIL, 752813Srdreslin@umich.edu const sc_bind_proxy &p004 = SC_BIND_PROXY_NIL, 762813Srdreslin@umich.edu const sc_bind_proxy &p005 = SC_BIND_PROXY_NIL, 772566SN/A const sc_bind_proxy &p006 = SC_BIND_PROXY_NIL, 782662Sstever@eecs.umich.edu const sc_bind_proxy &p007 = SC_BIND_PROXY_NIL, 792662Sstever@eecs.umich.edu const sc_bind_proxy &p008 = SC_BIND_PROXY_NIL, 802662Sstever@eecs.umich.edu const sc_bind_proxy &p009 = SC_BIND_PROXY_NIL, 812662Sstever@eecs.umich.edu const sc_bind_proxy &p010 = SC_BIND_PROXY_NIL, 822662Sstever@eecs.umich.edu const sc_bind_proxy &p011 = SC_BIND_PROXY_NIL, 832566SN/A const sc_bind_proxy &p012 = SC_BIND_PROXY_NIL, 842566SN/A const sc_bind_proxy &p013 = SC_BIND_PROXY_NIL, 852566SN/A const sc_bind_proxy &p014 = SC_BIND_PROXY_NIL, 862662Sstever@eecs.umich.edu const sc_bind_proxy &p015 = SC_BIND_PROXY_NIL, 872662Sstever@eecs.umich.edu const sc_bind_proxy &p016 = SC_BIND_PROXY_NIL, 882566SN/A const sc_bind_proxy &p017 = SC_BIND_PROXY_NIL, 892662Sstever@eecs.umich.edu const sc_bind_proxy &p018 = SC_BIND_PROXY_NIL, 902662Sstever@eecs.umich.edu const sc_bind_proxy &p019 = SC_BIND_PROXY_NIL, 912566SN/A const sc_bind_proxy &p020 = SC_BIND_PROXY_NIL, 922662Sstever@eecs.umich.edu const sc_bind_proxy &p021 = SC_BIND_PROXY_NIL, 932662Sstever@eecs.umich.edu const sc_bind_proxy &p022 = SC_BIND_PROXY_NIL, 942566SN/A const sc_bind_proxy &p023 = SC_BIND_PROXY_NIL, 952566SN/A const sc_bind_proxy &p024 = SC_BIND_PROXY_NIL, 962662Sstever@eecs.umich.edu const sc_bind_proxy &p025 = SC_BIND_PROXY_NIL, 972662Sstever@eecs.umich.edu const sc_bind_proxy &p026 = SC_BIND_PROXY_NIL, 982381SN/A const sc_bind_proxy &p027 = SC_BIND_PROXY_NIL, 992381SN/A const sc_bind_proxy &p028 = SC_BIND_PROXY_NIL, 1002662Sstever@eecs.umich.edu const sc_bind_proxy &p029 = SC_BIND_PROXY_NIL, 1012381SN/A const sc_bind_proxy &p030 = SC_BIND_PROXY_NIL, 1022381SN/A const sc_bind_proxy &p031 = SC_BIND_PROXY_NIL, 1032662Sstever@eecs.umich.edu const sc_bind_proxy &p032 = SC_BIND_PROXY_NIL, 1042662Sstever@eecs.umich.edu const sc_bind_proxy &p033 = SC_BIND_PROXY_NIL, 1052662Sstever@eecs.umich.edu const sc_bind_proxy &p034 = SC_BIND_PROXY_NIL, 1062662Sstever@eecs.umich.edu const sc_bind_proxy &p035 = SC_BIND_PROXY_NIL, 1072381SN/A const sc_bind_proxy &p036 = SC_BIND_PROXY_NIL, 1082381SN/A const sc_bind_proxy &p037 = SC_BIND_PROXY_NIL, 1092662Sstever@eecs.umich.edu const sc_bind_proxy &p038 = SC_BIND_PROXY_NIL, 1102662Sstever@eecs.umich.edu const sc_bind_proxy &p039 = SC_BIND_PROXY_NIL, 1112662Sstever@eecs.umich.edu const sc_bind_proxy &p040 = SC_BIND_PROXY_NIL, 1122662Sstever@eecs.umich.edu const sc_bind_proxy &p041 = SC_BIND_PROXY_NIL, 1132662Sstever@eecs.umich.edu const sc_bind_proxy &p042 = SC_BIND_PROXY_NIL, 1142641Sstever@eecs.umich.edu const sc_bind_proxy &p043 = SC_BIND_PROXY_NIL, 1152641Sstever@eecs.umich.edu const sc_bind_proxy &p044 = SC_BIND_PROXY_NIL, 1162663Sstever@eecs.umich.edu const sc_bind_proxy &p045 = SC_BIND_PROXY_NIL, 1172663Sstever@eecs.umich.edu const sc_bind_proxy &p046 = SC_BIND_PROXY_NIL, 1182662Sstever@eecs.umich.edu const sc_bind_proxy &p047 = SC_BIND_PROXY_NIL, 1192641Sstever@eecs.umich.edu const sc_bind_proxy &p048 = SC_BIND_PROXY_NIL, 1202813Srdreslin@umich.edu const sc_bind_proxy &p049 = SC_BIND_PROXY_NIL, 1212641Sstever@eecs.umich.edu const sc_bind_proxy &p050 = SC_BIND_PROXY_NIL, 1222641Sstever@eecs.umich.edu const sc_bind_proxy &p051 = SC_BIND_PROXY_NIL, 1232641Sstever@eecs.umich.edu const sc_bind_proxy &p052 = SC_BIND_PROXY_NIL, 1242811Srdreslin@umich.edu const sc_bind_proxy &p053 = SC_BIND_PROXY_NIL, 1252811Srdreslin@umich.edu const sc_bind_proxy &p054 = SC_BIND_PROXY_NIL, 1262811Srdreslin@umich.edu const sc_bind_proxy &p055 = SC_BIND_PROXY_NIL, 1273218Sgblack@eecs.umich.edu const sc_bind_proxy &p056 = SC_BIND_PROXY_NIL, 1283218Sgblack@eecs.umich.edu const sc_bind_proxy &p057 = SC_BIND_PROXY_NIL, 1293218Sgblack@eecs.umich.edu const sc_bind_proxy &p058 = SC_BIND_PROXY_NIL, 1303218Sgblack@eecs.umich.edu const sc_bind_proxy &p059 = SC_BIND_PROXY_NIL, 1313218Sgblack@eecs.umich.edu const sc_bind_proxy &p060 = SC_BIND_PROXY_NIL, 1323218Sgblack@eecs.umich.edu const sc_bind_proxy &p061 = SC_BIND_PROXY_NIL, 1332662Sstever@eecs.umich.edu const sc_bind_proxy &p062 = SC_BIND_PROXY_NIL, 1342662Sstever@eecs.umich.edu const sc_bind_proxy &p063 = SC_BIND_PROXY_NIL, 1352623SN/A const sc_bind_proxy &p064 = SC_BIND_PROXY_NIL); 1362623SN/A 1372662Sstever@eecs.umich.edu virtual const std::vector<sc_object *> &get_child_objects() const; 1382641Sstever@eecs.umich.edu virtual const std::vector<sc_event *> &get_child_events() const; 1392641Sstever@eecs.umich.edu 1402662Sstever@eecs.umich.edu protected: 1412662Sstever@eecs.umich.edu sc_module(const sc_module_name &); 1422662Sstever@eecs.umich.edu sc_module(); 1432641Sstever@eecs.umich.edu 1442641Sstever@eecs.umich.edu /* Deprecated, but used in the regression tests. */ 1452641Sstever@eecs.umich.edu void end_module() {} 1462641Sstever@eecs.umich.edu 1472641Sstever@eecs.umich.edu void reset_signal_is(const sc_in<bool> &, bool); 1482662Sstever@eecs.umich.edu void reset_signal_is(const sc_inout<bool> &, bool); 1492662Sstever@eecs.umich.edu void reset_signal_is(const sc_out<bool> &, bool); 1502662Sstever@eecs.umich.edu void reset_signal_is(const sc_signal_in_if<bool> &, bool); 1512662Sstever@eecs.umich.edu 1522641Sstever@eecs.umich.edu void async_reset_signal_is(const sc_in<bool> &, bool); 1532662Sstever@eecs.umich.edu void async_reset_signal_is(const sc_inout<bool> &, bool); 1542662Sstever@eecs.umich.edu void async_reset_signal_is(const sc_out<bool> &, bool); 1552662Sstever@eecs.umich.edu void async_reset_signal_is(const sc_signal_in_if<bool> &, bool); 1562662Sstever@eecs.umich.edu 1572662Sstever@eecs.umich.edu sc_sensitive sensitive; 1582662Sstever@eecs.umich.edu 1592662Sstever@eecs.umich.edu void dont_initialize(); 1602641Sstever@eecs.umich.edu void set_stack_size(size_t); 1612641Sstever@eecs.umich.edu 1622641Sstever@eecs.umich.edu void next_trigger(); 1632641Sstever@eecs.umich.edu void next_trigger(const sc_event &); 1642641Sstever@eecs.umich.edu void next_trigger(const sc_event_or_list &); 1652662Sstever@eecs.umich.edu void next_trigger(const sc_event_and_list &); 1662662Sstever@eecs.umich.edu void next_trigger(const sc_time &); 1672662Sstever@eecs.umich.edu void next_trigger(double, sc_time_unit); 1682641Sstever@eecs.umich.edu void next_trigger(const sc_time &, const sc_event &); 1692641Sstever@eecs.umich.edu void next_trigger(double, sc_time_unit, const sc_event &); 1702641Sstever@eecs.umich.edu void next_trigger(const sc_time &, const sc_event_or_list &); 1713158Sgblack@eecs.umich.edu void next_trigger(double, sc_time_unit, const sc_event_or_list &); 1723158Sgblack@eecs.umich.edu void next_trigger(const sc_time &, const sc_event_and_list &); 1732641Sstever@eecs.umich.edu void next_trigger(double, sc_time_unit, const sc_event_and_list &); 1742641Sstever@eecs.umich.edu 1753260Ssaidi@eecs.umich.edu void wait(); 1763260Ssaidi@eecs.umich.edu void wait(int); 1773260Ssaidi@eecs.umich.edu void wait(const sc_event &); 1783260Ssaidi@eecs.umich.edu void wait(const sc_event_or_list &); 1793260Ssaidi@eecs.umich.edu void wait(const sc_event_and_list &); 1803260Ssaidi@eecs.umich.edu void wait(const sc_time &); 1813260Ssaidi@eecs.umich.edu void wait(double, sc_time_unit); 1822811Srdreslin@umich.edu void wait(const sc_time &, const sc_event &); 1833156Sgblack@eecs.umich.edu void wait(double, sc_time_unit, const sc_event &); 1843214Srdreslin@umich.edu void wait(const sc_time &, const sc_event_or_list &); 1853260Ssaidi@eecs.umich.edu void wait(double, sc_time_unit, const sc_event_or_list &); 1862641Sstever@eecs.umich.edu void wait(const sc_time &, const sc_event_and_list &); 1872641Sstever@eecs.umich.edu void wait(double, sc_time_unit, const sc_event_and_list &); 1882641Sstever@eecs.umich.edu 1892641Sstever@eecs.umich.edu virtual void before_end_of_elaboration() {} 1902641Sstever@eecs.umich.edu virtual void end_of_elaboration() {} 1912641Sstever@eecs.umich.edu virtual void start_of_simulation() {} 1922813Srdreslin@umich.edu virtual void end_of_simulation() {} 1933260Ssaidi@eecs.umich.edu 1943260Ssaidi@eecs.umich.edu private: 1953260Ssaidi@eecs.umich.edu // Disabled 1963260Ssaidi@eecs.umich.edu sc_module(const sc_module &) : sc_object() {}; 1973260Ssaidi@eecs.umich.edu sc_module &operator = (const sc_module &) { return *this; } 1983158Sgblack@eecs.umich.edu}; 1992811Srdreslin@umich.edu 2002811Srdreslin@umich.eduvoid next_trigger(); 2013156Sgblack@eecs.umich.eduvoid next_trigger(const sc_event &); 2023158Sgblack@eecs.umich.eduvoid next_trigger(const sc_event_or_list &); 2033156Sgblack@eecs.umich.eduvoid next_trigger(const sc_event_and_list &); 2043260Ssaidi@eecs.umich.eduvoid next_trigger(const sc_time &); 2052812Srdreslin@umich.eduvoid next_trigger(double, sc_time_unit); 2063293Srdreslin@umich.eduvoid next_trigger(const sc_time &, const sc_event &); 2073293Srdreslin@umich.eduvoid next_trigger(double, sc_time_unit, const sc_event &); 2083335Srdreslin@umich.eduvoid next_trigger(const sc_time &, const sc_event_or_list &); 2093335Srdreslin@umich.eduvoid next_trigger(double, sc_time_unit, const sc_event_or_list &); 2103207Srdreslin@umich.eduvoid next_trigger(const sc_time &, const sc_event_and_list &); 2112855Srdreslin@umich.eduvoid next_trigger(double, sc_time_unit, const sc_event_and_list &); 2123156Sgblack@eecs.umich.edu 2133158Sgblack@eecs.umich.eduvoid wait(); 2142641Sstever@eecs.umich.eduvoid wait(int); 2152641Sstever@eecs.umich.eduvoid wait(const sc_event &); 2162662Sstever@eecs.umich.eduvoid wait(const sc_event_or_list &); 2172662Sstever@eecs.umich.eduvoid wait(const sc_event_and_list &); 2182641Sstever@eecs.umich.eduvoid wait(const sc_time &); 2192381SN/Avoid wait(double, sc_time_unit); 2202811Srdreslin@umich.eduvoid wait(const sc_time &, const sc_event &); 2212811Srdreslin@umich.eduvoid wait(double, sc_time_unit, const sc_event &); 2222811Srdreslin@umich.eduvoid wait(const sc_time &, const sc_event_or_list &); 2232811Srdreslin@umich.eduvoid wait(double, sc_time_unit, const sc_event_or_list &); 2242811Srdreslin@umich.eduvoid wait(const sc_time &, const sc_event_and_list &); 2252811Srdreslin@umich.eduvoid wait(double, sc_time_unit, const sc_event_and_list &); 2262662Sstever@eecs.umich.edu 2272381SN/A#define SC_MODULE(name) struct name : ::sc_core::sc_module 2282381SN/A 2293260Ssaidi@eecs.umich.edu#define SC_CTOR(name) \ 2303260Ssaidi@eecs.umich.edu typedef name SC_CURRENT_USER_MODULE; \ 2313260Ssaidi@eecs.umich.edu name(::sc_core::sc_module_name) 2323260Ssaidi@eecs.umich.edu 2333260Ssaidi@eecs.umich.edu#define SC_HAS_PROCESS(name) typedef name SC_CURRENT_USER_MODULE 2343260Ssaidi@eecs.umich.edu 2353260Ssaidi@eecs.umich.edu#define SC_METHOD(name) /* Implementation defined */ 2362812Srdreslin@umich.edu#define SC_THREAD(name) /* Implementation defined */ 2373260Ssaidi@eecs.umich.edu#define SC_CTHREAD(name, clk) /* Implementation defined */ 2383260Ssaidi@eecs.umich.edu 2393260Ssaidi@eecs.umich.educonst char *sc_gen_unique_name(const char *); 2402814Srdreslin@umich.edu 2413039Sstever@eecs.umich.edutypedef sc_module sc_behavior; 2422641Sstever@eecs.umich.edutypedef sc_module sc_channel; 2432662Sstever@eecs.umich.edu 2442641Sstever@eecs.umich.edubool sc_start_of_simulation_invoked(); 2452641Sstever@eecs.umich.edubool sc_end_of_simulation_invoked(); 2462641Sstever@eecs.umich.edu 2472641Sstever@eecs.umich.edu// Nonstandard 2482685Ssaidi@eecs.umich.edu// Allocates a module of type x and records a pointer to it so that it gets 2492641Sstever@eecs.umich.edu// destructed automatically at the end of the simulation. 2502641Sstever@eecs.umich.edusc_module *sc_module_sc_new(sc_module *); 2512641Sstever@eecs.umich.edu#define SC_NEW(x) ::sc_core::sc_module_sc_new(new x); 2522662Sstever@eecs.umich.edu 2532641Sstever@eecs.umich.edu} // namespace sc_core 2542381SN/A 2552381SN/A#endif //__SYSTEMC_EXT_CORE_SC_MODULE_HH__ 2562641Sstever@eecs.umich.edu