tlm_to_gem5.hh (13821:f9252f27ded7) tlm_to_gem5.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

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

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

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

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/TlmToGem5Bridge.hh"
65#include "params/TlmToGem5BridgeBase.hh"
66#include "systemc/ext/core/sc_module.hh"
67#include "systemc/ext/core/sc_module_name.hh"
68#include "systemc/ext/tlm_core/2/generic_payload/gp.hh"
69#include "systemc/ext/tlm_utils/peq_with_cb_and_phase.h"
70#include "systemc/ext/tlm_utils/simple_target_socket.h"
71#include "systemc/tlm_bridge/sc_ext.hh"
72#include "systemc/tlm_port_wrapper.hh"
73
74namespace sc_gem5
75{
76
66#include "systemc/ext/core/sc_module.hh"
67#include "systemc/ext/core/sc_module_name.hh"
68#include "systemc/ext/tlm_core/2/generic_payload/gp.hh"
69#include "systemc/ext/tlm_utils/peq_with_cb_and_phase.h"
70#include "systemc/ext/tlm_utils/simple_target_socket.h"
71#include "systemc/tlm_bridge/sc_ext.hh"
72#include "systemc/tlm_port_wrapper.hh"
73
74namespace sc_gem5
75{
76
77class TlmToGem5Bridge : public sc_core::sc_module
77class TlmToGem5BridgeBase : public sc_core::sc_module
78{
78{
79 protected:
80 using sc_core::sc_module::sc_module;
81};
82
83template <unsigned int BITWIDTH>
84class TlmToGem5Bridge : public TlmToGem5BridgeBase
85{
79 private:
80 struct TlmSenderState : public Packet::SenderState
81 {
82 tlm::tlm_generic_payload &trans;
83 TlmSenderState(tlm::tlm_generic_payload &trans) : trans(trans) {}
84 };
85
86 class BridgeMasterPort : public MasterPort
87 {
88 protected:
86 private:
87 struct TlmSenderState : public Packet::SenderState
88 {
89 tlm::tlm_generic_payload &trans;
90 TlmSenderState(tlm::tlm_generic_payload &trans) : trans(trans) {}
91 };
92
93 class BridgeMasterPort : public MasterPort
94 {
95 protected:
89 TlmToGem5Bridge &bridge;
96 TlmToGem5Bridge<BITWIDTH> &bridge;
90
91 bool
92 recvTimingResp(PacketPtr pkt) override
93 {
94 return bridge.recvTimingResp(pkt);
95 }
96 void recvReqRetry() override { bridge.recvReqRetry(); }
97 void recvRangeChange() override { bridge.recvRangeChange(); }
98
99 public:
97
98 bool
99 recvTimingResp(PacketPtr pkt) override
100 {
101 return bridge.recvTimingResp(pkt);
102 }
103 void recvReqRetry() override { bridge.recvReqRetry(); }
104 void recvRangeChange() override { bridge.recvRangeChange(); }
105
106 public:
100 BridgeMasterPort(const std::string &name_, TlmToGem5Bridge &bridge_) :
107 BridgeMasterPort(const std::string &name_,
108 TlmToGem5Bridge<BITWIDTH> &bridge_) :
101 MasterPort(name_, nullptr), bridge(bridge_)
102 {}
103 };
104
109 MasterPort(name_, nullptr), bridge(bridge_)
110 {}
111 };
112
105 tlm_utils::peq_with_cb_and_phase peq;
113 tlm_utils::peq_with_cb_and_phase<TlmToGem5Bridge<BITWIDTH>> peq;
106
107 bool waitForRetry;
108 tlm::tlm_generic_payload *pendingRequest;
109 PacketPtr pendingPacket;
110
111 bool needToSendRetry;
112
113 bool responseInProgress;
114
115 BridgeMasterPort bmp;
114
115 bool waitForRetry;
116 tlm::tlm_generic_payload *pendingRequest;
117 PacketPtr pendingPacket;
118
119 bool needToSendRetry;
120
121 bool responseInProgress;
122
123 BridgeMasterPort bmp;
116 tlm_utils::simple_target_socket<TlmToGem5Bridge, 64> socket;
117 sc_gem5::TlmTargetWrapper<64> wrapper;
124 tlm_utils::simple_target_socket<
125 TlmToGem5Bridge<BITWIDTH>, BITWIDTH> socket;
126 sc_gem5::TlmTargetWrapper<BITWIDTH> wrapper;
118
119 System *system;
120
121 void sendEndReq(tlm::tlm_generic_payload &trans);
122 void sendBeginResp(tlm::tlm_generic_payload &trans,
123 sc_core::sc_time &delay);
124
125 void handleBeginReq(tlm::tlm_generic_payload &trans);

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

146 // Gem5 port interface.
147 bool recvTimingResp(PacketPtr pkt);
148 void recvReqRetry();
149 void recvRangeChange();
150
151 public:
152 ::Port &gem5_getPort(const std::string &if_name, int idx=-1) override;
153
127
128 System *system;
129
130 void sendEndReq(tlm::tlm_generic_payload &trans);
131 void sendBeginResp(tlm::tlm_generic_payload &trans,
132 sc_core::sc_time &delay);
133
134 void handleBeginReq(tlm::tlm_generic_payload &trans);

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

155 // Gem5 port interface.
156 bool recvTimingResp(PacketPtr pkt);
157 void recvReqRetry();
158 void recvRangeChange();
159
160 public:
161 ::Port &gem5_getPort(const std::string &if_name, int idx=-1) override;
162
154 typedef TlmToGem5BridgeParams Params;
163 typedef TlmToGem5BridgeBaseParams Params;
155 TlmToGem5Bridge(Params *p, const sc_core::sc_module_name &mn);
156
164 TlmToGem5Bridge(Params *p, const sc_core::sc_module_name &mn);
165
157 tlm_utils::simple_target_socket<TlmToGem5Bridge, 64> &
166 tlm_utils::simple_target_socket<TlmToGem5Bridge<BITWIDTH>, BITWIDTH> &
158 getSocket()
159 {
160 return socket;
161 }
162
163 void before_end_of_elaboration() override;
164
165 const MasterID masterId;
166};
167
168} // namespace sc_gem5
169
170#endif // __SYSTEMC_TLM_BRIDGE_TLM_TO_GEM5_HH__
167 getSocket()
168 {
169 return socket;
170 }
171
172 void before_end_of_elaboration() override;
173
174 const MasterID masterId;
175};
176
177} // namespace sc_gem5
178
179#endif // __SYSTEMC_TLM_BRIDGE_TLM_TO_GEM5_HH__