SystemC  2.3.1
Accellera SystemC proof-of-concept library
sc_process.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  The following code is derived, directly or indirectly, from the SystemC
4  source code Copyright (c) 1996-2014 by all Contributors.
5  All Rights reserved.
6 
7  The contents of this file are subject to the restrictions and limitations
8  set forth in the SystemC Open Source License (the "License");
9  You may not use this file except in compliance with such restrictions and
10  limitations. You may obtain instructions on how to receive a copy of the
11  License at http://www.accellera.org/. Software distributed by Contributors
12  under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
13  ANY KIND, either express or implied. See the License for the specific
14  language governing rights and limitations under the License.
15 
16  *****************************************************************************/
17 
18 /*****************************************************************************
19 
20  sc_process.h -- Process base class support.
21 
22  Original Author: Andy Goodrich, Forte Design Systems, 04 August 2005
23 
24 
25  CHANGE LOG AT THE END OF THE FILE
26  *****************************************************************************/
27 
28 
29 #if !defined(sc_process_h_INCLUDED)
30 #define sc_process_h_INCLUDED
31 
32 #include <cassert>
33 #include "sysc/utils/sc_iostream.h"
35 #include "sysc/kernel/sc_object.h"
38 
39 namespace sc_core {
40 
41 // Forward declarations:
42 class sc_process_handle;
43 class sc_thread_process;
44 class sc_reset;
45 
46 const char* sc_gen_unique_name( const char*, bool preserve_first );
47 sc_process_handle sc_get_current_process_handle();
48 void sc_thread_cor_fn( void* arg );
49 bool timed_out( sc_simcontext* );
50 
51 extern bool sc_allow_process_control_corners; // see sc_simcontext.cpp.
52 
53 
54 // Process handles as forward references:
55 
59 
60 
61 // Standard process types:
62 
64 {
69 };
70 
71 // Descendant information for process hierarchy operations:
72 
77 };
78 
79 //==============================================================================
80 // CLASS sc_process_host
81 //
82 // This is the base class for objects which may have processes defined for
83 // their methods (e.g., sc_module)
84 //==============================================================================
85 
87 {
88  public:
90  virtual ~sc_process_host() { } // Needed for cast check for sc_module.
91  void defunct() {}
92 };
93 
94 
95 //==============================================================================
96 // CLASS sc_process_monitor
97 //
98 // This class provides a way of monitoring a process' status (e.g., waiting
99 // for a thread to complete its execution.) This class is intended to be a base
100 // class for classes which need to monitor a process or processes (e.g.,
101 // sc_join.) Its methods should be overloaded where notifications are desired.
102 //==============================================================================
103 
105  public:
106  enum {
108  };
109  virtual ~sc_process_monitor() {}
110  virtual void signal(sc_thread_handle thread_p, int type);
111 };
113 
114 //------------------------------------------------------------------------------
115 // PROCESS INVOCATION METHOD OR FUNCTION:
116 //
117 // Define SC_USE_MEMBER_FUNC_PTR if we want to use member function pointers
118 // to implement process dispatch. Otherwise, we'll use a hack that involves
119 // creating a templated invocation object which will invoke the member
120 // function. This should not be necessary, but some compilers (e.g., VC++)
121 // do not allow the conversion from `void (callback_tag::*)()' to
122 // `void (sc_process_host::*)()'. This is supposed to be OK as long as the
123 // dynamic type is correct. C++ Standard 5.4 "Explicit type conversion",
124 // clause 7: a pointer to member of derived class type may be explicitly
125 // converted to a pointer to member of an unambiguous non-virtual base class
126 // type.
127 //-----------------------------------------------------------------------------
128 
129 #if defined(_MSC_VER)
130 #if ( _MSC_VER > 1200 )
131 # define SC_USE_MEMBER_FUNC_PTR
132 #endif
133 #else
134 # define SC_USE_MEMBER_FUNC_PTR
135 #endif
136 
137 
138 // COMPILER DOES SUPPORT CAST TO void (sc_process_host::*)() from (T::*)():
139 
140 #if defined(SC_USE_MEMBER_FUNC_PTR)
141 
142  typedef void (sc_process_host::*SC_ENTRY_FUNC)();
143 # define SC_DECL_HELPER_STRUCT(callback_tag, func) /*EMPTY*/
144 # define SC_MAKE_FUNC_PTR(callback_tag, func) \
145  static_cast<sc_core::SC_ENTRY_FUNC>(&callback_tag::func)
146 
147 
148 // COMPILER NOT DOES SUPPORT CAST TO void (sc_process_host::*)() from (T::*)():
149 
150 #else // !defined(SC_USE_MEMBER_FUNC_PTR)
151  class sc_process_call_base {
152  public:
153  inline sc_process_call_base()
154  {
155  }
156 
157  virtual ~sc_process_call_base()
158  {
159  }
160 
161  virtual void invoke(sc_process_host* host_p)
162  {
163  }
164  };
165  extern sc_process_call_base sc_process_defunct;
166 
167  template<class T>
168  class sc_process_call : public sc_process_call_base {
169  public:
170  sc_process_call( void (T::*method_p)() ) :
171  sc_process_call_base()
172  {
173  m_method_p = method_p;
174  }
175 
176  virtual ~sc_process_call()
177  {
178  }
179 
180  virtual void invoke(sc_process_host* host_p)
181  {
182  (((T*)host_p)->*m_method_p)();
183  }
184 
185  protected:
186  void (T::*m_method_p)(); // Method implementing the process.
187  };
188 
189  typedef sc_process_call_base* SC_ENTRY_FUNC;
190 # define SC_DECL_HELPER_STRUCT(callback_tag, func) /*EMPTY*/
191 # define SC_MAKE_FUNC_PTR(callback_tag, func) \
192  (::sc_core::SC_ENTRY_FUNC) (new \
193  ::sc_core::sc_process_call<callback_tag>(&callback_tag::func))
194 
195 #endif // !defined(SC_USE_MEMBER_FUNC_PTR)
196 
197 
198 extern void sc_set_stack_size( sc_thread_handle, std::size_t );
199 
200 class sc_event;
201 class sc_event_list;
202 class sc_name_gen;
203 class sc_spawn_options;
204 class sc_unwind_exception;
205 
206 //==============================================================================
207 // CLASS sc_throw_it<EXCEPT> - ARBITRARY EXCEPTION CLASS
208 //
209 // This class serves as a way of throwing an execption for an aribtrary type
210 // without knowing what that type is. A true virtual method in the base
211 // class is used to actually throw the execption. A pointer to the base
212 // class is used internally removing the necessity of knowing what the type
213 // of EXCEPT is for code internal to the library.
214 //
215 // Note the clone() true virtual method. This is used to allow instances
216 // of the sc_throw_it<EXCEPT> class to be easily garbage collected. Since
217 // an exception may be propogated to more than one process knowing when
218 // to garbage collect is non-trivial. So when a call is made to
219 // sc_process_handle::throw_it() an instance of sc_throw_it<EXCEPT> is
220 // allocated on the stack. For each process throwing the exception a copy is
221 // made via clone(). That allows those objects to be deleted by the individual
222 // processes when they are no longer needed (in this implementation of SystemC
223 // that deletion will occur each time a new exception is thrown ( see
224 // sc_thread_process::suspend_me() ).
225 //==============================================================================
227  public:
228  virtual sc_throw_it_helper* clone() const = 0;
229  virtual void throw_it() = 0;
231  virtual ~sc_throw_it_helper() {}
232 };
233 
234 template<typename EXCEPT>
236 {
238  public:
239  sc_throw_it( const EXCEPT& value ) : m_value(value) { }
240  virtual ~sc_throw_it() {}
241  virtual inline this_type* clone() const { return new this_type(m_value); }
242  virtual inline void throw_it() { throw m_value; }
243  protected:
244  EXCEPT m_value; // value to be thrown.
245 };
246 
247 //==============================================================================
248 // CLASS sc_process_b - USER INITIATED DYNAMIC PROCESS SUPPORT:
249 //
250 // This class implements the base class for a threaded process_base process
251 // whose semantics are provided by the true virtual method semantics().
252 // Classes derived from this one will provide a version of semantics which
253 // implements the desired semantics. See the sc_spawn_xxx classes below.
254 //
255 // Notes:
256 // (1) Object instances of this class maintain a reference count of
257 // outstanding handles. When the handle count goes to zero the
258 // object will be deleted.
259 // (2) Descriptions of the methods and operators in this class appear with
260 // their implementations.
261 // (3) The m_sticky_reset field is used to handle synchronous resets that
262 // are enabled via the sc_process_handle::sync_reset_on() method. These
263 // resets are not generated by a signal, but rather are modal by
264 // method call: sync_reset_on - sync_reset_off.
265 //
266 //==============================================================================
267 class sc_process_b : public sc_object {
268  friend class sc_simcontext; // Allow static processes to have base.
269  friend class sc_cthread_process; // Child can access parent.
270  friend class sc_method_process; // Child can access parent.
271  friend class sc_process_handle; // Allow handles to modify ref. count.
272  friend class sc_thread_process; // Child can access parent.
273 
274  friend class sc_object;
275  friend class sc_port_base;
276  friend class sc_runnable;
277  friend class sc_sensitive;
278  friend class sc_sensitive_pos;
279  friend class sc_sensitive_neg;
280  friend class sc_module;
281  friend class sc_report_handler;
282  friend class sc_reset;
283  friend class sc_reset_finder;
284  friend class sc_unwind_exception;
285 
286  friend const char* sc_gen_unique_name( const char*, bool preserve_first );
288  friend void sc_thread_cor_fn( void* arg );
289  friend bool timed_out( sc_simcontext* );
290 
291  public:
298  };
299 
301  ps_bit_disabled = 1, // process is disabled.
302  ps_bit_ready_to_run = 2, // process is ready to run.
303  ps_bit_suspended = 4, // process is suspended.
304  ps_bit_zombie = 8, // process is a zombie.
305  ps_normal = 0 // must be zero.
306  };
307 
308  enum reset_type { // types for sc_process_b::reset_process()
309  reset_asynchronous = 0, // asynchronous reset.
310  reset_synchronous_off, // turn off synchronous reset sticky bit.
311  reset_synchronous_on // turn on synchronous reset sticky bit.
312  };
313 
315  {
324  };
325 
326  public:
327  sc_process_b( const char* name_p, bool is_thread, bool free_host,
328  SC_ENTRY_FUNC method_p, sc_process_host* host_p,
329  const sc_spawn_options* opt_p );
330 
331  protected:
332  // may not be deleted manually (called from destroy_process())
333  virtual ~sc_process_b();
334 
335  public:
336  inline int current_state() { return m_state; }
337  bool dont_initialize() const { return m_dont_init; }
338  virtual void dont_initialize( bool dont );
339  std::string dump_state() const;
340  const ::std::vector<sc_object*>& get_child_objects() const;
341  inline sc_curr_proc_kind proc_kind() const;
344 
345  public:
347 
348  protected:
349  virtual void add_child_object( sc_object* );
350  void add_static_event( const sc_event& );
351  bool dynamic() const { return m_dynamic_proc; }
352  const char* gen_unique_name( const char* basename_, bool preserve_first );
354  inline bool is_disabled() const;
355  inline bool is_runnable() const;
356  static inline sc_process_b* last_created_process_base();
357  virtual bool remove_child_object( sc_object* );
358  void remove_dynamic_events( bool skip_timeout = false );
359  void remove_static_events();
360  inline void set_last_report( sc_report* last_p )
361  {
362  delete m_last_report_p;
363  m_last_report_p = last_p;
364  }
365  inline bool timed_out() const;
366  void report_error( const char* msgid, const char* msg = "" ) const;
368 
369  protected: // process control methods:
370  virtual void disable_process(
372  void disconnect_process();
373  virtual void enable_process(
375  inline void initially_in_reset( bool async );
376  inline bool is_unwinding() const;
377  inline bool start_unwinding();
378  inline bool clear_unwinding();
379  virtual void kill_process(
381  void reset_changed( bool async, bool asserted );
382  void reset_process( reset_type rt,
384  virtual void resume_process(
386  virtual void suspend_process(
388  virtual void throw_user( const sc_throw_it_helper& helper,
390  virtual void throw_reset( bool async ) = 0;
391  virtual bool terminated() const;
392  void trigger_reset_event();
393 
394  private:
395  void delete_process();
396  inline void reference_decrement();
397  inline void reference_increment();
398 
399  protected:
400  inline void semantics();
401 
402  // debugging stuff:
403 
404  public:
405  const char* file;
406  int lineno;
407  int proc_id;
408 
409  protected:
410  int m_active_areset_n; // number of aresets active.
411  int m_active_reset_n; // number of resets active.
412  bool m_dont_init; // true: no initialize call.
413  bool m_dynamic_proc; // true: after elaboration.
414  const sc_event* m_event_p; // Dynamic event waiting on.
415  int m_event_count; // number of events.
416  const sc_event_list* m_event_list_p; // event list waiting on.
417  sc_process_b* m_exist_p; // process existence link.
418  bool m_free_host; // free sc_semantic_host_p.
419  bool m_has_reset_signal; // has reset_signal_is.
420  bool m_has_stack; // true is stack present.
421  bool m_is_thread; // true if this is thread.
422  sc_report* m_last_report_p; // last report this process.
423  sc_name_gen* m_name_gen_p; // subprocess name generator
424  sc_curr_proc_kind m_process_kind; // type of process.
425  int m_references_n; // outstanding handles.
426  std::vector<sc_reset*> m_resets; // resets for process.
427  sc_event* m_reset_event_p; // reset event.
428  sc_event* m_resume_event_p; // resume event.
429  sc_process_b* m_runnable_p; // sc_runnable link
430  sc_process_host* m_semantics_host_p; // host for semantics.
431  SC_ENTRY_FUNC m_semantics_method_p; // method for semantics.
432  int m_state; // process state.
433  std::vector<const sc_event*> m_static_events; // static events waiting on.
434  bool m_sticky_reset; // see note 3 above.
435  sc_event* m_term_event_p; // terminated event.
437  process_throw_type m_throw_status; // exception throwing status
438  bool m_timed_out; // true if we timed out.
439  sc_event* m_timeout_event_p; // timeout event.
440  trigger_t m_trigger_type; // type of trigger using.
441  bool m_unwinding; // true if unwinding stack.
442 
443  protected:
444  static sc_process_b* m_last_created_process_p; // Last process created.
445 };
446 
447 typedef sc_process_b sc_process_b; // For compatibility.
448 
449 
450 //------------------------------------------------------------------------------
451 //"sc_process_b::XXXX_child_YYYYY"
452 //
453 // These methods provide child object support.
454 //------------------------------------------------------------------------------
455 inline void
457 {
458  sc_object::add_child_object( object_p );
459  reference_increment();
460 }
461 
462 inline bool
464 {
465  if ( sc_object::remove_child_object( object_p ) ) {
466  reference_decrement();
467  return true;
468  }
469  else
470  {
471  return false;
472  }
473 }
474 
475 inline const ::std::vector<sc_object*>&
477 {
478  return m_child_objects;
479 }
480 
481 
482 //------------------------------------------------------------------------------
483 //"sc_process_b::initially_in_reset"
484 //
485 // This inline method is a callback to indicate that a reset is active at
486 // start up. This is because the signal will have been initialized before
487 // a reset linkage for it is set up, so we won't get a reset_changed()
488 // callback.
489 // async = true if this an asynchronous reset.
490 //------------------------------------------------------------------------------
491 inline void sc_process_b::initially_in_reset( bool async )
492 {
493  if ( async )
495  else
497 }
498 
499 //------------------------------------------------------------------------------
500 //"sc_process_b::is_disabled"
501 //
502 // This method returns true if this process is disabled.
503 //------------------------------------------------------------------------------
504 inline bool sc_process_b::is_disabled() const
505 {
506  return (m_state & ps_bit_disabled) ? true : false;
507 }
508 
509 //------------------------------------------------------------------------------
510 //"sc_process_b::is_runnable"
511 //
512 // This method returns true if this process is runnable. That is indicated
513 // by a non-zero m_runnable_p field.
514 //------------------------------------------------------------------------------
515 inline bool sc_process_b::is_runnable() const
516 {
517  return m_runnable_p != 0;
518 }
519 
520 //------------------------------------------------------------------------------
521 //"sc_process_b::is_unwinding"
522 //
523 // This method returns true if this process is unwinding from a kill or reset.
524 //------------------------------------------------------------------------------
525 inline bool sc_process_b::is_unwinding() const
526 {
527  return m_unwinding;
528 }
529 
530 //------------------------------------------------------------------------------
531 //"sc_process_b::start_unwinding"
532 //
533 // This method flags that this object instance should start unwinding if the
534 // current throw status requires an unwind.
535 //
536 // Result is true if the flag is set, false if the flag is already set.
537 //------------------------------------------------------------------------------
539 {
540  if ( !m_unwinding )
541  {
542  switch( m_throw_status )
543  {
544  case THROW_KILL:
545  case THROW_ASYNC_RESET:
546  case THROW_SYNC_RESET:
547  m_unwinding = true;
548  return true;
549  case THROW_USER:
550  default:
551  break;
552  }
553  }
554  return false;
555 }
556 
557 //------------------------------------------------------------------------------
558 //"sc_process_b::clear_unwinding"
559 //
560 // This method clears this object instance's throw status and always returns
561 // true.
562 //------------------------------------------------------------------------------
564 {
565  m_unwinding = false;
566  return true;
567 }
568 
569 
570 //------------------------------------------------------------------------------
571 //"sc_process_b::last_created_process_base"
572 //
573 // This virtual method returns the sc_process_b pointer for the last
574 // created process. It is only used internally by the simulator.
575 //------------------------------------------------------------------------------
577 {
579 }
580 
581 
582 
583 //------------------------------------------------------------------------------
584 //"sc_process_b::proc_kind"
585 //
586 // This method returns the kind of this process.
587 //------------------------------------------------------------------------------
589 {
590  return m_process_kind;
591 }
592 
593 
594 //------------------------------------------------------------------------------
595 //"sc_process_b::reference_decrement"
596 //
597 // This inline method decrements the number of outstanding references to this
598 // object instance. If the number of references goes to zero, this object
599 // can be deleted in "sc_process_b::delete_process()".
600 //------------------------------------------------------------------------------
601 inline void sc_process_b::reference_decrement()
602 {
603  m_references_n--;
604  if ( m_references_n == 0 ) delete_process();
605 }
606 
607 
608 //------------------------------------------------------------------------------
609 //"sc_process_b::reference_increment"
610 //
611 // This inline method increments the number of outstanding references to this
612 // object instance.
613 //------------------------------------------------------------------------------
614 inline void sc_process_b::reference_increment()
615 {
616  assert(m_references_n != 0);
617  m_references_n++;
618 }
619 
620 //------------------------------------------------------------------------------
621 //"sc_process_b::semantics"
622 //
623 // This inline method invokes the semantics for this object instance.
624 // We check to see if we are initially in reset and then invoke the
625 // process semantics.
626 //
627 // Notes:
628 // (1) For a description of the process reset mechanism see the top of
629 // the file sc_reset.cpp.
630 //------------------------------------------------------------------------------
632 {
633  scoped_flag( bool& b ) : ref(b){ ref = true; }
634  ~scoped_flag() { ref = false; }
635  bool& ref;
636 };
638 {
639 
640  // within this function, the process has a stack associated
641 
642  scoped_flag scoped_stack_flag( m_has_stack );
643 
644  assert( m_process_kind != SC_NO_PROC_ );
645 
646  // Determine the reset status of this object instance and potentially
647  // trigger its notify event:
648 
649  // See if we need to trigger the notify event:
650 
651  if ( m_reset_event_p &&
654  ) {
656  }
657 
658  // Set the new reset status of this object based on the reset counts:
659 
662 
663  // Dispatch the actual semantics for the process:
664 
665 # ifndef SC_USE_MEMBER_FUNC_PTR
667 # else
669 # endif
670 }
671 
672 
673 //------------------------------------------------------------------------------
674 //"sc_process_b::terminated"
675 //
676 // This inline method returns true if this object has terminated.
677 //------------------------------------------------------------------------------
678 inline bool sc_process_b::terminated() const
679 {
680  return (m_state & ps_bit_zombie) != 0;
681 }
682 
683 
684 //------------------------------------------------------------------------------
685 //"sc_process_b::timed_out"
686 //
687 // This inline method returns true if this object instance timed out.
688 //------------------------------------------------------------------------------
689 inline bool sc_process_b::timed_out() const
690 {
691  return m_timed_out;
692 }
693 
694 } // namespace sc_core
695 
696 /*****************************************************************************
697 
698  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
699  changes you are making here.
700 
701  Name, Affiliation, Date: Andy Goodrich, Forte Design Systems, 12 Aug 05
702  Description of Modification: This is the rewrite of process support. It
703  contains some code from the original
704  sc_process.h by Stan Liao, and the now-defunct
705  sc_process_b.h by Stan Liao and Martin
706  Janssen, all of Synopsys, Inc., It also contains
707  code from the original sc_process_b.h by
708  Andy Goodrich of Forte Design Systems and
709  Bishnupriya Bhattacharya of Cadence Design
710  Systems.
711 
712  Name, Affiliation, Date:
713  Description of Modification:
714 
715  *****************************************************************************/
716 
717 // $Log: sc_process.h,v $
718 // Revision 1.36 2011/08/26 22:44:30 acg
719 // Torsten Maehne: eliminate unused argument warning.
720 //
721 // Revision 1.35 2011/08/26 20:46:10 acg
722 // Andy Goodrich: moved the modification log to the end of the file to
723 // eliminate source line number skew when check-ins are done.
724 //
725 // Revision 1.34 2011/08/24 22:05:51 acg
726 // Torsten Maehne: initialization changes to remove warnings.
727 //
728 // Revision 1.33 2011/08/15 16:43:24 acg
729 // Torsten Maehne: changes to remove unused argument warnings.
730 //
731 // Revision 1.32 2011/07/24 11:20:03 acg
732 // Philipp A. Hartmann: process control error message improvements:
733 // (1) Downgrade error to warning for re-kills of processes.
734 // (2) Add process name to process messages.
735 // (3) drop some superfluous colons in messages.
736 //
737 // Revision 1.31 2011/04/13 02:44:26 acg
738 // Andy Goodrich: added m_unwinding flag in place of THROW_NOW because the
739 // throw status will be set back to THROW_*_RESET if reset is active and
740 // the check for an unwind being complete was expecting THROW_NONE as the
741 // clearing of THROW_NOW.
742 //
743 // Revision 1.30 2011/04/11 22:07:27 acg
744 // Andy Goodrich: check for reset event notification before resetting the
745 // throw_status value.
746 //
747 // Revision 1.29 2011/04/10 22:17:36 acg
748 // Andy Goodrich: added trigger_reset_event() to allow sc_process.h to
749 // contain the run_process() inline method. sc_process.h cannot have
750 // sc_simcontext information because of recursive includes.
751 //
752 // Revision 1.28 2011/04/08 22:34:06 acg
753 // Andy Goodrich: moved the semantics() method to this file and made it
754 // an inline method. Added reset processing to the semantics() method.
755 //
756 // Revision 1.27 2011/04/08 18:24:48 acg
757 // Andy Goodrich: moved reset_changed() to .cpp since it needs visibility
758 // to sc_simcontext.
759 //
760 // Revision 1.26 2011/04/01 21:24:57 acg
761 // Andy Goodrich: removed unused code.
762 //
763 // Revision 1.25 2011/03/28 13:02:51 acg
764 // Andy Goodrich: Changes for disable() interactions.
765 //
766 // Revision 1.24 2011/03/20 13:43:23 acg
767 // Andy Goodrich: added async_signal_is() plus suspend() as a corner case.
768 //
769 // Revision 1.23 2011/03/12 21:07:51 acg
770 // Andy Goodrich: changes to kernel generated event support.
771 //
772 // Revision 1.22 2011/03/08 20:49:31 acg
773 // Andy Goodrich: implement coarse checking for synchronous reset - suspend
774 // interaction.
775 //
776 // Revision 1.21 2011/03/07 17:38:43 acg
777 // Andy Goodrich: tightening up of checks for undefined interaction between
778 // synchronous reset and suspend.
779 //
780 // Revision 1.20 2011/03/06 19:57:11 acg
781 // Andy Goodrich: refinements for the illegal suspend - synchronous reset
782 // interaction.
783 //
784 // Revision 1.19 2011/03/05 19:44:20 acg
785 // Andy Goodrich: changes for object and event naming and structures.
786 //
787 // Revision 1.18 2011/02/19 08:30:53 acg
788 // Andy Goodrich: Moved process queueing into trigger_static from
789 // sc_event::notify.
790 //
791 // Revision 1.17 2011/02/18 20:27:14 acg
792 // Andy Goodrich: Updated Copyrights.
793 //
794 // Revision 1.16 2011/02/18 20:10:44 acg
795 // Philipp A. Hartmann: force return expression to be a bool to keep MSVC
796 // happy.
797 //
798 // Revision 1.15 2011/02/17 19:52:45 acg
799 // Andy Goodrich:
800 // (1) Simplified process control usage.
801 // (2) Changed dump_status() to dump_state() with new signature.
802 //
803 // Revision 1.14 2011/02/16 22:37:30 acg
804 // Andy Goodrich: clean up to remove need for ps_disable_pending.
805 //
806 // Revision 1.13 2011/02/13 21:47:37 acg
807 // Andy Goodrich: update copyright notice.
808 //
809 // Revision 1.12 2011/02/13 21:41:34 acg
810 // Andy Goodrich: get the log messages for the previous check in correct.
811 //
812 // Revision 1.11 2011/02/13 21:32:24 acg
813 // Andy Goodrich: moved sc_process_b::reset_process() implementation
814 // from header to cpp file . Added dump_status() to print out the status of a
815 // process.
816 //
817 // Revision 1.10 2011/02/11 13:25:24 acg
818 // Andy Goodrich: Philipp A. Hartmann's changes:
819 // (1) Removal of SC_CTHREAD method overloads.
820 // (2) New exception processing code.
821 //
822 // Revision 1.9 2011/02/04 15:27:36 acg
823 // Andy Goodrich: changes for suspend-resume semantics.
824 //
825 // Revision 1.8 2011/02/01 21:06:12 acg
826 // Andy Goodrich: new layout for the process_state enum.
827 //
828 // Revision 1.7 2011/01/25 20:50:37 acg
829 // Andy Goodrich: changes for IEEE 1666 2011.
830 //
831 // Revision 1.6 2011/01/19 23:21:50 acg
832 // Andy Goodrich: changes for IEEE 1666 2011
833 //
834 // Revision 1.5 2011/01/18 20:10:45 acg
835 // Andy Goodrich: changes for IEEE1666_2011 semantics.
836 //
837 // Revision 1.4 2010/07/22 20:02:33 acg
838 // Andy Goodrich: bug fixes.
839 //
840 // Revision 1.3 2009/05/22 16:06:29 acg
841 // Andy Goodrich: process control updates.
842 //
843 // Revision 1.2 2008/05/22 17:06:26 acg
844 // Andy Goodrich: updated copyright notice to include 2008.
845 //
846 // Revision 1.1.1.1 2006/12/15 20:20:05 acg
847 // SystemC 2.3
848 //
849 // Revision 1.11 2006/05/08 17:58:10 acg
850 // Andy Goodrich: added David Long's forward declarations for friend
851 // functions, methods, and operators to keep the Microsoft compiler happy.
852 //
853 // Revision 1.10 2006/04/28 23:29:01 acg
854 // Andy Goodrich: added an sc_core:: prefix to SC_FUNC_PTR in the
855 // SC_MAKE_FUNC_PTR macro to allow its transpareuse outside of the sc_core
856 // namespace.
857 //
858 // Revision 1.9 2006/04/28 21:52:57 acg
859 // Andy Goodrich: changed SC_MAKE_FUNC_PTR to use a static cast to address
860 // and AIX issue wrt sc_module's inherited classes.
861 //
862 // Revision 1.8 2006/04/20 17:08:17 acg
863 // Andy Goodrich: 3.0 style process changes.
864 //
865 // Revision 1.7 2006/04/11 23:13:21 acg
866 // Andy Goodrich: Changes for reduced reset support that only includes
867 // sc_cthread, but has preliminary hooks for expanding to method and thread
868 // processes also.
869 //
870 // Revision 1.6 2006/03/13 20:26:50 acg
871 // Andy Goodrich: Addition of forward class declarations, e.g.,
872 // sc_reset, to keep gcc 4.x happy.
873 //
874 // Revision 1.5 2006/01/31 20:09:10 acg
875 // Andy Goodrich: added explaination of static vs dynamic waits to
876 // sc_process_b::trigger_static.
877 //
878 // Revision 1.4 2006/01/24 20:49:05 acg
879 // Andy Goodrich: changes to remove the use of deprecated features within the
880 // simulator, and to issue warning messages when deprecated features are used.
881 //
882 // Revision 1.3 2006/01/13 18:44:30 acg
883 // Added $Log to record CVS changes into the source.
884 
885 #endif // !defined(sc_process_h_INCLUDED)
bool is_disabled() const
Definition: sc_process.h:504
const sc_event * m_event_p
Definition: sc_process.h:414
virtual sc_throw_it_helper * clone() const =0
sc_report * get_last_report()
Definition: sc_process.h:353
sc_event & terminated_event()
virtual void throw_it()=0
bool sc_allow_process_control_corners
static sc_process_b * m_last_created_process_p
Definition: sc_process.h:444
virtual bool remove_child_object(sc_object *)
Definition: sc_process.h:463
const ::std::vector< sc_object * > & get_child_objects() const
Definition: sc_process.h:476
void(sc_process_host::* SC_ENTRY_FUNC)()
Definition: sc_process.h:142
virtual void throw_reset(bool async)=0
virtual void enable_process(sc_descendant_inclusion_info descendants=SC_NO_DESCENDANTS)=0
sc_clock period is zero sc_clock low time is zero sc_fifo< T > cannot have more than one writer bind interface to port failed complete binding failed remove port failed insert primitive channel failed sc_signal< T > cannot have more than one driver resolved port not bound to resolved signal sc_semaphore requires an initial value
uint64 const sc_uint_base int b
Definition: sc_fxval.h:1003
std::vector< sc_reset * > m_resets
Definition: sc_process.h:426
virtual void throw_it()
Definition: sc_process.h:242
const char * file
Definition: sc_process.h:405
virtual void throw_user(const sc_throw_it_helper &helper, sc_descendant_inclusion_info descendants=SC_NO_DESCENDANTS)=0
sc_process_b sc_process_b
Definition: sc_process.h:447
virtual void signal(sc_thread_handle thread_p, int type)
Definition: sc_process.h:112
virtual void add_child_object(sc_object *)
Definition: sc_process.h:456
void add_static_event(const sc_event &)
bool timed_out() const
Definition: sc_process.h:689
sc_process_b * m_runnable_p
Definition: sc_process.h:429
sc_event * m_resume_event_p
Definition: sc_process.h:428
virtual this_type * clone() const
Definition: sc_process.h:241
class sc_thread_process * sc_thread_handle
Definition: sc_process.h:58
const sc_event_list * m_event_list_p
Definition: sc_process.h:416
sc_event * m_timeout_event_p
Definition: sc_process.h:439
static sc_process_handle last_created_process_handle()
void report_immediate_self_notification() const
sc_curr_proc_kind m_process_kind
Definition: sc_process.h:424
friend sc_process_handle sc_get_current_process_handle()
sc_process_b(const char *name_p, bool is_thread, bool free_host, SC_ENTRY_FUNC method_p, sc_process_host *host_p, const sc_spawn_options *opt_p)
friend void sc_thread_cor_fn(void *arg)
void sc_set_stack_size(sc_method_handle, std::size_t)
virtual bool remove_child_object(sc_object *object_p)
void initially_in_reset(bool async)
Definition: sc_process.h:491
const char * sc_gen_unique_name(const char *, bool preserve_first)
sc_name_gen * m_name_gen_p
Definition: sc_process.h:423
virtual void resume_process(sc_descendant_inclusion_info descendants=SC_NO_DESCENDANTS)=0
friend const char * sc_gen_unique_name(const char *, bool preserve_first)
virtual void add_child_object(sc_object *object_p)
sc_event & reset_event()
virtual bool terminated() const
Definition: sc_process.h:678
const char * gen_unique_name(const char *basename_, bool preserve_first)
void reset_process(reset_type rt, sc_descendant_inclusion_info descendants=SC_NO_DESCENDANTS)
SC_ENTRY_FUNC m_semantics_method_p
Definition: sc_process.h:431
sc_throw_it_helper * m_throw_helper_p
Definition: sc_process.h:436
sc_curr_proc_kind
Definition: sc_process.h:63
bool timed_out(sc_simcontext *)
bool dynamic() const
Definition: sc_process.h:351
sc_descendant_inclusion_info
Definition: sc_process.h:73
std::vector< const sc_event * > m_static_events
Definition: sc_process.h:433
void sc_thread_cor_fn(void *arg)
sc_event * m_term_event_p
Definition: sc_process.h:435
void report_error(const char *msgid, const char *msg="") const
class sc_cthread_process * sc_cthread_handle
Definition: sc_process.h:56
sc_process_handle sc_get_current_process_handle()
void reset_changed(bool async, bool asserted)
virtual void kill_process(sc_descendant_inclusion_info descendants=SC_NO_DESCENDANTS)=0
friend class sc_reset_finder
Definition: sc_process.h:283
bool is_runnable() const
Definition: sc_process.h:515
class sc_method_process * sc_method_handle
Definition: sc_process.h:57
sc_curr_proc_kind proc_kind() const
Definition: sc_process.h:588
sc_throw_it(const EXCEPT &value)
Definition: sc_process.h:239
bool dont_initialize() const
Definition: sc_process.h:337
void remove_dynamic_events(bool skip_timeout=false)
virtual void suspend_process(sc_descendant_inclusion_info descendants=SC_NO_DESCENDANTS)=0
process_throw_type m_throw_status
Definition: sc_process.h:437
sc_report * m_last_report_p
Definition: sc_process.h:422
void set_last_report(sc_report *last_p)
Definition: sc_process.h:360
sc_process_host * m_semantics_host_p
Definition: sc_process.h:430
sc_event * m_reset_event_p
Definition: sc_process.h:427
trigger_t m_trigger_type
Definition: sc_process.h:440
virtual void disable_process(sc_descendant_inclusion_info descendants=SC_NO_DESCENDANTS)=0
virtual ~sc_throw_it()
Definition: sc_process.h:240
bool is_unwinding() const
Definition: sc_process.h:525
std::string dump_state() const
static sc_process_b * last_created_process_base()
Definition: sc_process.h:576
virtual ~sc_process_host()
Definition: sc_process.h:90
sc_process_b * m_exist_p
Definition: sc_process.h:417