SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
tlm_fw_transport_if_handler.h
Go to the documentation of this file.
1// -*- mode: C++; c-file-style: "virtutech-c++" -*-
2
3/*
4 © 2015 Intel Corporation
5
6 This software and the related documents are Intel copyrighted materials, and
7 your use of them is governed by the express license under which they were
8 provided to you ("License"). Unless the License provides otherwise, you may
9 not use, modify, copy, publish, distribute, disclose or transmit this software
10 or the related documents without Intel's prior written permission.
11
12 This software and the related documents are provided as is, with no express or
13 implied warranties, other than those that are expressly stated in the License.
14*/
15
16#ifndef SIMICS_SYSTEMC_AWARENESS_TLM_FW_TRANSPORT_IF_HANDLER_H
17#define SIMICS_SYSTEMC_AWARENESS_TLM_FW_TRANSPORT_IF_HANDLER_H
18
24
25#include <tlm>
26#include <unordered_map>
27
28namespace simics {
29namespace systemc {
30namespace awareness {
31
32template <typename TYPES = tlm::tlm_base_protocol_types>
34 : public TlmBaseHandler, public tlm::tlm_fw_transport_if<TYPES> {
35 public:
36 typedef tlm::tlm_fw_transport_if<TYPES> FW_IF;
38
39 typedef typename TYPES::tlm_payload_type transaction_type;
40 typedef typename TYPES::tlm_phase_type phase_type;
41
42 tlm::tlm_sync_enum nb_transport_fw(transaction_type &trans, // NOLINT
43 phase_type &phase, // NOLINT
44 sc_core::sc_time &t) { // NOLINT
47 nb_transport_fw_pre, proxy(), &trans, &phase, &t);
48
49 tlm::tlm_sync_enum ret = fw_if()->nb_transport_fw(trans, phase, t);
50
51 // suppress DMI hint when there is an instrumentation tool
52 if (controller() && controller()->get_connections_state() !=
54 (&trans)->set_dmi_allowed(false);
55
58 nb_transport_fw_post,
59 proxy(), &trans, &phase, &t, &ret);
60 return ret;
61 }
62 void b_transport(transaction_type &trans, // NOLINT
63 sc_core::sc_time &local_time_offset) { //NOLINT
66 b_transport_pre, proxy(), &trans,
67 &local_time_offset);
68 fw_if()->b_transport(trans, local_time_offset);
69
70 // suppress DMI hint when there is an instrumentation tool
71 if (controller() && controller()->get_connections_state() !=
73 (&trans)->set_dmi_allowed(false);
74
77 b_transport_post, proxy(), &trans,
78 &local_time_offset);
79 }
80 bool get_direct_mem_ptr(transaction_type &trans, // NOLINT
81 tlm::tlm_dmi &dmi_data) { // NOLINT
84 get_direct_mem_ptr_pre, proxy(), &trans, &dmi_data);
85
86 bool ret = fw_if()->get_direct_mem_ptr(trans, dmi_data);
87
90 get_direct_mem_ptr_post,
91 proxy(), &trans, &dmi_data, &ret);
92
93 // suppress DMI when there is an instrumentation tool
94 if (controller() && controller()->get_connections_state() !=
96 return false;
97 }
98 return ret;
99 }
100 unsigned int transport_dbg(transaction_type &trans) { // NOLINT
103 transport_dbg_pre, proxy(), &trans);
104
105 unsigned int ret = fw_if()->transport_dbg(trans);
106
107 // suppress DMI hint when there is an instrumentation tool
108 if (controller() && controller()->get_connections_state() !=
110 (&trans)->set_dmi_allowed(false);
111
114 transport_dbg_post, proxy(), &trans, &ret);
115 return ret;
116 }
117
119 sc_core::sc_interface* sc_iface = iface();
120 if (fw_if_map_.find(sc_iface) == fw_if_map_.end()) {
121 // A micro performance benchmark shows dynamic_cast is a hotspot,
122 // thus the result of it is cached here
123 fw_if_map_.emplace(sc_iface, dynamic_cast<FW_IF*>(sc_iface));
124 }
125 return fw_if_map_[sc_iface];
126 }
127
128 private:
129 std::unordered_map<sc_core::sc_interface*, FW_IF*> fw_if_map_;
130};
131
132template <typename IF_PROVIDER = sc_core::sc_port_base,
133 typename TYPES = tlm::tlm_base_protocol_types>
134class TlmFwTransportIfHandler: public tlm::tlm_fw_transport_if<TYPES>,
136 public:
137 typedef tlm::tlm_fw_transport_if<TYPES> FW_IF;
138 typedef typename TYPES::tlm_payload_type transaction_type;
139 typedef typename TYPES::tlm_phase_type phase_type;
140
141 explicit TlmFwTransportIfHandler(IF_PROVIDER *fw_if) {
142 first_.set_tlm_iface(new TlmIface(&second_));
143 second_.set_tlm_iface(new TlmIfaceProvider<IF_PROVIDER,
144 TYPES, FW_IF>(fw_if));
145 }
147 first_.set_tlm_iface(new TlmIface(&second_));
148 second_.set_tlm_iface(new TlmIface(fw_if));
149 }
151 tlm_utils::callback_binder_fw<TYPES> *binder_fw)
152 : registry_(binder_fw, this) {
153 first_.set_tlm_iface(new TlmIface(&second_));
154 second_.set_tlm_iface(new TlmIface(binder_fw));
155 }
156
157 tlm::tlm_sync_enum nb_transport_fw(transaction_type &trans, // NOLINT
158 phase_type &phase, // NOLINT
159 sc_core::sc_time &t) { // NOLINT
160 return first_.nb_transport_fw(trans, phase, t);
161 }
162 void b_transport(transaction_type &trans, // NOLINT
163 sc_core::sc_time &local_time_offset) { //NOLINT
164 first_.b_transport(trans, local_time_offset);
165 }
166
168 tlm::tlm_dmi &dmi_data) { //NOLINT
169 return first_.get_direct_mem_ptr(trans, dmi_data);
170 }
171 unsigned int transport_dbg(transaction_type &trans) { // NOLINT
172 return first_.transport_dbg(trans);
173 }
175 return &first_;
176 }
178 return &second_;
179 }
180
181 private:
184 TlmMultiHandlerRegistry registry_;
185};
186
187} // namespace awareness
188} // namespace systemc
189} // namespace simics
190
191#endif
Definition: tlm_base_handler.h:68
virtual instrumentation::ToolController * controller()
Definition: tlm_base_handler.h:81
virtual sc_core::sc_interface * iface()
Definition: tlm_base_handler.h:92
virtual ProxyInterface * proxy()
Definition: tlm_base_handler.h:84
Definition: tlm_fw_transport_if_handler.h:34
unsigned int transport_dbg(transaction_type &trans)
Definition: tlm_fw_transport_if_handler.h:100
TYPES::tlm_payload_type transaction_type
Definition: tlm_fw_transport_if_handler.h:39
TYPES::tlm_phase_type phase_type
Definition: tlm_fw_transport_if_handler.h:40
tlm::tlm_sync_enum nb_transport_fw(transaction_type &trans, phase_type &phase, sc_core::sc_time &t)
Definition: tlm_fw_transport_if_handler.h:42
FW_IF * fw_if()
Definition: tlm_fw_transport_if_handler.h:118
bool get_direct_mem_ptr(transaction_type &trans, tlm::tlm_dmi &dmi_data)
Definition: tlm_fw_transport_if_handler.h:80
tlm::tlm_fw_transport_if< TYPES > FW_IF
Definition: tlm_fw_transport_if_handler.h:36
void b_transport(transaction_type &trans, sc_core::sc_time &local_time_offset)
Definition: tlm_fw_transport_if_handler.h:62
TlmFwTransportIfHandlerBase()
Definition: tlm_fw_transport_if_handler.h:37
Definition: tlm_fw_transport_if_handler.h:135
void b_transport(transaction_type &trans, sc_core::sc_time &local_time_offset)
Definition: tlm_fw_transport_if_handler.h:162
TlmFwTransportIfHandler(tlm_utils::callback_binder_fw< TYPES > *binder_fw)
Definition: tlm_fw_transport_if_handler.h:150
virtual TlmHandlerInterface * firstHandler()
Definition: tlm_fw_transport_if_handler.h:174
tlm::tlm_sync_enum nb_transport_fw(transaction_type &trans, phase_type &phase, sc_core::sc_time &t)
Definition: tlm_fw_transport_if_handler.h:157
TlmFwTransportIfHandler(IF_PROVIDER *fw_if)
Definition: tlm_fw_transport_if_handler.h:141
bool get_direct_mem_ptr(transaction_type &trans, tlm::tlm_dmi &dmi_data)
Definition: tlm_fw_transport_if_handler.h:167
TYPES::tlm_payload_type transaction_type
Definition: tlm_fw_transport_if_handler.h:138
tlm::tlm_fw_transport_if< TYPES > FW_IF
Definition: tlm_fw_transport_if_handler.h:137
unsigned int transport_dbg(transaction_type &trans)
Definition: tlm_fw_transport_if_handler.h:171
TYPES::tlm_phase_type phase_type
Definition: tlm_fw_transport_if_handler.h:139
virtual TlmHandlerInterface * secondHandler()
Definition: tlm_fw_transport_if_handler.h:177
TlmFwTransportIfHandler(FW_IF *fw_if)
Definition: tlm_fw_transport_if_handler.h:146
Definition: tlm_handler_interface.h:26
Definition: tlm_base_handler.h:55
Definition: tlm_base_handler.h:39
Definition: tlm_multi_handler_interface.h:25
Definition: tlm_multi_handler_registry.h:30
@ EMPTY
Definition: tool_controller.h:77
Definition: pci_bus_interface.h:24
#define DISPATCH_TOOL_CHAIN(controller, iface_type, func,...)
Definition: tool_controller.h:54