gem5  v20.1.0.0
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 
28 namespace tlm
29 {
30 
31 template <unsigned int BUSWIDTH=32, typename FW_IF=tlm_fw_transport_if<>,
32  typename BW_IF=tlm_bw_transport_if<>>
33 class tlm_base_target_socket_b
34 {
35  public:
36  virtual ~tlm_base_target_socket_b() {}
37 
40  virtual FW_IF &get_base_interface() = 0;
41 };
42 
43 template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF>
44 class tlm_base_initiator_socket_b;
45 
46 template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF, int N,
48 class tlm_base_initiator_socket;
49 
50 template <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>
53 class tlm_base_target_socket :
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 
64  typedef tlm_base_initiator_socket_b<
67 
68  typedef tlm_base_target_socket_b<
70 
71  template <unsigned int, typename, typename, int, sc_core::sc_port_policy>
72  friend class tlm_base_initiator_socket;
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) :
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  virtual void
96  {
97  // initiator.port -> target.export
98  (s.get_base_port())(get_base_interface());
99  // target.port -> initiator.export
100  get_base_port()(s.get_base_interface());
101  }
102 
104 
105  //
106  // Bind target socket to target socket (hierarchical bind)
107  // - Binds both the export and the port
108  //
109  virtual void
110  bind(base_type &s)
111  {
112  // export
113  (get_base_export())(s.get_base_export());
114  // port
115  (s.get_base_port())(get_base_port());
116  }
117 
118  void operator () (base_type &s) { bind(s); }
119 
120  //
121  // Bind interface to socket
122  // - Binds the interface to the export
123  //
124  virtual void
125  bind(fw_interface_type &ifs)
126  {
128  if (this == exp) {
129  export_type::bind(ifs);
130  } else {
131  exp->bind( ifs );
132  }
133  }
134 
136 
137  //
138  // Forward to 'size()' of port class.
139  //
140  int size() const { return m_port.size(); }
141 
142  //
143  // Forward to 'operator->()' of port class.
144  //
145  bw_interface_type *operator->() { return m_port.operator->(); }
146 
147  //
148  // Forward to 'operator[]()' of port class.
149  //
150  bw_interface_type *operator[](int i) { return m_port.operator[](i); }
151 
152  // Implementation of tlm_base_socket_if functions.
153  virtual sc_core::sc_port_base &get_port_base() { return m_port; }
154  virtual sc_core::sc_port_base const &
155  get_port_base() const
156  {
157  return m_port;
158  }
159  virtual sc_core::sc_export_base &get_export_base() { return *this; }
160  virtual sc_core::sc_export_base const &
161  get_export_base() const
162  {
163  return *this;
164  }
165  virtual unsigned int get_bus_width() const { return BUSWIDTH; }
166  virtual tlm_socket_category
168  {
169  return TLM_TARGET_SOCKET;
170  }
171 
172  // Implementation of tlm_base_target_socket_b functions
173  virtual sc_core::sc_port_b<BW_IF> &get_base_port() { return m_port; }
174  virtual sc_core::sc_port_b<BW_IF> const &
175  get_base_port() const
176  {
177  return m_port;
178  }
179 
180  virtual FW_IF &get_base_interface() { return *this; }
181  virtual FW_IF const &get_base_interface() const { return *this; }
182 
183  virtual sc_core::sc_export<FW_IF> &get_base_export() { return *this; }
185  get_base_export() const
186  {
187  return *this;
188  }
189 
190  protected:
192 };
193 
194 template <unsigned int BUSWIDTH=32, typename TYPES=tlm_base_protocol_types,
196 class tlm_target_socket :
198  BUSWIDTH, tlm_fw_transport_if<TYPES>,
199  tlm_bw_transport_if<TYPES>, N, POL>
200 {
201  public:
204  BUSWIDTH, tlm_fw_transport_if<TYPES>,
205  tlm_bw_transport_if<TYPES>, N, POL>()
206  {}
207 
208  explicit tlm_target_socket(const char *name) :
210  BUSWIDTH, tlm_fw_transport_if<TYPES>,
211  tlm_bw_transport_if<TYPES>, N, POL>(name)
212  {}
213 
214  virtual const char* kind() const { return "tlm_target_socket"; }
215 
216  virtual std::type_index
217  get_protocol_types() const
218  {
219  return typeid(TYPES);
220  }
221 };
222 
223 } // namespace tlm
224 
225 #endif /* __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_TARGET_SOCKET_HH__ */
sc_core::sc_port_b
Definition: sc_port.hh:118
tlm::tlm_base_target_socket_b::get_base_port
virtual sc_core::sc_port_b< BW_IF > & get_base_port()=0
sc_core::sc_port_base
Definition: sc_port.hh:74
tlm::tlm_bw_transport_if
Definition: fw_bw_ifs.hh:231
sc_core::SC_ONE_OR_MORE_BOUND
@ SC_ONE_OR_MORE_BOUND
Definition: sc_port.hh:69
tlm::tlm_base_target_socket_b::get_base_interface
virtual FW_IF & get_base_interface()=0
SignalInterruptBwIf
Definition: signal_interrupt.hh:45
tlm::tlm_base_target_socket::kind
virtual const char * kind() const
Definition: target_socket.hh:102
sc_core::sc_export_base
Definition: sc_export.hh:41
sc_core::sc_port< bw_interface_type, N, POL >
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
tlm::tlm_target_socket
Definition: target_socket.hh:213
sc_core
Definition: messages.cc:31
tlm::tlm_base_target_socket::base_type
tlm_base_target_socket_b< BUSWIDTH, fw_interface_type, bw_interface_type > base_type
Definition: target_socket.hh:86
tlm::tlm_base_target_socket::get_port_base
virtual sc_core::sc_port_base & get_port_base()
Definition: target_socket.hh:170
SignalInterruptFwIf
Definition: signal_interrupt.hh:37
tlm::tlm_target_socket::get_protocol_types
virtual std::type_index get_protocol_types() const
Definition: target_socket.hh:234
base_socket_if.hh
tlm::tlm_base_target_socket
Definition: initiator_socket.hh:69
tlm::tlm_base_target_socket::base_initiator_socket_type
tlm_base_initiator_socket_b< BUSWIDTH, fw_interface_type, bw_interface_type > base_initiator_socket_type
Definition: target_socket.hh:83
tlm::tlm_base_target_socket::operator()
void operator()(base_initiator_socket_type &s)
Definition: target_socket.hh:120
tlm::tlm_base_target_socket::export_type
sc_core::sc_export< fw_interface_type > export_type
Definition: target_socket.hh:80
tlm::tlm_base_target_socket::get_base_port
virtual sc_core::sc_port_b< BW_IF > & get_base_port()
Definition: target_socket.hh:190
tlm::tlm_fw_transport_if
Definition: fw_bw_ifs.hh:221
tlm::tlm_base_target_socket::fw_interface_type
FW_IF fw_interface_type
Definition: target_socket.hh:76
tlm::tlm_base_initiator_socket_b
Definition: initiator_socket.hh:51
tlm::tlm_base_target_socket::get_bus_width
virtual unsigned int get_bus_width() const
Definition: target_socket.hh:182
tlm::TLM_TARGET_SOCKET
@ TLM_TARGET_SOCKET
Definition: base_socket_if.hh:69
tlm::tlm_base_target_socket::tlm_base_target_socket
tlm_base_target_socket()
Definition: target_socket.hh:92
tlm::tlm_base_target_socket::m_port
port_type m_port
Definition: target_socket.hh:208
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_target_socket::operator->
bw_interface_type * operator->()
Definition: target_socket.hh:162
tlm::tlm_target_socket::tlm_target_socket
tlm_target_socket()
Definition: target_socket.hh:219
tlm::tlm_target_socket::kind
virtual const char * kind() const
Definition: target_socket.hh:231
name
const std::string & name()
Definition: trace.cc:50
tlm::tlm_base_target_socket_b::get_base_export
virtual sc_core::sc_export< FW_IF > & get_base_export()=0
sc_core::sc_export::bind
virtual void bind(IF &i)
Definition: sc_export.hh:75
tlm::tlm_base_target_socket::bw_interface_type
BW_IF bw_interface_type
Definition: target_socket.hh:77
std
Overload hash function for BasicBlockRange type.
Definition: vec_reg.hh:587
tlm::tlm_base_target_socket::port_type
sc_core::sc_port< bw_interface_type, N, POL > port_type
Definition: target_socket.hh:78
tlm::tlm_base_protocol_types
Definition: fw_bw_ifs.hh:213
tlm::tlm_base_target_socket::get_base_export
virtual sc_core::sc_export< FW_IF > & get_base_export()
Definition: target_socket.hh:200
ArmISA::s
Bitfield< 4 > s
Definition: miscregs_types.hh:556
sc_core::sc_export
Definition: sc_export.hh:60
tlm::tlm_base_target_socket::bind
virtual void bind(base_initiator_socket_type &s)
Definition: target_socket.hh:112
tlm::tlm_base_target_socket::operator[]
bw_interface_type * operator[](int i)
Definition: target_socket.hh:167
tlm::tlm_base_target_socket::size
int size() const
Definition: target_socket.hh:157
sc_core::sc_port_base::size
int size() const
Definition: sc_port.cc:107
tlm::tlm_base_target_socket::get_base_interface
virtual FW_IF & get_base_interface()
Definition: target_socket.hh:197
tlm::tlm_base_initiator_socket
Definition: initiator_socket.hh:78
tlm::tlm_base_target_socket_b::~tlm_base_target_socket_b
virtual ~tlm_base_target_socket_b()
Definition: target_socket.hh:70
tlm::tlm_base_target_socket::get_export_base
virtual sc_core::sc_export_base & get_export_base()
Definition: target_socket.hh:176
tlm::tlm_base_target_socket::get_socket_category
virtual tlm_socket_category get_socket_category() const
Definition: target_socket.hh:184

Generated on Wed Sep 30 2020 14:02:16 for gem5 by doxygen 1.8.17