gem5  v21.1.0.2
gem5_to_tlm.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2019 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  * Copyright (c) 2015, University of Kaiserslautern
28  * Copyright (c) 2016, Dresden University of Technology (TU Dresden)
29  * All rights reserved.
30  *
31  * Redistribution and use in source and binary forms, with or without
32  * modification, are permitted provided that the following conditions are
33  * met:
34  *
35  * 1. Redistributions of source code must retain the above copyright notice,
36  * this list of conditions and the following disclaimer.
37  *
38  * 2. Redistributions in binary form must reproduce the above copyright
39  * notice, this list of conditions and the following disclaimer in the
40  * documentation and/or other materials provided with the distribution.
41  *
42  * 3. Neither the name of the copyright holder nor the names of its
43  * contributors may be used to endorse or promote products derived from
44  * this software without specific prior written permission.
45  *
46  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
47  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
48  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
49  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
50  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
51  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
52  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
53  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
54  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
55  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
56  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57  */
58 
59 #ifndef __SYSTEMC_TLM_BRIDGE_GEM5_TO_TLM_HH__
60 #define __SYSTEMC_TLM_BRIDGE_GEM5_TO_TLM_HH__
61 
62 #include <functional>
63 #include <string>
64 
65 #include "mem/port.hh"
66 #include "params/Gem5ToTlmBridgeBase.hh"
67 #include "sim/system.hh"
73 
74 namespace sc_gem5
75 {
76 
78  std::function<void(gem5::PacketPtr pkt, tlm::tlm_generic_payload &trans)>;
79 
81 
83 
85 {
86  protected:
88 };
89 
90 template <unsigned int BITWIDTH>
92 {
93  private:
95  {
96  protected:
98 
100  getAddrRanges() const override
101  {
102  return bridge.getAddrRanges();
103  }
104  gem5::Tick
106  {
107  return bridge.recvAtomic(pkt);
108  }
109  gem5::Tick
111  gem5::MemBackdoorPtr &backdoor) override
112  {
113  return bridge.recvAtomicBackdoor(pkt, backdoor);
114  }
115  void
117  {
118  return bridge.recvFunctional(pkt);
119  }
120  bool
122  {
123  return bridge.recvTimingReq(pkt);
124  }
125  bool
127  {
128  return bridge.tryTiming(pkt);
129  }
130  bool
132  {
133  return bridge.recvTimingSnoopResp(pkt);
134  }
135  void recvRespRetry() override { bridge.recvRespRetry(); }
136 
137  public:
138  BridgeResponsePort(const std::string &name_,
139  Gem5ToTlmBridge<BITWIDTH> &bridge_) :
140  ResponsePort(name_, nullptr), bridge(bridge_)
141  {}
142  };
143 
148 
150 
156 
162 
168 
170 
171  protected:
172  void pec(tlm::tlm_generic_payload &trans, const tlm::tlm_phase &phase);
173 
176 
177  // The gem5 port interface.
180  gem5::MemBackdoorPtr &backdoor);
181  void recvFunctional(gem5::PacketPtr packet);
182  bool recvTimingReq(gem5::PacketPtr packet);
183  bool tryTiming(gem5::PacketPtr packet);
185  void recvRespRetry();
188 
189  // The TLM initiator interface.
191  tlm::tlm_phase &phase,
194  sc_dt::uint64 start_range, sc_dt::uint64 end_range);
195 
196  public:
197  gem5::Port &gem5_getPort(const std::string &if_name, int idx=-1) override;
198 
199  typedef gem5::Gem5ToTlmBridgeBaseParams Params;
200  Gem5ToTlmBridge(const Params &p, const sc_core::sc_module_name &mn);
201 
204  {
205  return socket;
206  }
207 
208  void before_end_of_elaboration() override;
209 };
210 
211 } // namespace sc_gem5
212 
213 #endif // __SYSTEMC_TLM_BRIDGE_GEM5_TO_TLM_HH__
sc_gem5::Gem5ToTlmBridge::gem5_getPort
gem5::Port & gem5_getPort(const std::string &if_name, int idx=-1) override
Definition: gem5_to_tlm.cc:517
gem5::AddrRangeMap
The AddrRangeMap uses an STL map to implement an interval tree for address decoding.
Definition: addr_range_map.hh:62
system.hh
sc_core::sc_module
Definition: sc_module.hh:98
tlm::tlm_phase
Definition: phase.hh:47
sc_gem5::Gem5ToTlmBridge::needToSendRequestRetry
bool needToSendRequestRetry
Did another gem5 request arrive while currently blocked? This variable is needed when a retry should ...
Definition: gem5_to_tlm.hh:161
sc_gem5::Gem5ToTlmBridge::before_end_of_elaboration
void before_end_of_elaboration() override
Definition: gem5_to_tlm.cc:529
sc_gem5::Gem5ToTlmBridge::recvAtomic
gem5::Tick recvAtomic(gem5::PacketPtr packet)
Definition: gem5_to_tlm.cc:262
sc_gem5::addPacketToPayloadConversionStep
void addPacketToPayloadConversionStep(PacketToPayloadConversionStep step)
Notify the Gem5ToTlm bridge that we need an extra step to properly convert a gem5 packet to tlm paylo...
Definition: gem5_to_tlm.cc:118
sc_module_name.hh
sc_gem5::packet2payload
tlm::tlm_generic_payload * packet2payload(PacketPtr packet)
Convert a gem5 packet to a TLM payload by copying all the relevant information to new tlm payload.
Definition: gem5_to_tlm.cc:128
sc_core::sc_module::sc_module
sc_module()
Definition: sc_module.cc:256
sc_gem5::Gem5ToTlmBridge::BridgeResponsePort::recvFunctional
void recvFunctional(gem5::PacketPtr pkt) override
Receive a functional request packet from the peer.
Definition: gem5_to_tlm.hh:116
sc_gem5::Gem5ToTlmBridge::recvRespRetry
void recvRespRetry()
Definition: gem5_to_tlm.cc:433
sc_gem5::Gem5ToTlmBridge::Gem5ToTlmBridge
Gem5ToTlmBridge(const Params &p, const sc_core::sc_module_name &mn)
Definition: gem5_to_tlm.cc:503
sc_gem5::Gem5ToTlmBridge::backdoorMap
gem5::AddrRangeMap< gem5::MemBackdoorPtr > backdoorMap
Definition: gem5_to_tlm.hh:175
sc_gem5::Gem5ToTlmBridge::blockingResponse
tlm::tlm_generic_payload * blockingResponse
A response which has been asked to retry by gem5 and so is blocking the response channel.
Definition: gem5_to_tlm.hh:167
sc_gem5::Gem5ToTlmBridge::BridgeResponsePort::recvTimingSnoopResp
bool recvTimingSnoopResp(gem5::PacketPtr pkt) override
Receive a timing snoop response from the peer.
Definition: gem5_to_tlm.hh:131
sc_gem5::Gem5ToTlmBridge::BridgeResponsePort::bridge
Gem5ToTlmBridge< BITWIDTH > & bridge
Definition: gem5_to_tlm.hh:97
sc_gem5::Gem5ToTlmBridge::recvTimingReq
bool recvTimingReq(gem5::PacketPtr packet)
Definition: gem5_to_tlm.cc:330
sc_gem5::Gem5ToTlmBridge::recvFunctional
void recvFunctional(gem5::PacketPtr packet)
Definition: gem5_to_tlm.cc:457
sc_gem5::Gem5ToTlmBridge::BridgeResponsePort::recvAtomicBackdoor
gem5::Tick recvAtomicBackdoor(gem5::PacketPtr pkt, gem5::MemBackdoorPtr &backdoor) override
Default implementations.
Definition: gem5_to_tlm.hh:110
gem5::System
Definition: system.hh:77
sc_gem5::Gem5ToTlmBridge::socket
tlm_utils::simple_initiator_socket< Gem5ToTlmBridge< BITWIDTH >, BITWIDTH > socket
Definition: gem5_to_tlm.hh:146
sc_dt::uint64
uint64_t uint64
Definition: sc_nbdefs.hh:206
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:283
sc_gem5::Gem5ToTlmBridge::BridgeResponsePort
Definition: gem5_to_tlm.hh:94
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
sc_gem5::Gem5ToTlmBridge::BridgeResponsePort::recvTimingReq
bool recvTimingReq(gem5::PacketPtr pkt) override
Receive a timing request from the peer.
Definition: gem5_to_tlm.hh:121
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
simple_initiator_socket.h
sc_core::sc_time
Definition: sc_time.hh:49
port.hh
tlm_utils::simple_initiator_socket
Definition: simple_initiator_socket.h:173
sc_gem5::Gem5ToTlmBridge::BridgeResponsePort::recvRespRetry
void recvRespRetry() override
Called by the peer if sendTimingResp was called on this protocol (causing recvTimingResp to be called...
Definition: gem5_to_tlm.hh:135
sc_gem5::Gem5ToTlmBridge::recvAtomicBackdoor
gem5::Tick recvAtomicBackdoor(gem5::PacketPtr pkt, gem5::MemBackdoorPtr &backdoor)
Definition: gem5_to_tlm.cc:287
sc_gem5::PacketToPayloadConversionStep
std::function< void(gem5::PacketPtr pkt, tlm::tlm_generic_payload &trans)> PacketToPayloadConversionStep
Definition: gem5_to_tlm.hh:78
sc_gem5::Gem5ToTlmBridge::recvTimingSnoopResp
bool recvTimingSnoopResp(gem5::PacketPtr packet)
Definition: gem5_to_tlm.cc:416
sc_core::sc_module_name
Definition: sc_module_name.hh:41
sc_gem5::Gem5ToTlmBridge::recvFunctionalSnoop
void recvFunctionalSnoop(gem5::PacketPtr packet)
Definition: gem5_to_tlm.cc:320
sc_gem5::Gem5ToTlmBridge
Definition: gem5_to_tlm.hh:91
sc_gem5::Gem5ToTlmBridge::nb_transport_bw
tlm::tlm_sync_enum nb_transport_bw(tlm::tlm_generic_payload &trans, tlm::tlm_phase &phase, sc_core::sc_time &t)
Definition: gem5_to_tlm.cc:474
gem5::ArmISA::t
Bitfield< 5 > t
Definition: misc_types.hh:70
gem5::MemBackdoor
Definition: backdoor.hh:41
sc_module.hh
sc_gem5::Gem5ToTlmBridge::getSocket
tlm_utils::simple_initiator_socket< Gem5ToTlmBridge< BITWIDTH >, BITWIDTH > & getSocket()
Definition: gem5_to_tlm.hh:203
gem5::ResponsePort::ResponsePort
ResponsePort(const std::string &name, SimObject *_owner, PortID id=InvalidPortID)
Response port.
Definition: port.cc:172
sc_gem5::Gem5ToTlmBridge::wrapper
sc_gem5::TlmInitiatorWrapper< BITWIDTH > wrapper
Definition: gem5_to_tlm.hh:147
sc_gem5::Gem5ToTlmBridge::BridgeResponsePort::recvAtomic
gem5::Tick recvAtomic(gem5::PacketPtr pkt) override
Receive an atomic request packet from the peer.
Definition: gem5_to_tlm.hh:105
gem5::ResponsePort
A ResponsePort is a specialization of a port.
Definition: port.hh:268
sc_gem5::Gem5ToTlmBridge::bridgeResponsePort
BridgeResponsePort bridgeResponsePort
Definition: gem5_to_tlm.hh:144
tlm::tlm_generic_payload
Definition: gp.hh:133
gem5::Port
Ports are used to interface objects to each other.
Definition: port.hh:61
sc_gem5::TlmInitiatorBaseWrapper
Definition: tlm_port_wrapper.hh:40
sc_gem5::Gem5ToTlmBridge::blockingRequest
tlm::tlm_generic_payload * blockingRequest
A transaction after BEGIN_REQ has been sent but before END_REQ, which is blocking the request channel...
Definition: gem5_to_tlm.hh:155
sc_gem5::Gem5ToTlmBridge::BridgeResponsePort::tryTiming
bool tryTiming(gem5::PacketPtr pkt) override
Availability request from the peer.
Definition: gem5_to_tlm.hh:126
sc_gem5::Gem5ToTlmBridge::getAddrRanges
gem5::AddrRangeList getAddrRanges() const
Definition: gem5_to_tlm.hh:187
tlm::tlm_sync_enum
tlm_sync_enum
Definition: fw_bw_ifs.hh:48
sc_gem5::Gem5ToTlmBridge::getBackdoor
gem5::MemBackdoorPtr getBackdoor(tlm::tlm_generic_payload &trans)
Definition: gem5_to_tlm.cc:230
tlm_port_wrapper.hh
sc_gem5::Gem5ToTlmBridge::invalidate_direct_mem_ptr
void invalidate_direct_mem_ptr(sc_dt::uint64 start_range, sc_dt::uint64 end_range)
Definition: gem5_to_tlm.cc:486
sc_gem5
Definition: sc_clock.cc:41
sc_gem5::Gem5ToTlmBridge::addrRanges
gem5::AddrRangeList addrRanges
Definition: gem5_to_tlm.hh:169
std::list< AddrRange >
sc_gem5::Gem5ToTlmBridge::Params
gem5::Gem5ToTlmBridgeBaseParams Params
Definition: gem5_to_tlm.hh:199
sc_gem5::Gem5ToTlmBridge::system
gem5::System * system
Definition: gem5_to_tlm.hh:149
sc_gem5::Gem5ToTlmBridge::tryTiming
bool tryTiming(gem5::PacketPtr packet)
Definition: gem5_to_tlm.cc:426
sc_gem5::Gem5ToTlmBridge::pec
void pec(tlm::tlm_generic_payload &trans, const tlm::tlm_phase &phase)
Definition: gem5_to_tlm.cc:178
sc_gem5::Gem5ToTlmBridgeBase
Definition: gem5_to_tlm.hh:84
sc_gem5::Gem5ToTlmBridge::BridgeResponsePort::BridgeResponsePort
BridgeResponsePort(const std::string &name_, Gem5ToTlmBridge< BITWIDTH > &bridge_)
Definition: gem5_to_tlm.hh:138
sc_gem5::Gem5ToTlmBridge::BridgeResponsePort::getAddrRanges
gem5::AddrRangeList getAddrRanges() const override
Get a list of the non-overlapping address ranges the owner is responsible for.
Definition: gem5_to_tlm.hh:100
gp.hh

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