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