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 void run() override;
61 void stop() override;
62 void switch_in() override;
63 void switch_out() override;
64
65 // EventDeltaInterface
66 uint64 set_delta(conf_object_t *NOTNULL event_handler_obj,
67 const event_class_t *next_event_ec,
68 uint64 delta) override;
69 uint64 get_delta(conf_object_t *NOTNULL event_handler_obj) override;
70
71 // FrequencyInterface
72 double get() const override;
73
74 // ConcurrencyGroupInterface
75 std::vector<conf_object_t *> serialized_memory_group(
76 unsigned group_index) override;
77 std::vector<conf_object_t *> execution_group(unsigned group_index) override;
78
79 // ConcurrencyModeInterface
80 concurrency_mode_t supported_modes() override;
81 concurrency_mode_t current_mode() override;
82 void switch_mode(concurrency_mode_t mode) override;
83
84 // ExecuteControlInterface
85 void message_pending() override;
86 void yield_request() override;
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 uint64_t get_sc_time_resolution() const {
98 return time_resolution_;
99 }
100 void set_sc_time_resolution(uint64_t time_resolution);
101
102 protected:
103 // methods called from Adapter
104 void finalize();
105
106 virtual void callHandleEvent();
107
108 const std::vector<conf_object_t*>& instances() const;
109
110 void set_frequency(double frequency);
111
112 private:
113 int runDeltaPhaseNoStateCheck(int count);
114 bool isPausePending();
115 bool hasPendingAsyncActivity() const;
116 bool runSimulationNoCallHandleEvent(sc_core::sc_time t);
117
118 static void atSimulationStopped(lang_void *simulation, conf_object_t *obj);
119 static std::vector<conf_object_t*> instancesNotInCell(conf_object_t *cell);
120 static void onCellChange(lang_void *callback_data, conf_object_t *obj,
121 conf_object_t *old_cell, conf_object_t *new_cell);
122
123 // Helper to group all instances in the same TD
124 struct InstanceTracker {
125 explicit InstanceTracker(conf_object_t *NOTNULL object);
126 virtual ~InstanceTracker();
127 conf_object_t *object_;
128 };
129 static std::vector<conf_object_t*> instances_;
130
131 class YieldRequest : public sc_core::sc_prim_channel {
132 public:
133 YieldRequest(conf_object_t *co_execute, const char* name)
134 : sc_core::sc_prim_channel(name) {
135 INIT_IFACE(&execute_, execute, co_execute);
136 }
137 void update(void) override {
138 if (execute_.obj)
139 CALL(execute_, stop)();
140 }
141 IFACE_OBJ(execute) execute_;
142 };
143
144 ConfObjectRef simics_object_;
145 SimulationDeleter *simulation_deleter_;
146 Kernel kernel_;
147 uint64 delta_;
148 sc_core::sc_time sc_time_when_set_delta_;
149 IFACE_OBJ(event_handler) event_handler_;
150 concurrency_mode_t concurrency_mode_;
151 YieldRequest yield_request_;
152 bool break_pending_;
153 InternalInterface *internal_;
154 InstanceTracker instance_tracker_;
155 // The frequency value returned for the FrequencyInterface. It represents
156 // the number of Simics cycles that equate to one second in SystemC.
157 double frequency_;
158 // The SystemC time resolution in number of ps
159 uint64_t time_resolution_;
160};
161
162} // namespace systemc
163} // namespace simics
164
165#endif
Definition: internal_interface.h:25
Provides the interface to the SystemC kernel.
Definition: simulation.h:54
bool runSimulation(sc_core::sc_time t) override
ConfObjectRef simics_object() const override
uint64_t get_sc_time_resolution() const
Definition: simulation.h:97
void switch_mode(concurrency_mode_t mode) override
void set_sc_time_resolution(uint64_t time_resolution)
uint64 set_delta(conf_object_t *NOTNULL event_handler_obj, const event_class_t *next_event_ec, uint64 delta) override
virtual void callHandleEvent()
double get() const override
int runDeltaPhase(int count) override
void yield_request() override
void set_run_next_delta(const int &count)
sc_core::sc_simcontext * context() const override
concurrency_mode_t supported_modes() override
concurrency_mode_t current_mode() override
void switch_out() override
uint64 get_delta(conf_object_t *NOTNULL event_handler_obj) override
Simulation(ConfObjectRef o, InternalInterface *internal)
void set_frequency(double frequency)
std::vector< conf_object_t * > execution_group(unsigned group_index) override
void message_pending() override
void stopSimulation() override
const std::vector< conf_object_t * > & instances() const
std::vector< conf_object_t * > serialized_memory_group(unsigned group_index) override
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: adapter.h:81