SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
pcie_gasket_class.h
Go to the documentation of this file.
1/*
2 © 2024 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_COMPOSITE_PCIE_GASKET_CLASS_H
15#define SIMICS_SYSTEMC_COMPOSITE_PCIE_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 composite {
32
33template<unsigned int BUSWIDTH = 32,
34 typename TYPES = tlm::tlm_base_protocol_types>
36 : public ConfObject, public SimulationInterfaceProxy,
37 public PcieGasket<BUSWIDTH, TYPES>,
38 public GasketClassInterface, public Version {
39 public:
40 explicit PcieGasketClass(ConfObjectRef o)
41 : ConfObject(o), PcieGasket<BUSWIDTH, TYPES>(this, o) {
42 }
43 void finalize() override {
44 // Avoid recursive calls to finalize_instance
45 SIM_set_object_configured(obj());
46
47 // Make sure the Adapter is configured
48 simulation_ref_.require();
49 }
50
51 // GasketClassInterface
53 return this;
54 }
55 void createGasket(iface::SimulationInterface *simulation) override {
56 setSimulation(simulation);
57 sc_core::sc_object *obj = sc_core::sc_find_object(
58 sc_pcie_device_name_.c_str());
59 if (!obj) {
60 SIM_LOG_ERROR(simulation->simics_object(), Log_Configuration,
61 "Invalid SystemC object name for "
62 "PcieDeviceQueryInterface and "
63 "PcieBaseAddressRegisterQueryInterface implementor");
64 return;
65 }
66
67 this->connect(obj);
68 }
69 static conf_class_t *registerGasketClass(const char* class_name) {
70 conf_class_t *cls = SIM_get_class(class_name);
71 if (SIM_clear_exception() == SimExc_No_Exception) {
72 return cls;
73 }
74
75 auto new_cls = make_class<PcieGasketClass>(
76 class_name,
77 "model of SystemC compsite pcie gasket class",
78 "Class for binding Simics interface to SystemC Pcie Gasket.",
79 Sim_Class_Kind_Pseudo);
80
81 new_cls->add(Attribute("device", "s",
82 "Name of the SystemC object that implements the"
83 " PcieDeviceQueryInterface and"
84 " PcieBaseAddressRegisterQueryInterface."
85 "All TLM2 sockets returned by the object must"
86 " have BUSWIDTH = 32 and TYPES ="
87 " tlm::tlm_base_protocol_types",
88 ATTR_CLS_VAR(PcieGasketClass,
89 sc_pcie_device_name_),
90 Sim_Attr_Required));
91 new_cls->add(Attribute("simulation", "o",
92 "Simics object implementing the SystemC"
93 " Simulation interface.",
94 ATTR_CLS_VAR(PcieGasketClass, simulation_ref_),
95 Sim_Attr_Required));
96 PcieGasketBase::initClassInternal<PcieGasketClass>(new_cls.get());
97
98 return *new_cls.get();
99 }
100
101 private:
102 std::string sc_pcie_device_name_;
103 ConfObjectRef simulation_ref_;
104};
105} // namespace composite
106} // namespace systemc // NOLINT
107} // namespace simics // NOLINT
108
109#endif
Definition: gasket_class_interface.h:26
Interface to the SystemC simulation.
Definition: simulation_interface_proxy.h:25
void setSimulation(iface::SimulationInterface *simulation)
Definition: simulation_interface_proxy.h:30
Definition: version.h:41
Definition: pcie_gasket_class.h:38
void finalize() override
Definition: pcie_gasket_class.h:43
static conf_class_t * registerGasketClass(const char *class_name)
Definition: pcie_gasket_class.h:69
PcieGasketClass(ConfObjectRef o)
Definition: pcie_gasket_class.h:40
void createGasket(iface::SimulationInterface *simulation) override
Definition: pcie_gasket_class.h:55
iface::ScVersionInterface * version() override
Definition: pcie_gasket_class.h:52
Composite Pcie Gasket to help the wrapping of a SystemC PCIe (multifunction) endpoint in Simics.
Definition: pcie_gasket.h:127
void connect(TPcieDevice *device)
Definition: pcie_gasket.h:212
Definition: sc_version_interface.h:25
Interface to the SystemC simulation.
Definition: simulation_interface.h:25
virtual ConfObjectRef simics_object() const =0
conf_class_t * SIM_get_class(const char *NOTNULL name)
@ Log_Configuration
Definition: adapter_log_groups.h:23
Definition: adapter.h:79