2 * Copyright 2018 Google, Inc.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution;
11 * neither the name of the copyright holders nor the names of its
12 * contributors may be used to endorse or promote products derived from
13 * this software without specific prior written permission.
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #ifndef __SYSTEMC_EXT_CORE_SC_PORT_HH__
31 #define __SYSTEMC_EXT_CORE_SC_PORT_HH__
35 #include "sc_module.hh" // for sc_gen_unique_name
36 #include "sc_object.hh"
42 class PendingSensitivityPort;
53 SC_ONE_OR_MORE_BOUND, // Default
54 SC_ZERO_OR_MORE_BOUND,
58 class sc_port_base : public sc_object
61 sc_port_base(const char *name, int n, sc_port_policy p);
63 void warn_unimpl(const char *func) const;
69 // Implementation defined, but depended on by the tests.
70 void bind(sc_interface &);
71 void bind(sc_port_base &);
73 // Implementation defined, but depended on by the tests.
74 virtual int vbind(sc_interface &) = 0;
75 virtual int vbind(sc_port_base &) = 0;
78 friend class ::sc_gem5::PendingSensitivityPort;
80 std::vector<::sc_gem5::BindInfo *> _gem5BindInfo;
85 class sc_port_b : public sc_port_base
91 this->warn_unimpl(__PRETTY_FUNCTION__);
95 operator () (sc_port_b<IF> &)
97 this->warn_unimpl(__PRETTY_FUNCTION__);
103 this->warn_unimpl(__PRETTY_FUNCTION__);
107 bind(sc_port_b<IF> &)
109 this->warn_unimpl(__PRETTY_FUNCTION__);
115 this->warn_unimpl(__PRETTY_FUNCTION__);
122 this->warn_unimpl(__PRETTY_FUNCTION__);
123 return (IF *)nullptr;
129 this->warn_unimpl(__PRETTY_FUNCTION__);
130 return (IF *)nullptr;
136 this->warn_unimpl(__PRETTY_FUNCTION__);
137 return (IF *)nullptr;
141 operator [] (int) const
143 this->warn_unimpl(__PRETTY_FUNCTION__);
144 return (IF *)nullptr;
147 virtual sc_interface *
150 this->warn_unimpl(__PRETTY_FUNCTION__);
151 return (sc_interface *)nullptr;
154 virtual const sc_interface *
155 get_interface() const
157 this->warn_unimpl(__PRETTY_FUNCTION__);
158 return (sc_interface *)nullptr;
162 virtual void before_end_of_elaboration() {}
163 virtual void end_of_elaboration() {}
164 virtual void start_of_elaboration() {}
165 virtual void end_of_simulation() {}
167 explicit sc_port_b(int n, sc_port_policy p) :
168 sc_port_base(sc_gen_unique_name("port"), n, p)
170 sc_port_b(const char *name, int n, sc_port_policy p) :
171 sc_port_base(name, n, p)
173 virtual ~sc_port_b() {}
175 // Implementation defined, but depended on by the tests.
177 vbind(sc_interface &)
179 this->warn_unimpl(__PRETTY_FUNCTION__);
183 vbind(sc_port_base &)
185 this->warn_unimpl(__PRETTY_FUNCTION__);
192 sc_port_b(const sc_port_b<IF> &) {}
193 sc_port_b<IF> &operator = (const sc_port_b<IF> &) { return *this; }
196 template <class IF, int N=1, sc_port_policy P=SC_ONE_OR_MORE_BOUND>
197 class sc_port : public sc_port_b<IF>
200 sc_port() : sc_port_b<IF>(N, P) {}
201 explicit sc_port(const char *name) : sc_port_b<IF>(name, N, P) {}
202 virtual ~sc_port() {}
204 // Deprecated binding constructors.
205 explicit sc_port(const IF &interface) : sc_port_b<IF>(N, P)
207 this->warn_unimpl(__PRETTY_FUNCTION__);
208 // Should warn that these are deprecated. See Accellera sc_port.h.
209 sc_port_b<IF>::bind(const_cast<IF &>(interface));
211 sc_port(const char *name, const IF &interface) : sc_port_b<IF>(name, N, P)
213 this->warn_unimpl(__PRETTY_FUNCTION__);
214 // Should warn that these are deprecated. See Accellera sc_port.h.
215 sc_port_b<IF>::bind(const_cast<IF &>(interface));
217 explicit sc_port(sc_port_b<IF> &parent) : sc_port_b<IF>(N, P)
219 this->warn_unimpl(__PRETTY_FUNCTION__);
220 // Should warn that these are deprecated. See Accellera sc_port.h.
221 sc_port_b<IF>::bind(parent);
223 sc_port(const char *name, sc_port_b<IF> &parent) :
224 sc_port_b<IF>(name, N, P)
226 this->warn_unimpl(__PRETTY_FUNCTION__);
227 // Should warn that these are deprecated. See Accellera sc_port.h.
228 sc_port_b<IF>::bind(parent);
230 explicit sc_port(sc_port<IF, N, P> &parent) : sc_port_b<IF>(N, P)
232 this->warn_unimpl(__PRETTY_FUNCTION__);
233 // Should warn that these are deprecated. See Accellera sc_port.h.
234 sc_port_b<IF>::bind(parent);
236 sc_port(const char *name, sc_port<IF, N, P> &parent) :
237 sc_port_b<IF>(name, N, P)
239 this->warn_unimpl(__PRETTY_FUNCTION__);
240 // Should warn that these are deprecated. See Accellera sc_port.h.
241 sc_port_b<IF>::bind(parent);
244 virtual const char *kind() const { return "sc_port"; }
248 sc_port(const sc_port<IF, N, P> &) {}
249 sc_port<IF, N, P> &operator = (const sc_port<IF, N, P> &) { return *this; }
252 } // namespace sc_core
254 #endif //__SYSTEMC_EXT_CORE_SC_PORT_HH__