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_except.h - Exception classes to be handled by SystemC. 00021 00022 Original Author: Stan Y. Liao, Synopsys, Inc. 00023 00024 CHANGE LOG AT THE END OF THE FILE 00025 *****************************************************************************/ 00026 00027 00028 #ifndef SC_EXCEPT_H 00029 #define SC_EXCEPT_H 00030 00031 #include <exception> 00032 00033 namespace sc_core { 00034 00035 class sc_simcontext; 00036 class sc_process_b; 00037 class sc_method_process; 00038 class sc_thread_process; 00039 void sc_thread_cor_fn( void* arg ); 00040 00041 /* 00042 * These classes are intentionally empty. Their raison d'etre is for 00043 * the implementation of various SystemC throws. 00044 */ 00045 00046 class sc_user 00047 { 00048 /*EMPTY*/ 00049 public: 00050 sc_user() {} 00051 sc_user( const sc_user& ) {} 00052 }; 00053 00054 class sc_halt 00055 { 00056 public: 00057 sc_halt() {} 00058 sc_halt( const sc_halt& ) {} 00059 }; 00060 00061 class sc_kill 00062 { 00063 public: 00064 sc_kill() {} 00065 sc_kill( const sc_kill& ) {} 00066 }; 00067 00068 class sc_unwind_exception : public std::exception 00069 { 00070 friend class sc_simcontext; 00071 friend class sc_process_b; 00072 friend class sc_method_process; 00073 friend class sc_thread_process; 00074 friend void sc_thread_cor_fn( void* arg ); 00075 friend void sc_method_cor_fn( void* arg ); 00076 00077 public: 00078 virtual bool is_reset() const { return m_is_reset; } 00079 virtual const char* what() const throw(); 00080 00081 public: 00082 00083 // enable catch by value 00084 sc_unwind_exception( const sc_unwind_exception& ); 00085 virtual ~sc_unwind_exception() throw(); 00086 00087 protected: 00088 explicit 00089 sc_unwind_exception( sc_process_b* target_p, bool is_reset = false ); 00090 00091 bool active() const; 00092 void clear() const; 00093 00094 private: 00095 // disabled 00096 sc_unwind_exception& operator=( const sc_unwind_exception& ); 00097 00098 mutable sc_process_b* m_proc_p; // used to check, if caught by the kernel 00099 const bool m_is_reset; // true if this is an unwind of a reset 00100 00101 }; 00102 00103 inline 00104 sc_unwind_exception::sc_unwind_exception( const sc_unwind_exception& that ) 00105 : std::exception( that ) 00106 , m_proc_p( that.m_proc_p ) 00107 , m_is_reset( that.m_is_reset ) 00108 { 00109 that.m_proc_p = 0; // move to new instance 00110 } 00111 00112 //------------------------------------------------------------------------------ 00113 // global exception handling 00114 //------------------------------------------------------------------------------ 00115 00116 class sc_report; 00117 sc_report* sc_handle_exception(); 00118 00119 } // namespace sc_core 00120 00121 /***************************************************************************** 00122 00123 MODIFICATION LOG - modifiers, enter your name, affiliation, date and 00124 changes you are making here. 00125 00126 Name, Affiliation, Date: Gene Bushuyev. Synopsys, Inc. 00127 Description of Modification: - Had to add empty public default and copy 00128 constructors to satisfy VC6.0. 00129 00130 Name, Affiliation, Date: 00131 Description of Modification: 00132 00133 *****************************************************************************/ 00134 00135 // $Log: sc_except.h,v $ 00136 // Revision 1.11 2011/08/26 21:40:26 acg 00137 // Philipp A. Hartmann: fix up sc_unwind_exception copy-ctor. 00138 // 00139 // Revision 1.10 2011/08/26 20:46:09 acg 00140 // Andy Goodrich: moved the modification log to the end of the file to 00141 // eliminate source line number skew when check-ins are done. 00142 // 00143 // Revision 1.9 2011/08/24 22:05:50 acg 00144 // Torsten Maehne: initialization changes to remove warnings. 00145 // 00146 // Revision 1.8 2011/05/09 04:07:48 acg 00147 // Philipp A. Hartmann: 00148 // (1) Restore hierarchy in all phase callbacks. 00149 // (2) Ensure calls to before_end_of_elaboration. 00150 // 00151 // Revision 1.7 2011/02/18 20:27:14 acg 00152 // Andy Goodrich: Updated Copyrights. 00153 // 00154 // Revision 1.6 2011/02/13 21:47:37 acg 00155 // Andy Goodrich: update copyright notice. 00156 // 00157 // Revision 1.5 2011/02/11 13:25:24 acg 00158 // Andy Goodrich: Philipp A. Hartmann's changes: 00159 // (1) Removal of SC_CTHREAD method overloads. 00160 // (2) New exception processing code. 00161 // 00162 // Revision 1.4 2011/01/18 20:10:44 acg 00163 // Andy Goodrich: changes for IEEE1666_2011 semantics. 00164 // 00165 // Revision 1.3 2009/05/22 16:06:29 acg 00166 // Andy Goodrich: process control updates. 00167 // 00168 // Revision 1.2 2008/05/22 17:06:25 acg 00169 // Andy Goodrich: updated copyright notice to include 2008. 00170 // 00171 // Revision 1.1.1.1 2006/12/15 20:20:05 acg 00172 // SystemC 2.3 00173 // 00174 // Revision 1.3 2006/01/13 18:44:29 acg 00175 // Added $Log to record CVS changes into the source. 00176 00177 #endif