gem5 v24.0.0.0
Loading...
Searching...
No Matches
extension_adaptors.h
Go to the documentation of this file.
1/*****************************************************************************
2
3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4 more contributor license agreements. See the NOTICE file distributed
5 with this work for additional information regarding copyright ownership.
6 Accellera licenses this file to you under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with the
8 License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15 implied. See the License for the specific language governing
16 permissions and limitations under the License.
17
18 *****************************************************************************/
19
20#ifndef __EXTENSIONS_ADAPTORS_H__
21#define __EXTENSIONS_ADAPTORS_H__
22
23#include "tlm.h"
24#include "my_extension.h"
25
26#include "tlm_utils/simple_initiator_socket.h"
27#include "tlm_utils/simple_target_socket.h"
28
29template <unsigned int BUSWIDTH = 32>
31{
32 public:
39
42
54
56 // NB transport
58
59 // Forward direction: The initiator calls this method with an extended
60 // payload. We leave the extension class in the vector, and it will be
61 // ignored by the GP target.
63 tlm::tlm_phase& phase,
65 {
66 return initiator_socket->nb_transport_fw(trans, phase, t);
67 }
68 // Backward direction: we can assume here that the payload we get
69 // as parameter is the same one that the initiator sent out. Thus, the
70 // extension vector is known to be present.
72 tlm::tlm_phase& phase,
74 {
75 return target_socket->nb_transport_bw(trans, phase, t);
76 }
77
79 tlm::tlm_dmi& dmi_data)
80 {
81 bool tmp_ret = initiator_socket->get_direct_mem_ptr(trans,
82 dmi_data);
83 return tmp_ret;
84 }
85
87 // simple call forwarders:
90 {
91 return initiator_socket->transport_dbg(trans);
92 }
94 sc_dt::uint64 end_range)
95 {
96 target_socket->invalidate_direct_mem_ptr(start_range,
97 end_range);
98 }
99};
100
101template <unsigned int BUSWIDTH = 32>
103{
104 public:
111
114
131
133 // NB transport
135
136 // Forward direction: We extend the payload on the fly (if needed).
138 tlm::tlm_phase& phase,
140 {
141 // If the mandatory extension is not there, we need to add it and
142 // store it so that we can re-construc the original state.
143 // Otherwise we don't touch the extension, so that we don't overwrite
144 // it in e.g. a nonGP->GP->nonGP (initiator->interconnect->target)
145 // setup.
146 // Note, however, that there might be situations where we might need to
147 // re-initialize the extension, e.g. for mutable data fields in
148 // different system setups.
150 if (!m_initiator_ext)
151 {
153 }
155 initiator_socket->nb_transport_fw(trans, phase, t);
156 if (tmp == tlm::TLM_COMPLETED)
157 {
159 }
160 return tmp;
161 }
162 // Backward direction: only restore of original extension and static_cast.
164 tlm::tlm_phase& phase,
166 {
168 return target_socket->nb_transport_bw(trans, phase, t);
169 }
170
172 tlm::tlm_dmi& dmi_data)
173 {
174 // If the mandatory extension is not there, we need to add it and
175 // store it so that we can re-construc the original state.
176 // Otherwise we don't touch the extension, so that we don't overwrite
177 // it in e.g. a nonGP->GP->nonGP (initiator->interconnect->target)
178 // setup.
179 my_extension* tmp_ext;
180 trans.get_extension(tmp_ext);
181 if (!tmp_ext)
182 {
183 trans.set_extension(&m_ext);
184 }
185 bool tmp_ret = initiator_socket->get_direct_mem_ptr(trans,
186 dmi_data);
187 if(!tmp_ext)
188 {
189 trans.clear_extension(tmp_ext);
190 }
191 return tmp_ret;
192 }
194 // simple call forwarders:
197 {
198 return initiator_socket->transport_dbg(trans);
199 }
201 sc_dt::uint64 end_range)
202 {
203 target_socket->invalidate_direct_mem_ptr(start_range,
204 end_range);
205 }
206
207private:
210};
211
212#endif
adapt_ext2gp(sc_core::sc_module_name name_)
tlm_utils::simple_target_socket< adapt_ext2gp, BUSWIDTH, my_extended_payload_types > target_socket_type
bool get_dmi_pointer(target_payload_type &trans, tlm::tlm_dmi &dmi_data)
void invalidate_dmi_pointers(sc_dt::uint64 start_range, sc_dt::uint64 end_range)
SC_HAS_PROCESS(adapt_ext2gp)
target_socket_type target_socket
tlm::tlm_generic_payload initiator_payload_type
tlm::tlm_sync_enum forward_nb_transport(initiator_payload_type &trans, tlm::tlm_phase &phase, sc_core::sc_time &t)
unsigned int transport_debug(target_payload_type &trans)
tlm::tlm_sync_enum backward_nb_transport(target_payload_type &trans, tlm::tlm_phase &phase, sc_core::sc_time &t)
tlm_utils::simple_initiator_socket< adapt_ext2gp, BUSWIDTH, tlm::tlm_base_protocol_types > initiator_socket_type
tlm::tlm_generic_payload target_payload_type
initiator_socket_type initiator_socket
target_socket_type target_socket
void invalidate_dmi_pointers(sc_dt::uint64 start_range, sc_dt::uint64 end_range)
tlm::tlm_sync_enum backward_nb_transport(target_payload_type &trans, tlm::tlm_phase &phase, sc_core::sc_time &t)
initiator_socket_type initiator_socket
my_extension m_ext
unsigned int transport_debug(target_payload_type &trans)
bool get_dmi_pointer(target_payload_type &trans, tlm::tlm_dmi &dmi_data)
tlm_utils::simple_target_socket< adapt_gp2ext, BUSWIDTH, tlm::tlm_base_protocol_types > target_socket_type
tlm::tlm_generic_payload initiator_payload_type
tlm::tlm_generic_payload target_payload_type
tlm::tlm_sync_enum forward_nb_transport(initiator_payload_type &trans, tlm::tlm_phase &phase, sc_core::sc_time &t)
tlm_utils::simple_initiator_socket< adapt_gp2ext, BUSWIDTH, my_extended_payload_types > initiator_socket_type
my_extension * m_initiator_ext
SC_HAS_PROCESS(adapt_gp2ext)
adapt_gp2ext(sc_core::sc_module_name name_)
void get_extension(T *&ext) const
Definition gp.hh:364
void clear_extension(const T *ext)
Definition gp.hh:379
T * set_extension(T *ext)
Definition gp.hh:340
void register_nb_transport_bw(MODULE *mod, sync_enum_type(MODULE::*cb)(transaction_type &, phase_type &, sc_core::sc_time &))
void register_invalidate_direct_mem_ptr(MODULE *mod, void(MODULE::*cb)(sc_dt::uint64, sc_dt::uint64))
void register_nb_transport_fw(MODULE *mod, sync_enum_type(MODULE::*cb)(transaction_type &, phase_type &, sc_core::sc_time &))
void register_get_direct_mem_ptr(MODULE *mod, bool(MODULE::*cb)(transaction_type &, tlm::tlm_dmi &))
void register_transport_dbg(MODULE *mod, unsigned int(MODULE::*cb)(transaction_type &))
uint64_t uint64
Definition sc_nbdefs.hh:172
tlm_sync_enum
Definition fw_bw_ifs.hh:31
@ TLM_COMPLETED
Definition fw_bw_ifs.hh:31

Generated on Tue Jun 18 2024 16:24:07 for gem5 by doxygen 1.11.0