SystemC  2.3.1
Accellera SystemC proof-of-concept library
sc_except.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_except.h - Exception classes to be handled by SystemC.
21 
22  Original Author: Stan Y. Liao, Synopsys, Inc.
23 
24  CHANGE LOG AT THE END OF THE FILE
25  *****************************************************************************/
26 
27 
28 #ifndef SC_EXCEPT_H
29 #define SC_EXCEPT_H
30 
31 #include <exception>
32 
33 namespace sc_core {
34 
35 class sc_simcontext;
36 class sc_process_b;
37 class sc_method_process;
38 class sc_thread_process;
39 void sc_thread_cor_fn( void* arg );
40 
41 /*
42  * These classes are intentionally empty. Their raison d'etre is for
43  * the implementation of various SystemC throws.
44  */
45 
46 class sc_user
47 {
48  /*EMPTY*/
49 public:
50  sc_user() {}
51  sc_user( const sc_user& ) {}
52 };
53 
54 class sc_halt
55 {
56 public:
57  sc_halt() {}
58  sc_halt( const sc_halt& ) {}
59 };
60 
61 class sc_kill
62 {
63 public:
64  sc_kill() {}
65  sc_kill( const sc_kill& ) {}
66 };
67 
68 class sc_unwind_exception : public std::exception
69 {
70  friend class sc_simcontext;
71  friend class sc_process_b;
72  friend class sc_method_process;
73  friend class sc_thread_process;
74  friend void sc_thread_cor_fn( void* arg );
75 
76  public:
77  virtual bool is_reset() const { return m_is_reset; }
78  virtual const char* what() const throw();
79 
80  public:
81 
82  // enable catch by value
84  virtual ~sc_unwind_exception() throw();
85 
86  protected:
87  explicit
88  sc_unwind_exception( sc_process_b* target_p, bool is_reset = false );
89 
90  bool active() const;
91  void clear() const;
92 
93  private:
94  // disabled
95  sc_unwind_exception& operator=( const sc_unwind_exception& );
96 
97  mutable sc_process_b* m_proc_p; // used to check, if caught by the kernel
98  const bool m_is_reset; // true if this is an unwind of a reset
99 
100 };
101 
102 inline
103 sc_unwind_exception::sc_unwind_exception( const sc_unwind_exception& that )
104  : std::exception( that )
105  , m_proc_p( that.m_proc_p )
106  , m_is_reset( that.m_is_reset )
107 {
108  that.m_proc_p = 0; // move to new instance
109 }
110 
111 //------------------------------------------------------------------------------
112 // global exception handling
113 //------------------------------------------------------------------------------
114 
115 class sc_report;
117 
118 } // namespace sc_core
119 
120 /*****************************************************************************
121 
122  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
123  changes you are making here.
124 
125  Name, Affiliation, Date: Gene Bushuyev. Synopsys, Inc.
126  Description of Modification: - Had to add empty public default and copy
127  constructors to satisfy VC6.0.
128 
129  Name, Affiliation, Date:
130  Description of Modification:
131 
132  *****************************************************************************/
133 
134 // $Log: sc_except.h,v $
135 // Revision 1.11 2011/08/26 21:40:26 acg
136 // Philipp A. Hartmann: fix up sc_unwind_exception copy-ctor.
137 //
138 // Revision 1.10 2011/08/26 20:46:09 acg
139 // Andy Goodrich: moved the modification log to the end of the file to
140 // eliminate source line number skew when check-ins are done.
141 //
142 // Revision 1.9 2011/08/24 22:05:50 acg
143 // Torsten Maehne: initialization changes to remove warnings.
144 //
145 // Revision 1.8 2011/05/09 04:07:48 acg
146 // Philipp A. Hartmann:
147 // (1) Restore hierarchy in all phase callbacks.
148 // (2) Ensure calls to before_end_of_elaboration.
149 //
150 // Revision 1.7 2011/02/18 20:27:14 acg
151 // Andy Goodrich: Updated Copyrights.
152 //
153 // Revision 1.6 2011/02/13 21:47:37 acg
154 // Andy Goodrich: update copyright notice.
155 //
156 // Revision 1.5 2011/02/11 13:25:24 acg
157 // Andy Goodrich: Philipp A. Hartmann's changes:
158 // (1) Removal of SC_CTHREAD method overloads.
159 // (2) New exception processing code.
160 //
161 // Revision 1.4 2011/01/18 20:10:44 acg
162 // Andy Goodrich: changes for IEEE1666_2011 semantics.
163 //
164 // Revision 1.3 2009/05/22 16:06:29 acg
165 // Andy Goodrich: process control updates.
166 //
167 // Revision 1.2 2008/05/22 17:06:25 acg
168 // Andy Goodrich: updated copyright notice to include 2008.
169 //
170 // Revision 1.1.1.1 2006/12/15 20:20:05 acg
171 // SystemC 2.3
172 //
173 // Revision 1.3 2006/01/13 18:44:29 acg
174 // Added $Log to record CVS changes into the source.
175 
176 #endif
virtual bool is_reset() const
Definition: sc_except.h:77
sc_process_b sc_process_b
Definition: sc_process.h:447
sc_halt(const sc_halt &)
Definition: sc_except.h:58
sc_kill(const sc_kill &)
Definition: sc_except.h:65
friend void sc_thread_cor_fn(void *arg)
void sc_thread_cor_fn(void *arg)
virtual const char * what() const
sc_user(const sc_user &)
Definition: sc_except.h:51
sc_report * sc_handle_exception()