34 #ifndef SC_SIMCONTEXT_H 35 #define SC_SIMCONTEXT_H 44 #if defined(_MSC_VER) && !defined(SC_WIN_DLL_WARN) 46 #pragma warning(disable: 4251) // DLL import for std::vector 57 class sc_export_registry;
60 class sc_module_registry;
63 class sc_object_manager;
64 class sc_phase_callback_registry;
65 class sc_process_handle;
66 class sc_port_registry;
67 class sc_prim_channel_registry;
68 class sc_process_table;
69 class sc_signal_bool_deval;
72 class sc_process_host;
73 class sc_method_process;
74 class sc_cthread_process;
75 class sc_thread_process;
76 class sc_reset_finder;
141 struct sc_invoke_method;
151 friend struct sc_invoke_method;
180 enum sc_signal_write_check
182 SC_SIGNAL_WRITE_CHECK_DISABLE_ = 0x0,
183 SC_SIGNAL_WRITE_CHECK_DEFAULT_ = 0x1,
184 SC_SIGNAL_WRITE_CHECK_CONFLICT_ = 0x2
196 void initialize(
bool =
false );
198 void simulate(
const sc_time& duration );
203 int sim_status()
const;
204 bool elaboration_done()
const;
206 std::vector<sc_thread_handle>& get_active_invokers();
219 sc_object* find_object(
const char* name );
226 std::string construct_hierarchical_name(
const sc_object* parent,
227 const std::string& name);
228 bool register_hierarchical_name(
const sc_object* parent,
229 const std::string& name);
230 bool unregister_hierarchical_name(
const sc_object* parent,
231 const std::string& name);
232 bool hierarchical_name_exists(
const sc_object* parent,
233 const std::string& name);
234 const char* get_hierarchical_name(
const sc_object* parent,
235 const std::string& name);
238 const char* gen_unique_name(
const char* basename_,
239 bool preserve_first =
false 255 sc_curr_proc_handle get_curr_proc_info();
257 bool write_check()
const;
258 bool write_check_conflicts_only()
const;
260 void reset_curr_proc();
272 const sc_time& max_time()
const;
273 const sc_time& time_stamp()
const;
278 bool event_occurred(
sc_dt::uint64 last_change_count )
const;
279 bool evaluation_phase()
const;
280 bool is_running()
const;
281 bool update_phase()
const;
282 bool notify_phase()
const;
287 {
return m_cor_pkg; }
292 const ::std::vector<sc_object*>& get_child_objects()
const;
295 void prepare_to_simulate();
296 inline void initial_crunch(
bool no_crunch );
297 bool next_time(
sc_time& t )
const;
298 bool pending_activity_at_current_time()
const;
304 void remove_child_event(
sc_event* );
307 void crunch(
bool once=
false );
310 void remove_delta_event(
sc_event* );
313 void trace_cycle(
bool delta_cycle );
333 void requeue_current_process();
334 void suspend_current_process();
336 void do_sc_stop_action();
337 void do_timestep(
const sc_time& );
345 enum execution_phases {
346 phase_initialize = 0,
361 sc_process_table* m_process_table;
364 sc_signal_write_check m_write_check;
367 std::vector<sc_thread_handle> m_active_invokers;
369 std::vector<sc_event*> m_child_events;
370 std::vector<sc_object*> m_child_objects;
372 std::vector<sc_event*> m_delta_events;
375 std::vector<sc_trace_file*> m_trace_files;
376 bool m_something_to_trace;
379 sc_process_list* m_collectable;
385 sc_invoke_method* m_method_invoker_p;
391 bool m_ready_to_simulate;
392 bool m_elaboration_done;
393 execution_phases m_execution_phase;
395 bool m_in_simulator_control;
396 bool m_end_of_simulation_called;
398 bool m_start_of_simulation_called;
423 if( sc_curr_simcontext == 0 ) {
444 return m_elaboration_done;
451 m_simulation_status :
462 if( m_forced_stop ) {
473 return m_object_manager;
480 return m_module_registry;
487 return m_port_registry;
494 return m_export_registry;
501 return m_prim_channel_registry;
509 return &m_curr_proc_info;
517 return ( ++ m_next_proc_id );
536 return m_change_stamp;
542 return m_delta_count - m_initial_delta_count_at_current_time;
557 return m_change_stamp == last_change_stamp;
564 return (m_execution_phase == phase_evaluate) &&
572 return m_execution_phase == phase_update;
579 return m_execution_phase == phase_notify;
595 return m_error != NULL;
600 sc_simcontext::add_delta_event(
sc_event* e )
602 m_delta_events.push_back( e );
603 return static_cast<int>( m_delta_events.size() - 1 );
610 m_timed_events->insert( et );
618 return m_current_writer;
624 return m_write_check != SC_SIGNAL_WRITE_CHECK_DISABLE_;
688 return simc_p->m_child_events;
695 return simc_p->m_child_objects;
717 return simc_p->m_ready_to_simulate;
838 #if defined(_MSC_VER) && !defined(SC_WIN_DLL_WARN) const sc_time & time_stamp() const
Registry for all exports.
SC_API const sc_time SC_ZERO_TIME
sc_process_b * sc_get_current_process_b()
SC_API sc_event * sc_find_event(const char *name)
void set_error(sc_report *)
const char * get_hierarchical_name(const sc_object *parent, const std::string &name)
Process base class support.
SC_API bool sc_is_unwinding()
sc_status get_status() const
SC_API sc_time sc_get_default_time_unit()
SC_API bool sc_pending_activity_at_future_time(const sc_simcontext *)
SC_API sc_stop_mode sc_get_stop_mode()
Abstract base class of all SystemC `simulation' objects.
SC_API double sc_simulation_time()
const char * sc_get_hierarchical_name(const char *name)
bool hierarchical_name_exists(const sc_object *parent, const std::string &name)
bool elaboration_done() const
SC_API const sc_time & sc_max_time()
sc_port_registry * get_port_registry()
sc_curr_proc_handle get_curr_proc_info()
bool sc_hierarchical_name_exists(const char *name)
SC_API void sc_initialize()
bool pending_activity_at_current_time() const
initialization, evaluation or update
Definition of the simulation phases.
Struct that holds the time resolution and default time unit.
bool sc_unregister_hierarchical_name(const char *name)
bool sc_register_hierarchical_name(const char *name)
SC_API sc_dt::uint64 sc_delta_count()
SC_API const std::vector< sc_object * > & sc_get_top_level_objects(const sc_simcontext *simc_p)
sc_curr_proc_kind sc_get_curr_process_kind()
sc_object_manager * get_object_manager()
SC_API const sc_time & sc_time_stamp()
Registry for all primitive channels.
SC_API sc_simcontext * sc_curr_simcontext
SC_API bool sc_is_running(const sc_simcontext *simc_p)
bool unregister_hierarchical_name(const sc_object *parent, const std::string &name)
int sc_get_simulator_status()
SC_API bool sc_pending_activity_at_current_time(const sc_simcontext *)
Coroutine abstract base class.
SC_API sc_time sc_time_to_pending_activity(const sc_simcontext *)
Unique name generator class.
Base class for all structural entities.
sc_module_registry * get_module_registry()
bool evaluation_phase() const
bool sc_pending_activity(const sc_simcontext *simc_p=sc_get_curr_simcontext())
sc_dt::uint64 delta_count_at_current_time() const
void(sc_process_host::* SC_ENTRY_FUNC)()
SC_API void sc_set_stop_mode(sc_stop_mode mode)
bool notify_phase() const
void sc_thread_cor_fn(void *arg)
SC_API void sc_set_time_resolution(double, sc_time_unit)
SC_API void sc_set_random_seed(unsigned int seed_)
sc_object * sc_get_current_object()
SC_API sc_dt::uint64 sc_delta_count_at_current_time()
sc_dt::uint64 change_stamp() const
Registry for all modules.
bool event_occurred(sc_dt::uint64 last_change_count) const
sc_plist< sc_process_b *> sc_process_list
class SC_API sc_trace_file
const sc_time & max_time() const
bool update_phase() const
SC_API bool sc_start_of_simulation_invoked()
const int SC_SIM_USER_STOP
Coroutine package abstract base class.
sc_object * active_object()
bool register_hierarchical_name(const sc_object *parent, const std::string &name)
const sc_curr_proc_info * sc_curr_proc_handle
SC_API const char * sc_gen_unique_name(const char *, bool preserve_first)
SC_API bool sc_allow_process_control_corners
when scheduler stopped by sc_pause()
SC_API sc_process_b * sc_get_curr_process_handle()
SC_API sc_time sc_get_time_resolution()
sc_prim_channel_registry * get_prim_channel_registry()
class sc_thread_process * sc_thread_handle
class sc_method_process * sc_method_handle
static sc_time from_value(value_type)
SC_API const std::vector< sc_event * > & sc_get_top_level_events(const sc_simcontext *simc_p)
sc_simcontext * sc_get_curr_simcontext()
SC_API sc_object * sc_find_object(const char *name)
sc_process_b * process_handle
sc_export_registry * get_export_registry()
sc_status sc_get_status()
SC_API sc_simcontext * sc_default_global_context
SC_API sc_process_handle sc_get_current_process_handle()
sc_process_b * get_current_writer() const
class SC_API sc_simcontext
Abstract base class of all primitive channel classes.
SC_API void sc_set_default_time_unit(double, sc_time_unit)
static const uint64 UINT64_ZERO
sc_time_unit
Enumeration of time units.
bool next_time(sc_time &t) const
SC_API bool sc_end_of_simulation_invoked()
A simple priority queue (which can be used to model multiple.