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