scc 2025.09
SystemC components library
tlm_network_sockets.h
Go to the documentation of this file.
1/*******************************************************************************
2 * Copyright 2024 MINRES Technologies GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *******************************************************************************/
16
17#ifndef _TLM_NW_TLM_NETWORK_SOCKETS_H_
18#define _TLM_NW_TLM_NETWORK_SOCKETS_H_
19
20#include "tlm_network_gp.h"
21#include <sysc/kernel/sc_object.h>
22#include <tlm/scc/tlm_mm.h>
23#ifdef CWR_SYSTEMC
24#include <tlm_h/tlm_sockets/tlm_initiator_socket.h>
25#include <tlm_h/tlm_sockets/tlm_target_socket.h>
26#else
27#include <tlm>
28#endif
36
42namespace tlm {
43namespace nw {
44
45template <typename SIG> class tlm_network_gp;
46
48 using tlm_payload_type = tlm_network_payload_base;
49 using tlm_phase_type = ::tlm::tlm_phase;
50};
51
57DECLARE_EXTENDED_PHASE(INDICATION);
59
60template <typename TYPES = tlm_network_baseprotocol_types>
61struct tlm_network_fw_transport_if : public virtual tlm::tlm_blocking_transport_if<typename TYPES::tlm_payload_type>,
62 public virtual tlm::tlm_fw_nonblocking_transport_if<typename TYPES::tlm_payload_type>,
63 public virtual tlm::tlm_transport_dbg_if<typename TYPES::tlm_payload_type> {
64 typedef TYPES protocol_types;
65};
66
67template <typename TYPES = tlm_network_baseprotocol_types>
68struct tlm_network_bw_transport_if : public virtual tlm::tlm_bw_nonblocking_transport_if<typename TYPES::tlm_payload_type> {
69 typedef TYPES protocol_types;
70};
71
72#if SC_VERSION_MAJOR < 3
73using type_index = sc_core::sc_type_index;
74#else
75using type_index = std::type_index;
76#endif
77
85template <unsigned PHITWIDTH, typename CMDENUM, typename TYPES = tlm_network_baseprotocol_types, int N = 1,
86 sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
88: public tlm_base_initiator_socket<0, tlm_network_fw_transport_if<TYPES>, tlm_network_bw_transport_if<TYPES>, N, POL> {
89
90 using protocol_types = TYPES;
91 using transaction_type = typename TYPES::tlm_payload_type;
92 using phase_type = typename TYPES::tlm_phase_type;
93
94 using base_class = tlm_base_initiator_socket<0, tlm_network_fw_transport_if<TYPES>, tlm_network_bw_transport_if<TYPES>, N, POL>;
95
96 using fw_interface_type = tlm_network_fw_transport_if<TYPES>;
97 using bw_interface_type = tlm_network_bw_transport_if<TYPES>;
98
99 using port_type = sc_core::sc_port<fw_interface_type, N, POL>;
100 using export_type = sc_core::sc_export<bw_interface_type>;
107 : tlm_base_initiator_socket<0, tlm_network_fw_transport_if<TYPES>, tlm_network_bw_transport_if<TYPES>, N, POL>() {}
108
115 explicit tlm_network_initiator_socket(const char* name)
116 : tlm_base_initiator_socket<0, tlm_network_fw_transport_if<TYPES>, tlm_network_bw_transport_if<TYPES>, N, POL>(name) {}
117
120 virtual ~tlm_network_initiator_socket() = default;
124 virtual const char* kind() const { return "tlm_network_initiator_socket"; }
128 virtual type_index get_protocol_types() const { return typeid(TYPES); }
129};
130
137template <unsigned PHITWIDTH, typename CMDENUM, typename TYPES = tlm_network_baseprotocol_types, int N = 1,
138 sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
140: public ::tlm::tlm_base_target_socket<0, tlm_network_fw_transport_if<TYPES>, tlm_network_bw_transport_if<TYPES>, N, POL> {
141
142 using protocol_types = TYPES;
143 using transaction_type = typename TYPES::tlm_payload_type;
144 using phase_type = typename TYPES::tlm_phase_type;
151 : tlm_base_target_socket<0, tlm_network_fw_transport_if<TYPES>, tlm_network_bw_transport_if<TYPES>, N, POL>() {}
152
157 explicit tlm_network_target_socket(const char* name)
158 : tlm_base_target_socket<0, tlm_network_fw_transport_if<TYPES>, tlm_network_bw_transport_if<TYPES>, N, POL>(name) {}
159
162 virtual ~tlm_network_target_socket() = default;
166 virtual const char* kind() const { return "tlm_network_target_socket"; }
170 virtual type_index get_protocol_types() const { return typeid(TYPES); }
171};
172} // namespace nw
173namespace scc {
175 using mm_if_type = tlm::nw::tlm_base_mm_interface;
176 using payload_base = tlm::nw::tlm_network_payload_base;
177};
178
179} // namespace scc
180} // namespace tlm
181
182#endif /* _TLM_NW_TLM_NETWORK_SOCKETS_H_ */
SCC TLM utilities.
SCC TLM utilities.
Definition cxs_tlm.h:544
DECLARE_EXTENDED_PHASE(REQUEST)
Definition of the additional protocol phases.
SystemC TLM.
Definition dmi_mgr.h:19
tlm_network_initiator_socket(const char *name)
Constructor with specified name.
tlm_network_initiator_socket()
Constructor with default name.
virtual ~tlm_network_initiator_socket()=default
virtual type_index get_protocol_types() const
A base class for TLM network payloads.
tlm_network_target_socket(const char *name)
Constructor with name.
virtual ~tlm_network_target_socket()=default
tlm_network_target_socket()
Constructor with default name.
virtual const char * kind() const
virtual type_index get_protocol_types() const