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