gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 #include <unordered_map>
65 
66 #include "mem/backdoor.hh"
67 #include "mem/port.hh"
68 #include "params/Gem5ToTlmBridgeBase.hh"
69 #include "sim/system.hh"
75 
76 namespace sc_gem5
77 {
78 
80  std::function<void(gem5::PacketPtr pkt, tlm::tlm_generic_payload &trans)>;
81 
83 
85 
87 {
88  protected:
90 };
91 
92 template <unsigned int BITWIDTH>
94 {
95  private:
97  {
98  protected:
100 
102  getAddrRanges() const override
103  {
104  return bridge.getAddrRanges();
105  }
106  gem5::Tick
108  {
109  return bridge.recvAtomic(pkt);
110  }
111  gem5::Tick
113  gem5::MemBackdoorPtr &backdoor) override
114  {
115  return bridge.recvAtomicBackdoor(pkt, backdoor);
116  }
117  void
119  {
120  return bridge.recvFunctional(pkt);
121  }
122  void
124  gem5::MemBackdoorPtr &backdoor) override
125  {
126  bridge.recvMemBackdoorReq(req, backdoor);
127  }
128  bool
130  {
131  return bridge.recvTimingReq(pkt);
132  }
133  bool
135  {
136  return bridge.tryTiming(pkt);
137  }
138  bool
140  {
141  return bridge.recvTimingSnoopResp(pkt);
142  }
143  void recvRespRetry() override { bridge.recvRespRetry(); }
144 
145  public:
146  BridgeResponsePort(const std::string &name_,
147  Gem5ToTlmBridge<BITWIDTH> &bridge_) :
148  ResponsePort(name_), bridge(bridge_)
149  {}
150  };
151 
156 
158 
164 
170 
176 
181  std::unordered_map<tlm::tlm_generic_payload *, gem5::PacketPtr> packetMap;
182 
184 
185  protected:
186  void pec(tlm::tlm_generic_payload &trans, const tlm::tlm_phase &phase);
187 
190 
191  // The gem5 port interface.
194  gem5::MemBackdoorPtr &backdoor);
195  void recvFunctional(gem5::PacketPtr packet);
197  gem5::MemBackdoorPtr &backdoor);
198  bool recvTimingReq(gem5::PacketPtr packet);
199  bool tryTiming(gem5::PacketPtr packet);
201  void recvRespRetry();
204 
205  // The TLM initiator interface.
207  tlm::tlm_phase &phase,
210  sc_dt::uint64 start_range, sc_dt::uint64 end_range);
211 
212  public:
213  gem5::Port &gem5_getPort(const std::string &if_name, int idx=-1) override;
214 
215  typedef gem5::Gem5ToTlmBridgeBaseParams Params;
216  Gem5ToTlmBridge(const Params &p, const sc_core::sc_module_name &mn);
217 
220  {
221  return socket;
222  }
223 
224  void before_end_of_elaboration() override;
225 };
226 
227 } // namespace sc_gem5
228 
229 #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:586
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:101
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:169
sc_gem5::Gem5ToTlmBridge::before_end_of_elaboration
void before_end_of_elaboration() override
Definition: gem5_to_tlm.cc:598
sc_gem5::Gem5ToTlmBridge::recvAtomic
gem5::Tick recvAtomic(gem5::PacketPtr packet)
Definition: gem5_to_tlm.cc:302
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:119
sc_module_name.hh
sc_gem5::packet2payload
tlm::tlm_generic_payload * packet2payload(PacketPtr packet)
Convert a gem5 packet to TLM payload by copying all the relevant information to new payload.
Definition: gem5_to_tlm.cc:131
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:118
sc_gem5::Gem5ToTlmBridge::recvRespRetry
void recvRespRetry()
Definition: gem5_to_tlm.cc:476
backdoor.hh
sc_gem5::Gem5ToTlmBridge::Gem5ToTlmBridge
Gem5ToTlmBridge(const Params &p, const sc_core::sc_module_name &mn)
Definition: gem5_to_tlm.cc:572
sc_gem5::Gem5ToTlmBridge::backdoorMap
gem5::AddrRangeMap< gem5::MemBackdoorPtr > backdoorMap
Definition: gem5_to_tlm.hh:189
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:175
sc_gem5::Gem5ToTlmBridge::BridgeResponsePort::recvTimingSnoopResp
bool recvTimingSnoopResp(gem5::PacketPtr pkt) override
Receive a timing snoop response from the peer.
Definition: gem5_to_tlm.hh:139
sc_gem5::Gem5ToTlmBridge::BridgeResponsePort::bridge
Gem5ToTlmBridge< BITWIDTH > & bridge
Definition: gem5_to_tlm.hh:99
sc_gem5::Gem5ToTlmBridge::recvTimingReq
bool recvTimingReq(gem5::PacketPtr packet)
Definition: gem5_to_tlm.cc:371
sc_gem5::Gem5ToTlmBridge::recvFunctional
void recvFunctional(gem5::PacketPtr packet)
Definition: gem5_to_tlm.cc:501
sc_gem5::Gem5ToTlmBridge::BridgeResponsePort::recvAtomicBackdoor
gem5::Tick recvAtomicBackdoor(gem5::PacketPtr pkt, gem5::MemBackdoorPtr &backdoor) override
Default implementations.
Definition: gem5_to_tlm.hh:112
gem5::System
Definition: system.hh:74
sc_gem5::Gem5ToTlmBridge::socket
tlm_utils::simple_initiator_socket< Gem5ToTlmBridge< BITWIDTH >, BITWIDTH > socket
Definition: gem5_to_tlm.hh:154
gem5::VegaISA::t
Bitfield< 51 > t
Definition: pagetable.hh:56
gem5::VegaISA::p
Bitfield< 54 > p
Definition: pagetable.hh:70
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:294
sc_gem5::Gem5ToTlmBridge::BridgeResponsePort
Definition: gem5_to_tlm.hh:96
sc_gem5::Gem5ToTlmBridge::BridgeResponsePort::recvTimingReq
bool recvTimingReq(gem5::PacketPtr pkt) override
Receive a timing request from the peer.
Definition: gem5_to_tlm.hh:129
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:143
sc_gem5::Gem5ToTlmBridge::recvAtomicBackdoor
gem5::Tick recvAtomicBackdoor(gem5::PacketPtr pkt, gem5::MemBackdoorPtr &backdoor)
Definition: gem5_to_tlm.cc:327
sc_gem5::PacketToPayloadConversionStep
std::function< void(gem5::PacketPtr pkt, tlm::tlm_generic_payload &trans)> PacketToPayloadConversionStep
Definition: gem5_to_tlm.hh:80
sc_gem5::Gem5ToTlmBridge::recvTimingSnoopResp
bool recvTimingSnoopResp(gem5::PacketPtr packet)
Definition: gem5_to_tlm.cc:459
sc_core::sc_module_name
Definition: sc_module_name.hh:41
sc_gem5::Gem5ToTlmBridge::packetMap
std::unordered_map< tlm::tlm_generic_payload *, gem5::PacketPtr > packetMap
A map to record the association between payload and packet.
Definition: gem5_to_tlm.hh:181
sc_gem5::Gem5ToTlmBridge::recvFunctionalSnoop
void recvFunctionalSnoop(gem5::PacketPtr packet)
Definition: gem5_to_tlm.cc:361
sc_gem5::Gem5ToTlmBridge
Definition: gem5_to_tlm.hh:93
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:543
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:219
gem5::ResponsePort::ResponsePort
ResponsePort(const std::string &name, SimObject *_owner, PortID id=InvalidPortID)
Response port.
Definition: port.cc:218
sc_gem5::Gem5ToTlmBridge::wrapper
sc_gem5::TlmInitiatorWrapper< BITWIDTH > wrapper
Definition: gem5_to_tlm.hh:155
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:107
gem5::ResponsePort
A ResponsePort is a specialization of a port.
Definition: port.hh:331
sc_gem5::Gem5ToTlmBridge::bridgeResponsePort
BridgeResponsePort bridgeResponsePort
Definition: gem5_to_tlm.hh:152
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:163
sc_gem5::Gem5ToTlmBridge::BridgeResponsePort::tryTiming
bool tryTiming(gem5::PacketPtr pkt) override
Availability request from the peer.
Definition: gem5_to_tlm.hh:134
sc_gem5::Gem5ToTlmBridge::getAddrRanges
gem5::AddrRangeList getAddrRanges() const
Definition: gem5_to_tlm.hh:203
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:270
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:555
sc_gem5
Definition: sc_clock.cc:41
sc_gem5::Gem5ToTlmBridge::addrRanges
gem5::AddrRangeList addrRanges
Definition: gem5_to_tlm.hh:183
std::list< AddrRange >
sc_gem5::Gem5ToTlmBridge::Params
gem5::Gem5ToTlmBridgeBaseParams Params
Definition: gem5_to_tlm.hh:215
gem5::MemBackdoorReq
Definition: backdoor.hh:129
sc_gem5::Gem5ToTlmBridge::system
gem5::System * system
Definition: gem5_to_tlm.hh:157
sc_gem5::Gem5ToTlmBridge::tryTiming
bool tryTiming(gem5::PacketPtr packet)
Definition: gem5_to_tlm.cc:469
sc_gem5::Gem5ToTlmBridge::pec
void pec(tlm::tlm_generic_payload &trans, const tlm::tlm_phase &phase)
Definition: gem5_to_tlm.cc:217
sc_gem5::Gem5ToTlmBridgeBase
Definition: gem5_to_tlm.hh:86
sc_gem5::Gem5ToTlmBridge::BridgeResponsePort::recvMemBackdoorReq
void recvMemBackdoorReq(const gem5::MemBackdoorReq &req, gem5::MemBackdoorPtr &backdoor) override
Receive a request for a back door to a range of memory.
Definition: gem5_to_tlm.hh:123
sc_gem5::Gem5ToTlmBridge::BridgeResponsePort::BridgeResponsePort
BridgeResponsePort(const std::string &name_, Gem5ToTlmBridge< BITWIDTH > &bridge_)
Definition: gem5_to_tlm.hh:146
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:102
sc_gem5::Gem5ToTlmBridge::recvMemBackdoorReq
void recvMemBackdoorReq(const gem5::MemBackdoorReq &req, gem5::MemBackdoorPtr &backdoor)
Definition: gem5_to_tlm.cc:518
gp.hh

Generated on Sun Jul 30 2023 01:57:03 for gem5 by doxygen 1.8.17