gem5  v20.1.0.0
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 
29 template <unsigned int BUSWIDTH = 32>
31 {
32  public:
39 
42 
45  : sc_core::sc_module(name_)
46  {
50 
53  }
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:
89  unsigned int transport_debug(target_payload_type& trans)
90  {
91  return initiator_socket->transport_dbg(trans);
92  }
93  void invalidate_dmi_pointers(sc_dt::uint64 start_range,
94  sc_dt::uint64 end_range)
95  {
96  target_socket->invalidate_direct_mem_ptr(start_range,
97  end_range);
98  }
99 };
100 
101 template <unsigned int BUSWIDTH = 32>
103 {
104  public:
111 
114 
117  : sc_core::sc_module(name_)
118  {
119  // Optionally, we can initialize our private extension class
120  // here, if required.
121 
125 
128 
129  m_ext.m_data = 13;
130  }
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  }
154  tlm::tlm_sync_enum tmp =
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 
207 private:
210 };
211 
212 #endif
adapt_ext2gp
Definition: extension_adaptors.h:30
adapt_ext2gp::target_payload_type
tlm::tlm_generic_payload target_payload_type
Definition: extension_adaptors.h:51
adapt_ext2gp::forward_nb_transport
tlm::tlm_sync_enum forward_nb_transport(initiator_payload_type &trans, tlm::tlm_phase &phase, sc_core::sc_time &t)
Definition: extension_adaptors.h:79
adapt_gp2ext::initiator_socket_type
tlm_utils::simple_initiator_socket< adapt_gp2ext, BUSWIDTH, my_extended_payload_types > initiator_socket_type
Definition: extension_adaptors.h:108
tlm_utils::simple_initiator_socket_b::register_nb_transport_bw
void register_nb_transport_bw(MODULE *mod, sync_enum_type(MODULE::*cb)(transaction_type &, phase_type &, sc_core::sc_time &))
Definition: simple_initiator_socket.h:97
sc_core::sc_module
Definition: sc_module.hh:97
tlm::tlm_phase
Definition: phase.hh:47
adapt_gp2ext::target_payload_type
tlm::tlm_generic_payload target_payload_type
Definition: extension_adaptors.h:106
adapt_gp2ext::m_ext
my_extension m_ext
Definition: extension_adaptors.h:208
adapt_gp2ext::initiator_socket
initiator_socket_type initiator_socket
Definition: extension_adaptors.h:113
adapt_ext2gp::target_socket
target_socket_type target_socket
Definition: extension_adaptors.h:57
tlm::TLM_COMPLETED
@ TLM_COMPLETED
Definition: fw_bw_ifs.hh:65
adapt_ext2gp::initiator_socket_type
tlm_utils::simple_initiator_socket< adapt_ext2gp, BUSWIDTH, tlm::tlm_base_protocol_types > initiator_socket_type
Definition: extension_adaptors.h:53
sc_core
Definition: messages.cc:31
tlm::tlm_dmi
Definition: dmi.hh:46
adapt_gp2ext::target_socket_type
tlm_utils::simple_target_socket< adapt_gp2ext, BUSWIDTH, tlm::tlm_base_protocol_types > target_socket_type
Definition: extension_adaptors.h:110
sc_core::sc_module::sc_module
sc_module()
Definition: sc_module.cc:256
adapt_gp2ext::invalidate_dmi_pointers
void invalidate_dmi_pointers(sc_dt::uint64 start_range, sc_dt::uint64 end_range)
Definition: extension_adaptors.h:200
adapt_gp2ext::get_dmi_pointer
bool get_dmi_pointer(target_payload_type &trans, tlm::tlm_dmi &dmi_data)
Definition: extension_adaptors.h:171
tlm_utils::simple_target_socket_b::register_transport_dbg
void register_transport_dbg(MODULE *mod, unsigned int(MODULE::*cb)(transaction_type &))
Definition: simple_target_socket.h:125
adapt_ext2gp::initiator_socket
initiator_socket_type initiator_socket
Definition: extension_adaptors.h:58
adapt_gp2ext::SC_HAS_PROCESS
SC_HAS_PROCESS(adapt_gp2ext)
tlm::tlm_generic_payload::clear_extension
void clear_extension(const T *ext)
Definition: gp.hh:396
tlm_utils::simple_initiator_socket_b::register_invalidate_direct_mem_ptr
void register_invalidate_direct_mem_ptr(MODULE *mod, void(MODULE::*cb)(sc_dt::uint64, sc_dt::uint64))
Definition: simple_initiator_socket.h:105
my_extension::m_data
int m_data
Definition: my_extension.h:64
adapt_gp2ext::m_initiator_ext
my_extension * m_initiator_ext
Definition: extension_adaptors.h:209
adapt_gp2ext::backward_nb_transport
tlm::tlm_sync_enum backward_nb_transport(target_payload_type &trans, tlm::tlm_phase &phase, sc_core::sc_time &t)
Definition: extension_adaptors.h:163
sc_dt::uint64
uint64_t uint64
Definition: sc_nbdefs.hh:206
adapt_gp2ext::transport_debug
unsigned int transport_debug(target_payload_type &trans)
Definition: extension_adaptors.h:196
adapt_ext2gp::adapt_ext2gp
adapt_ext2gp(sc_core::sc_module_name name_)
Definition: extension_adaptors.h:61
adapt_ext2gp::initiator_payload_type
tlm::tlm_generic_payload initiator_payload_type
Definition: extension_adaptors.h:50
adapt_ext2gp::target_socket_type
tlm_utils::simple_target_socket< adapt_ext2gp, BUSWIDTH, my_extended_payload_types > target_socket_type
Definition: extension_adaptors.h:55
sc_core::sc_time
Definition: sc_time.hh:49
tlm_utils::simple_initiator_socket
Definition: simple_initiator_socket.h:173
adapt_ext2gp::SC_HAS_PROCESS
SC_HAS_PROCESS(adapt_ext2gp)
sc_core::sc_module_name
Definition: sc_module_name.hh:41
tlm_utils::simple_target_socket_b::register_get_direct_mem_ptr
void register_get_direct_mem_ptr(MODULE *mod, bool(MODULE::*cb)(transaction_type &, tlm::tlm_dmi &))
Definition: simple_target_socket.h:133
tlm::tlm_generic_payload::get_extension
void get_extension(T *&ext) const
Definition: gp.hh:381
tlm_utils::simple_target_socket
Definition: simple_target_socket.h:605
adapt_ext2gp::get_dmi_pointer
bool get_dmi_pointer(target_payload_type &trans, tlm::tlm_dmi &dmi_data)
Definition: extension_adaptors.h:95
my_extension.h
adapt_gp2ext
Definition: extension_adaptors.h:102
tlm::tlm_generic_payload
Definition: gp.hh:133
adapt_gp2ext::adapt_gp2ext
adapt_gp2ext(sc_core::sc_module_name name_)
Definition: extension_adaptors.h:116
my_extended_payload_types
Definition: my_extension.h:50
ArmISA::t
Bitfield< 5 > t
Definition: miscregs_types.hh:67
adapt_ext2gp::transport_debug
unsigned int transport_debug(target_payload_type &trans)
Definition: extension_adaptors.h:106
adapt_gp2ext::initiator_payload_type
tlm::tlm_generic_payload initiator_payload_type
Definition: extension_adaptors.h:105
tlm::tlm_base_protocol_types
Definition: fw_bw_ifs.hh:213
adapt_gp2ext::target_socket
target_socket_type target_socket
Definition: extension_adaptors.h:112
tlm::tlm_generic_payload::set_extension
T * set_extension(T *ext)
Definition: gp.hh:357
tlm::tlm_sync_enum
tlm_sync_enum
Definition: fw_bw_ifs.hh:48
adapt_ext2gp::invalidate_dmi_pointers
void invalidate_dmi_pointers(sc_dt::uint64 start_range, sc_dt::uint64 end_range)
Definition: extension_adaptors.h:110
my_extension
Definition: my_extension.h:26
adapt_ext2gp::backward_nb_transport
tlm::tlm_sync_enum backward_nb_transport(target_payload_type &trans, tlm::tlm_phase &phase, sc_core::sc_time &t)
Definition: extension_adaptors.h:88
adapt_gp2ext::forward_nb_transport
tlm::tlm_sync_enum forward_nb_transport(initiator_payload_type &trans, tlm::tlm_phase &phase, sc_core::sc_time &t)
Definition: extension_adaptors.h:137
tlm_utils::simple_target_socket_b::register_nb_transport_fw
void register_nb_transport_fw(MODULE *mod, sync_enum_type(MODULE::*cb)(transaction_type &, phase_type &, sc_core::sc_time &))
Definition: simple_target_socket.h:108

Generated on Wed Sep 30 2020 14:02:18 for gem5 by doxygen 1.8.17