gem5_to_tlm.hh (13821:f9252f27ded7) gem5_to_tlm.hh (13823:040971e0f728)
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

--- 52 unchanged lines hidden (view full) ---

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"
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

--- 52 unchanged lines hidden (view full) ---

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/Gem5ToTlmBridge.hh"
69#include "params/Gem5ToTlmBridgeBase.hh"
70#include "sim/system.hh"
71#include "systemc/ext/core/sc_module.hh"
72#include "systemc/ext/core/sc_module_name.hh"
73#include "systemc/ext/tlm_core/2/generic_payload/gp.hh"
74#include "systemc/ext/tlm_utils/simple_initiator_socket.h"
75#include "systemc/tlm_bridge/sc_peq.hh"
76#include "systemc/tlm_port_wrapper.hh"
77
78namespace sc_gem5
79{
80
70#include "sim/system.hh"
71#include "systemc/ext/core/sc_module.hh"
72#include "systemc/ext/core/sc_module_name.hh"
73#include "systemc/ext/tlm_core/2/generic_payload/gp.hh"
74#include "systemc/ext/tlm_utils/simple_initiator_socket.h"
75#include "systemc/tlm_bridge/sc_peq.hh"
76#include "systemc/tlm_port_wrapper.hh"
77
78namespace sc_gem5
79{
80
81class Gem5ToTlmBridge : public sc_core::sc_module
81class Gem5ToTlmBridgeBase : public sc_core::sc_module
82{
82{
83 protected:
84 using sc_core::sc_module::sc_module;
85};
86
87template <unsigned int BITWIDTH>
88class Gem5ToTlmBridge : public Gem5ToTlmBridgeBase
89{
83 private:
84 class BridgeSlavePort : public SlavePort
85 {
86 protected:
90 private:
91 class BridgeSlavePort : public SlavePort
92 {
93 protected:
87 Gem5ToTlmBridge &bridge;
94 Gem5ToTlmBridge<BITWIDTH> &bridge;
88
89 AddrRangeList
90 getAddrRanges() const override
91 {
92 return bridge.getAddrRanges();
93 }
94 Tick
95 recvAtomic(PacketPtr pkt) override

--- 18 unchanged lines hidden (view full) ---

114 bool
115 recvTimingSnoopResp(PacketPtr pkt) override
116 {
117 return bridge.recvTimingSnoopResp(pkt);
118 }
119 void recvRespRetry() override { bridge.recvRespRetry(); }
120
121 public:
95
96 AddrRangeList
97 getAddrRanges() const override
98 {
99 return bridge.getAddrRanges();
100 }
101 Tick
102 recvAtomic(PacketPtr pkt) override

--- 18 unchanged lines hidden (view full) ---

121 bool
122 recvTimingSnoopResp(PacketPtr pkt) override
123 {
124 return bridge.recvTimingSnoopResp(pkt);
125 }
126 void recvRespRetry() override { bridge.recvRespRetry(); }
127
128 public:
122 BridgeSlavePort(const std::string &name_, Gem5ToTlmBridge &bridge_) :
129 BridgeSlavePort(const std::string &name_,
130 Gem5ToTlmBridge<BITWIDTH> &bridge_) :
123 SlavePort(name_, nullptr), bridge(bridge_)
124 {}
125 };
126
127 BridgeSlavePort bsp;
131 SlavePort(name_, nullptr), bridge(bridge_)
132 {}
133 };
134
135 BridgeSlavePort bsp;
128 tlm_utils::simple_initiator_socket<Gem5ToTlmBridge, 64> socket;
129 sc_gem5::TlmInitiatorWrapper<64> wrapper;
136 tlm_utils::simple_initiator_socket<
137 Gem5ToTlmBridge<BITWIDTH>, BITWIDTH> socket;
138 sc_gem5::TlmInitiatorWrapper<BITWIDTH> wrapper;
130
131 System *system;
132
133 /**
134 * A transaction after BEGIN_REQ has been sent but before END_REQ, which
135 * is blocking the request channel (Exlusion Rule, see IEEE1666)
136 */
137 tlm::tlm_generic_payload *blockingRequest;

--- 8 unchanged lines hidden (view full) ---

146 * A response which has been asked to retry by gem5 and so is blocking
147 * the response channel
148 */
149 tlm::tlm_generic_payload *blockingResponse;
150
151 AddrRangeList addrRanges;
152
153 protected:
139
140 System *system;
141
142 /**
143 * A transaction after BEGIN_REQ has been sent but before END_REQ, which
144 * is blocking the request channel (Exlusion Rule, see IEEE1666)
145 */
146 tlm::tlm_generic_payload *blockingRequest;

--- 8 unchanged lines hidden (view full) ---

155 * A response which has been asked to retry by gem5 and so is blocking
156 * the response channel
157 */
158 tlm::tlm_generic_payload *blockingResponse;
159
160 AddrRangeList addrRanges;
161
162 protected:
154 void pec(Gem5SystemC::PayloadEvent *pe,
163 void pec(Gem5SystemC::PayloadEvent<Gem5ToTlmBridge<BITWIDTH>> *pe,
155 tlm::tlm_generic_payload &trans, const tlm::tlm_phase &phase);
156
157 // The gem5 port interface.
158 Tick recvAtomic(PacketPtr packet);
159 void recvFunctional(PacketPtr packet);
160 bool recvTimingReq(PacketPtr packet);
161 bool tryTiming(PacketPtr packet);
162 bool recvTimingSnoopResp(PacketPtr packet);

--- 4 unchanged lines hidden (view full) ---

167 // The TLM initiator interface.
168 tlm::tlm_sync_enum nb_transport_bw(tlm::tlm_generic_payload &trans,
169 tlm::tlm_phase &phase,
170 sc_core::sc_time &t);
171
172 public:
173 ::Port &gem5_getPort(const std::string &if_name, int idx=-1) override;
174
164 tlm::tlm_generic_payload &trans, const tlm::tlm_phase &phase);
165
166 // The gem5 port interface.
167 Tick recvAtomic(PacketPtr packet);
168 void recvFunctional(PacketPtr packet);
169 bool recvTimingReq(PacketPtr packet);
170 bool tryTiming(PacketPtr packet);
171 bool recvTimingSnoopResp(PacketPtr packet);

--- 4 unchanged lines hidden (view full) ---

176 // The TLM initiator interface.
177 tlm::tlm_sync_enum nb_transport_bw(tlm::tlm_generic_payload &trans,
178 tlm::tlm_phase &phase,
179 sc_core::sc_time &t);
180
181 public:
182 ::Port &gem5_getPort(const std::string &if_name, int idx=-1) override;
183
175 typedef Gem5ToTlmBridgeParams Params;
184 typedef Gem5ToTlmBridgeBaseParams Params;
176 Gem5ToTlmBridge(Params *p, const sc_core::sc_module_name &mn);
177
185 Gem5ToTlmBridge(Params *p, const sc_core::sc_module_name &mn);
186
178 tlm_utils::simple_initiator_socket<Gem5ToTlmBridge, 64> &
187 tlm_utils::simple_initiator_socket<Gem5ToTlmBridge<BITWIDTH>, BITWIDTH> &
179 getSocket()
180 {
181 return socket;
182 }
183
184 void before_end_of_elaboration() override;
185};
186
187} // namespace sc_gem5
188
189#endif // __SYSTEMC_TLM_BRIDGE_GEM5_TO_TLM_HH__
188 getSocket()
189 {
190 return socket;
191 }
192
193 void before_end_of_elaboration() override;
194};
195
196} // namespace sc_gem5
197
198#endif // __SYSTEMC_TLM_BRIDGE_GEM5_TO_TLM_HH__