00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef SC_SIMCONTEXT_H
00029 #define SC_SIMCONTEXT_H
00030
00031 #include "sysc/kernel/sc_cmnhdr.h"
00032 #include "sysc/kernel/sc_process.h"
00033 #include "sysc/kernel/sc_status.h"
00034 #include "sysc/kernel/sc_time.h"
00035 #include "sysc/utils/sc_hash.h"
00036 #include "sysc/utils/sc_pq.h"
00037 #include <list>
00038 #include <string.h>
00039 #include <time.h>
00040
00041
00042 #ifndef _SYSC_PRINT_VERBOSE_MESSAGE_ENV_VAR
00043 #define _SYSC_PRINT_VERBOSE_MESSAGE_ENV_VAR "SYSC_PRINT_VERBOSE_MESSAGE"
00044 #endif
00045 namespace sc_core {
00046
00047
00048
00049 class sc_cor;
00050 class sc_cor_pkg;
00051 class sc_event;
00052 class sc_event_timed;
00053 class sc_export_registry;
00054 class sc_module;
00055 class sc_module_name;
00056 class sc_module_registry;
00057 class sc_name_gen;
00058 class sc_object;
00059 class sc_object_manager;
00060 class sc_phase_callback_registry;
00061 class sc_process_handle;
00062 class sc_port_registry;
00063 class sc_prim_channel_registry;
00064 class sc_process_table;
00065 class sc_signal_bool_deval;
00066 class sc_trace_file;
00067 class sc_runnable;
00068 class sc_process_host;
00069 class sc_method_process;
00070 class sc_cthread_process;
00071 class sc_thread_process;
00072
00073 template< typename > class sc_plist;
00074 typedef sc_plist< sc_process_b* > sc_process_list;
00075
00076
00077
00078 enum sc_stop_mode {
00079 SC_STOP_FINISH_DELTA,
00080 SC_STOP_IMMEDIATE
00081 };
00082 extern void sc_set_stop_mode( sc_stop_mode mode );
00083 extern sc_stop_mode sc_get_stop_mode();
00084
00085 enum sc_starvation_policy
00086 {
00087 SC_EXIT_ON_STARVATION,
00088 SC_RUN_TO_TIME
00089 };
00090 extern void sc_start();
00091 extern void sc_start( const sc_time& duration,
00092 sc_starvation_policy p=SC_RUN_TO_TIME );
00093 inline void sc_start( int duration, sc_time_unit unit,
00094 sc_starvation_policy p=SC_RUN_TO_TIME )
00095 {
00096 sc_start( sc_time((double)duration,unit), p );
00097 }
00098
00099 inline void sc_start( double duration, sc_time_unit unit,
00100 sc_starvation_policy p=SC_RUN_TO_TIME )
00101 {
00102 sc_start( sc_time(duration,unit), p );
00103 }
00104
00105 extern void sc_stop();
00106
00107
00108 extern bool _SYSC_SYNC_PAR_SIM;
00109
00110
00111
00112 sc_dt::uint64 sc_delta_count();
00113 const std::vector<sc_event*>& sc_get_top_level_events(
00114 const sc_simcontext* simc_p);
00115 const std::vector<sc_object*>& sc_get_top_level_objects(
00116 const sc_simcontext* simc_p);
00117 bool sc_is_running( const sc_simcontext* simc_p );
00118 void sc_pause();
00119 bool sc_end_of_simulation_invoked();
00120 void sc_start( const sc_time&, sc_starvation_policy );
00121 bool sc_start_of_simulation_invoked();
00122 void sc_set_time_resolution( double, sc_time_unit );
00123 sc_time sc_get_time_resolution();
00124 void sc_set_default_time_unit( double, sc_time_unit );
00125 sc_time sc_get_default_time_unit();
00126 bool sc_pending_activity_at_current_time( const sc_simcontext* );
00127 bool sc_pending_activity_at_future_time( const sc_simcontext* );
00128 sc_time sc_time_to_pending_activity( const sc_simcontext* );
00129
00130 struct sc_invoke_method;
00131
00135
00136 struct sc_kernel_lock {
00137 sc_simcontext* simc_p;
00138 sc_cor* m_cor_p;
00139 explicit sc_kernel_lock();
00140 ~sc_kernel_lock();
00141 };
00142
00143
00144 extern unsigned int _OoO_Combined_Data_Conflict_Table_Size;
00145
00146
00147 extern unsigned int _OoO_Combined_Data_Conflict_Lookup_Table_Number_Segments;
00148
00149
00150 extern unsigned int _OoO_Combined_Data_Conflict_Lookup_Table_Max_Instances;
00151
00152
00153 extern unsigned int _OoO_Prediction_Time_Advance_Table_Number_Steps;
00154
00155
00156 extern unsigned int _OoO_Prediction_Time_Advance_Table_Number_Segments;
00157
00158
00159 extern unsigned int _OoO_Prediction_Event_Notification_Table_Number_Segments;
00160
00161
00162 extern unsigned int _OoO_Prediction_Event_Notification_Table_Max_Instances;
00163
00164
00165
00166 extern int _OoO_Combined_Data_Conflict_Table[];
00167
00168
00169 extern int _OoO_Combined_Data_Conflict_Lookup_Table[];
00170
00171
00172 extern long long _OoO_Prediction_Time_Advance_Table_Time_Units[];
00173
00174
00175 extern int _OoO_Prediction_Time_Advance_Table_Delta[];
00176
00177
00178 extern int _OoO_Prediction_Time_Advance_Lookup_Table[];
00179
00180
00181 extern long long _OoO_Prediction_Event_Notification_Table_Time_Units[];
00182
00183
00184 extern int _OoO_Prediction_Event_Notification_Table_Delta[];
00185
00186
00187 extern int _OoO_Prediction_Event_Notification_Lookup_Table[];
00188
00189
00193
00194 extern bool _OoO_Data_Conflict_Table[];
00195
00199
00200 extern unsigned int _OoO_Data_Conflict_Table_Size;
00201
00205
00206 extern bool _OoO_Event_Notify_Table[];
00207
00211
00212 extern unsigned int _OoO_Event_Notify_Table_Size;
00213
00218
00219 extern int _OoO_Conflict_Index_Lookup_Table[];
00220
00224
00225 extern unsigned int _OoO_Max_Number_of_Instances;
00226
00230
00231 extern unsigned int _OoO_Number_of_Segments;
00232
00237
00238 extern long long _OoO_Curr_Time_Advance_Table_Time[];
00239
00244
00245 extern int _OoO_Curr_Time_Advance_Table_Delta[];
00246
00250
00251 extern unsigned int _OoO_Curr_Time_Advance_Table_Size;
00252
00257
00258 extern long long _OoO_Next_Time_Advance_Table_Time[];
00259
00264
00265 extern int _OoO_Next_Time_Advance_Table_Delta[];
00266
00270
00271 extern unsigned int _OoO_Next_Time_Advance_Table_Size;
00272
00276
00277 extern int _OoO_Time_Advance_Index_Lookup_Table[];
00278
00282
00283 extern unsigned int _OoO_Time_Advance_Index_Lookup_Table_Size;
00284
00285
00291 class sc_simcontext
00292 {
00293 friend struct sc_invoke_method;
00294 friend class sc_event;
00295 friend class sc_module;
00296
00297
00298 friend class sc_channel;
00299
00300 friend class sc_object;
00301 friend class sc_time;
00302 friend class sc_clock;
00303 friend class sc_method_process;
00304 friend class sc_phase_callback_registry;
00305 friend class sc_process_b;
00306 friend class sc_process_handle;
00307 friend class sc_prim_channel;
00308 friend class sc_cthread_process;
00309 friend class sc_thread_process;
00310 friend class sc_runnable;
00311 friend sc_dt::uint64 sc_delta_count();
00312 friend const std::vector<sc_event*>& sc_get_top_level_events(
00313 const sc_simcontext* simc_p);
00314 friend const std::vector<sc_object*>& sc_get_top_level_objects(
00315 const sc_simcontext* simc_p);
00316 friend bool sc_is_running( const sc_simcontext* simc_p );
00317 friend void sc_pause();
00318 friend bool sc_end_of_simulation_invoked();
00319 friend void sc_start( const sc_time&, sc_starvation_policy );
00320 friend bool sc_start_of_simulation_invoked();
00321 friend void sc_thread_cor_fn(void*);
00322 friend sc_time sc_time_to_pending_activity( const sc_simcontext* );
00323 friend bool sc_pending_activity_at_current_time( const sc_simcontext* );
00324 friend bool sc_pending_activity_at_future_time( const sc_simcontext* );
00325
00326
00327 friend struct sc_kernel_lock;
00328
00329
00330 friend sc_cor* get_cor_pointer( sc_process_b* process_p );
00331
00332
00333 void init();
00334 void clean();
00335
00336 public:
00337
00338 sc_simcontext();
00339 ~sc_simcontext();
00340
00341 void initialize( bool = false );
00342
00347
00348 void cycle( const sc_time& );
00349
00350 void simulate( const sc_time& duration );
00351 void stop();
00352 void end();
00353 void reset();
00354 void print_ready_threads();
00355 void print_all_threads();
00356 void print_events();
00357
00358
00359
00360
00366
00367
00368
00372
00373 void oooschedule( sc_cor *cor );
00374
00375 int sim_status() const;
00376 bool elaboration_done() const;
00377
00378 std::vector<sc_thread_handle>& get_active_invokers();
00379
00380 sc_object_manager* get_object_manager();
00381
00382 inline sc_status get_status() const;
00383
00384 sc_object* active_object();
00385
00386 void hierarchy_push( sc_module* );
00387 sc_module* hierarchy_pop();
00388 sc_module* hierarchy_curr() const;
00389 sc_object* first_object();
00390 sc_object* next_object();
00391 sc_object* find_object( const char* name );
00392
00393 sc_module_registry* get_module_registry();
00394 sc_port_registry* get_port_registry();
00395 sc_export_registry* get_export_registry();
00396 sc_prim_channel_registry* get_prim_channel_registry();
00397
00398
00399 const char* gen_unique_name( const char* basename_,
00400 bool preserve_first = false
00401 );
00402
00403
00404
00409
00410
00411 sc_process_handle create_cthread_process(
00412 const char* name_p, bool free_host, SC_ENTRY_FUNC method_p,
00413 sc_process_host* host_p, const sc_spawn_options* opt_p,
00414 int seg_id, int inst_id );
00415
00420
00421
00422 sc_process_handle create_method_process(
00423 const char* name_p, bool free_host, SC_ENTRY_FUNC method_p,
00424 sc_process_host* host_p, const sc_spawn_options* opt_p,
00425 int seg_id, int inst_id );
00426
00431
00432
00433 sc_process_handle create_thread_process(
00434 const char* name_p, bool free_host, SC_ENTRY_FUNC method_p,
00435 sc_process_host* host_p, const sc_spawn_options* opt_p,
00436 int seg_id, int inst_id );
00437
00438
00439
00440
00441 sc_process_b* get_curr_proc() const;
00442 sc_object* get_current_writer() const;
00443 bool write_check() const;
00444
00449
00450 void set_curr_proc( sc_process_b* );
00451
00452 void reset_curr_proc();
00453
00454 int next_proc_id();
00455
00456 void add_trace_file( sc_trace_file* );
00457 void remove_trace_file( sc_trace_file* );
00458
00459 friend void sc_set_time_resolution( double, sc_time_unit );
00460 friend sc_time sc_get_time_resolution();
00461 friend void sc_set_default_time_unit( double, sc_time_unit );
00462 friend sc_time sc_get_default_time_unit();
00463
00464 const sc_time& max_time() const;
00465
00466
00467 const sc_time& time_stamp();
00468
00469 sc_dt::uint64 change_stamp() const;
00470
00471
00472 sc_dt::uint64 delta_count() const;
00473
00474 bool event_occurred( sc_dt::uint64 last_change_count ) const;
00475 bool evaluation_phase() const;
00476 bool is_running() const;
00477 bool update_phase() const;
00478 bool notify_phase() const;
00479 bool get_error();
00480 void set_error( sc_report* );
00481
00482 sc_cor_pkg* cor_pkg()
00483 { return m_cor_pkg; }
00484 sc_cor* next_cor();
00485
00486 const ::std::vector<sc_object*>& get_child_objects() const;
00487
00488 void elaborate();
00489 void prepare_to_simulate();
00490
00495
00496 inline void initial_crunch( bool no_crunch );
00497
00498 bool next_time( sc_time& t ) const;
00499 bool pending_activity_at_current_time() const;
00500
00504
00505 void remove_running_process( sc_process_b* );
00506
00510
00511 bool is_running_process( sc_process_b* );
00512
00516
00517 void suspend_cor( sc_cor* );
00518
00522
00523 void resume_cor( sc_cor* );
00524
00528
00529 bool is_locked();
00530
00534
00535 bool is_unlocked();
00536
00541
00542 bool is_lock_owner();
00543
00548
00549 bool is_not_owner();
00550
00555
00556 bool is_locked_and_owner();
00557
00562
00563 unsigned int conflict_table_index_lookup( int, int );
00564
00568
00569 unsigned int time_adv_table_index_lookup( int );
00570
00571 private:
00572
00573 void add_child_event( sc_event* );
00574 void add_child_object( sc_object* );
00575 void remove_child_event( sc_event* );
00576 void remove_child_object( sc_object* );
00577
00578
00579
00580 int add_delta_event( sc_event* );
00581 void remove_delta_event( sc_event* );
00582 void add_timed_event( sc_event_timed* );
00583
00584 void trace_cycle( bool delta_cycle );
00585
00586 const ::std::vector<sc_event*>& get_child_events_internal() const;
00587 const ::std::vector<sc_object*>& get_child_objects_internal() const;
00588
00589 void execute_method_next( sc_method_handle );
00590 void execute_thread_next( sc_thread_handle );
00591
00592 sc_method_handle pop_runnable_method();
00593 sc_thread_handle pop_runnable_thread();
00594
00599
00600 void preempt_with( sc_method_handle );
00601
00606
00607 inline void preempt_with( sc_thread_handle );
00608
00609 void push_runnable_method( sc_method_handle );
00610 void push_runnable_thread( sc_thread_handle );
00611
00612 void push_runnable_method_front( sc_method_handle );
00613 void push_runnable_thread_front( sc_thread_handle );
00614
00615 void remove_runnable_method( sc_method_handle );
00616 void remove_runnable_thread( sc_thread_handle );
00617
00618 void requeue_current_process();
00619 void suspend_current_process();
00620
00621 void do_sc_stop_action();
00622 void mark_to_collect_process( sc_process_b* zombie_p );
00623
00627
00628 void acquire_sched_mutex();
00629
00633
00634 void release_sched_mutex();
00635
00639
00640 bool has_no_conflicts( sc_process_b*, std::list<sc_method_handle>, std::list<sc_thread_handle> );
00641
00645
00646
00647
00651
00652
00653
00657
00658 int combined_data_conflict_table_index_lookup( int , int );
00659
00663
00664 int event_prediction_table_index_lookup( int , int );
00665
00669
00670 int prediction_time_advance_table_index_lookup( int);
00671
00675
00676 bool conflict_between_two_segs(
00677 int ,
00678 int ,
00679 int ,
00680 int ,
00681 sc_timestamp ,
00682 sc_timestamp );
00683
00687
00688 bool conflict_between_with_prediction( sc_process_b*, sc_process_b* );
00689
00693
00694 void add_to_wait_queue( sc_process_b*) ;
00695 void remove_from_wait_queue(sc_process_b*) ;
00696
00700
00701 bool conflict_between( sc_process_b*, sc_process_b* );
00702
00706
00707 void update_oldest_time( sc_time& curr_time );
00708
00709
00710 private:
00711
00712 enum execution_phases {
00713 phase_initialize = 0,
00714 phase_evaluate,
00715 phase_update,
00716 phase_notify
00717 };
00718 sc_object_manager* m_object_manager;
00719
00720 sc_module_registry* m_module_registry;
00721 sc_port_registry* m_port_registry;
00722 sc_export_registry* m_export_registry;
00723 sc_prim_channel_registry* m_prim_channel_registry;
00724 sc_phase_callback_registry* m_phase_cb_registry;
00725
00726 sc_name_gen* m_name_gen;
00727
00728 sc_process_table* m_process_table;
00729
00730
00731
00732
00733 std::list<sc_process_b*> m_curr_proc_queue;
00734
00735
00736
00737
00738
00739
00740
00741 bool m_write_check;
00742 int m_next_proc_id;
00743
00744 std::vector<sc_thread_handle> m_active_invokers;
00745
00746 std::vector<sc_event*> m_child_events;
00747 std::vector<sc_object*> m_child_objects;
00748
00749 std::vector<sc_event*> m_delta_events;
00750 sc_ppq<sc_event_timed*>* m_timed_events;
00751
00752 std::vector<sc_trace_file*> m_trace_files;
00753 bool m_something_to_trace;
00754
00755 sc_runnable* m_runnable;
00756 sc_process_list* m_collectable;
00757
00758 sc_time_params* m_time_params;
00759
00760
00761
00762
00763 mutable sc_time m_max_time;
00764
00765 sc_invoke_method* m_method_invoker_p;
00766 sc_dt::uint64 m_change_stamp;
00767
00768
00769
00770
00771 bool m_forced_stop;
00772 bool m_paused;
00773 bool m_ready_to_simulate;
00774 bool m_elaboration_done;
00775 execution_phases m_execution_phase;
00776 sc_report* m_error;
00777 bool m_in_simulator_control;
00778 bool m_end_of_simulation_called;
00779 sc_status m_simulation_status;
00780 bool m_start_of_simulation_called;
00781
00782 sc_cor_pkg* m_cor_pkg;
00783 sc_cor* m_cor;
00784
00785
00786
00787 bool m_one_delta_cycle;
00788 bool m_one_timed_cycle;
00789 sc_time m_finish_time;
00790
00791
00792 std::list<sc_process_b*> m_all_proc;
00793
00794 sc_time m_oldest_time;
00795 int last_seg_id;
00796 long* workload_table;
00797
00798 long* visits;
00799
00800 long old_sys_time;
00801
00802 std::list<sc_process_b*> m_waiting_proc_queue;
00803
00804 private:
00805
00806
00807 sc_simcontext( const sc_simcontext& );
00808 sc_simcontext& operator = ( const sc_simcontext& );
00809
00810 public:
00811 std::list<sc_thread_handle> m_synch_thread_queue;
00812 };
00813
00814
00815
00816
00817
00818 #if 1
00819 extern sc_simcontext* sc_curr_simcontext;
00820 extern sc_simcontext* sc_default_global_context;
00821
00822 inline sc_simcontext*
00823 sc_get_curr_simcontext()
00824 {
00825 if( sc_curr_simcontext == 0 ) {
00826 sc_default_global_context = new sc_simcontext;
00827 sc_curr_simcontext = sc_default_global_context;
00828 }
00829 return sc_curr_simcontext;
00830 }
00831 #else
00832 extern sc_simcontext* sc_get_curr_simcontext();
00833 #endif // 0
00834 inline sc_status sc_get_status()
00835 {
00836 return sc_get_curr_simcontext()->get_status();
00837 }
00838
00839
00840
00841
00842 inline
00843 bool
00844 sc_simcontext::elaboration_done() const
00845 {
00846 return m_elaboration_done;
00847 }
00848
00849
00850 inline sc_status sc_simcontext::get_status() const
00851 {
00852 return m_simulation_status != SC_RUNNING ?
00853 m_simulation_status :
00854 (m_in_simulator_control ? SC_RUNNING : SC_PAUSED);
00855 }
00856
00857 inline
00858 int
00859 sc_simcontext::sim_status() const
00860 {
00861 if( m_error ) {
00862 return SC_SIM_ERROR;
00863 }
00864 if( m_forced_stop ) {
00865 return SC_SIM_USER_STOP;
00866 }
00867 return SC_SIM_OK;
00868 }
00869
00870
00871 inline
00872 sc_object_manager*
00873 sc_simcontext::get_object_manager()
00874 {
00875 return m_object_manager;
00876 }
00877
00878 inline
00879 sc_module_registry*
00880 sc_simcontext::get_module_registry()
00881 {
00882 return m_module_registry;
00883 }
00884
00885 inline
00886 sc_port_registry*
00887 sc_simcontext::get_port_registry()
00888 {
00889 return m_port_registry;
00890 }
00891
00892 inline
00893 sc_export_registry*
00894 sc_simcontext::get_export_registry()
00895 {
00896 return m_export_registry;
00897 }
00898
00899 inline
00900 sc_prim_channel_registry*
00901 sc_simcontext::get_prim_channel_registry()
00902 {
00903 return m_prim_channel_registry;
00904 }
00905
00906
00907 inline
00908 int
00909 sc_simcontext::next_proc_id()
00910 {
00911 return ( ++ m_next_proc_id );
00912 }
00913
00914
00915 inline
00916 const sc_time&
00917 sc_simcontext::max_time() const
00918 {
00919 if ( m_max_time == SC_ZERO_TIME )
00920 {
00921 m_max_time = sc_time::from_value( ~sc_dt::UINT64_ZERO );
00922 }
00923 return m_max_time;
00924 }
00925
00926 inline
00927 sc_dt::uint64
00928 sc_simcontext::change_stamp() const
00929 {
00930 return m_change_stamp;
00931 }
00932
00933
00934
00935 inline
00936 bool
00937 sc_simcontext::event_occurred(sc_dt::uint64 last_change_stamp) const
00938 {
00939 return m_change_stamp == last_change_stamp;
00940 }
00941
00942 inline
00943 bool
00944 sc_simcontext::evaluation_phase() const
00945 {
00946 return (m_execution_phase == phase_evaluate) &&
00947 m_ready_to_simulate;
00948 }
00949
00950 inline
00951 bool
00952 sc_simcontext::update_phase() const
00953 {
00954 return m_execution_phase == phase_update;
00955 }
00956
00957 inline
00958 bool
00959 sc_simcontext::notify_phase() const
00960 {
00961 return m_execution_phase == phase_notify;
00962 }
00963
00964 inline
00965 void
00966 sc_simcontext::set_error( sc_report* err )
00967 {
00968 delete m_error;
00969 m_error = err;
00970 }
00971
00972
00973 inline
00974 bool
00975 sc_simcontext::get_error()
00976 {
00977 return m_error != NULL;
00978 }
00979
00980 inline
00981 int
00982 sc_simcontext::add_delta_event( sc_event* e )
00983 {
00984 m_delta_events.push_back( e );
00985 return ( m_delta_events.size() - 1 );
00986 }
00987
00988 inline
00989 void
00990 sc_simcontext::add_timed_event( sc_event_timed* et )
00991 {
00992 m_timed_events->insert( et );
00993 }
00994
00995 inline sc_object*
00996 sc_simcontext::get_current_writer() const
00997 {
00998
00999 return m_write_check ? get_curr_proc() : (sc_object*)0;
01000 }
01001
01002 inline bool
01003 sc_simcontext::write_check() const
01004 {
01005 return m_write_check;
01006 }
01007
01008 inline void
01009 sc_simcontext::remove_running_process( sc_process_b* proc )
01010 {
01011 m_curr_proc_queue.remove( proc );
01012 }
01013
01014 inline bool
01015 sc_simcontext::is_running_process( sc_process_b* proc )
01016 {
01017 for ( std::list<sc_process_b*>::iterator it = m_curr_proc_queue.begin();
01018 it != m_curr_proc_queue.end(); it++ )
01019 if ( *it == proc )
01020 return true;
01021 return false;
01022 }
01023
01024
01025
01026
01027 class sc_process_handle;
01028 sc_process_handle sc_get_current_process_handle();
01029
01030
01031
01032
01033
01034
01035
01036 inline sc_object*
01037 sc_get_current_object()
01038 {
01039 return sc_get_curr_simcontext()->active_object();
01040 }
01041
01042 inline
01043 sc_process_b*
01044 sc_get_current_process_b()
01045 {
01046 return sc_get_curr_simcontext()->get_curr_proc();
01047 }
01048
01049
01050 extern sc_process_b* sc_get_curr_process_handle();
01051
01052 inline
01053 sc_curr_proc_kind
01054 sc_get_curr_process_kind()
01055 {
01056 return sc_get_curr_simcontext()->get_curr_proc()->proc_kind();
01057 }
01058
01059
01060 inline int sc_get_simulator_status()
01061 {
01062 return sc_get_curr_simcontext()->sim_status();
01063 }
01064
01065
01066
01067 extern
01068 const char*
01069 sc_gen_unique_name( const char* basename_, bool preserve_first = false );
01070
01071
01072
01073 extern
01074 void
01075 sc_set_random_seed( unsigned int seed_ );
01076
01077
01078 extern void sc_initialize();
01079
01080 extern const sc_time& sc_max_time();
01081 extern const sc_time& sc_time_stamp();
01082 extern double sc_simulation_time();
01083
01084 inline
01085 const std::vector<sc_event*>& sc_get_top_level_events(
01086 const sc_simcontext* simc_p = sc_get_curr_simcontext() )
01087 {
01088 return simc_p->m_child_events;
01089 }
01090
01091 inline
01092 const std::vector<sc_object*>& sc_get_top_level_objects(
01093 const sc_simcontext* simc_p = sc_get_curr_simcontext() )
01094 {
01095 return simc_p->m_child_objects;
01096 }
01097
01098 extern sc_event* sc_find_event( const char* name );
01099
01100 extern sc_object* sc_find_object( const char* name );
01101
01105 inline
01106 sc_dt::uint64 sc_delta_count()
01107 {
01108
01109
01110
01111 sc_process_b* proc = sc_get_current_process_b();
01112
01113 if ( proc )
01114 return proc->get_timestamp().get_delta_count();
01115 else
01116 return 0;
01117 }
01118
01119 inline
01120 bool sc_is_running( const sc_simcontext* simc_p = sc_get_curr_simcontext() )
01121 {
01122 return simc_p->m_ready_to_simulate;
01123 }
01124
01125 bool sc_is_unwinding();
01126
01127 inline void sc_pause()
01128 {
01129 sc_get_curr_simcontext()->m_paused = true;
01130 }
01131
01132
01133
01134 inline bool sc_pending_activity_at_current_time
01135 ( const sc_simcontext* simc_p = sc_get_curr_simcontext() )
01136 {
01137 return simc_p->pending_activity_at_current_time();
01138 }
01139
01140
01141
01142 inline bool sc_pending_activity_at_future_time
01143 ( const sc_simcontext* simc_p = sc_get_curr_simcontext() )
01144 {
01145 sc_time ignored;
01146 return simc_p->next_time( ignored );
01147 }
01148
01149
01150
01151
01152 inline bool sc_pending_activity
01153 ( const sc_simcontext* simc_p = sc_get_curr_simcontext() )
01154 {
01155 return sc_pending_activity_at_current_time( simc_p )
01156 || sc_pending_activity_at_future_time( simc_p );
01157 }
01158
01159 sc_time
01160 sc_time_to_pending_activity
01161 ( const sc_simcontext* simc_p = sc_get_curr_simcontext() );
01162
01163
01164 inline
01165 bool
01166 sc_end_of_simulation_invoked()
01167 {
01168 return sc_get_curr_simcontext()->m_end_of_simulation_called;
01169 }
01170
01171 inline bool sc_hierarchical_name_exists( const char* name )
01172 {
01173 return sc_find_object(name) || sc_find_event(name);
01174 }
01175
01176 inline
01177 bool
01178 sc_start_of_simulation_invoked()
01179 {
01180 return sc_get_curr_simcontext()->m_start_of_simulation_called;
01181 }
01182
01183
01184
01185
01186
01187 extern bool sc_allow_process_control_corners;
01188
01189 }
01190
01191
01192
01193
01194
01195
01196
01197
01198
01199
01200
01201
01202
01203
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222
01223
01224
01225
01226
01227
01228
01229
01230
01231
01232
01233
01234
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247
01248
01249
01250
01251
01252
01253
01254
01255
01256
01257
01258
01259
01260
01261
01262
01263
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274
01275
01276
01277
01278
01279
01280
01281
01282
01283
01284
01285
01286
01287
01288
01289
01290
01291
01292
01293
01294
01295
01296
01297
01298
01299
01300
01301
01302
01303
01304
01305
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319
01320
01321
01322
01323
01324
01325
01326
01327
01328
01329
01330
01331
01332
01333
01334
01335
01336
01337
01338
01339
01340
01341
01342
01343
01344
01345
01346
01347
01348
01349
01350
01351
01352
01353
01354
01355
01356
01357
01358
01359 #endif