scc  2022.4.0
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 template <typename SIG = bool, typename TYPES = tlm_signal_baseprotocol_types<SIG>, int N = 1,
58  sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
60 : public tlm_base_initiator_socket<0, tlm_signal_fw_transport_if<SIG, TYPES>, tlm_signal_bw_transport_if<SIG, TYPES>, N, POL> {
61  using tlm_signal_type = SIG;
62  using protocol_types = TYPES;
63  using transaction_type = typename TYPES::tlm_payload_type;
64  using phase_type = typename TYPES::tlm_phase_type;
65 
67  : tlm_base_initiator_socket<0, tlm_signal_fw_transport_if<SIG, TYPES>, tlm_signal_bw_transport_if<SIG, TYPES>, N, POL>() {}
68 
69  explicit tlm_signal_initiator_socket(const char* name)
70  : tlm_base_initiator_socket<0, tlm_signal_fw_transport_if<SIG, TYPES>, tlm_signal_bw_transport_if<SIG, TYPES>, N, POL>(name) {}
71 
72  virtual const char* kind() const { return "tlm_signal_initiator_socket"; }
73 
74  virtual sc_core::sc_type_index get_protocol_types() const { return typeid(TYPES); }
75 };
76 
77 template <typename SIG = bool, typename TYPES = tlm_signal_baseprotocol_types<SIG>, int N = 1>
78 using tlm_signal_opt_initiator_socket = struct tlm_signal_initiator_socket<SIG, TYPES, N, sc_core::SC_ZERO_OR_MORE_BOUND>;
79 
80 template <typename SIG = bool, typename TYPES = tlm_signal_baseprotocol_types<SIG>, int N = 1,
81  sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
83 : public ::tlm::tlm_base_target_socket<0, tlm_signal_fw_transport_if<SIG, TYPES>, tlm_signal_bw_transport_if<SIG, TYPES>, N, POL> {
84  using tlm_signal_type = SIG;
85  using protocol_types = TYPES;
86  using transaction_type = typename TYPES::tlm_payload_type;
87  using phase_type = typename TYPES::tlm_phase_type;
88 
90  : tlm_base_target_socket<0, tlm_signal_fw_transport_if<TYPES>, tlm_signal_bw_transport_if<TYPES>, N, POL>() {}
91 
92  explicit tlm_signal_target_socket(const char* name)
93  : tlm_base_target_socket<0, tlm_signal_fw_transport_if<SIG, TYPES>, tlm_signal_bw_transport_if<SIG, TYPES>, N, POL>(name) {}
94 
95  virtual const char* kind() const { return "tlm_signal_target_socket"; }
96 
97  virtual sc_core::sc_type_index get_protocol_types() const { return typeid(TYPES); }
98 };
99 
100 template <typename SIG = bool, typename TYPES = tlm_signal_baseprotocol_types<SIG>, int N = 1>
101 using tlm_signal_opt_target_socket = struct tlm_signal_target_socket<SIG, TYPES, N, sc_core::SC_ZERO_OR_MORE_BOUND>;
102 } // namespace scc
103 } // namespace tlm
104 
105 #endif /* _TLM_TLM_SIGNAL_SOCKETS_H_ */
SCC SystemC utilities.
SystemC TLM.