scc  2024.06
SystemC components library
tlm_signal_sockets.h
1 /*******************************************************************************
2  * Copyright 2018-2022 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_TLM_SIGNAL_SOCKETS_H_
18 #define _TLM_TLM_SIGNAL_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_core/tlm_2/tlm_sockets/tlm_initiator_socket.h>
28 #include <tlm_core/tlm_2/tlm_sockets/tlm_target_socket.h>
29 #endif
30 
32 namespace tlm {
34 namespace scc {
35 
36 template <typename SIG> class tlm_signal_gp;
37 
38 template <typename SIG = bool> struct tlm_signal_baseprotocol_types {
39  using tlm_signal_type = SIG;
41  using tlm_phase_type = ::tlm::tlm_phase;
42 };
43 
44 template <typename SIG = bool, typename TYPES = tlm_signal_baseprotocol_types<SIG>>
45 struct tlm_signal_fw_transport_if : public virtual sc_core::sc_interface {
46  typedef TYPES protocol_types;
47  // virtual void b_transport(typename TYPES::tlm_payload_type&, sc_core::sc_time&) = 0;
48  virtual ::tlm::tlm_sync_enum nb_transport_fw(typename TYPES::tlm_payload_type&, ::tlm::tlm_phase&, sc_core::sc_time&) = 0;
49 };
50 
51 template <typename SIG = bool, typename TYPES = tlm_signal_baseprotocol_types<SIG>>
52 struct tlm_signal_bw_transport_if : public virtual sc_core::sc_interface {
53  typedef TYPES protocol_types;
54  virtual ::tlm::tlm_sync_enum nb_transport_bw(typename TYPES::tlm_payload_type&, ::tlm::tlm_phase&, sc_core::sc_time&) = 0;
55 };
56 
57 #if SC_VERSION_MAJOR < 3
58 using type_index = sc_core::sc_type_index;
59 #else
60 using type_index = std::type_index;
61 #endif
62 
63 template <typename SIG = bool, typename TYPES = tlm_signal_baseprotocol_types<SIG>, int N = 1,
64  sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
66 : public tlm_base_initiator_socket<0, tlm_signal_fw_transport_if<SIG, TYPES>, tlm_signal_bw_transport_if<SIG, TYPES>, N, POL> {
67  using tlm_signal_type = SIG;
68  using protocol_types = TYPES;
69  using transaction_type = typename TYPES::tlm_payload_type;
70  using phase_type = typename TYPES::tlm_phase_type;
71 
73  : tlm_base_initiator_socket<0, tlm_signal_fw_transport_if<SIG, TYPES>, tlm_signal_bw_transport_if<SIG, TYPES>, N, POL>() {}
74 
75  explicit tlm_signal_initiator_socket(const char* name)
76  : tlm_base_initiator_socket<0, tlm_signal_fw_transport_if<SIG, TYPES>, tlm_signal_bw_transport_if<SIG, TYPES>, N, POL>(name) {}
77 
78  virtual const char* kind() const { return "tlm_signal_initiator_socket"; }
79 
80  virtual type_index get_protocol_types() const { return typeid(TYPES); }
81 };
82 
83 template <typename SIG = bool, typename TYPES = tlm_signal_baseprotocol_types<SIG>, int N = 1>
84 using tlm_signal_opt_initiator_socket = struct tlm_signal_initiator_socket<SIG, TYPES, N, sc_core::SC_ZERO_OR_MORE_BOUND>;
85 
86 template <typename SIG = bool, typename TYPES = tlm_signal_baseprotocol_types<SIG>, int N = 1,
87  sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
89 : public ::tlm::tlm_base_target_socket<0, tlm_signal_fw_transport_if<SIG, TYPES>, tlm_signal_bw_transport_if<SIG, TYPES>, N, POL> {
90  using tlm_signal_type = SIG;
91  using protocol_types = TYPES;
92  using transaction_type = typename TYPES::tlm_payload_type;
93  using phase_type = typename TYPES::tlm_phase_type;
94 
96  : tlm_base_target_socket<0, tlm_signal_fw_transport_if<TYPES>, tlm_signal_bw_transport_if<TYPES>, N, POL>() {}
97 
98  explicit tlm_signal_target_socket(const char* name)
99  : tlm_base_target_socket<0, tlm_signal_fw_transport_if<SIG, TYPES>, tlm_signal_bw_transport_if<SIG, TYPES>, N, POL>(name) {}
100 
101  virtual const char* kind() const { return "tlm_signal_target_socket"; }
102 
103  virtual type_index get_protocol_types() const { return typeid(TYPES); }
104 };
105 
106 template <typename SIG = bool, typename TYPES = tlm_signal_baseprotocol_types<SIG>, int N = 1>
107 using tlm_signal_opt_target_socket = struct tlm_signal_target_socket<SIG, TYPES, N, sc_core::SC_ZERO_OR_MORE_BOUND>;
108 } // namespace scc
109 } // namespace tlm
110 
111 #endif /* _TLM_TLM_SIGNAL_SOCKETS_H_ */
SCC TLM utilities.
SystemC TLM.
Definition: cxs_tlm.h:69