scc  2024.06
SystemC components library
tlm_network_sockets.h
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 "scc/report.h"
21 
22 #include <sysc/kernel/sc_object.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
29 
31 namespace tlm {
33 namespace nw {
34 
35 template <typename SIG> class tlm_network_gp;
36 
39  using tlm_phase_type = ::tlm::tlm_phase;
40 };
41 
46 DECLARE_EXTENDED_PHASE(CONFIRM);
47 DECLARE_EXTENDED_PHASE(INDICATION);
48 DECLARE_EXTENDED_PHASE(RESPONSE);
49 
50 template <typename TYPES = tlm_network_baseprotocol_types>
51 struct tlm_network_fw_transport_if : public virtual tlm::tlm_blocking_transport_if<typename TYPES::tlm_payload_type>,
52  public virtual tlm::tlm_fw_nonblocking_transport_if<typename TYPES::tlm_payload_type>,
53  public virtual tlm::tlm_transport_dbg_if<typename TYPES::tlm_payload_type> {
54  typedef TYPES protocol_types;
55 };
56 
57 template <typename TYPES = tlm_network_baseprotocol_types>
58 struct tlm_network_bw_transport_if : public virtual tlm::tlm_bw_nonblocking_transport_if<typename TYPES::tlm_payload_type> {
59  typedef TYPES protocol_types;
60 };
61 
62 #if SC_VERSION_MAJOR < 3
63 using type_index = sc_core::sc_type_index;
64 #else
65 using type_index = std::type_index;
66 #endif
67 
68 template <unsigned PHITWIDTH, typename CMDENUM, typename TYPES = tlm_network_baseprotocol_types, int N = 1,
69  sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
71 : public tlm_base_initiator_socket<0, tlm_network_fw_transport_if<TYPES>, tlm_network_bw_transport_if<TYPES>, N, POL> {
72 
73  using protocol_types = TYPES;
74  using transaction_type = typename TYPES::tlm_payload_type;
75  using phase_type = typename TYPES::tlm_phase_type;
76 
78  : tlm_base_initiator_socket<0, tlm_network_fw_transport_if<TYPES>, tlm_network_bw_transport_if<TYPES>, N, POL>() {}
79 
80  explicit tlm_network_initiator_socket(const char* name)
81  : tlm_base_initiator_socket<0, tlm_network_fw_transport_if<TYPES>, tlm_network_bw_transport_if<TYPES>, N, POL>(name) {}
82 
83  virtual ~tlm_network_initiator_socket() = default;
84 
85  virtual const char* kind() const { return "tlm_network_initiator_socket"; }
86 
87  virtual type_index get_protocol_types() const { return typeid(TYPES); }
88 };
89 
90 template <unsigned PHITWIDTH, typename CMDENUM, typename TYPES = tlm_network_baseprotocol_types, int N = 1,
91  sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
93 : public ::tlm::tlm_base_target_socket<0, tlm_network_fw_transport_if<TYPES>, tlm_network_bw_transport_if<TYPES>, N, POL> {
94 
95  using protocol_types = TYPES;
96  using transaction_type = typename TYPES::tlm_payload_type;
97  using phase_type = typename TYPES::tlm_phase_type;
98 
100  : tlm_base_target_socket<0, tlm_network_fw_transport_if<TYPES>, tlm_network_bw_transport_if<TYPES>, N, POL>() {}
101 
102  explicit tlm_network_target_socket(const char* name)
103  : tlm_base_target_socket<0, tlm_network_fw_transport_if<TYPES>, tlm_network_bw_transport_if<TYPES>, N, POL>(name) {}
104 
105  virtual const char* kind() const { return "tlm_network_target_socket"; }
106 
107  virtual type_index get_protocol_types() const { return typeid(TYPES); }
108 };
109 } // namespace nw
110 } // namespace tlm
111 
112 #endif /* _TLM_NW_TLM_NETWORK_SOCKETS_H_ */
DECLARE_EXTENDED_PHASE(REQUEST)
SystemC TLM.
Definition: cxs_tlm.h:69