sc_simcontext.h revision 12027
112027Sjungma@eit.uni-kl.de/***************************************************************************** 212027Sjungma@eit.uni-kl.de 312027Sjungma@eit.uni-kl.de Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 412027Sjungma@eit.uni-kl.de more contributor license agreements. See the NOTICE file distributed 512027Sjungma@eit.uni-kl.de with this work for additional information regarding copyright ownership. 612027Sjungma@eit.uni-kl.de Accellera licenses this file to you under the Apache License, Version 2.0 712027Sjungma@eit.uni-kl.de (the "License"); you may not use this file except in compliance with the 812027Sjungma@eit.uni-kl.de License. You may obtain a copy of the License at 912027Sjungma@eit.uni-kl.de 1012027Sjungma@eit.uni-kl.de http://www.apache.org/licenses/LICENSE-2.0 1112027Sjungma@eit.uni-kl.de 1212027Sjungma@eit.uni-kl.de Unless required by applicable law or agreed to in writing, software 1312027Sjungma@eit.uni-kl.de distributed under the License is distributed on an "AS IS" BASIS, 1412027Sjungma@eit.uni-kl.de WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 1512027Sjungma@eit.uni-kl.de implied. See the License for the specific language governing 1612027Sjungma@eit.uni-kl.de permissions and limitations under the License. 1712027Sjungma@eit.uni-kl.de 1812027Sjungma@eit.uni-kl.de *****************************************************************************/ 1912027Sjungma@eit.uni-kl.de 2012027Sjungma@eit.uni-kl.de/***************************************************************************** 2112027Sjungma@eit.uni-kl.de 2212027Sjungma@eit.uni-kl.de sc_simcontext.h -- Definition of the simulation context class. 2312027Sjungma@eit.uni-kl.de 2412027Sjungma@eit.uni-kl.de Original Author: Stan Y. Liao, Synopsys, Inc. 2512027Sjungma@eit.uni-kl.de Martin Janssen, Synopsys, Inc. 2612027Sjungma@eit.uni-kl.de 2712027Sjungma@eit.uni-kl.de CHANGE LOG AT THE END OF THE FILE 2812027Sjungma@eit.uni-kl.de *****************************************************************************/ 2912027Sjungma@eit.uni-kl.de 3012027Sjungma@eit.uni-kl.de#ifndef SC_SIMCONTEXT_H 3112027Sjungma@eit.uni-kl.de#define SC_SIMCONTEXT_H 3212027Sjungma@eit.uni-kl.de 3312027Sjungma@eit.uni-kl.de#include "sysc/kernel/sc_cmnhdr.h" 3412027Sjungma@eit.uni-kl.de#include "sysc/kernel/sc_process.h" 3512027Sjungma@eit.uni-kl.de#include "sysc/kernel/sc_status.h" 3612027Sjungma@eit.uni-kl.de#include "sysc/kernel/sc_time.h" 3712027Sjungma@eit.uni-kl.de#include "sysc/utils/sc_hash.h" 3812027Sjungma@eit.uni-kl.de#include "sysc/utils/sc_pq.h" 3912027Sjungma@eit.uni-kl.de 4012027Sjungma@eit.uni-kl.denamespace sc_core { 4112027Sjungma@eit.uni-kl.de 4212027Sjungma@eit.uni-kl.de// forward declarations 4312027Sjungma@eit.uni-kl.de 4412027Sjungma@eit.uni-kl.declass sc_cor; 4512027Sjungma@eit.uni-kl.declass sc_cor_pkg; 4612027Sjungma@eit.uni-kl.declass sc_event; 4712027Sjungma@eit.uni-kl.declass sc_event_timed; 4812027Sjungma@eit.uni-kl.declass sc_export_registry; 4912027Sjungma@eit.uni-kl.declass sc_module; 5012027Sjungma@eit.uni-kl.declass sc_module_name; 5112027Sjungma@eit.uni-kl.declass sc_module_registry; 5212027Sjungma@eit.uni-kl.declass sc_name_gen; 5312027Sjungma@eit.uni-kl.declass sc_object; 5412027Sjungma@eit.uni-kl.declass sc_object_manager; 5512027Sjungma@eit.uni-kl.declass sc_phase_callback_registry; 5612027Sjungma@eit.uni-kl.declass sc_process_handle; 5712027Sjungma@eit.uni-kl.declass sc_port_registry; 5812027Sjungma@eit.uni-kl.declass sc_prim_channel_registry; 5912027Sjungma@eit.uni-kl.declass sc_process_table; 6012027Sjungma@eit.uni-kl.declass sc_signal_bool_deval; 6112027Sjungma@eit.uni-kl.declass sc_trace_file; 6212027Sjungma@eit.uni-kl.declass sc_runnable; 6312027Sjungma@eit.uni-kl.declass sc_process_host; 6412027Sjungma@eit.uni-kl.declass sc_method_process; 6512027Sjungma@eit.uni-kl.declass sc_cthread_process; 6612027Sjungma@eit.uni-kl.declass sc_thread_process; 6712027Sjungma@eit.uni-kl.de 6812027Sjungma@eit.uni-kl.detemplate< typename > class sc_plist; 6912027Sjungma@eit.uni-kl.detypedef sc_plist< sc_process_b* > sc_process_list; 7012027Sjungma@eit.uni-kl.de 7112027Sjungma@eit.uni-kl.destruct sc_curr_proc_info 7212027Sjungma@eit.uni-kl.de{ 7312027Sjungma@eit.uni-kl.de sc_process_b* process_handle; 7412027Sjungma@eit.uni-kl.de sc_curr_proc_kind kind; 7512027Sjungma@eit.uni-kl.de sc_curr_proc_info() : process_handle( 0 ), kind( SC_NO_PROC_ ) {} 7612027Sjungma@eit.uni-kl.de}; 7712027Sjungma@eit.uni-kl.de 7812027Sjungma@eit.uni-kl.detypedef const sc_curr_proc_info* sc_curr_proc_handle; 7912027Sjungma@eit.uni-kl.de 8012027Sjungma@eit.uni-kl.deenum sc_stop_mode { // sc_stop modes: 8112027Sjungma@eit.uni-kl.de SC_STOP_FINISH_DELTA, 8212027Sjungma@eit.uni-kl.de SC_STOP_IMMEDIATE 8312027Sjungma@eit.uni-kl.de}; 8412027Sjungma@eit.uni-kl.deextern void sc_set_stop_mode( sc_stop_mode mode ); 8512027Sjungma@eit.uni-kl.deextern sc_stop_mode sc_get_stop_mode(); 8612027Sjungma@eit.uni-kl.de 8712027Sjungma@eit.uni-kl.deenum sc_starvation_policy 8812027Sjungma@eit.uni-kl.de{ 8912027Sjungma@eit.uni-kl.de SC_EXIT_ON_STARVATION, 9012027Sjungma@eit.uni-kl.de SC_RUN_TO_TIME 9112027Sjungma@eit.uni-kl.de}; 9212027Sjungma@eit.uni-kl.deextern void sc_start(); 9312027Sjungma@eit.uni-kl.deextern void sc_start( const sc_time& duration, 9412027Sjungma@eit.uni-kl.de sc_starvation_policy p=SC_RUN_TO_TIME ); 9512027Sjungma@eit.uni-kl.deinline void sc_start( int duration, sc_time_unit unit, 9612027Sjungma@eit.uni-kl.de sc_starvation_policy p=SC_RUN_TO_TIME ) 9712027Sjungma@eit.uni-kl.de{ 9812027Sjungma@eit.uni-kl.de sc_start( sc_time((double)duration,unit), p ); 9912027Sjungma@eit.uni-kl.de} 10012027Sjungma@eit.uni-kl.de 10112027Sjungma@eit.uni-kl.deinline void sc_start( double duration, sc_time_unit unit, 10212027Sjungma@eit.uni-kl.de sc_starvation_policy p=SC_RUN_TO_TIME ) 10312027Sjungma@eit.uni-kl.de{ 10412027Sjungma@eit.uni-kl.de sc_start( sc_time(duration,unit), p ); 10512027Sjungma@eit.uni-kl.de} 10612027Sjungma@eit.uni-kl.de 10712027Sjungma@eit.uni-kl.deextern void sc_stop(); 10812027Sjungma@eit.uni-kl.de 10912027Sjungma@eit.uni-kl.de// friend function declarations 11012027Sjungma@eit.uni-kl.de 11112027Sjungma@eit.uni-kl.desc_dt::uint64 sc_delta_count(); 11212027Sjungma@eit.uni-kl.deconst std::vector<sc_event*>& sc_get_top_level_events( 11312027Sjungma@eit.uni-kl.de const sc_simcontext* simc_p); 11412027Sjungma@eit.uni-kl.deconst std::vector<sc_object*>& sc_get_top_level_objects( 11512027Sjungma@eit.uni-kl.de const sc_simcontext* simc_p); 11612027Sjungma@eit.uni-kl.debool sc_is_running( const sc_simcontext* simc_p ); 11712027Sjungma@eit.uni-kl.devoid sc_pause(); 11812027Sjungma@eit.uni-kl.debool sc_end_of_simulation_invoked(); 11912027Sjungma@eit.uni-kl.devoid sc_start( const sc_time&, sc_starvation_policy ); 12012027Sjungma@eit.uni-kl.debool sc_start_of_simulation_invoked(); 12112027Sjungma@eit.uni-kl.devoid sc_set_time_resolution( double, sc_time_unit ); 12212027Sjungma@eit.uni-kl.desc_time sc_get_time_resolution(); 12312027Sjungma@eit.uni-kl.devoid sc_set_default_time_unit( double, sc_time_unit ); 12412027Sjungma@eit.uni-kl.desc_time sc_get_default_time_unit(); 12512027Sjungma@eit.uni-kl.debool sc_pending_activity_at_current_time( const sc_simcontext* ); 12612027Sjungma@eit.uni-kl.debool sc_pending_activity_at_future_time( const sc_simcontext* ); 12712027Sjungma@eit.uni-kl.desc_time sc_time_to_pending_activity( const sc_simcontext* ); 12812027Sjungma@eit.uni-kl.de 12912027Sjungma@eit.uni-kl.destruct sc_invoke_method; 13012027Sjungma@eit.uni-kl.de 13112027Sjungma@eit.uni-kl.de// ---------------------------------------------------------------------------- 13212027Sjungma@eit.uni-kl.de// CLASS : sc_simcontext 13312027Sjungma@eit.uni-kl.de// 13412027Sjungma@eit.uni-kl.de// The simulation context. 13512027Sjungma@eit.uni-kl.de// ---------------------------------------------------------------------------- 13612027Sjungma@eit.uni-kl.de 13712027Sjungma@eit.uni-kl.declass sc_simcontext 13812027Sjungma@eit.uni-kl.de{ 13912027Sjungma@eit.uni-kl.de friend struct sc_invoke_method; 14012027Sjungma@eit.uni-kl.de friend class sc_event; 14112027Sjungma@eit.uni-kl.de friend class sc_module; 14212027Sjungma@eit.uni-kl.de friend class sc_object; 14312027Sjungma@eit.uni-kl.de friend class sc_time; 14412027Sjungma@eit.uni-kl.de friend class sc_clock; 14512027Sjungma@eit.uni-kl.de friend class sc_method_process; 14612027Sjungma@eit.uni-kl.de friend class sc_phase_callback_registry; 14712027Sjungma@eit.uni-kl.de friend class sc_process_b; 14812027Sjungma@eit.uni-kl.de friend class sc_process_handle; 14912027Sjungma@eit.uni-kl.de friend class sc_prim_channel; 15012027Sjungma@eit.uni-kl.de friend class sc_cthread_process; 15112027Sjungma@eit.uni-kl.de friend class sc_thread_process; 15212027Sjungma@eit.uni-kl.de friend sc_dt::uint64 sc_delta_count(); 15312027Sjungma@eit.uni-kl.de friend const std::vector<sc_event*>& sc_get_top_level_events( 15412027Sjungma@eit.uni-kl.de const sc_simcontext* simc_p); 15512027Sjungma@eit.uni-kl.de friend const std::vector<sc_object*>& sc_get_top_level_objects( 15612027Sjungma@eit.uni-kl.de const sc_simcontext* simc_p); 15712027Sjungma@eit.uni-kl.de friend bool sc_is_running( const sc_simcontext* simc_p ); 15812027Sjungma@eit.uni-kl.de friend void sc_pause(); 15912027Sjungma@eit.uni-kl.de friend bool sc_end_of_simulation_invoked(); 16012027Sjungma@eit.uni-kl.de friend void sc_start( const sc_time&, sc_starvation_policy ); 16112027Sjungma@eit.uni-kl.de friend bool sc_start_of_simulation_invoked(); 16212027Sjungma@eit.uni-kl.de friend void sc_thread_cor_fn(void*); 16312027Sjungma@eit.uni-kl.de friend sc_time sc_time_to_pending_activity( const sc_simcontext* ); 16412027Sjungma@eit.uni-kl.de friend bool sc_pending_activity_at_current_time( const sc_simcontext* ); 16512027Sjungma@eit.uni-kl.de friend bool sc_pending_activity_at_future_time( const sc_simcontext* ); 16612027Sjungma@eit.uni-kl.de 16712027Sjungma@eit.uni-kl.de 16812027Sjungma@eit.uni-kl.de void init(); 16912027Sjungma@eit.uni-kl.de void clean(); 17012027Sjungma@eit.uni-kl.de 17112027Sjungma@eit.uni-kl.depublic: 17212027Sjungma@eit.uni-kl.de 17312027Sjungma@eit.uni-kl.de sc_simcontext(); 17412027Sjungma@eit.uni-kl.de ~sc_simcontext(); 17512027Sjungma@eit.uni-kl.de 17612027Sjungma@eit.uni-kl.de void initialize( bool = false ); 17712027Sjungma@eit.uni-kl.de void cycle( const sc_time& ); 17812027Sjungma@eit.uni-kl.de void simulate( const sc_time& duration ); 17912027Sjungma@eit.uni-kl.de void stop(); 18012027Sjungma@eit.uni-kl.de void end(); 18112027Sjungma@eit.uni-kl.de void reset(); 18212027Sjungma@eit.uni-kl.de 18312027Sjungma@eit.uni-kl.de int sim_status() const; 18412027Sjungma@eit.uni-kl.de bool elaboration_done() const; 18512027Sjungma@eit.uni-kl.de 18612027Sjungma@eit.uni-kl.de std::vector<sc_thread_handle>& get_active_invokers(); 18712027Sjungma@eit.uni-kl.de 18812027Sjungma@eit.uni-kl.de sc_object_manager* get_object_manager(); 18912027Sjungma@eit.uni-kl.de 19012027Sjungma@eit.uni-kl.de inline sc_status get_status() const; 19112027Sjungma@eit.uni-kl.de 19212027Sjungma@eit.uni-kl.de sc_object* active_object(); 19312027Sjungma@eit.uni-kl.de 19412027Sjungma@eit.uni-kl.de void hierarchy_push( sc_module* ); 19512027Sjungma@eit.uni-kl.de sc_module* hierarchy_pop(); 19612027Sjungma@eit.uni-kl.de sc_module* hierarchy_curr() const; 19712027Sjungma@eit.uni-kl.de sc_object* first_object(); 19812027Sjungma@eit.uni-kl.de sc_object* next_object(); 19912027Sjungma@eit.uni-kl.de sc_object* find_object( const char* name ); 20012027Sjungma@eit.uni-kl.de 20112027Sjungma@eit.uni-kl.de sc_module_registry* get_module_registry(); 20212027Sjungma@eit.uni-kl.de sc_port_registry* get_port_registry(); 20312027Sjungma@eit.uni-kl.de sc_export_registry* get_export_registry(); 20412027Sjungma@eit.uni-kl.de sc_prim_channel_registry* get_prim_channel_registry(); 20512027Sjungma@eit.uni-kl.de 20612027Sjungma@eit.uni-kl.de // to generate unique names for objects in an MT-Safe way 20712027Sjungma@eit.uni-kl.de const char* gen_unique_name( const char* basename_, 20812027Sjungma@eit.uni-kl.de bool preserve_first = false 20912027Sjungma@eit.uni-kl.de ); 21012027Sjungma@eit.uni-kl.de 21112027Sjungma@eit.uni-kl.de // process creation 21212027Sjungma@eit.uni-kl.de sc_process_handle create_cthread_process( 21312027Sjungma@eit.uni-kl.de const char* name_p, bool free_host, SC_ENTRY_FUNC method_p, 21412027Sjungma@eit.uni-kl.de sc_process_host* host_p, const sc_spawn_options* opt_p ); 21512027Sjungma@eit.uni-kl.de 21612027Sjungma@eit.uni-kl.de sc_process_handle create_method_process( 21712027Sjungma@eit.uni-kl.de const char* name_p, bool free_host, SC_ENTRY_FUNC method_p, 21812027Sjungma@eit.uni-kl.de sc_process_host* host_p, const sc_spawn_options* opt_p ); 21912027Sjungma@eit.uni-kl.de 22012027Sjungma@eit.uni-kl.de sc_process_handle create_thread_process( 22112027Sjungma@eit.uni-kl.de const char* name_p, bool free_host, SC_ENTRY_FUNC method_p, 22212027Sjungma@eit.uni-kl.de sc_process_host* host_p, const sc_spawn_options* opt_p ); 22312027Sjungma@eit.uni-kl.de 22412027Sjungma@eit.uni-kl.de sc_curr_proc_handle get_curr_proc_info(); 22512027Sjungma@eit.uni-kl.de sc_object* get_current_writer() const; 22612027Sjungma@eit.uni-kl.de bool write_check() const; 22712027Sjungma@eit.uni-kl.de void set_curr_proc( sc_process_b* ); 22812027Sjungma@eit.uni-kl.de void reset_curr_proc(); 22912027Sjungma@eit.uni-kl.de 23012027Sjungma@eit.uni-kl.de int next_proc_id(); 23112027Sjungma@eit.uni-kl.de 23212027Sjungma@eit.uni-kl.de void add_trace_file( sc_trace_file* ); 23312027Sjungma@eit.uni-kl.de void remove_trace_file( sc_trace_file* ); 23412027Sjungma@eit.uni-kl.de 23512027Sjungma@eit.uni-kl.de friend void sc_set_time_resolution( double, sc_time_unit ); 23612027Sjungma@eit.uni-kl.de friend sc_time sc_get_time_resolution(); 23712027Sjungma@eit.uni-kl.de friend void sc_set_default_time_unit( double, sc_time_unit ); 23812027Sjungma@eit.uni-kl.de friend sc_time sc_get_default_time_unit(); 23912027Sjungma@eit.uni-kl.de 24012027Sjungma@eit.uni-kl.de const sc_time& max_time() const; 24112027Sjungma@eit.uni-kl.de const sc_time& time_stamp() const; 24212027Sjungma@eit.uni-kl.de 24312027Sjungma@eit.uni-kl.de sc_dt::uint64 change_stamp() const; 24412027Sjungma@eit.uni-kl.de sc_dt::uint64 delta_count() const; 24512027Sjungma@eit.uni-kl.de bool event_occurred( sc_dt::uint64 last_change_count ) const; 24612027Sjungma@eit.uni-kl.de bool evaluation_phase() const; 24712027Sjungma@eit.uni-kl.de bool is_running() const; 24812027Sjungma@eit.uni-kl.de bool update_phase() const; 24912027Sjungma@eit.uni-kl.de bool notify_phase() const; 25012027Sjungma@eit.uni-kl.de bool get_error(); 25112027Sjungma@eit.uni-kl.de void set_error( sc_report* ); 25212027Sjungma@eit.uni-kl.de 25312027Sjungma@eit.uni-kl.de sc_cor_pkg* cor_pkg() 25412027Sjungma@eit.uni-kl.de { return m_cor_pkg; } 25512027Sjungma@eit.uni-kl.de sc_cor* next_cor(); 25612027Sjungma@eit.uni-kl.de 25712027Sjungma@eit.uni-kl.de const ::std::vector<sc_object*>& get_child_objects() const; 25812027Sjungma@eit.uni-kl.de 25912027Sjungma@eit.uni-kl.de void elaborate(); 26012027Sjungma@eit.uni-kl.de void prepare_to_simulate(); 26112027Sjungma@eit.uni-kl.de inline void initial_crunch( bool no_crunch ); 26212027Sjungma@eit.uni-kl.de bool next_time( sc_time& t ) const; 26312027Sjungma@eit.uni-kl.de bool pending_activity_at_current_time() const; 26412027Sjungma@eit.uni-kl.de 26512027Sjungma@eit.uni-kl.deprivate: 26612027Sjungma@eit.uni-kl.de 26712027Sjungma@eit.uni-kl.de void add_child_event( sc_event* ); 26812027Sjungma@eit.uni-kl.de void add_child_object( sc_object* ); 26912027Sjungma@eit.uni-kl.de void remove_child_event( sc_event* ); 27012027Sjungma@eit.uni-kl.de void remove_child_object( sc_object* ); 27112027Sjungma@eit.uni-kl.de 27212027Sjungma@eit.uni-kl.de void crunch( bool once=false ); 27312027Sjungma@eit.uni-kl.de 27412027Sjungma@eit.uni-kl.de int add_delta_event( sc_event* ); 27512027Sjungma@eit.uni-kl.de void remove_delta_event( sc_event* ); 27612027Sjungma@eit.uni-kl.de void add_timed_event( sc_event_timed* ); 27712027Sjungma@eit.uni-kl.de 27812027Sjungma@eit.uni-kl.de void trace_cycle( bool delta_cycle ); 27912027Sjungma@eit.uni-kl.de 28012027Sjungma@eit.uni-kl.de const ::std::vector<sc_event*>& get_child_events_internal() const; 28112027Sjungma@eit.uni-kl.de const ::std::vector<sc_object*>& get_child_objects_internal() const; 28212027Sjungma@eit.uni-kl.de 28312027Sjungma@eit.uni-kl.de void execute_method_next( sc_method_handle ); 28412027Sjungma@eit.uni-kl.de void execute_thread_next( sc_thread_handle ); 28512027Sjungma@eit.uni-kl.de 28612027Sjungma@eit.uni-kl.de sc_method_handle pop_runnable_method(); 28712027Sjungma@eit.uni-kl.de sc_thread_handle pop_runnable_thread(); 28812027Sjungma@eit.uni-kl.de 28912027Sjungma@eit.uni-kl.de void preempt_with( sc_method_handle ); 29012027Sjungma@eit.uni-kl.de inline void preempt_with( sc_thread_handle ); 29112027Sjungma@eit.uni-kl.de 29212027Sjungma@eit.uni-kl.de void push_runnable_method( sc_method_handle ); 29312027Sjungma@eit.uni-kl.de void push_runnable_thread( sc_thread_handle ); 29412027Sjungma@eit.uni-kl.de 29512027Sjungma@eit.uni-kl.de void push_runnable_method_front( sc_method_handle ); 29612027Sjungma@eit.uni-kl.de void push_runnable_thread_front( sc_thread_handle ); 29712027Sjungma@eit.uni-kl.de 29812027Sjungma@eit.uni-kl.de void remove_runnable_method( sc_method_handle ); 29912027Sjungma@eit.uni-kl.de void remove_runnable_thread( sc_thread_handle ); 30012027Sjungma@eit.uni-kl.de 30112027Sjungma@eit.uni-kl.de void requeue_current_process(); 30212027Sjungma@eit.uni-kl.de void suspend_current_process(); 30312027Sjungma@eit.uni-kl.de 30412027Sjungma@eit.uni-kl.de void do_sc_stop_action(); 30512027Sjungma@eit.uni-kl.de void mark_to_collect_process( sc_process_b* zombie_p ); 30612027Sjungma@eit.uni-kl.de 30712027Sjungma@eit.uni-kl.deprivate: 30812027Sjungma@eit.uni-kl.de 30912027Sjungma@eit.uni-kl.de enum execution_phases { 31012027Sjungma@eit.uni-kl.de phase_initialize = 0, 31112027Sjungma@eit.uni-kl.de phase_evaluate, 31212027Sjungma@eit.uni-kl.de phase_update, 31312027Sjungma@eit.uni-kl.de phase_notify 31412027Sjungma@eit.uni-kl.de }; 31512027Sjungma@eit.uni-kl.de sc_object_manager* m_object_manager; 31612027Sjungma@eit.uni-kl.de 31712027Sjungma@eit.uni-kl.de sc_module_registry* m_module_registry; 31812027Sjungma@eit.uni-kl.de sc_port_registry* m_port_registry; 31912027Sjungma@eit.uni-kl.de sc_export_registry* m_export_registry; 32012027Sjungma@eit.uni-kl.de sc_prim_channel_registry* m_prim_channel_registry; 32112027Sjungma@eit.uni-kl.de sc_phase_callback_registry* m_phase_cb_registry; 32212027Sjungma@eit.uni-kl.de 32312027Sjungma@eit.uni-kl.de sc_name_gen* m_name_gen; 32412027Sjungma@eit.uni-kl.de 32512027Sjungma@eit.uni-kl.de sc_process_table* m_process_table; 32612027Sjungma@eit.uni-kl.de sc_curr_proc_info m_curr_proc_info; 32712027Sjungma@eit.uni-kl.de sc_object* m_current_writer; 32812027Sjungma@eit.uni-kl.de bool m_write_check; 32912027Sjungma@eit.uni-kl.de int m_next_proc_id; 33012027Sjungma@eit.uni-kl.de 33112027Sjungma@eit.uni-kl.de std::vector<sc_thread_handle> m_active_invokers; 33212027Sjungma@eit.uni-kl.de 33312027Sjungma@eit.uni-kl.de std::vector<sc_event*> m_child_events; 33412027Sjungma@eit.uni-kl.de std::vector<sc_object*> m_child_objects; 33512027Sjungma@eit.uni-kl.de 33612027Sjungma@eit.uni-kl.de std::vector<sc_event*> m_delta_events; 33712027Sjungma@eit.uni-kl.de sc_ppq<sc_event_timed*>* m_timed_events; 33812027Sjungma@eit.uni-kl.de 33912027Sjungma@eit.uni-kl.de std::vector<sc_trace_file*> m_trace_files; 34012027Sjungma@eit.uni-kl.de bool m_something_to_trace; 34112027Sjungma@eit.uni-kl.de 34212027Sjungma@eit.uni-kl.de sc_runnable* m_runnable; 34312027Sjungma@eit.uni-kl.de sc_process_list* m_collectable; 34412027Sjungma@eit.uni-kl.de 34512027Sjungma@eit.uni-kl.de sc_time_params* m_time_params; 34612027Sjungma@eit.uni-kl.de sc_time m_curr_time; 34712027Sjungma@eit.uni-kl.de mutable sc_time m_max_time; 34812027Sjungma@eit.uni-kl.de 34912027Sjungma@eit.uni-kl.de sc_invoke_method* m_method_invoker_p; 35012027Sjungma@eit.uni-kl.de sc_dt::uint64 m_change_stamp; // "time" change occurred. 35112027Sjungma@eit.uni-kl.de sc_dt::uint64 m_delta_count; 35212027Sjungma@eit.uni-kl.de bool m_forced_stop; 35312027Sjungma@eit.uni-kl.de bool m_paused; 35412027Sjungma@eit.uni-kl.de bool m_ready_to_simulate; 35512027Sjungma@eit.uni-kl.de bool m_elaboration_done; 35612027Sjungma@eit.uni-kl.de execution_phases m_execution_phase; 35712027Sjungma@eit.uni-kl.de sc_report* m_error; 35812027Sjungma@eit.uni-kl.de bool m_in_simulator_control; 35912027Sjungma@eit.uni-kl.de bool m_end_of_simulation_called; 36012027Sjungma@eit.uni-kl.de sc_status m_simulation_status; 36112027Sjungma@eit.uni-kl.de bool m_start_of_simulation_called; 36212027Sjungma@eit.uni-kl.de 36312027Sjungma@eit.uni-kl.de sc_cor_pkg* m_cor_pkg; // the simcontext's coroutine package 36412027Sjungma@eit.uni-kl.de sc_cor* m_cor; // the simcontext's coroutine 36512027Sjungma@eit.uni-kl.de 36612027Sjungma@eit.uni-kl.deprivate: 36712027Sjungma@eit.uni-kl.de 36812027Sjungma@eit.uni-kl.de // disabled 36912027Sjungma@eit.uni-kl.de sc_simcontext( const sc_simcontext& ); 37012027Sjungma@eit.uni-kl.de sc_simcontext& operator = ( const sc_simcontext& ); 37112027Sjungma@eit.uni-kl.de}; 37212027Sjungma@eit.uni-kl.de 37312027Sjungma@eit.uni-kl.de// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 37412027Sjungma@eit.uni-kl.de 37512027Sjungma@eit.uni-kl.de// Not MT safe. 37612027Sjungma@eit.uni-kl.de 37712027Sjungma@eit.uni-kl.de#if 1 37812027Sjungma@eit.uni-kl.deextern sc_simcontext* sc_curr_simcontext; 37912027Sjungma@eit.uni-kl.deextern sc_simcontext* sc_default_global_context; 38012027Sjungma@eit.uni-kl.de 38112027Sjungma@eit.uni-kl.deinline sc_simcontext* 38212027Sjungma@eit.uni-kl.desc_get_curr_simcontext() 38312027Sjungma@eit.uni-kl.de{ 38412027Sjungma@eit.uni-kl.de if( sc_curr_simcontext == 0 ) { 38512027Sjungma@eit.uni-kl.de sc_default_global_context = new sc_simcontext; 38612027Sjungma@eit.uni-kl.de sc_curr_simcontext = sc_default_global_context; 38712027Sjungma@eit.uni-kl.de } 38812027Sjungma@eit.uni-kl.de return sc_curr_simcontext; 38912027Sjungma@eit.uni-kl.de} 39012027Sjungma@eit.uni-kl.de#else 39112027Sjungma@eit.uni-kl.de extern sc_simcontext* sc_get_curr_simcontext(); 39212027Sjungma@eit.uni-kl.de#endif // 0 39312027Sjungma@eit.uni-kl.deinline sc_status sc_get_status() 39412027Sjungma@eit.uni-kl.de{ 39512027Sjungma@eit.uni-kl.de return sc_get_curr_simcontext()->get_status(); 39612027Sjungma@eit.uni-kl.de} 39712027Sjungma@eit.uni-kl.de 39812027Sjungma@eit.uni-kl.de 39912027Sjungma@eit.uni-kl.de// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 40012027Sjungma@eit.uni-kl.de 40112027Sjungma@eit.uni-kl.deinline 40212027Sjungma@eit.uni-kl.debool 40312027Sjungma@eit.uni-kl.desc_simcontext::elaboration_done() const 40412027Sjungma@eit.uni-kl.de{ 40512027Sjungma@eit.uni-kl.de return m_elaboration_done; 40612027Sjungma@eit.uni-kl.de} 40712027Sjungma@eit.uni-kl.de 40812027Sjungma@eit.uni-kl.de 40912027Sjungma@eit.uni-kl.deinline sc_status sc_simcontext::get_status() const 41012027Sjungma@eit.uni-kl.de{ 41112027Sjungma@eit.uni-kl.de return m_simulation_status != SC_RUNNING ? 41212027Sjungma@eit.uni-kl.de m_simulation_status : 41312027Sjungma@eit.uni-kl.de (m_in_simulator_control ? SC_RUNNING : SC_PAUSED); 41412027Sjungma@eit.uni-kl.de} 41512027Sjungma@eit.uni-kl.de 41612027Sjungma@eit.uni-kl.deinline 41712027Sjungma@eit.uni-kl.deint 41812027Sjungma@eit.uni-kl.desc_simcontext::sim_status() const 41912027Sjungma@eit.uni-kl.de{ 42012027Sjungma@eit.uni-kl.de if( m_error ) { 42112027Sjungma@eit.uni-kl.de return SC_SIM_ERROR; 42212027Sjungma@eit.uni-kl.de } 42312027Sjungma@eit.uni-kl.de if( m_forced_stop ) { 42412027Sjungma@eit.uni-kl.de return SC_SIM_USER_STOP; 42512027Sjungma@eit.uni-kl.de } 42612027Sjungma@eit.uni-kl.de return SC_SIM_OK; 42712027Sjungma@eit.uni-kl.de} 42812027Sjungma@eit.uni-kl.de 42912027Sjungma@eit.uni-kl.de 43012027Sjungma@eit.uni-kl.deinline 43112027Sjungma@eit.uni-kl.desc_object_manager* 43212027Sjungma@eit.uni-kl.desc_simcontext::get_object_manager() 43312027Sjungma@eit.uni-kl.de{ 43412027Sjungma@eit.uni-kl.de return m_object_manager; 43512027Sjungma@eit.uni-kl.de} 43612027Sjungma@eit.uni-kl.de 43712027Sjungma@eit.uni-kl.deinline 43812027Sjungma@eit.uni-kl.desc_module_registry* 43912027Sjungma@eit.uni-kl.desc_simcontext::get_module_registry() 44012027Sjungma@eit.uni-kl.de{ 44112027Sjungma@eit.uni-kl.de return m_module_registry; 44212027Sjungma@eit.uni-kl.de} 44312027Sjungma@eit.uni-kl.de 44412027Sjungma@eit.uni-kl.deinline 44512027Sjungma@eit.uni-kl.desc_port_registry* 44612027Sjungma@eit.uni-kl.desc_simcontext::get_port_registry() 44712027Sjungma@eit.uni-kl.de{ 44812027Sjungma@eit.uni-kl.de return m_port_registry; 44912027Sjungma@eit.uni-kl.de} 45012027Sjungma@eit.uni-kl.de 45112027Sjungma@eit.uni-kl.deinline 45212027Sjungma@eit.uni-kl.desc_export_registry* 45312027Sjungma@eit.uni-kl.desc_simcontext::get_export_registry() 45412027Sjungma@eit.uni-kl.de{ 45512027Sjungma@eit.uni-kl.de return m_export_registry; 45612027Sjungma@eit.uni-kl.de} 45712027Sjungma@eit.uni-kl.de 45812027Sjungma@eit.uni-kl.deinline 45912027Sjungma@eit.uni-kl.desc_prim_channel_registry* 46012027Sjungma@eit.uni-kl.desc_simcontext::get_prim_channel_registry() 46112027Sjungma@eit.uni-kl.de{ 46212027Sjungma@eit.uni-kl.de return m_prim_channel_registry; 46312027Sjungma@eit.uni-kl.de} 46412027Sjungma@eit.uni-kl.de 46512027Sjungma@eit.uni-kl.de 46612027Sjungma@eit.uni-kl.deinline 46712027Sjungma@eit.uni-kl.desc_curr_proc_handle 46812027Sjungma@eit.uni-kl.desc_simcontext::get_curr_proc_info() 46912027Sjungma@eit.uni-kl.de{ 47012027Sjungma@eit.uni-kl.de return &m_curr_proc_info; 47112027Sjungma@eit.uni-kl.de} 47212027Sjungma@eit.uni-kl.de 47312027Sjungma@eit.uni-kl.de 47412027Sjungma@eit.uni-kl.deinline 47512027Sjungma@eit.uni-kl.deint 47612027Sjungma@eit.uni-kl.desc_simcontext::next_proc_id() 47712027Sjungma@eit.uni-kl.de{ 47812027Sjungma@eit.uni-kl.de return ( ++ m_next_proc_id ); 47912027Sjungma@eit.uni-kl.de} 48012027Sjungma@eit.uni-kl.de 48112027Sjungma@eit.uni-kl.de 48212027Sjungma@eit.uni-kl.deinline 48312027Sjungma@eit.uni-kl.deconst sc_time& 48412027Sjungma@eit.uni-kl.desc_simcontext::max_time() const 48512027Sjungma@eit.uni-kl.de{ 48612027Sjungma@eit.uni-kl.de if ( m_max_time == SC_ZERO_TIME ) 48712027Sjungma@eit.uni-kl.de { 48812027Sjungma@eit.uni-kl.de m_max_time = sc_time::from_value( ~sc_dt::UINT64_ZERO ); 48912027Sjungma@eit.uni-kl.de } 49012027Sjungma@eit.uni-kl.de return m_max_time; 49112027Sjungma@eit.uni-kl.de} 49212027Sjungma@eit.uni-kl.de 49312027Sjungma@eit.uni-kl.deinline 49412027Sjungma@eit.uni-kl.desc_dt::uint64 49512027Sjungma@eit.uni-kl.desc_simcontext::change_stamp() const 49612027Sjungma@eit.uni-kl.de{ 49712027Sjungma@eit.uni-kl.de return m_change_stamp; 49812027Sjungma@eit.uni-kl.de} 49912027Sjungma@eit.uni-kl.de 50012027Sjungma@eit.uni-kl.deinline 50112027Sjungma@eit.uni-kl.deconst sc_time& 50212027Sjungma@eit.uni-kl.desc_simcontext::time_stamp() const 50312027Sjungma@eit.uni-kl.de{ 50412027Sjungma@eit.uni-kl.de return m_curr_time; 50512027Sjungma@eit.uni-kl.de} 50612027Sjungma@eit.uni-kl.de 50712027Sjungma@eit.uni-kl.de 50812027Sjungma@eit.uni-kl.deinline 50912027Sjungma@eit.uni-kl.debool 51012027Sjungma@eit.uni-kl.desc_simcontext::event_occurred(sc_dt::uint64 last_change_stamp) const 51112027Sjungma@eit.uni-kl.de{ 51212027Sjungma@eit.uni-kl.de return m_change_stamp == last_change_stamp; 51312027Sjungma@eit.uni-kl.de} 51412027Sjungma@eit.uni-kl.de 51512027Sjungma@eit.uni-kl.deinline 51612027Sjungma@eit.uni-kl.debool 51712027Sjungma@eit.uni-kl.desc_simcontext::evaluation_phase() const 51812027Sjungma@eit.uni-kl.de{ 51912027Sjungma@eit.uni-kl.de return (m_execution_phase == phase_evaluate) && 52012027Sjungma@eit.uni-kl.de m_ready_to_simulate; 52112027Sjungma@eit.uni-kl.de} 52212027Sjungma@eit.uni-kl.de 52312027Sjungma@eit.uni-kl.deinline 52412027Sjungma@eit.uni-kl.debool 52512027Sjungma@eit.uni-kl.desc_simcontext::update_phase() const 52612027Sjungma@eit.uni-kl.de{ 52712027Sjungma@eit.uni-kl.de return m_execution_phase == phase_update; 52812027Sjungma@eit.uni-kl.de} 52912027Sjungma@eit.uni-kl.de 53012027Sjungma@eit.uni-kl.deinline 53112027Sjungma@eit.uni-kl.debool 53212027Sjungma@eit.uni-kl.desc_simcontext::notify_phase() const 53312027Sjungma@eit.uni-kl.de{ 53412027Sjungma@eit.uni-kl.de return m_execution_phase == phase_notify; 53512027Sjungma@eit.uni-kl.de} 53612027Sjungma@eit.uni-kl.de 53712027Sjungma@eit.uni-kl.deinline 53812027Sjungma@eit.uni-kl.devoid 53912027Sjungma@eit.uni-kl.desc_simcontext::set_error( sc_report* err ) 54012027Sjungma@eit.uni-kl.de{ 54112027Sjungma@eit.uni-kl.de delete m_error; 54212027Sjungma@eit.uni-kl.de m_error = err; 54312027Sjungma@eit.uni-kl.de} 54412027Sjungma@eit.uni-kl.de 54512027Sjungma@eit.uni-kl.de 54612027Sjungma@eit.uni-kl.deinline 54712027Sjungma@eit.uni-kl.debool 54812027Sjungma@eit.uni-kl.desc_simcontext::get_error() 54912027Sjungma@eit.uni-kl.de{ 55012027Sjungma@eit.uni-kl.de return m_error != NULL; 55112027Sjungma@eit.uni-kl.de} 55212027Sjungma@eit.uni-kl.de 55312027Sjungma@eit.uni-kl.deinline 55412027Sjungma@eit.uni-kl.deint 55512027Sjungma@eit.uni-kl.desc_simcontext::add_delta_event( sc_event* e ) 55612027Sjungma@eit.uni-kl.de{ 55712027Sjungma@eit.uni-kl.de m_delta_events.push_back( e ); 55812027Sjungma@eit.uni-kl.de return ( m_delta_events.size() - 1 ); 55912027Sjungma@eit.uni-kl.de} 56012027Sjungma@eit.uni-kl.de 56112027Sjungma@eit.uni-kl.deinline 56212027Sjungma@eit.uni-kl.devoid 56312027Sjungma@eit.uni-kl.desc_simcontext::add_timed_event( sc_event_timed* et ) 56412027Sjungma@eit.uni-kl.de{ 56512027Sjungma@eit.uni-kl.de m_timed_events->insert( et ); 56612027Sjungma@eit.uni-kl.de} 56712027Sjungma@eit.uni-kl.de 56812027Sjungma@eit.uni-kl.deinline sc_object* 56912027Sjungma@eit.uni-kl.desc_simcontext::get_current_writer() const 57012027Sjungma@eit.uni-kl.de{ 57112027Sjungma@eit.uni-kl.de return m_current_writer; 57212027Sjungma@eit.uni-kl.de} 57312027Sjungma@eit.uni-kl.de 57412027Sjungma@eit.uni-kl.deinline bool 57512027Sjungma@eit.uni-kl.desc_simcontext::write_check() const 57612027Sjungma@eit.uni-kl.de{ 57712027Sjungma@eit.uni-kl.de return m_write_check; 57812027Sjungma@eit.uni-kl.de} 57912027Sjungma@eit.uni-kl.de 58012027Sjungma@eit.uni-kl.de// ---------------------------------------------------------------------------- 58112027Sjungma@eit.uni-kl.de 58212027Sjungma@eit.uni-kl.declass sc_process_handle; 58312027Sjungma@eit.uni-kl.desc_process_handle sc_get_current_process_handle(); 58412027Sjungma@eit.uni-kl.de 58512027Sjungma@eit.uni-kl.de// Get the current object hierarchy context 58612027Sjungma@eit.uni-kl.de// 58712027Sjungma@eit.uni-kl.de// Returns a pointer the the sc_object (module or process) that 58812027Sjungma@eit.uni-kl.de// would become the parent object of a newly created element 58912027Sjungma@eit.uni-kl.de// of the SystemC object hierarchy, or NULL. 59012027Sjungma@eit.uni-kl.de// 59112027Sjungma@eit.uni-kl.deinline sc_object* 59212027Sjungma@eit.uni-kl.desc_get_current_object() 59312027Sjungma@eit.uni-kl.de{ 59412027Sjungma@eit.uni-kl.de return sc_get_curr_simcontext()->active_object(); 59512027Sjungma@eit.uni-kl.de} 59612027Sjungma@eit.uni-kl.de 59712027Sjungma@eit.uni-kl.deinline 59812027Sjungma@eit.uni-kl.desc_process_b* 59912027Sjungma@eit.uni-kl.desc_get_current_process_b() 60012027Sjungma@eit.uni-kl.de{ 60112027Sjungma@eit.uni-kl.de return sc_get_curr_simcontext()->get_curr_proc_info()->process_handle; 60212027Sjungma@eit.uni-kl.de} 60312027Sjungma@eit.uni-kl.de 60412027Sjungma@eit.uni-kl.de// THE FOLLOWING FUNCTION IS DEPRECATED IN 2.1 60512027Sjungma@eit.uni-kl.deextern sc_process_b* sc_get_curr_process_handle(); 60612027Sjungma@eit.uni-kl.de 60712027Sjungma@eit.uni-kl.deinline 60812027Sjungma@eit.uni-kl.desc_curr_proc_kind 60912027Sjungma@eit.uni-kl.desc_get_curr_process_kind() 61012027Sjungma@eit.uni-kl.de{ 61112027Sjungma@eit.uni-kl.de return sc_get_curr_simcontext()->get_curr_proc_info()->kind; 61212027Sjungma@eit.uni-kl.de} 61312027Sjungma@eit.uni-kl.de 61412027Sjungma@eit.uni-kl.de 61512027Sjungma@eit.uni-kl.deinline int sc_get_simulator_status() 61612027Sjungma@eit.uni-kl.de{ 61712027Sjungma@eit.uni-kl.de return sc_get_curr_simcontext()->sim_status(); 61812027Sjungma@eit.uni-kl.de} 61912027Sjungma@eit.uni-kl.de 62012027Sjungma@eit.uni-kl.de 62112027Sjungma@eit.uni-kl.de// Generates unique names within each module. 62212027Sjungma@eit.uni-kl.deextern 62312027Sjungma@eit.uni-kl.deconst char* 62412027Sjungma@eit.uni-kl.desc_gen_unique_name( const char* basename_, bool preserve_first = false ); 62512027Sjungma@eit.uni-kl.de 62612027Sjungma@eit.uni-kl.de 62712027Sjungma@eit.uni-kl.de// Set the random seed for controlled randomization -- not yet implemented 62812027Sjungma@eit.uni-kl.deextern 62912027Sjungma@eit.uni-kl.devoid 63012027Sjungma@eit.uni-kl.desc_set_random_seed( unsigned int seed_ ); 63112027Sjungma@eit.uni-kl.de 63212027Sjungma@eit.uni-kl.de 63312027Sjungma@eit.uni-kl.deextern void sc_initialize(); 63412027Sjungma@eit.uni-kl.de 63512027Sjungma@eit.uni-kl.deextern const sc_time& sc_max_time(); // Get maximum time value. 63612027Sjungma@eit.uni-kl.deextern const sc_time& sc_time_stamp(); // Current simulation time. 63712027Sjungma@eit.uni-kl.deextern double sc_simulation_time(); // Current time in default time units. 63812027Sjungma@eit.uni-kl.de 63912027Sjungma@eit.uni-kl.deinline 64012027Sjungma@eit.uni-kl.deconst std::vector<sc_event*>& sc_get_top_level_events( 64112027Sjungma@eit.uni-kl.de const sc_simcontext* simc_p = sc_get_curr_simcontext() ) 64212027Sjungma@eit.uni-kl.de{ 64312027Sjungma@eit.uni-kl.de return simc_p->m_child_events; 64412027Sjungma@eit.uni-kl.de} 64512027Sjungma@eit.uni-kl.de 64612027Sjungma@eit.uni-kl.deinline 64712027Sjungma@eit.uni-kl.deconst std::vector<sc_object*>& sc_get_top_level_objects( 64812027Sjungma@eit.uni-kl.de const sc_simcontext* simc_p = sc_get_curr_simcontext() ) 64912027Sjungma@eit.uni-kl.de{ 65012027Sjungma@eit.uni-kl.de return simc_p->m_child_objects; 65112027Sjungma@eit.uni-kl.de} 65212027Sjungma@eit.uni-kl.de 65312027Sjungma@eit.uni-kl.deextern sc_event* sc_find_event( const char* name ); 65412027Sjungma@eit.uni-kl.de 65512027Sjungma@eit.uni-kl.deextern sc_object* sc_find_object( const char* name ); 65612027Sjungma@eit.uni-kl.de 65712027Sjungma@eit.uni-kl.deinline 65812027Sjungma@eit.uni-kl.desc_dt::uint64 sc_delta_count() 65912027Sjungma@eit.uni-kl.de{ 66012027Sjungma@eit.uni-kl.de return sc_get_curr_simcontext()->m_delta_count; 66112027Sjungma@eit.uni-kl.de} 66212027Sjungma@eit.uni-kl.de 66312027Sjungma@eit.uni-kl.deinline 66412027Sjungma@eit.uni-kl.debool sc_is_running( const sc_simcontext* simc_p = sc_get_curr_simcontext() ) 66512027Sjungma@eit.uni-kl.de{ 66612027Sjungma@eit.uni-kl.de return simc_p->m_ready_to_simulate; 66712027Sjungma@eit.uni-kl.de} 66812027Sjungma@eit.uni-kl.de 66912027Sjungma@eit.uni-kl.debool sc_is_unwinding(); 67012027Sjungma@eit.uni-kl.de 67112027Sjungma@eit.uni-kl.deinline void sc_pause() 67212027Sjungma@eit.uni-kl.de{ 67312027Sjungma@eit.uni-kl.de sc_get_curr_simcontext()->m_paused = true; 67412027Sjungma@eit.uni-kl.de} 67512027Sjungma@eit.uni-kl.de 67612027Sjungma@eit.uni-kl.de// Return indication if there are more processes to execute in this delta phase 67712027Sjungma@eit.uni-kl.de 67812027Sjungma@eit.uni-kl.deinline bool sc_pending_activity_at_current_time 67912027Sjungma@eit.uni-kl.de ( const sc_simcontext* simc_p = sc_get_curr_simcontext() ) 68012027Sjungma@eit.uni-kl.de{ 68112027Sjungma@eit.uni-kl.de return simc_p->pending_activity_at_current_time(); 68212027Sjungma@eit.uni-kl.de} 68312027Sjungma@eit.uni-kl.de 68412027Sjungma@eit.uni-kl.de// Return indication if there are timed notifications in the future 68512027Sjungma@eit.uni-kl.de 68612027Sjungma@eit.uni-kl.deinline bool sc_pending_activity_at_future_time 68712027Sjungma@eit.uni-kl.de ( const sc_simcontext* simc_p = sc_get_curr_simcontext() ) 68812027Sjungma@eit.uni-kl.de{ 68912027Sjungma@eit.uni-kl.de sc_time ignored; 69012027Sjungma@eit.uni-kl.de return simc_p->next_time( ignored ); 69112027Sjungma@eit.uni-kl.de} 69212027Sjungma@eit.uni-kl.de 69312027Sjungma@eit.uni-kl.de// Return indication if there are processes to run, 69412027Sjungma@eit.uni-kl.de// or notifications in the future 69512027Sjungma@eit.uni-kl.de 69612027Sjungma@eit.uni-kl.deinline bool sc_pending_activity 69712027Sjungma@eit.uni-kl.de ( const sc_simcontext* simc_p = sc_get_curr_simcontext() ) 69812027Sjungma@eit.uni-kl.de{ 69912027Sjungma@eit.uni-kl.de return sc_pending_activity_at_current_time( simc_p ) 70012027Sjungma@eit.uni-kl.de || sc_pending_activity_at_future_time( simc_p ); 70112027Sjungma@eit.uni-kl.de} 70212027Sjungma@eit.uni-kl.de 70312027Sjungma@eit.uni-kl.desc_time 70412027Sjungma@eit.uni-kl.desc_time_to_pending_activity 70512027Sjungma@eit.uni-kl.de ( const sc_simcontext* simc_p = sc_get_curr_simcontext() ); 70612027Sjungma@eit.uni-kl.de 70712027Sjungma@eit.uni-kl.de 70812027Sjungma@eit.uni-kl.deinline 70912027Sjungma@eit.uni-kl.debool 71012027Sjungma@eit.uni-kl.desc_end_of_simulation_invoked() 71112027Sjungma@eit.uni-kl.de{ 71212027Sjungma@eit.uni-kl.de return sc_get_curr_simcontext()->m_end_of_simulation_called; 71312027Sjungma@eit.uni-kl.de} 71412027Sjungma@eit.uni-kl.de 71512027Sjungma@eit.uni-kl.deinline bool sc_hierarchical_name_exists( const char* name ) 71612027Sjungma@eit.uni-kl.de{ 71712027Sjungma@eit.uni-kl.de return sc_find_object(name) || sc_find_event(name); 71812027Sjungma@eit.uni-kl.de} 71912027Sjungma@eit.uni-kl.de 72012027Sjungma@eit.uni-kl.deinline 72112027Sjungma@eit.uni-kl.debool 72212027Sjungma@eit.uni-kl.desc_start_of_simulation_invoked() 72312027Sjungma@eit.uni-kl.de{ 72412027Sjungma@eit.uni-kl.de return sc_get_curr_simcontext()->m_start_of_simulation_called; 72512027Sjungma@eit.uni-kl.de} 72612027Sjungma@eit.uni-kl.de 72712027Sjungma@eit.uni-kl.de// The following variable controls whether process control corners should 72812027Sjungma@eit.uni-kl.de// be considered errors or not. See sc_simcontext.cpp for details on what 72912027Sjungma@eit.uni-kl.de// happens if this value is set to true. 73012027Sjungma@eit.uni-kl.de 73112027Sjungma@eit.uni-kl.deextern bool sc_allow_process_control_corners; 73212027Sjungma@eit.uni-kl.de 73312027Sjungma@eit.uni-kl.de} // namespace sc_core 73412027Sjungma@eit.uni-kl.de 73512027Sjungma@eit.uni-kl.de/***************************************************************************** 73612027Sjungma@eit.uni-kl.de 73712027Sjungma@eit.uni-kl.de MODIFICATION LOG - modifiers, enter your name, affiliation, date and 73812027Sjungma@eit.uni-kl.de changes you are making here. 73912027Sjungma@eit.uni-kl.de 74012027Sjungma@eit.uni-kl.de Name, Affiliation, Date: Andy Goodrich, Forte Design Systems 20 May 2003 74112027Sjungma@eit.uni-kl.de Description of Modification: - phase callbacks 74212027Sjungma@eit.uni-kl.de - sc_stop mode 74312027Sjungma@eit.uni-kl.de 74412027Sjungma@eit.uni-kl.de Name, Affiliation, Date: Bishnupriya Bhattacharya, Cadence Design Systems, 74512027Sjungma@eit.uni-kl.de 25 August, 2003 74612027Sjungma@eit.uni-kl.de Description of Modification: - support for dynamic process 74712027Sjungma@eit.uni-kl.de - support for sc export registry 74812027Sjungma@eit.uni-kl.de - new member methods elaborate(), 74912027Sjungma@eit.uni-kl.de prepare_to_simulate(), and initial_crunch() 75012027Sjungma@eit.uni-kl.de that are invoked by initialize() in that order 75112027Sjungma@eit.uni-kl.de - add sc_get_last_created_process_handle() for 75212027Sjungma@eit.uni-kl.de use before simulation starts 75312027Sjungma@eit.uni-kl.de 75412027Sjungma@eit.uni-kl.de Name, Affiliation, Date: Bishnupriya Bhattacharya, Cadence Design Systems, 75512027Sjungma@eit.uni-kl.de 3 March, 2004 75612027Sjungma@eit.uni-kl.de Description of Modification: add sc_get_curr_process_kind() 75712027Sjungma@eit.uni-kl.de 75812027Sjungma@eit.uni-kl.de Name, Affiliation, Date: 75912027Sjungma@eit.uni-kl.de Description of Modification: 76012027Sjungma@eit.uni-kl.de 76112027Sjungma@eit.uni-kl.de *****************************************************************************/ 76212027Sjungma@eit.uni-kl.de// $Log: sc_simcontext.h,v $ 76312027Sjungma@eit.uni-kl.de// Revision 1.26 2011/09/05 21:20:22 acg 76412027Sjungma@eit.uni-kl.de// Andy Goodrich: result of automake invocation. 76512027Sjungma@eit.uni-kl.de// 76612027Sjungma@eit.uni-kl.de// Revision 1.25 2011/09/01 15:28:10 acg 76712027Sjungma@eit.uni-kl.de// Andy Goodrich: the aftermath of automake. 76812027Sjungma@eit.uni-kl.de// 76912027Sjungma@eit.uni-kl.de// Revision 1.24 2011/08/29 18:04:32 acg 77012027Sjungma@eit.uni-kl.de// Philipp A. Hartmann: miscellaneous clean ups. 77112027Sjungma@eit.uni-kl.de// 77212027Sjungma@eit.uni-kl.de// Revision 1.23 2011/08/26 20:46:10 acg 77312027Sjungma@eit.uni-kl.de// Andy Goodrich: moved the modification log to the end of the file to 77412027Sjungma@eit.uni-kl.de// eliminate source line number skew when check-ins are done. 77512027Sjungma@eit.uni-kl.de// 77612027Sjungma@eit.uni-kl.de// Revision 1.22 2011/08/24 22:05:51 acg 77712027Sjungma@eit.uni-kl.de// Torsten Maehne: initialization changes to remove warnings. 77812027Sjungma@eit.uni-kl.de// 77912027Sjungma@eit.uni-kl.de// Revision 1.21 2011/05/09 04:07:49 acg 78012027Sjungma@eit.uni-kl.de// Philipp A. Hartmann: 78112027Sjungma@eit.uni-kl.de// (1) Restore hierarchy in all phase callbacks. 78212027Sjungma@eit.uni-kl.de// (2) Ensure calls to before_end_of_elaboration. 78312027Sjungma@eit.uni-kl.de// 78412027Sjungma@eit.uni-kl.de// Revision 1.20 2011/04/08 18:26:07 acg 78512027Sjungma@eit.uni-kl.de// Andy Goodrich: added execute_method_next() to handle method dispatch 78612027Sjungma@eit.uni-kl.de// for asynchronous notifications that occur outside the evaluation phase. 78712027Sjungma@eit.uni-kl.de// 78812027Sjungma@eit.uni-kl.de// Revision 1.19 2011/04/05 20:50:57 acg 78912027Sjungma@eit.uni-kl.de// Andy Goodrich: 79012027Sjungma@eit.uni-kl.de// (1) changes to make sure that event(), posedge() and negedge() only 79112027Sjungma@eit.uni-kl.de// return true if the clock has not moved. 79212027Sjungma@eit.uni-kl.de// (2) fixes for method self-resumes. 79312027Sjungma@eit.uni-kl.de// (3) added SC_PRERELEASE_VERSION 79412027Sjungma@eit.uni-kl.de// (4) removed kernel events from the object hierarchy, added 79512027Sjungma@eit.uni-kl.de// sc_hierarchical_name_exists(). 79612027Sjungma@eit.uni-kl.de// 79712027Sjungma@eit.uni-kl.de// Revision 1.18 2011/03/20 13:43:23 acg 79812027Sjungma@eit.uni-kl.de// Andy Goodrich: added async_signal_is() plus suspend() as a corner case. 79912027Sjungma@eit.uni-kl.de// 80012027Sjungma@eit.uni-kl.de// Revision 1.17 2011/03/07 18:25:19 acg 80112027Sjungma@eit.uni-kl.de// Andy Goodrich: tightening of check for resume on a disabled process to 80212027Sjungma@eit.uni-kl.de// only produce an error if it is ready to run. 80312027Sjungma@eit.uni-kl.de// 80412027Sjungma@eit.uni-kl.de// Revision 1.16 2011/03/06 15:58:50 acg 80512027Sjungma@eit.uni-kl.de// Andy Goodrich: added escape to turn off process control corner case 80612027Sjungma@eit.uni-kl.de// checks. 80712027Sjungma@eit.uni-kl.de// 80812027Sjungma@eit.uni-kl.de// Revision 1.15 2011/03/05 04:45:16 acg 80912027Sjungma@eit.uni-kl.de// Andy Goodrich: moved active process calculation to the sc_simcontext class. 81012027Sjungma@eit.uni-kl.de// 81112027Sjungma@eit.uni-kl.de// Revision 1.14 2011/03/05 01:39:21 acg 81212027Sjungma@eit.uni-kl.de// Andy Goodrich: changes for named events. 81312027Sjungma@eit.uni-kl.de// 81412027Sjungma@eit.uni-kl.de// Revision 1.13 2011/02/18 20:27:14 acg 81512027Sjungma@eit.uni-kl.de// Andy Goodrich: Updated Copyrights. 81612027Sjungma@eit.uni-kl.de// 81712027Sjungma@eit.uni-kl.de// Revision 1.12 2011/02/13 21:47:38 acg 81812027Sjungma@eit.uni-kl.de// Andy Goodrich: update copyright notice. 81912027Sjungma@eit.uni-kl.de// 82012027Sjungma@eit.uni-kl.de// Revision 1.11 2011/02/13 21:34:35 acg 82112027Sjungma@eit.uni-kl.de// Andy Goodrich: added SC_UNITIALIZED enum value to process status so 82212027Sjungma@eit.uni-kl.de// its possible to detect throws before initialization. 82312027Sjungma@eit.uni-kl.de// 82412027Sjungma@eit.uni-kl.de// Revision 1.10 2011/02/11 13:25:24 acg 82512027Sjungma@eit.uni-kl.de// Andy Goodrich: Philipp A. Hartmann's changes: 82612027Sjungma@eit.uni-kl.de// (1) Removal of SC_CTHREAD method overloads. 82712027Sjungma@eit.uni-kl.de// (2) New exception processing code. 82812027Sjungma@eit.uni-kl.de// 82912027Sjungma@eit.uni-kl.de// Revision 1.9 2011/02/01 21:18:56 acg 83012027Sjungma@eit.uni-kl.de// Andy Goodrich: addition of new preempt_with() method used to immediately 83112027Sjungma@eit.uni-kl.de// throw exceptions from threads. 83212027Sjungma@eit.uni-kl.de// 83312027Sjungma@eit.uni-kl.de// Revision 1.8 2011/01/25 20:50:37 acg 83412027Sjungma@eit.uni-kl.de// Andy Goodrich: changes for IEEE 1666 2011. 83512027Sjungma@eit.uni-kl.de// 83612027Sjungma@eit.uni-kl.de// Revision 1.7 2011/01/19 23:21:50 acg 83712027Sjungma@eit.uni-kl.de// Andy Goodrich: changes for IEEE 1666 2011 83812027Sjungma@eit.uni-kl.de// 83912027Sjungma@eit.uni-kl.de// Revision 1.6 2011/01/18 20:10:45 acg 84012027Sjungma@eit.uni-kl.de// Andy Goodrich: changes for IEEE1666_2011 semantics. 84112027Sjungma@eit.uni-kl.de// 84212027Sjungma@eit.uni-kl.de// Revision 1.5 2010/07/22 20:02:33 acg 84312027Sjungma@eit.uni-kl.de// Andy Goodrich: bug fixes. 84412027Sjungma@eit.uni-kl.de// 84512027Sjungma@eit.uni-kl.de// Revision 1.4 2009/05/22 16:06:29 acg 84612027Sjungma@eit.uni-kl.de// Andy Goodrich: process control updates. 84712027Sjungma@eit.uni-kl.de// 84812027Sjungma@eit.uni-kl.de// Revision 1.3 2008/05/22 17:06:26 acg 84912027Sjungma@eit.uni-kl.de// Andy Goodrich: updated copyright notice to include 2008. 85012027Sjungma@eit.uni-kl.de// 85112027Sjungma@eit.uni-kl.de// Revision 1.2 2007/09/20 20:32:35 acg 85212027Sjungma@eit.uni-kl.de// Andy Goodrich: changes to the semantics of throw_it() to match the 85312027Sjungma@eit.uni-kl.de// specification. A call to throw_it() will immediately suspend the calling 85412027Sjungma@eit.uni-kl.de// thread until all the throwees have executed. At that point the calling 85512027Sjungma@eit.uni-kl.de// thread will be restarted before the execution of any other threads. 85612027Sjungma@eit.uni-kl.de// 85712027Sjungma@eit.uni-kl.de// Revision 1.1.1.1 2006/12/15 20:20:05 acg 85812027Sjungma@eit.uni-kl.de// SystemC 2.3 85912027Sjungma@eit.uni-kl.de// 86012027Sjungma@eit.uni-kl.de// Revision 1.13 2006/05/08 18:00:06 acg 86112027Sjungma@eit.uni-kl.de// Andy Goodrich: added David Long's forward declarations for friend 86212027Sjungma@eit.uni-kl.de// functions, methods, and operators to keep the Microsoft compiler happy. 86312027Sjungma@eit.uni-kl.de// 86412027Sjungma@eit.uni-kl.de// Revision 1.11 2006/04/11 23:13:21 acg 86512027Sjungma@eit.uni-kl.de// Andy Goodrich: Changes for reduced reset support that only includes 86612027Sjungma@eit.uni-kl.de// sc_cthread, but has preliminary hooks for expanding to method and thread 86712027Sjungma@eit.uni-kl.de// processes also. 86812027Sjungma@eit.uni-kl.de// 86912027Sjungma@eit.uni-kl.de// Revision 1.10 2006/03/21 00:00:34 acg 87012027Sjungma@eit.uni-kl.de// Andy Goodrich: changed name of sc_get_current_process_base() to be 87112027Sjungma@eit.uni-kl.de// sc_get_current_process_b() since its returning an sc_process_b instance. 87212027Sjungma@eit.uni-kl.de// 87312027Sjungma@eit.uni-kl.de// Revision 1.9 2006/01/26 21:04:54 acg 87412027Sjungma@eit.uni-kl.de// Andy Goodrich: deprecation message changes and additional messages. 87512027Sjungma@eit.uni-kl.de// 87612027Sjungma@eit.uni-kl.de// Revision 1.8 2006/01/24 20:49:05 acg 87712027Sjungma@eit.uni-kl.de// Andy Goodrich: changes to remove the use of deprecated features within the 87812027Sjungma@eit.uni-kl.de// simulator, and to issue warning messages when deprecated features are used. 87912027Sjungma@eit.uni-kl.de// 88012027Sjungma@eit.uni-kl.de// Revision 1.7 2006/01/19 00:29:52 acg 88112027Sjungma@eit.uni-kl.de// Andy Goodrich: Yet another implementation for signal write checking. This 88212027Sjungma@eit.uni-kl.de// one uses an environment variable SC_SIGNAL_WRITE_CHECK, that when set to 88312027Sjungma@eit.uni-kl.de// DISABLE will disable write checking on signals. 88412027Sjungma@eit.uni-kl.de// 88512027Sjungma@eit.uni-kl.de// Revision 1.6 2006/01/18 21:42:37 acg 88612027Sjungma@eit.uni-kl.de// Andy Goodrich: Changes for check writer support. 88712027Sjungma@eit.uni-kl.de// 88812027Sjungma@eit.uni-kl.de// Revision 1.5 2006/01/13 18:44:30 acg 88912027Sjungma@eit.uni-kl.de// Added $Log to record CVS changes into the source. 89012027Sjungma@eit.uni-kl.de// 89112027Sjungma@eit.uni-kl.de// Revision 1.4 2006/01/03 23:18:44 acg 89212027Sjungma@eit.uni-kl.de// Changed copyright to include 2006. 89312027Sjungma@eit.uni-kl.de// 89412027Sjungma@eit.uni-kl.de// Revision 1.3 2005/12/20 22:11:10 acg 89512027Sjungma@eit.uni-kl.de// Fixed $Log lines. 89612027Sjungma@eit.uni-kl.de// 89712027Sjungma@eit.uni-kl.de// Revision 1.2 2005/12/20 22:02:30 acg 89812027Sjungma@eit.uni-kl.de// Changed where delta cycles are incremented to match IEEE 1666. Added the 89912027Sjungma@eit.uni-kl.de// event_occurred() method to hide how delta cycle comparisions are done within 90012027Sjungma@eit.uni-kl.de// sc_simcontext. Changed the boolean update_phase to an enum that shows all 90112027Sjungma@eit.uni-kl.de// the phases. 90212027Sjungma@eit.uni-kl.de 90312027Sjungma@eit.uni-kl.de#endif 904