sc_module.hh revision 12909
11689SN/A/* 22316SN/A * Copyright 2018 Google, Inc. 31689SN/A * 41689SN/A * Redistribution and use in source and binary forms, with or without 51689SN/A * modification, are permitted provided that the following conditions are 61689SN/A * met: redistributions of source code must retain the above copyright 71689SN/A * notice, this list of conditions and the following disclaimer; 81689SN/A * redistributions in binary form must reproduce the above copyright 91689SN/A * notice, this list of conditions and the following disclaimer in the 101689SN/A * documentation and/or other materials provided with the distribution; 111689SN/A * neither the name of the copyright holders nor the names of its 121689SN/A * contributors may be used to endorse or promote products derived from 131689SN/A * this software without specific prior written permission. 141689SN/A * 151689SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 161689SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 171689SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 181689SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 191689SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 201689SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 211689SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 221689SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 231689SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 241689SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 251689SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 261689SN/A * 272665Ssaidi@eecs.umich.edu * Authors: Gabe Black 282665Ssaidi@eecs.umich.edu */ 292965Sksewell@umich.edu 301689SN/A#ifndef __SYSTEMC_CORE_EXT_SC_MODULE_HH__ 311689SN/A#define __SYSTEMC_CORE_EXT_SC_MODULE_HH__ 322733Sktlim@umich.edu 332733Sktlim@umich.edu#include <vector> 342733Sktlim@umich.edu 352292SN/A#include "sc_object.hh" 362329SN/A#include "sc_sensitive.hh" 372292SN/A#include "sc_time.hh" 383577Sgblack@eecs.umich.edu 392292SN/Anamespace sc_core 401060SN/A{ 412292SN/A 421717SN/Atemplate <class T> 432292SN/Aclass sc_in; 442292SN/Atemplate <class T> 452790Sktlim@umich.educlass sc_out; 462790Sktlim@umich.edutemplate <class T> 472790Sktlim@umich.educlass sc_inout; 482790Sktlim@umich.edutemplate <class T> 491061SN/Aclass sc_signal_in_if; 502292SN/A 512292SN/Aclass sc_event; 522292SN/Aclass sc_event_and_list; 531060SN/Aclass sc_event_or_list; 542292SN/Aclass sc_module_name; 551060SN/A 561060SN/Aclass sc_bind_proxy 571061SN/A{ 581060SN/A public: 592292SN/A sc_bind_proxy(const sc_interface &interface); 601062SN/A sc_bind_proxy(const sc_port_base &port); 612316SN/A}; 622316SN/A 632292SN/Aextern const sc_bind_proxy SC_BIND_PROXY_NIL; 642292SN/A 652292SN/Aclass sc_module : public sc_object 662292SN/A{ 672292SN/A public: 682292SN/A virtual ~sc_module(); 692292SN/A 702292SN/A virtual const char *kind() const; 712292SN/A 722292SN/A void operator () (const sc_bind_proxy &p001, 732292SN/A const sc_bind_proxy &p002 = SC_BIND_PROXY_NIL, 742292SN/A const sc_bind_proxy &p003 = SC_BIND_PROXY_NIL, 752669Sktlim@umich.edu const sc_bind_proxy &p004 = SC_BIND_PROXY_NIL, 762292SN/A const sc_bind_proxy &p005 = SC_BIND_PROXY_NIL, 772292SN/A const sc_bind_proxy &p006 = SC_BIND_PROXY_NIL, 782292SN/A const sc_bind_proxy &p007 = SC_BIND_PROXY_NIL, 792292SN/A const sc_bind_proxy &p008 = SC_BIND_PROXY_NIL, 802292SN/A const sc_bind_proxy &p009 = SC_BIND_PROXY_NIL, 812292SN/A const sc_bind_proxy &p010 = SC_BIND_PROXY_NIL, 822307SN/A const sc_bind_proxy &p011 = SC_BIND_PROXY_NIL, 832843Sktlim@umich.edu const sc_bind_proxy &p012 = SC_BIND_PROXY_NIL, 842316SN/A const sc_bind_proxy &p013 = SC_BIND_PROXY_NIL, 852874Sktlim@umich.edu const sc_bind_proxy &p014 = SC_BIND_PROXY_NIL, 862292SN/A const sc_bind_proxy &p015 = SC_BIND_PROXY_NIL, 872292SN/A const sc_bind_proxy &p016 = SC_BIND_PROXY_NIL, 882292SN/A const sc_bind_proxy &p017 = SC_BIND_PROXY_NIL, 892980Sgblack@eecs.umich.edu const sc_bind_proxy &p018 = SC_BIND_PROXY_NIL, 902292SN/A const sc_bind_proxy &p019 = SC_BIND_PROXY_NIL, 912292SN/A const sc_bind_proxy &p020 = SC_BIND_PROXY_NIL, 922292SN/A const sc_bind_proxy &p021 = SC_BIND_PROXY_NIL, 932292SN/A const sc_bind_proxy &p022 = SC_BIND_PROXY_NIL, 942292SN/A const sc_bind_proxy &p023 = SC_BIND_PROXY_NIL, 952292SN/A const sc_bind_proxy &p024 = SC_BIND_PROXY_NIL, 962292SN/A const sc_bind_proxy &p025 = SC_BIND_PROXY_NIL, 972292SN/A const sc_bind_proxy &p026 = SC_BIND_PROXY_NIL, 982292SN/A const sc_bind_proxy &p027 = SC_BIND_PROXY_NIL, 992292SN/A const sc_bind_proxy &p028 = SC_BIND_PROXY_NIL, 1002292SN/A const sc_bind_proxy &p029 = SC_BIND_PROXY_NIL, 1012292SN/A const sc_bind_proxy &p030 = SC_BIND_PROXY_NIL, 1022292SN/A const sc_bind_proxy &p031 = SC_BIND_PROXY_NIL, 1032292SN/A const sc_bind_proxy &p032 = SC_BIND_PROXY_NIL, 1042292SN/A const sc_bind_proxy &p033 = SC_BIND_PROXY_NIL, 1052292SN/A const sc_bind_proxy &p034 = SC_BIND_PROXY_NIL, 1062292SN/A const sc_bind_proxy &p035 = SC_BIND_PROXY_NIL, 1072292SN/A const sc_bind_proxy &p036 = SC_BIND_PROXY_NIL, 1082292SN/A const sc_bind_proxy &p037 = SC_BIND_PROXY_NIL, 1092292SN/A const sc_bind_proxy &p038 = SC_BIND_PROXY_NIL, 1102292SN/A const sc_bind_proxy &p039 = SC_BIND_PROXY_NIL, 1112292SN/A const sc_bind_proxy &p040 = SC_BIND_PROXY_NIL, 1122292SN/A const sc_bind_proxy &p041 = SC_BIND_PROXY_NIL, 1132292SN/A const sc_bind_proxy &p042 = SC_BIND_PROXY_NIL, 1142292SN/A const sc_bind_proxy &p043 = SC_BIND_PROXY_NIL, 1152292SN/A const sc_bind_proxy &p044 = SC_BIND_PROXY_NIL, 1162292SN/A const sc_bind_proxy &p045 = SC_BIND_PROXY_NIL, 1172292SN/A const sc_bind_proxy &p046 = SC_BIND_PROXY_NIL, 1182292SN/A const sc_bind_proxy &p047 = SC_BIND_PROXY_NIL, 1192292SN/A const sc_bind_proxy &p048 = SC_BIND_PROXY_NIL, 1202292SN/A const sc_bind_proxy &p049 = SC_BIND_PROXY_NIL, 1212292SN/A const sc_bind_proxy &p050 = SC_BIND_PROXY_NIL, 1222680Sktlim@umich.edu const sc_bind_proxy &p051 = SC_BIND_PROXY_NIL, 1232935Sksewell@umich.edu const sc_bind_proxy &p052 = SC_BIND_PROXY_NIL, 1242292SN/A const sc_bind_proxy &p053 = SC_BIND_PROXY_NIL, 1253640Sktlim@umich.edu const sc_bind_proxy &p054 = SC_BIND_PROXY_NIL, 1263640Sktlim@umich.edu const sc_bind_proxy &p055 = SC_BIND_PROXY_NIL, 1273640Sktlim@umich.edu const sc_bind_proxy &p056 = SC_BIND_PROXY_NIL, 1282292SN/A const sc_bind_proxy &p057 = SC_BIND_PROXY_NIL, 1292292SN/A const sc_bind_proxy &p058 = SC_BIND_PROXY_NIL, 1302292SN/A const sc_bind_proxy &p059 = SC_BIND_PROXY_NIL, 1312292SN/A const sc_bind_proxy &p060 = SC_BIND_PROXY_NIL, 1322292SN/A const sc_bind_proxy &p061 = SC_BIND_PROXY_NIL, 1332292SN/A const sc_bind_proxy &p062 = SC_BIND_PROXY_NIL, 1342292SN/A const sc_bind_proxy &p063 = SC_BIND_PROXY_NIL, 1352292SN/A const sc_bind_proxy &p064 = SC_BIND_PROXY_NIL); 1362292SN/A 1372292SN/A virtual const std::vector<sc_object *> &get_child_objects() const; 1382292SN/A virtual const std::vector<sc_event *> &get_child_events() const; 1392292SN/A 1402132SN/A protected: 1412301SN/A sc_module(const sc_module_name &); 1421062SN/A sc_module(); 1431062SN/A 1441062SN/A /* Deprecated, but used in the regression tests. */ 1451062SN/A void end_module() {} 1461062SN/A 1471062SN/A void reset_signal_is(const sc_in<bool> &, bool); 1481062SN/A void reset_signal_is(const sc_inout<bool> &, bool); 1491062SN/A void reset_signal_is(const sc_out<bool> &, bool); 1501062SN/A void reset_signal_is(const sc_signal_in_if<bool> &, bool); 1511062SN/A 1521062SN/A void async_reset_signal_is(const sc_in<bool> &, bool); 1531062SN/A void async_reset_signal_is(const sc_inout<bool> &, bool); 1541062SN/A void async_reset_signal_is(const sc_out<bool> &, bool); 1551062SN/A void async_reset_signal_is(const sc_signal_in_if<bool> &, bool); 1561062SN/A 1571062SN/A sc_sensitive sensitive; 1581062SN/A 1591062SN/A void dont_initialize(); 1601062SN/A void set_stack_size(size_t); 1611062SN/A 1621062SN/A void next_trigger(); 1632292SN/A void next_trigger(const sc_event &); 1641062SN/A void next_trigger(const sc_event_or_list &); 1651062SN/A void next_trigger(const sc_event_and_list &); 1661062SN/A void next_trigger(const sc_time &); 1671062SN/A void next_trigger(double, sc_time_unit); 1681062SN/A void next_trigger(const sc_time &, const sc_event &); 1692301SN/A void next_trigger(double, sc_time_unit, const sc_event &); 1702316SN/A void next_trigger(const sc_time &, const sc_event_or_list &); 1712301SN/A void next_trigger(double, sc_time_unit, const sc_event_or_list &); 1722301SN/A void next_trigger(const sc_time &, const sc_event_and_list &); 1732301SN/A void next_trigger(double, sc_time_unit, const sc_event_and_list &); 1742301SN/A 1752301SN/A void wait(); 1762301SN/A void wait(int); 1772316SN/A void wait(const sc_event &); 1782301SN/A void wait(const sc_event_or_list &); 1792301SN/A void wait(const sc_event_and_list &); 1802301SN/A void wait(const sc_time &); 1812301SN/A void wait(double, sc_time_unit); 1822301SN/A void wait(const sc_time &, const sc_event &); 1832301SN/A void wait(double, sc_time_unit, const sc_event &); 1842316SN/A void wait(const sc_time &, const sc_event_or_list &); 1852301SN/A void wait(double, sc_time_unit, const sc_event_or_list &); 1862301SN/A void wait(const sc_time &, const sc_event_and_list &); 1872301SN/A void wait(double, sc_time_unit, const sc_event_and_list &); 1882301SN/A 1892301SN/A void halt(); 1902301SN/A 1912316SN/A virtual void before_end_of_elaboration() {} 1922301SN/A virtual void end_of_elaboration() {} 1932301SN/A virtual void start_of_simulation() {} 1942301SN/A virtual void end_of_simulation() {} 1952301SN/A 1962301SN/A private: 1972301SN/A // Disabled 1982316SN/A sc_module(const sc_module &) : sc_object() {}; 1992301SN/A sc_module &operator = (const sc_module &) { return *this; } 2002301SN/A}; 2012301SN/A 2022301SN/Avoid next_trigger(); 2032301SN/Avoid next_trigger(const sc_event &); 2042301SN/Avoid next_trigger(const sc_event_or_list &); 2052316SN/Avoid next_trigger(const sc_event_and_list &); 2062301SN/Avoid next_trigger(const sc_time &); 2072301SN/Avoid next_trigger(double, sc_time_unit); 2082301SN/Avoid next_trigger(const sc_time &, const sc_event &); 2092301SN/Avoid next_trigger(double, sc_time_unit, const sc_event &); 2102301SN/Avoid next_trigger(const sc_time &, const sc_event_or_list &); 2112301SN/Avoid next_trigger(double, sc_time_unit, const sc_event_or_list &); 2122316SN/Avoid next_trigger(const sc_time &, const sc_event_and_list &); 2132301SN/Avoid next_trigger(double, sc_time_unit, const sc_event_and_list &); 2142301SN/A 2152301SN/Avoid wait(); 2162301SN/Avoid wait(int); 2172301SN/Avoid wait(const sc_event &); 2182301SN/Avoid wait(const sc_event_or_list &); 2192316SN/Avoid wait(const sc_event_and_list &); 2202301SN/Avoid wait(const sc_time &); 2212301SN/Avoid wait(double, sc_time_unit); 2222301SN/Avoid wait(const sc_time &, const sc_event &); 2231062SN/Avoid wait(double, sc_time_unit, const sc_event &); 2241062SN/Avoid wait(const sc_time &, const sc_event_or_list &); 2251062SN/Avoid wait(double, sc_time_unit, const sc_event_or_list &); 2261062SN/Avoid wait(const sc_time &, const sc_event_and_list &); 2272733Sktlim@umich.eduvoid wait(double, sc_time_unit, const sc_event_and_list &); 2281060SN/A 2291060SN/A#define SC_MODULE(name) struct name : ::sc_core::sc_module 2301060SN/A 2312292SN/A#define SC_CTOR(name) \ 2322292SN/A typedef name SC_CURRENT_USER_MODULE; \ 2332292SN/A name(::sc_core::sc_module_name) 2342733Sktlim@umich.edu 2352307SN/A#define SC_HAS_PROCESS(name) typedef name SC_CURRENT_USER_MODULE 2362316SN/A 2371060SN/A#define SC_METHOD(name) /* Implementation defined */ 2381060SN/A#define SC_THREAD(name) /* Implementation defined */ 2391061SN/A#define SC_CTHREAD(name, clk) /* Implementation defined */ 2401060SN/A 2412980Sgblack@eecs.umich.edu// Nonstandard 2422292SN/A// Documentation for this is very scarce, but it looks like it's supposed to 2432292SN/A// stop the currently executing cthread, or if a cthread isn't running report 2442292SN/A// an error. 2452292SN/Avoid halt(); 2462292SN/A 2472292SN/Aconst char *sc_gen_unique_name(const char *); 2482292SN/A 2491060SN/Atypedef sc_module sc_behavior; 2501060SN/Atypedef sc_module sc_channel; 2511060SN/A 2521060SN/Abool sc_start_of_simulation_invoked(); 2531060SN/Abool sc_end_of_simulation_invoked(); 2541060SN/A 2551060SN/A// Nonstandard 2561060SN/A// Allocates a module of type x and records a pointer to it so that it gets 2571060SN/A// destructed automatically at the end of the simulation. 2581060SN/Asc_module *sc_module_sc_new(sc_module *); 2591060SN/A#define SC_NEW(x) ::sc_core::sc_module_sc_new(new x); 2601061SN/A 2611060SN/A// Nonstandard 2622292SN/A// In the Accellera implementation, this macro calls sc_set_location to record 2632292SN/A// the current file and line, calls wait, and then calls it again to clear the 2642292SN/A// file and line. We'll ignore the sc_set_location calls for now. 2652292SN/A#define SC_WAIT() ::sc_core::wait(); 2662292SN/A 2672292SN/A// Nonstandard 2682292SN/A// Same as above, but passes through an argument. 2692292SN/A#define SC_WAITN(n) ::sc_core::wait(n); 2702292SN/A 2712292SN/A// Nonstandard 2722292SN/A#define SC_WAIT_UNTIL(expr) do { SC_WAIT(); } while (!(expr)) 2732292SN/A 2741060SN/A} // namespace sc_core 2751060SN/A 2761060SN/A#endif //__SYSTEMC_EXT_CORE_SC_MODULE_HH__ 2771060SN/A