gem5  v22.1.0.0
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__
The AddrRangeMap uses an STL map to implement an interval tree for address decoding.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
Ports are used to interface objects to each other.
Definition: port.hh:62
A ResponsePort is a specialization of a port.
Definition: port.hh:270
ResponsePort(const std::string &name, SimObject *_owner, PortID id=InvalidPortID)
Response port.
Definition: port.cc:173
bool recvTimingSnoopResp(gem5::PacketPtr pkt) override
Receive a timing snoop response from the peer.
Definition: gem5_to_tlm.hh:131
gem5::Tick recvAtomic(gem5::PacketPtr pkt) override
Receive an atomic request packet from the peer.
Definition: gem5_to_tlm.hh:105
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
Gem5ToTlmBridge< BITWIDTH > & bridge
Definition: gem5_to_tlm.hh:97
bool recvTimingReq(gem5::PacketPtr pkt) override
Receive a timing request from the peer.
Definition: gem5_to_tlm.hh:121
bool tryTiming(gem5::PacketPtr pkt) override
Availability request from the peer.
Definition: gem5_to_tlm.hh:126
gem5::Tick recvAtomicBackdoor(gem5::PacketPtr pkt, gem5::MemBackdoorPtr &backdoor) override
Default implementations.
Definition: gem5_to_tlm.hh:110
void recvFunctional(gem5::PacketPtr pkt) override
Receive a functional request packet from the peer.
Definition: gem5_to_tlm.hh:116
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
BridgeResponsePort(const std::string &name_, Gem5ToTlmBridge< BITWIDTH > &bridge_)
Definition: gem5_to_tlm.hh:138
bool needToSendRequestRetry
Did another gem5 request arrive while currently blocked? This variable is needed when a retry should ...
Definition: gem5_to_tlm.hh:161
void before_end_of_elaboration() override
Definition: gem5_to_tlm.cc:569
void invalidate_direct_mem_ptr(sc_dt::uint64 start_range, sc_dt::uint64 end_range)
Definition: gem5_to_tlm.cc:526
void pec(tlm::tlm_generic_payload &trans, const tlm::tlm_phase &phase)
Definition: gem5_to_tlm.cc:217
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
gem5::AddrRangeList addrRanges
Definition: gem5_to_tlm.hh:169
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:514
gem5::MemBackdoorPtr getBackdoor(tlm::tlm_generic_payload &trans)
Definition: gem5_to_tlm.cc:269
gem5::Gem5ToTlmBridgeBaseParams Params
Definition: gem5_to_tlm.hh:199
tlm_utils::simple_initiator_socket< Gem5ToTlmBridge< BITWIDTH >, BITWIDTH > socket
Definition: gem5_to_tlm.hh:146
Gem5ToTlmBridge(const Params &p, const sc_core::sc_module_name &mn)
Definition: gem5_to_tlm.cc:543
gem5::AddrRangeMap< gem5::MemBackdoorPtr > backdoorMap
Definition: gem5_to_tlm.hh:175
void recvFunctionalSnoop(gem5::PacketPtr packet)
Definition: gem5_to_tlm.cc:360
gem5::AddrRangeList getAddrRanges() const
Definition: gem5_to_tlm.hh:187
gem5::Tick recvAtomic(gem5::PacketPtr packet)
Definition: gem5_to_tlm.cc:301
tlm_utils::simple_initiator_socket< Gem5ToTlmBridge< BITWIDTH >, BITWIDTH > & getSocket()
Definition: gem5_to_tlm.hh:203
gem5::Tick recvAtomicBackdoor(gem5::PacketPtr pkt, gem5::MemBackdoorPtr &backdoor)
Definition: gem5_to_tlm.cc:326
bool tryTiming(gem5::PacketPtr packet)
Definition: gem5_to_tlm.cc:466
bool recvTimingSnoopResp(gem5::PacketPtr packet)
Definition: gem5_to_tlm.cc:456
gem5::Port & gem5_getPort(const std::string &if_name, int idx=-1) override
Definition: gem5_to_tlm.cc:557
bool recvTimingReq(gem5::PacketPtr packet)
Definition: gem5_to_tlm.cc:370
sc_gem5::TlmInitiatorWrapper< BITWIDTH > wrapper
Definition: gem5_to_tlm.hh:147
void recvFunctional(gem5::PacketPtr packet)
Definition: gem5_to_tlm.cc:497
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
BridgeResponsePort bridgeResponsePort
Definition: gem5_to_tlm.hh:144
Port Object Declaration.
Bitfield< 51 > t
Definition: pagetable.hh:56
Bitfield< 54 > p
Definition: pagetable.hh:70
uint64_t Tick
Tick count type.
Definition: types.hh:58
uint64_t uint64
Definition: sc_nbdefs.hh:172
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
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
std::function< void(gem5::PacketPtr pkt, tlm::tlm_generic_payload &trans)> PacketToPayloadConversionStep
Definition: gem5_to_tlm.hh:78
tlm_sync_enum
Definition: fw_bw_ifs.hh:31

Generated on Wed Dec 21 2022 10:22:50 for gem5 by doxygen 1.9.1