112027Sjungma@eit.uni-kl.de/*****************************************************************************
212027Sjungma@eit.uni-kl.de
312027Sjungma@eit.uni-kl.de  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
412027Sjungma@eit.uni-kl.de  more contributor license agreements.  See the NOTICE file distributed
512027Sjungma@eit.uni-kl.de  with this work for additional information regarding copyright ownership.
612027Sjungma@eit.uni-kl.de  Accellera licenses this file to you under the Apache License, Version 2.0
712027Sjungma@eit.uni-kl.de  (the "License"); you may not use this file except in compliance with the
812027Sjungma@eit.uni-kl.de  License.  You may obtain a copy of the License at
912027Sjungma@eit.uni-kl.de
1012027Sjungma@eit.uni-kl.de    http://www.apache.org/licenses/LICENSE-2.0
1112027Sjungma@eit.uni-kl.de
1212027Sjungma@eit.uni-kl.de  Unless required by applicable law or agreed to in writing, software
1312027Sjungma@eit.uni-kl.de  distributed under the License is distributed on an "AS IS" BASIS,
1412027Sjungma@eit.uni-kl.de  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
1512027Sjungma@eit.uni-kl.de  implied.  See the License for the specific language governing
1612027Sjungma@eit.uni-kl.de  permissions and limitations under the License.
1712027Sjungma@eit.uni-kl.de
1812027Sjungma@eit.uni-kl.de *****************************************************************************/
1912027Sjungma@eit.uni-kl.de
2012027Sjungma@eit.uni-kl.de/*****************************************************************************
2112027Sjungma@eit.uni-kl.de
2212027Sjungma@eit.uni-kl.de  sc_process.h -- Process base class support.
2312027Sjungma@eit.uni-kl.de
2412027Sjungma@eit.uni-kl.de  Original Author: Andy Goodrich, Forte Design Systems, 04 August 2005
2512027Sjungma@eit.uni-kl.de
2612027Sjungma@eit.uni-kl.de
2712027Sjungma@eit.uni-kl.de  CHANGE LOG AT THE END OF THE FILE
2812027Sjungma@eit.uni-kl.de *****************************************************************************/
2912027Sjungma@eit.uni-kl.de
3012027Sjungma@eit.uni-kl.de
3112027Sjungma@eit.uni-kl.de#if !defined(sc_process_h_INCLUDED)
3212027Sjungma@eit.uni-kl.de#define sc_process_h_INCLUDED
3312027Sjungma@eit.uni-kl.de
3412027Sjungma@eit.uni-kl.de#include <cassert>
3512027Sjungma@eit.uni-kl.de#include "sysc/utils/sc_iostream.h"
3612027Sjungma@eit.uni-kl.de#include "sysc/kernel/sc_constants.h"
3712027Sjungma@eit.uni-kl.de#include "sysc/kernel/sc_object.h"
3812027Sjungma@eit.uni-kl.de#include "sysc/kernel/sc_kernel_ids.h"
3912027Sjungma@eit.uni-kl.de#include "sysc/communication/sc_export.h"
4012027Sjungma@eit.uni-kl.de
4112027Sjungma@eit.uni-kl.denamespace sc_core {
4212027Sjungma@eit.uni-kl.de
4312027Sjungma@eit.uni-kl.de// Forward declarations:
4412027Sjungma@eit.uni-kl.declass sc_process_handle;
4512027Sjungma@eit.uni-kl.declass sc_thread_process;
4612027Sjungma@eit.uni-kl.declass sc_reset;
4712027Sjungma@eit.uni-kl.de
4812027Sjungma@eit.uni-kl.deconst char* sc_gen_unique_name( const char*, bool preserve_first );
4912027Sjungma@eit.uni-kl.desc_process_handle sc_get_current_process_handle();
5012027Sjungma@eit.uni-kl.devoid sc_thread_cor_fn( void* arg );
5112027Sjungma@eit.uni-kl.debool timed_out( sc_simcontext* );
5212027Sjungma@eit.uni-kl.de
5312027Sjungma@eit.uni-kl.deextern bool sc_allow_process_control_corners; // see sc_simcontext.cpp.
5412027Sjungma@eit.uni-kl.de
5512027Sjungma@eit.uni-kl.de
5612027Sjungma@eit.uni-kl.de// Process handles as forward references:
5712027Sjungma@eit.uni-kl.de
5812027Sjungma@eit.uni-kl.detypedef class sc_cthread_process* sc_cthread_handle;
5912027Sjungma@eit.uni-kl.detypedef class sc_method_process*  sc_method_handle;
6012027Sjungma@eit.uni-kl.detypedef class sc_thread_process*  sc_thread_handle;
6112027Sjungma@eit.uni-kl.de
6212027Sjungma@eit.uni-kl.de
6312027Sjungma@eit.uni-kl.de// Standard process types:
6412027Sjungma@eit.uni-kl.de
6512027Sjungma@eit.uni-kl.deenum sc_curr_proc_kind
6612027Sjungma@eit.uni-kl.de{
6712027Sjungma@eit.uni-kl.de    SC_NO_PROC_,
6812027Sjungma@eit.uni-kl.de    SC_METHOD_PROC_,
6912027Sjungma@eit.uni-kl.de    SC_THREAD_PROC_,
7012027Sjungma@eit.uni-kl.de    SC_CTHREAD_PROC_
7112027Sjungma@eit.uni-kl.de};
7212027Sjungma@eit.uni-kl.de
7312027Sjungma@eit.uni-kl.de// Descendant information for process hierarchy operations:
7412027Sjungma@eit.uni-kl.de
7512027Sjungma@eit.uni-kl.deenum sc_descendant_inclusion_info {
7612027Sjungma@eit.uni-kl.de    SC_NO_DESCENDANTS=0,
7712027Sjungma@eit.uni-kl.de    SC_INCLUDE_DESCENDANTS,
7812027Sjungma@eit.uni-kl.de    SC_INVALID_DESCENDANTS
7912027Sjungma@eit.uni-kl.de};
8012027Sjungma@eit.uni-kl.de
8112027Sjungma@eit.uni-kl.de//==============================================================================
8212027Sjungma@eit.uni-kl.de// CLASS sc_process_host
8312027Sjungma@eit.uni-kl.de//
8412027Sjungma@eit.uni-kl.de// This is the base class for objects which may have processes defined for
8512027Sjungma@eit.uni-kl.de// their methods (e.g., sc_module)
8612027Sjungma@eit.uni-kl.de//==============================================================================
8712027Sjungma@eit.uni-kl.de
8812027Sjungma@eit.uni-kl.declass sc_process_host
8912027Sjungma@eit.uni-kl.de{
9012027Sjungma@eit.uni-kl.de  public:
9112027Sjungma@eit.uni-kl.de    sc_process_host() {}
9212027Sjungma@eit.uni-kl.de    virtual ~sc_process_host() { } // Needed for cast check for sc_module.
9312027Sjungma@eit.uni-kl.de    void defunct() {}
9412027Sjungma@eit.uni-kl.de};
9512027Sjungma@eit.uni-kl.de
9612027Sjungma@eit.uni-kl.de
9712027Sjungma@eit.uni-kl.de//==============================================================================
9812027Sjungma@eit.uni-kl.de// CLASS sc_process_monitor
9912027Sjungma@eit.uni-kl.de//
10012027Sjungma@eit.uni-kl.de// This class provides a way of monitoring a process' status (e.g., waiting
10112027Sjungma@eit.uni-kl.de// for a thread to complete its execution.) This class is intended to be a base
10212027Sjungma@eit.uni-kl.de// class for classes which need to monitor a process or processes (e.g.,
10312027Sjungma@eit.uni-kl.de// sc_join.) Its methods should be overloaded where notifications are desired.
10412027Sjungma@eit.uni-kl.de//==============================================================================
10512027Sjungma@eit.uni-kl.de
10612027Sjungma@eit.uni-kl.declass sc_process_monitor {
10712027Sjungma@eit.uni-kl.de  public:
10812027Sjungma@eit.uni-kl.de    enum {
10912027Sjungma@eit.uni-kl.de        spm_exit = 0
11012027Sjungma@eit.uni-kl.de    };
11112027Sjungma@eit.uni-kl.de    virtual ~sc_process_monitor() {}
11212027Sjungma@eit.uni-kl.de    virtual void signal(sc_thread_handle thread_p, int type);
11312027Sjungma@eit.uni-kl.de};
11412027Sjungma@eit.uni-kl.deinline void sc_process_monitor::signal(sc_thread_handle , int ) {}
11512027Sjungma@eit.uni-kl.de
11612027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
11712027Sjungma@eit.uni-kl.de// PROCESS INVOCATION METHOD OR FUNCTION:
11812027Sjungma@eit.uni-kl.de//
11912027Sjungma@eit.uni-kl.de//  Define SC_USE_MEMBER_FUNC_PTR if we want to use member function pointers
12012027Sjungma@eit.uni-kl.de//  to implement process dispatch. Otherwise, we'll use a hack that involves
12112027Sjungma@eit.uni-kl.de//  creating a templated invocation object which will invoke the member
12212027Sjungma@eit.uni-kl.de//  function. This should not be necessary, but some compilers (e.g., VC++)
12312027Sjungma@eit.uni-kl.de//  do not allow the conversion from `void (callback_tag::*)()' to
12412027Sjungma@eit.uni-kl.de//  `void (sc_process_host::*)()'. This is supposed to be OK as long as the
12512027Sjungma@eit.uni-kl.de//  dynamic type is correct.  C++ Standard 5.4 "Explicit type conversion",
12612027Sjungma@eit.uni-kl.de//  clause 7: a pointer to member of derived class type may be explicitly
12712027Sjungma@eit.uni-kl.de//  converted to a pointer to member of an unambiguous non-virtual base class
12812027Sjungma@eit.uni-kl.de//  type.
12912027Sjungma@eit.uni-kl.de//-----------------------------------------------------------------------------
13012027Sjungma@eit.uni-kl.de
13112027Sjungma@eit.uni-kl.de#if defined(_MSC_VER)
13212027Sjungma@eit.uni-kl.de#if ( _MSC_VER > 1200 )
13312027Sjungma@eit.uni-kl.de#   define SC_USE_MEMBER_FUNC_PTR
13412027Sjungma@eit.uni-kl.de#endif
13512027Sjungma@eit.uni-kl.de#else
13612027Sjungma@eit.uni-kl.de#   define SC_USE_MEMBER_FUNC_PTR
13712027Sjungma@eit.uni-kl.de#endif
13812027Sjungma@eit.uni-kl.de
13912027Sjungma@eit.uni-kl.de
14012027Sjungma@eit.uni-kl.de// COMPILER DOES SUPPORT CAST TO void (sc_process_host::*)() from (T::*)():
14112027Sjungma@eit.uni-kl.de
14212027Sjungma@eit.uni-kl.de#if defined(SC_USE_MEMBER_FUNC_PTR)
14312027Sjungma@eit.uni-kl.de
14412027Sjungma@eit.uni-kl.de    typedef void (sc_process_host::*SC_ENTRY_FUNC)();
14512027Sjungma@eit.uni-kl.de#   define SC_DECL_HELPER_STRUCT(callback_tag, func) /*EMPTY*/
14612027Sjungma@eit.uni-kl.de#   define SC_MAKE_FUNC_PTR(callback_tag, func) \
14712027Sjungma@eit.uni-kl.de        static_cast<sc_core::SC_ENTRY_FUNC>(&callback_tag::func)
14812027Sjungma@eit.uni-kl.de
14912027Sjungma@eit.uni-kl.de
15012027Sjungma@eit.uni-kl.de// COMPILER NOT DOES SUPPORT CAST TO void (sc_process_host::*)() from (T::*)():
15112027Sjungma@eit.uni-kl.de
15212027Sjungma@eit.uni-kl.de#else // !defined(SC_USE_MEMBER_FUNC_PTR)
15312027Sjungma@eit.uni-kl.de    class sc_process_call_base {
15412027Sjungma@eit.uni-kl.de      public:
15512027Sjungma@eit.uni-kl.de        inline sc_process_call_base()
15612027Sjungma@eit.uni-kl.de        {
15712027Sjungma@eit.uni-kl.de        }
15812027Sjungma@eit.uni-kl.de
15912027Sjungma@eit.uni-kl.de        virtual ~sc_process_call_base()
16012027Sjungma@eit.uni-kl.de        {
16112027Sjungma@eit.uni-kl.de        }
16212027Sjungma@eit.uni-kl.de
16312027Sjungma@eit.uni-kl.de        virtual void invoke(sc_process_host* host_p)
16412027Sjungma@eit.uni-kl.de        {
16512027Sjungma@eit.uni-kl.de        }
16612027Sjungma@eit.uni-kl.de    };
16712027Sjungma@eit.uni-kl.de    extern sc_process_call_base sc_process_defunct;
16812027Sjungma@eit.uni-kl.de
16912027Sjungma@eit.uni-kl.de    template<class T>
17012027Sjungma@eit.uni-kl.de    class sc_process_call : public sc_process_call_base {
17112027Sjungma@eit.uni-kl.de      public:
17212027Sjungma@eit.uni-kl.de        sc_process_call( void (T::*method_p)() ) :
17312027Sjungma@eit.uni-kl.de            sc_process_call_base()
17412027Sjungma@eit.uni-kl.de        {
17512027Sjungma@eit.uni-kl.de             m_method_p = method_p;
17612027Sjungma@eit.uni-kl.de        }
17712027Sjungma@eit.uni-kl.de
17812027Sjungma@eit.uni-kl.de        virtual ~sc_process_call()
17912027Sjungma@eit.uni-kl.de        {
18012027Sjungma@eit.uni-kl.de        }
18112027Sjungma@eit.uni-kl.de
18212027Sjungma@eit.uni-kl.de        virtual void invoke(sc_process_host* host_p)
18312027Sjungma@eit.uni-kl.de        {
18412027Sjungma@eit.uni-kl.de            (((T*)host_p)->*m_method_p)();
18512027Sjungma@eit.uni-kl.de        }
18612027Sjungma@eit.uni-kl.de
18712027Sjungma@eit.uni-kl.de      protected:
18812027Sjungma@eit.uni-kl.de        void (T::*m_method_p)();  // Method implementing the process.
18912027Sjungma@eit.uni-kl.de    };
19012027Sjungma@eit.uni-kl.de
19112027Sjungma@eit.uni-kl.de    typedef sc_process_call_base* SC_ENTRY_FUNC;
19212027Sjungma@eit.uni-kl.de#   define SC_DECL_HELPER_STRUCT(callback_tag, func) /*EMPTY*/
19312027Sjungma@eit.uni-kl.de#   define SC_MAKE_FUNC_PTR(callback_tag, func) \
19412027Sjungma@eit.uni-kl.de        (::sc_core::SC_ENTRY_FUNC) (new \
19512027Sjungma@eit.uni-kl.de        ::sc_core::sc_process_call<callback_tag>(&callback_tag::func))
19612027Sjungma@eit.uni-kl.de
19712027Sjungma@eit.uni-kl.de#endif // !defined(SC_USE_MEMBER_FUNC_PTR)
19812027Sjungma@eit.uni-kl.de
19912027Sjungma@eit.uni-kl.de
20012027Sjungma@eit.uni-kl.deextern void sc_set_stack_size( sc_thread_handle, std::size_t );
20112027Sjungma@eit.uni-kl.de
20212027Sjungma@eit.uni-kl.declass sc_event;
20312027Sjungma@eit.uni-kl.declass sc_event_list;
20412027Sjungma@eit.uni-kl.declass sc_name_gen;
20512027Sjungma@eit.uni-kl.declass sc_spawn_options;
20612027Sjungma@eit.uni-kl.declass sc_unwind_exception;
20712027Sjungma@eit.uni-kl.de
20812027Sjungma@eit.uni-kl.de//==============================================================================
20912027Sjungma@eit.uni-kl.de// CLASS sc_throw_it<EXCEPT> - ARBITRARY EXCEPTION CLASS
21012027Sjungma@eit.uni-kl.de//
21112027Sjungma@eit.uni-kl.de// This class serves as a way of throwing an execption for an aribtrary type
21212027Sjungma@eit.uni-kl.de// without knowing what that type is. A true virtual method in the base
21312027Sjungma@eit.uni-kl.de// class is used to actually throw the execption. A pointer to the base
21412027Sjungma@eit.uni-kl.de// class is used internally removing the necessity of knowing what the type
21512027Sjungma@eit.uni-kl.de// of EXCEPT is for code internal to the library.
21612027Sjungma@eit.uni-kl.de//
21712027Sjungma@eit.uni-kl.de// Note the clone() true virtual method. This is used to allow instances
21812027Sjungma@eit.uni-kl.de// of the sc_throw_it<EXCEPT> class to be easily garbage collected. Since
21912027Sjungma@eit.uni-kl.de// an exception may be propogated to more than one process knowing when
22012027Sjungma@eit.uni-kl.de// to garbage collect is non-trivial. So when a call is made to
22112027Sjungma@eit.uni-kl.de// sc_process_handle::throw_it() an instance of sc_throw_it<EXCEPT> is
22212027Sjungma@eit.uni-kl.de// allocated on the stack. For each process throwing the exception a copy is
22312027Sjungma@eit.uni-kl.de// made via clone(). That allows those objects to be deleted by the individual
22412027Sjungma@eit.uni-kl.de// processes when they are no longer needed (in this implementation of SystemC
22512027Sjungma@eit.uni-kl.de// that deletion will occur each time a new exception is thrown ( see
22612027Sjungma@eit.uni-kl.de// sc_thread_process::suspend_me() ).
22712027Sjungma@eit.uni-kl.de//==============================================================================
22812027Sjungma@eit.uni-kl.declass sc_throw_it_helper {
22912027Sjungma@eit.uni-kl.de  public:
23012027Sjungma@eit.uni-kl.de    virtual sc_throw_it_helper* clone() const = 0;
23112027Sjungma@eit.uni-kl.de    virtual void throw_it() = 0;
23212027Sjungma@eit.uni-kl.de    sc_throw_it_helper() {}
23312027Sjungma@eit.uni-kl.de    virtual ~sc_throw_it_helper() {}
23412027Sjungma@eit.uni-kl.de};
23512027Sjungma@eit.uni-kl.de
23612027Sjungma@eit.uni-kl.detemplate<typename EXCEPT>
23712027Sjungma@eit.uni-kl.declass sc_throw_it : public sc_throw_it_helper
23812027Sjungma@eit.uni-kl.de{
23912027Sjungma@eit.uni-kl.de    typedef sc_throw_it<EXCEPT> this_type;
24012027Sjungma@eit.uni-kl.de  public:
24112027Sjungma@eit.uni-kl.de    sc_throw_it( const EXCEPT& value ) : m_value(value) { }
24212027Sjungma@eit.uni-kl.de    virtual ~sc_throw_it() {}
24312027Sjungma@eit.uni-kl.de    virtual inline this_type* clone() const { return new this_type(m_value); }
24412027Sjungma@eit.uni-kl.de    virtual inline void throw_it() { throw m_value; }
24512027Sjungma@eit.uni-kl.de  protected:
24612027Sjungma@eit.uni-kl.de    EXCEPT m_value;  // value to be thrown.
24712027Sjungma@eit.uni-kl.de};
24812027Sjungma@eit.uni-kl.de
24912027Sjungma@eit.uni-kl.de//==============================================================================
25012027Sjungma@eit.uni-kl.de// CLASS sc_process_b - USER INITIATED DYNAMIC PROCESS SUPPORT:
25112027Sjungma@eit.uni-kl.de//
25212027Sjungma@eit.uni-kl.de// This class implements the base class for a threaded process_base process
25312027Sjungma@eit.uni-kl.de// whose semantics are provided by the true virtual method semantics().
25412027Sjungma@eit.uni-kl.de// Classes derived from this one will provide a version of semantics which
25512027Sjungma@eit.uni-kl.de// implements the desired semantics. See the sc_spawn_xxx classes below.
25612027Sjungma@eit.uni-kl.de//
25712027Sjungma@eit.uni-kl.de// Notes:
25812027Sjungma@eit.uni-kl.de//   (1) Object instances of this class maintain a reference count of
25912027Sjungma@eit.uni-kl.de//       outstanding handles. When the handle count goes to zero the
26012027Sjungma@eit.uni-kl.de//       object will be deleted.
26112027Sjungma@eit.uni-kl.de//   (2) Descriptions of the methods and operators in this class appear with
26212027Sjungma@eit.uni-kl.de//       their implementations.
26312027Sjungma@eit.uni-kl.de//   (3) The m_sticky_reset field is used to handle synchronous resets that
26412027Sjungma@eit.uni-kl.de//       are enabled via the sc_process_handle::sync_reset_on() method. These
26512027Sjungma@eit.uni-kl.de//       resets are not generated by a signal, but rather are modal by
26612027Sjungma@eit.uni-kl.de//       method call: sync_reset_on - sync_reset_off.
26712027Sjungma@eit.uni-kl.de//
26812027Sjungma@eit.uni-kl.de//==============================================================================
26912027Sjungma@eit.uni-kl.declass sc_process_b : public sc_object {
27012027Sjungma@eit.uni-kl.de    friend class sc_simcontext;      // Allow static processes to have base.
27112027Sjungma@eit.uni-kl.de    friend class sc_cthread_process; // Child can access parent.
27212027Sjungma@eit.uni-kl.de    friend class sc_method_process;  // Child can access parent.
27312027Sjungma@eit.uni-kl.de    friend class sc_process_handle;  // Allow handles to modify ref. count.
27412027Sjungma@eit.uni-kl.de    friend class sc_thread_process;  // Child can access parent.
27512027Sjungma@eit.uni-kl.de
27612027Sjungma@eit.uni-kl.de    friend class sc_object;
27712027Sjungma@eit.uni-kl.de    friend class sc_port_base;
27812027Sjungma@eit.uni-kl.de    friend class sc_runnable;
27912027Sjungma@eit.uni-kl.de    friend class sc_sensitive;
28012027Sjungma@eit.uni-kl.de    friend class sc_sensitive_pos;
28112027Sjungma@eit.uni-kl.de    friend class sc_sensitive_neg;
28212027Sjungma@eit.uni-kl.de    friend class sc_module;
28312027Sjungma@eit.uni-kl.de    friend class sc_report_handler;
28412027Sjungma@eit.uni-kl.de    friend class sc_reset;
28512027Sjungma@eit.uni-kl.de    friend class sc_reset_finder;
28612027Sjungma@eit.uni-kl.de    friend class sc_unwind_exception;
28712027Sjungma@eit.uni-kl.de
28812027Sjungma@eit.uni-kl.de    friend const char* sc_gen_unique_name( const char*, bool preserve_first );
28912027Sjungma@eit.uni-kl.de    friend sc_process_handle sc_get_current_process_handle();
29012027Sjungma@eit.uni-kl.de    friend void sc_thread_cor_fn( void* arg );
29112027Sjungma@eit.uni-kl.de    friend bool timed_out( sc_simcontext* );
29212027Sjungma@eit.uni-kl.de
29312027Sjungma@eit.uni-kl.de  public:
29412027Sjungma@eit.uni-kl.de    enum process_throw_type {
29512027Sjungma@eit.uni-kl.de        THROW_NONE = 0,
29612027Sjungma@eit.uni-kl.de	THROW_KILL,
29712027Sjungma@eit.uni-kl.de        THROW_USER,
29812027Sjungma@eit.uni-kl.de        THROW_ASYNC_RESET,
29912027Sjungma@eit.uni-kl.de        THROW_SYNC_RESET
30012027Sjungma@eit.uni-kl.de    };
30112027Sjungma@eit.uni-kl.de
30212027Sjungma@eit.uni-kl.de    enum process_state {
30312027Sjungma@eit.uni-kl.de	ps_bit_disabled = 1,      // process is disabled.
30412027Sjungma@eit.uni-kl.de	ps_bit_ready_to_run = 2,  // process is ready to run.
30512027Sjungma@eit.uni-kl.de        ps_bit_suspended = 4,     // process is suspended.
30612027Sjungma@eit.uni-kl.de	ps_bit_zombie = 8,        // process is a zombie.
30712027Sjungma@eit.uni-kl.de        ps_normal = 0             // must be zero.
30812027Sjungma@eit.uni-kl.de    };
30912027Sjungma@eit.uni-kl.de
31012027Sjungma@eit.uni-kl.de    enum reset_type {             // types for sc_process_b::reset_process()
31112027Sjungma@eit.uni-kl.de        reset_asynchronous = 0,   // asynchronous reset.
31212027Sjungma@eit.uni-kl.de        reset_synchronous_off,    // turn off synchronous reset sticky bit.
31312027Sjungma@eit.uni-kl.de        reset_synchronous_on      // turn on synchronous reset sticky bit.
31412027Sjungma@eit.uni-kl.de    };
31512027Sjungma@eit.uni-kl.de
31612027Sjungma@eit.uni-kl.de    enum trigger_t
31712027Sjungma@eit.uni-kl.de    {
31812027Sjungma@eit.uni-kl.de        STATIC,
31912027Sjungma@eit.uni-kl.de        EVENT,
32012027Sjungma@eit.uni-kl.de        OR_LIST,
32112027Sjungma@eit.uni-kl.de        AND_LIST,
32212027Sjungma@eit.uni-kl.de        TIMEOUT,
32312027Sjungma@eit.uni-kl.de        EVENT_TIMEOUT,
32412027Sjungma@eit.uni-kl.de        OR_LIST_TIMEOUT,
32512027Sjungma@eit.uni-kl.de        AND_LIST_TIMEOUT
32612027Sjungma@eit.uni-kl.de    };
32712027Sjungma@eit.uni-kl.de
32812027Sjungma@eit.uni-kl.de  public:
32912027Sjungma@eit.uni-kl.de    sc_process_b( const char* name_p, bool is_thread, bool free_host,
33012027Sjungma@eit.uni-kl.de        SC_ENTRY_FUNC method_p, sc_process_host* host_p,
33112027Sjungma@eit.uni-kl.de        const sc_spawn_options* opt_p );
33212027Sjungma@eit.uni-kl.de
33312027Sjungma@eit.uni-kl.de  protected:
33412027Sjungma@eit.uni-kl.de    // may not be deleted manually (called from destroy_process())
33512027Sjungma@eit.uni-kl.de    virtual ~sc_process_b();
33612027Sjungma@eit.uni-kl.de
33712027Sjungma@eit.uni-kl.de  public:
33812027Sjungma@eit.uni-kl.de    inline int current_state() { return m_state; }
33912027Sjungma@eit.uni-kl.de    bool dont_initialize() const { return m_dont_init; }
34012027Sjungma@eit.uni-kl.de    virtual void dont_initialize( bool dont );
34112027Sjungma@eit.uni-kl.de    std::string dump_state() const;
34212027Sjungma@eit.uni-kl.de    const ::std::vector<sc_object*>& get_child_objects() const;
34312027Sjungma@eit.uni-kl.de    inline sc_curr_proc_kind proc_kind() const;
34412027Sjungma@eit.uni-kl.de    sc_event& reset_event();
34512027Sjungma@eit.uni-kl.de    sc_event& terminated_event();
34612027Sjungma@eit.uni-kl.de
34712027Sjungma@eit.uni-kl.de  public:
34812027Sjungma@eit.uni-kl.de    static inline sc_process_handle last_created_process_handle();
34912027Sjungma@eit.uni-kl.de
35012027Sjungma@eit.uni-kl.de  protected:
35112027Sjungma@eit.uni-kl.de    virtual void add_child_object( sc_object* );
35212027Sjungma@eit.uni-kl.de    void add_static_event( const sc_event& );
35312027Sjungma@eit.uni-kl.de    bool dynamic() const { return m_dynamic_proc; }
35412027Sjungma@eit.uni-kl.de    const char* gen_unique_name( const char* basename_, bool preserve_first );
35512027Sjungma@eit.uni-kl.de    inline sc_report* get_last_report() { return m_last_report_p; }
35612027Sjungma@eit.uni-kl.de    inline bool is_disabled() const;
35712027Sjungma@eit.uni-kl.de    inline bool is_runnable() const;
35812027Sjungma@eit.uni-kl.de    static inline sc_process_b* last_created_process_base();
35912027Sjungma@eit.uni-kl.de    virtual bool remove_child_object( sc_object* );
36012027Sjungma@eit.uni-kl.de    void remove_dynamic_events( bool skip_timeout = false );
36112027Sjungma@eit.uni-kl.de    void remove_static_events();
36212027Sjungma@eit.uni-kl.de    inline void set_last_report( sc_report* last_p )
36312027Sjungma@eit.uni-kl.de        {
36412027Sjungma@eit.uni-kl.de            delete m_last_report_p;
36512027Sjungma@eit.uni-kl.de            m_last_report_p = last_p;
36612027Sjungma@eit.uni-kl.de        }
36712027Sjungma@eit.uni-kl.de    inline bool timed_out() const;
36812027Sjungma@eit.uni-kl.de    void report_error( const char* msgid, const char* msg = "" ) const;
36912027Sjungma@eit.uni-kl.de    void report_immediate_self_notification() const;
37012027Sjungma@eit.uni-kl.de
37112027Sjungma@eit.uni-kl.de  protected: // process control methods:
37212027Sjungma@eit.uni-kl.de    virtual void disable_process(
37312027Sjungma@eit.uni-kl.de        sc_descendant_inclusion_info descendants = SC_NO_DESCENDANTS ) = 0;
37412027Sjungma@eit.uni-kl.de    void disconnect_process();
37512027Sjungma@eit.uni-kl.de    virtual void enable_process(
37612027Sjungma@eit.uni-kl.de        sc_descendant_inclusion_info descendants = SC_NO_DESCENDANTS ) = 0;
37712027Sjungma@eit.uni-kl.de    inline void initially_in_reset( bool async );
37812027Sjungma@eit.uni-kl.de    inline bool is_unwinding() const;
37912027Sjungma@eit.uni-kl.de    inline bool start_unwinding();
38012027Sjungma@eit.uni-kl.de    inline bool clear_unwinding();
38112027Sjungma@eit.uni-kl.de    virtual void kill_process(
38212027Sjungma@eit.uni-kl.de        sc_descendant_inclusion_info descendants = SC_NO_DESCENDANTS ) = 0;
38312027Sjungma@eit.uni-kl.de    void reset_changed( bool async, bool asserted );
38412027Sjungma@eit.uni-kl.de    void reset_process( reset_type rt,
38512027Sjungma@eit.uni-kl.de        sc_descendant_inclusion_info descendants = SC_NO_DESCENDANTS );
38612027Sjungma@eit.uni-kl.de    virtual void resume_process(
38712027Sjungma@eit.uni-kl.de        sc_descendant_inclusion_info descendants = SC_NO_DESCENDANTS ) = 0;
38812027Sjungma@eit.uni-kl.de    virtual void suspend_process(
38912027Sjungma@eit.uni-kl.de        sc_descendant_inclusion_info descendants = SC_NO_DESCENDANTS ) = 0;
39012027Sjungma@eit.uni-kl.de    virtual void throw_user( const sc_throw_it_helper& helper,
39112027Sjungma@eit.uni-kl.de        sc_descendant_inclusion_info descendants = SC_NO_DESCENDANTS ) = 0;
39212027Sjungma@eit.uni-kl.de    virtual void throw_reset( bool async ) = 0;
39312027Sjungma@eit.uni-kl.de    virtual bool terminated() const;
39412027Sjungma@eit.uni-kl.de    void trigger_reset_event();
39512027Sjungma@eit.uni-kl.de
39612027Sjungma@eit.uni-kl.de  private:
39712027Sjungma@eit.uni-kl.de    void        delete_process();
39812027Sjungma@eit.uni-kl.de    inline void reference_decrement();
39912027Sjungma@eit.uni-kl.de    inline void reference_increment();
40012027Sjungma@eit.uni-kl.de
40112027Sjungma@eit.uni-kl.de  protected:
40212027Sjungma@eit.uni-kl.de    inline void semantics();
40312027Sjungma@eit.uni-kl.de
40412027Sjungma@eit.uni-kl.de    // debugging stuff:
40512027Sjungma@eit.uni-kl.de
40612027Sjungma@eit.uni-kl.de  public:
40712027Sjungma@eit.uni-kl.de    const char*                 file;
40812027Sjungma@eit.uni-kl.de    int                         lineno;
40912027Sjungma@eit.uni-kl.de    int                         proc_id;
41012027Sjungma@eit.uni-kl.de
41112027Sjungma@eit.uni-kl.de  protected:
41212027Sjungma@eit.uni-kl.de    int                          m_active_areset_n; // number of aresets active.
41312027Sjungma@eit.uni-kl.de    int                          m_active_reset_n;  // number of resets active.
41412027Sjungma@eit.uni-kl.de    bool                         m_dont_init;       // true: no initialize call.
41512027Sjungma@eit.uni-kl.de    bool                         m_dynamic_proc;    // true: after elaboration.
41612027Sjungma@eit.uni-kl.de    const sc_event*              m_event_p;         // Dynamic event waiting on.
41712027Sjungma@eit.uni-kl.de    int                          m_event_count;     // number of events.
41812027Sjungma@eit.uni-kl.de    const sc_event_list*         m_event_list_p;    // event list waiting on.
41912027Sjungma@eit.uni-kl.de    sc_process_b*                m_exist_p;         // process existence link.
42012027Sjungma@eit.uni-kl.de    bool                         m_free_host;       // free sc_semantic_host_p.
42112027Sjungma@eit.uni-kl.de    bool                         m_has_reset_signal;  // has reset_signal_is.
42212027Sjungma@eit.uni-kl.de    bool                         m_has_stack;       // true is stack present.
42312027Sjungma@eit.uni-kl.de    bool                         m_is_thread;       // true if this is thread.
42412027Sjungma@eit.uni-kl.de    sc_report*                   m_last_report_p;   // last report this process.
42512027Sjungma@eit.uni-kl.de    sc_name_gen*                 m_name_gen_p;      // subprocess name generator
42612027Sjungma@eit.uni-kl.de    sc_curr_proc_kind            m_process_kind;    // type of process.
42712027Sjungma@eit.uni-kl.de    int                          m_references_n;    // outstanding handles.
42812027Sjungma@eit.uni-kl.de    std::vector<sc_reset*>       m_resets;          // resets for process.
42912027Sjungma@eit.uni-kl.de    sc_event*                    m_reset_event_p;   // reset event.
43012027Sjungma@eit.uni-kl.de    sc_event*                    m_resume_event_p;  // resume event.
43112027Sjungma@eit.uni-kl.de    sc_process_b*                m_runnable_p;      // sc_runnable link
43212027Sjungma@eit.uni-kl.de    sc_process_host*             m_semantics_host_p;   // host for semantics.
43312027Sjungma@eit.uni-kl.de    SC_ENTRY_FUNC                m_semantics_method_p; // method for semantics.
43412027Sjungma@eit.uni-kl.de    int                          m_state;           // process state.
43512027Sjungma@eit.uni-kl.de    std::vector<const sc_event*> m_static_events;   // static events waiting on.
43612027Sjungma@eit.uni-kl.de    bool                         m_sticky_reset;    // see note 3 above.
43712027Sjungma@eit.uni-kl.de    sc_event*                    m_term_event_p;    // terminated event.
43812027Sjungma@eit.uni-kl.de    sc_throw_it_helper*          m_throw_helper_p;  // what to throw.
43912027Sjungma@eit.uni-kl.de    process_throw_type           m_throw_status;    // exception throwing status
44012027Sjungma@eit.uni-kl.de    bool                         m_timed_out;       // true if we timed out.
44112027Sjungma@eit.uni-kl.de    sc_event*                    m_timeout_event_p; // timeout event.
44212027Sjungma@eit.uni-kl.de    trigger_t                    m_trigger_type;    // type of trigger using.
44312027Sjungma@eit.uni-kl.de    bool                         m_unwinding;       // true if unwinding stack.
44412027Sjungma@eit.uni-kl.de
44512027Sjungma@eit.uni-kl.de  protected:
44612027Sjungma@eit.uni-kl.de    static sc_process_b* m_last_created_process_p; // Last process created.
44712027Sjungma@eit.uni-kl.de};
44812027Sjungma@eit.uni-kl.de
44912027Sjungma@eit.uni-kl.detypedef sc_process_b sc_process_b;  // For compatibility.
45012027Sjungma@eit.uni-kl.de
45112027Sjungma@eit.uni-kl.de
45212027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
45312027Sjungma@eit.uni-kl.de//"sc_process_b::XXXX_child_YYYYY"
45412027Sjungma@eit.uni-kl.de//
45512027Sjungma@eit.uni-kl.de// These methods provide child object support.
45612027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
45712027Sjungma@eit.uni-kl.deinline void
45812027Sjungma@eit.uni-kl.desc_process_b::add_child_object( sc_object* object_p )
45912027Sjungma@eit.uni-kl.de{
46012027Sjungma@eit.uni-kl.de    sc_object::add_child_object( object_p );
46112027Sjungma@eit.uni-kl.de    reference_increment();
46212027Sjungma@eit.uni-kl.de}
46312027Sjungma@eit.uni-kl.de
46412027Sjungma@eit.uni-kl.deinline bool
46512027Sjungma@eit.uni-kl.desc_process_b::remove_child_object( sc_object* object_p )
46612027Sjungma@eit.uni-kl.de{
46712027Sjungma@eit.uni-kl.de    if ( sc_object::remove_child_object( object_p ) ) {
46812027Sjungma@eit.uni-kl.de	    reference_decrement();
46912027Sjungma@eit.uni-kl.de            return true;
47012027Sjungma@eit.uni-kl.de    }
47112027Sjungma@eit.uni-kl.de    else
47212027Sjungma@eit.uni-kl.de    {
47312027Sjungma@eit.uni-kl.de        return false;
47412027Sjungma@eit.uni-kl.de    }
47512027Sjungma@eit.uni-kl.de}
47612027Sjungma@eit.uni-kl.de
47712027Sjungma@eit.uni-kl.deinline const ::std::vector<sc_object*>&
47812027Sjungma@eit.uni-kl.desc_process_b::get_child_objects() const
47912027Sjungma@eit.uni-kl.de{
48012027Sjungma@eit.uni-kl.de    return m_child_objects;
48112027Sjungma@eit.uni-kl.de}
48212027Sjungma@eit.uni-kl.de
48312027Sjungma@eit.uni-kl.de
48412027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
48512027Sjungma@eit.uni-kl.de//"sc_process_b::initially_in_reset"
48612027Sjungma@eit.uni-kl.de//
48712027Sjungma@eit.uni-kl.de// This inline method is a callback to indicate that a reset is active at
48812027Sjungma@eit.uni-kl.de// start up. This is because the signal will have been initialized before
48912027Sjungma@eit.uni-kl.de// a reset linkage for it is set up, so we won't get a reset_changed()
49012027Sjungma@eit.uni-kl.de// callback.
49112027Sjungma@eit.uni-kl.de//     async = true if this an asynchronous reset.
49212027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
49312027Sjungma@eit.uni-kl.deinline void sc_process_b::initially_in_reset( bool async )
49412027Sjungma@eit.uni-kl.de{
49512027Sjungma@eit.uni-kl.de    if ( async )
49612027Sjungma@eit.uni-kl.de        m_active_areset_n++;
49712027Sjungma@eit.uni-kl.de    else
49812027Sjungma@eit.uni-kl.de        m_active_reset_n++;
49912027Sjungma@eit.uni-kl.de}
50012027Sjungma@eit.uni-kl.de
50112027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
50212027Sjungma@eit.uni-kl.de//"sc_process_b::is_disabled"
50312027Sjungma@eit.uni-kl.de//
50412027Sjungma@eit.uni-kl.de// This method returns true if this process is disabled.
50512027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
50612027Sjungma@eit.uni-kl.deinline bool sc_process_b::is_disabled() const
50712027Sjungma@eit.uni-kl.de{
50812027Sjungma@eit.uni-kl.de    return (m_state & ps_bit_disabled) ? true : false;
50912027Sjungma@eit.uni-kl.de}
51012027Sjungma@eit.uni-kl.de
51112027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
51212027Sjungma@eit.uni-kl.de//"sc_process_b::is_runnable"
51312027Sjungma@eit.uni-kl.de//
51412027Sjungma@eit.uni-kl.de// This method returns true if this process is runnable. That is indicated
51512027Sjungma@eit.uni-kl.de// by a non-zero m_runnable_p field.
51612027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
51712027Sjungma@eit.uni-kl.deinline bool sc_process_b::is_runnable() const
51812027Sjungma@eit.uni-kl.de{
51912027Sjungma@eit.uni-kl.de    return m_runnable_p != 0;
52012027Sjungma@eit.uni-kl.de}
52112027Sjungma@eit.uni-kl.de
52212027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
52312027Sjungma@eit.uni-kl.de//"sc_process_b::is_unwinding"
52412027Sjungma@eit.uni-kl.de//
52512027Sjungma@eit.uni-kl.de// This method returns true if this process is unwinding from a kill or reset.
52612027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
52712027Sjungma@eit.uni-kl.deinline bool sc_process_b::is_unwinding() const
52812027Sjungma@eit.uni-kl.de{
52912027Sjungma@eit.uni-kl.de    return m_unwinding;
53012027Sjungma@eit.uni-kl.de}
53112027Sjungma@eit.uni-kl.de
53212027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
53312027Sjungma@eit.uni-kl.de//"sc_process_b::start_unwinding"
53412027Sjungma@eit.uni-kl.de//
53512027Sjungma@eit.uni-kl.de// This method flags that this object instance should start unwinding if the
53612027Sjungma@eit.uni-kl.de// current throw status requires an unwind.
53712027Sjungma@eit.uni-kl.de//
53812027Sjungma@eit.uni-kl.de// Result is true if the flag is set, false if the flag is already set.
53912027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
54012027Sjungma@eit.uni-kl.deinline bool sc_process_b::start_unwinding()
54112027Sjungma@eit.uni-kl.de{
54212027Sjungma@eit.uni-kl.de    if ( !m_unwinding )
54312027Sjungma@eit.uni-kl.de    {
54412027Sjungma@eit.uni-kl.de	switch( m_throw_status )
54512027Sjungma@eit.uni-kl.de	{
54612027Sjungma@eit.uni-kl.de	  case THROW_KILL:
54712027Sjungma@eit.uni-kl.de	  case THROW_ASYNC_RESET:
54812027Sjungma@eit.uni-kl.de	  case THROW_SYNC_RESET:
54912027Sjungma@eit.uni-kl.de	    m_unwinding = true;
55012027Sjungma@eit.uni-kl.de	     return true;
55112027Sjungma@eit.uni-kl.de	  case THROW_USER:
55212027Sjungma@eit.uni-kl.de	   default:
55312027Sjungma@eit.uni-kl.de	     break;
55412027Sjungma@eit.uni-kl.de	 }
55512027Sjungma@eit.uni-kl.de    }
55612027Sjungma@eit.uni-kl.de    return false;
55712027Sjungma@eit.uni-kl.de}
55812027Sjungma@eit.uni-kl.de
55912027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
56012027Sjungma@eit.uni-kl.de//"sc_process_b::clear_unwinding"
56112027Sjungma@eit.uni-kl.de//
56212027Sjungma@eit.uni-kl.de// This method clears this object instance's throw status and always returns
56312027Sjungma@eit.uni-kl.de// true.
56412027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
56512027Sjungma@eit.uni-kl.deinline bool sc_process_b::clear_unwinding()
56612027Sjungma@eit.uni-kl.de{
56712027Sjungma@eit.uni-kl.de    m_unwinding = false;
56812027Sjungma@eit.uni-kl.de    return true;
56912027Sjungma@eit.uni-kl.de}
57012027Sjungma@eit.uni-kl.de
57112027Sjungma@eit.uni-kl.de
57212027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
57312027Sjungma@eit.uni-kl.de//"sc_process_b::last_created_process_base"
57412027Sjungma@eit.uni-kl.de//
57512027Sjungma@eit.uni-kl.de// This virtual method returns the sc_process_b pointer for the last
57612027Sjungma@eit.uni-kl.de// created process. It is only used internally by the simulator.
57712027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
57812027Sjungma@eit.uni-kl.deinline sc_process_b* sc_process_b::last_created_process_base()
57912027Sjungma@eit.uni-kl.de{
58012027Sjungma@eit.uni-kl.de    return m_last_created_process_p;
58112027Sjungma@eit.uni-kl.de}
58212027Sjungma@eit.uni-kl.de
58312027Sjungma@eit.uni-kl.de
58412027Sjungma@eit.uni-kl.de
58512027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
58612027Sjungma@eit.uni-kl.de//"sc_process_b::proc_kind"
58712027Sjungma@eit.uni-kl.de//
58812027Sjungma@eit.uni-kl.de// This method returns the kind of this process.
58912027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
59012027Sjungma@eit.uni-kl.deinline sc_curr_proc_kind sc_process_b::proc_kind() const
59112027Sjungma@eit.uni-kl.de{
59212027Sjungma@eit.uni-kl.de    return m_process_kind;
59312027Sjungma@eit.uni-kl.de}
59412027Sjungma@eit.uni-kl.de
59512027Sjungma@eit.uni-kl.de
59612027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
59712027Sjungma@eit.uni-kl.de//"sc_process_b::reference_decrement"
59812027Sjungma@eit.uni-kl.de//
59912027Sjungma@eit.uni-kl.de// This inline method decrements the number of outstanding references to this
60012027Sjungma@eit.uni-kl.de// object instance. If the number of references goes to zero, this object
60112027Sjungma@eit.uni-kl.de// can be deleted in "sc_process_b::delete_process()".
60212027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
60312027Sjungma@eit.uni-kl.deinline void sc_process_b::reference_decrement()
60412027Sjungma@eit.uni-kl.de{
60512027Sjungma@eit.uni-kl.de    m_references_n--;
60612027Sjungma@eit.uni-kl.de    if ( m_references_n == 0 ) delete_process();
60712027Sjungma@eit.uni-kl.de}
60812027Sjungma@eit.uni-kl.de
60912027Sjungma@eit.uni-kl.de
61012027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
61112027Sjungma@eit.uni-kl.de//"sc_process_b::reference_increment"
61212027Sjungma@eit.uni-kl.de//
61312027Sjungma@eit.uni-kl.de// This inline method increments the number of outstanding references to this
61412027Sjungma@eit.uni-kl.de// object instance.
61512027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
61612027Sjungma@eit.uni-kl.deinline void sc_process_b::reference_increment()
61712027Sjungma@eit.uni-kl.de{
61812027Sjungma@eit.uni-kl.de    assert(m_references_n != 0);
61912027Sjungma@eit.uni-kl.de    m_references_n++;
62012027Sjungma@eit.uni-kl.de}
62112027Sjungma@eit.uni-kl.de
62212027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
62312027Sjungma@eit.uni-kl.de//"sc_process_b::semantics"
62412027Sjungma@eit.uni-kl.de//
62512027Sjungma@eit.uni-kl.de// This inline method invokes the semantics for this object instance.
62612027Sjungma@eit.uni-kl.de// We check to see if we are initially in reset and then invoke the
62712027Sjungma@eit.uni-kl.de// process semantics.
62812027Sjungma@eit.uni-kl.de//
62912027Sjungma@eit.uni-kl.de// Notes:
63012027Sjungma@eit.uni-kl.de//   (1) For a description of the process reset mechanism see the top of
63112027Sjungma@eit.uni-kl.de//       the file sc_reset.cpp.
63212027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
63312027Sjungma@eit.uni-kl.destruct scoped_flag
63412027Sjungma@eit.uni-kl.de{
63512027Sjungma@eit.uni-kl.de    scoped_flag( bool& b ) : ref(b){ ref = true;  }
63612027Sjungma@eit.uni-kl.de    ~scoped_flag()                 { ref = false; }
63712027Sjungma@eit.uni-kl.de    bool& ref;
63812027Sjungma@eit.uni-kl.de};
63912027Sjungma@eit.uni-kl.deinline void sc_process_b::semantics()
64012027Sjungma@eit.uni-kl.de{
64112027Sjungma@eit.uni-kl.de
64212027Sjungma@eit.uni-kl.de    // within this function, the process has a stack associated
64312027Sjungma@eit.uni-kl.de
64412027Sjungma@eit.uni-kl.de    scoped_flag scoped_stack_flag( m_has_stack );
64512027Sjungma@eit.uni-kl.de
64612027Sjungma@eit.uni-kl.de    assert( m_process_kind != SC_NO_PROC_ );
64712027Sjungma@eit.uni-kl.de
64812027Sjungma@eit.uni-kl.de    // Determine the reset status of this object instance and potentially
64912027Sjungma@eit.uni-kl.de    // trigger its notify event:
65012027Sjungma@eit.uni-kl.de
65112027Sjungma@eit.uni-kl.de    // See if we need to trigger the notify event:
65212027Sjungma@eit.uni-kl.de
65312027Sjungma@eit.uni-kl.de    if ( m_reset_event_p &&
65412027Sjungma@eit.uni-kl.de         ( (m_throw_status == THROW_SYNC_RESET) ||
65512027Sjungma@eit.uni-kl.de	   (m_throw_status == THROW_ASYNC_RESET) )
65612027Sjungma@eit.uni-kl.de    ) {
65712027Sjungma@eit.uni-kl.de        trigger_reset_event();
65812027Sjungma@eit.uni-kl.de    }
65912027Sjungma@eit.uni-kl.de
66012027Sjungma@eit.uni-kl.de    // Set the new reset status of this object based on the reset counts:
66112027Sjungma@eit.uni-kl.de
66212027Sjungma@eit.uni-kl.de    m_throw_status = m_active_areset_n ? THROW_ASYNC_RESET :
66312027Sjungma@eit.uni-kl.de        ( m_active_reset_n  ?  THROW_SYNC_RESET : THROW_NONE);
66412027Sjungma@eit.uni-kl.de
66512027Sjungma@eit.uni-kl.de    // Dispatch the actual semantics for the process:
66612027Sjungma@eit.uni-kl.de
66712027Sjungma@eit.uni-kl.de#   ifndef SC_USE_MEMBER_FUNC_PTR
66812027Sjungma@eit.uni-kl.de        m_semantics_method_p->invoke( m_semantics_host_p );
66912027Sjungma@eit.uni-kl.de#   else
67012027Sjungma@eit.uni-kl.de        (m_semantics_host_p->*m_semantics_method_p)();
67112027Sjungma@eit.uni-kl.de#   endif
67212027Sjungma@eit.uni-kl.de}
67312027Sjungma@eit.uni-kl.de
67412027Sjungma@eit.uni-kl.de
67512027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
67612027Sjungma@eit.uni-kl.de//"sc_process_b::terminated"
67712027Sjungma@eit.uni-kl.de//
67812027Sjungma@eit.uni-kl.de// This inline method returns true if this object has terminated.
67912027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
68012027Sjungma@eit.uni-kl.deinline bool sc_process_b::terminated() const
68112027Sjungma@eit.uni-kl.de{
68212027Sjungma@eit.uni-kl.de    return (m_state & ps_bit_zombie) != 0;
68312027Sjungma@eit.uni-kl.de}
68412027Sjungma@eit.uni-kl.de
68512027Sjungma@eit.uni-kl.de
68612027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
68712027Sjungma@eit.uni-kl.de//"sc_process_b::timed_out"
68812027Sjungma@eit.uni-kl.de//
68912027Sjungma@eit.uni-kl.de// This inline method returns true if this object instance timed out.
69012027Sjungma@eit.uni-kl.de//------------------------------------------------------------------------------
69112027Sjungma@eit.uni-kl.deinline bool sc_process_b::timed_out() const
69212027Sjungma@eit.uni-kl.de{
69312027Sjungma@eit.uni-kl.de    return m_timed_out;
69412027Sjungma@eit.uni-kl.de}
69512027Sjungma@eit.uni-kl.de
69612027Sjungma@eit.uni-kl.de} // namespace sc_core
69712027Sjungma@eit.uni-kl.de
69812027Sjungma@eit.uni-kl.de/*****************************************************************************
69912027Sjungma@eit.uni-kl.de
70012027Sjungma@eit.uni-kl.de  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
70112027Sjungma@eit.uni-kl.de  changes you are making here.
70212027Sjungma@eit.uni-kl.de
70312027Sjungma@eit.uni-kl.de      Name, Affiliation, Date: Andy Goodrich, Forte Design Systems, 12 Aug 05
70412027Sjungma@eit.uni-kl.de  Description of Modification: This is the rewrite of process support. It
70512027Sjungma@eit.uni-kl.de                               contains some code from the original
70612027Sjungma@eit.uni-kl.de                               sc_process.h by Stan Liao, and the now-defunct
70712027Sjungma@eit.uni-kl.de                               sc_process_b.h by Stan Liao and Martin
70812027Sjungma@eit.uni-kl.de                               Janssen, all of Synopsys, Inc., It also contains
70912027Sjungma@eit.uni-kl.de                               code from the original sc_process_b.h by
71012027Sjungma@eit.uni-kl.de                               Andy Goodrich of Forte Design Systems and
71112027Sjungma@eit.uni-kl.de                               Bishnupriya Bhattacharya of Cadence Design
71212027Sjungma@eit.uni-kl.de                               Systems.
71312027Sjungma@eit.uni-kl.de
71412027Sjungma@eit.uni-kl.de      Name, Affiliation, Date:
71512027Sjungma@eit.uni-kl.de  Description of Modification:
71612027Sjungma@eit.uni-kl.de
71712027Sjungma@eit.uni-kl.de *****************************************************************************/
71812027Sjungma@eit.uni-kl.de
71912027Sjungma@eit.uni-kl.de// $Log: sc_process.h,v $
72012027Sjungma@eit.uni-kl.de// Revision 1.36  2011/08/26 22:44:30  acg
72112027Sjungma@eit.uni-kl.de//  Torsten Maehne: eliminate unused argument warning.
72212027Sjungma@eit.uni-kl.de//
72312027Sjungma@eit.uni-kl.de// Revision 1.35  2011/08/26 20:46:10  acg
72412027Sjungma@eit.uni-kl.de//  Andy Goodrich: moved the modification log to the end of the file to
72512027Sjungma@eit.uni-kl.de//  eliminate source line number skew when check-ins are done.
72612027Sjungma@eit.uni-kl.de//
72712027Sjungma@eit.uni-kl.de// Revision 1.34  2011/08/24 22:05:51  acg
72812027Sjungma@eit.uni-kl.de//  Torsten Maehne: initialization changes to remove warnings.
72912027Sjungma@eit.uni-kl.de//
73012027Sjungma@eit.uni-kl.de// Revision 1.33  2011/08/15 16:43:24  acg
73112027Sjungma@eit.uni-kl.de//  Torsten Maehne: changes to remove unused argument warnings.
73212027Sjungma@eit.uni-kl.de//
73312027Sjungma@eit.uni-kl.de// Revision 1.32  2011/07/24 11:20:03  acg
73412027Sjungma@eit.uni-kl.de//  Philipp A. Hartmann: process control error message improvements:
73512027Sjungma@eit.uni-kl.de//  (1) Downgrade error to warning for re-kills of processes.
73612027Sjungma@eit.uni-kl.de//  (2) Add process name to process messages.
73712027Sjungma@eit.uni-kl.de//  (3) drop some superfluous colons in messages.
73812027Sjungma@eit.uni-kl.de//
73912027Sjungma@eit.uni-kl.de// Revision 1.31  2011/04/13 02:44:26  acg
74012027Sjungma@eit.uni-kl.de//  Andy Goodrich: added m_unwinding flag in place of THROW_NOW because the
74112027Sjungma@eit.uni-kl.de//  throw status will be set back to THROW_*_RESET if reset is active and
74212027Sjungma@eit.uni-kl.de//  the check for an unwind being complete was expecting THROW_NONE as the
74312027Sjungma@eit.uni-kl.de//  clearing of THROW_NOW.
74412027Sjungma@eit.uni-kl.de//
74512027Sjungma@eit.uni-kl.de// Revision 1.30  2011/04/11 22:07:27  acg
74612027Sjungma@eit.uni-kl.de//  Andy Goodrich: check for reset event notification before resetting the
74712027Sjungma@eit.uni-kl.de//  throw_status value.
74812027Sjungma@eit.uni-kl.de//
74912027Sjungma@eit.uni-kl.de// Revision 1.29  2011/04/10 22:17:36  acg
75012027Sjungma@eit.uni-kl.de//  Andy Goodrich: added trigger_reset_event() to allow sc_process.h to
75112027Sjungma@eit.uni-kl.de//  contain the run_process() inline method. sc_process.h cannot have
75212027Sjungma@eit.uni-kl.de//  sc_simcontext information because of recursive includes.
75312027Sjungma@eit.uni-kl.de//
75412027Sjungma@eit.uni-kl.de// Revision 1.28  2011/04/08 22:34:06  acg
75512027Sjungma@eit.uni-kl.de//  Andy Goodrich: moved the semantics() method to this file and made it
75612027Sjungma@eit.uni-kl.de//  an inline method. Added reset processing to the semantics() method.
75712027Sjungma@eit.uni-kl.de//
75812027Sjungma@eit.uni-kl.de// Revision 1.27  2011/04/08 18:24:48  acg
75912027Sjungma@eit.uni-kl.de//  Andy Goodrich: moved reset_changed() to .cpp since it needs visibility
76012027Sjungma@eit.uni-kl.de//  to sc_simcontext.
76112027Sjungma@eit.uni-kl.de//
76212027Sjungma@eit.uni-kl.de// Revision 1.26  2011/04/01 21:24:57  acg
76312027Sjungma@eit.uni-kl.de//  Andy Goodrich: removed unused code.
76412027Sjungma@eit.uni-kl.de//
76512027Sjungma@eit.uni-kl.de// Revision 1.25  2011/03/28 13:02:51  acg
76612027Sjungma@eit.uni-kl.de//  Andy Goodrich: Changes for disable() interactions.
76712027Sjungma@eit.uni-kl.de//
76812027Sjungma@eit.uni-kl.de// Revision 1.24  2011/03/20 13:43:23  acg
76912027Sjungma@eit.uni-kl.de//  Andy Goodrich: added async_signal_is() plus suspend() as a corner case.
77012027Sjungma@eit.uni-kl.de//
77112027Sjungma@eit.uni-kl.de// Revision 1.23  2011/03/12 21:07:51  acg
77212027Sjungma@eit.uni-kl.de//  Andy Goodrich: changes to kernel generated event support.
77312027Sjungma@eit.uni-kl.de//
77412027Sjungma@eit.uni-kl.de// Revision 1.22  2011/03/08 20:49:31  acg
77512027Sjungma@eit.uni-kl.de//  Andy Goodrich: implement coarse checking for synchronous reset - suspend
77612027Sjungma@eit.uni-kl.de//  interaction.
77712027Sjungma@eit.uni-kl.de//
77812027Sjungma@eit.uni-kl.de// Revision 1.21  2011/03/07 17:38:43  acg
77912027Sjungma@eit.uni-kl.de//  Andy Goodrich: tightening up of checks for undefined interaction between
78012027Sjungma@eit.uni-kl.de//  synchronous reset and suspend.
78112027Sjungma@eit.uni-kl.de//
78212027Sjungma@eit.uni-kl.de// Revision 1.20  2011/03/06 19:57:11  acg
78312027Sjungma@eit.uni-kl.de//  Andy Goodrich: refinements for the illegal suspend - synchronous reset
78412027Sjungma@eit.uni-kl.de//  interaction.
78512027Sjungma@eit.uni-kl.de//
78612027Sjungma@eit.uni-kl.de// Revision 1.19  2011/03/05 19:44:20  acg
78712027Sjungma@eit.uni-kl.de//  Andy Goodrich: changes for object and event naming and structures.
78812027Sjungma@eit.uni-kl.de//
78912027Sjungma@eit.uni-kl.de// Revision 1.18  2011/02/19 08:30:53  acg
79012027Sjungma@eit.uni-kl.de//  Andy Goodrich: Moved process queueing into trigger_static from
79112027Sjungma@eit.uni-kl.de//  sc_event::notify.
79212027Sjungma@eit.uni-kl.de//
79312027Sjungma@eit.uni-kl.de// Revision 1.17  2011/02/18 20:27:14  acg
79412027Sjungma@eit.uni-kl.de//  Andy Goodrich: Updated Copyrights.
79512027Sjungma@eit.uni-kl.de//
79612027Sjungma@eit.uni-kl.de// Revision 1.16  2011/02/18 20:10:44  acg
79712027Sjungma@eit.uni-kl.de//  Philipp A. Hartmann: force return expression to be a bool to keep MSVC
79812027Sjungma@eit.uni-kl.de//  happy.
79912027Sjungma@eit.uni-kl.de//
80012027Sjungma@eit.uni-kl.de// Revision 1.15  2011/02/17 19:52:45  acg
80112027Sjungma@eit.uni-kl.de//  Andy Goodrich:
80212027Sjungma@eit.uni-kl.de//    (1) Simplified process control usage.
80312027Sjungma@eit.uni-kl.de//    (2) Changed dump_status() to dump_state() with new signature.
80412027Sjungma@eit.uni-kl.de//
80512027Sjungma@eit.uni-kl.de// Revision 1.14  2011/02/16 22:37:30  acg
80612027Sjungma@eit.uni-kl.de//  Andy Goodrich: clean up to remove need for ps_disable_pending.
80712027Sjungma@eit.uni-kl.de//
80812027Sjungma@eit.uni-kl.de// Revision 1.13  2011/02/13 21:47:37  acg
80912027Sjungma@eit.uni-kl.de//  Andy Goodrich: update copyright notice.
81012027Sjungma@eit.uni-kl.de//
81112027Sjungma@eit.uni-kl.de// Revision 1.12  2011/02/13 21:41:34  acg
81212027Sjungma@eit.uni-kl.de//  Andy Goodrich: get the log messages for the previous check in correct.
81312027Sjungma@eit.uni-kl.de//
81412027Sjungma@eit.uni-kl.de// Revision 1.11  2011/02/13 21:32:24  acg
81512027Sjungma@eit.uni-kl.de//  Andy Goodrich: moved sc_process_b::reset_process() implementation
81612027Sjungma@eit.uni-kl.de//  from header to cpp file . Added dump_status() to print out the status of a
81712027Sjungma@eit.uni-kl.de//  process.
81812027Sjungma@eit.uni-kl.de//
81912027Sjungma@eit.uni-kl.de// Revision 1.10  2011/02/11 13:25:24  acg
82012027Sjungma@eit.uni-kl.de//  Andy Goodrich: Philipp A. Hartmann's changes:
82112027Sjungma@eit.uni-kl.de//    (1) Removal of SC_CTHREAD method overloads.
82212027Sjungma@eit.uni-kl.de//    (2) New exception processing code.
82312027Sjungma@eit.uni-kl.de//
82412027Sjungma@eit.uni-kl.de// Revision 1.9  2011/02/04 15:27:36  acg
82512027Sjungma@eit.uni-kl.de//  Andy Goodrich: changes for suspend-resume semantics.
82612027Sjungma@eit.uni-kl.de//
82712027Sjungma@eit.uni-kl.de// Revision 1.8  2011/02/01 21:06:12  acg
82812027Sjungma@eit.uni-kl.de//  Andy Goodrich: new layout for the process_state enum.
82912027Sjungma@eit.uni-kl.de//
83012027Sjungma@eit.uni-kl.de// Revision 1.7  2011/01/25 20:50:37  acg
83112027Sjungma@eit.uni-kl.de//  Andy Goodrich: changes for IEEE 1666 2011.
83212027Sjungma@eit.uni-kl.de//
83312027Sjungma@eit.uni-kl.de// Revision 1.6  2011/01/19 23:21:50  acg
83412027Sjungma@eit.uni-kl.de//  Andy Goodrich: changes for IEEE 1666 2011
83512027Sjungma@eit.uni-kl.de//
83612027Sjungma@eit.uni-kl.de// Revision 1.5  2011/01/18 20:10:45  acg
83712027Sjungma@eit.uni-kl.de//  Andy Goodrich: changes for IEEE1666_2011 semantics.
83812027Sjungma@eit.uni-kl.de//
83912027Sjungma@eit.uni-kl.de// Revision 1.4  2010/07/22 20:02:33  acg
84012027Sjungma@eit.uni-kl.de//  Andy Goodrich: bug fixes.
84112027Sjungma@eit.uni-kl.de//
84212027Sjungma@eit.uni-kl.de// Revision 1.3  2009/05/22 16:06:29  acg
84312027Sjungma@eit.uni-kl.de//  Andy Goodrich: process control updates.
84412027Sjungma@eit.uni-kl.de//
84512027Sjungma@eit.uni-kl.de// Revision 1.2  2008/05/22 17:06:26  acg
84612027Sjungma@eit.uni-kl.de//  Andy Goodrich: updated copyright notice to include 2008.
84712027Sjungma@eit.uni-kl.de//
84812027Sjungma@eit.uni-kl.de// Revision 1.1.1.1  2006/12/15 20:20:05  acg
84912027Sjungma@eit.uni-kl.de// SystemC 2.3
85012027Sjungma@eit.uni-kl.de//
85112027Sjungma@eit.uni-kl.de// Revision 1.11  2006/05/08 17:58:10  acg
85212027Sjungma@eit.uni-kl.de// Andy Goodrich: added David Long's forward declarations for friend
85312027Sjungma@eit.uni-kl.de//   functions, methods, and operators to keep the Microsoft compiler happy.
85412027Sjungma@eit.uni-kl.de//
85512027Sjungma@eit.uni-kl.de// Revision 1.10  2006/04/28 23:29:01  acg
85612027Sjungma@eit.uni-kl.de//  Andy Goodrich: added an sc_core:: prefix to SC_FUNC_PTR in the
85712027Sjungma@eit.uni-kl.de//  SC_MAKE_FUNC_PTR macro to allow its transpareuse outside of the sc_core
85812027Sjungma@eit.uni-kl.de//  namespace.
85912027Sjungma@eit.uni-kl.de//
86012027Sjungma@eit.uni-kl.de// Revision 1.9  2006/04/28 21:52:57  acg
86112027Sjungma@eit.uni-kl.de//  Andy Goodrich: changed SC_MAKE_FUNC_PTR to use a static cast to address
86212027Sjungma@eit.uni-kl.de//  and AIX issue wrt sc_module's inherited classes.
86312027Sjungma@eit.uni-kl.de//
86412027Sjungma@eit.uni-kl.de// Revision 1.8  2006/04/20 17:08:17  acg
86512027Sjungma@eit.uni-kl.de//  Andy Goodrich: 3.0 style process changes.
86612027Sjungma@eit.uni-kl.de//
86712027Sjungma@eit.uni-kl.de// Revision 1.7  2006/04/11 23:13:21  acg
86812027Sjungma@eit.uni-kl.de//   Andy Goodrich: Changes for reduced reset support that only includes
86912027Sjungma@eit.uni-kl.de//   sc_cthread, but has preliminary hooks for expanding to method and thread
87012027Sjungma@eit.uni-kl.de//   processes also.
87112027Sjungma@eit.uni-kl.de//
87212027Sjungma@eit.uni-kl.de// Revision 1.6  2006/03/13 20:26:50  acg
87312027Sjungma@eit.uni-kl.de//  Andy Goodrich: Addition of forward class declarations, e.g.,
87412027Sjungma@eit.uni-kl.de//  sc_reset, to keep gcc 4.x happy.
87512027Sjungma@eit.uni-kl.de//
87612027Sjungma@eit.uni-kl.de// Revision 1.5  2006/01/31 20:09:10  acg
87712027Sjungma@eit.uni-kl.de//  Andy Goodrich: added explaination of static vs dynamic waits to
87812027Sjungma@eit.uni-kl.de//  sc_process_b::trigger_static.
87912027Sjungma@eit.uni-kl.de//
88012027Sjungma@eit.uni-kl.de// Revision 1.4  2006/01/24 20:49:05  acg
88112027Sjungma@eit.uni-kl.de// Andy Goodrich: changes to remove the use of deprecated features within the
88212027Sjungma@eit.uni-kl.de// simulator, and to issue warning messages when deprecated features are used.
88312027Sjungma@eit.uni-kl.de//
88412027Sjungma@eit.uni-kl.de// Revision 1.3  2006/01/13 18:44:30  acg
88512027Sjungma@eit.uni-kl.de// Added $Log to record CVS changes into the source.
88612027Sjungma@eit.uni-kl.de
88712027Sjungma@eit.uni-kl.de#endif // !defined(sc_process_h_INCLUDED)
888