gem5  v19.0.0.0
tlm_port_wrapper.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2018 Google, Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met: redistributions of source code must retain the above copyright
7  * notice, this list of conditions and the following disclaimer;
8  * redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution;
11  * neither the name of the copyright holders nor the names of its
12  * contributors may be used to endorse or promote products derived from
13  * this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  * Authors: Gabe Black
28  */
29 
30 #ifndef __SYSTEMC_TLM_PORT_WRAPPER_HH__
31 #define __SYSTEMC_TLM_PORT_WRAPPER_HH__
32 
33 #include "base/logging.hh"
34 #include "sim/port.hh"
36 
37 namespace sc_gem5
38 {
39 
40 template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF, int N,
43 
44 template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF, int N,
47 
48 template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF, int N,
50 class TlmInitiatorBaseWrapper : public ::Port
51 {
52  public:
57 
59 
61  InitiatorSocket &i, const std::string &_name, PortID _id) :
62  Port(_name, _id), _initiator(i)
63  {}
64 
65  void
66  bind(::Port &peer) override
67  {
68  auto *target = dynamic_cast<TargetWrapper *>(&peer);
69  fatal_if(!target, "Attempt to bind TLM initiator socket %s to "
70  "incompatible port %s.", name(), peer.name());
71 
72  initiator().bind(target->target());
73  Port::bind(peer);
74  }
75 
76  void
77  unbind() override
78  {
79  panic("TLM sockets can't be unbound.");
80  }
81 
82  private:
84 };
85 
86 template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF, int N,
88 class TlmTargetBaseWrapper : public ::Port
89 {
90  public:
93 
94  TargetSocket &target() { return _target; }
95 
96  TlmTargetBaseWrapper(TargetSocket &t, const std::string &_name,
97  PortID _id) :
98  Port(_name, _id), _target(t)
99  {}
100 
101  void
102  bind(::Port &peer) override
103  {
104  // Ignore attempts to bind a target socket. The initiator will
105  // handle it.
106  Port::bind(peer);
107  }
108 
109  void
110  unbind() override
111  {
112  panic("TLM sockets can't be unbound.");
113  }
114 
115  private:
117 };
118 
119 template <unsigned int BUSWIDTH=32,
120  typename TYPES=tlm::tlm_base_protocol_types, int N=1,
122 using TlmInitiatorWrapper =
125 
126 template <unsigned int BUSWIDTH=32,
127  typename TYPES=tlm::tlm_base_protocol_types, int N=1,
129 using TlmTargetWrapper =
132 
133 } // namespace sc_gem5
134 
135 #endif //__SYSTEMC_TLM_PORT_WRAPPER_HH__
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:167
Bitfield< 7 > i
tlm::tlm_base_target_socket< BUSWIDTH, FW_IF, BW_IF, N, POL > TargetSocket
void unbind() override
Dettach from a peer port.
TlmTargetBaseWrapper(TargetSocket &t, const std::string &_name, PortID _id)
tlm::tlm_base_initiator_socket< BUSWIDTH, FW_IF, BW_IF, N, POL > InitiatorSocket
InitiatorSocket::base_target_socket_type TargetSocket
virtual void bind(base_target_socket_type &s)
void bind(::Port &peer) override
void bind(::Port &peer) override
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Definition: logging.hh:203
TlmTargetBaseWrapper< BUSWIDTH, FW_IF, BW_IF, N, POL > TargetWrapper
Port Object Declaration.
sc_port_policy
Definition: sc_port.hh:69
TlmInitiatorBaseWrapper(InitiatorSocket &i, const std::string &_name, PortID _id)
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:106
void bind(::sc_core::sc_interface *interface)
Definition: port.hh:140
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
Bitfield< 5 > t
void unbind() override
Dettach from a peer port.

Generated on Fri Feb 28 2020 16:27:05 for gem5 by doxygen 1.8.13