28#ifndef SIMICS_SYSTEMC_COMPOSITE_PCIE_GASKET_H
29#define SIMICS_SYSTEMC_COMPOSITE_PCIE_GASKET_H
33#include <simics/cc-api.h>
67 cls->add(Attribute(
"upstream_target",
"o|n",
68 "The PCIe upstream target to connect to.",
70 cls->add(Attribute(
"address_id_mem_map",
"[[[ii]i]*]",
71 "Internal. The map from MEM address range to"
73 ATTR_GETTER(C, addressIdMemMap),
nullptr));
74 cls->add(Attribute(
"address_id_io_map",
"[[[ii]i]*]",
75 "Internal. The map from IO address range to"
77 ATTR_GETTER(C, addressIdIoMap),
nullptr));
78 cls->add(Attribute(
"enable_base_address_subtraction",
"b",
79 "If set, MEM/IO transaction will receive only the"
80 " offset to the base address. Otherwise, it receives"
81 " the whole base address + offset. Default enabled",
82 ATTR_GETTER(C, enableBaseAddressSubtraction),
83 ATTR_SETTER(C, setEnableBaseAddressSubtraction)));
84 cls->add(pcie_device_simics_adapter);
85 cls->add(transaction_simics_adapter);
86 cls->add(signal_simics_adapter);
90 if (SIM_clear_exception() != SimExc_No_Exception) {
91 std::cerr <<
"ERROR: Simics class pcie_map_helper_cpp is not"
92 <<
" registered. Please build module"
93 <<
" pcie-map-helper-c++ first."
97 SIM_register_port(*cls,
"port.mem", map_helper,
98 " The help object maps to the PCIe MEM space");
99 SIM_register_port(*cls,
"port.io", map_helper,
100 "The help object maps to the PCIe IO space");
101 SIM_register_port(*cls,
"port.msg", map_helper,
102 "The help object mapes to the PCIe MSG space");
116template<
unsigned int BUSWIDTH = 32,
117 typename TYPES = tlm::tlm_base_protocol_types>
127 simulation_(simulation) {
134 simics::ConfObjectRef obj)
138 simulation_(simulation),
149 void connected(conf_object_t *port_obj, uint16_t
id)
override {
152 if (port_obj ==
nullptr) {
154 "can't connect to NULL");
162 "can't connect to '%s', currently connected to '%s'",
163 SIM_object_name(port_obj),
170 interconnect_.connected(
id);
176 if (port_obj ==
nullptr) {
178 "can't disconnect from NULL");
184 "can't disconnect from '%s', currently connected"
186 SIM_object_name(port_obj),
193 interconnect_.disconnected(
id);
200 interconnect_.hotReset();
205 template<
typename TPcieDevice>
213 simics2tlm::createGasket(
214 &interconnect_.pcie_device_target_socket, o));
218 simics2tlm::createGasket(
219 &interconnect_.transaction_target_socket, o));
222 systemc_signal_.
set_pin(&interconnect_.warm_reset_pin,
false, o);
226 tlm2simics::createMultiGasket(
227 &interconnect_.pcie_map_initiator_socket, o));
229 tlm2simics::createMultiGasket(
230 &interconnect_.pcie_map_initiator_socket, o));
234 interconnect_.connect(
244 return interconnect_.addressIdMemMap();
248 return interconnect_.addressIdIoMap();
252 return interconnect_.enable_base_address_subtraction;
255 interconnect_.enable_base_address_subtraction = val;
258 SIM_set_attribute_default(
259 SIM_object_descendant(obj,
"port.mem"),
"pcie_type",
261 SIM_set_attribute_default(
262 SIM_object_descendant(obj,
"port.mem"),
"forward_target",
263 SIM_make_attr_object(obj));
264 SIM_set_attribute_default(
265 SIM_object_descendant(obj,
"port.io"),
"pcie_type",
267 SIM_set_attribute_default(
268 SIM_object_descendant(obj,
"port.io"),
"forward_target",
269 SIM_make_attr_object(obj));
270 SIM_set_attribute_default(
271 SIM_object_descendant(obj,
"port.msg"),
"pcie_type",
273 SIM_set_attribute_default(
274 SIM_object_descendant(obj,
"port.msg"),
"forward_target",
275 SIM_make_attr_object(obj));
282 interconnect_.createCfgMapHelper();
296 simics::ConfObjectRef obj_;
304 composite::PcieGasketBase::initClassInternal<T>(cls);
Definition: connector.h:76
Provides get/set functionality for a connector attribute, typically registered by using the Connector...
Definition: connector.h:41
Utility class that handles the context switching, using RAII methodology.
Definition: context.h:33
Definition: pcie_gasket.h:59
Connector< tlm2simics::PcieTransaction > simics_transaction_target_
Definition: pcie_gasket.h:106
PcieGasketBase * is_composite_pcie_gasket
Definition: pcie_gasket.h:61
ConnectorProxy< tlm2simics::PcieMap > simics_pcie_map_target_
Definition: pcie_gasket.h:107
static void initClassInternal(ConfClass *cls)
Definition: pcie_gasket.h:63
Composite Pcie Gasket to help the wrapping of a SystemC PCIe (multifunction) endpoint in Simics.
Definition: pcie_gasket.h:121
void hot_reset() override
Definition: pcie_gasket.h:198
void createCfgMapHelper()
Definition: pcie_gasket.h:281
void disconnected(conf_object_t *port_obj, uint16_t id) override
Definition: pcie_gasket.h:173
bool enableBaseAddressSubtraction() const
Definition: pcie_gasket.h:251
std::map< std::pair< size_t, size_t >, size_t > addressIdMemMap() const
Definition: pcie_gasket.h:243
void connected(conf_object_t *port_obj, uint16_t id) override
Definition: pcie_gasket.h:149
void connect(TPcieDevice *device)
Definition: pcie_gasket.h:206
PcieGasket(iface::SimulationInterface *simulation, simics::ConfObjectRef obj)
Definition: pcie_gasket.h:133
PcieGasket(iface::SimulationInterface *simulation)
Definition: pcie_gasket.h:123
void setPcieTypeAndForwardTarget(ConfObjectRef obj)
Definition: pcie_gasket.h:257
void setEnableBaseAddressSubtraction(const bool &val)
Definition: pcie_gasket.h:254
std::map< std::pair< size_t, size_t >, size_t > addressIdIoMap() const
Definition: pcie_gasket.h:247
Definition: pcie_mapping_interconnect.h:106
Interface that allows the Simics glue to perform snooping and automatic connection of the device's ta...
Definition: pcie_device_query_interface.h:50
Interface required from a SystemC PCIe device in order to connect to Simics.
Definition: pcie_device_query_interface.h:29
Adapter for Simics pcie_device interface.
Definition: pcie_device_simics_adapter.h:32
Definition: pcie_device_query_interface.h:92
Adapter for Simics signal interface.
Definition: signal_simics_adapter.h:32
Interface to the SystemC simulation.
Definition: simulation_interface.h:27
virtual ConfObjectRef simics_object() const =0
Adapter for Simics signal interface.
Definition: transaction_simics_adapter.h:32
void set_pin(sc_core::sc_in< bool > *target_pin, bool initial_level, const ConfObjectRef &obj)
Adapter for Signal gasket.
Definition: signal_gasket_adapter.h:35
SignalGasketAdapter(SignalInterface *signal, iface::SimulationInterface *simulation)
Definition: signal_gasket_adapter.h:37
void set_gasket(GasketInterface::Ptr gasketInterface)
Definition: gasket_owner.h:39
Adapter for PcieDevice gasket.
Definition: pcie_device_gasket_adapter.h:33
PcieDeviceGasketAdapter(PcieDeviceInterface *pcie_device, iface::SimulationInterface *simulation)
Definition: pcie_device_gasket_adapter.h:35
Class that implements the Simics pcie_device interface and translates it into a TLM transaction.
Definition: pcie_device.h:33
Definition: pcie_transaction.h:36
Adapter for Transaction gasket.
Definition: transaction_gasket_adapter.h:33
TransactionGasketAdapter(TransactionInterface *transaction, iface::SimulationInterface *simulation)
Definition: transaction_gasket_adapter.h:35
conf_class_t * SIM_get_class(const char *NOTNULL name)
void SCLCompositePcieInit(...)
Definition: class_decorator.h:34
@ PCIE_Type_Mem
Definition: pcie_type.h:24
@ PCIE_Type_Msg
Definition: pcie_type.h:27
@ PCIE_Type_IO
Definition: pcie_type.h:25