SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
sc_tlm_fw_transport_simics_adapter.h
Go to the documentation of this file.
1/*
2 © 2017 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_IFACE_INJECTION_SC_TLM_FW_TRANSPORT_SIMICS_ADAPTER_H
15#define SIMICS_SYSTEMC_IFACE_INJECTION_SC_TLM_FW_TRANSPORT_SIMICS_ADAPTER_H
16
21
22#include <systemc-interfaces.h>
23
24#include <tlm>
25
26#include <string>
27#include <vector>
28
29namespace simics {
30namespace systemc {
31namespace iface {
32namespace injection {
33
34template<typename TBase,
35 typename TYPES = tlm::tlm_base_protocol_types,
36 typename TInterface = tlm::tlm_fw_transport_if<TYPES> >
38 : public SimicsAdapter<sc_tlm_fw_transport_interface_t> {
39 public:
40 typedef typename TYPES::tlm_payload_type transaction_type;
42 : SimicsAdapter<sc_tlm_fw_transport_interface_t>(
43 SC_TLM_FW_TRANSPORT_INTERFACE, init_iface()) {
44 }
45
46 static sc_tlm_sync_enum_t nb_transport_fw(conf_object_t *obj,
47 attr_value_t trans,
48 ::uint64 phase, ::uint64 t) {
49 transaction_type *payload = NULL;
50 typename TYPES::tlm_phase_type p;
51 p = static_cast<tlm::tlm_phase_enum>(phase);
52 sc_core::sc_time t2 = sc_core::sc_time::from_seconds(1.0 * t / 1e12);
54 payload = registry.attrToPayload(obj, &trans);
55 if (!payload)
56 return SC_TLM_ATTR_ERROR;
57
58 tlm::tlm_sync_enum ret =
59 adapter<TBase, TInterface>(obj)->nb_transport_fw(*payload, p, t2);
60 payload->release();
61 return static_cast<sc_tlm_sync_enum_t>(ret);
62 }
63 static void b_transport(conf_object_t *obj, attr_value_t trans,
64 ::uint64 t) {
65 transaction_type *payload = NULL;
66 sc_core::sc_time t2 = sc_core::sc_time::from_seconds(1.0 * t / 1e12);
68 registry;
69 payload = registry.attrToPayload(obj, &trans);
70 if (!payload)
71 return;
72
73 adapter<TBase, TInterface>(obj)->b_transport(*payload, t2);
74 // No payload->release() in this b_transport.
75 // ScTlmBTransportInvoker is invoking release later.
76 }
77 static bool get_direct_mem_ptr(conf_object_t *obj, attr_value_t trans,
78 attr_value_t dmi_data) {
79 tlm::tlm_dmi dmi;
82 p.parse(&attr_dmi);
83
84 if (!p.reportInvalidAttrs())
85 return false;
86
87 transaction_type *payload = NULL;
89 payload = registry.attrToPayload(obj, &trans);
90 if (!payload)
91 return false;
92
93 bool ret = adapter<TBase, TInterface>(obj)->get_direct_mem_ptr(*payload,
94 dmi);
95 payload->release();
96 return ret;
97 }
98 static ::uint64 transport_dbg(conf_object_t *obj, attr_value_t trans) {
99 transaction_type *payload = NULL;
101 payload = registry.attrToPayload(obj, &trans);
102 if (!payload)
103 return 0;
104
105 ::uint64 ret = adapter<TBase, TInterface>(obj)->transport_dbg(*payload);
106 payload->release();
107 return ret;
108 }
109
110 private:
111 std::vector<std::string> description(conf_object_t *obj,
112 DescriptionType type) override {
113 return descriptionBase<TBase, TInterface>(obj, type);
114 }
115 sc_tlm_fw_transport_interface_t init_iface() {
116 sc_tlm_fw_transport_interface_t iface = {};
117 iface.nb_transport_fw = nb_transport_fw;
118 iface.b_transport = b_transport;
119 iface.get_direct_mem_ptr = get_direct_mem_ptr;
120 iface.transport_dbg = transport_dbg;
121 return iface;
122 }
123};
124
125} // namespace injection
126} // namespace iface
127} // namespace systemc
128} // namespace simics
129
130#endif
Base class for mapping Simics interface to a C++ interface.
Definition: simics_adapter.h:45
Definition: sc_tlm_fw_transport_simics_adapter.h:38
static void b_transport(conf_object_t *obj, attr_value_t trans, ::uint64 t)
Definition: sc_tlm_fw_transport_simics_adapter.h:63
::uint64 transport_dbg(conf_object_t *obj, attr_value_t trans)
Definition: sc_tlm_fw_transport_simics_adapter.h:98
static bool get_direct_mem_ptr(conf_object_t *obj, attr_value_t trans, attr_value_t dmi_data)
Definition: sc_tlm_fw_transport_simics_adapter.h:77
static sc_tlm_sync_enum_t nb_transport_fw(conf_object_t *obj, attr_value_t trans, ::uint64 phase, ::uint64 t)
Definition: sc_tlm_fw_transport_simics_adapter.h:46
ScTlmFwTransportSimicsAdapter()
Definition: sc_tlm_fw_transport_simics_adapter.h:41
TYPES::tlm_payload_type transaction_type
Definition: sc_tlm_fw_transport_simics_adapter.h:40
Definition: attr_dict_parser.h:38
bool parse(ParserInterface *parser)
Definition: attr_dmi.h:30
Definition: inject_registry.h:35
TPAYLOAD * attrToPayload(conf_object_t *obj, attr_value_t *attr)
Definition: inject_registry.h:37
DescriptionType
Definition: description_interface.h:23
Definition: adapter.h:79