multi_passthrough_target_socket.h (13513:bbf275465d3d) multi_passthrough_target_socket.h (13586:008fe87c1ad4)
1/*****************************************************************************
2
3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4 more contributor license agreements. See the NOTICE file distributed
5 with this work for additional information regarding copyright ownership.
6 Accellera licenses this file to you under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with the
8 License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15 implied. See the License for the specific language governing
16 permissions and limitations under the License.
17
18 *****************************************************************************/
19#ifndef __SYSTEMC_EXT_TLM_UTILS_MULTI_PASSTHROUGH_TARGET_SOCKET_H__
20#define __SYSTEMC_EXT_TLM_UTILS_MULTI_PASSTHROUGH_TARGET_SOCKET_H__
21
1/*****************************************************************************
2
3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4 more contributor license agreements. See the NOTICE file distributed
5 with this work for additional information regarding copyright ownership.
6 Accellera licenses this file to you under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with the
8 License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15 implied. See the License for the specific language governing
16 permissions and limitations under the License.
17
18 *****************************************************************************/
19#ifndef __SYSTEMC_EXT_TLM_UTILS_MULTI_PASSTHROUGH_TARGET_SOCKET_H__
20#define __SYSTEMC_EXT_TLM_UTILS_MULTI_PASSTHROUGH_TARGET_SOCKET_H__
21
22#include "tlm_utils/multi_socket_bases.h"
22#include "../core/sc_module.hh"
23#include "../core/sc_port.hh"
24#include "multi_socket_bases.h"
23
24namespace tlm_utils
25{
26
27/*
28This class implements a trivial multi target socket.
29The triviality refers to the fact that the socket does not
30do blocking to non-blocking or non-blocking to blocking conversions.
31
32It allows to connect multiple initiators to this socket.
33The user has to register callbacks for the fw interface methods
34he likes to use. The callbacks are basically equal to the fw interface
35methods but carry an additional integer that indicates to which
36index of this socket the calling initiator is connected.
37*/
38template <typename MODULE, unsigned int BUSWIDTH=32,
39 typename TYPES=tlm::tlm_base_protocol_types, unsigned int N=0,
40 sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND>
41class multi_passthrough_target_socket :
42 public multi_target_base< BUSWIDTH, TYPES, N, POL>,
43 public multi_to_multi_bind_base<TYPES>
44{
45 public:
46 //typedefs
47 // tlm 2.0 types for nb_transport
48 typedef typename TYPES::tlm_payload_type transaction_type;
49 typedef typename TYPES::tlm_phase_type phase_type;
50 typedef tlm::tlm_sync_enum sync_enum_type;
51
52 // typedefs to keep the fn ptr notations short
53 typedef sync_enum_type (MODULE::*nb_cb)(
54 int, transaction_type &, phase_type &, sc_core::sc_time &);
55 typedef void (MODULE::*b_cb)(int, transaction_type &, sc_core::sc_time &);
56 typedef unsigned int (MODULE::*dbg_cb)(int, transaction_type &txn);
57 typedef bool (MODULE::*dmi_cb)(
58 int, transaction_type &txn, tlm::tlm_dmi &dmi);
59
60 typedef multi_target_base<BUSWIDTH, TYPES, N, POL> base_type;
61
62 typedef typename base_type::base_initiator_socket_type
63 base_initiator_socket_type;
64
65 static const char *
66 default_name()
67 {
68 return sc_core::sc_gen_unique_name("multi_passthrough_target_socket");
69 }
70
71 explicit multi_passthrough_target_socket(const char *name=default_name()) :
72 base_type(name), m_hierarch_bind(0), m_eoe_disabled(false),
73 m_export_callback_created(false)
74 {}
75
76 ~multi_passthrough_target_socket()
77 {
78 // Clean up everything allocated by 'new'.
79 for (unsigned int i = 0; i < m_binders.size(); i++)
80 delete m_binders[i];
81 }
82
83 void
84 check_export_binding()
85 {
86 // If our export hasn't been bound yet (due to a hierarch binding)
87 // we bind it now. We do that here as the user of the target port HAS
88 // to bind at least on callback, otherwise the socket was useless.
89 // Nevertheless, the target socket may still stay unbound afterwards.
90 if (!sc_core::sc_export<tlm::tlm_fw_transport_if<TYPES>>::
91 get_interface()) {
92 // We bind to a callback_binder that will be used as the first
93 // interface i.e. calls to the sc_export will have the same ID as
94 // calls from the first initator socket bound.
95 callback_binder_fw<TYPES> *binder;
96
97 if (m_binders.size() == 0) {
98 binder = new callback_binder_fw<TYPES>(
99 this, m_binders.size());
100 m_binders.push_back(binder);
101 m_export_callback_created = true;
102 } else {
103 binder = m_binders[0];
104 }
105
106 sc_core::sc_export<tlm::tlm_fw_transport_if<TYPES>>::bind(*binder);
107 }
108 }
109
110 //register callback for nb transport of fw interface
111 void
112 register_nb_transport_fw(MODULE *mod, nb_cb cb)
113 {
114 check_export_binding();
115
116 // Warn if there already is a callback.
117 if (m_nb_f.is_valid()) {
118 display_warning("NBTransport_bw callback already registered.");
119 return;
120 }
121
122 // Set the functor.
123 m_nb_f.set_function(mod, cb);
124 }
125
126 // Register callback for b transport of fw interface.
127 void
128 register_b_transport(MODULE *mod, b_cb cb)
129 {
130 check_export_binding();
131
132 // Warn if there already is a callback.
133 if (m_b_f.is_valid()) {
134 display_warning("BTransport callback already registered.");
135 return;
136 }
137
138 // Set the functor.
139 m_b_f.set_function(mod, cb);
140 }
141
142 // Register callback for debug transport of fw interface.
143 void
144 register_transport_dbg(MODULE *mod, dbg_cb cb)
145 {
146 check_export_binding();
147
148 // Warn if there already is a callback.
149 if (m_dbg_f.is_valid()) {
150 display_warning("DebugTransport callback already registered.");
151 return;
152 }
153
154 // Set the functor.
155 m_dbg_f.set_function(mod, cb);
156 }
157
158 // Register callback for DMI of fw interface.
159 void
160 register_get_direct_mem_ptr(MODULE *mod, dmi_cb cb)
161 {
162 check_export_binding();
163
164 // Warn if there already is a callback.
165 if (m_dmi_f.is_valid()) {
166 display_warning("DMI callback already registered.");
167 return;
168 }
169
170 // Set the functor.
171 m_dmi_f.set_function(mod, cb);
172 }
173
174
175 // Override virtual functions of the tlm_target_socket:
176 // this function is called whenever an sc_port (as part of a init socket)
177 // wants to bind to the export of the underlying tlm_target_socket
178 // At this time a callback binder is created an returned to the sc_port
179 // of the init socket, so that it binds to the callback binder.
180 virtual tlm::tlm_fw_transport_if<TYPES> &
181 get_base_interface()
182 {
183 // Error if this socket is already bound hierarchically.
184 if (m_hierarch_bind)
185 display_error("Socket already bound hierarchically.");
186
187 if (m_export_callback_created) {
188 // Consume binder created from the callback registration.
189 m_export_callback_created = false;
190 } else {
191 m_binders.push_back(
192 new callback_binder_fw<TYPES>(this, m_binders.size()));
193 }
194
195 return *m_binders[m_binders.size()-1];
196 }
197
198 // Const overload not allowed for multi-sockets.
199 virtual const tlm::tlm_fw_transport_if<TYPES> &
200 get_base_interface() const
201 {
202 display_error("'get_base_interface() const'"
203 " not allowed for multi-sockets.");
204 return base_type::get_base_interface();
205 }
206
207 // Just return the export of the underlying tlm_target_socket in case of
208 // a hierarchical bind.
209 virtual sc_core::sc_export<tlm::tlm_fw_transport_if<TYPES>> &
210 get_base_export()
211 {
212 return *this;
213 }
214
215 // Just return the export of the underlying tlm_target_socket in case of
216 // a hierarchical bind.
217 virtual const sc_core::sc_export<tlm::tlm_fw_transport_if<TYPES>> &
218 get_base_export() const
219 {
220 return base_type::get_base_export();
221 }
222
223 // The standard end of elaboration callback.
224 void
225 end_of_elaboration()
226 {
227 // 'break' here if the socket was told not to do callback binding.
228 if (m_eoe_disabled)
229 return;
230
231 // Get the callback binders and the multi binds of the top of the
232 // hierachical bind chain.
233 // NOTE: this could be the same socket if there is no hierachical
234 // bind.
235 std::vector<callback_binder_fw<TYPES> *> &binders =
236 get_hierarch_bind()->get_binders();
237 std::map<unsigned int, tlm::tlm_bw_transport_if<TYPES> *> &
238 multi_binds = get_hierarch_bind()->get_multi_binds();
239
240 // Complete binding only if there has been a real bind.
241 bool unbound = (binders.size() == 1 && m_export_callback_created);
242 // No call to get_base_interface has consumed the export - ignore.
243 if (unbound)
244 return;
245
246 // Iterate over all binders.
247 for (unsigned int i = 0; i < binders.size(); i++) {
248 // Set the callbacks for the binder.
249 binders[i]->set_callbacks(m_nb_f, m_b_f, m_dmi_f, m_dbg_f);
250 // Check if this connection is multi-multi.
251 if (multi_binds.find(i) != multi_binds.end()) {
252 // If so remember the interface.
253 m_sockets.push_back(multi_binds[i]);
254 } else {
255 // If we are bound to a normal socket.
256 // Get the calling port and try to cast it into a tlm socket
257 // base.
258 base_initiator_socket_type *test =
259 dynamic_cast<base_initiator_socket_type*>(
260 binders[i]->get_other_side());
261 if (!test) {
262 display_error("Not bound to tlm_socket.");
263 }
264 // Remember the interface.
265 m_sockets.push_back(&test->get_base_interface());
266 }
267 }
268 }
269
270 //
271 // Bind multi target socket to multi target socket (hierarchical bind)
272 //
273 virtual void
274 bind(base_type &s)
275 {
276 // Warn if already bound hierarchically.
277 if (m_eoe_disabled) {
278 display_warning("Socket already bound hierarchically. "
279 "Bind attempt ignored.");
280 return;
281 }
282
283 // Disable our own end of elaboration call.
284 disable_cb_bind();
285
286 // Inform the bound target socket that it is bound
287 // hierarchically now.
288 s.set_hierarch_bind((base_type*)this);
289 base_type::bind(s); // Satisfy SystemC.
290 }
291
292 // Operator notation for hierarchical bind.
293 void operator () (base_type &s) { bind(s); }
294
295 // Get access to sub port.
296 tlm::tlm_bw_transport_if<TYPES> *
297 operator [] (int i)
298 {
299 return m_sockets[i];
300 }
301
302 // Get number of bound initiators.
303 // NOTE: this is only valid at end of elaboration!
304 unsigned int size() { return get_hierarch_bind()->get_binders().size(); }
305
306 protected:
307 using base_type::display_warning;
308 using base_type::display_error;
309
310 // Implementation of base class interface.
311 base_type *
312 get_hierarch_bind()
313 {
314 if (m_hierarch_bind)
315 return m_hierarch_bind->get_hierarch_bind();
316 else
317 return this;
318 }
319 std::map<unsigned int, tlm::tlm_bw_transport_if<TYPES> *> &
320 get_multi_binds()
321 {
322 return m_multi_binds;
323 }
324 void set_hierarch_bind(base_type* h) { m_hierarch_bind = h; }
325 tlm::tlm_fw_transport_if<TYPES> *
326 get_last_binder(tlm::tlm_bw_transport_if<TYPES> *other)
327 {
328 m_multi_binds[m_binders.size() - 1] = other;
329 return m_binders[m_binders.size() - 1];
330 }
331
332 // Map that stores to which index a multi init socket is connected
333 // and the interface of the multi init socket.
334 std::map<unsigned int, tlm::tlm_bw_transport_if<TYPES> *> m_multi_binds;
335
336 void disable_cb_bind() { m_eoe_disabled = true; }
337 std::vector<callback_binder_fw<TYPES> *> &
338 get_binders()
339 {
340 return m_binders;
341 }
342 // Vector of connected sockets.
343 std::vector<tlm::tlm_bw_transport_if<TYPES> *> m_sockets;
344 // Vector of binders that convert untagged interface into tagged
345 // interface.
346 std::vector<callback_binder_fw<TYPES> *> m_binders;
347
348 base_type *m_hierarch_bind; // Pointer to hierarchical bound multi port.
349 // bool that disables callback bindings at end of elaboration.
350 bool m_eoe_disabled;
351 // bool that indicates that a binder has been created from a callback
352 // registration.
353 bool m_export_callback_created;
354
355 // callbacks as functors
356 // (allows to pass the callback to another socket that does not know
357 // the type of the module that owns the callbacks).
358 typename callback_binder_fw<TYPES>::nb_func_type m_nb_f;
359 typename callback_binder_fw<TYPES>::b_func_type m_b_f;
360 typename callback_binder_fw<TYPES>::debug_func_type m_dbg_f;
361 typename callback_binder_fw<TYPES>::dmi_func_type m_dmi_f;
362};
363
364template <typename MODULE, unsigned int BUSWIDTH=32,
365 typename TYPES=tlm::tlm_base_protocol_types, unsigned int N=0>
366class multi_passthrough_target_socket_optional :
367 public multi_passthrough_target_socket<
368 MODULE, BUSWIDTH, TYPES, N, sc_core::SC_ZERO_OR_MORE_BOUND>
369{
370 typedef multi_passthrough_target_socket<
371 MODULE, BUSWIDTH, TYPES, N, sc_core::SC_ZERO_OR_MORE_BOUND> socket_b;
372 public:
373 multi_passthrough_target_socket_optional() : socket_b() {}
374 explicit multi_passthrough_target_socket_optional(const char *name) :
375 socket_b(name)
376 {}
377};
378
379} // namespace tlm_utils
380
381#endif /* __SYSTEMC_EXT_TLM_UTILS_MULTI_PASSTHROUGH_TARGET_SOCKET_H__ */
25
26namespace tlm_utils
27{
28
29/*
30This class implements a trivial multi target socket.
31The triviality refers to the fact that the socket does not
32do blocking to non-blocking or non-blocking to blocking conversions.
33
34It allows to connect multiple initiators to this socket.
35The user has to register callbacks for the fw interface methods
36he likes to use. The callbacks are basically equal to the fw interface
37methods but carry an additional integer that indicates to which
38index of this socket the calling initiator is connected.
39*/
40template <typename MODULE, unsigned int BUSWIDTH=32,
41 typename TYPES=tlm::tlm_base_protocol_types, unsigned int N=0,
42 sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND>
43class multi_passthrough_target_socket :
44 public multi_target_base< BUSWIDTH, TYPES, N, POL>,
45 public multi_to_multi_bind_base<TYPES>
46{
47 public:
48 //typedefs
49 // tlm 2.0 types for nb_transport
50 typedef typename TYPES::tlm_payload_type transaction_type;
51 typedef typename TYPES::tlm_phase_type phase_type;
52 typedef tlm::tlm_sync_enum sync_enum_type;
53
54 // typedefs to keep the fn ptr notations short
55 typedef sync_enum_type (MODULE::*nb_cb)(
56 int, transaction_type &, phase_type &, sc_core::sc_time &);
57 typedef void (MODULE::*b_cb)(int, transaction_type &, sc_core::sc_time &);
58 typedef unsigned int (MODULE::*dbg_cb)(int, transaction_type &txn);
59 typedef bool (MODULE::*dmi_cb)(
60 int, transaction_type &txn, tlm::tlm_dmi &dmi);
61
62 typedef multi_target_base<BUSWIDTH, TYPES, N, POL> base_type;
63
64 typedef typename base_type::base_initiator_socket_type
65 base_initiator_socket_type;
66
67 static const char *
68 default_name()
69 {
70 return sc_core::sc_gen_unique_name("multi_passthrough_target_socket");
71 }
72
73 explicit multi_passthrough_target_socket(const char *name=default_name()) :
74 base_type(name), m_hierarch_bind(0), m_eoe_disabled(false),
75 m_export_callback_created(false)
76 {}
77
78 ~multi_passthrough_target_socket()
79 {
80 // Clean up everything allocated by 'new'.
81 for (unsigned int i = 0; i < m_binders.size(); i++)
82 delete m_binders[i];
83 }
84
85 void
86 check_export_binding()
87 {
88 // If our export hasn't been bound yet (due to a hierarch binding)
89 // we bind it now. We do that here as the user of the target port HAS
90 // to bind at least on callback, otherwise the socket was useless.
91 // Nevertheless, the target socket may still stay unbound afterwards.
92 if (!sc_core::sc_export<tlm::tlm_fw_transport_if<TYPES>>::
93 get_interface()) {
94 // We bind to a callback_binder that will be used as the first
95 // interface i.e. calls to the sc_export will have the same ID as
96 // calls from the first initator socket bound.
97 callback_binder_fw<TYPES> *binder;
98
99 if (m_binders.size() == 0) {
100 binder = new callback_binder_fw<TYPES>(
101 this, m_binders.size());
102 m_binders.push_back(binder);
103 m_export_callback_created = true;
104 } else {
105 binder = m_binders[0];
106 }
107
108 sc_core::sc_export<tlm::tlm_fw_transport_if<TYPES>>::bind(*binder);
109 }
110 }
111
112 //register callback for nb transport of fw interface
113 void
114 register_nb_transport_fw(MODULE *mod, nb_cb cb)
115 {
116 check_export_binding();
117
118 // Warn if there already is a callback.
119 if (m_nb_f.is_valid()) {
120 display_warning("NBTransport_bw callback already registered.");
121 return;
122 }
123
124 // Set the functor.
125 m_nb_f.set_function(mod, cb);
126 }
127
128 // Register callback for b transport of fw interface.
129 void
130 register_b_transport(MODULE *mod, b_cb cb)
131 {
132 check_export_binding();
133
134 // Warn if there already is a callback.
135 if (m_b_f.is_valid()) {
136 display_warning("BTransport callback already registered.");
137 return;
138 }
139
140 // Set the functor.
141 m_b_f.set_function(mod, cb);
142 }
143
144 // Register callback for debug transport of fw interface.
145 void
146 register_transport_dbg(MODULE *mod, dbg_cb cb)
147 {
148 check_export_binding();
149
150 // Warn if there already is a callback.
151 if (m_dbg_f.is_valid()) {
152 display_warning("DebugTransport callback already registered.");
153 return;
154 }
155
156 // Set the functor.
157 m_dbg_f.set_function(mod, cb);
158 }
159
160 // Register callback for DMI of fw interface.
161 void
162 register_get_direct_mem_ptr(MODULE *mod, dmi_cb cb)
163 {
164 check_export_binding();
165
166 // Warn if there already is a callback.
167 if (m_dmi_f.is_valid()) {
168 display_warning("DMI callback already registered.");
169 return;
170 }
171
172 // Set the functor.
173 m_dmi_f.set_function(mod, cb);
174 }
175
176
177 // Override virtual functions of the tlm_target_socket:
178 // this function is called whenever an sc_port (as part of a init socket)
179 // wants to bind to the export of the underlying tlm_target_socket
180 // At this time a callback binder is created an returned to the sc_port
181 // of the init socket, so that it binds to the callback binder.
182 virtual tlm::tlm_fw_transport_if<TYPES> &
183 get_base_interface()
184 {
185 // Error if this socket is already bound hierarchically.
186 if (m_hierarch_bind)
187 display_error("Socket already bound hierarchically.");
188
189 if (m_export_callback_created) {
190 // Consume binder created from the callback registration.
191 m_export_callback_created = false;
192 } else {
193 m_binders.push_back(
194 new callback_binder_fw<TYPES>(this, m_binders.size()));
195 }
196
197 return *m_binders[m_binders.size()-1];
198 }
199
200 // Const overload not allowed for multi-sockets.
201 virtual const tlm::tlm_fw_transport_if<TYPES> &
202 get_base_interface() const
203 {
204 display_error("'get_base_interface() const'"
205 " not allowed for multi-sockets.");
206 return base_type::get_base_interface();
207 }
208
209 // Just return the export of the underlying tlm_target_socket in case of
210 // a hierarchical bind.
211 virtual sc_core::sc_export<tlm::tlm_fw_transport_if<TYPES>> &
212 get_base_export()
213 {
214 return *this;
215 }
216
217 // Just return the export of the underlying tlm_target_socket in case of
218 // a hierarchical bind.
219 virtual const sc_core::sc_export<tlm::tlm_fw_transport_if<TYPES>> &
220 get_base_export() const
221 {
222 return base_type::get_base_export();
223 }
224
225 // The standard end of elaboration callback.
226 void
227 end_of_elaboration()
228 {
229 // 'break' here if the socket was told not to do callback binding.
230 if (m_eoe_disabled)
231 return;
232
233 // Get the callback binders and the multi binds of the top of the
234 // hierachical bind chain.
235 // NOTE: this could be the same socket if there is no hierachical
236 // bind.
237 std::vector<callback_binder_fw<TYPES> *> &binders =
238 get_hierarch_bind()->get_binders();
239 std::map<unsigned int, tlm::tlm_bw_transport_if<TYPES> *> &
240 multi_binds = get_hierarch_bind()->get_multi_binds();
241
242 // Complete binding only if there has been a real bind.
243 bool unbound = (binders.size() == 1 && m_export_callback_created);
244 // No call to get_base_interface has consumed the export - ignore.
245 if (unbound)
246 return;
247
248 // Iterate over all binders.
249 for (unsigned int i = 0; i < binders.size(); i++) {
250 // Set the callbacks for the binder.
251 binders[i]->set_callbacks(m_nb_f, m_b_f, m_dmi_f, m_dbg_f);
252 // Check if this connection is multi-multi.
253 if (multi_binds.find(i) != multi_binds.end()) {
254 // If so remember the interface.
255 m_sockets.push_back(multi_binds[i]);
256 } else {
257 // If we are bound to a normal socket.
258 // Get the calling port and try to cast it into a tlm socket
259 // base.
260 base_initiator_socket_type *test =
261 dynamic_cast<base_initiator_socket_type*>(
262 binders[i]->get_other_side());
263 if (!test) {
264 display_error("Not bound to tlm_socket.");
265 }
266 // Remember the interface.
267 m_sockets.push_back(&test->get_base_interface());
268 }
269 }
270 }
271
272 //
273 // Bind multi target socket to multi target socket (hierarchical bind)
274 //
275 virtual void
276 bind(base_type &s)
277 {
278 // Warn if already bound hierarchically.
279 if (m_eoe_disabled) {
280 display_warning("Socket already bound hierarchically. "
281 "Bind attempt ignored.");
282 return;
283 }
284
285 // Disable our own end of elaboration call.
286 disable_cb_bind();
287
288 // Inform the bound target socket that it is bound
289 // hierarchically now.
290 s.set_hierarch_bind((base_type*)this);
291 base_type::bind(s); // Satisfy SystemC.
292 }
293
294 // Operator notation for hierarchical bind.
295 void operator () (base_type &s) { bind(s); }
296
297 // Get access to sub port.
298 tlm::tlm_bw_transport_if<TYPES> *
299 operator [] (int i)
300 {
301 return m_sockets[i];
302 }
303
304 // Get number of bound initiators.
305 // NOTE: this is only valid at end of elaboration!
306 unsigned int size() { return get_hierarch_bind()->get_binders().size(); }
307
308 protected:
309 using base_type::display_warning;
310 using base_type::display_error;
311
312 // Implementation of base class interface.
313 base_type *
314 get_hierarch_bind()
315 {
316 if (m_hierarch_bind)
317 return m_hierarch_bind->get_hierarch_bind();
318 else
319 return this;
320 }
321 std::map<unsigned int, tlm::tlm_bw_transport_if<TYPES> *> &
322 get_multi_binds()
323 {
324 return m_multi_binds;
325 }
326 void set_hierarch_bind(base_type* h) { m_hierarch_bind = h; }
327 tlm::tlm_fw_transport_if<TYPES> *
328 get_last_binder(tlm::tlm_bw_transport_if<TYPES> *other)
329 {
330 m_multi_binds[m_binders.size() - 1] = other;
331 return m_binders[m_binders.size() - 1];
332 }
333
334 // Map that stores to which index a multi init socket is connected
335 // and the interface of the multi init socket.
336 std::map<unsigned int, tlm::tlm_bw_transport_if<TYPES> *> m_multi_binds;
337
338 void disable_cb_bind() { m_eoe_disabled = true; }
339 std::vector<callback_binder_fw<TYPES> *> &
340 get_binders()
341 {
342 return m_binders;
343 }
344 // Vector of connected sockets.
345 std::vector<tlm::tlm_bw_transport_if<TYPES> *> m_sockets;
346 // Vector of binders that convert untagged interface into tagged
347 // interface.
348 std::vector<callback_binder_fw<TYPES> *> m_binders;
349
350 base_type *m_hierarch_bind; // Pointer to hierarchical bound multi port.
351 // bool that disables callback bindings at end of elaboration.
352 bool m_eoe_disabled;
353 // bool that indicates that a binder has been created from a callback
354 // registration.
355 bool m_export_callback_created;
356
357 // callbacks as functors
358 // (allows to pass the callback to another socket that does not know
359 // the type of the module that owns the callbacks).
360 typename callback_binder_fw<TYPES>::nb_func_type m_nb_f;
361 typename callback_binder_fw<TYPES>::b_func_type m_b_f;
362 typename callback_binder_fw<TYPES>::debug_func_type m_dbg_f;
363 typename callback_binder_fw<TYPES>::dmi_func_type m_dmi_f;
364};
365
366template <typename MODULE, unsigned int BUSWIDTH=32,
367 typename TYPES=tlm::tlm_base_protocol_types, unsigned int N=0>
368class multi_passthrough_target_socket_optional :
369 public multi_passthrough_target_socket<
370 MODULE, BUSWIDTH, TYPES, N, sc_core::SC_ZERO_OR_MORE_BOUND>
371{
372 typedef multi_passthrough_target_socket<
373 MODULE, BUSWIDTH, TYPES, N, sc_core::SC_ZERO_OR_MORE_BOUND> socket_b;
374 public:
375 multi_passthrough_target_socket_optional() : socket_b() {}
376 explicit multi_passthrough_target_socket_optional(const char *name) :
377 socket_b(name)
378 {}
379};
380
381} // namespace tlm_utils
382
383#endif /* __SYSTEMC_EXT_TLM_UTILS_MULTI_PASSTHROUGH_TARGET_SOCKET_H__ */