29 #if !defined(sc_process_h_INCLUDED)
30 #define sc_process_h_INCLUDED
42 #include <unordered_set>
43 #ifndef SC_INCLUDE_WINDOWS_H // 02/20/2015 GL
44 # define SC_INCLUDE_WINDOWS_H // include Windows.h, if needed
48 #if defined(WIN32) || defined(_WIN32)
50 #define CHNL_MTX_TYPE_ CRITICAL_SECTION
52 #define CHNL_MTX_INIT_( Mutex ) \
53 InitializeCriticalSection( &(Mutex) )
54 #define CHNL_MTX_LOCK_( Mutex ) \
55 EnterCriticalSection( &(Mutex) )
56 #define CHNL_MTX_UNLOCK_( Mutex ) \
57 LeaveCriticalSection( &(Mutex) )
58 #define CHNL_MTX_TRYLOCK_( Mutex ) \
59 ( TryEnterCriticalSection( &(Mutex) ) != 0 )
60 #define CHNL_MTX_DESTROY_( Mutex ) \
61 DeleteCriticalSection( &(Mutex) )
63 #else // use pthread mutex
66 #define CHNL_MTX_TYPE_ pthread_mutex_t
69 # define CHNL_PTHREAD_NULL_ cma_c_null
70 #else // !defined(__hpux)
71 # define CHNL_PTHREAD_NULL_ NULL
74 #define CHNL_MTX_INIT_( Mutex ) \
75 pthread_mutex_init( &(Mutex), CHNL_PTHREAD_NULL_ )
76 #define CHNL_MTX_LOCK_( Mutex ) \
77 pthread_mutex_lock( &(Mutex) )
78 #define CHNL_MTX_UNLOCK_( Mutex ) \
79 pthread_mutex_unlock( &(Mutex) )
82 # define CHNL_MTX_TRYLOCK_( Mutex ) \
83 ( pthread_mutex_trylock( &(Mutex) ) == 0 )
84 #else // no try_lock available
85 # define CHNL_MTX_TRYLOCK_( Mutex ) \
89 #define CHNL_MTX_DESTROY_( Mutex ) \
90 pthread_mutex_destroy( &(Mutex) )
99 #ifndef _SYSC_PRINT_VERBOSE_MESSAGE_ENV_VAR
100 #define _SYSC_PRINT_VERBOSE_MESSAGE_ENV_VAR "SYSC_PRINT_VERBOSE_MESSAGE"
105 class sc_process_handle;
106 class sc_thread_process;
199 #if defined(_MSC_VER)
200 #if ( _MSC_VER > 1200 )
201 # define SC_USE_MEMBER_FUNC_PTR
204 # define SC_USE_MEMBER_FUNC_PTR
210 #if defined(SC_USE_MEMBER_FUNC_PTR)
213 # define SC_DECL_HELPER_STRUCT(callback_tag, func)
214 # define SC_MAKE_FUNC_PTR(callback_tag, func) \
215 static_cast<sc_core::SC_ENTRY_FUNC>(&callback_tag::func)
220 #else // !defined(SC_USE_MEMBER_FUNC_PTR)
221 class sc_process_call_base {
223 inline sc_process_call_base()
227 virtual ~sc_process_call_base()
231 virtual void invoke(sc_process_host* host_p)
235 extern sc_process_call_base sc_process_defunct;
238 class sc_process_call :
public sc_process_call_base {
240 sc_process_call(
void (T::*method_p)() ) :
241 sc_process_call_base()
243 m_method_p = method_p;
246 virtual ~sc_process_call()
250 virtual void invoke(sc_process_host* host_p)
252 (((T*)host_p)->*m_method_p)();
256 void (T::*m_method_p)();
260 # define SC_DECL_HELPER_STRUCT(callback_tag, func)
261 # define SC_MAKE_FUNC_PTR(callback_tag, func) \
262 (::sc_core::SC_ENTRY_FUNC) (new \
263 ::sc_core::sc_process_call<callback_tag>(&callback_tag::func))
265 #endif // !defined(SC_USE_MEMBER_FUNC_PTR)
275 class sc_event_or_list;
277 class sc_spawn_options;
278 class sc_unwind_exception;
310 template<
typename EXCEPT>
421 std::list<sc_chnl_lock*> queue;
731 sc_process_b(
const char* name_p,
bool is_thread,
bool free_host,
829 const char*
gen_unique_name(
const char* basename_,
bool preserve_first );
843 void report_error(
const char* msgid,
const char* msg =
"" )
const;
872 void delete_process();
873 inline void reference_decrement();
874 inline void reference_increment();
969 std::unordered_set<sc_process_b*> proc_defined;
972 int get_previous_seg_id();
989 reference_increment();
998 reference_decrement();
1007 inline const ::std::vector<sc_object*>&
1010 return m_child_objects;
1133 inline void sc_process_b::reference_decrement()
1146 inline void sc_process_b::reference_increment()
1197 # ifndef SC_USE_MEMBER_FUNC_PTR
1418 #endif // !defined(sc_process_h_INCLUDED)
virtual void suspend_process(sc_descendant_inclusion_info descendants=SC_NO_DESCENDANTS)=0
void report_immediate_self_notification() const
void set_last_report(sc_report *last_p)
sc_throw_it_helper * m_throw_helper_p
sc_event * m_reset_event_p
virtual void add_child_object(sc_object *object_p)
std::string event_names()
int get_segment_id()
Set the current segment ID of this process.
void pop_and_unlock(CHNL_MTX_TYPE_ *lock)
Release a channel lock or decrement the lock counter.
SC_ENTRY_FUNC m_semantics_method_p
void lock_all(void)
Acquire all the channel locks in the list.
virtual bool remove_child_object(sc_object *)
virtual this_type * clone() const
sc_timestamp & operator=(const sc_timestamp &)
Overload assignment operator.
process_throw_type m_throw_status
sc_report * m_last_report_p
sc_name_gen * m_name_gen_p
sc_process_b sc_process_b
void report_error(const char *msgid, const char *msg="") const
sc_event_or_list * m_sensitivity_events
A time stamp combining timed cycles and delta cycles.
const sc_time & get_time_count() const
Get the value of timed cycles.
sc_throw_it(const EXCEPT &value)
sc_dt::uint64 value_type
The data type of delta cycles.
bool timed_out(sc_simcontext *)
sc_descendant_inclusion_info
This class provides access to an sc_process_b object instance in a manner which allows some persisten...
void add_sensitivity_event(const sc_event &e)
bool sc_allow_process_control_corners
void(sc_process_host::* SC_ENTRY_FUNC)()
bool operator<=(const sc_timestamp &) const
Overload <= operator.
virtual void disable_process(sc_descendant_inclusion_info descendants=SC_NO_DESCENDANTS)=0
void reset_changed(bool async, bool asserted)
virtual void kill_process(sc_descendant_inclusion_info descendants=SC_NO_DESCENDANTS)=0
void reset_process(reset_type rt, sc_descendant_inclusion_info descendants=SC_NO_DESCENDANTS)
void set_upcoming_socket_id(int socket_id)
sets the upcoming socket id ZC 10:30 2018/10/31
sc_event * m_timeout_event_p
class sc_cthread_process * sc_cthread_handle
void set_upcoming_segment_ids(int *segment_ids)
sets the upcoming segment ids TS 07/08/17
int get_instance_id()
Set the instance ID of this process.
bool dont_initialize() const
Base class for lists of events.
bool get_infinite() const
Check whether the time stamp is infinite.
value_type m_delta_count
The value of delta cycles.
class sc_method_process * sc_method_handle
void remove_static_events()
const sc_event * m_event_p
void remove_dynamic_events(bool skip_timeout=false)
void sc_thread_cor_fn(void *arg)
std::string dump_state() const
static sc_process_b * last_created_process_base()
uint64 const sc_uint_base int b
friend const char * sc_gen_unique_name(const char *, bool preserve_first)
User initiated dynamic process support.
friend class sc_reset_finder
unsigned int counter
The lock counter.
virtual ~sc_process_host()
sc_process_host * m_semantics_host_p
Arbitrary exception class.
void decrease_offset(int offset)
decrease the offset ZC 10:31 2018/10/31
sc_timestamp operator+(const sc_timestamp &)
Overload + operator.
void trigger_reset_event()
virtual sc_throw_it_helper * clone() const =0
sc_event & terminated_event()
sc_curr_proc_kind proc_kind() const
const char * sc_gen_unique_name(const char *, bool preserve_first)
int m_segment_id
The current segment ID of this process.
Class that manages the ready-to-run queues.
static sc_process_b * m_last_created_process_p
sc_curr_proc_kind m_process_kind
std::vector< const sc_event * > m_static_events
void lock_and_push(CHNL_MTX_TYPE_ *lock)
Acquire a new channel lock or increment the lock counter.
sc_acq_chnl_lock_queue m_acq_chnl_lock_queue
A list of channel locks acquired by this process.
std::string to_string() const
CHNL_MTX_TYPE_ * lock_p
A pointer to the specific channel lock.
void lock_all_channels(void)
Acquire all the channel locks.
A list of channel locks acquired by a process.
class sc_thread_process * sc_thread_handle
A data structure to keep the state of a channel lock.
sc_report * get_last_report()
bool is_unwinding() const
virtual void enable_process(sc_descendant_inclusion_info descendants=SC_NO_DESCENDANTS)=0
sc_timestamp possible_wakeup_time
static sc_process_handle last_created_process_handle()
int m_instance_id
The instance ID of this process.
sc_event * m_term_event_p
int * segment_ids
stores the upcoming segment ids TS 07/08/17
sc_process_handle sc_get_current_process_handle()
sc_time m_time_count
The value of timed cycles.
bool operator>=(const sc_timestamp &) const
Overload >= operator.
virtual void add_child_object(sc_object *)
virtual void throw_user(const sc_throw_it_helper &helper, sc_descendant_inclusion_info descendants=SC_NO_DESCENDANTS)=0
Base class for all structural entities.
void unlock_all_channels(void)
Release all the channel locks.
Abstract base class for class sc_port_b.
sc_timestamp m_timestamp
The local time stamp of this process.
void increase_offset(int offset)
increase the offset ZC 10:30 2018/10/31
virtual ~sc_process_monitor()
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)
bool operator>(const sc_timestamp &) const
Overload > operator.
friend bool heap_cmp(sc_process_b *&, sc_process_b *&)
Base class for all hierarchical channels.
virtual void throw_it()=0
bool operator==(const sc_timestamp &) const
Overload == operator.
const char * gen_unique_name(const char *basename_, bool preserve_first)
void lock_and_push(CHNL_MTX_TYPE_ *lock)
Acquire a new channel lock or increment the lock counter.
sc_timestamp wake_up_time_for_event_list
bool operator<(const sc_timestamp &) const
Overload < operator.
std::vector< sc_reset * > m_resets
void set_timestamp(const sc_timestamp &ts)
Get the local time stamp of this process.
virtual ~sc_throw_it_helper()
void sc_set_stack_size(sc_method_handle, std::size_t)
bool operator!=(const sc_timestamp &) const
Overload != operator.
void add_static_event(const sc_event &)
sc_event * m_resume_event_p
sc_chnl_lock(CHNL_MTX_TYPE_ *m)
The constructor initializes the lock pointer and counter.
This is the base class for objects which may have processes defined for their methods (e...
sc_process_b * cur_invoker_method_handle
int socket_id_
stores the upcoming socket id ZC 10:31 2018/10/31
void set_instance_id(int id)
Get the instance ID of this process.
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
void disconnect_process()
virtual bool terminated() const
sc_process_b * m_runnable_p
virtual void throw_reset(bool async)=0
int get_upcoming_socket_id()
returns the upcoming socket id ZC 10:31 2018/10/31
bool heap_cmp(sc_process_b *&s, sc_process_b *&t)
const sc_timestamp & get_timestamp()
Set the local time stamp of this process.
friend sc_process_handle sc_get_current_process_handle()
const ::std::vector< sc_object * > & get_child_objects() const
value_type get_delta_count() const
Get the value of delta cycles.
int * get_upcoming_segment_ids()
returns the upcoming segment ids TS 07/08/17
virtual void resume_process(sc_descendant_inclusion_info descendants=SC_NO_DESCENDANTS)=0
bool event_list_member_triggered
void unlock_all(void)
Release all the channel locks in the list.
virtual void signal(sc_thread_handle thread_p, int type)
void set_segment_id(int id)
Get the current segment ID of this process.
void pop_and_unlock(CHNL_MTX_TYPE_ *lock)
Release a channel lock or decrement the lock counter.
virtual bool remove_child_object(sc_object *object_p)
int m_process_state
The name of this process.
Abstract base class of all SystemC `simulation' objects.
int get_offset()
returns the offset ZC 10:31 2018/10/31
void initially_in_reset(bool async)
const sc_event_list * m_event_list_p