sc_port.hh (12837:413a7b490b1b) sc_port.hh (12842:79e4e6e731fe)
1/*
2 * Copyright 2018 Google, Inc.
3 *
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.
14 *
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.
26 *
27 * Authors: Gabe Black
28 */
29
30#ifndef __SYSTEMC_EXT_CORE_SC_PORT_HH__
31#define __SYSTEMC_EXT_CORE_SC_PORT_HH__
32
1/*
2 * Copyright 2018 Google, Inc.
3 *
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.
14 *
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.
26 *
27 * Authors: Gabe Black
28 */
29
30#ifndef __SYSTEMC_EXT_CORE_SC_PORT_HH__
31#define __SYSTEMC_EXT_CORE_SC_PORT_HH__
32
33#include "sc_module.hh" // for sc_gen_unique_name
33#include "sc_object.hh"
34
35namespace sc_core
36{
37
38class sc_interface;
39
40enum sc_port_policy
41{
42 SC_ONE_OR_MORE_BOUND, // Default
43 SC_ZERO_OR_MORE_BOUND,
44 SC_ALL_BOUND
45};
46
47class sc_port_base : public sc_object
48{
49 public:
34#include "sc_object.hh"
35
36namespace sc_core
37{
38
39class sc_interface;
40
41enum sc_port_policy
42{
43 SC_ONE_OR_MORE_BOUND, // Default
44 SC_ZERO_OR_MORE_BOUND,
45 SC_ALL_BOUND
46};
47
48class sc_port_base : public sc_object
49{
50 public:
50 void warn_unimpl(const char *func);
51 sc_port_base(const char *name, int n, sc_port_policy p) : sc_object(name)
52 {}
53
54 void warn_unimpl(const char *func) const;
51};
52
53template <class IF>
54class sc_port_b : public sc_port_base
55{
56 public:
57 void
58 operator () (IF &)
59 {
60 warn_unimpl(__PRETTY_FUNCTION__);
61 }
62
63 void
64 operator () (sc_port_b<IF> &)
65 {
66 warn_unimpl(__PRETTY_FUNCTION__);
67 }
68
69 virtual void
70 bind(IF &)
71 {
72 warn_unimpl(__PRETTY_FUNCTION__);
73 }
74
75 virtual void
76 bind(sc_port_b<IF> &)
77 {
78 warn_unimpl(__PRETTY_FUNCTION__);
79 }
80
81 int
82 size() const
83 {
84 warn_unimpl(__PRETTY_FUNCTION__);
85 return 0;
86 }
87
88 IF *
89 operator -> ()
90 {
91 warn_unimpl(__PRETTY_FUNCTION__);
92 return (IF *)nullptr;
93 }
94
95 const IF *
96 operator -> () const
97 {
98 warn_unimpl(__PRETTY_FUNCTION__);
99 return (IF *)nullptr;
100 }
101
102 IF *
103 operator [] (int)
104 {
105 warn_unimpl(__PRETTY_FUNCTION__);
106 return (IF *)nullptr;
107 }
108
109 const IF *
110 operator [] (int) const
111 {
112 warn_unimpl(__PRETTY_FUNCTION__);
113 return (IF *)nullptr;
114 }
115
116 virtual sc_interface *
117 get_interface()
118 {
119 warn_unimpl(__PRETTY_FUNCTION__);
120 return (sc_interface *)nullptr;
121 }
122
123 virtual const sc_interface *
124 get_interface() const
125 {
126 warn_unimpl(__PRETTY_FUNCTION__);
127 return (sc_interface *)nullptr;
128 }
129
130 protected:
131 virtual void before_end_of_elaboration() {}
132 virtual void end_of_elaboration() {}
133 virtual void start_of_elaboration() {}
134 virtual void end_of_simulation() {}
135
55};
56
57template <class IF>
58class sc_port_b : public sc_port_base
59{
60 public:
61 void
62 operator () (IF &)
63 {
64 warn_unimpl(__PRETTY_FUNCTION__);
65 }
66
67 void
68 operator () (sc_port_b<IF> &)
69 {
70 warn_unimpl(__PRETTY_FUNCTION__);
71 }
72
73 virtual void
74 bind(IF &)
75 {
76 warn_unimpl(__PRETTY_FUNCTION__);
77 }
78
79 virtual void
80 bind(sc_port_b<IF> &)
81 {
82 warn_unimpl(__PRETTY_FUNCTION__);
83 }
84
85 int
86 size() const
87 {
88 warn_unimpl(__PRETTY_FUNCTION__);
89 return 0;
90 }
91
92 IF *
93 operator -> ()
94 {
95 warn_unimpl(__PRETTY_FUNCTION__);
96 return (IF *)nullptr;
97 }
98
99 const IF *
100 operator -> () const
101 {
102 warn_unimpl(__PRETTY_FUNCTION__);
103 return (IF *)nullptr;
104 }
105
106 IF *
107 operator [] (int)
108 {
109 warn_unimpl(__PRETTY_FUNCTION__);
110 return (IF *)nullptr;
111 }
112
113 const IF *
114 operator [] (int) const
115 {
116 warn_unimpl(__PRETTY_FUNCTION__);
117 return (IF *)nullptr;
118 }
119
120 virtual sc_interface *
121 get_interface()
122 {
123 warn_unimpl(__PRETTY_FUNCTION__);
124 return (sc_interface *)nullptr;
125 }
126
127 virtual const sc_interface *
128 get_interface() const
129 {
130 warn_unimpl(__PRETTY_FUNCTION__);
131 return (sc_interface *)nullptr;
132 }
133
134 protected:
135 virtual void before_end_of_elaboration() {}
136 virtual void end_of_elaboration() {}
137 virtual void start_of_elaboration() {}
138 virtual void end_of_simulation() {}
139
136 explicit sc_port_b(int, sc_port_policy)
137 {
138 warn_unimpl(__PRETTY_FUNCTION__);
139 }
140 explicit sc_port_b(int n, sc_port_policy p) :
141 sc_port_base(sc_gen_unique_name("sc_port"), n, p)
142 {}
143 sc_port_b(const char *name, int n, sc_port_policy p) :
144 sc_port_base(name, n, p)
145 {}
146 virtual ~sc_port_b() {}
140
147
141 sc_port_b(const char *, int, sc_port_policy)
142 {
143 warn_unimpl(__PRETTY_FUNCTION__);
144 }
145
146 virtual ~sc_port_b()
147 {
148 warn_unimpl(__PRETTY_FUNCTION__);
149 }
150
151 private:
152 // Disabled
153 sc_port_b() {}
154 sc_port_b(const sc_port_b<IF> &) {}
155 sc_port_b<IF> &operator = (const sc_port_b<IF> &) { return *this; }
156};
157
158template <class IF, int N=1, sc_port_policy P=SC_ONE_OR_MORE_BOUND>
159class sc_port : public sc_port_b<IF>
160{
161 public:
148 private:
149 // Disabled
150 sc_port_b() {}
151 sc_port_b(const sc_port_b<IF> &) {}
152 sc_port_b<IF> &operator = (const sc_port_b<IF> &) { return *this; }
153};
154
155template <class IF, int N=1, sc_port_policy P=SC_ONE_OR_MORE_BOUND>
156class sc_port : public sc_port_b<IF>
157{
158 public:
162 sc_port()
163 {
164 warn_unimpl(__PRETTY_FUNCTION__);
165 }
159 sc_port() : sc_port_b<IF>(sc_gen_unique_name("sc_port"), N, P) {}
160 explicit sc_port(const char *name) : sc_port_b<IF>(name, N, P) {}
161 virtual ~sc_port() {}
166
162
167 explicit sc_port(const char *)
168 {
169 warn_unimpl(__PRETTY_FUNCTION__);
170 }
163 virtual const char *kind() const { return "sc_port"; }
171
164
172 virtual ~sc_port()
173 {
174 warn_unimpl(__PRETTY_FUNCTION__);
175 }
176
177 virtual const char *
178 kind() const
179 {
180 warn_unimpl(__PRETTY_FUNCTION__);
181 return "";
182 }
183
184 private:
185 // Disabled
186 sc_port(const sc_port<IF, N, P> &) {}
187 sc_port<IF, N, P> &operator = (const sc_port<IF, N, P> &) { return *this; }
188};
189
190} // namespace sc_core
191
192#endif //__SYSTEMC_EXT_CORE_SC_PORT_HH__
165 private:
166 // Disabled
167 sc_port(const sc_port<IF, N, P> &) {}
168 sc_port<IF, N, P> &operator = (const sc_port<IF, N, P> &) { return *this; }
169};
170
171} // namespace sc_core
172
173#endif //__SYSTEMC_EXT_CORE_SC_PORT_HH__