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_segid{
00292 public:
00293 int seg_id;
00294 inline explicit sc_segid(int val):
00295 seg_id(val)
00296 {}
00297 };
00298
00299
00305 class sc_simcontext
00306 {
00307 friend struct sc_invoke_method;
00308 friend class sc_event;
00309 friend class sc_module;
00310
00311
00312 friend class sc_channel;
00313
00314 friend class sc_object;
00315 friend class sc_time;
00316 friend class sc_clock;
00317 friend class sc_method_process;
00318 friend class sc_phase_callback_registry;
00319 friend class sc_process_b;
00320 friend class sc_process_handle;
00321 friend class sc_prim_channel;
00322 friend class sc_cthread_process;
00323 friend class sc_thread_process;
00324 friend class sc_runnable;
00325 friend sc_dt::uint64 sc_delta_count();
00326 friend const std::vector<sc_event*>& sc_get_top_level_events(
00327 const sc_simcontext* simc_p);
00328 friend const std::vector<sc_object*>& sc_get_top_level_objects(
00329 const sc_simcontext* simc_p);
00330 friend bool sc_is_running( const sc_simcontext* simc_p );
00331 friend void sc_pause();
00332 friend bool sc_end_of_simulation_invoked();
00333 friend void sc_start( const sc_time&, sc_starvation_policy );
00334 friend bool sc_start_of_simulation_invoked();
00335 friend void sc_thread_cor_fn(void*);
00336 friend sc_time sc_time_to_pending_activity( const sc_simcontext* );
00337 friend bool sc_pending_activity_at_current_time( const sc_simcontext* );
00338 friend bool sc_pending_activity_at_future_time( const sc_simcontext* );
00339
00340
00341 friend struct sc_kernel_lock;
00342
00343
00344 friend sc_cor* get_cor_pointer( sc_process_b* process_p );
00345
00346
00347 void init();
00348 void clean();
00349 void display_all_delta_events();
00350 void display_all_process_states();
00351 public:
00352
00353 sc_simcontext();
00354 ~sc_simcontext();
00355
00356 void initialize( bool = false );
00357
00362
00363 void cycle( const sc_time& );
00364
00365 void simulate( const sc_time& duration );
00366 void stop();
00367 void end();
00368 void reset();
00369 void print_ready_threads();
00370 void print_all_threads();
00371 void print_events();
00372
00373
00374
00375
00381
00382
00383
00387
00388 void oooschedule( sc_cor *cor );
00389
00390 int sim_status() const;
00391 bool elaboration_done() const;
00392
00393 std::vector<sc_thread_handle>& get_active_invokers();
00394
00395 sc_object_manager* get_object_manager();
00396
00397 inline sc_status get_status() const;
00398
00399 sc_object* active_object();
00400
00401 void hierarchy_push( sc_module* );
00402 sc_module* hierarchy_pop();
00403 sc_module* hierarchy_curr() const;
00404 sc_object* first_object();
00405 sc_object* next_object();
00406 sc_object* find_object( const char* name );
00407
00408 sc_module_registry* get_module_registry();
00409 sc_port_registry* get_port_registry();
00410 sc_export_registry* get_export_registry();
00411 sc_prim_channel_registry* get_prim_channel_registry();
00412
00413
00414 const char* gen_unique_name( const char* basename_,
00415 bool preserve_first = false
00416 );
00417
00418
00419
00424
00425
00426 sc_process_handle create_cthread_process(
00427 const char* name_p, bool free_host, SC_ENTRY_FUNC method_p,
00428 sc_process_host* host_p, const sc_spawn_options* opt_p,
00429 int seg_id, int inst_id );
00430
00435
00436
00437 sc_process_handle create_method_process(
00438 const char* name_p, bool free_host, SC_ENTRY_FUNC method_p,
00439 sc_process_host* host_p, const sc_spawn_options* opt_p,
00440 int seg_id, int inst_id );
00441
00446
00447
00448 sc_process_handle create_thread_process(
00449 const char* name_p, bool free_host, SC_ENTRY_FUNC method_p,
00450 sc_process_host* host_p, const sc_spawn_options* opt_p,
00451 int seg_id, int inst_id );
00452
00453
00454
00455
00456 sc_process_b* get_curr_proc() const;
00457 sc_object* get_current_writer() const;
00458 bool write_check() const;
00459
00464
00465 void set_curr_proc( sc_process_b* );
00466
00467 void reset_curr_proc();
00468
00469 int next_proc_id();
00470
00471 void add_trace_file( sc_trace_file* );
00472 void remove_trace_file( sc_trace_file* );
00473
00474 friend void sc_set_time_resolution( double, sc_time_unit );
00475 friend sc_time sc_get_time_resolution();
00476 friend void sc_set_default_time_unit( double, sc_time_unit );
00477 friend sc_time sc_get_default_time_unit();
00478
00479 const sc_time& max_time() const;
00480
00481
00482 const sc_time& time_stamp();
00483
00484 sc_dt::uint64 change_stamp() const;
00485
00486
00487 sc_dt::uint64 delta_count() const;
00488
00489 bool event_occurred( sc_dt::uint64 last_change_count ) const;
00490 bool evaluation_phase() const;
00491 bool is_running() const;
00492 bool update_phase() const;
00493 bool notify_phase() const;
00494 bool get_error();
00495 void set_error( sc_report* );
00496
00497 sc_cor_pkg* cor_pkg()
00498 { return m_cor_pkg; }
00499 sc_cor* next_cor();
00500
00501 const ::std::vector<sc_object*>& get_child_objects() const;
00502
00503 void elaborate();
00504 void prepare_to_simulate();
00505
00510
00511 inline void initial_crunch( bool no_crunch );
00512
00513 bool next_time( sc_time& t ) const;
00514 bool pending_activity_at_current_time() const;
00515
00519
00520 void remove_running_process( sc_process_b* );
00521
00525
00526 bool is_running_process( sc_process_b* );
00527
00531
00532 void suspend_cor( sc_cor* );
00533
00537
00538 void resume_cor( sc_cor* );
00539
00543
00544 bool is_locked();
00545
00549
00550 bool is_unlocked();
00551
00556
00557 bool is_lock_owner();
00558
00563
00564 bool is_not_owner();
00565
00570
00571 bool is_locked_and_owner();
00572
00577
00578 unsigned int conflict_table_index_lookup( int, int );
00579
00583
00584 unsigned int time_adv_table_index_lookup( int );
00585
00586 private:
00587
00588 void add_child_event( sc_event* );
00589 void add_child_object( sc_object* );
00590 void remove_child_event( sc_event* );
00591 void remove_child_object( sc_object* );
00592
00593
00594
00595 int add_delta_event( sc_event* );
00596 void remove_delta_event( sc_event* );
00597 void add_timed_event( sc_event_timed* );
00598
00599 void trace_cycle( bool delta_cycle );
00600
00601 const ::std::vector<sc_event*>& get_child_events_internal() const;
00602 const ::std::vector<sc_object*>& get_child_objects_internal() const;
00603
00604 void execute_method_next( sc_method_handle );
00605 void execute_thread_next( sc_thread_handle );
00606
00607 sc_method_handle pop_runnable_method();
00608 sc_thread_handle pop_runnable_thread();
00609
00614
00615 void preempt_with( sc_method_handle );
00616
00621
00622 inline void preempt_with( sc_thread_handle );
00623
00624 void push_runnable_method( sc_method_handle );
00625 void push_runnable_thread( sc_thread_handle );
00626
00627 void push_runnable_method_front( sc_method_handle );
00628 void push_runnable_thread_front( sc_thread_handle );
00629
00630 void remove_runnable_method( sc_method_handle );
00631 void remove_runnable_thread( sc_thread_handle );
00632
00633 void requeue_current_process();
00634 void suspend_current_process();
00635
00636 void do_sc_stop_action();
00637 void mark_to_collect_process( sc_process_b* zombie_p );
00638
00642
00643 void acquire_sched_mutex();
00644
00648
00649 void release_sched_mutex();
00650
00654
00655 bool has_no_conflicts( sc_process_b*, std::list<sc_method_handle>, std::list<sc_thread_handle> );
00656
00660
00661
00662
00666
00667
00668
00672
00673 int combined_data_conflict_table_index_lookup( int , int );
00674
00678
00679 int event_prediction_table_index_lookup( int , int );
00680
00684
00685 int prediction_time_advance_table_index_lookup( int);
00686
00690
00691 bool conflict_between_two_segs(
00692 int ,
00693 int ,
00694 int ,
00695 int ,
00696 sc_timestamp ,
00697 sc_timestamp );
00698
00702
00703 bool conflict_between_with_prediction( sc_process_b*, sc_process_b* );
00704
00708
00709 void add_to_wait_queue( sc_process_b*) ;
00710 void remove_from_wait_queue(sc_process_b*) ;
00711
00715
00716 bool conflict_between( sc_process_b*, sc_process_b* );
00717
00721
00722 void update_oldest_time( sc_time& curr_time );
00723
00724
00725 private:
00726
00727 enum execution_phases {
00728 phase_initialize = 0,
00729 phase_evaluate,
00730 phase_update,
00731 phase_notify
00732 };
00733 sc_object_manager* m_object_manager;
00734
00735 sc_module_registry* m_module_registry;
00736 sc_port_registry* m_port_registry;
00737 sc_export_registry* m_export_registry;
00738 sc_prim_channel_registry* m_prim_channel_registry;
00739 sc_phase_callback_registry* m_phase_cb_registry;
00740
00741 sc_name_gen* m_name_gen;
00742
00743 sc_process_table* m_process_table;
00744
00745
00746
00747
00748 std::list<sc_process_b*> m_curr_proc_queue;
00749
00750
00751
00752
00753
00754
00755
00756 bool m_write_check;
00757 int m_next_proc_id;
00758
00759 std::vector<sc_thread_handle> m_active_invokers;
00760
00761 std::vector<sc_event*> m_child_events;
00762 std::vector<sc_object*> m_child_objects;
00763
00764 std::vector<sc_event*> m_delta_events;
00765 sc_ppq<sc_event_timed*>* m_timed_events;
00766
00767 std::vector<sc_trace_file*> m_trace_files;
00768 bool m_something_to_trace;
00769
00770 sc_runnable* m_runnable;
00771 sc_process_list* m_collectable;
00772
00773 sc_time_params* m_time_params;
00774
00775
00776
00777
00778 mutable sc_time m_max_time;
00779
00780 sc_invoke_method* m_method_invoker_p;
00781 sc_dt::uint64 m_change_stamp;
00782
00783
00784
00785
00786 bool m_forced_stop;
00787 bool m_paused;
00788 bool m_ready_to_simulate;
00789 bool m_elaboration_done;
00790 execution_phases m_execution_phase;
00791 sc_report* m_error;
00792 bool m_in_simulator_control;
00793 bool m_end_of_simulation_called;
00794 sc_status m_simulation_status;
00795 bool m_start_of_simulation_called;
00796
00797 sc_cor_pkg* m_cor_pkg;
00798 sc_cor* m_cor;
00799
00800
00801
00802 bool m_one_delta_cycle;
00803 bool m_one_timed_cycle;
00804 sc_time m_finish_time;
00805
00806
00807
00808
00809 int last_seg_id;
00810 long* workload_table;
00811
00812 long* visits;
00813
00814 long old_sys_time;
00815
00816 std::list<sc_process_b*> m_waiting_proc_queue;
00817
00818 private:
00819
00820
00821 sc_simcontext( const sc_simcontext& );
00822 sc_simcontext& operator = ( const sc_simcontext& );
00823
00824 public:
00825 std::list<sc_thread_handle> m_synch_thread_queue;
00826
00827 std::list<sc_process_b*> m_all_proc;
00828
00829 private:
00830 sc_time oldest_untraced_time;
00831
00832
00833 std::vector<sc_process_b*> m_paused_processes;
00834
00835
00836 public:
00837 const sc_time& get_oldest_untraced_time();
00838 sc_time m_oldest_time;
00839 sc_timestamp m_simulation_duration;
00840 bool m_is_first_simulation;
00841 sc_starvation_policy m_starvation_policy;
00842
00843
00844 };
00845
00846
00847
00848
00849
00850 #if 1
00851 extern sc_simcontext* sc_curr_simcontext;
00852 extern sc_simcontext* sc_default_global_context;
00853
00854 inline sc_simcontext*
00855 sc_get_curr_simcontext()
00856 {
00857 if( sc_curr_simcontext == 0 ) {
00858 sc_default_global_context = new sc_simcontext;
00859 sc_curr_simcontext = sc_default_global_context;
00860 }
00861 return sc_curr_simcontext;
00862 }
00863 #else
00864 extern sc_simcontext* sc_get_curr_simcontext();
00865 #endif // 0
00866 inline sc_status sc_get_status()
00867 {
00868 return sc_get_curr_simcontext()->get_status();
00869 }
00870
00871
00872
00873
00874 inline
00875 bool
00876 sc_simcontext::elaboration_done() const
00877 {
00878 return m_elaboration_done;
00879 }
00880
00881
00882 inline sc_status sc_simcontext::get_status() const
00883 {
00884 return m_simulation_status != SC_RUNNING ?
00885 m_simulation_status :
00886 (m_in_simulator_control ? SC_RUNNING : SC_PAUSED);
00887 }
00888
00889 inline
00890 int
00891 sc_simcontext::sim_status() const
00892 {
00893 if( m_error ) {
00894 return SC_SIM_ERROR;
00895 }
00896 if( m_forced_stop ) {
00897 return SC_SIM_USER_STOP;
00898 }
00899 return SC_SIM_OK;
00900 }
00901
00902
00903 inline
00904 sc_object_manager*
00905 sc_simcontext::get_object_manager()
00906 {
00907 return m_object_manager;
00908 }
00909
00910 inline
00911 sc_module_registry*
00912 sc_simcontext::get_module_registry()
00913 {
00914 return m_module_registry;
00915 }
00916
00917 inline
00918 sc_port_registry*
00919 sc_simcontext::get_port_registry()
00920 {
00921 return m_port_registry;
00922 }
00923
00924 inline
00925 sc_export_registry*
00926 sc_simcontext::get_export_registry()
00927 {
00928 return m_export_registry;
00929 }
00930
00931 inline
00932 sc_prim_channel_registry*
00933 sc_simcontext::get_prim_channel_registry()
00934 {
00935 return m_prim_channel_registry;
00936 }
00937
00938
00939 inline
00940 int
00941 sc_simcontext::next_proc_id()
00942 {
00943 return ( ++ m_next_proc_id );
00944 }
00945
00946
00947 inline
00948 const sc_time&
00949 sc_simcontext::max_time() const
00950 {
00951 if ( m_max_time == SC_ZERO_TIME )
00952 {
00953 m_max_time = sc_time::from_value( ~sc_dt::UINT64_ZERO );
00954 }
00955 return m_max_time;
00956 }
00957
00958 inline
00959 sc_dt::uint64
00960 sc_simcontext::change_stamp() const
00961 {
00962 return m_change_stamp;
00963 }
00964
00965
00966
00967 inline
00968 bool
00969 sc_simcontext::event_occurred(sc_dt::uint64 last_change_stamp) const
00970 {
00971 return m_change_stamp == last_change_stamp;
00972 }
00973
00974 inline
00975 bool
00976 sc_simcontext::evaluation_phase() const
00977 {
00978 return (m_execution_phase == phase_evaluate) &&
00979 m_ready_to_simulate;
00980 }
00981
00982 inline
00983 bool
00984 sc_simcontext::update_phase() const
00985 {
00986 return m_execution_phase == phase_update;
00987 }
00988
00989 inline
00990 bool
00991 sc_simcontext::notify_phase() const
00992 {
00993 return m_execution_phase == phase_notify;
00994 }
00995
00996 inline
00997 void
00998 sc_simcontext::set_error( sc_report* err )
00999 {
01000 delete m_error;
01001 m_error = err;
01002 }
01003
01004
01005 inline
01006 bool
01007 sc_simcontext::get_error()
01008 {
01009 return m_error != NULL;
01010 }
01011
01012 inline
01013 int
01014 sc_simcontext::add_delta_event( sc_event* e )
01015 {
01016 m_delta_events.push_back( e );
01017 return ( m_delta_events.size() - 1 );
01018 }
01019
01020 inline
01021 void
01022 sc_simcontext::add_timed_event( sc_event_timed* et )
01023 {
01024 m_timed_events->insert( et );
01025 }
01026
01027 inline sc_object*
01028 sc_simcontext::get_current_writer() const
01029 {
01030
01031 return m_write_check ? get_curr_proc() : (sc_object*)0;
01032 }
01033
01034 inline bool
01035 sc_simcontext::write_check() const
01036 {
01037 return m_write_check;
01038 }
01039
01040 inline void
01041 sc_simcontext::remove_running_process( sc_process_b* proc )
01042 {
01043 m_curr_proc_queue.remove( proc );
01044 }
01045
01046 inline bool
01047 sc_simcontext::is_running_process( sc_process_b* proc )
01048 {
01049 for ( std::list<sc_process_b*>::iterator it = m_curr_proc_queue.begin();
01050 it != m_curr_proc_queue.end(); it++ )
01051 if ( *it == proc )
01052 return true;
01053 return false;
01054 }
01055
01056
01057
01058
01059 class sc_process_handle;
01060 sc_process_handle sc_get_current_process_handle();
01061
01062
01063
01064
01065
01066
01067
01068 inline sc_object*
01069 sc_get_current_object()
01070 {
01071 return sc_get_curr_simcontext()->active_object();
01072 }
01073
01074 inline
01075 sc_process_b*
01076 sc_get_current_process_b()
01077 {
01078 return sc_get_curr_simcontext()->get_curr_proc();
01079 }
01080
01081
01082 extern sc_process_b* sc_get_curr_process_handle();
01083
01084 inline
01085 sc_curr_proc_kind
01086 sc_get_curr_process_kind()
01087 {
01088 return sc_get_curr_simcontext()->get_curr_proc()->proc_kind();
01089 }
01090
01091
01092 inline int sc_get_simulator_status()
01093 {
01094 return sc_get_curr_simcontext()->sim_status();
01095 }
01096
01097
01098
01099 extern
01100 const char*
01101 sc_gen_unique_name( const char* basename_, bool preserve_first = false );
01102
01103
01104
01105 extern
01106 void
01107 sc_set_random_seed( unsigned int seed_ );
01108
01109
01110 extern void sc_initialize();
01111
01112 extern const sc_time& sc_max_time();
01113 extern const sc_time& sc_time_stamp();
01114 extern double sc_simulation_time();
01115
01116 extern const sc_time& get_current_trace_time();
01117
01118 inline
01119 const std::vector<sc_event*>& sc_get_top_level_events(
01120 const sc_simcontext* simc_p = sc_get_curr_simcontext() )
01121 {
01122 return simc_p->m_child_events;
01123 }
01124
01125 inline
01126 const std::vector<sc_object*>& sc_get_top_level_objects(
01127 const sc_simcontext* simc_p = sc_get_curr_simcontext() )
01128 {
01129 return simc_p->m_child_objects;
01130 }
01131
01132 extern sc_event* sc_find_event( const char* name );
01133
01134 extern sc_object* sc_find_object( const char* name );
01135
01139 inline
01140 sc_dt::uint64 sc_delta_count()
01141 {
01142
01143
01144
01145 sc_process_b* proc = sc_get_current_process_b();
01146
01147 if ( proc )
01148 return proc->get_timestamp().get_delta_count();
01149 else
01150 return 0;
01151 }
01152
01153 inline
01154 bool sc_is_running( const sc_simcontext* simc_p = sc_get_curr_simcontext() )
01155 {
01156 return simc_p->m_ready_to_simulate;
01157 }
01158
01159 bool sc_is_unwinding();
01160
01161 inline void sc_pause()
01162 {
01163 sc_get_curr_simcontext()->m_paused = true;
01164 }
01165
01166
01167
01168 inline bool sc_pending_activity_at_current_time
01169 ( const sc_simcontext* simc_p = sc_get_curr_simcontext() )
01170 {
01171 return simc_p->pending_activity_at_current_time();
01172 }
01173
01174
01175
01176 inline bool sc_pending_activity_at_future_time
01177 ( const sc_simcontext* simc_p = sc_get_curr_simcontext() )
01178 {
01179 sc_time ignored;
01180 return simc_p->next_time( ignored );
01181 }
01182
01183
01184
01185
01186 inline bool sc_pending_activity
01187 ( const sc_simcontext* simc_p = sc_get_curr_simcontext() )
01188 {
01189 return sc_pending_activity_at_current_time( simc_p )
01190 || sc_pending_activity_at_future_time( simc_p );
01191 }
01192
01193 sc_time
01194 sc_time_to_pending_activity
01195 ( const sc_simcontext* simc_p = sc_get_curr_simcontext() );
01196
01197
01198 inline
01199 bool
01200 sc_end_of_simulation_invoked()
01201 {
01202 return sc_get_curr_simcontext()->m_end_of_simulation_called;
01203 }
01204
01205 inline bool sc_hierarchical_name_exists( const char* name )
01206 {
01207 return sc_find_object(name) || sc_find_event(name);
01208 }
01209
01210 inline
01211 bool
01212 sc_start_of_simulation_invoked()
01213 {
01214 return sc_get_curr_simcontext()->m_start_of_simulation_called;
01215 }
01216
01217
01218
01219
01220
01221 extern bool sc_allow_process_control_corners;
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
01360
01361
01362
01363
01364
01365
01366
01367
01368
01369
01370
01371
01372
01373
01374
01375
01376
01377
01378
01379
01380
01381
01382
01383
01384
01385
01386
01387
01388
01389
01390
01391
01392
01393 #endif