SystemC  Recoding Infrastructure for SystemC v0.6.2 derived from Accellera SystemC 2.3.1
Accellera SystemC proof-of-concept library
sc_cthread_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_cthread_process.h -- Clocked thread declarations
21 
22  Original Author: Andy Goodrich, Forte Design Systems, 4 August 2005
23 
24 
25  CHANGE LOG AT THE END OF THE FILE
26  *****************************************************************************/
27 
28 
29 #if !defined(sc_cthread_process_h_INCLUDED)
30 #define sc_cthread_process_h_INCLUDED
31 
33 
34 namespace sc_core {
35 
36 // friend function declarations:
37 
38 void halt( sc_simcontext* );
39 void wait( int, sc_simcontext* );
40 
41 
42 /**************************************************************************/
48 
49  friend class sc_module;
50 
51  // 04/07/2015 GL: a new sc_channel class is derived from sc_module
52  friend class sc_channel;
53 
54  friend class sc_process_handle;
55  friend class sc_process_table;
56  friend class sc_thread_process;
57  friend class sc_simcontext;
58 
59  friend void sc_cthread_cor_fn( void* );
60 
61  // 08/19/2015 GL: modified for the OoO simulation
62  friend void halt( int, sc_simcontext* );
63  friend void wait( int, int, sc_simcontext* );
64 
65  public:
66  sc_cthread_process( const char* name_p, bool free_host,
67  SC_ENTRY_FUNC method_p, sc_process_host* host_p,
68  const sc_spawn_options* opt_p );
69 
70  virtual void dont_initialize( bool dont );
71  virtual const char* kind() const
72  { return "sc_cthread_process"; }
73 
74 private:
75 
76  sc_cthread_process( const char* nm,
77  SC_ENTRY_FUNC fn,
78  sc_process_host* host );
79 
80  // may not be deleted manually (called from sc_process_b)
81  virtual ~sc_cthread_process();
82 
83  bool eval_watchlist();
84  bool eval_watchlist_curr_level();
85 
90  // 08/19/2015 GL: modified for the OoO simulation
91  void wait_halt( int );
92 
93 };
94 
95 //------------------------------------------------------------------------------
96 //"sc_cthread_process::wait_halt"
97 //
98 //------------------------------------------------------------------------------
99 inline void sc_cthread_process::wait_halt( int seg_id )
100 {
101  // 05/25/2015 GL: sc_kernel_lock constructor acquires the kernel lock
102  sc_kernel_lock lock;
103 
104 #ifdef SC_LOCK_CHECK
105  assert( sc_get_curr_simcontext()->is_locked_and_owner() );
106 #endif /* SC_LOCK_CHECK */
107 
108  // 08/19/2015 GL: set the new segment ID of this thread
109  set_segment_id( seg_id );
110 
111  // 04/28/2015 GL: release all the channel locks (not sure sc_cthread
112  // can be used in sc_channel)
114 
115  m_wait_cycle_n = 0;
116  suspend_me();
117 
118  // 04/28/2015 GL: as we are going to throw an exception, we do not need
119  // to acquire the channel locks
120  throw sc_halt();
121  // 05/25/2015 GL: sc_kernel_lock destructor releases the kernel lock
122 }
123 
124 } // namespace sc_core
125 
126 // $Log: sc_cthread_process.h,v $
127 // Revision 1.8 2011/08/26 20:46:09 acg
128 // Andy Goodrich: moved the modification log to the end of the file to
129 // eliminate source line number skew when check-ins are done.
130 //
131 // Revision 1.7 2011/02/18 20:27:14 acg
132 // Andy Goodrich: Updated Copyrights.
133 //
134 // Revision 1.6 2011/02/13 21:47:37 acg
135 // Andy Goodrich: update copyright notice.
136 //
137 // Revision 1.5 2011/02/11 13:25:24 acg
138 // Andy Goodrich: Philipp A. Hartmann's changes:
139 // (1) Removal of SC_CTHREAD method overloads.
140 // (2) New exception processing code.
141 //
142 // Revision 1.4 2011/02/01 21:01:41 acg
143 // Andy Goodrich: removed throw_reset() as it is now handled by the parent
144 // method sc_thread_process::throw_reset().
145 //
146 // Revision 1.3 2011/01/18 20:10:44 acg
147 // Andy Goodrich: changes for IEEE1666_2011 semantics.
148 //
149 // Revision 1.2 2008/05/22 17:06:25 acg
150 // Andy Goodrich: updated copyright notice to include 2008.
151 //
152 // Revision 1.1.1.1 2006/12/15 20:20:05 acg
153 // SystemC 2.3
154 //
155 // Revision 1.6 2006/05/08 17:57:13 acg
156 // Andy Goodrich: Added David Long's forward declarations for friend functions
157 // to keep the Microsoft C++ compiler happy.
158 //
159 // Revision 1.5 2006/04/20 17:08:16 acg
160 // Andy Goodrich: 3.0 style process changes.
161 //
162 // Revision 1.4 2006/04/11 23:13:20 acg
163 // Andy Goodrich: Changes for reduced reset support that only includes
164 // sc_cthread, but has preliminary hooks for expanding to method and thread
165 // processes also.
166 //
167 // Revision 1.3 2006/01/13 18:44:29 acg
168 // Added $Log to record CVS changes into the source.
169 //
170 
171 #endif // !defined(sc_cthread_process_h_INCLUDED)
void halt(sc_simcontext *)
This class provides access to an sc_process_b object instance in a manner which allows some persisten...
void(sc_process_host::* SC_ENTRY_FUNC)()
Definition: sc_process.h:212
void wait(int, sc_simcontext *)
bool dont_initialize() const
Definition: sc_process.h:741
friend void sc_cthread_cor_fn(void *)
sc_cthread_process(const char *name_p, bool free_host, SC_ENTRY_FUNC method_p, sc_process_host *host_p, const sc_spawn_options *opt_p)
The simulation context.
Base class for all structural entities.
Definition: sc_module.h:83
void unlock_all_channels(void)
Release all the channel locks.
virtual const char * kind() const
Base class for all hierarchical channels.
Definition: sc_module.h:712
sc_simcontext * sc_get_curr_simcontext()
This is the base class for objects which may have processes defined for their methods (e...
Definition: sc_process.h:149
friend void wait(int, int, sc_simcontext *)
A new parameter segment ID is added for the out-of-order simulation.
void set_segment_id(int id)
Get the current segment ID of this process.
friend void halt(int, sc_simcontext *)
A new parameter segment ID is added for the out-of-order simulation.