SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
gasket_class.h
Go to the documentation of this file.
1// -*- mode: C++; c-file-style: "virtutech-c++" -*-
2
3/*
4 © 2017 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_SIMICS2TLM_GASKET_CLASS_H
17#define SIMICS_SYSTEMC_SIMICS2TLM_GASKET_CLASS_H
18
19#include <systemc>
20
21
22#include <simics/simulator/sim-get-class.h>
30
31#include <string>
32
33namespace simics {
34namespace systemc {
35namespace simics2tlm {
36
37template<class TGasket,
38 class TGasketAdapter,
39 template<class, class> class TSimicsAdapter,
40 class TGasketInterface>
42 : public ConfObject, public TGasketAdapter, public GasketClassInterface,
45 public:
46 explicit GasketClass(ConfObjectRef o)
47 : ConfObject(o), TGasketAdapter(&gasket_, this) {}
48 virtual void finalize() {
49 // Avoid recursive calls to finalize_instance
50 SIM_set_object_configured(obj());
51
52 // Make sure the Adapter is configured
53 simulation_ref_.require();
54 }
55
56 // GasketClassInterface
58 return this;
59 }
60 virtual void createGasket(iface::SimulationInterface *simulation) {
61 setSimulation(simulation);
62 gasket_.set_gasket(createGasketByName(socket_name_, simics_object()));
63 }
64
65 // ScInitiatorGasketInterface
66 virtual void set_dmi(bool enable) {
67 gasket_.gasket()->set_dmi(enable);
68 }
69 virtual bool is_dmi_enabled() {
70 return gasket_.gasket()->is_dmi_enabled();
71 }
72 virtual char *print_dmi_table() {
73 return MM_STRDUP(
74 gasket_.gasket()->get_dmi_data_table()->print().c_str());
75 }
76
77 static conf_class_t *registerGasketClass(const char* class_name) {
78 conf_class_t *cls = SIM_get_class(class_name);
79 if (SIM_clear_exception() == SimExc_No_Exception) {
80 return cls;
81 }
82
83 auto new_cls = make_class<GasketClass>(
84 class_name,
85 "model of SystemC simics2tlm gasket class",
86 "Class for binding Simics interface to SystemC Gasket.");
87
88 new_cls->add(iface::createAdapter<
89 TSimicsAdapter<GasketClass, TGasketInterface>>());
90 new_cls->add(iface::createAdapter<
92 new_cls->add(Attribute("target", "s",
93 "Name of the target socket the gasket is"
94 " connected to.",
95 ATTR_CLS_VAR(GasketClass, socket_name_),
96 Sim_Attr_Required));
97 new_cls->add(Attribute("simulation", "o",
98 "Simics object implementing the SystemC"
99 " Simulation interface.",
100 ATTR_CLS_VAR(GasketClass, simulation_ref_),
101 Sim_Attr_Required));
102
103 return *new_cls.get();
104 }
105
106 private:
107 std::string socket_name_;
108 ConfObjectRef simulation_ref_;
109 TGasket gasket_;
110};
111} // namespace simics2tlm
112} // namespace systemc // NOLINT
113} // namespace simics // NOLINT
114
115#endif
Definition: gasket_class_interface.h:28
Interface to the SystemC simulation.
Definition: simulation_interface_proxy.h:27
void setSimulation(iface::SimulationInterface *simulation)
Definition: simulation_interface_proxy.h:32
virtual ConfObjectRef simics_object() const
Definition: simulation_interface_proxy.h:49
Definition: version.h:37
Definition: sc_initiator_gasket_interface.h:24
Definition: sc_initiator_gasket_simics_adapter.h:35
Definition: sc_version_interface.h:27
Interface to the SystemC simulation.
Definition: simulation_interface.h:27
Definition: gasket_class.h:44
static conf_class_t * registerGasketClass(const char *class_name)
Definition: gasket_class.h:77
virtual void finalize()
Definition: gasket_class.h:48
GasketClass(ConfObjectRef o)
Definition: gasket_class.h:46
virtual iface::ScVersionInterface * version()
Definition: gasket_class.h:57
virtual void createGasket(iface::SimulationInterface *simulation)
Definition: gasket_class.h:60
virtual void set_dmi(bool enable)
Definition: gasket_class.h:66
virtual bool is_dmi_enabled()
Definition: gasket_class.h:69
virtual char * print_dmi_table()
Definition: gasket_class.h:72
GasketInterface::Ptr createGasketByName(std::string socket_name, const simics::ConfObjectRef &simics_obj)
Factory for creating a Gasket and bind it to a target socket.
InterfaceSimicsAdapter & createAdapter()
Create a SimicsAdapter that can be registered with a ConfClass.
Definition: simics_adapter.h:172
conf_class_t * SIM_get_class(const char *NOTNULL name)
Definition: pci_bus_interface.h:24