gem5 v24.1.0.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
target_socket.hh
Go to the documentation of this file.
1/*****************************************************************************
2
3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4 more contributor license agreements. See the NOTICE file distributed
5 with this work for additional information regarding copyright ownership.
6 Accellera licenses this file to you under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with the
8 License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15 implied. See the License for the specific language governing
16 permissions and limitations under the License.
17
18 *****************************************************************************/
19
20#ifndef __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_TARGET_SOCKET_HH__
21#define __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_TARGET_SOCKET_HH__
22
23#include <typeindex>
24
25#include "../interfaces/fw_bw_ifs.hh"
26#include "base_socket_if.hh"
27
28namespace tlm
29{
30
31template <unsigned int BUSWIDTH=32, typename FW_IF=tlm_fw_transport_if<>,
32 typename BW_IF=tlm_bw_transport_if<>>
42
43template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF>
45
46template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF, int N,
49
50template <unsigned int BUSWIDTH=32, typename FW_IF=tlm_fw_transport_if<>,
51 typename BW_IF=tlm_bw_transport_if<>, int N=1,
52 sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND>
54 public tlm_base_socket_if,
55 public tlm_base_target_socket_b<BUSWIDTH, FW_IF, BW_IF>,
56 public sc_core::sc_export<FW_IF>
57{
58 public:
59 typedef FW_IF fw_interface_type;
60 typedef BW_IF bw_interface_type;
62
67
70
71 template <unsigned int, typename, typename, int, sc_core::sc_port_policy>
73
74 public:
76 export_type(sc_core::sc_gen_unique_name("tlm_base_target_socket")),
77 m_port(sc_core::sc_gen_unique_name("tlm_base_target_socket_port"))
78 {}
79
80 explicit tlm_base_target_socket(const char *name) :
81 export_type(name), m_port(sc_core::sc_gen_unique_name(
82 (std::string(name) + "_port").c_str()))
83 {}
84
85 virtual const char *kind() const { return "tlm_base_target_socket"; }
86
87 //
88 // Bind target socket to initiator socket
89 // - Binds the port of the initiator socket to the export of the target
90 // socket
91 // - Binds the port of the target socket to the export of the initiator
92 // socket
93 //
94
95#pragma GCC diagnostic push
103#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 13))
104#pragma GCC diagnostic ignored "-Woverloaded-virtual"
105#endif
106 virtual void
108 {
109 // initiator.port -> target.export
110 (s.get_base_port())(get_base_interface());
111 // target.port -> initiator.export
112 get_base_port()(s.get_base_interface());
113 }
114
116
117 //
118 // Bind target socket to target socket (hierarchical bind)
119 // - Binds both the export and the port
120 //
121 virtual void
123 {
124 // export
125 (get_base_export())(s.get_base_export());
126 // port
127 (s.get_base_port())(get_base_port());
128 }
129
130 void operator () (base_type &s) { bind(s); }
131
132 //
133 // Bind interface to socket
134 // - Binds the interface to the export
135 //
136 virtual void
138 {
140 if (this == exp) {
142 } else {
143 exp->bind( ifs );
144 }
145 }
146
148#pragma GCC diagnostic pop
149
150 //
151 // Forward to 'size()' of port class.
152 //
153 int size() const { return m_port.size(); }
154
155 //
156 // Forward to 'operator->()' of port class.
157 //
158 bw_interface_type *operator->() { return m_port.operator->(); }
159
160 //
161 // Forward to 'operator[]()' of port class.
162 //
163 bw_interface_type *operator[](int i) { return m_port.operator[](i); }
164
165 // Implementation of tlm_base_socket_if functions.
167 virtual sc_core::sc_port_base const &
169 {
170 return m_port;
171 }
172 virtual sc_core::sc_export_base &get_export_base() { return *this; }
173 virtual sc_core::sc_export_base const &
175 {
176 return *this;
177 }
178 virtual unsigned int get_bus_width() const { return BUSWIDTH; }
179 virtual tlm_socket_category
181 {
182 return TLM_TARGET_SOCKET;
183 }
184
185 // Implementation of tlm_base_target_socket_b functions
187 virtual sc_core::sc_port_b<BW_IF> const &
189 {
190 return m_port;
191 }
192
193 virtual FW_IF &get_base_interface() { return *this; }
194 virtual FW_IF const &get_base_interface() const { return *this; }
195
196 virtual sc_core::sc_export<FW_IF> &get_base_export() { return *this; }
197 virtual sc_core::sc_export<FW_IF> const &
199 {
200 return *this;
201 }
202
203 protected:
205};
206
207template <unsigned int BUSWIDTH=32, typename TYPES=tlm_base_protocol_types,
211 BUSWIDTH, tlm_fw_transport_if<TYPES>,
212 tlm_bw_transport_if<TYPES>, N, POL>
213{
214 public:
217 BUSWIDTH, tlm_fw_transport_if<TYPES>,
218 tlm_bw_transport_if<TYPES>, N, POL>()
219 {}
220
221 explicit tlm_target_socket(const char *name) :
223 BUSWIDTH, tlm_fw_transport_if<TYPES>,
224 tlm_bw_transport_if<TYPES>, N, POL>(name)
225 {}
226
227 virtual const char* kind() const { return "tlm_target_socket"; }
228
229 virtual std::type_index
231 {
232 return typeid(TYPES);
233 }
234};
235
236} // namespace tlm
237
238#endif /* __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_TARGET_SOCKET_HH__ */
virtual void bind(IF &i)
Definition sc_export.hh:86
const char * name() const
Definition sc_object.cc:44
virtual FW_IF & get_base_interface()=0
virtual sc_core::sc_port_b< BW_IF > & get_base_port()=0
virtual sc_core::sc_export< FW_IF > & get_base_export()=0
bw_interface_type * operator->()
virtual sc_core::sc_port_base const & get_port_base() const
tlm_base_initiator_socket_b< BUSWIDTH, fw_interface_type, bw_interface_type > base_initiator_socket_type
virtual void bind(base_initiator_socket_type &s)
The following warning is disabled because the bind methods are overloaded in the derived class and th...
virtual FW_IF & get_base_interface()
virtual tlm_socket_category get_socket_category() const
virtual FW_IF const & get_base_interface() const
tlm_base_target_socket(const char *name)
tlm_base_target_socket_b< BUSWIDTH, fw_interface_type, bw_interface_type > base_type
virtual void bind(base_type &s)
bw_interface_type * operator[](int i)
virtual sc_core::sc_export_base const & get_export_base() const
void operator()(base_initiator_socket_type &s)
virtual sc_core::sc_export< FW_IF > & get_base_export()
virtual sc_core::sc_port_b< BW_IF > & get_base_port()
virtual sc_core::sc_export< FW_IF > const & get_base_export() const
virtual unsigned int get_bus_width() const
virtual sc_core::sc_export_base & get_export_base()
virtual sc_core::sc_port_base & get_port_base()
sc_core::sc_port< bw_interface_type, N, POL > port_type
virtual const char * kind() const
sc_core::sc_export< fw_interface_type > export_type
virtual sc_core::sc_port_b< BW_IF > const & get_base_port() const
virtual void bind(fw_interface_type &ifs)
virtual const char * kind() const
virtual std::type_index get_protocol_types() const
tlm_target_socket(const char *name)
sc_port_policy
Definition sc_port.hh:68
@ SC_ONE_OR_MORE_BOUND
Definition sc_port.hh:69
Overload hash function for BasicBlockRange type.
Definition binary32.hh:81
tlm_socket_category
@ TLM_TARGET_SOCKET
const std::string & name()
Definition trace.cc:48

Generated on Mon Jan 13 2025 04:28:43 for gem5 by doxygen 1.9.8