sc_module.hh revision 13135
112953Sgabeblack@google.com/*
212953Sgabeblack@google.com * Copyright 2018 Google, Inc.
312953Sgabeblack@google.com *
412953Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
512953Sgabeblack@google.com * modification, are permitted provided that the following conditions are
612953Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
712953Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
812953Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
912953Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
1012953Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
1112953Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
1212953Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
1312953Sgabeblack@google.com * this software without specific prior written permission.
1412953Sgabeblack@google.com *
1512953Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1612953Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1712953Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1812953Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1912953Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2012953Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2112953Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2212953Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2312953Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2412953Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2512953Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2612953Sgabeblack@google.com *
2712953Sgabeblack@google.com * Authors: Gabe Black
2812953Sgabeblack@google.com */
2912953Sgabeblack@google.com
3012953Sgabeblack@google.com#ifndef __SYSTEMC_CORE_EXT_SC_MODULE_HH__
3112953Sgabeblack@google.com#define __SYSTEMC_CORE_EXT_SC_MODULE_HH__
3212953Sgabeblack@google.com
3313063Sgabeblack@google.com#include <vector>
3413063Sgabeblack@google.com
3513063Sgabeblack@google.com#include "sc_object.hh"
3612957Sgabeblack@google.com#include "sc_process_handle.hh"
3712957Sgabeblack@google.com#include "sc_sensitive.hh"
3812961Sgabeblack@google.com#include "sc_time.hh"
3913063Sgabeblack@google.com
4012954Sgabeblack@google.comnamespace sc_dt
4112954Sgabeblack@google.com{
4212953Sgabeblack@google.com
4312953Sgabeblack@google.comclass sc_logic;
4413063Sgabeblack@google.com
4512953Sgabeblack@google.com} // namespace sc_dt
4612961Sgabeblack@google.com
4712961Sgabeblack@google.comnamespace sc_gem5
4812953Sgabeblack@google.com{
4912953Sgabeblack@google.com
5012953Sgabeblack@google.comclass Kernel;
5112953Sgabeblack@google.comclass Module;
5212954Sgabeblack@google.comclass Process;
5312954Sgabeblack@google.comstruct ProcessFuncWrapper;
5412954Sgabeblack@google.com
5512954Sgabeblack@google.comProcess *newMethodProcess(const char *name, ProcessFuncWrapper *func);
5612954Sgabeblack@google.comProcess *newThreadProcess(const char *name, ProcessFuncWrapper *func);
5712954Sgabeblack@google.comProcess *newCThreadProcess(const char *name, ProcessFuncWrapper *func);
5812954Sgabeblack@google.com
5912954Sgabeblack@google.com} // namespace sc_gem5
6012954Sgabeblack@google.com
6112954Sgabeblack@google.comnamespace sc_core
6212954Sgabeblack@google.com{
6312954Sgabeblack@google.com
6412954Sgabeblack@google.comtemplate <class T>
6512954Sgabeblack@google.comclass sc_in;
6612954Sgabeblack@google.comtemplate <class T>
6712954Sgabeblack@google.comclass sc_out;
6812954Sgabeblack@google.comtemplate <class T>
6912954Sgabeblack@google.comclass sc_inout;
7012954Sgabeblack@google.comtemplate <class T>
7112957Sgabeblack@google.comclass sc_signal_in_if;
7212954Sgabeblack@google.com
7312954Sgabeblack@google.comclass sc_event;
7412954Sgabeblack@google.comclass sc_event_and_list;
7512954Sgabeblack@google.comclass sc_event_or_list;
7612954Sgabeblack@google.comclass sc_module_name;
7712954Sgabeblack@google.com
7812954Sgabeblack@google.comclass sc_bind_proxy
7912954Sgabeblack@google.com{
8012954Sgabeblack@google.com  private:
8112954Sgabeblack@google.com    sc_interface *_interface;
8212954Sgabeblack@google.com    sc_port_base *_port;
8312954Sgabeblack@google.com
8412954Sgabeblack@google.com  public:
8512954Sgabeblack@google.com    sc_bind_proxy(sc_interface &_interface);
8612954Sgabeblack@google.com    sc_bind_proxy(sc_port_base &_port);
8712954Sgabeblack@google.com
8812954Sgabeblack@google.com    sc_interface *interface() const { return _interface; }
8913063Sgabeblack@google.com    sc_port_base *port() const { return _port; }
9012954Sgabeblack@google.com};
9112954Sgabeblack@google.com
9212954Sgabeblack@google.comextern const sc_bind_proxy SC_BIND_PROXY_NIL;
9312954Sgabeblack@google.com
9412954Sgabeblack@google.comclass sc_module : public sc_object
9512954Sgabeblack@google.com{
9612954Sgabeblack@google.com  public:
9712954Sgabeblack@google.com    friend class ::sc_gem5::Kernel;
9812954Sgabeblack@google.com
9913063Sgabeblack@google.com    virtual ~sc_module();
10013063Sgabeblack@google.com
10112954Sgabeblack@google.com    virtual const char *kind() const { return "sc_module"; }
10212954Sgabeblack@google.com
10313063Sgabeblack@google.com    void operator () (const sc_bind_proxy &p001,
10413063Sgabeblack@google.com                      const sc_bind_proxy &p002 = SC_BIND_PROXY_NIL,
10512954Sgabeblack@google.com                      const sc_bind_proxy &p003 = SC_BIND_PROXY_NIL,
10612954Sgabeblack@google.com                      const sc_bind_proxy &p004 = SC_BIND_PROXY_NIL,
10712954Sgabeblack@google.com                      const sc_bind_proxy &p005 = SC_BIND_PROXY_NIL,
10812954Sgabeblack@google.com                      const sc_bind_proxy &p006 = SC_BIND_PROXY_NIL,
10913063Sgabeblack@google.com                      const sc_bind_proxy &p007 = SC_BIND_PROXY_NIL,
11013063Sgabeblack@google.com                      const sc_bind_proxy &p008 = SC_BIND_PROXY_NIL,
11113063Sgabeblack@google.com                      const sc_bind_proxy &p009 = SC_BIND_PROXY_NIL,
11213063Sgabeblack@google.com                      const sc_bind_proxy &p010 = SC_BIND_PROXY_NIL,
11313063Sgabeblack@google.com                      const sc_bind_proxy &p011 = SC_BIND_PROXY_NIL,
11412961Sgabeblack@google.com                      const sc_bind_proxy &p012 = SC_BIND_PROXY_NIL,
11512961Sgabeblack@google.com                      const sc_bind_proxy &p013 = SC_BIND_PROXY_NIL,
11612961Sgabeblack@google.com                      const sc_bind_proxy &p014 = SC_BIND_PROXY_NIL,
11712961Sgabeblack@google.com                      const sc_bind_proxy &p015 = SC_BIND_PROXY_NIL,
11812961Sgabeblack@google.com                      const sc_bind_proxy &p016 = SC_BIND_PROXY_NIL,
11912961Sgabeblack@google.com                      const sc_bind_proxy &p017 = SC_BIND_PROXY_NIL,
12012961Sgabeblack@google.com                      const sc_bind_proxy &p018 = SC_BIND_PROXY_NIL,
12112961Sgabeblack@google.com                      const sc_bind_proxy &p019 = SC_BIND_PROXY_NIL,
12212961Sgabeblack@google.com                      const sc_bind_proxy &p020 = SC_BIND_PROXY_NIL,
12312961Sgabeblack@google.com                      const sc_bind_proxy &p021 = SC_BIND_PROXY_NIL,
12412961Sgabeblack@google.com                      const sc_bind_proxy &p022 = SC_BIND_PROXY_NIL,
12512961Sgabeblack@google.com                      const sc_bind_proxy &p023 = SC_BIND_PROXY_NIL,
12612961Sgabeblack@google.com                      const sc_bind_proxy &p024 = SC_BIND_PROXY_NIL,
12712961Sgabeblack@google.com                      const sc_bind_proxy &p025 = SC_BIND_PROXY_NIL,
12812961Sgabeblack@google.com                      const sc_bind_proxy &p026 = SC_BIND_PROXY_NIL,
12912961Sgabeblack@google.com                      const sc_bind_proxy &p027 = SC_BIND_PROXY_NIL,
13012961Sgabeblack@google.com                      const sc_bind_proxy &p028 = SC_BIND_PROXY_NIL,
13112961Sgabeblack@google.com                      const sc_bind_proxy &p029 = SC_BIND_PROXY_NIL,
13212961Sgabeblack@google.com                      const sc_bind_proxy &p030 = SC_BIND_PROXY_NIL,
13312961Sgabeblack@google.com                      const sc_bind_proxy &p031 = SC_BIND_PROXY_NIL,
13412961Sgabeblack@google.com                      const sc_bind_proxy &p032 = SC_BIND_PROXY_NIL,
13513058Sgabeblack@google.com                      const sc_bind_proxy &p033 = SC_BIND_PROXY_NIL,
13613058Sgabeblack@google.com                      const sc_bind_proxy &p034 = SC_BIND_PROXY_NIL,
13713058Sgabeblack@google.com                      const sc_bind_proxy &p035 = SC_BIND_PROXY_NIL,
13813058Sgabeblack@google.com                      const sc_bind_proxy &p036 = SC_BIND_PROXY_NIL,
13913058Sgabeblack@google.com                      const sc_bind_proxy &p037 = SC_BIND_PROXY_NIL,
14013058Sgabeblack@google.com                      const sc_bind_proxy &p038 = SC_BIND_PROXY_NIL,
14113058Sgabeblack@google.com                      const sc_bind_proxy &p039 = SC_BIND_PROXY_NIL,
14213058Sgabeblack@google.com                      const sc_bind_proxy &p040 = SC_BIND_PROXY_NIL,
14312954Sgabeblack@google.com                      const sc_bind_proxy &p041 = SC_BIND_PROXY_NIL,
14412953Sgabeblack@google.com                      const sc_bind_proxy &p042 = SC_BIND_PROXY_NIL,
14512953Sgabeblack@google.com                      const sc_bind_proxy &p043 = SC_BIND_PROXY_NIL,
14612953Sgabeblack@google.com                      const sc_bind_proxy &p044 = SC_BIND_PROXY_NIL,
14712953Sgabeblack@google.com                      const sc_bind_proxy &p045 = SC_BIND_PROXY_NIL,
14813144Sgabeblack@google.com                      const sc_bind_proxy &p046 = SC_BIND_PROXY_NIL,
14913063Sgabeblack@google.com                      const sc_bind_proxy &p047 = SC_BIND_PROXY_NIL,
15013063Sgabeblack@google.com                      const sc_bind_proxy &p048 = SC_BIND_PROXY_NIL,
15113063Sgabeblack@google.com                      const sc_bind_proxy &p049 = SC_BIND_PROXY_NIL,
15213063Sgabeblack@google.com                      const sc_bind_proxy &p050 = SC_BIND_PROXY_NIL,
15313063Sgabeblack@google.com                      const sc_bind_proxy &p051 = SC_BIND_PROXY_NIL,
15413063Sgabeblack@google.com                      const sc_bind_proxy &p052 = SC_BIND_PROXY_NIL,
15513063Sgabeblack@google.com                      const sc_bind_proxy &p053 = SC_BIND_PROXY_NIL,
15613063Sgabeblack@google.com                      const sc_bind_proxy &p054 = SC_BIND_PROXY_NIL,
15713063Sgabeblack@google.com                      const sc_bind_proxy &p055 = SC_BIND_PROXY_NIL,
15813063Sgabeblack@google.com                      const sc_bind_proxy &p056 = SC_BIND_PROXY_NIL,
15913063Sgabeblack@google.com                      const sc_bind_proxy &p057 = SC_BIND_PROXY_NIL,
16013063Sgabeblack@google.com                      const sc_bind_proxy &p058 = SC_BIND_PROXY_NIL,
16112953Sgabeblack@google.com                      const sc_bind_proxy &p059 = SC_BIND_PROXY_NIL,
16213072Sgabeblack@google.com                      const sc_bind_proxy &p060 = SC_BIND_PROXY_NIL,
16312953Sgabeblack@google.com                      const sc_bind_proxy &p061 = SC_BIND_PROXY_NIL,
16413076Sgabeblack@google.com                      const sc_bind_proxy &p062 = SC_BIND_PROXY_NIL,
16513076Sgabeblack@google.com                      const sc_bind_proxy &p063 = SC_BIND_PROXY_NIL,
16612954Sgabeblack@google.com                      const sc_bind_proxy &p064 = SC_BIND_PROXY_NIL);
16712954Sgabeblack@google.com
16812953Sgabeblack@google.com    virtual const std::vector<sc_object *> &get_child_objects() const;
16912953Sgabeblack@google.com    virtual const std::vector<sc_event *> &get_child_events() const;
17012953Sgabeblack@google.com
17113067Sgabeblack@google.com  protected:
17212953Sgabeblack@google.com    sc_module(const sc_module_name &);
17312957Sgabeblack@google.com    sc_module();
17412957Sgabeblack@google.com
17512957Sgabeblack@google.com    // Deprecated
17612953Sgabeblack@google.com    sc_module(const char *);
17712953Sgabeblack@google.com    sc_module(const std::string &);
17812953Sgabeblack@google.com
17912953Sgabeblack@google.com    /* Deprecated, but used in the regression tests. */
18012954Sgabeblack@google.com    void end_module() {}
18112954Sgabeblack@google.com
18213133Sgabeblack@google.com    void reset_signal_is(const sc_in<bool> &, bool);
18313133Sgabeblack@google.com    void reset_signal_is(const sc_inout<bool> &, bool);
18413133Sgabeblack@google.com    void reset_signal_is(const sc_out<bool> &, bool);
18513133Sgabeblack@google.com    void reset_signal_is(const sc_signal_in_if<bool> &, bool);
18613133Sgabeblack@google.com
18713133Sgabeblack@google.com    void async_reset_signal_is(const sc_in<bool> &, bool);
18813133Sgabeblack@google.com    void async_reset_signal_is(const sc_inout<bool> &, bool);
18913133Sgabeblack@google.com    void async_reset_signal_is(const sc_out<bool> &, bool);
19012954Sgabeblack@google.com    void async_reset_signal_is(const sc_signal_in_if<bool> &, bool);
19112954Sgabeblack@google.com
19212953Sgabeblack@google.com    sc_sensitive sensitive;
19312953Sgabeblack@google.com
19412953Sgabeblack@google.com    void dont_initialize();
19512953Sgabeblack@google.com    void set_stack_size(size_t);
19612953Sgabeblack@google.com
19713176Sgabeblack@google.com    void next_trigger();
19813176Sgabeblack@google.com    void next_trigger(const sc_event &);
19913176Sgabeblack@google.com    void next_trigger(const sc_event_or_list &);
20013176Sgabeblack@google.com    void next_trigger(const sc_event_and_list &);
20113176Sgabeblack@google.com    void next_trigger(const sc_time &);
20212953Sgabeblack@google.com    void next_trigger(double, sc_time_unit);
20312953Sgabeblack@google.com    void next_trigger(const sc_time &, const sc_event &);
20413176Sgabeblack@google.com    void next_trigger(double, sc_time_unit, const sc_event &);
20512953Sgabeblack@google.com    void next_trigger(const sc_time &, const sc_event_or_list &);
20613176Sgabeblack@google.com    void next_trigger(double, sc_time_unit, const sc_event_or_list &);
20712953Sgabeblack@google.com    void next_trigger(const sc_time &, const sc_event_and_list &);
20812953Sgabeblack@google.com    void next_trigger(double, sc_time_unit, const sc_event_and_list &);
20912953Sgabeblack@google.com
21012954Sgabeblack@google.com    // Nonstandard
21112954Sgabeblack@google.com    bool timed_out();
21212954Sgabeblack@google.com
21312962Sgabeblack@google.com    void wait();
21412962Sgabeblack@google.com    void wait(int);
21512962Sgabeblack@google.com    void wait(const sc_event &);
21613063Sgabeblack@google.com    void wait(const sc_event_or_list &);
21713063Sgabeblack@google.com    void wait(const sc_event_and_list &);
21813063Sgabeblack@google.com    void wait(const sc_time &);
21913063Sgabeblack@google.com    void wait(double, sc_time_unit);
22013063Sgabeblack@google.com    void wait(const sc_time &, const sc_event &);
22113063Sgabeblack@google.com    void wait(double, sc_time_unit, const sc_event &);
22213063Sgabeblack@google.com    void wait(const sc_time &, const sc_event_or_list &);
22312962Sgabeblack@google.com    void wait(double, sc_time_unit, const sc_event_or_list &);
22412962Sgabeblack@google.com    void wait(const sc_time &, const sc_event_and_list &);
22513063Sgabeblack@google.com    void wait(double, sc_time_unit, const sc_event_and_list &);
22612962Sgabeblack@google.com
22713063Sgabeblack@google.com    // Nonstandard
22813125Sgabeblack@google.com    void halt();
22913125Sgabeblack@google.com    void at_posedge(const sc_signal_in_if<bool> &);
23013125Sgabeblack@google.com    void at_posedge(const sc_signal_in_if<sc_dt::sc_logic> &);
23113063Sgabeblack@google.com    void at_negedge(const sc_signal_in_if<bool> &);
23213063Sgabeblack@google.com    void at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &);
23313144Sgabeblack@google.com
23413063Sgabeblack@google.com    virtual void before_end_of_elaboration() {}
23513063Sgabeblack@google.com    virtual void end_of_elaboration() {}
23613063Sgabeblack@google.com    virtual void start_of_simulation() {}
23713063Sgabeblack@google.com    virtual void end_of_simulation() {}
23813063Sgabeblack@google.com
23913063Sgabeblack@google.com  private:
24013063Sgabeblack@google.com    sc_gem5::Module *_gem5_module;
24113063Sgabeblack@google.com
24213069Sgabeblack@google.com    // Disabled
24313063Sgabeblack@google.com    sc_module(const sc_module &) : sc_object() {};
24413144Sgabeblack@google.com    sc_module &operator = (const sc_module &) { return *this; }
24512962Sgabeblack@google.com};
24612962Sgabeblack@google.com
24712962Sgabeblack@google.comvoid next_trigger();
24812962Sgabeblack@google.comvoid next_trigger(const sc_event &);
24913063Sgabeblack@google.comvoid next_trigger(const sc_event_or_list &);
25012962Sgabeblack@google.comvoid next_trigger(const sc_event_and_list &);
25113144Sgabeblack@google.comvoid next_trigger(const sc_time &);
25213144Sgabeblack@google.comvoid next_trigger(double, sc_time_unit);
25313144Sgabeblack@google.comvoid next_trigger(const sc_time &, const sc_event &);
25413144Sgabeblack@google.comvoid next_trigger(double, sc_time_unit, const sc_event &);
25513144Sgabeblack@google.comvoid next_trigger(const sc_time &, const sc_event_or_list &);
25613063Sgabeblack@google.comvoid next_trigger(double, sc_time_unit, const sc_event_or_list &);
25712985Sgabeblack@google.comvoid next_trigger(const sc_time &, const sc_event_and_list &);
25813063Sgabeblack@google.comvoid next_trigger(double, sc_time_unit, const sc_event_and_list &);
25913063Sgabeblack@google.com
26013063Sgabeblack@google.comvoid wait();
26113063Sgabeblack@google.comvoid wait(int);
26213063Sgabeblack@google.comvoid wait(const sc_event &);
26313063Sgabeblack@google.comvoid wait(const sc_event_or_list &);
26413144Sgabeblack@google.comvoid wait(const sc_event_and_list &);
26513063Sgabeblack@google.comvoid wait(const sc_time &);
26613063Sgabeblack@google.comvoid wait(double, sc_time_unit);
26713063Sgabeblack@google.comvoid wait(const sc_time &, const sc_event &);
26813063Sgabeblack@google.comvoid wait(double, sc_time_unit, const sc_event &);
26913069Sgabeblack@google.comvoid wait(const sc_time &, const sc_event_or_list &);
27013063Sgabeblack@google.comvoid wait(double, sc_time_unit, const sc_event_or_list &);
27113063Sgabeblack@google.comvoid wait(const sc_time &, const sc_event_and_list &);
27212962Sgabeblack@google.comvoid wait(double, sc_time_unit, const sc_event_and_list &);
27312962Sgabeblack@google.com
27412962Sgabeblack@google.com// Nonstandard
27513063Sgabeblack@google.combool timed_out();
27612962Sgabeblack@google.com
27713140Sgabeblack@google.com#define SC_MODULE(name) struct name : ::sc_core::sc_module
27813063Sgabeblack@google.com
27913063Sgabeblack@google.com#define SC_CTOR(name) \
28013096Sgabeblack@google.com    typedef name SC_CURRENT_USER_MODULE; \
28113096Sgabeblack@google.com    name(::sc_core::sc_module_name)
28212962Sgabeblack@google.com
28312962Sgabeblack@google.com#define SC_HAS_PROCESS(name) typedef name SC_CURRENT_USER_MODULE
28412962Sgabeblack@google.com
28512962Sgabeblack@google.com#define SC_METHOD(name) \
28612962Sgabeblack@google.com    { \
28712962Sgabeblack@google.com        ::sc_gem5::Process *p = \
28812962Sgabeblack@google.com            ::sc_gem5::newMethodProcess( \
28912962Sgabeblack@google.com                #name, new ::sc_gem5::ProcessMemberFuncWrapper< \
29012962Sgabeblack@google.com                    SC_CURRENT_USER_MODULE>(this, \
29112962Sgabeblack@google.com                        &SC_CURRENT_USER_MODULE::name)); \
29212962Sgabeblack@google.com        if (p) \
29312962Sgabeblack@google.com            this->sensitive << p; \
29412962Sgabeblack@google.com    }
29513176Sgabeblack@google.com#define SC_THREAD(name) \
29613176Sgabeblack@google.com    { \
29712962Sgabeblack@google.com        ::sc_gem5::Process *p = \
29812962Sgabeblack@google.com            ::sc_gem5::newThreadProcess( \
29912962Sgabeblack@google.com                #name, new ::sc_gem5::ProcessMemberFuncWrapper< \
30012962Sgabeblack@google.com                    SC_CURRENT_USER_MODULE>(this, \
30112962Sgabeblack@google.com                        &SC_CURRENT_USER_MODULE::name)); \
30212962Sgabeblack@google.com        if (p) \
30313063Sgabeblack@google.com            this->sensitive << p; \
30412962Sgabeblack@google.com    }
30512962Sgabeblack@google.com#define SC_CTHREAD(name, clk) \
30612962Sgabeblack@google.com    { \
30712962Sgabeblack@google.com        ::sc_gem5::Process *p = \
30812962Sgabeblack@google.com            ::sc_gem5::newCThreadProcess( \
30912962Sgabeblack@google.com                #name, new ::sc_gem5::ProcessMemberFuncWrapper< \
31013063Sgabeblack@google.com                    SC_CURRENT_USER_MODULE>(this, \
31112962Sgabeblack@google.com                        &SC_CURRENT_USER_MODULE::name)); \
31213063Sgabeblack@google.com        if (p) { \
31313063Sgabeblack@google.com            this->sensitive << p; \
31413063Sgabeblack@google.com            this->sensitive << clk; \
31512962Sgabeblack@google.com        } \
31612954Sgabeblack@google.com    }
31712954Sgabeblack@google.com
31813186Sgabeblack@google.com// Nonstandard
31913186Sgabeblack@google.com// Documentation for this is very scarce, but it looks like it's supposed to
32013186Sgabeblack@google.com// stop the currently executing cthread, or if a cthread isn't running report
32113186Sgabeblack@google.com// an error.
32212954Sgabeblack@google.comvoid halt();
32312961Sgabeblack@google.comvoid at_posedge(const sc_signal_in_if<bool> &);
32412961Sgabeblack@google.comvoid at_posedge(const sc_signal_in_if<sc_dt::sc_logic> &);
32512961Sgabeblack@google.comvoid at_negedge(const sc_signal_in_if<bool> &);
32613061Sgabeblack@google.comvoid at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &);
32712961Sgabeblack@google.com
32812961Sgabeblack@google.comconst char *sc_gen_unique_name(const char *);
32912961Sgabeblack@google.com
33012961Sgabeblack@google.com// Nonstandard
33113186Sgabeblack@google.combool sc_hierarchical_name_exists(const char *name);
33213186Sgabeblack@google.com
33313186Sgabeblack@google.comtypedef sc_module sc_behavior;
33413186Sgabeblack@google.comtypedef sc_module sc_channel;
33513186Sgabeblack@google.com
33613186Sgabeblack@google.combool sc_start_of_simulation_invoked();
33713186Sgabeblack@google.combool sc_end_of_simulation_invoked();
33813186Sgabeblack@google.com
33913186Sgabeblack@google.com// Nonstandard
34013186Sgabeblack@google.com// Allocates a module of type x and records a pointer to it so that it gets
34113203Sgabeblack@google.com// destructed automatically at the end of the simulation.
34213203Sgabeblack@google.comsc_module *sc_module_sc_new(sc_module *);
34313203Sgabeblack@google.com#define SC_NEW(x) ::sc_core::sc_module_sc_new(new x);
34413186Sgabeblack@google.com
34513186Sgabeblack@google.com// Nonstandard
34613186Sgabeblack@google.com#define SC_WAIT() \
34713186Sgabeblack@google.com    ::sc_core::sc_set_location(__FILE__, __LINE__); \
34813186Sgabeblack@google.com    ::sc_core::wait(); \
34912961Sgabeblack@google.com    ::sc_core::sc_set_location(NULL, 0)
35013140Sgabeblack@google.com
35113140Sgabeblack@google.com// Nonstandard
35213182Sgabeblack@google.com#define SC_WAITN(n) \
35313182Sgabeblack@google.com    ::sc_core::sc_set_location(__FILE__, __LINE__); \
35413186Sgabeblack@google.com    ::sc_core::wait(n); \
35513186Sgabeblack@google.com    ::sc_core::sc_set_location(NULL, 0)
35613186Sgabeblack@google.com
35712953Sgabeblack@google.com// Nonstandard
35812961Sgabeblack@google.com#define SC_WAIT_UNTIL(expr) \
35912961Sgabeblack@google.com    do { SC_WAIT(); } while (!(expr))
36012961Sgabeblack@google.com
36112961Sgabeblack@google.com} // namespace sc_core
36212961Sgabeblack@google.com
36313058Sgabeblack@google.com#endif  //__SYSTEMC_EXT_CORE_SC_MODULE_HH__
36413058Sgabeblack@google.com