gem5  v19.0.0.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  * Authors: Gabe Black
59  * Matthias Jung
60  * Christian Menard
61  */
62 
63 #ifndef __SYSTEMC_TLM_BRIDGE_GEM5_TO_TLM_HH__
64 #define __SYSTEMC_TLM_BRIDGE_GEM5_TO_TLM_HH__
65 
66 #include <string>
67 
68 #include "mem/port.hh"
69 #include "params/Gem5ToTlmBridgeBase.hh"
70 #include "sim/system.hh"
76 
77 namespace sc_gem5
78 {
79 
81 
83 {
84  protected:
86 };
87 
88 template <unsigned int BITWIDTH>
90 {
91  private:
92  class BridgeSlavePort : public SlavePort
93  {
94  protected:
96 
98  getAddrRanges() const override
99  {
100  return bridge.getAddrRanges();
101  }
102  Tick
103  recvAtomic(PacketPtr pkt) override
104  {
105  return bridge.recvAtomic(pkt);
106  }
107  Tick
108  recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor) override
109  {
110  return bridge.recvAtomicBackdoor(pkt, backdoor);
111  }
112  void
113  recvFunctional(PacketPtr pkt) override
114  {
115  return bridge.recvFunctional(pkt);
116  }
117  bool
118  recvTimingReq(PacketPtr pkt) override
119  {
120  return bridge.recvTimingReq(pkt);
121  }
122  bool
123  tryTiming(PacketPtr pkt) override
124  {
125  return bridge.tryTiming(pkt);
126  }
127  bool
129  {
130  return bridge.recvTimingSnoopResp(pkt);
131  }
132  void recvRespRetry() override { bridge.recvRespRetry(); }
133 
134  public:
135  BridgeSlavePort(const std::string &name_,
136  Gem5ToTlmBridge<BITWIDTH> &bridge_) :
137  SlavePort(name_, nullptr), bridge(bridge_)
138  {}
139  };
140 
145 
147 
153 
159 
165 
167 
168  protected:
169  void pec(tlm::tlm_generic_payload &trans, const tlm::tlm_phase &phase);
170 
171  MemBackdoorPtr getBackdoor(tlm::tlm_generic_payload &trans);
173 
174  // The gem5 port interface.
175  Tick recvAtomic(PacketPtr packet);
176  Tick recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor);
177  void recvFunctional(PacketPtr packet);
178  bool recvTimingReq(PacketPtr packet);
179  bool tryTiming(PacketPtr packet);
180  bool recvTimingSnoopResp(PacketPtr packet);
181  void recvRespRetry();
182  void recvFunctionalSnoop(PacketPtr packet);
183  AddrRangeList getAddrRanges() const { return addrRanges; }
184 
185  // The TLM initiator interface.
186  tlm::tlm_sync_enum nb_transport_bw(tlm::tlm_generic_payload &trans,
187  tlm::tlm_phase &phase,
189  void invalidate_direct_mem_ptr(
190  sc_dt::uint64 start_range, sc_dt::uint64 end_range);
191 
192  public:
193  ::Port &gem5_getPort(const std::string &if_name, int idx=-1) override;
194 
195  typedef Gem5ToTlmBridgeBaseParams Params;
196  Gem5ToTlmBridge(Params *p, const sc_core::sc_module_name &mn);
197 
200  {
201  return socket;
202  }
203 
204  void before_end_of_elaboration() override;
205 };
206 
207 } // namespace sc_gem5
208 
209 #endif // __SYSTEMC_TLM_BRIDGE_GEM5_TO_TLM_HH__
Tick recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor)
Definition: gem5_to_tlm.cc:236
tlm_utils::simple_initiator_socket< Gem5ToTlmBridge< BITWIDTH >, BITWIDTH > socket
Definition: gem5_to_tlm.hh:143
Gem5ToTlmBridgeBaseParams Params
Definition: gem5_to_tlm.hh:195
bool recvTimingReq(PacketPtr packet)
Definition: gem5_to_tlm.cc:279
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:86
void recvFunctional(PacketPtr packet)
Definition: gem5_to_tlm.cc:403
BridgeSlavePort(const std::string &name_, Gem5ToTlmBridge< BITWIDTH > &bridge_)
Definition: gem5_to_tlm.hh:135
Definition: system.hh:77
tlm_utils::simple_initiator_socket< Gem5ToTlmBridge< BITWIDTH >, BITWIDTH > & getSocket()
Definition: gem5_to_tlm.hh:199
A SlavePort is a specialisation of a port.
Definition: port.hh:258
bool needToSendRequestRetry
Did another gem5 request arrive while currently blocked? This variable is needed when a retry should ...
Definition: gem5_to_tlm.hh:158
Tick recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor) override
Default implementations.
Definition: gem5_to_tlm.hh:108
bool tryTiming(PacketPtr packet)
Definition: gem5_to_tlm.cc:372
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:152
bool recvTimingSnoopResp(PacketPtr packet)
Definition: gem5_to_tlm.cc:362
bool recvTimingReq(PacketPtr pkt) override
Receive a timing request from the peer.
Definition: gem5_to_tlm.hh:118
AddrRangeList getAddrRanges() const
Definition: gem5_to_tlm.hh:183
uint64_t Tick
Tick count type.
Definition: types.hh:63
bool recvTimingSnoopResp(PacketPtr pkt) override
Receive a timing snoop response from the peer.
Definition: gem5_to_tlm.hh:128
AddrRangeList addrRanges
Definition: gem5_to_tlm.hh:166
The AddrRangeMap uses an STL map to implement an interval tree for address decoding.
Port Object Declaration.
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
void recvRespRetry() override
Called by the peer if sendTimingResp was called on this protocol (causing recvTimingResp to be called...
Definition: gem5_to_tlm.hh:132
uint64_t uint64
Definition: sc_nbdefs.hh:172
Gem5ToTlmBridge< BITWIDTH > & bridge
Definition: gem5_to_tlm.hh:95
AddrRangeMap< MemBackdoorPtr > backdoorMap
Definition: gem5_to_tlm.hh:172
virtual ::Port & gem5_getPort(const std::string &if_name, int idx=-1)
Definition: sc_module.cc:119
void recvFunctional(PacketPtr pkt) override
Receive a functional request packet from the peer.
Definition: gem5_to_tlm.hh:113
bool tryTiming(PacketPtr pkt) override
Availability request from the peer.
Definition: gem5_to_tlm.hh:123
sc_gem5::TlmInitiatorWrapper< BITWIDTH > wrapper
Definition: gem5_to_tlm.hh:144
tlm_sync_enum
Definition: fw_bw_ifs.hh:31
Bitfield< 5 > t
Bitfield< 0 > p
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:164
Tick recvAtomic(PacketPtr packet)
Definition: gem5_to_tlm.cc:211
AddrRangeList getAddrRanges() const override
Get a list of the non-overlapping address ranges the owner is responsible for.
Definition: gem5_to_tlm.hh:98
Tick recvAtomic(PacketPtr pkt) override
Receive an atomic request packet from the peer.
Definition: gem5_to_tlm.hh:103
virtual void before_end_of_elaboration()
Definition: sc_module.hh:250

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