gem5 v24.0.0.0
Loading...
Searching...
No Matches
passthrough_target_socket.h
Go to the documentation of this file.
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
20#ifndef __SYSTEMC_EXT_TLM_UTILS_PASSTHROUGH_TARGET_SOCKET_H__
21#define __SYSTEMC_EXT_TLM_UTILS_PASSTHROUGH_TARGET_SOCKET_H__
22
23#include "../core/sc_port.hh"
24#include "../core/sc_time.hh"
28
29namespace tlm_utils
30{
31
32template <typename MODULE, unsigned int BUSWIDTH, typename TYPES,
35 public tlm::tlm_target_socket<BUSWIDTH, TYPES, 1, POL>,
37{
38 public:
39 typedef typename TYPES::tlm_payload_type transaction_type;
40 typedef typename TYPES::tlm_phase_type phase_type;
45
46 public:
47 static const char *
49 {
50 return sc_core::sc_gen_unique_name("passthrough_target_socket");
51 }
52
53 explicit passthrough_target_socket_b(const char *n=default_name()) :
54 base_type(n), m_process(this)
55 {
57 }
58
59 using base_type::bind;
60
61 // REGISTER_XXX
62 void
65 sc_core::sc_time &))
66 {
68 }
69
70 void
72 void (MODULE::*cb)(transaction_type &, sc_core::sc_time &))
73 {
75 }
76
77 void
79 unsigned int (MODULE::*cb)(transaction_type &))
80 {
82 }
83
84 void
86 bool (MODULE::*cb)(transaction_type &, tlm::tlm_dmi &))
87 {
89 }
90
91 private:
92 class process : public tlm::tlm_fw_transport_if<TYPES>,
94 {
95 public:
96 typedef sync_enum_type (MODULE::*NBTransportPtr)(
97 transaction_type &, phase_type &, sc_core::sc_time &);
98 typedef void (MODULE::*BTransportPtr)(
99 transaction_type &, sc_core::sc_time &);
100 typedef unsigned int (MODULE::*TransportDbgPtr)(transaction_type &);
101 typedef bool (MODULE::*GetDirectMem_ptr)(
102 transaction_type &, tlm::tlm_dmi &);
103
109
110 void
112 {
113 if (m_nb_transport_ptr) {
114 display_warning("non-blocking callback already registered");
115 return;
116 }
117 sc_assert(!m_mod || m_mod == mod);
118 m_mod = mod;
120 }
121
122 void
124 {
125 if (m_b_transport_ptr) {
126 display_warning("blocking callback already registered");
127 return;
128 }
129 sc_assert(!m_mod || m_mod == mod);
130 m_mod = mod;
132 }
133
134 void
136 {
138 display_warning("debug callback already registered");
139 return;
140 }
141 sc_assert(!m_mod || m_mod == mod);
142 m_mod = mod;
144 }
145
146 void
148 {
151 "get DMI pointer callback already registered");
152 return;
153 }
154 sc_assert(!m_mod || m_mod == mod);
155 m_mod = mod;
157 }
158
160 transaction_type &trans, phase_type &phase,
162 {
163 if (m_nb_transport_ptr) {
164 // Forward call.
166 return (m_mod->*m_nb_transport_ptr)(trans, phase, t);
167 }
168 display_error("no non-blocking callback registered");
169 return tlm::TLM_COMPLETED;
170 }
171
172 void
174 {
175 if (m_b_transport_ptr) {
176 // Forward call.
178 return (m_mod->*m_b_transport_ptr)(trans, t);
179 }
180 display_error("no blocking callback registered");
181 }
182
183 unsigned int
185 {
187 // Forward call.
189 return (m_mod->*m_transport_dbg_ptr)(trans);
190 }
191 // No debug support
192 return 0;
193 }
194
195 bool
197 {
199 // Forward call.
201 return (m_mod->*m_get_direct_mem_ptr)(trans, dmi_data);
202 }
203 // No DMI support
204 dmi_data.allow_read_write();
205 dmi_data.set_start_address(0x0);
206 dmi_data.set_end_address((sc_dt::uint64)-1);
207 return false;
208 }
209
210 private:
211 MODULE *m_mod;
216 };
217
218 private:
219 const sc_core::sc_object *get_socket() const { return this; }
220
221 private:
223};
224
225template <typename MODULE, unsigned int BUSWIDTH=32,
226 typename TYPES=tlm::tlm_base_protocol_types>
235
236template <typename MODULE, unsigned int BUSWIDTH=32,
237 typename TYPES=tlm::tlm_base_protocol_types>
240 MODULE, BUSWIDTH, TYPES, sc_core::SC_ZERO_OR_MORE_BOUND>
241{
243 MODULE, BUSWIDTH, TYPES, sc_core::SC_ZERO_OR_MORE_BOUND> socket_b;
244 public:
247 socket_b(name) {}
248};
249
250// ID Tagged version
251template <typename MODULE, unsigned int BUSWIDTH, typename TYPES,
254 public tlm::tlm_target_socket<BUSWIDTH, TYPES, 1, POL>,
256{
257 public:
258 typedef typename TYPES::tlm_payload_type transaction_type;
259 typedef typename TYPES::tlm_phase_type phase_type;
264
265 static const char *
267 {
269 "passthrough_target_socket_tagged");
270 }
271
272 public:
274 const char *n=default_name()) : base_type(n), m_process(this)
275 {
277 }
278
279 using base_type::bind;
280
281 // REGISTER_XXX
282 void
284 sync_enum_type (MODULE::*cb)(int id, transaction_type &,
285 phase_type &, sc_core::sc_time &),
286 int id)
287 {
290 }
291
292 void
294 void (MODULE::*cb)(int id, transaction_type &,
295 sc_core::sc_time &),
296 int id)
297 {
300 }
301
302 void
304 unsigned int (MODULE::*cb)(int id, transaction_type &), int id)
305 {
308 }
309
310 void
312 bool (MODULE::*cb)(int id, transaction_type &, tlm::tlm_dmi &),
313 int id)
314 {
317 }
318
319 private:
320 class process : public tlm::tlm_fw_transport_if<TYPES>,
322 {
323 public:
324 typedef sync_enum_type (MODULE::*NBTransportPtr)(
325 int id, transaction_type &, phase_type &, sc_core::sc_time &);
326 typedef void (MODULE::*BTransportPtr)(
327 int id, transaction_type &, sc_core::sc_time &);
328 typedef unsigned int (MODULE::*TransportDbgPtr)(
329 int id, transaction_type &);
330 typedef bool (MODULE::*GetDirectMem_ptr)(
331 int id, transaction_type &, tlm::tlm_dmi &);
332
340
341 void
346 void
348 {
350 }
351 void
356 void
358 {
360 }
361
362 void
364 {
365 if (m_nb_transport_ptr) {
366 display_warning("non-blocking callback already registered");
367 return;
368 }
369 sc_assert(!m_mod || m_mod == mod);
370 m_mod = mod;
372 }
373
374 void
376 {
377 if (m_b_transport_ptr) {
378 display_warning("blocking callback already registered");
379 return;
380 }
381 sc_assert(!m_mod || m_mod == mod);
382 m_mod = mod;
384 }
385
386 void
388 {
390 display_warning("debug callback already registered");
391 return;
392 }
393 sc_assert(!m_mod || m_mod == mod);
394 m_mod = mod;
396 }
397
398 void
400 {
403 "get DMI pointer callback already registered");
404 return;
405 }
406 sc_assert(!m_mod || m_mod == mod);
407 m_mod = mod;
409 }
410
414 {
415 if (m_nb_transport_ptr) {
416 // Forward call.
418 return (m_mod->*m_nb_transport_ptr)(
419 m_nb_transport_user_id, trans, phase, t);
420 }
421 display_error("no non-blocking callback registered");
422 return tlm::TLM_COMPLETED;
423 }
424
425 void
427 {
428 if (m_b_transport_ptr) {
429 // Forward call.
431 return (m_mod->*m_b_transport_ptr)(
432 m_b_transport_user_id, trans, t);
433 }
434 display_error("no blocking callback registered");
435 }
436
437 unsigned int
439 {
441 // Forward call.
443 return (m_mod->*m_transport_dbg_ptr)(
445 }
446 // No debug support.
447 return 0;
448 }
449
450 bool
452 {
454 // Forward call.
456 return (m_mod->*m_get_direct_mem_ptr)(
457 m_get_dmi_user_id, trans, dmi_data);
458 }
459 // No DMI support
460 dmi_data.allow_read_write();
461 dmi_data.set_start_address(0x0);
462 dmi_data.set_end_address((sc_dt::uint64)-1);
463 return false;
464 }
465
466 private:
467 MODULE *m_mod;
476 };
477
478 private:
479 const sc_core::sc_object *get_socket() const { return this; }
480
481 private:
483};
484
485template <typename MODULE, unsigned int BUSWIDTH=32,
486 typename TYPES=tlm::tlm_base_protocol_types>
498
499template <typename MODULE, unsigned int BUSWIDTH=32,
500 typename TYPES=tlm::tlm_base_protocol_types>
503 MODULE, BUSWIDTH, TYPES, sc_core::SC_ZERO_OR_MORE_BOUND>
504{
506 MODULE, BUSWIDTH, TYPES, sc_core::SC_ZERO_OR_MORE_BOUND> socket_b;
507 public:
511 {}
512};
513
514} // namespace tlm_utils
515
516#endif /* __SYSTEMC_EXT_TLM_UTILS_PASSTHROUGH_TARGET_SOCKET_H__ */
virtual void bind(tlm_fw_transport_if< tlm_base_protocol_types > &i)
Definition sc_export.hh:75
void set_start_address(sc_dt::uint64 addr)
Definition dmi.hh:82
void set_end_address(sc_dt::uint64 addr)
Definition dmi.hh:83
void allow_read_write()
Definition dmi.hh:90
unsigned int(MODULE::* TransportDbgPtr)(transaction_type &)
sync_enum_type nb_transport_fw(transaction_type &trans, phase_type &phase, sc_core::sc_time &t)
void(MODULE::* BTransportPtr)(transaction_type &, sc_core::sc_time &)
void set_transport_dbg_ptr(MODULE *mod, TransportDbgPtr p)
void set_get_direct_mem_ptr(MODULE *mod, GetDirectMem_ptr p)
void b_transport(transaction_type &trans, sc_core::sc_time &t)
unsigned int transport_dbg(transaction_type &trans)
sync_enum_type(MODULE::* NBTransportPtr)(transaction_type &, phase_type &, sc_core::sc_time &)
void set_nb_transport_ptr(MODULE *mod, NBTransportPtr p)
bool(MODULE::* GetDirectMem_ptr)(transaction_type &, tlm::tlm_dmi &)
bool get_direct_mem_ptr(transaction_type &trans, tlm::tlm_dmi &dmi_data)
tlm::tlm_bw_transport_if< TYPES > bw_interface_type
void register_transport_dbg(MODULE *mod, unsigned int(MODULE::*cb)(transaction_type &))
void register_get_direct_mem_ptr(MODULE *mod, bool(MODULE::*cb)(transaction_type &, tlm::tlm_dmi &))
passthrough_target_socket_b(const char *n=default_name())
tlm::tlm_target_socket< BUSWIDTH, TYPES, 1, POL > base_type
tlm::tlm_fw_transport_if< TYPES > fw_interface_type
void register_nb_transport_fw(MODULE *mod, sync_enum_type(MODULE::*cb)(transaction_type &, phase_type &, sc_core::sc_time &))
const sc_core::sc_object * get_socket() const
void register_b_transport(MODULE *mod, void(MODULE::*cb)(transaction_type &, sc_core::sc_time &))
passthrough_target_socket_b< MODULE, BUSWIDTH, TYPES, sc_core::SC_ZERO_OR_MORE_BOUND > socket_b
sync_enum_type nb_transport_fw(transaction_type &trans, phase_type &phase, sc_core::sc_time &t)
void(MODULE::* BTransportPtr)(int id, transaction_type &, sc_core::sc_time &)
bool(MODULE::* GetDirectMem_ptr)(int id, transaction_type &, tlm::tlm_dmi &)
void b_transport(transaction_type &trans, sc_core::sc_time &t)
bool get_direct_mem_ptr(transaction_type &trans, tlm::tlm_dmi &dmi_data)
sync_enum_type(MODULE::* NBTransportPtr)(int id, transaction_type &, phase_type &, sc_core::sc_time &)
unsigned int(MODULE::* TransportDbgPtr)(int id, transaction_type &)
tlm::tlm_target_socket< BUSWIDTH, TYPES, 1, POL > base_type
void register_transport_dbg(MODULE *mod, unsigned int(MODULE::*cb)(int id, transaction_type &), int id)
passthrough_target_socket_tagged_b(const char *n=default_name())
void register_nb_transport_fw(MODULE *mod, sync_enum_type(MODULE::*cb)(int id, transaction_type &, phase_type &, sc_core::sc_time &), int id)
void register_b_transport(MODULE *mod, void(MODULE::*cb)(int id, transaction_type &, sc_core::sc_time &), int id)
void register_get_direct_mem_ptr(MODULE *mod, bool(MODULE::*cb)(int id, transaction_type &, tlm::tlm_dmi &), int id)
passthrough_target_socket_tagged_b< MODULE, BUSWIDTH, TYPES, sc_core::SC_ZERO_OR_MORE_BOUND > socket_b
passthrough_target_socket_tagged_b< MODULE, BUSWIDTH, TYPES > socket_b
passthrough_target_socket_b< MODULE, BUSWIDTH, TYPES > socket_b
sc_port_policy
Definition sc_port.hh:68
@ SC_ZERO_OR_MORE_BOUND
Definition sc_port.hh:70
@ SC_ONE_OR_MORE_BOUND
Definition sc_port.hh:69
const char * sc_gen_unique_name(const char *seed)
Definition sc_module.cc:820
uint64_t uint64
Definition sc_nbdefs.hh:172
tlm_sync_enum
Definition fw_bw_ifs.hh:31
@ TLM_COMPLETED
Definition fw_bw_ifs.hh:31
#define sc_assert(expr)
const std::string & name()
Definition trace.cc:48

Generated on Tue Jun 18 2024 16:24:07 for gem5 by doxygen 1.11.0