scc 2025.09
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
32namespace tlm {
34namespace scc {
35
36template <typename SIG> class tlm_signal_gp;
37
38template <typename SIG = bool> struct tlm_signal_baseprotocol_types {
39 using tlm_signal_type = SIG;
40 using tlm_payload_type = tlm_signal_gp<tlm_signal_type>;
41 using tlm_phase_type = ::tlm::tlm_phase;
42};
43
44template <typename SIG = bool, typename TYPES = tlm_signal_baseprotocol_types<SIG>>
45struct 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
51template <typename SIG = bool, typename TYPES = tlm_signal_baseprotocol_types<SIG>>
52struct 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
58using type_index = sc_core::sc_type_index;
59#else
60using type_index = std::type_index;
61#endif
62
63template <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>
65struct tlm_signal_initiator_socket
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
72 tlm_signal_initiator_socket()
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
83template <typename SIG = bool, typename TYPES = tlm_signal_baseprotocol_types<SIG>, int N = 1>
84using tlm_signal_opt_initiator_socket = struct tlm_signal_initiator_socket<SIG, TYPES, N, sc_core::SC_ZERO_OR_MORE_BOUND>;
85
86template <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>
88struct tlm_signal_target_socket
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
95 tlm_signal_target_socket()
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
106template <typename SIG = bool, typename TYPES = tlm_signal_baseprotocol_types<SIG>, int N = 1>
107using 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.
Definition axis_tlm.h:56
SystemC TLM.
Definition dmi_mgr.h:19