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) {
45 }
46 virtual void finalize() {
47 // Avoid recursive calls to finalize_instance
48 SIM_set_object_configured(obj());
49
50 // Make sure the Adapter is configured
51 simulation_ref_.require();
52 }
53
54 // GasketClassInterface
56 return this;
57 }
58 virtual void createGasket(iface::SimulationInterface *simulation) {
59 setSimulation(simulation);
60 sc_core::sc_object *obj = sc_core::sc_find_object(
61 sc_pcie_device_name_.c_str());
62 if (!obj) {
63 SIM_LOG_ERROR(simulation->simics_object(), Log_Configuration,
64 "Invalid SystemC object name for "
65 "PcieDeviceQueryInterface and "
66 "PcieBaseAddressRegisterQueryInterface implementor");
67 return;
68 }
69
70 this->connect(obj);
71 }
72 static conf_class_t *registerGasketClass(const char* class_name) {
73 conf_class_t *cls = SIM_get_class(class_name);
74 if (SIM_clear_exception() == SimExc_No_Exception) {
75 return cls;
76 }
77
78 auto new_cls = make_class<PcieGasketClass>(
79 class_name,
80 "model of SystemC compsite pcie gasket class",
81 "Class for binding Simics interface to SystemC Pcie Gasket.",
82 Sim_Class_Kind_Pseudo);
83
84 new_cls->add(Attribute("device", "s",
85 "Name of the SystemC object that implements the"
86 " PcieDeviceQueryInterface and"
87 " PcieBaseAddressRegisterQueryInterface."
88 "All TLM2 sockets returned by the object must"
89 " have BUSWIDTH = 32 and TYPES ="
90 " tlm::tlm_base_protocol_types",
91 ATTR_CLS_VAR(PcieGasketClass,
92 sc_pcie_device_name_),
93 Sim_Attr_Required));
94 new_cls->add(Attribute("simulation", "o",
95 "Simics object implementing the SystemC"
96 " Simulation interface.",
97 ATTR_CLS_VAR(PcieGasketClass, simulation_ref_),
98 Sim_Attr_Required));
99 PcieGasketBase::initClassInternal<PcieGasketClass>(new_cls.get());
100
101 return *new_cls.get();
102 }
103
104 private:
105 std::string sc_pcie_device_name_;
106 ConfObjectRef simulation_ref_;
107};
108} // namespace composite
109} // namespace systemc // NOLINT
110} // namespace simics // NOLINT
111
112#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 createGasket(iface::SimulationInterface *simulation)
Definition: pcie_gasket_class.h:58
virtual void finalize()
Definition: pcie_gasket_class.h:46
static conf_class_t * registerGasketClass(const char *class_name)
Definition: pcie_gasket_class.h:72
virtual iface::ScVersionInterface * version()
Definition: pcie_gasket_class.h:55
PcieGasketClass(ConfObjectRef o)
Definition: pcie_gasket_class.h:42
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:206
void setPcieTypeAndForwardTarget(ConfObjectRef obj)
Definition: pcie_gasket.h:257
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:80