00001 /***************************************************************************** 00002 00003 The following code is derived, directly or indirectly, from the SystemC 00004 source code Copyright (c) 1996-2014 by all Contributors. 00005 All Rights reserved. 00006 00007 The contents of this file are subject to the restrictions and limitations 00008 set forth in the SystemC Open Source License (the "License"); 00009 You may not use this file except in compliance with such restrictions and 00010 limitations. You may obtain instructions on how to receive a copy of the 00011 License at http://www.accellera.org/. Software distributed by Contributors 00012 under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF 00013 ANY KIND, either express or implied. See the License for the specific 00014 language governing rights and limitations under the License. 00015 00016 *****************************************************************************/ 00017 00018 /***************************************************************************** 00019 00020 sc_cthread_process.h -- Clocked thread declarations 00021 00022 Original Author: Andy Goodrich, Forte Design Systems, 4 August 2005 00023 00024 00025 CHANGE LOG AT THE END OF THE FILE 00026 *****************************************************************************/ 00027 00028 00029 #if !defined(sc_cthread_process_h_INCLUDED) 00030 #define sc_cthread_process_h_INCLUDED 00031 00032 #include "sysc/kernel/sc_thread_process.h" 00033 00034 namespace sc_core { 00035 00036 // friend function declarations: 00037 00038 void halt( sc_simcontext* ); 00039 void wait( int, sc_simcontext* ); 00040 00041 00042 /**************************************************************************/ 00047 class sc_cthread_process : public sc_thread_process { 00048 00049 friend class sc_module; 00050 00051 // 04/07/2015 GL: a new sc_channel class is derived from sc_module 00052 friend class sc_channel; 00053 00054 friend class sc_process_handle; 00055 friend class sc_process_table; 00056 friend class sc_thread_process; 00057 friend class sc_simcontext; 00058 00059 friend void sc_cthread_cor_fn( void* ); 00060 00061 // 08/19/2015 GL: modified for the OoO simulation 00062 friend void halt( int, sc_simcontext* ); 00063 friend void wait( int, int, sc_simcontext* ); 00064 00065 public: 00066 sc_cthread_process( const char* name_p, bool free_host, 00067 SC_ENTRY_FUNC method_p, sc_process_host* host_p, 00068 const sc_spawn_options* opt_p ); 00069 00070 virtual void dont_initialize( bool dont ); 00071 virtual const char* kind() const 00072 { return "sc_cthread_process"; } 00073 00074 private: 00075 00076 sc_cthread_process( const char* nm, 00077 SC_ENTRY_FUNC fn, 00078 sc_process_host* host ); 00079 00080 // may not be deleted manually (called from sc_process_b) 00081 virtual ~sc_cthread_process(); 00082 00083 bool eval_watchlist(); 00084 bool eval_watchlist_curr_level(); 00085 00090 // 08/19/2015 GL: modified for the OoO simulation 00091 void wait_halt( int ); 00092 00093 }; 00094 00095 //------------------------------------------------------------------------------ 00096 //"sc_cthread_process::wait_halt" 00097 // 00098 //------------------------------------------------------------------------------ 00099 inline void sc_cthread_process::wait_halt( int seg_id ) 00100 { 00101 // 05/25/2015 GL: sc_kernel_lock constructor acquires the kernel lock 00102 sc_kernel_lock lock; 00103 00104 #ifdef SC_LOCK_CHECK 00105 assert( sc_get_curr_simcontext()->is_locked_and_owner() ); 00106 #endif /* SC_LOCK_CHECK */ 00107 00108 // 08/19/2015 GL: set the new segment ID of this thread 00109 set_segment_id( seg_id ); 00110 00111 // 04/28/2015 GL: release all the channel locks (not sure sc_cthread 00112 // can be used in sc_channel) 00113 unlock_all_channels(); 00114 00115 m_wait_cycle_n = 0; 00116 suspend_me(); 00117 00118 // 04/28/2015 GL: as we are going to throw an exception, we do not need 00119 // to acquire the channel locks 00120 throw sc_halt(); 00121 // 05/25/2015 GL: sc_kernel_lock destructor releases the kernel lock 00122 } 00123 00124 } // namespace sc_core 00125 00126 // $Log: sc_cthread_process.h,v $ 00127 // Revision 1.8 2011/08/26 20:46:09 acg 00128 // Andy Goodrich: moved the modification log to the end of the file to 00129 // eliminate source line number skew when check-ins are done. 00130 // 00131 // Revision 1.7 2011/02/18 20:27:14 acg 00132 // Andy Goodrich: Updated Copyrights. 00133 // 00134 // Revision 1.6 2011/02/13 21:47:37 acg 00135 // Andy Goodrich: update copyright notice. 00136 // 00137 // Revision 1.5 2011/02/11 13:25:24 acg 00138 // Andy Goodrich: Philipp A. Hartmann's changes: 00139 // (1) Removal of SC_CTHREAD method overloads. 00140 // (2) New exception processing code. 00141 // 00142 // Revision 1.4 2011/02/01 21:01:41 acg 00143 // Andy Goodrich: removed throw_reset() as it is now handled by the parent 00144 // method sc_thread_process::throw_reset(). 00145 // 00146 // Revision 1.3 2011/01/18 20:10:44 acg 00147 // Andy Goodrich: changes for IEEE1666_2011 semantics. 00148 // 00149 // Revision 1.2 2008/05/22 17:06:25 acg 00150 // Andy Goodrich: updated copyright notice to include 2008. 00151 // 00152 // Revision 1.1.1.1 2006/12/15 20:20:05 acg 00153 // SystemC 2.3 00154 // 00155 // Revision 1.6 2006/05/08 17:57:13 acg 00156 // Andy Goodrich: Added David Long's forward declarations for friend functions 00157 // to keep the Microsoft C++ compiler happy. 00158 // 00159 // Revision 1.5 2006/04/20 17:08:16 acg 00160 // Andy Goodrich: 3.0 style process changes. 00161 // 00162 // Revision 1.4 2006/04/11 23:13:20 acg 00163 // Andy Goodrich: Changes for reduced reset support that only includes 00164 // sc_cthread, but has preliminary hooks for expanding to method and thread 00165 // processes also. 00166 // 00167 // Revision 1.3 2006/01/13 18:44:29 acg 00168 // Added $Log to record CVS changes into the source. 00169 // 00170 00171 #endif // !defined(sc_cthread_process_h_INCLUDED)