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