gem5  v21.2.0.0
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 
28 namespace tlm
29 {
30 
31 template <unsigned int BUSWIDTH=32,
32  typename FW_IF=tlm_fw_transport_if<>,
33  typename BW_IF=tlm_bw_transport_if<>>
34 class tlm_base_initiator_socket_b
35 {
36  public:
37  virtual ~tlm_base_initiator_socket_b() {}
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 
47 template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF>
48 class tlm_base_target_socket_b;
49 
50 template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF, int N,
53 
54 // The overloaded virtual is intended in SystemC, so we'll disable the warning.
55 // Please check section 9.3 of SystemC 2.3.1 release note for more details.
56 #pragma GCC diagnostic push
57 #pragma GCC diagnostic ignored "-Woverloaded-virtual"
58 template <unsigned int BUSWIDTH=32, typename FW_IF=tlm_fw_transport_if<>,
59  typename BW_IF=tlm_bw_transport_if<>, int N=1,
60  sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND>
62  public tlm_base_socket_if,
63  public tlm_base_initiator_socket_b<BUSWIDTH, FW_IF, BW_IF>,
64  public sc_core::sc_port<FW_IF, N, POL>
65 {
66  public:
67  typedef FW_IF fw_interface_type;
68  typedef BW_IF bw_interface_type;
70 
72 
78 
79  template <unsigned int, typename, typename, int, sc_core::sc_port_policy>
80  friend class tlm_base_target_socket;
81 
82  public:
84  port_type(sc_core::sc_gen_unique_name("tlm_base_initiator_socket")),
86  "tlm_base_initiator_socket_export"))
87  {}
88 
89  explicit tlm_base_initiator_socket(const char *name) : port_type(name),
91  (std::string(name) + "_export").c_str()))
92  {}
93 
94  virtual const char* kind() const { return "tlm_base_initiator_socket"; }
95 
96  //
97  // Bind initiator socket to target socket
98  // - Binds the port of the initiator socket to the export of the target
99  // socket
100  // - Binds the port of the target socket to the export of the initiator
101  // socket
102  //
103  virtual void
105  {
106  // initiator.port -> target.export
107  (get_base_port())(s.get_base_interface());
108  // target.port -> initiator.export
109  (s.get_base_port())(get_base_interface());
110  }
111 
113 
114  //
115  // Bind initiator socket to initiator socket (hierarchical bind)
116  // - Binds both the export and the port
117  //
118  virtual void
119  bind(base_type &s)
120  {
121  // port
122  (get_base_port())(s.get_base_port());
123  // export
124  (s.get_base_export())(get_base_export());
125  }
126 
127  void operator() (base_type &s) { bind(s); }
128 
129  //
130  // Bind interface to socket
131  // - Binds the interface to the export of this socket
132  //
133  virtual void bind(bw_interface_type &ifs) { (get_base_export())(ifs); }
134  void operator() (bw_interface_type &s) { bind(s); }
135 
136  // Implementation of tlm_base_socket_if functions
137  virtual sc_core::sc_port_base &get_port_base() { return *this; }
138  virtual sc_core::sc_port_base const &
139  get_port_base() const
140  {
141  return *this;
142  }
143  virtual sc_core::sc_export_base &get_export_base() { return m_export; }
144  virtual sc_core::sc_export_base const &
145  get_export_base() const
146  {
147  return m_export;
148  }
149  virtual unsigned int get_bus_width() const { return BUSWIDTH; }
152  {
153  return TLM_INITIATOR_SOCKET;
154  }
155 
156  // Implementation of tlm_base_target_socket_b functions
157  virtual sc_core::sc_port_b<FW_IF> &get_base_port() { return *this; }
158  virtual sc_core::sc_port_b<FW_IF> const &
159  get_base_port() const
160  {
161  return *this;
162  }
163 
164  virtual BW_IF &get_base_interface() { return m_export; }
165  virtual BW_IF const &get_base_interface() const { return m_export; }
166 
167  virtual sc_core::sc_export<BW_IF> &get_base_export() { return m_export; }
169  get_base_export() const
170  {
171  return m_export;
172  }
173 
174  protected:
176 };
177 #pragma GCC diagnostic pop
178 
179 //
180 // Convenience socket classes
181 //
182 
183 template <unsigned int BUSWIDTH=32, typename TYPES=tlm_base_protocol_types,
186  BUSWIDTH, tlm_fw_transport_if<TYPES>,
187  tlm_bw_transport_if<TYPES>, N, POL>
188 {
189  public:
191  BUSWIDTH, tlm_fw_transport_if<TYPES>,
193  {}
194 
195  explicit tlm_initiator_socket(const char *name) :
197  tlm_bw_transport_if<TYPES>, N, POL>(name)
198  {}
199 
200  virtual const char *kind() const { return "tlm_initiator_socket"; }
201 
202  virtual std::type_index
203  get_protocol_types() const
204  {
205  return typeid(TYPES);
206  }
207 };
208 
209 } // namespace tlm
210 
211 #endif /* __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_INITIATOR_SOCKET_HH__ */
sc_core::sc_port_b
Definition: sc_port.hh:118
sc_core::sc_port_base
Definition: sc_port.hh:74
tlm::tlm_bw_transport_if<>
tlm::tlm_base_initiator_socket::base_type
tlm_base_initiator_socket_b< BUSWIDTH, fw_interface_type, bw_interface_type > base_type
Definition: initiator_socket.hh:94
sc_core::SC_ONE_OR_MORE_BOUND
@ SC_ONE_OR_MORE_BOUND
Definition: sc_port.hh:69
tlm::tlm_base_initiator_socket::tlm_base_initiator_socket
tlm_base_initiator_socket()
Definition: initiator_socket.hh:100
sc_core::sc_export_base
Definition: sc_export.hh:41
sc_core::sc_port
Definition: sc_port.hh:249
sc_core
Definition: messages.cc:31
tlm::tlm_initiator_socket
Definition: initiator_socket.hh:202
base_socket_if.hh
tlm::tlm_base_target_socket
Definition: initiator_socket.hh:69
tlm::tlm_base_initiator_socket::get_base_interface
virtual BW_IF & get_base_interface()
Definition: initiator_socket.hh:181
tlm::TLM_INITIATOR_SOCKET
@ TLM_INITIATOR_SOCKET
Definition: base_socket_if.hh:68
tlm::tlm_base_initiator_socket::m_export
export_type m_export
Definition: initiator_socket.hh:192
tlm::tlm_fw_transport_if<>
tlm::tlm_base_initiator_socket_b
Definition: initiator_socket.hh:51
tlm::tlm_base_initiator_socket::fw_interface_type
FW_IF fw_interface_type
Definition: initiator_socket.hh:84
tlm::tlm_base_initiator_socket::get_base_export
virtual sc_core::sc_export< BW_IF > & get_base_export()
Definition: initiator_socket.hh:184
tlm::tlm_initiator_socket::get_protocol_types
virtual std::type_index get_protocol_types() const
Definition: initiator_socket.hh:220
tlm::tlm_base_initiator_socket::operator()
void operator()(base_target_socket_type &s)
Definition: initiator_socket.hh:129
gem5::ArmISA::s
Bitfield< 4 > s
Definition: misc_types.hh:562
tlm::tlm_base_initiator_socket::port_type
sc_core::sc_port< fw_interface_type, N, POL > port_type
Definition: initiator_socket.hh:86
tlm::tlm_initiator_socket::tlm_initiator_socket
tlm_initiator_socket()
Definition: initiator_socket.hh:207
tlm::tlm_base_initiator_socket::base_target_socket_type
tlm_base_target_socket_b< BUSWIDTH, fw_interface_type, bw_interface_type > base_target_socket_type
Definition: initiator_socket.hh:92
sc_core::sc_gen_unique_name
const char * sc_gen_unique_name(const char *seed)
Definition: sc_module.cc:820
tlm::tlm_socket_category
tlm_socket_category
Definition: base_socket_if.hh:48
sc_core::sc_port_policy
sc_port_policy
Definition: sc_port.hh:67
tlm
Definition: analysis_fifo.hh:27
tlm::tlm_base_initiator_socket::get_socket_category
virtual tlm_socket_category get_socket_category() const
Definition: initiator_socket.hh:168
tlm::tlm_base_target_socket_b
Definition: initiator_socket.hh:65
tlm::tlm_initiator_socket::kind
virtual const char * kind() const
Definition: initiator_socket.hh:217
tlm::tlm_base_initiator_socket_b::get_base_interface
virtual BW_IF & get_base_interface()=0
tlm::tlm_base_initiator_socket::get_export_base
virtual sc_core::sc_export_base & get_export_base()
Definition: initiator_socket.hh:160
tlm::tlm_base_initiator_socket::bind
virtual void bind(base_target_socket_type &s)
Definition: initiator_socket.hh:121
std
Overload hash function for BasicBlockRange type.
Definition: types.hh:111
tlm::tlm_base_protocol_types
Definition: fw_bw_ifs.hh:213
sc_core::sc_object::name
const char * name() const
Definition: sc_object.cc:44
tlm::tlm_base_initiator_socket::export_type
sc_core::sc_export< bw_interface_type > export_type
Definition: initiator_socket.hh:88
tlm::tlm_base_initiator_socket::get_bus_width
virtual unsigned int get_bus_width() const
Definition: initiator_socket.hh:166
tlm::tlm_base_initiator_socket::get_base_port
virtual sc_core::sc_port_b< FW_IF > & get_base_port()
Definition: initiator_socket.hh:174
tlm::tlm_base_socket_if
Definition: base_socket_if.hh:60
tlm::tlm_base_initiator_socket_b::~tlm_base_initiator_socket_b
virtual ~tlm_base_initiator_socket_b()
Definition: initiator_socket.hh:71
sc_core::sc_export
Definition: sc_export.hh:60
tlm::tlm_base_initiator_socket_b::get_base_export
virtual sc_core::sc_export< BW_IF > & get_base_export()=0
tlm::tlm_base_initiator_socket::bw_interface_type
BW_IF bw_interface_type
Definition: initiator_socket.hh:85
tlm::tlm_base_initiator_socket::kind
virtual const char * kind() const
Definition: initiator_socket.hh:111
tlm::tlm_base_initiator_socket_b::get_base_port
virtual sc_core::sc_port_b< FW_IF > & get_base_port()=0
tlm::tlm_base_initiator_socket
Definition: initiator_socket.hh:78
tlm::tlm_base_initiator_socket::get_port_base
virtual sc_core::sc_port_base & get_port_base()
Definition: initiator_socket.hh:154

Generated on Tue Dec 21 2021 11:34:37 for gem5 by doxygen 1.8.17