gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
tlm_to_gem5.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) 2016, Dresden University of Technology (TU Dresden)
28  * All rights reserved.
29  *
30  * Redistribution and use in source and binary forms, with or without
31  * modification, are permitted provided that the following conditions are
32  * met:
33  *
34  * 1. Redistributions of source code must retain the above copyright notice,
35  * this list of conditions and the following disclaimer.
36  *
37  * 2. Redistributions in binary form must reproduce the above copyright
38  * notice, this list of conditions and the following disclaimer in the
39  * documentation and/or other materials provided with the distribution.
40  *
41  * 3. Neither the name of the copyright holder nor the names of its
42  * contributors may be used to endorse or promote products derived from
43  * this software without specific prior written permission.
44  *
45  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
46  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
47  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
48  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
49  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
50  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
51  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
52  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
53  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
54  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
55  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56  *
57  * Authors: Gabe Black
58  * Christian Menard
59  */
60 
61 #ifndef __SYSTEMC_TLM_BRIDGE_TLM_TO_GEM5_HH__
62 #define __SYSTEMC_TLM_BRIDGE_TLM_TO_GEM5_HH__
63 
64 #include "mem/port.hh"
65 #include "params/TlmToGem5BridgeBase.hh"
73 
74 namespace sc_gem5
75 {
76 
78 {
79  protected:
81 };
82 
84 
85 template <unsigned int BITWIDTH>
87 {
88  private:
90  {
92  TlmSenderState(tlm::tlm_generic_payload &trans) : trans(trans) {}
93  };
94 
96  {
97  protected:
99 
100  bool
101  recvTimingResp(PacketPtr pkt) override
102  {
103  return bridge.recvTimingResp(pkt);
104  }
105  void recvReqRetry() override { bridge.recvReqRetry(); }
106  void recvRangeChange() override { bridge.recvRangeChange(); }
107 
108  public:
109  BridgeMasterPort(const std::string &name_,
110  TlmToGem5Bridge<BITWIDTH> &bridge_) :
111  MasterPort(name_, nullptr), bridge(bridge_)
112  {}
113  };
114 
116 
120 
122 
124 
129 
131 
132  void sendEndReq(tlm::tlm_generic_payload &trans);
133  void sendBeginResp(tlm::tlm_generic_payload &trans,
134  sc_core::sc_time &delay);
135 
136  void handleBeginReq(tlm::tlm_generic_payload &trans);
137  void handleEndResp(tlm::tlm_generic_payload &trans);
138 
139  void destroyPacket(PacketPtr pkt);
140 
141  void checkTransaction(tlm::tlm_generic_payload &trans);
142 
143  void invalidateDmi(const ::MemBackdoor &backdoor);
144 
145  protected:
146  // payload event call back
147  void peq_cb(tlm::tlm_generic_payload &trans, const tlm::tlm_phase &phase);
148 
149  // The TLM target interface
150  tlm::tlm_sync_enum nb_transport_fw(tlm::tlm_generic_payload &trans,
151  tlm::tlm_phase &phase,
153  void b_transport(tlm::tlm_generic_payload &trans, sc_core::sc_time &t);
154  unsigned int transport_dbg(tlm::tlm_generic_payload &trans);
155  bool get_direct_mem_ptr(tlm::tlm_generic_payload &trans,
156  tlm::tlm_dmi &dmi_data);
157 
158  // Gem5 port interface.
159  bool recvTimingResp(PacketPtr pkt);
160  void recvReqRetry();
161  void recvRangeChange();
162 
163  public:
164  ::Port &gem5_getPort(const std::string &if_name, int idx=-1) override;
165 
166  typedef TlmToGem5BridgeBaseParams Params;
167  TlmToGem5Bridge(Params *p, const sc_core::sc_module_name &mn);
168 
171  {
172  return socket;
173  }
174 
175  void before_end_of_elaboration() override;
176 
178 };
179 
180 } // namespace sc_gem5
181 
182 #endif // __SYSTEMC_TLM_BRIDGE_TLM_TO_GEM5_HH__
A MasterPort is a specialisation of a BaseMasterPort, which implements the default protocol for the t...
Definition: port.hh:75
TlmToGem5Bridge< BITWIDTH > & bridge
Definition: tlm_to_gem5.hh:98
BridgeMasterPort(const std::string &name_, TlmToGem5Bridge< BITWIDTH > &bridge_)
Definition: tlm_to_gem5.hh:109
tlm_utils::simple_target_socket< TlmToGem5Bridge< BITWIDTH >, BITWIDTH > & getSocket()
Definition: tlm_to_gem5.hh:170
tlm_utils::peq_with_cb_and_phase< TlmToGem5Bridge< BITWIDTH > > peq
Definition: tlm_to_gem5.hh:115
bool recvTimingResp(PacketPtr pkt)
Definition: tlm_to_gem5.cc:381
TlmSenderState(tlm::tlm_generic_payload &trans)
Definition: tlm_to_gem5.hh:92
Definition: system.hh:77
tlm::tlm_generic_payload * pendingRequest
Definition: tlm_to_gem5.hh:118
void recvReqRetry() override
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
Definition: tlm_to_gem5.hh:105
tlm::tlm_generic_payload & trans
Definition: tlm_to_gem5.hh:91
BridgeMasterPort bmp
Definition: tlm_to_gem5.hh:125
sc_gem5::TlmTargetWrapper< BITWIDTH > wrapper
Definition: tlm_to_gem5.hh:128
Port Object Declaration.
An event queue that can contain any number of pending notifications.
const MasterID masterId
Definition: tlm_to_gem5.hh:177
uint16_t MasterID
Definition: request.hh:86
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
A virtual base opaque structure used to hold state associated with the packet (e.g., an MSHR), specific to a SimObject that sees the packet.
Definition: packet.hh:403
TlmToGem5BridgeBaseParams Params
Definition: tlm_to_gem5.hh:166
void recvRangeChange() override
Called to receive an address range change from the peer slave port.
Definition: tlm_to_gem5.hh:106
virtual ::Port & gem5_getPort(const std::string &if_name, int idx=-1)
Definition: sc_module.cc:119
tlm_utils::simple_target_socket< TlmToGem5Bridge< BITWIDTH >, BITWIDTH > socket
Definition: tlm_to_gem5.hh:127
bool recvTimingResp(PacketPtr pkt) override
Receive a timing response from the peer.
Definition: tlm_to_gem5.hh:101
PacketPtr payload2packet(MasterID masterId, tlm::tlm_generic_payload &trans)
Definition: tlm_to_gem5.cc:73
tlm_sync_enum
Definition: fw_bw_ifs.hh:31
Bitfield< 5 > t
Bitfield< 0 > p
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