gem5  v21.1.0.2
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 
28 #ifndef __SYSTEMC_TLM_PORT_WRAPPER_HH__
29 #define __SYSTEMC_TLM_PORT_WRAPPER_HH__
30 
31 #include "base/logging.hh"
32 #include "sim/port.hh"
34 
35 namespace sc_gem5
36 {
37 
38 template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF, int N,
41 
42 template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF, int N,
45 
46 template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF, int N,
49 {
50  public:
55 
57 
59  InitiatorSocket &i, const std::string &_name, gem5::PortID _id) :
60  gem5::Port(_name, _id), _initiator(i)
61  {}
62 
63  void
64  bind(gem5::Port &peer) override
65  {
66  using namespace gem5;
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  gem5::Port::bind(peer);
74  }
75 
76  void
77  unbind() override
78  {
79  using namespace gem5;
80 
81  panic("TLM sockets can't be unbound.");
82  }
83 
84  private:
86 };
87 
88 template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF, int N,
90 class TlmTargetBaseWrapper : public gem5::Port
91 {
92  public:
95 
96  TargetSocket &target() { return _target; }
97 
98  TlmTargetBaseWrapper(TargetSocket &t, const std::string &_name,
99  gem5::PortID _id) :
100  gem5::Port(_name, _id), _target(t)
101  {}
102 
103  void
104  bind(gem5::Port &peer) override
105  {
106  // Ignore attempts to bind a target socket. The initiator will
107  // handle it.
108  gem5::Port::bind(peer);
109  }
110 
111  void
112  unbind() override
113  {
114  using namespace gem5;
115 
116  panic("TLM sockets can't be unbound.");
117  }
118 
119  private:
121 };
122 
123 template <unsigned int BUSWIDTH=32,
124  typename TYPES=tlm::tlm_base_protocol_types, int N=1,
126 using TlmInitiatorWrapper =
129 
130 template <unsigned int BUSWIDTH=32,
131  typename TYPES=tlm::tlm_base_protocol_types, int N=1,
133 using TlmTargetWrapper =
136 
137 } // namespace sc_gem5
138 
139 #endif //__SYSTEMC_TLM_PORT_WRAPPER_HH__
sc_gem5::TlmInitiatorBaseWrapper::TlmInitiatorBaseWrapper
TlmInitiatorBaseWrapper(InitiatorSocket &i, const std::string &_name, gem5::PortID _id)
Definition: tlm_port_wrapper.hh:58
sc_gem5::TlmInitiatorBaseWrapper::initiator
InitiatorSocket & initiator()
Definition: tlm_port_wrapper.hh:56
gem5::PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:252
tlm::tlm_bw_transport_if
Definition: fw_bw_ifs.hh:231
sc_gem5::TlmTargetBaseWrapper::_target
TargetSocket & _target
Definition: tlm_port_wrapper.hh:120
sc_core::SC_ONE_OR_MORE_BOUND
@ SC_ONE_OR_MORE_BOUND
Definition: sc_port.hh:69
gem5::Port::name
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:111
sockets.hh
tlm::tlm_base_target_socket
Definition: initiator_socket.hh:69
sc_gem5::TlmInitiatorBaseWrapper::InitiatorSocket
tlm::tlm_base_initiator_socket< BUSWIDTH, FW_IF, BW_IF, N, POL > InitiatorSocket
Definition: tlm_port_wrapper.hh:52
gem5::ArmISA::i
Bitfield< 7 > i
Definition: misc_types.hh:66
gem5::Port::bind
virtual void bind(Port &peer)
Attach to a peer port.
Definition: port.hh:118
sc_gem5::TlmTargetBaseWrapper::TargetSocket
tlm::tlm_base_target_socket< BUSWIDTH, FW_IF, BW_IF, N, POL > TargetSocket
Definition: tlm_port_wrapper.hh:94
sc_gem5::TlmTargetBaseWrapper::TlmTargetBaseWrapper
TlmTargetBaseWrapper(TargetSocket &t, const std::string &_name, gem5::PortID _id)
Definition: tlm_port_wrapper.hh:98
sc_gem5::TlmTargetBaseWrapper::target
TargetSocket & target()
Definition: tlm_port_wrapper.hh:96
sc_core::sc_port_policy
sc_port_policy
Definition: sc_port.hh:67
gem5::ArmISA::t
Bitfield< 5 > t
Definition: misc_types.hh:70
sc_gem5::TlmInitiatorBaseWrapper::bind
void bind(gem5::Port &peer) override
Definition: tlm_port_wrapper.hh:64
port.hh
name
const std::string & name()
Definition: trace.cc:49
sc_gem5::TlmInitiatorBaseWrapper::TargetSocket
InitiatorSocket::base_target_socket_type TargetSocket
Definition: tlm_port_wrapper.hh:53
tlm::tlm_base_target_socket_b
Definition: initiator_socket.hh:65
sc_gem5::TlmTargetBaseWrapper::unbind
void unbind() override
Definition: tlm_port_wrapper.hh:112
sc_gem5::TlmTargetBaseWrapper::bind
void bind(gem5::Port &peer) override
Definition: tlm_port_wrapper.hh:104
sc_gem5::TlmInitiatorBaseWrapper::unbind
void unbind() override
Definition: tlm_port_wrapper.hh:77
tlm::tlm_base_initiator_socket::bind
virtual void bind(base_target_socket_type &s)
Definition: initiator_socket.hh:121
sc_gem5::TlmInitiatorBaseWrapper::TargetWrapper
TlmTargetBaseWrapper< BUSWIDTH, FW_IF, BW_IF, N, POL > TargetWrapper
Definition: tlm_port_wrapper.hh:54
gem5::Port
Ports are used to interface objects to each other.
Definition: port.hh:61
sc_gem5::TlmInitiatorBaseWrapper
Definition: tlm_port_wrapper.hh:40
tlm::tlm_base_protocol_types
Definition: fw_bw_ifs.hh:213
logging.hh
sc_gem5::Port
Definition: port.hh:50
sc_gem5
Definition: sc_clock.cc:41
sc_gem5::TlmTargetBaseWrapper
Definition: tlm_port_wrapper.hh:44
fatal_if
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Definition: logging.hh:225
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
sc_gem5::TlmInitiatorBaseWrapper::_initiator
InitiatorSocket & _initiator
Definition: tlm_port_wrapper.hh:85
tlm::tlm_base_initiator_socket
Definition: initiator_socket.hh:78
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:177

Generated on Tue Sep 21 2021 12:26:16 for gem5 by doxygen 1.8.17