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/*
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_TLM2SIMICS_GASKET_CLASS_H
15#define SIMICS_SYSTEMC_TLM2SIMICS_GASKET_CLASS_H
16
17#include <systemc>
18
19
20#include <simics/simulator/sim-get-class.h>
26
27#include <string>
28
29namespace simics {
30namespace systemc {
31namespace tlm2simics {
32
33template<class TGasket>
35 : public ConfObject, public GasketClassInterface, public Version {
36 public:
37 explicit GasketClass(ConfObjectRef o) : ConfObject(o) {}
38 void finalize() override {
39 // Avoid recursive calls to finalize_instance
40 SIM_set_object_configured(obj());
41
42 // Make sure the Adapter is configured
43 simulation_ref_.require();
44 }
46 return this;
47 }
48 void createGasket(iface::SimulationInterface *simulation) override {
49 object_->set_gasket(createGasketByName(socket_name_,
50 simulation->simics_object()));
51 }
52 static conf_class_t *registerGasketClass(const char* class_name) {
53 conf_class_t *cls = SIM_get_class(class_name);
54 if (SIM_clear_exception() == SimExc_No_Exception) {
55 return cls;
56 }
57
58 auto new_cls = make_class<GasketClass>(
59 class_name,
60 "model of SystemC tlm2simics gasket class",
61 "Class for binding Simics interface to SystemC Gasket.");
62
63 new_cls->add(Attribute("initiator", "s",
64 "Name of the initiator socket the gasket"
65 " is connected to.",
66 ATTR_CLS_VAR(GasketClass, socket_name_),
67 Sim_Attr_Required));
68 new_cls->add(Attribute("simulation", "o",
69 "Simics object implementing the SystemC"
70 " Simulation interface.",
71 ATTR_CLS_VAR(GasketClass, simulation_ref_),
72 Sim_Attr_Required));
73 new_cls->add(Attribute("object", "o|n",
74 "Simics object implementing the corresponding"
75 " interface of this gasket.",
76 ATTR_CLS_VAR(GasketClass, object_)));
77
78 return *new_cls.get();
79 }
80
81 private:
82 std::string socket_name_;
83 ConfObjectRef simulation_ref_;
84 Connector<TGasket> object_;
85};
86} // namespace tlm2simics
87} // namespace systemc
88} // namespace simics
89
90#endif
Provides get/set functionality for a connector attribute, typically registered by using the Connector...
Definition: connector.h:39
Definition: gasket_class_interface.h:26
Definition: version.h:41
Definition: sc_version_interface.h:25
Interface to the SystemC simulation.
Definition: simulation_interface.h:25
virtual ConfObjectRef simics_object() const =0
Definition: gasket_class.h:35
void createGasket(iface::SimulationInterface *simulation) override
Definition: gasket_class.h:48
void finalize() override
Definition: gasket_class.h:38
iface::ScVersionInterface * version() override
Definition: gasket_class.h:45
static conf_class_t * registerGasketClass(const char *class_name)
Definition: gasket_class.h:52
GasketClass(ConfObjectRef o)
Definition: gasket_class.h:37
GasketInterface::Ptr createGasketByName(std::string socket_name, const simics::ConfObjectRef &simics_obj)
conf_class_t * SIM_get_class(const char *NOTNULL name)
Definition: adapter.h:79