SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
simulation.h
Go to the documentation of this file.
1// -*- mode: C++; c-file-style: "virtutech-c++" -*-
2
3/*
4 © 2014 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_SIMULATION_H
17#define SIMICS_SYSTEMC_SIMULATION_H
18
19#include <systemc>
20
21#include <simics/base/iface-call.h>
22
23#include <simics/devs/frequency.h>
24#include <simics/model-iface/event-delta.h>
25#include <simics/model-iface/co-execute.h>
36
37#include <vector>
38
39namespace simics {
40namespace systemc {
41
55 public:
56 Simulation(ConfObjectRef o, InternalInterface *internal);
57 virtual ~Simulation();
58
59 // ExecuteInterface
60 virtual void run();
61 virtual void stop();
62 virtual void switch_in();
63 virtual void switch_out();
64
65 // EventDeltaInterface
66 virtual uint64 set_delta(conf_object_t *NOTNULL event_handler_obj,
67 const event_class_t *next_event_ec,
68 uint64 delta);
69 virtual uint64 get_delta(conf_object_t *NOTNULL event_handler_obj);
70
71 // FrequencyInterface
72 virtual double get() const;
73
74 // ConcurrencyGroupInterface
75 virtual std::vector<conf_object_t *> serialized_memory_group(
76 unsigned group_index);
77 virtual std::vector<conf_object_t *> execution_group(unsigned group_index);
78
79 // ConcurrencyModeInterface
80 virtual concurrency_mode_t supported_modes();
81 virtual concurrency_mode_t current_mode();
82 virtual void switch_mode(concurrency_mode_t mode);
83
84 // ExecuteControlInterface
85 virtual void message_pending();
86 virtual void yield_request();
87
88 // SimulationInterface
89 int runDeltaPhase(int count); /* override */
90 bool runSimulation(sc_core::sc_time t); /* override */
91 void stopSimulation(); /* override */
92 sc_core::sc_simcontext* context() const; /* override */
93 ConfObjectRef simics_object() const; /* override */
94
95 void set_run_next_delta(const int &count);
96
97 protected:
98 // methods called from Adapter
99 void finalize();
100
101 virtual void callHandleEvent();
102
103 const std::vector<conf_object_t*>& instances() const;
104
105 private:
106 int runDeltaPhaseNoStateCheck(int count);
107 bool isPausePending();
108 bool hasPendingAsyncActivity() const;
109 bool runSimulationNoCallHandleEvent(sc_core::sc_time t);
110
111 static void atSimulationStopped(lang_void *simulation, conf_object_t *obj);
112 static std::vector<conf_object_t*> instancesNotInCell(conf_object_t *cell);
113 static void onCellChange(lang_void *callback_data, conf_object_t *obj,
114 conf_object_t *old_cell, conf_object_t *new_cell);
115
116 // Helper to group all instances in the same TD
117 struct InstanceTracker {
118 explicit InstanceTracker(conf_object_t *NOTNULL object);
119 virtual ~InstanceTracker();
120 conf_object_t *object_;
121 };
122 static std::vector<conf_object_t*> instances_;
123
124 class YieldRequest : public sc_core::sc_prim_channel {
125 public:
126 YieldRequest(conf_object_t *engine, const char* name)
127 : sc_core::sc_prim_channel(name) {
128 INIT_IFACE(&execute_, execute, engine);
129 }
130 virtual void update(void) {
131 if (execute_.obj)
132 CALL(execute_, stop)();
133 }
134 IFACE_OBJ(execute) execute_;
135 };
136
137 ConfObjectRef simics_object_;
138 SimulationDeleter *simulation_deleter_;
139 Kernel kernel_;
140 uint64 delta_;
141 sc_core::sc_time delta_time_;
142 IFACE_OBJ(event_handler) event_handler_;
143 concurrency_mode_t concurrency_mode_;
144 YieldRequest yield_request_;
145 bool break_pending_;
146 InternalInterface *internal_;
147 InstanceTracker instance_tracker_;
148};
149
150} // namespace systemc
151} // namespace simics
152
153#endif
Definition: internal_interface.h:25
Provides the interface to the SystemC kernel.
Definition: simulation.h:54
virtual void switch_mode(concurrency_mode_t mode)
sc_core::sc_simcontext * context() const
virtual std::vector< conf_object_t * > execution_group(unsigned group_index)
virtual uint64 get_delta(conf_object_t *NOTNULL event_handler_obj)
virtual void callHandleEvent()
virtual uint64 set_delta(conf_object_t *NOTNULL event_handler_obj, const event_class_t *next_event_ec, uint64 delta)
int runDeltaPhase(int count)
virtual void yield_request()
virtual concurrency_mode_t supported_modes()
void set_run_next_delta(const int &count)
virtual std::vector< conf_object_t * > serialized_memory_group(unsigned group_index)
virtual double get() const
virtual void message_pending()
ConfObjectRef simics_object() const
Simulation(ConfObjectRef o, InternalInterface *internal)
bool runSimulation(sc_core::sc_time t)
virtual concurrency_mode_t current_mode()
const std::vector< conf_object_t * > & instances() const
Simics concurrency group interface.
Definition: concurrency_group_interface.h:28
Simics concurrency mode interface.
Definition: concurrency_mode_interface.h:26
Definition: event_delta_interface.h:27
Simics execute control interface.
Definition: execute_control_interface.h:26
Definition: execute_interface.h:24
Definition: frequency_interface.h:26
Interface to the SystemC simulation.
Definition: simulation_interface.h:27
Definition: argument_registry.h:26
Definition: pci_bus_interface.h:24