gem5 v24.1.0.1
Loading...
Searching...
No Matches
initiator_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_INITIATOR_SOCKET_HH__
21#define __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_INITIATOR_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,
32 typename FW_IF=tlm_fw_transport_if<>,
33 typename BW_IF=tlm_bw_transport_if<>>
35{
36 public:
38
40 virtual sc_core::sc_port_b<FW_IF> const &get_base_port() const = 0;
41 virtual BW_IF &get_base_interface() = 0;
42 virtual BW_IF const &get_base_interface() const = 0;
44 virtual sc_core::sc_export<BW_IF> const &get_base_export() const = 0;
45};
46
47template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF>
49
50template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF, int N,
53
54template <unsigned int BUSWIDTH=32, typename FW_IF=tlm_fw_transport_if<>,
55 typename BW_IF=tlm_bw_transport_if<>, int N=1,
56 sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND>
58 public tlm_base_socket_if,
59 public tlm_base_initiator_socket_b<BUSWIDTH, FW_IF, BW_IF>,
60 public sc_core::sc_port<FW_IF, N, POL>
61{
62 public:
63 typedef FW_IF fw_interface_type;
64 typedef BW_IF bw_interface_type;
66
68
74
75 template <unsigned int, typename, typename, int, sc_core::sc_port_policy>
77
78 public:
80 port_type(sc_core::sc_gen_unique_name("tlm_base_initiator_socket")),
81 m_export(sc_core::sc_gen_unique_name(
82 "tlm_base_initiator_socket_export"))
83 {}
84
85 explicit tlm_base_initiator_socket(const char *name) : port_type(name),
86 m_export(sc_core::sc_gen_unique_name(
87 (std::string(name) + "_export").c_str()))
88 {}
89
90 virtual const char* kind() const { return "tlm_base_initiator_socket"; }
91
92 //
93 // Bind initiator socket to target socket
94 // - Binds the port of the initiator socket to the export of the target
95 // socket
96 // - Binds the port of the target socket to the export of the initiator
97 // socket
98 //
99
100#pragma GCC diagnostic push
108#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 13))
109#pragma GCC diagnostic ignored "-Woverloaded-virtual"
110#endif
111 virtual void
113 {
114 // initiator.port -> target.export
115 (get_base_port())(s.get_base_interface());
116 // target.port -> initiator.export
117 (s.get_base_port())(get_base_interface());
118 }
119
121
122 //
123 // Bind initiator socket to initiator socket (hierarchical bind)
124 // - Binds both the export and the port
125 //
126 virtual void
128 {
129 // port
130 (get_base_port())(s.get_base_port());
131 // export
132 (s.get_base_export())(get_base_export());
133 }
134
135 void operator() (base_type &s) { bind(s); }
136
137 //
138 // Bind interface to socket
139 // - Binds the interface to the export of this socket
140 //
141 virtual void bind(bw_interface_type &ifs) { (get_base_export())(ifs); }
143#pragma GCC diagnostic pop
144
145 // Implementation of tlm_base_socket_if functions
146 virtual sc_core::sc_port_base &get_port_base() { return *this; }
147 virtual sc_core::sc_port_base const &
149 {
150 return *this;
151 }
153 virtual sc_core::sc_export_base const &
155 {
156 return m_export;
157 }
158 virtual unsigned int get_bus_width() const { return BUSWIDTH; }
159 virtual tlm_socket_category
161 {
163 }
164
165 // Implementation of tlm_base_target_socket_b functions
166 virtual sc_core::sc_port_b<FW_IF> &get_base_port() { return *this; }
167 virtual sc_core::sc_port_b<FW_IF> const &
169 {
170 return *this;
171 }
172
173 virtual BW_IF &get_base_interface() { return m_export; }
174 virtual BW_IF const &get_base_interface() const { return m_export; }
175
177 virtual sc_core::sc_export<BW_IF> const &
179 {
180 return m_export;
181 }
182
183 protected:
185};
186
187//
188// Convenience socket classes
189//
190
191template <unsigned int BUSWIDTH=32, typename TYPES=tlm_base_protocol_types,
194 BUSWIDTH, tlm_fw_transport_if<TYPES>,
195 tlm_bw_transport_if<TYPES>, N, POL>
196{
197 public:
199 BUSWIDTH, tlm_fw_transport_if<TYPES>,
200 tlm_bw_transport_if<TYPES>, N, POL>()
201 {}
202
203 explicit tlm_initiator_socket(const char *name) :
205 tlm_bw_transport_if<TYPES>, N, POL>(name)
206 {}
207
208 virtual const char *kind() const { return "tlm_initiator_socket"; }
209
210 virtual std::type_index
212 {
213 return typeid(TYPES);
214 }
215};
216
217} // namespace tlm
218
219#endif /* __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_INITIATOR_SOCKET_HH__ */
virtual sc_core::sc_export< BW_IF > const & get_base_export() const =0
virtual sc_core::sc_export< BW_IF > & get_base_export()=0
virtual BW_IF const & get_base_interface() const =0
virtual sc_core::sc_port_b< FW_IF > & get_base_port()=0
virtual sc_core::sc_port_b< FW_IF > const & get_base_port() const =0
virtual BW_IF & get_base_interface()=0
virtual void bind(base_type &s)
virtual BW_IF const & get_base_interface() const
sc_core::sc_export< bw_interface_type > export_type
virtual sc_core::sc_export< BW_IF > & get_base_export()
tlm_base_initiator_socket_b< BUSWIDTH, fw_interface_type, bw_interface_type > base_type
tlm_base_initiator_socket(const char *name)
virtual sc_core::sc_port_base & get_port_base()
virtual void bind(base_target_socket_type &s)
The following warning is disabled because the bind methods are overloaded in the derived class and th...
virtual void bind(bw_interface_type &ifs)
virtual sc_core::sc_port_b< FW_IF > const & get_base_port() const
sc_core::sc_port< fw_interface_type, N, POL > port_type
tlm_base_target_socket_b< BUSWIDTH, fw_interface_type, bw_interface_type > base_target_socket_type
virtual sc_core::sc_export_base const & get_export_base() const
virtual sc_core::sc_export_base & get_export_base()
virtual sc_core::sc_port_base const & get_port_base() const
virtual unsigned int get_bus_width() const
virtual tlm_socket_category get_socket_category() const
virtual const char * kind() const
virtual sc_core::sc_export< BW_IF > const & get_base_export() const
void operator()(base_target_socket_type &s)
virtual sc_core::sc_port_b< FW_IF > & get_base_port()
virtual const char * kind() const
tlm_initiator_socket(const char *name)
virtual std::type_index get_protocol_types() const
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_INITIATOR_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