SystemC  2.3.2
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 */
34 #ifndef SC_SIMCONTEXT_H
35 #define SC_SIMCONTEXT_H
36 
37 #include "sysc/kernel/sc_cmnhdr.h"
38 #include "sysc/kernel/sc_process.h"
39 #include "sysc/kernel/sc_status.h"
40 #include "sysc/kernel/sc_time.h"
41 #include "sysc/utils/sc_hash.h"
42 #include "sysc/utils/sc_pq.h"
43 
44 #if defined(_MSC_VER) && !defined(SC_WIN_DLL_WARN)
45 #pragma warning(push)
46 #pragma warning(disable: 4251) // DLL import for std::vector
47 #endif
48 
49 namespace sc_core {
50 
51 // forward declarations
52 
53 class sc_cor;
54 class sc_cor_pkg;
55 class sc_event;
56 class sc_event_timed;
57 class sc_export_registry;
58 class sc_module;
59 class sc_module_name;
60 class sc_module_registry;
61 class sc_name_gen;
62 class sc_object;
63 class sc_object_manager;
64 class sc_phase_callback_registry;
65 class sc_process_handle;
66 class sc_port_registry;
67 class sc_prim_channel_registry;
68 class sc_process_table;
69 class sc_signal_bool_deval;
70 class sc_trace_file;
71 class sc_runnable;
72 class sc_process_host;
73 class sc_method_process;
74 class sc_cthread_process;
75 class sc_thread_process;
76 class sc_reset_finder;
77 
78 
79 template< typename > class sc_plist;
81 
83 {
86  sc_curr_proc_info() : process_handle( 0 ), kind( SC_NO_PROC_ ) {}
87 };
88 
90 
91 enum sc_stop_mode { // sc_stop modes:
94 };
95 extern SC_API void sc_set_stop_mode( sc_stop_mode mode );
97 
99 {
102 };
103 extern SC_API void sc_start();
104 extern SC_API void sc_start( const sc_time& duration,
106 inline void sc_start( int duration, sc_time_unit unit,
108 {
109  sc_start( sc_time((double)duration,unit), p );
110 }
111 
112 inline void sc_start( double duration, sc_time_unit unit,
114 {
115  sc_start( sc_time(duration,unit), p );
116 }
117 
118 extern SC_API void sc_stop();
119 
120 // friend function declarations
121 
124 SC_API const std::vector<sc_event*>& sc_get_top_level_events(
125  const sc_simcontext* simc_p);
126 SC_API const std::vector<sc_object*>& sc_get_top_level_objects(
127  const sc_simcontext* simc_p);
128 SC_API bool sc_is_running( const sc_simcontext* simc_p );
129 SC_API void sc_pause();
140 
141 struct sc_invoke_method;
142 
150 {
151  friend struct sc_invoke_method;
152  friend class sc_event;
153  friend class sc_module;
154  friend class sc_object;
155  friend class sc_time;
156  friend class sc_time_tuple;
157  friend class sc_clock;
158  friend class sc_method_process;
160  friend class sc_process_b;
161  friend class sc_process_handle;
162  friend class sc_prim_channel;
163  friend class sc_cthread_process;
164  friend class sc_thread_process;
166  friend SC_API const std::vector<sc_event*>& sc_get_top_level_events(
167  const sc_simcontext* simc_p);
168  friend SC_API const std::vector<sc_object*>& sc_get_top_level_objects(
169  const sc_simcontext* simc_p);
170  friend SC_API bool sc_is_running( const sc_simcontext* simc_p );
171  friend SC_API void sc_pause();
172  friend SC_API bool sc_end_of_simulation_invoked();
173  friend SC_API void sc_start( const sc_time&, sc_starvation_policy );
175  friend void sc_thread_cor_fn(void*);
179 
180  enum sc_signal_write_check
181  {
182  SC_SIGNAL_WRITE_CHECK_DISABLE_ = 0x0,
183  SC_SIGNAL_WRITE_CHECK_DEFAULT_ = 0x1,
184  SC_SIGNAL_WRITE_CHECK_CONFLICT_ = 0x2 // only check for conflicting writes
185  };
186 
187 
188  void init();
189  void clean();
190 
191 public:
192 
193  sc_simcontext();
194  ~sc_simcontext();
195 
196  void initialize( bool = false );
197  void cycle( const sc_time& );
198  void simulate( const sc_time& duration );
199  void stop();
200  void end();
201  void reset();
202 
203  int sim_status() const;
204  bool elaboration_done() const;
205 
206  std::vector<sc_thread_handle>& get_active_invokers();
207 
208  sc_object_manager* get_object_manager();
209 
210  inline sc_status get_status() const;
211 
212  sc_object* active_object();
213 
214  void hierarchy_push( sc_module* );
215  sc_module* hierarchy_pop();
216  sc_module* hierarchy_curr() const;
217  sc_object* first_object();
218  sc_object* next_object();
219  sc_object* find_object( const char* name );
220 
221  sc_module_registry* get_module_registry();
222  sc_port_registry* get_port_registry();
223  sc_export_registry* get_export_registry();
224  sc_prim_channel_registry* get_prim_channel_registry();
225 
226  std::string construct_hierarchical_name(const sc_object* parent,
227  const std::string& name);
228  bool register_hierarchical_name(const sc_object* parent,
229  const std::string& name);
230  bool unregister_hierarchical_name(const sc_object* parent,
231  const std::string& name);
232  bool hierarchical_name_exists(const sc_object* parent,
233  const std::string& name);
234  const char* get_hierarchical_name(const sc_object* parent,
235  const std::string& name);
236 
237  // to generate unique names for objects in an MT-Safe way
238  const char* gen_unique_name( const char* basename_,
239  bool preserve_first = false
240  );
241 
242  // process creation
243  sc_process_handle create_cthread_process(
244  const char* name_p, bool free_host, SC_ENTRY_FUNC method_p,
245  sc_process_host* host_p, const sc_spawn_options* opt_p );
246 
247  sc_process_handle create_method_process(
248  const char* name_p, bool free_host, SC_ENTRY_FUNC method_p,
249  sc_process_host* host_p, const sc_spawn_options* opt_p );
250 
251  sc_process_handle create_thread_process(
252  const char* name_p, bool free_host, SC_ENTRY_FUNC method_p,
253  sc_process_host* host_p, const sc_spawn_options* opt_p );
254 
255  sc_curr_proc_handle get_curr_proc_info();
256  sc_process_b* get_current_writer() const;
257  bool write_check() const;
258  bool write_check_conflicts_only() const;
259  void set_curr_proc( sc_process_b* );
260  void reset_curr_proc();
261 
262  int next_proc_id();
263 
264  void add_trace_file( sc_trace_file* );
265  void remove_trace_file( sc_trace_file* );
266 
267  friend SC_API void sc_set_time_resolution( double, sc_time_unit );
269  friend SC_API void sc_set_default_time_unit( double, sc_time_unit );
271 
272  const sc_time& max_time() const;
273  const sc_time& time_stamp() const;
274 
275  sc_dt::uint64 change_stamp() const;
276  sc_dt::uint64 delta_count() const;
277  sc_dt::uint64 delta_count_at_current_time() const;
278  bool event_occurred( sc_dt::uint64 last_change_count ) const;
279  bool evaluation_phase() const;
280  bool is_running() const;
281  bool update_phase() const;
282  bool notify_phase() const;
283  bool get_error();
284  void set_error( sc_report* );
285 
287  { return m_cor_pkg; }
288  sc_cor* next_cor();
289 
290  void add_reset_finder( sc_reset_finder* );
291 
292  const ::std::vector<sc_object*>& get_child_objects() const;
293 
294  void elaborate();
295  void prepare_to_simulate();
296  inline void initial_crunch( bool no_crunch );
297  bool next_time( sc_time& t ) const;
298  bool pending_activity_at_current_time() const;
299 
300 private:
301 
302  void add_child_event( sc_event* );
303  void add_child_object( sc_object* );
304  void remove_child_event( sc_event* );
305  void remove_child_object( sc_object* );
306 
307  void crunch( bool once=false );
308 
309  int add_delta_event( sc_event* );
310  void remove_delta_event( sc_event* );
311  void add_timed_event( sc_event_timed* );
312 
313  void trace_cycle( bool delta_cycle );
314 
315  void execute_method_next( sc_method_handle );
316  void execute_thread_next( sc_thread_handle );
317 
318  sc_method_handle pop_runnable_method();
319  sc_thread_handle pop_runnable_thread();
320 
321  void preempt_with( sc_method_handle );
322  inline void preempt_with( sc_thread_handle );
323 
324  void push_runnable_method( sc_method_handle );
325  void push_runnable_thread( sc_thread_handle );
326 
327  void push_runnable_method_front( sc_method_handle );
328  void push_runnable_thread_front( sc_thread_handle );
329 
330  void remove_runnable_method( sc_method_handle );
331  void remove_runnable_thread( sc_thread_handle );
332 
333  void requeue_current_process();
334  void suspend_current_process();
335 
336  void do_sc_stop_action();
337  void do_timestep( const sc_time& );
338  void mark_to_collect_process( sc_process_b* zombie_p );
339 
340  sc_method_handle remove_process( sc_method_handle );
341  sc_thread_handle remove_process( sc_thread_handle );
342 
343 private:
344 
345  enum execution_phases {
346  phase_initialize = 0,
347  phase_evaluate,
348  phase_update,
349  phase_notify
350  };
351  sc_object_manager* m_object_manager;
352 
353  sc_module_registry* m_module_registry;
354  sc_port_registry* m_port_registry;
355  sc_export_registry* m_export_registry;
356  sc_prim_channel_registry* m_prim_channel_registry;
357  sc_phase_callback_registry* m_phase_cb_registry;
358 
359  sc_name_gen* m_name_gen;
360 
361  sc_process_table* m_process_table;
362  sc_curr_proc_info m_curr_proc_info;
363  sc_process_b* m_current_writer;
364  sc_signal_write_check m_write_check;
365  int m_next_proc_id;
366 
367  std::vector<sc_thread_handle> m_active_invokers;
368 
369  std::vector<sc_event*> m_child_events;
370  std::vector<sc_object*> m_child_objects;
371 
372  std::vector<sc_event*> m_delta_events;
373  sc_ppq<sc_event_timed*>* m_timed_events;
374 
375  std::vector<sc_trace_file*> m_trace_files;
376  bool m_something_to_trace;
377 
378  sc_runnable* m_runnable;
379  sc_process_list* m_collectable;
380 
381  sc_time_params* m_time_params;
382  sc_time m_curr_time;
383  mutable sc_time m_max_time;
384 
385  sc_invoke_method* m_method_invoker_p;
386  sc_dt::uint64 m_change_stamp; // "time" change occurred.
387  sc_dt::uint64 m_delta_count;
388  sc_dt::uint64 m_initial_delta_count_at_current_time;
389  bool m_forced_stop;
390  bool m_paused;
391  bool m_ready_to_simulate;
392  bool m_elaboration_done;
393  execution_phases m_execution_phase;
394  sc_report* m_error;
395  bool m_in_simulator_control;
396  bool m_end_of_simulation_called;
397  sc_status m_simulation_status;
398  bool m_start_of_simulation_called;
399 
400  sc_cor_pkg* m_cor_pkg; // the simcontext's coroutine package
401  sc_cor* m_cor; // the simcontext's coroutine
402 
403  sc_reset_finder* m_reset_finder_q; // Q of reset finders to reconcile.
404 
405 private:
406 
407  // disabled
408  sc_simcontext( const sc_simcontext& );
409  sc_simcontext& operator = ( const sc_simcontext& );
410 };
411 
412 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
413 
414 // Not MT safe.
415 
416 #if 1
419 
420 inline sc_simcontext*
422 {
423  if( sc_curr_simcontext == 0 ) {
424  sc_default_global_context = new sc_simcontext;
425  sc_curr_simcontext = sc_default_global_context;
426  }
427  return sc_curr_simcontext;
428 }
429 #else
431 #endif // 0
433 {
435 }
436 
437 
438 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
439 
440 inline
441 bool
443 {
444  return m_elaboration_done;
445 }
446 
447 
449 {
450  return m_simulation_status != SC_RUNNING ?
451  m_simulation_status :
452  (m_in_simulator_control ? SC_RUNNING : SC_PAUSED);
453 }
454 
455 inline
456 int
458 {
459  if( m_error ) {
460  return SC_SIM_ERROR;
461  }
462  if( m_forced_stop ) {
463  return SC_SIM_USER_STOP;
464  }
465  return SC_SIM_OK;
466 }
467 
468 
469 inline
472 {
473  return m_object_manager;
474 }
475 
476 inline
479 {
480  return m_module_registry;
481 }
482 
483 inline
486 {
487  return m_port_registry;
488 }
489 
490 inline
493 {
494  return m_export_registry;
495 }
496 
497 inline
500 {
501  return m_prim_channel_registry;
502 }
503 
504 
505 inline
506 sc_curr_proc_handle
508 {
509  return &m_curr_proc_info;
510 }
511 
512 
513 inline
514 int
516 {
517  return ( ++ m_next_proc_id );
518 }
519 
520 
521 inline
522 const sc_time&
524 {
525  if ( m_max_time == SC_ZERO_TIME )
526  {
527  m_max_time = sc_time::from_value( ~sc_dt::UINT64_ZERO );
528  }
529  return m_max_time;
530 }
531 
532 inline
535 {
536  return m_change_stamp;
537 }
538 
539 inline sc_dt::uint64
541 {
542  return m_delta_count - m_initial_delta_count_at_current_time;
543 }
544 
545 inline
546 const sc_time&
548 {
549  return m_curr_time;
550 }
551 
552 
553 inline
554 bool
556 {
557  return m_change_stamp == last_change_stamp;
558 }
559 
560 inline
561 bool
563 {
564  return (m_execution_phase == phase_evaluate) &&
565  m_ready_to_simulate;
566 }
567 
568 inline
569 bool
571 {
572  return m_execution_phase == phase_update;
573 }
574 
575 inline
576 bool
578 {
579  return m_execution_phase == phase_notify;
580 }
581 
582 inline
583 void
585 {
586  delete m_error;
587  m_error = err;
588 }
589 
590 
591 inline
592 bool
594 {
595  return m_error != NULL;
596 }
597 
598 inline
599 int
600 sc_simcontext::add_delta_event( sc_event* e )
601 {
602  m_delta_events.push_back( e );
603  return static_cast<int>( m_delta_events.size() - 1 );
604 }
605 
606 inline
607 void
608 sc_simcontext::add_timed_event( sc_event_timed* et )
609 {
610  m_timed_events->insert( et );
611 }
612 
613 // ----------------------------------------------------------------------------
614 
615 inline sc_process_b*
617 {
618  return m_current_writer;
619 }
620 
621 inline bool
623 {
624  return m_write_check != SC_SIGNAL_WRITE_CHECK_DISABLE_;
625 }
626 
627 class sc_process_handle;
629 
630 // Get the current object hierarchy context
631 //
632 // Returns a pointer the the sc_object (module or process) that
633 // would become the parent object of a newly created element
634 // of the SystemC object hierarchy, or NULL.
635 //
636 inline sc_object*
638 {
640 }
641 
642 inline
645 {
647 }
648 
649 // THE FOLLOWING FUNCTION IS DEPRECATED IN 2.1
651 
652 inline
655 {
657 }
658 
659 
661 {
663 }
664 
665 
666 // Generates unique names within each module.
667 extern SC_API
668 const char*
669 sc_gen_unique_name( const char* basename_, bool preserve_first = false );
670 
671 
672 // Set the random seed for controlled randomization -- not yet implemented
673 extern SC_API
674 void
675 sc_set_random_seed( unsigned int seed_ );
676 
677 
678 extern SC_API void sc_initialize();
679 
680 extern SC_API const sc_time& sc_max_time(); // Get maximum time value.
681 extern SC_API const sc_time& sc_time_stamp(); // Current simulation time.
682 extern SC_API double sc_simulation_time(); // Current time in default time units.
683 
684 inline
685 const std::vector<sc_event*>& sc_get_top_level_events(
686  const sc_simcontext* simc_p = sc_get_curr_simcontext() )
687 {
688  return simc_p->m_child_events;
689 }
690 
691 inline
692 const std::vector<sc_object*>& sc_get_top_level_objects(
693  const sc_simcontext* simc_p = sc_get_curr_simcontext() )
694 {
695  return simc_p->m_child_objects;
696 }
697 
698 extern SC_API sc_event* sc_find_event( const char* name );
699 
700 extern SC_API sc_object* sc_find_object( const char* name );
701 
702 inline
704 {
705  return sc_get_curr_simcontext()->m_delta_count;
706 }
707 
708 inline
710 {
712 }
713 
714 inline
716 {
717  return simc_p->m_ready_to_simulate;
718 }
719 
720 SC_API bool sc_is_unwinding();
721 
722 inline void sc_pause()
723 {
724  sc_get_curr_simcontext()->m_paused = true;
725 }
726 
727 // Return indication if there are more processes to execute in this delta phase
728 
730  ( const sc_simcontext* simc_p = sc_get_curr_simcontext() )
731 {
732  return simc_p->pending_activity_at_current_time();
733 }
734 
735 // Return indication if there are timed notifications in the future
736 
738  ( const sc_simcontext* simc_p = sc_get_curr_simcontext() )
739 {
740  sc_time ignored;
741  return simc_p->next_time( ignored );
742 }
743 
744 // Return indication if there are processes to run,
745 // or notifications in the future
746 
747 inline bool sc_pending_activity
748  ( const sc_simcontext* simc_p = sc_get_curr_simcontext() )
749 {
750  return sc_pending_activity_at_current_time( simc_p )
752 }
753 
756  ( const sc_simcontext* simc_p = sc_get_curr_simcontext() );
757 
758 
759 inline
760 bool
762 {
763  return sc_get_curr_simcontext()->m_end_of_simulation_called;
764 }
765 
766 inline
767 bool
768 sc_hierarchical_name_exists( const char* name )
769 {
770  return sc_get_curr_simcontext()->hierarchical_name_exists(NULL, name);
771 }
772 
773 inline
774 bool
776  const char* name )
777 {
778  return sc_get_curr_simcontext()->hierarchical_name_exists(parent, name);
779 }
780 
781 inline
782 const char*
783 sc_get_hierarchical_name(const char* name)
784 {
785  return sc_get_curr_simcontext()->get_hierarchical_name(NULL, name);
786 }
787 
788 inline
789 const char*
790 sc_get_hierarchical_name(const sc_object* parent, const char* name)
791 {
792  return sc_get_curr_simcontext()->get_hierarchical_name(parent, name);
793 }
794 
795 inline
796 bool
798 {
800 }
801 
802 inline
803 bool
804 sc_register_hierarchical_name(const sc_object* parent, const char* name)
805 {
806  return sc_get_curr_simcontext()->register_hierarchical_name(parent, name);
807 }
808 
809 inline
810 bool
812 {
814 }
815 
816 inline
817 bool
818 sc_unregister_hierarchical_name(const sc_object* parent, const char* name)
819 {
821 }
822 
823 inline
824 bool
826 {
827  return sc_get_curr_simcontext()->m_start_of_simulation_called;
828 }
829 
830 // The following variable controls whether process control corners should
831 // be considered errors or not. See sc_simcontext.cpp for details on what
832 // happens if this value is set to true.
833 
835 
836 } // namespace sc_core
837 
838 #if defined(_MSC_VER) && !defined(SC_WIN_DLL_WARN)
839 #pragma warning(pop)
840 #endif
841 
842 /*****************************************************************************
843 
844  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
845  changes you are making here.
846 
847  Name, Affiliation, Date: Andy Goodrich, Forte Design Systems 20 May 2003
848  Description of Modification: - phase callbacks
849  - sc_stop mode
850 
851  Name, Affiliation, Date: Bishnupriya Bhattacharya, Cadence Design Systems,
852  25 August, 2003
853  Description of Modification: - support for dynamic process
854  - support for sc export registry
855  - new member methods elaborate(),
856  prepare_to_simulate(), and initial_crunch()
857  that are invoked by initialize() in that order
858  - add sc_get_last_created_process_handle() for
859  use before simulation starts
860 
861  Name, Affiliation, Date: Bishnupriya Bhattacharya, Cadence Design Systems,
862  3 March, 2004
863  Description of Modification: add sc_get_curr_process_kind()
864 
865  Name, Affiliation, Date:
866  Description of Modification:
867 
868  *****************************************************************************/
869 // $Log: sc_simcontext.h,v $
870 // Revision 1.26 2011/09/05 21:20:22 acg
871 // Andy Goodrich: result of automake invocation.
872 //
873 // Revision 1.25 2011/09/01 15:28:10 acg
874 // Andy Goodrich: the aftermath of automake.
875 //
876 // Revision 1.24 2011/08/29 18:04:32 acg
877 // Philipp A. Hartmann: miscellaneous clean ups.
878 //
879 // Revision 1.23 2011/08/26 20:46:10 acg
880 // Andy Goodrich: moved the modification log to the end of the file to
881 // eliminate source line number skew when check-ins are done.
882 //
883 // Revision 1.22 2011/08/24 22:05:51 acg
884 // Torsten Maehne: initialization changes to remove warnings.
885 //
886 // Revision 1.21 2011/05/09 04:07:49 acg
887 // Philipp A. Hartmann:
888 // (1) Restore hierarchy in all phase callbacks.
889 // (2) Ensure calls to before_end_of_elaboration.
890 //
891 // Revision 1.20 2011/04/08 18:26:07 acg
892 // Andy Goodrich: added execute_method_next() to handle method dispatch
893 // for asynchronous notifications that occur outside the evaluation phase.
894 //
895 // Revision 1.19 2011/04/05 20:50:57 acg
896 // Andy Goodrich:
897 // (1) changes to make sure that event(), posedge() and negedge() only
898 // return true if the clock has not moved.
899 // (2) fixes for method self-resumes.
900 // (3) added SC_PRERELEASE_VERSION
901 // (4) removed kernel events from the object hierarchy, added
902 // sc_hierarchical_name_exists().
903 //
904 // Revision 1.18 2011/03/20 13:43:23 acg
905 // Andy Goodrich: added async_signal_is() plus suspend() as a corner case.
906 //
907 // Revision 1.17 2011/03/07 18:25:19 acg
908 // Andy Goodrich: tightening of check for resume on a disabled process to
909 // only produce an error if it is ready to run.
910 //
911 // Revision 1.16 2011/03/06 15:58:50 acg
912 // Andy Goodrich: added escape to turn off process control corner case
913 // checks.
914 //
915 // Revision 1.15 2011/03/05 04:45:16 acg
916 // Andy Goodrich: moved active process calculation to the sc_simcontext class.
917 //
918 // Revision 1.14 2011/03/05 01:39:21 acg
919 // Andy Goodrich: changes for named events.
920 //
921 // Revision 1.13 2011/02/18 20:27:14 acg
922 // Andy Goodrich: Updated Copyrights.
923 //
924 // Revision 1.12 2011/02/13 21:47:38 acg
925 // Andy Goodrich: update copyright notice.
926 //
927 // Revision 1.11 2011/02/13 21:34:35 acg
928 // Andy Goodrich: added SC_UNITIALIZED enum value to process status so
929 // its possible to detect throws before initialization.
930 //
931 // Revision 1.10 2011/02/11 13:25:24 acg
932 // Andy Goodrich: Philipp A. Hartmann's changes:
933 // (1) Removal of SC_CTHREAD method overloads.
934 // (2) New exception processing code.
935 //
936 // Revision 1.9 2011/02/01 21:18:56 acg
937 // Andy Goodrich: addition of new preempt_with() method used to immediately
938 // throw exceptions from threads.
939 //
940 // Revision 1.8 2011/01/25 20:50:37 acg
941 // Andy Goodrich: changes for IEEE 1666 2011.
942 //
943 // Revision 1.7 2011/01/19 23:21:50 acg
944 // Andy Goodrich: changes for IEEE 1666 2011
945 //
946 // Revision 1.6 2011/01/18 20:10:45 acg
947 // Andy Goodrich: changes for IEEE1666_2011 semantics.
948 //
949 // Revision 1.5 2010/07/22 20:02:33 acg
950 // Andy Goodrich: bug fixes.
951 //
952 // Revision 1.4 2009/05/22 16:06:29 acg
953 // Andy Goodrich: process control updates.
954 //
955 // Revision 1.3 2008/05/22 17:06:26 acg
956 // Andy Goodrich: updated copyright notice to include 2008.
957 //
958 // Revision 1.2 2007/09/20 20:32:35 acg
959 // Andy Goodrich: changes to the semantics of throw_it() to match the
960 // specification. A call to throw_it() will immediately suspend the calling
961 // thread until all the throwees have executed. At that point the calling
962 // thread will be restarted before the execution of any other threads.
963 //
964 // Revision 1.1.1.1 2006/12/15 20:20:05 acg
965 // SystemC 2.3
966 //
967 // Revision 1.13 2006/05/08 18:00:06 acg
968 // Andy Goodrich: added David Long's forward declarations for friend
969 // functions, methods, and operators to keep the Microsoft compiler happy.
970 //
971 // Revision 1.11 2006/04/11 23:13:21 acg
972 // Andy Goodrich: Changes for reduced reset support that only includes
973 // sc_cthread, but has preliminary hooks for expanding to method and thread
974 // processes also.
975 //
976 // Revision 1.10 2006/03/21 00:00:34 acg
977 // Andy Goodrich: changed name of sc_get_current_process_base() to be
978 // sc_get_current_process_b() since its returning an sc_process_b instance.
979 //
980 // Revision 1.9 2006/01/26 21:04:54 acg
981 // Andy Goodrich: deprecation message changes and additional messages.
982 //
983 // Revision 1.8 2006/01/24 20:49:05 acg
984 // Andy Goodrich: changes to remove the use of deprecated features within the
985 // simulator, and to issue warning messages when deprecated features are used.
986 //
987 // Revision 1.7 2006/01/19 00:29:52 acg
988 // Andy Goodrich: Yet another implementation for signal write checking. This
989 // one uses an environment variable SC_SIGNAL_WRITE_CHECK, that when set to
990 // DISABLE will disable write checking on signals.
991 //
992 // Revision 1.6 2006/01/18 21:42:37 acg
993 // Andy Goodrich: Changes for check writer support.
994 //
995 // Revision 1.5 2006/01/13 18:44:30 acg
996 // Added $Log to record CVS changes into the source.
997 //
998 // Revision 1.4 2006/01/03 23:18:44 acg
999 // Changed copyright to include 2006.
1000 //
1001 // Revision 1.3 2005/12/20 22:11:10 acg
1002 // Fixed $Log lines.
1003 //
1004 // Revision 1.2 2005/12/20 22:02:30 acg
1005 // Changed where delta cycles are incremented to match IEEE 1666. Added the
1006 // event_occurred() method to hide how delta cycle comparisions are done within
1007 // sc_simcontext. Changed the boolean update_phase to an enum that shows all
1008 // the phases.
1009 
1010 #endif
const sc_time & time_stamp() const
Registry for all exports.
Definition: sc_export.h:227
SC_API const sc_time SC_ZERO_TIME
sc_process_b * sc_get_current_process_b()
bool write_check() const
SC_API sc_event * sc_find_event(const char *name)
void set_error(sc_report *)
const char * get_hierarchical_name(const sc_object *parent, const std::string &name)
Process base class support.
SC_API bool sc_is_unwinding()
sc_status get_status() const
SC_API sc_time sc_get_default_time_unit()
sc_curr_proc_kind
Definition: sc_process.h:72
Registry for all ports.
Definition: sc_port.h:208
SC_API bool sc_pending_activity_at_future_time(const sc_simcontext *)
SC_API sc_stop_mode sc_get_stop_mode()
Abstract base class of all SystemC `simulation&#39; objects.
Definition: sc_object.h:61
SC_API double sc_simulation_time()
const char * sc_get_hierarchical_name(const char *name)
bool hierarchical_name_exists(const sc_object *parent, const std::string &name)
bool elaboration_done() const
SC_API const sc_time & sc_max_time()
sc_port_registry * get_port_registry()
sc_curr_proc_handle get_curr_proc_info()
bool sc_hierarchical_name_exists(const char *name)
SC_API void sc_initialize()
sc_cor_pkg * cor_pkg()
bool pending_activity_at_current_time() const
initialization, evaluation or update
Definition: sc_status.h:57
Definition of the simulation phases.
Struct that holds the time resolution and default time unit.
Definition: sc_time.h:451
The clock channel.
Definition: sc_clock.h:49
The event class.
Definition: sc_event.h:256
bool sc_unregister_hierarchical_name(const char *name)
bool sc_register_hierarchical_name(const char *name)
SC_API sc_dt::uint64 sc_delta_count()
SC_API const std::vector< sc_object * > & sc_get_top_level_objects(const sc_simcontext *simc_p)
sc_curr_proc_kind sc_get_curr_process_kind()
sc_object_manager * get_object_manager()
SC_API void sc_start()
uint64_t uint64
Definition: sc_nbdefs.h:189
SC_API const sc_time & sc_time_stamp()
Registry for all primitive channels.
SC_API sc_simcontext * sc_curr_simcontext
SC_API bool sc_is_running(const sc_simcontext *simc_p)
bool unregister_hierarchical_name(const sc_object *parent, const std::string &name)
const int SC_SIM_ERROR
Definition: sc_status.h:45
int sc_get_simulator_status()
SC_API bool sc_pending_activity_at_current_time(const sc_simcontext *)
Manager of objects.
Coroutine abstract base class.
Definition: sc_cor.h:61
SC_API sc_time sc_time_to_pending_activity(const sc_simcontext *)
sc_curr_proc_kind kind
Definition: sc_simcontext.h:85
Unique name generator class.
Definition: sc_name_gen.h:48
SC_API void sc_pause()
Base class for all structural entities.
Definition: sc_module.h:83
sc_module_registry * get_module_registry()
class SC_API sc_event
Definition: sc_interface.h:40
bool evaluation_phase() const
bool sc_pending_activity(const sc_simcontext *simc_p=sc_get_curr_simcontext())
sc_dt::uint64 delta_count_at_current_time() const
void(sc_process_host::* SC_ENTRY_FUNC)()
Definition: sc_process.h:152
const int SC_SIM_OK
Definition: sc_status.h:44
SC_API void sc_set_stop_mode(sc_stop_mode mode)
The time class.
bool notify_phase() const
Exception reporting.
Definition: sc_report.h:121
void sc_thread_cor_fn(void *arg)
SC_API void sc_set_time_resolution(double, sc_time_unit)
SC_API void sc_set_random_seed(unsigned int seed_)
sc_object * sc_get_current_object()
SC_API sc_dt::uint64 sc_delta_count_at_current_time()
sc_dt::uint64 change_stamp() const
Registry for all modules.
bool event_occurred(sc_dt::uint64 last_change_count) const
The simulation context.
sc_plist< sc_process_b *> sc_process_list
Definition: sc_simcontext.h:79
class SC_API sc_module
Definition: sc_object.h:48
class SC_API sc_trace_file
Definition: sc_object.h:52
const sc_time & max_time() const
bool update_phase() const
SC_API bool sc_start_of_simulation_invoked()
const int SC_SIM_USER_STOP
Definition: sc_status.h:46
Coroutine package abstract base class.
Definition: sc_cor.h:90
sc_object * active_object()
bool register_hierarchical_name(const sc_object *parent, const std::string &name)
The time class.
Definition: sc_time.h:82
const sc_curr_proc_info * sc_curr_proc_handle
Definition: sc_simcontext.h:89
SC_API const char * sc_gen_unique_name(const char *, bool preserve_first)
SC_API bool sc_allow_process_control_corners
when scheduler stopped by sc_pause()
Definition: sc_status.h:58
SC_API sc_process_b * sc_get_curr_process_handle()
SC_API sc_time sc_get_time_resolution()
sc_prim_channel_registry * get_prim_channel_registry()
class sc_thread_process * sc_thread_handle
Definition: sc_process.h:67
class sc_method_process * sc_method_handle
Definition: sc_process.h:66
static sc_time from_value(value_type)
SC_API const std::vector< sc_event * > & sc_get_top_level_events(const sc_simcontext *simc_p)
sc_simcontext * sc_get_curr_simcontext()
SC_API sc_object * sc_find_object(const char *name)
sc_process_b * process_handle
Definition: sc_simcontext.h:84
sc_export_registry * get_export_registry()
SC_API void sc_stop()
sc_status sc_get_status()
SC_API sc_simcontext * sc_default_global_context
SC_API sc_process_handle sc_get_current_process_handle()
sc_process_b * get_current_writer() const
class SC_API sc_simcontext
Definition: sc_object.h:51
Abstract base class of all primitive channel classes.
SC_API void sc_set_default_time_unit(double, sc_time_unit)
static const uint64 UINT64_ZERO
Definition: sc_nbdefs.h:197
#define SC_API
Definition: sc_cmnhdr.h:168
sc_time_unit
Enumeration of time units.
Definition: sc_time.h:64
sc_starvation_policy
Definition: sc_simcontext.h:98
bool next_time(sc_time &t) const
SC_API bool sc_end_of_simulation_invoked()
A simple priority queue (which can be used to model multiple.