SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
adapter.h
Go to the documentation of this file.
1// -*- mode: C++; c-file-style: "virtutech-c++" -*-
2
3/*
4 © 2013 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_ADAPTER_H
17#define SIMICS_SYSTEMC_ADAPTER_H
18
19#include <systemc>
20
21#include <simics/conf-object.h>
41
62
63#include <systemc-kernel-compiler-version-check.h>
64#include <systemc-library-version-checks.h>
65
66#if INTC_EXT && USE_SIMICS_CCI
67#include <cci_utils/broker.h>
68#endif
69
70#include <string>
71#include <vector>
72#include <memory>
73#include <map>
74#include <type_traits>
75#include <utility> // pair
76
77namespace simics {
78namespace systemc {
79
86class Adapter : public ConfObject,
87 public Simulation,
88#if INTC_EXT && USE_SIMICS_CHECKPOINTING
89 public Checkpoint,
90#else
91 public CheckpointStub,
92#endif
93 public SimContext,
96 public Version,
97 public GasketInfo {
98 public:
100 explicit Adapter(ConfObjectRef o);
101 virtual ~Adapter();
102
110 virtual void elaborate() {}
111
119
128 virtual void bindGaskets() {}
129
141 virtual void finalize();
142
143 template <typename C>
144 static void initClassInternal(ConfClass *conf_class) {
145#if INTC_EXT && USE_SIMICS_CHECKPOINTING
146 static iface::CheckpointSimicsAdapter<C> checkpoint_simics_adapter;
147 conf_class->add(checkpoint_simics_adapter);
148#endif
149 static iface::SimContextSimicsAdapter<C> simcontext_simics_adapter;
150 conf_class->add(simcontext_simics_adapter);
152 memory_profiler_control_simics_adapter;
153 conf_class->add(memory_profiler_control_simics_adapter);
155 ppc_simics_adapter;
156 conf_class->add(ppc_simics_adapter);
157 static iface::ScVersionSimicsAdapter<C> version_simics_adapter;
158 conf_class->add(version_simics_adapter);
159#if INTC_EXT && USE_SIMICS_CHECKPOINTING
160 static iface::TemporalStateSimicsAdapter<C> temporal_simics_adapter;
161 conf_class->add(temporal_simics_adapter);
162#endif
163 static iface::EventDeltaSimicsAdapter<C> event_delta_simics_adapter;
164 conf_class->add(event_delta_simics_adapter);
165 static iface::ExecuteSimicsAdapter<C> execute_simics_adapter;
166 conf_class->add(execute_simics_adapter);
167 static iface::FrequencySimicsAdapter<C> frequency_simics_adapter;
168 conf_class->add(frequency_simics_adapter);
170 concurrency_group_simics_adapter;
171 conf_class->add(concurrency_group_simics_adapter);
173 concurrency_mode_simics_adapter;
174 conf_class->add(concurrency_mode_simics_adapter);
176 execute_control_simics_adapter;
177 conf_class->add(execute_control_simics_adapter);
178 static iface::ScGasketInfoSimicsAdapter<C> gasket_info_simics_adapter;
179 conf_class->add(gasket_info_simics_adapter);
180
181 if (std::is_base_of<simics2tlm::IoMemoryGasketAdapter, C>::value &&
182 std::is_base_of<iface::RegisterViewInterface, C>::value) {
184 register_view_simics_adapter;
185 conf_class->add(register_view_simics_adapter);
186 }
187
188 initOnce();
189 initScAttributes(conf_class);
190 conf_class_t *cls = *conf_class;
191
192 struct Invoker {
193 bool operator()(iface::SimicsAdapterInterface* adapter) {
194 if (adapter->map_adapter()) {
195 adapter->set_map_adapter(false);
196 adapter->set_simics_class(cls);
197 }
198 return false;
199 }
200 conf_class_t *cls;
201 };
202
203 Invoker invoker{cls};
205
206 const char *const log_groups[] = {
207 "Scheduling",
208 "TLM",
209 "Configuration",
210 "Awareness",
211 "Other",
212 NULL };
213
214 SIM_log_register_groups(cls, log_groups);
215
216 conf_class_t *clock = SIM_get_class("clock-extension");
217 if (SIM_clear_exception() != SimExc_No_Exception) {
218 FATAL_ERROR("Adapter::initClass: %s", SIM_last_error());
219 }
220 SIM_extend_class(cls, clock);
221
222 SIM_register_notifier(cls, Sim_Notify_Frequency_Change, NULL);
223
224 conf_class_t *co_execute = SIM_get_class("co-execute");
225 if (SIM_clear_exception() != SimExc_No_Exception) {
226 FATAL_ERROR("Adapter::initClass: %s", SIM_last_error());
227 }
228 SIM_register_port(cls, "engine", co_execute, "executor");
229
230#ifdef MODULE_NAME
232#ifdef REGISTER_SYSTEMC_GASKET_CLASSES
234#endif
235#endif
236 }
237
239 static SimulationInterface &simulation_from_conf_obj(conf_object_t *obj);
240
243 return &proxy_builder_;
244 }
245
248 return &internal_;
249 }
250
251#if INTC_EXT
253 static awareness::TlmSpyFactoryRegistry *spy_factory_registry() {
254 static awareness::TlmSpyFactoryRegistry registry;
255 return &registry;
256 }
257#endif
258
259 std::vector<simics::ConfObjectRef> gaskets_;
260
262 virtual void deinit();
263
264 private:
266 bool allowUnconnectedPorts() const;
267 void setAllowUnconnectedPorts(const bool &val);
268 bool createProxyObjects() const;
269 void setCreateProxyObjects(const bool &val);
270 void set_argv(const std::vector<std::string> &val);
271 std::vector<std::string> get_argv() const;
272 void set_cci_preset_values(
273 const std::vector<std::pair<std::string, std::string>> &attr);
274 simics::ConfObjectRef get_same_cell_as() const;
275
276 conf_object_t *createObject(conf_class_t *cls,
277 std::string full_name);
278 void createGaskets(const std::vector<simics::ConfObjectRef> &objs);
279
280 static void initOnce();
281 static void initScAttributes(ConfClass *conf_class);
282
283 bool allow_unconnected_ports_;
284 bool create_proxy_objects_;
285#if INTC_EXT
286 LateBinder late_binder_;
287#endif
288 static awareness::ProxyBuilder proxy_builder_;
289 std::map<sc_core::sc_object *, awareness::ProxyInterface *> links_;
290 awareness::Attributes attributes_;
291 conf_object_t *dynamic_events_object_;
292 conf_object_t *dynamic_processes_object_;
293 StateHandler *state_handler_;
294 void *dbg_library_;
295 ScSignalAccess signal_access_;
296 GasketTag gasket_tag_;
297 Internal internal_;
298#if INTC_EXT
299 awareness::TlmSpyFactoryRegistry spy_factory_registry_;
300#endif
301#if INTC_EXT && USE_SIMICS_CCI
302 cci_utils::broker broker_;
303 conf_object_t *cci_global_;
304#endif
305};
306
307} // namespace systemc
308} // namespace simics
309
310#endif
Entry point for creating a Simics conf-object that adapts a SystemC model to Simics,...
Definition: adapter.h:97
Adapter(ConfObjectRef o)
virtual void elaborate()
Override this method to elaborate the SystemC hierarchy.
Definition: adapter.h:110
InternalInterface * internal()
Definition: adapter.h:247
virtual void finalize()
Called during the finalize phase.
static SimulationInterface & simulation_from_conf_obj(conf_object_t *obj)
virtual void tagGaskets(simics::systemc::GasketTagInterface *gasket_tag)
Override this method to create tag based gaskets.
Definition: adapter.h:118
virtual void bindGaskets()
Override this method to bind Simics interfaces to SystemC after elaboration.
Definition: adapter.h:128
static awareness::ProxyBuilder * proxy_builder()
Definition: adapter.h:242
std::vector< simics::ConfObjectRef > gaskets_
Definition: adapter.h:259
static void initClassInternal(ConfClass *conf_class)
Definition: adapter.h:144
Adapter * is_systemc_adapter
Definition: adapter.h:99
Definition: checkpoint.h:34
Definition: gasket_info.h:29
This interface provides the means to create gaskets encapsulated in Simics objects.
Definition: gasket_tag.h:33
Definition: gasket_tag.h:68
Definition: internal_interface.h:25
Definition: internal.h:27
static void set_module_name(const char *module_name)
Definition: process_profiler_control.h:25
static Registry< T > * instance()
Definition: registry.h:69
Definition: sc_memory_profiler_control.h:24
Definition: sc_signal_access.h:24
Provides the interface to the SystemC simulation context.
Definition: simcontext.h:30
Provides the interface to the SystemC kernel.
Definition: simulation.h:54
Definition: state_handler.h:26
Definition: version.h:37
Definition: attributes.h:28
Definition: proxy_builder.h:50
Adapter for Simics checkpoint interface.
Definition: checkpoint_simics_adapter.h:32
Adapter for concurrency mode interface.
Definition: concurrency_group_simics_adapter.h:33
Adapter for concurrency mode interface.
Definition: concurrency_mode_simics_adapter.h:33
Definition: event_delta_simics_adapter.h:32
Adapter for concurrency group interface.
Definition: execute_control_simics_adapter.h:33
Definition: execute_simics_adapter.h:32
Definition: frequency_simics_adapter.h:32
Definition: register_view_simics_adapter.h:34
Definition: sc_gasket_info_simics_adapter.h:36
Definition: sc_memory_profiler_control_simics_adapter.h:33
Definition: sc_process_profiler_control_simics_adapter.h:35
Definition: sc_version_simics_adapter.h:35
Adapter for Simics simulation context interface.
Definition: simcontext_simics_adapter.h:34
Definition: simics_adapter_interface.h:29
virtual void set_simics_class(conf_class_t *conf_class)=0
Definition: temporal_state_simics_adapter.h:32
conf_class_t * SIM_get_class(const char *NOTNULL name)
void initGasketClasses(const char *module_name)
Definition: pci_bus_interface.h:24