SystemC  2.3.2
Accellera SystemC proof-of-concept library
sc_except.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4  more contributor license agreements. See the NOTICE file distributed
5  with this work for additional information regarding copyright ownership.
6  Accellera licenses this file to you under the Apache License, Version 2.0
7  (the "License"); you may not use this file except in compliance with the
8  License. You may obtain a copy of the License at
9 
10  http://www.apache.org/licenses/LICENSE-2.0
11 
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15  implied. See the License for the specific language governing
16  permissions and limitations under the License.
17 
18  *****************************************************************************/
19 
20 /*****************************************************************************
21 
22  sc_except.h - Exception classes to be handled by SystemC.
23 
24  Original Author: Stan Y. Liao, Synopsys, Inc.
25 
26  CHANGE LOG AT THE END OF THE FILE
27  *****************************************************************************/
28 
29 
30 #ifndef SC_EXCEPT_H
31 #define SC_EXCEPT_H
32 
33 #include <exception>
34 #include "sysc/kernel/sc_cmnhdr.h"
35 
36 #if defined(_MSC_VER) && !defined(SC_WIN_DLL_WARN)
37 # pragma warning(push)
38 # pragma warning(disable:4275) // ignore missing std::exception DLL export
39 #endif
40 
41 namespace sc_core {
42 
43 class sc_simcontext;
44 class sc_process_b;
45 class sc_method_process;
46 class sc_thread_process;
47 void sc_thread_cor_fn( void* arg );
48 
49 /*
50  * These classes are intentionally empty. Their raison d'etre is for
51  * the implementation of various SystemC throws.
52  */
53 
55 {
56  /*EMPTY*/
57 public:
58  sc_user() {}
59  sc_user( const sc_user& ) {}
60 };
61 
63 {
64 public:
65  sc_halt() {}
66  sc_halt( const sc_halt& ) {}
67 };
68 
70 {
71 public:
72  sc_kill() {}
73  sc_kill( const sc_kill& ) {}
74 };
75 
76 class SC_API sc_unwind_exception : public std::exception
77 {
78  friend class sc_simcontext;
79  friend class sc_process_b;
80  friend class sc_method_process;
81  friend class sc_thread_process;
82  friend void sc_thread_cor_fn( void* arg );
83 
84  public:
85  virtual bool is_reset() const { return m_is_reset; }
86  virtual const char* what() const throw();
87 
88  public:
89 
90  // enable catch by value
92  virtual ~sc_unwind_exception() throw();
93 
94  protected:
95  explicit
96  sc_unwind_exception( sc_process_b* target_p, bool is_reset = false );
97 
98  bool active() const;
99  void clear() const;
100 
101  private:
102  // disabled
103  sc_unwind_exception& operator=( const sc_unwind_exception& );
104 
105  mutable sc_process_b* m_proc_p; // used to check, if caught by the kernel
106  const bool m_is_reset; // true if this is an unwind of a reset
107 
108 };
109 
110 inline
112  : std::exception( that )
113  , m_proc_p( that.m_proc_p )
114  , m_is_reset( that.m_is_reset )
115 {
116  that.m_proc_p = 0; // move to new instance
117 }
118 
119 //------------------------------------------------------------------------------
120 // global exception handling
121 //------------------------------------------------------------------------------
122 
123 class sc_report;
125 
126 } // namespace sc_core
127 
128 #if defined(_MSC_VER) && !defined(SC_WIN_DLL_WARN)
129 # pragma warning(pop)
130 #endif
131 
132 /*****************************************************************************
133 
134  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
135  changes you are making here.
136 
137  Name, Affiliation, Date: Gene Bushuyev. Synopsys, Inc.
138  Description of Modification: - Had to add empty public default and copy
139  constructors to satisfy VC6.0.
140 
141  Name, Affiliation, Date:
142  Description of Modification:
143 
144  *****************************************************************************/
145 
146 // $Log: sc_except.h,v $
147 // Revision 1.11 2011/08/26 21:40:26 acg
148 // Philipp A. Hartmann: fix up sc_unwind_exception copy-ctor.
149 //
150 // Revision 1.10 2011/08/26 20:46:09 acg
151 // Andy Goodrich: moved the modification log to the end of the file to
152 // eliminate source line number skew when check-ins are done.
153 //
154 // Revision 1.9 2011/08/24 22:05:50 acg
155 // Torsten Maehne: initialization changes to remove warnings.
156 //
157 // Revision 1.8 2011/05/09 04:07:48 acg
158 // Philipp A. Hartmann:
159 // (1) Restore hierarchy in all phase callbacks.
160 // (2) Ensure calls to before_end_of_elaboration.
161 //
162 // Revision 1.7 2011/02/18 20:27:14 acg
163 // Andy Goodrich: Updated Copyrights.
164 //
165 // Revision 1.6 2011/02/13 21:47:37 acg
166 // Andy Goodrich: update copyright notice.
167 //
168 // Revision 1.5 2011/02/11 13:25:24 acg
169 // Andy Goodrich: Philipp A. Hartmann's changes:
170 // (1) Removal of SC_CTHREAD method overloads.
171 // (2) New exception processing code.
172 //
173 // Revision 1.4 2011/01/18 20:10:44 acg
174 // Andy Goodrich: changes for IEEE1666_2011 semantics.
175 //
176 // Revision 1.3 2009/05/22 16:06:29 acg
177 // Andy Goodrich: process control updates.
178 //
179 // Revision 1.2 2008/05/22 17:06:25 acg
180 // Andy Goodrich: updated copyright notice to include 2008.
181 //
182 // Revision 1.1.1.1 2006/12/15 20:20:05 acg
183 // SystemC 2.3
184 //
185 // Revision 1.3 2006/01/13 18:44:29 acg
186 // Added $Log to record CVS changes into the source.
187 
188 #endif
sc_user(const sc_user &)
Definition: sc_except.h:59
virtual bool is_reset() const
Definition: sc_except.h:85
sc_kill(const sc_kill &)
Definition: sc_except.h:73
SC_API sc_report * sc_handle_exception()
Exception reporting.
Definition: sc_report.h:121
void sc_thread_cor_fn(void *arg)
The simulation context.
sc_halt(const sc_halt &)
Definition: sc_except.h:66
STL namespace.
sc_unwind_exception(const sc_unwind_exception &)
Definition: sc_except.h:111
sc_process_b sc_process_b
Definition: sc_process.h:458
class SC_API sc_simcontext
Definition: sc_object.h:51
#define SC_API
Definition: sc_cmnhdr.h:168