| 1 | /*------------------------------------------------------------\ |
|---|
| 2 | | | |
|---|
| 3 | | Tool : systemcass | |
|---|
| 4 | | | |
|---|
| 5 | | File : sc_module_ext.h | |
|---|
| 6 | | | |
|---|
| 7 | | Author : Buchmann Richard | |
|---|
| 8 | | Taktak Sami | |
|---|
| 9 | | | |
|---|
| 10 | | Date : 09_07_2004 | |
|---|
| 11 | | | |
|---|
| 12 | \------------------------------------------------------------*/ |
|---|
| 13 | |
|---|
| 14 | /* |
|---|
| 15 | * This file is part of the Disydent Project |
|---|
| 16 | * Copyright (C) Laboratoire LIP6 - Département ASIM |
|---|
| 17 | * Universite Pierre et Marie Curie |
|---|
| 18 | * |
|---|
| 19 | * Home page : http://www-asim.lip6.fr/disydent |
|---|
| 20 | * E-mail : mailto:richard.buchmann@lip6.fr |
|---|
| 21 | * |
|---|
| 22 | * This library is free software; you can redistribute it and/or modify it |
|---|
| 23 | * under the terms of the GNU Library General Public License as published |
|---|
| 24 | * by the Free Software Foundation; either version 2 of the License, or (at |
|---|
| 25 | * your option) any later version. |
|---|
| 26 | * |
|---|
| 27 | * Disydent is distributed in the hope that it will be |
|---|
| 28 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 29 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
|---|
| 30 | * Public License for more details. |
|---|
| 31 | * |
|---|
| 32 | * You should have received a copy of the GNU General Public License along |
|---|
| 33 | * with the GNU C Library; see the file COPYING. If not, write to the Free |
|---|
| 34 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|---|
| 35 | */ |
|---|
| 36 | |
|---|
| 37 | #ifndef __SC_MODULE_EXT_H__ |
|---|
| 38 | #define __SC_MODULE_EXT_H__ |
|---|
| 39 | |
|---|
| 40 | #include "sc_fwd.h" |
|---|
| 41 | #include "internal_ext.h" |
|---|
| 42 | #include "sc_object.h" |
|---|
| 43 | #include "sc_sensitive.h" |
|---|
| 44 | #include "serialization_ext.h" |
|---|
| 45 | |
|---|
| 46 | namespace sc_core { |
|---|
| 47 | |
|---|
| 48 | class method_process_t; |
|---|
| 49 | class sc_module; |
|---|
| 50 | class sc_module_name; |
|---|
| 51 | class sc_port_base; |
|---|
| 52 | class sc_signal_base; |
|---|
| 53 | |
|---|
| 54 | typedef void (sc_module::*SC_ENTRY_FUNC)(); |
|---|
| 55 | |
|---|
| 56 | extern method_process_t * create_method_process(const char *, SC_ENTRY_FUNC, sc_module &); |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | // ---------------------------------------------------------------------------- |
|---|
| 60 | // CLASS : sc_module |
|---|
| 61 | // |
|---|
| 62 | // Module class. |
|---|
| 63 | // ---------------------------------------------------------------------------- |
|---|
| 64 | |
|---|
| 65 | typedef sc_signal_base sc_bind_proxy; |
|---|
| 66 | extern sc_bind_proxy SC_BIND_PROXY_NIL; |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | struct sc_module : public sc_object { |
|---|
| 70 | |
|---|
| 71 | ////////////////////// |
|---|
| 72 | // SYSTEMCASS SPECIFIC |
|---|
| 73 | private : |
|---|
| 74 | void init(); |
|---|
| 75 | ////////////////////// |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | // LRM (?) |
|---|
| 79 | protected: |
|---|
| 80 | sc_module(); |
|---|
| 81 | sc_module(const char * nm); |
|---|
| 82 | sc_module(const sc_module_name & nm); |
|---|
| 83 | |
|---|
| 84 | public: |
|---|
| 85 | ~sc_module() {}; |
|---|
| 86 | |
|---|
| 87 | ///////// |
|---|
| 88 | //// LRM |
|---|
| 89 | protected: |
|---|
| 90 | void dont_initialize(); |
|---|
| 91 | |
|---|
| 92 | public: |
|---|
| 93 | void operator () ( |
|---|
| 94 | /* const */ sc_bind_proxy& p001, |
|---|
| 95 | /* const */ sc_bind_proxy& p002 = SC_BIND_PROXY_NIL, |
|---|
| 96 | /* const */ sc_bind_proxy& p003 = SC_BIND_PROXY_NIL, |
|---|
| 97 | /* const */ sc_bind_proxy& p004 = SC_BIND_PROXY_NIL, |
|---|
| 98 | /* const */ sc_bind_proxy& p005 = SC_BIND_PROXY_NIL, |
|---|
| 99 | /* const */ sc_bind_proxy& p006 = SC_BIND_PROXY_NIL, |
|---|
| 100 | /* const */ sc_bind_proxy& p007 = SC_BIND_PROXY_NIL, |
|---|
| 101 | /* const */ sc_bind_proxy& p008 = SC_BIND_PROXY_NIL, |
|---|
| 102 | /* const */ sc_bind_proxy& p009 = SC_BIND_PROXY_NIL, |
|---|
| 103 | /* const */ sc_bind_proxy& p010 = SC_BIND_PROXY_NIL, |
|---|
| 104 | /* const */ sc_bind_proxy& p011 = SC_BIND_PROXY_NIL, |
|---|
| 105 | /* const */ sc_bind_proxy& p012 = SC_BIND_PROXY_NIL, |
|---|
| 106 | /* const */ sc_bind_proxy& p013 = SC_BIND_PROXY_NIL, |
|---|
| 107 | /* const */ sc_bind_proxy& p014 = SC_BIND_PROXY_NIL, |
|---|
| 108 | /* const */ sc_bind_proxy& p015 = SC_BIND_PROXY_NIL, |
|---|
| 109 | /* const */ sc_bind_proxy& p016 = SC_BIND_PROXY_NIL, |
|---|
| 110 | /* const */ sc_bind_proxy& p017 = SC_BIND_PROXY_NIL, |
|---|
| 111 | /* const */ sc_bind_proxy& p018 = SC_BIND_PROXY_NIL, |
|---|
| 112 | /* const */ sc_bind_proxy& p019 = SC_BIND_PROXY_NIL, |
|---|
| 113 | /* const */ sc_bind_proxy& p020 = SC_BIND_PROXY_NIL, |
|---|
| 114 | /* const */ sc_bind_proxy& p021 = SC_BIND_PROXY_NIL, |
|---|
| 115 | /* const */ sc_bind_proxy& p022 = SC_BIND_PROXY_NIL, |
|---|
| 116 | /* const */ sc_bind_proxy& p023 = SC_BIND_PROXY_NIL, |
|---|
| 117 | /* const */ sc_bind_proxy& p024 = SC_BIND_PROXY_NIL, |
|---|
| 118 | /* const */ sc_bind_proxy& p025 = SC_BIND_PROXY_NIL, |
|---|
| 119 | /* const */ sc_bind_proxy& p026 = SC_BIND_PROXY_NIL, |
|---|
| 120 | /* const */ sc_bind_proxy& p027 = SC_BIND_PROXY_NIL, |
|---|
| 121 | /* const */ sc_bind_proxy& p028 = SC_BIND_PROXY_NIL, |
|---|
| 122 | /* const */ sc_bind_proxy& p029 = SC_BIND_PROXY_NIL, |
|---|
| 123 | /* const */ sc_bind_proxy& p030 = SC_BIND_PROXY_NIL, |
|---|
| 124 | /* const */ sc_bind_proxy& p031 = SC_BIND_PROXY_NIL, |
|---|
| 125 | /* const */ sc_bind_proxy& p032 = SC_BIND_PROXY_NIL, |
|---|
| 126 | /* const */ sc_bind_proxy& p033 = SC_BIND_PROXY_NIL, |
|---|
| 127 | /* const */ sc_bind_proxy& p034 = SC_BIND_PROXY_NIL, |
|---|
| 128 | /* const */ sc_bind_proxy& p035 = SC_BIND_PROXY_NIL, |
|---|
| 129 | /* const */ sc_bind_proxy& p036 = SC_BIND_PROXY_NIL, |
|---|
| 130 | /* const */ sc_bind_proxy& p037 = SC_BIND_PROXY_NIL, |
|---|
| 131 | /* const */ sc_bind_proxy& p038 = SC_BIND_PROXY_NIL, |
|---|
| 132 | /* const */ sc_bind_proxy& p039 = SC_BIND_PROXY_NIL, |
|---|
| 133 | /* const */ sc_bind_proxy& p040 = SC_BIND_PROXY_NIL, |
|---|
| 134 | /* const */ sc_bind_proxy& p041 = SC_BIND_PROXY_NIL, |
|---|
| 135 | /* const */ sc_bind_proxy& p042 = SC_BIND_PROXY_NIL, |
|---|
| 136 | /* const */ sc_bind_proxy& p043 = SC_BIND_PROXY_NIL, |
|---|
| 137 | /* const */ sc_bind_proxy& p044 = SC_BIND_PROXY_NIL, |
|---|
| 138 | /* const */ sc_bind_proxy& p045 = SC_BIND_PROXY_NIL, |
|---|
| 139 | /* const */ sc_bind_proxy& p046 = SC_BIND_PROXY_NIL, |
|---|
| 140 | /* const */ sc_bind_proxy& p047 = SC_BIND_PROXY_NIL, |
|---|
| 141 | /* const */ sc_bind_proxy& p048 = SC_BIND_PROXY_NIL, |
|---|
| 142 | /* const */ sc_bind_proxy& p049 = SC_BIND_PROXY_NIL, |
|---|
| 143 | /* const */ sc_bind_proxy& p050 = SC_BIND_PROXY_NIL, |
|---|
| 144 | /* const */ sc_bind_proxy& p051 = SC_BIND_PROXY_NIL, |
|---|
| 145 | /* const */ sc_bind_proxy& p052 = SC_BIND_PROXY_NIL, |
|---|
| 146 | /* const */ sc_bind_proxy& p053 = SC_BIND_PROXY_NIL, |
|---|
| 147 | /* const */ sc_bind_proxy& p054 = SC_BIND_PROXY_NIL, |
|---|
| 148 | /* const */ sc_bind_proxy& p055 = SC_BIND_PROXY_NIL, |
|---|
| 149 | /* const */ sc_bind_proxy& p056 = SC_BIND_PROXY_NIL, |
|---|
| 150 | /* const */ sc_bind_proxy& p057 = SC_BIND_PROXY_NIL, |
|---|
| 151 | /* const */ sc_bind_proxy& p058 = SC_BIND_PROXY_NIL, |
|---|
| 152 | /* const */ sc_bind_proxy& p059 = SC_BIND_PROXY_NIL, |
|---|
| 153 | /* const */ sc_bind_proxy& p060 = SC_BIND_PROXY_NIL, |
|---|
| 154 | /* const */ sc_bind_proxy& p061 = SC_BIND_PROXY_NIL, |
|---|
| 155 | /* const */ sc_bind_proxy& p062 = SC_BIND_PROXY_NIL, |
|---|
| 156 | /* const */ sc_bind_proxy& p063 = SC_BIND_PROXY_NIL, |
|---|
| 157 | /* const */ sc_bind_proxy& p064 = SC_BIND_PROXY_NIL); |
|---|
| 158 | |
|---|
| 159 | ///////// |
|---|
| 160 | // These are protected so that user derived classes can refer to them. |
|---|
| 161 | sc_sensitive sensitive; |
|---|
| 162 | sc_sensitive_pos sensitive_pos; |
|---|
| 163 | sc_sensitive_neg sensitive_neg; |
|---|
| 164 | }; |
|---|
| 165 | |
|---|
| 166 | |
|---|
| 167 | #define SC_MODULE(user_module_name) \ |
|---|
| 168 | struct user_module_name : public sc_core::sc_module |
|---|
| 169 | |
|---|
| 170 | // the SC_HAS_PROCESS macro call must be followed by a ; |
|---|
| 171 | #define SC_HAS_PROCESS(user_module_name) \ |
|---|
| 172 | typedef user_module_name SC_CURRENT_USER_MODULE |
|---|
| 173 | |
|---|
| 174 | #define SC_CTOR(user_module_name) \ |
|---|
| 175 | SC_HAS_PROCESS(user_module_name); \ |
|---|
| 176 | user_module_name(sc_core::sc_module_name) |
|---|
| 177 | |
|---|
| 178 | /* Converting `void (module_tag::*)()' to `void (sc_module::*)()' is OK as |
|---|
| 179 | long as the dynamic type is correct. C++ Standard 5.4 "Explicit type |
|---|
| 180 | conversion", clause 7: a pointer to member of derived class type may be |
|---|
| 181 | explicitly converted to a pointer to member of an unambiguous non-virtual |
|---|
| 182 | base class type. */ |
|---|
| 183 | #define SC_MAKE_FUNC_PTR(module_tag, func) \ |
|---|
| 184 | (/*static_cast<*/(sc_core::SC_ENTRY_FUNC)/*>*/ (&module_tag::func)) |
|---|
| 185 | |
|---|
| 186 | extern void declare_method_process(const char*,SC_ENTRY_FUNC,sc_module&); |
|---|
| 187 | |
|---|
| 188 | #define DECLARE_METHOD_PROCESS(handle, name, module_tag, func) \ |
|---|
| 189 | declare_method_process(name, \ |
|---|
| 190 | SC_MAKE_FUNC_PTR( module_tag, func ), \ |
|---|
| 191 | *this) |
|---|
| 192 | |
|---|
| 193 | |
|---|
| 194 | #define SC_METHOD(func) \ |
|---|
| 195 | { \ |
|---|
| 196 | DECLARE_METHOD_PROCESS(func ## _handle, #func, SC_CURRENT_USER_MODULE,func); \ |
|---|
| 197 | } |
|---|
| 198 | |
|---|
| 199 | #define SC_MAKE_SAVE_PTR(module_tag, func) \ |
|---|
| 200 | (/*static_cast<*/(sc_core::save_fct_t1)/*>*/ (&module_tag::func)) |
|---|
| 201 | |
|---|
| 202 | extern void declare_save_handler(const char*,save_fct_t1,sc_module&); |
|---|
| 203 | |
|---|
| 204 | #define DECLARE_SAVE_HANDLER(handle, name, module_tag, func) \ |
|---|
| 205 | declare_save_handler (name, \ |
|---|
| 206 | SC_MAKE_SAVE_PTR( module_tag, func ), \ |
|---|
| 207 | *this) |
|---|
| 208 | |
|---|
| 209 | |
|---|
| 210 | #define SAVE_HANDLER(func) \ |
|---|
| 211 | { \ |
|---|
| 212 | DECLARE_SAVE_HANDLER(func ## _handle, #func, SC_CURRENT_USER_MODULE,func); \ |
|---|
| 213 | } |
|---|
| 214 | |
|---|
| 215 | } // end of namespace sc_core |
|---|
| 216 | |
|---|
| 217 | #endif /* __SC_MODULE_EXT_H__ */ |
|---|
| 218 | |
|---|
| 219 | /* |
|---|
| 220 | # Local Variables: |
|---|
| 221 | # tab-width: 4; |
|---|
| 222 | # c-basic-offset: 4; |
|---|
| 223 | # c-file-offsets:((innamespace . 0)(inline-open . 0)); |
|---|
| 224 | # indent-tabs-mode: nil; |
|---|
| 225 | # End: |
|---|
| 226 | # |
|---|
| 227 | # vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
|---|
| 228 | */ |
|---|
| 229 | |
|---|