SystemC 3.0.0
Accellera SystemC proof-of-concept library
sc_simcontext.h
Go to the documentation of this file.
1/*****************************************************************************
2
3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4 more contributor license agreements. See the NOTICE file distributed
5 with this work for additional information regarding copyright ownership.
6 Accellera licenses this file to you under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with the
8 License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15 implied. See the License for the specific language governing
16 permissions and limitations under the License.
17
18 *****************************************************************************/
19
20/*****************************************************************************
21
22 sc_simcontext.h -- Definition of the simulation context class.
23
24 Original Author: Stan Y. Liao, Synopsys, Inc.
25 Martin Janssen, Synopsys, Inc.
26
27 CHANGE LOG AT THE END OF THE FILE
28 *****************************************************************************/
29
30#ifndef SC_SIMCONTEXT_H
31#define SC_SIMCONTEXT_H
32
36#include "sysc/kernel/sc_time.h"
38#include "sysc/utils/sc_hash.h"
39#include "sysc/utils/sc_pq.h"
40
42
43#if defined(_MSC_VER) && !defined(SC_WIN_DLL_WARN)
44#pragma warning(push)
45#pragma warning(disable: 4251) // DLL import for std::vector
46#endif
47
48namespace sc_core {
49
50// forward declarations
51
52class sc_cor;
53class sc_cor_pkg;
54class sc_event;
55class sc_event_timed;
56class sc_export_registry;
57class sc_hierarchy_scope;
58class sc_initializer_function;
59class sc_module;
60class sc_module_name;
61class sc_module_registry;
62class sc_name_gen;
63class sc_object;
64class sc_object_host;
65class sc_object_manager;
66class sc_stage_callback_registry;
67class sc_process_handle;
68class sc_port_registry;
69class sc_prim_channel_registry;
70class sc_process_table;
71class sc_signal_bool_deval;
72class sc_trace_file;
73class sc_runnable;
74class sc_process_host;
75class sc_method_process;
76class sc_cthread_process;
77class sc_thread_process;
78class sc_reset_finder;
79class sc_stub_registry;
80
82
83template< typename > class sc_plist;
85
87{
90 sc_curr_proc_info() : process_handle( 0 ), kind( SC_NO_PROC_ ) {}
91};
92
94
95enum sc_stop_mode { // sc_stop modes:
98};
101
103{
107extern SC_API void sc_start();
108extern SC_API void sc_start( const sc_time& duration,
110inline void sc_start( int duration, sc_time_unit unit,
112{
113 sc_start( sc_time((double)duration,unit), p );
114}
115
116inline void sc_start( double duration, sc_time_unit unit,
118{
119 sc_start( sc_time(duration,unit), p );
120}
121
122extern SC_API void sc_stop();
123
124// friend function declarations
125
128SC_API const std::vector<sc_event*>& sc_get_top_level_events(
129 const sc_simcontext* simc_p);
130SC_API const std::vector<sc_object*>& sc_get_top_level_objects(
131 const sc_simcontext* simc_p);
132SC_API bool sc_is_running( const sc_simcontext* simc_p );
133SC_API void sc_pause();
144
146 unsigned int mask);
148 unsigned int mask);
149
150class sc_invoke_method;
151
156
157// ----------------------------------------------------------------------------
158// CLASS : sc_simcontext
159//
160// The simulation context.
161// ----------------------------------------------------------------------------
162
164{
165 friend class sc_event;
166 friend class sc_export_registry;
167 friend class sc_hierarchy_scope;
169 friend class sc_invoke_method;
170 friend class sc_module;
171 friend class sc_object;
172 friend class sc_object_host;
173 friend class sc_time;
174 friend class sc_time_tuple;
175 friend class sc_clock;
176 friend class sc_method_process;
178 friend class sc_port_registry;
179 friend class sc_process_b;
180 friend class sc_process_handle;
181 friend class sc_prim_channel;
182 friend class sc_cthread_process;
183 friend class sc_thread_process;
185 friend SC_API const std::vector<sc_event*>& sc_get_top_level_events(
186 const sc_simcontext* simc_p);
187 friend SC_API const std::vector<sc_object*>& sc_get_top_level_objects(
188 const sc_simcontext* simc_p);
189 friend SC_API bool sc_is_running( const sc_simcontext* simc_p );
190 friend SC_API void sc_pause();
194 friend void sc_thread_cor_fn(void*);
198 friend SC_API void sc_suspend_all();
201 friend SC_API void sc_suspendable();
202
204 unsigned int mask);
206 unsigned int mask);
207
208 enum sc_signal_write_check
209 {
210 SC_SIGNAL_WRITE_CHECK_DISABLE_ = 0x0, // no multiple writer checks
211 SC_SIGNAL_WRITE_CHECK_DEFAULT_ = 0x1, // default IEEE-1666 writer checks
212 SC_SIGNAL_WRITE_CHECK_CONFLICT_ = 0x2 // only check for conflicting writes
213 };
214
215
216 void init();
217 void clean();
218
219public:
220
223
224 void initialize( bool = false );
225 void cycle( const sc_time& );
226 void simulate( const sc_time& duration );
227 void stop();
228 void end();
229 void reset();
230
231 int sim_status() const;
232 bool elaboration_done() const;
233
234 std::vector<sc_thread_handle>& get_active_invokers();
235
236 sc_object_manager* get_object_manager();
237
238 inline sc_status get_status() const;
239
241
242 inline sc_stage get_stage() const;
243
245
248 sc_object* find_object( const char* name );
249
250 sc_module_registry* get_module_registry();
251 sc_port_registry* get_port_registry();
252 sc_export_registry* get_export_registry();
253 sc_prim_channel_registry* get_prim_channel_registry();
254 sc_stage_callback_registry* get_stage_cb_registry();
255 sc_stub_registry* get_stub_registry();
256
257 std::string construct_hierarchical_name(const sc_object* parent,
258 const std::string& name);
260 const std::string& name);
262 const std::string& name);
264 const std::string& name);
265 const char* get_hierarchical_name(const sc_object* parent,
266 const std::string& name);
267
268 // to generate unique names for objects in an MT-Safe way
269 const char* gen_unique_name( const char* basename_,
270 bool preserve_first = false
271 );
272
273 // process creation
275 const char* name_p, bool free_host, sc_entry_func method_p,
276 sc_process_host* host_p, const sc_spawn_options* opt_p );
277
279 const char* name_p, bool free_host, sc_entry_func method_p,
280 sc_process_host* host_p, const sc_spawn_options* opt_p );
281
283 const char* name_p, bool free_host, sc_entry_func method_p,
284 sc_process_host* host_p, const sc_spawn_options* opt_p );
285
286 sc_curr_proc_handle get_curr_proc_info();
287 sc_process_b* get_current_writer() const;
288 bool write_check() const;
289 bool write_check_conflicts_only() const;
290 void set_curr_proc( sc_process_b* );
291 void reset_curr_proc();
292
293 int next_proc_id();
294
299
300 const sc_time& max_time() const;
301 const sc_time& time_stamp() const;
302
303 sc_dt::uint64 change_stamp() const;
305 sc_dt::uint64 delta_count_at_current_time() const;
306 bool event_occurred( sc_dt::uint64 last_change_count ) const;
307 bool evaluation_phase() const;
308 bool is_running() const;
309 bool update_phase() const;
310 bool notify_phase() const;
311 bool get_error();
312 void set_error( sc_report* );
313
315 { return m_cor_pkg; }
317
319
320 const ::std::vector<sc_object*>& get_child_objects() const;
321
323
324 void elaborate();
326 inline void initial_crunch( bool no_crunch );
327 bool next_time( sc_time& t ) const;
329
330 void pre_suspend() const;
331 void post_suspend() const;
332
333private:
334 void hierarchy_push(sc_object_host*);
335 sc_object_host* hierarchy_pop();
336 sc_object_host* hierarchy_curr() const;
337
338 void add_child_event( sc_event* );
339 void add_child_object( sc_object* );
340 void remove_child_event( sc_event* );
341 void remove_child_object( sc_object* );
342
343 void crunch( bool once=false );
344
345 int add_delta_event( sc_event* );
346 void remove_delta_event( sc_event* );
347 void add_timed_event( sc_event_timed* );
348
349 void trace_cycle( bool delta_cycle );
350
351 void execute_method_next( sc_method_handle );
352 void execute_thread_next( sc_thread_handle );
353
354 sc_method_handle pop_runnable_method();
355 sc_thread_handle pop_runnable_thread();
356
357 void preempt_with( sc_method_handle );
358 inline void preempt_with( sc_thread_handle );
359
360 void push_runnable_method( sc_method_handle );
361 void push_runnable_thread( sc_thread_handle );
362
363 void push_runnable_method_front( sc_method_handle );
364 void push_runnable_thread_front( sc_thread_handle );
365
366 void remove_runnable_method( sc_method_handle );
367 void remove_runnable_thread( sc_thread_handle );
368
369 void requeue_current_process();
370 void suspend_current_process();
371
372 void do_sc_stop_action();
373 void do_timestep( const sc_time& );
374 void mark_to_collect_process( sc_process_b* zombie_p );
375 void do_collect_processes();
376
377 sc_method_handle remove_process( sc_method_handle );
378 sc_thread_handle remove_process( sc_thread_handle );
379
380 inline void set_simulation_status(sc_status status);
381
382private:
383
384 enum execution_phases {
385 phase_initialize = 0,
386 phase_evaluate,
387 phase_update,
388 phase_notify
389 };
390 sc_object_manager* m_object_manager;
391
392 sc_module_registry* m_module_registry;
393 sc_port_registry* m_port_registry;
394 sc_export_registry* m_export_registry;
395 sc_prim_channel_registry* m_prim_channel_registry;
396 sc_stage_callback_registry* m_stage_cb_registry;
397 sc_stub_registry* m_stub_registry;
398
399 sc_name_gen* m_name_gen;
400
401 sc_process_table* m_process_table;
402 sc_curr_proc_info m_curr_proc_info;
403 sc_process_b* m_current_writer;
404 sc_signal_write_check m_write_check;
405 int m_next_proc_id;
406
407 std::vector<sc_thread_handle> m_active_invokers;
408
409 std::vector<sc_event*> m_child_events;
410 std::vector<sc_object*> m_child_objects;
411
412 std::vector<sc_event*> m_delta_events;
413 sc_ppq<sc_event_timed*>* m_timed_events;
414
415 sc_event* m_null_event_p;
416
417 std::vector<sc_trace_file*> m_trace_files;
418 bool m_something_to_trace;
419
420 sc_runnable* m_runnable;
421 sc_process_list* m_collectable;
422
423 sc_time_params* m_time_params;
424 sc_time m_curr_time;
425 mutable sc_time m_max_time;
426
427 sc_invoke_method* m_method_invoker_p;
428 sc_dt::uint64 m_change_stamp; // "time" change occurred.
429 sc_dt::uint64 m_delta_count;
430 sc_dt::uint64 m_initial_delta_count_at_current_time;
431 bool m_forced_stop;
432 bool m_paused;
433 bool m_ready_to_simulate;
434 bool m_elaboration_done;
435 execution_phases m_execution_phase;
436 sc_report* m_error;
437 bool m_in_simulator_control;
438 bool m_end_of_simulation_called;
439 sc_status m_simulation_status;
440 sc_host_mutex m_simulation_status_mutex;
441 sc_stage m_stage;
442 bool m_start_of_simulation_called;
443
444 sc_cor_pkg* m_cor_pkg; // the simcontext's coroutine package
445 sc_cor* m_cor; // the simcontext's coroutine
446
447 sc_reset_finder* m_reset_finder_q; // Q of reset finders to reconcile.
448
449 int m_suspend;
450 int m_unsuspendable;
451
452private:
453
454 // disabled
456 sc_simcontext& operator = ( const sc_simcontext& );
457};
458
459// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
460
461// Not MT safe.
462
463#if 1
466
467inline sc_simcontext*
469{
470 if( sc_curr_simcontext == 0 ) {
473 }
474 return sc_curr_simcontext;
475}
476#else
478#endif // 0
479
480
481// +------------------------------------------------------------------------------------------------
482// |"sc_get_status"
483// |
484// | This method returns the current simulator status, and uses a mutex mechanism to guarantee
485// | thread safety. It may be called from pthreads other than the simulator's.
486// |
487// | Result:
488// | Current simulator status (see the sc_status enum).
489// +------------------------------------------------------------------------------------------------
491{
493}
494
495// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
496
497inline
498bool
500{
501 return m_elaboration_done;
502}
503
504
505// +------------------------------------------------------------------------------------------------
506// |"sc_simcontext::get_status"
507// |
508// | This method returns the current simulator status, but does not use a mutex mechanism. It is
509// | intended for use within the simulator's pthread.
510// |
511// | Notes:
512// | (1) To get the status from outside the simulator's thread the get_thread_safe_status()
513// | method should be used.
514// | Result:
515// | Current simulator status (see the sc_status enum).
516// +------------------------------------------------------------------------------------------------
518{
519 return m_simulation_status != SC_RUNNING ?
520 m_simulation_status :
521 (m_in_simulator_control ? (m_suspend ? SC_SUSPENDED: SC_RUNNING) : SC_PAUSED);
522}
523
525{
526 return m_stage;
527}
528
529inline
530int
532{
533 if( m_error ) {
534 return SC_SIM_ERROR;
535 }
536 if( m_forced_stop ) {
537 return SC_SIM_USER_STOP;
538 }
539 return SC_SIM_OK;
540}
541
542
543inline
546{
547 return m_object_manager;
548}
549
550inline
553{
554 return m_module_registry;
555}
556
557inline
560{
561 return m_port_registry;
562}
563
564inline
567{
568 return m_export_registry;
569}
570
571inline
574{
575 return m_prim_channel_registry;
576}
577
578inline
581{
582 return m_stage_cb_registry;
583}
584
585inline
588{
589 return m_stub_registry;
590}
591
592inline
595{
596 return &m_curr_proc_info;
597}
598
599
600inline
601int
603{
604 return ( ++ m_next_proc_id );
605}
606
607
608inline
609const sc_time&
611{
612 if ( m_max_time == SC_ZERO_TIME )
613 {
615 }
616 return m_max_time;
617}
618
619inline
622{
623 return m_change_stamp;
624}
625
626inline sc_dt::uint64
628{
629 return m_delta_count - m_initial_delta_count_at_current_time;
630}
631
632inline
633const sc_time&
635{
636 return m_curr_time;
637}
638
639
640inline
641bool
643{
644 return m_change_stamp == last_change_stamp;
645}
646
647inline
648bool
650{
651 return (m_execution_phase == phase_evaluate) &&
652 m_ready_to_simulate;
653}
654
655inline
656bool
658{
659 return m_execution_phase == phase_update;
660}
661
662inline
663bool
665{
666 return m_execution_phase == phase_notify;
667}
668
669inline
670void
672{
673 delete m_error;
674 m_error = err;
675}
676
677
678inline
679bool
681{
682 return m_error != NULL;
683}
684
685inline
686int
687sc_simcontext::add_delta_event( sc_event* e )
688{
689 m_delta_events.push_back( e );
690 return static_cast<int>( m_delta_events.size() - 1 );
691}
692
693inline
694void
695sc_simcontext::add_timed_event( sc_event_timed* et )
696{
697 m_timed_events->insert( et );
698}
699
700// ----------------------------------------------------------------------------
701
702inline sc_process_b*
704{
705 return m_current_writer;
706}
707
708inline void sc_simcontext::set_simulation_status(sc_status status)
709{
710 sc_scoped_lock lock( m_simulation_status_mutex );
711 m_simulation_status = status;
712}
713
714
715inline bool
717{
718 return m_write_check != SC_SIGNAL_WRITE_CHECK_DISABLE_;
719}
720
721// ----------------------------------------------------------------------------
722
725
726// Get the current object hierarchy context
727//
728// Returns a pointer the the sc_object (module or process) that
729// would become the parent object of a newly created element
730// of the SystemC object hierarchy, or NULL.
731//
732inline sc_object*
734{
736}
737
738inline
739sc_process_b*
741{
743}
744
745// THE FOLLOWING FUNCTION IS DEPRECATED IN 2.1
747
748inline
751{
753}
754
755
757{
759}
760
761
762// Generates unique names within each module.
763extern SC_API
764const char*
765sc_gen_unique_name( const char* basename_, bool preserve_first = false );
766
767
768// Set the random seed for controlled randomization -- not yet implemented
769extern SC_API
770void
771sc_set_random_seed( unsigned int seed_ );
772
773
774extern SC_API void sc_initialize();
775
776extern SC_API const sc_time& sc_max_time(); // Get maximum time value.
777extern SC_API const sc_time& sc_time_stamp(); // Current simulation time.
778extern SC_API double sc_simulation_time(); // Current time in default time units.
779
780inline
781const std::vector<sc_event*>& sc_get_top_level_events(
782 const sc_simcontext* simc_p = sc_get_curr_simcontext() )
783{
784 return simc_p->m_child_events;
785}
786
787inline
788const std::vector<sc_object*>& sc_get_top_level_objects(
789 const sc_simcontext* simc_p = sc_get_curr_simcontext() )
790{
791 return simc_p->m_child_objects;
792}
793
794extern SC_API sc_event* sc_find_event( const char* name );
795
796extern SC_API sc_object* sc_find_object( const char* name );
797
798inline
800{
801 return sc_get_curr_simcontext()->m_delta_count;
802}
803
804inline
806{
808}
809
810inline
812{
813 static bool stop_assert_issued = false;
814 bool lrm_assert_condition_section_4_6_7_sc_is_running = ( ( sc_get_status() & (SC_RUNNING | SC_PAUSED | SC_SUSPENDED) ) != 0 );
815 if ( ( !stop_assert_issued ) &&
816 ( simc_p->m_ready_to_simulate != lrm_assert_condition_section_4_6_7_sc_is_running )
817 ) {
818 stop_assert_issued = true; // This must be before the sc_assert!!!
819 sc_assert( simc_p->m_ready_to_simulate == lrm_assert_condition_section_4_6_7_sc_is_running );
820 }
821 return simc_p->m_ready_to_simulate;
822}
823
825
826inline void sc_pause()
827{
828 sc_get_curr_simcontext()->m_paused = true;
829}
830
831// Return indication if there are more processes to execute in this delta phase
832
834 ( const sc_simcontext* simc_p = sc_get_curr_simcontext() )
835{
836 return simc_p->pending_activity_at_current_time();
837}
838
839// Return indication if there are timed notifications in the future
840
842 ( const sc_simcontext* simc_p = sc_get_curr_simcontext() )
843{
844 sc_time ignored;
845 return simc_p->next_time( ignored );
846}
847
848// Return indication if there are processes to run,
849// or notifications in the future
850
852 ( const sc_simcontext* simc_p = sc_get_curr_simcontext() )
853{
856}
857
858SC_API sc_time
860 ( const sc_simcontext* simc_p = sc_get_curr_simcontext() );
861
862
863inline
864bool
866{
867 return sc_get_curr_simcontext()->m_end_of_simulation_called;
868}
869
870inline
871const char*
872sc_get_current_process_name( const char * if_empty = NULL )
873{
874 sc_process_b* active_p; // active process to get name of.
875 const char* result; // name of active process.
876
878 if ( active_p )
879 result = active_p->name();
880 else
881 result = if_empty;
882 return result;
883}
884
885inline
886bool
888{
890}
891
892inline
893bool
895 const char* name )
896{
897 return sc_get_curr_simcontext()->hierarchical_name_exists(parent, name);
898}
899
900inline
901const char*
903{
904 return sc_get_curr_simcontext()->get_hierarchical_name(NULL, name);
905}
906
907inline
908const char*
909sc_get_hierarchical_name(const sc_object* parent, const char* name)
910{
911 return sc_get_curr_simcontext()->get_hierarchical_name(parent, name);
912}
913
914inline
915bool
917{
919}
920
921inline
922bool
923sc_register_hierarchical_name(const sc_object* parent, const char* name)
924{
926}
927
928inline
929bool
931{
933}
934
935inline
936bool
937sc_unregister_hierarchical_name(const sc_object* parent, const char* name)
938{
940}
941
942inline
943bool
945{
946 return sc_get_curr_simcontext()->m_start_of_simulation_called;
947}
948
949// The following variable controls whether process control corners should
950// be considered errors or not. See sc_simcontext.cpp for details on what
951// happens if this value is set to true.
952
954
955} // namespace sc_core
956
957#if defined(_MSC_VER) && !defined(SC_WIN_DLL_WARN)
958#pragma warning(pop)
959#endif
960
961/*****************************************************************************
962
963 MODIFICATION LOG - modifiers, enter your name, affiliation, date and
964 changes you are making here.
965
966 Name, Affiliation, Date: Andy Goodrich, Forte Design Systems 20 May 2003
967 Description of Modification: - phase callbacks
968 - sc_stop mode
969
970 Name, Affiliation, Date: Bishnupriya Bhattacharya, Cadence Design Systems,
971 25 August, 2003
972 Description of Modification: - support for dynamic process
973 - support for sc export registry
974 - new member methods elaborate(),
975 prepare_to_simulate(), and initial_crunch()
976 that are invoked by initialize() in that order
977 - add sc_get_last_created_process_handle() for
978 use before simulation starts
979
980 Name, Affiliation, Date: Bishnupriya Bhattacharya, Cadence Design Systems,
981 3 March, 2004
982 Description of Modification: add sc_get_curr_process_kind()
983
984 Name, Affiliation, Date:
985 Description of Modification:
986
987 *****************************************************************************/
988// $Log: sc_simcontext.h,v $
989// Revision 1.26 2011/09/05 21:20:22 acg
990// Andy Goodrich: result of automake invocation.
991//
992// Revision 1.25 2011/09/01 15:28:10 acg
993// Andy Goodrich: the aftermath of automake.
994//
995// Revision 1.24 2011/08/29 18:04:32 acg
996// Philipp A. Hartmann: miscellaneous clean ups.
997//
998// Revision 1.23 2011/08/26 20:46:10 acg
999// Andy Goodrich: moved the modification log to the end of the file to
1000// eliminate source line number skew when check-ins are done.
1001//
1002// Revision 1.22 2011/08/24 22:05:51 acg
1003// Torsten Maehne: initialization changes to remove warnings.
1004//
1005// Revision 1.21 2011/05/09 04:07:49 acg
1006// Philipp A. Hartmann:
1007// (1) Restore hierarchy in all phase callbacks.
1008// (2) Ensure calls to before_end_of_elaboration.
1009//
1010// Revision 1.20 2011/04/08 18:26:07 acg
1011// Andy Goodrich: added execute_method_next() to handle method dispatch
1012// for asynchronous notifications that occur outside the evaluation phase.
1013//
1014// Revision 1.19 2011/04/05 20:50:57 acg
1015// Andy Goodrich:
1016// (1) changes to make sure that event(), posedge() and negedge() only
1017// return true if the clock has not moved.
1018// (2) fixes for method self-resumes.
1019// (3) added SC_PRERELEASE_VERSION
1020// (4) removed kernel events from the object hierarchy, added
1021// sc_hierarchical_name_exists().
1022//
1023// Revision 1.18 2011/03/20 13:43:23 acg
1024// Andy Goodrich: added async_signal_is() plus suspend() as a corner case.
1025//
1026// Revision 1.17 2011/03/07 18:25:19 acg
1027// Andy Goodrich: tightening of check for resume on a disabled process to
1028// only produce an error if it is ready to run.
1029//
1030// Revision 1.16 2011/03/06 15:58:50 acg
1031// Andy Goodrich: added escape to turn off process control corner case
1032// checks.
1033//
1034// Revision 1.15 2011/03/05 04:45:16 acg
1035// Andy Goodrich: moved active process calculation to the sc_simcontext class.
1036//
1037// Revision 1.14 2011/03/05 01:39:21 acg
1038// Andy Goodrich: changes for named events.
1039//
1040// Revision 1.13 2011/02/18 20:27:14 acg
1041// Andy Goodrich: Updated Copyrights.
1042//
1043// Revision 1.12 2011/02/13 21:47:38 acg
1044// Andy Goodrich: update copyright notice.
1045//
1046// Revision 1.11 2011/02/13 21:34:35 acg
1047// Andy Goodrich: added SC_UNINITIALIZED enum value to process status so
1048// its possible to detect throws before initialization.
1049//
1050// Revision 1.10 2011/02/11 13:25:24 acg
1051// Andy Goodrich: Philipp A. Hartmann's changes:
1052// (1) Removal of SC_CTHREAD method overloads.
1053// (2) New exception processing code.
1054//
1055// Revision 1.9 2011/02/01 21:18:56 acg
1056// Andy Goodrich: addition of new preempt_with() method used to immediately
1057// throw exceptions from threads.
1058//
1059// Revision 1.8 2011/01/25 20:50:37 acg
1060// Andy Goodrich: changes for IEEE 1666 2011.
1061//
1062// Revision 1.7 2011/01/19 23:21:50 acg
1063// Andy Goodrich: changes for IEEE 1666 2011
1064//
1065// Revision 1.6 2011/01/18 20:10:45 acg
1066// Andy Goodrich: changes for IEEE1666_2011 semantics.
1067//
1068// Revision 1.5 2010/07/22 20:02:33 acg
1069// Andy Goodrich: bug fixes.
1070//
1071// Revision 1.4 2009/05/22 16:06:29 acg
1072// Andy Goodrich: process control updates.
1073//
1074// Revision 1.3 2008/05/22 17:06:26 acg
1075// Andy Goodrich: updated copyright notice to include 2008.
1076//
1077// Revision 1.2 2007/09/20 20:32:35 acg
1078// Andy Goodrich: changes to the semantics of throw_it() to match the
1079// specification. A call to throw_it() will immediately suspend the calling
1080// thread until all the throwees have executed. At that point the calling
1081// thread will be restarted before the execution of any other threads.
1082//
1083// Revision 1.1.1.1 2006/12/15 20:20:05 acg
1084// SystemC 2.3
1085//
1086// Revision 1.13 2006/05/08 18:00:06 acg
1087// Andy Goodrich: added David Long's forward declarations for friend
1088// functions, methods, and operators to keep the Microsoft compiler happy.
1089//
1090// Revision 1.11 2006/04/11 23:13:21 acg
1091// Andy Goodrich: Changes for reduced reset support that only includes
1092// sc_cthread, but has preliminary hooks for expanding to method and thread
1093// processes also.
1094//
1095// Revision 1.10 2006/03/21 00:00:34 acg
1096// Andy Goodrich: changed name of sc_get_current_process_base() to be
1097// sc_get_current_process_b() since its returning an sc_process_b instance.
1098//
1099// Revision 1.9 2006/01/26 21:04:54 acg
1100// Andy Goodrich: deprecation message changes and additional messages.
1101//
1102// Revision 1.8 2006/01/24 20:49:05 acg
1103// Andy Goodrich: changes to remove the use of deprecated features within the
1104// simulator, and to issue warning messages when deprecated features are used.
1105//
1106// Revision 1.7 2006/01/19 00:29:52 acg
1107// Andy Goodrich: Yet another implementation for signal write checking. This
1108// one uses an environment variable SC_SIGNAL_WRITE_CHECK, that when set to
1109// DISABLE will disable write checking on signals.
1110//
1111// Revision 1.6 2006/01/18 21:42:37 acg
1112// Andy Goodrich: Changes for check writer support.
1113//
1114// Revision 1.5 2006/01/13 18:44:30 acg
1115// Added $Log to record CVS changes into the source.
1116//
1117// Revision 1.4 2006/01/03 23:18:44 acg
1118// Changed copyright to include 2006.
1119//
1120// Revision 1.3 2005/12/20 22:11:10 acg
1121// Fixed $Log lines.
1122//
1123// Revision 1.2 2005/12/20 22:02:30 acg
1124// Changed where delta cycles are incremented to match IEEE 1666. Added the
1125// event_occurred() method to hide how delta cycle comparisions are done within
1126// sc_simcontext. Changed the boolean update_phase to an enum that shows all
1127// the phases.
1128
1129#endif
#define SC_API
Definition: sc_cmnhdr.h:148
#define sc_assert(expr)
Definition: sc_report.h:248
const int SC_SIM_OK
Definition: sc_status.h:40
SC_API bool sc_start_of_simulation_invoked()
int sc_get_simulator_status()
SC_API const sc_time & sc_max_time()
SC_API sc_dt::uint64 sc_delta_count()
class SC_API sc_simcontext
Definition: sc_object.h:50
SC_API bool sc_allow_process_control_corners
const int SC_SIM_USER_STOP
Definition: sc_status.h:42
bool sc_unregister_hierarchical_name(const char *name)
class sc_method_process * sc_method_handle
Definition: sc_process.h:61
sc_status sc_get_status()
const int SC_SIM_ERROR
Definition: sc_status.h:41
class SC_API sc_event
Definition: sc_interface.h:36
SC_API sc_time sc_time_to_pending_activity(const sc_simcontext *)
SC_API const char * sc_gen_unique_name(const char *, bool preserve_first)
const char * sc_get_hierarchical_name(const char *name)
SC_API bool sc_end_of_simulation_invoked()
SC_API bool sc_pending_activity_at_future_time(const sc_simcontext *)
SC_API void sc_start()
SC_API sc_process_b * sc_get_curr_process_handle()
@ SC_SUSPENDED
Definition: sc_status.h:53
@ SC_RUNNING
Definition: sc_status.h:51
@ SC_PAUSED
Definition: sc_status.h:52
SC_API sc_stop_mode sc_get_stop_mode()
SC_API void sc_unsuspend_all()
SC_API sc_simcontext * sc_default_global_context
sc_curr_proc_kind
Definition: sc_process.h:68
@ SC_NO_PROC_
Definition: sc_process.h:69
SC_API void sc_stop()
SC_API bool sc_is_unwinding()
SC_API void sc_set_time_resolution(double, sc_time_unit)
SC_API const sc_time & sc_time_stamp()
class sc_thread_process * sc_thread_handle
Definition: sc_process.h:62
SC_API void sc_initialize()
const char * sc_get_current_process_name(const char *if_empty=NULL)
SC_API double sc_simulation_time()
class SC_API sc_trace_file
Definition: sc_object.h:51
const sc_curr_proc_info * sc_curr_proc_handle
Definition: sc_simcontext.h:93
SC_API sc_time sc_get_default_time_unit()
sc_curr_proc_kind sc_get_curr_process_kind()
sc_simcontext * sc_get_curr_simcontext()
SC_API void sc_set_stop_mode(sc_stop_mode mode)
SC_API void sc_unsuspendable()
class SC_API sc_object
Definition: sc_object.h:46
SC_API const std::vector< sc_object * > & sc_get_top_level_objects(const sc_simcontext *simc_p)
SC_API sc_process_handle sc_get_current_process_handle()
SC_API sc_event * sc_find_event(const char *name)
@ SC_STOP_FINISH_DELTA
Definition: sc_simcontext.h:96
@ SC_STOP_IMMEDIATE
Definition: sc_simcontext.h:97
void(sc_process_host::* sc_entry_func)()
Definition: sc_process.h:132
SC_API const std::vector< sc_event * > & sc_get_top_level_events(const sc_simcontext *simc_p)
bool sc_hierarchical_name_exists(const char *name)
SC_API const sc_time SC_ZERO_TIME
SC_API sc_dt::uint64 sc_delta_count_at_current_time()
sc_time_unit
Definition: sc_time.h:82
SC_API bool sc_is_running(const sc_simcontext *simc_p)
bool sc_pending_activity(const sc_simcontext *simc_p=sc_get_curr_simcontext())
SC_API void sc_register_stage_callback(sc_stage_callback_if &cb, unsigned int mask)
SC_API void sc_set_default_time_unit(double, sc_time_unit)
SC_API void sc_pause()
sc_process_b * sc_get_current_process_b()
bool sc_register_hierarchical_name(const char *name)
SC_API bool sc_pending_activity_at_current_time(const sc_simcontext *)
SC_API void sc_suspendable()
sc_starvation_policy
@ SC_RUN_TO_TIME
@ SC_EXIT_ON_STARVATION
sc_object * sc_get_current_object()
class SC_API sc_object_host
Definition: sc_object.h:47
class SC_API sc_module
Definition: sc_object.h:44
SC_API sc_object * sc_find_object(const char *name)
SC_API sc_time sc_get_time_resolution()
sc_plist< sc_process_b * > sc_process_list
Definition: sc_simcontext.h:84
SC_API void sc_unregister_stage_callback(sc_stage_callback_if &cb, unsigned int mask)
SC_API void sc_suspend_all()
SC_API void sc_set_random_seed(unsigned int seed_)
SC_API sc_simcontext * sc_curr_simcontext
unsigned long long uint64
Definition: sc_nbdefs.h:216
constexpr uint64 UINT64_ZERO
Definition: sc_nbdefs.h:218
const char * name() const
Definition: sc_object.h:122
sc_process_b * process_handle
Definition: sc_simcontext.h:88
sc_curr_proc_kind kind
Definition: sc_simcontext.h:89
sc_export_registry * get_export_registry()
friend SC_API void sc_suspend_all()
friend SC_API void sc_start(const sc_time &, sc_starvation_policy)
bool pending_activity_at_current_time() const
void simulate(const sc_time &duration)
friend SC_API sc_time sc_get_default_time_unit()
sc_object_host * active_object()
const char * gen_unique_name(const char *basename_, bool preserve_first=false)
const ::std::vector< sc_object * > & get_child_objects() const
friend SC_API sc_time sc_get_time_resolution()
sc_dt::uint64 change_stamp() const
void add_reset_finder(sc_reset_finder *)
friend SC_API void sc_unsuspendable()
bool notify_phase() const
friend void sc_thread_cor_fn(void *)
bool next_time(sc_time &t) const
sc_event & null_event()
friend SC_API void sc_register_stage_callback(sc_stage_callback_if &cb, unsigned int mask)
bool evaluation_phase() const
const char * get_hierarchical_name(const sc_object *parent, const std::string &name)
friend SC_API void sc_suspendable()
void initial_crunch(bool no_crunch)
std::string construct_hierarchical_name(const sc_object *parent, const std::string &name)
sc_cor_pkg * cor_pkg()
bool event_occurred(sc_dt::uint64 last_change_count) const
sc_object * next_object()
const sc_time & max_time() const
sc_object_manager * get_object_manager()
friend SC_API void sc_unregister_stage_callback(sc_stage_callback_if &cb, unsigned int mask)
sc_status get_status() const
sc_curr_proc_handle get_curr_proc_info()
sc_status get_thread_safe_status()
bool unregister_hierarchical_name(const sc_object *parent, const std::string &name)
void set_error(sc_report *)
friend SC_API void sc_set_default_time_unit(double, sc_time_unit)
bool update_phase() const
sc_stage_callback_registry * get_stage_cb_registry()
void post_suspend() const
void initialize(bool=false)
friend SC_API sc_time sc_time_to_pending_activity(const sc_simcontext *)
void cycle(const sc_time &)
friend SC_API void sc_unsuspend_all()
sc_process_handle create_cthread_process(const char *name_p, bool free_host, sc_entry_func method_p, sc_process_host *host_p, const sc_spawn_options *opt_p)
sc_process_handle create_thread_process(const char *name_p, bool free_host, sc_entry_func method_p, sc_process_host *host_p, const sc_spawn_options *opt_p)
void pre_suspend() const
sc_process_b * get_current_writer() const
bool hierarchical_name_exists(const sc_object *parent, const std::string &name)
const sc_time & time_stamp() const
sc_process_handle create_method_process(const char *name_p, bool free_host, sc_entry_func method_p, sc_process_host *host_p, const sc_spawn_options *opt_p)
sc_stage get_stage() const
bool is_running() const
bool register_hierarchical_name(const sc_object *parent, const std::string &name)
sc_dt::uint64 delta_count() const
bool elaboration_done() const
sc_object * find_object(const char *name)
sc_object * first_object()
sc_port_registry * get_port_registry()
sc_module_registry * get_module_registry()
sc_stub_registry * get_stub_registry()
bool write_check() const
sc_dt::uint64 delta_count_at_current_time() const
sc_prim_channel_registry * get_prim_channel_registry()
friend SC_API void sc_set_time_resolution(double, sc_time_unit)
static sc_time from_value(value_type)