SystemC  2.3.2
Accellera SystemC proof-of-concept library
sc_reset.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_reset.h -- Process reset support.
23 */
33 #if !defined(sc_reset_h_INCLUDED)
34 #define sc_reset_h_INCLUDED
35 
37 
38 #if defined(_MSC_VER) && !defined(SC_WIN_DLL_WARN)
39 #pragma warning(push)
40 #pragma warning(disable: 4251) // DLL import for std::vector
41 #endif
42 
43 namespace sc_core {
44 
45 // FORWARD CLASS REFERENCES:
46 
47 template<typename DATA> class sc_signal_in_if;
48 template<typename IF, sc_writer_policy POL> class sc_signal;
49 template<typename DATA> class sc_in;
50 template<typename DATA> class sc_inout;
51 template<typename DATA> class sc_out;
52 template<typename SOURCE> class sc_spawn_reset;
53 class sc_reset;
54 class sc_process_b;
55 
56 //==============================================================================
57 // CLASS sc_reset_target - RESET ENTRY FOR AN sc_process_b TARGET
58 //
59 // This class describes a reset condition associated with an sc_process_b
60 // instance.
61 //==============================================================================
63  public:
64  bool m_async; // true asynchronous reset, false synchronous.
65  bool m_level; // level for reset.
66  sc_process_b* m_process_p; // process this reset entry is for.
67 };
68 
69 inline std::ostream& operator << ( std::ostream& os,
70  const sc_reset_target& target )
71 {
72  os << "[";
73  os << target.m_async << ",";
74  os << target.m_level << ",";
75  os << target.m_process_p << ",";
76  return os;
77 }
78 
79 
80 //==============================================================================
81 // sc_reset_finder - place holder class for a port reset signal until it is
82 // bound and an interface class is available. When the port
83 // has been bound the information in this class will be used
84 // to initialize its sc_reset object instance.
85 //==============================================================================
87  friend class sc_reset;
88  friend class sc_simcontext;
89 public:
90  sc_reset_finder( bool async, const sc_in<bool>* port_p, bool level,
91  sc_process_b* target_p);
92  sc_reset_finder( bool async, const sc_inout<bool>* port_p, bool level,
93  sc_process_b* target_p);
94  sc_reset_finder( bool async, const sc_out<bool>* port_p, bool level,
95  sc_process_b* target_p);
96 
97 protected:
98  bool m_async; // True if asynchronous reset.
99  bool m_level; // Level for reset.
100  sc_reset_finder* m_next_p; // Next reset finder in list.
101  const sc_in<bool>* m_in_p; // Port for which reset is needed.
102  const sc_inout<bool>* m_inout_p; // Port for which reset is needed.
103  const sc_out<bool>* m_out_p; // Port for which reset is needed.
104  sc_process_b* m_target_p; // Process to reset.
105 
106 private: // disabled
108  const sc_reset_finder& operator = ( const sc_reset_finder& );
109 };
110 
111 //==============================================================================
112 // CLASS sc_reset - RESET INFORMATION FOR A RESET SIGNAL
113 //
114 // See the top of sc_reset.cpp for an explaination of how the reset mechanism
115 // is implemented.
116 //==============================================================================
118  friend class sc_cthread_process;
119  friend class sc_method_process;
120  friend class sc_module;
121  friend class sc_process_b;
122  friend class sc_signal<bool, SC_ONE_WRITER>;
123  friend class sc_signal<bool, SC_MANY_WRITERS>;
124  friend class sc_signal<bool, SC_UNCHECKED_WRITERS>;
125  friend class sc_simcontext;
126  template<typename SOURCE> friend class sc_spawn_reset;
127  friend class sc_thread_process;
128 
129  protected:
130  static void reconcile_resets(sc_reset_finder* reset_finder_q);
131  static void
132  reset_signal_is(bool async, const sc_signal_in_if<bool>& iface,
133  bool level);
134  static void
135  reset_signal_is( bool async, const sc_in<bool>& iface, bool level);
136  static void
137  reset_signal_is( bool async, const sc_inout<bool>& iface, bool level);
138  static void
139  reset_signal_is( bool async, const sc_out<bool>& iface, bool level);
140 
141  protected:
142  sc_reset( const sc_signal_in_if<bool>* iface_p ) :
143  m_iface_p(iface_p), m_targets() {}
144  void notify_processes();
145  void remove_process( sc_process_b* );
146 
147  protected:
148  const sc_signal_in_if<bool>* m_iface_p; // Interface to read.
149  std::vector<sc_reset_target> m_targets; // List of processes to reset.
150 
151  private: // disabled
152  sc_reset( const sc_reset& );
153  const sc_reset& operator = ( const sc_reset& );
154 };
155 
156 // $Log: sc_reset.h,v $
157 // Revision 1.11 2011/08/26 20:46:10 acg
158 // Andy Goodrich: moved the modification log to the end of the file to
159 // eliminate source line number skew when check-ins are done.
160 //
161 // Revision 1.10 2011/08/24 22:05:51 acg
162 // Torsten Maehne: initialization changes to remove warnings.
163 //
164 // Revision 1.9 2011/04/08 22:38:30 acg
165 // Andy Goodrich: added comment pointing to the description of how the
166 // reset mechanism works that is in sc_reset.cpp.
167 //
168 // Revision 1.8 2011/02/18 20:27:14 acg
169 // Andy Goodrich: Updated Copyrights.
170 //
171 // Revision 1.7 2011/02/13 21:47:37 acg
172 // Andy Goodrich: update copyright notice.
173 //
174 // Revision 1.6 2011/01/06 18:00:32 acg
175 // Andy Goodrich: Removed commented out code.
176 //
177 // Revision 1.5 2010/12/07 20:09:14 acg
178 // Andy Goodrich: removed sc_signal signatures since already have sc_signal_in_if signatures.
179 //
180 // Revision 1.4 2010/11/20 17:10:57 acg
181 // Andy Goodrich: reset processing changes for new IEEE 1666 standard.
182 //
183 // Revision 1.3 2009/05/22 16:06:29 acg
184 // Andy Goodrich: process control updates.
185 //
186 // Revision 1.2 2008/05/22 17:06:26 acg
187 // Andy Goodrich: updated copyright notice to include 2008.
188 //
189 // Revision 1.1.1.1 2006/12/15 20:20:05 acg
190 // SystemC 2.3
191 //
192 // Revision 1.6 2006/12/02 20:58:19 acg
193 // Andy Goodrich: updates from 2.2 for IEEE 1666 support.
194 //
195 // Revision 1.4 2006/04/11 23:13:21 acg
196 // Andy Goodrich: Changes for reduced reset support that only includes
197 // sc_cthread, but has preliminary hooks for expanding to method and thread
198 // processes also.
199 //
200 // Revision 1.3 2006/01/13 18:44:30 acg
201 // Added $Log to record CVS changes into the source.
202 
203 } // namespace sc_core
204 
205 #if defined(_MSC_VER) && !defined(SC_WIN_DLL_WARN)
206 #pragma warning(pop)
207 #endif
208 
209 #endif // !defined(sc_reset_h_INCLUDED)
inline ::std::ostream & operator<<(::std::ostream &os, const sc_fifo< T > &a)
Definition: sc_fifo.h:431
Specialization of sc_signal_in_if<T> for type bool.
operand is not sc_logic object already exists internal maximum number of processes per module module construction not properly hierarchical name as shown may be incorrect due to previous errors incorrect use of sc_module_name set time resolution failed default time unit changed to time resolution immediate notification is not allowed during update phase or elaboration use reset_signal_is()" ) SC_DEFINE_MESSAGE(SC_ID_DONT_INITIALIZE_
const sc_in< bool > * m_in_p
Definition: sc_reset.h:101
Specialization of sc_inout<T> for type bool.
unique writer (from a unique port)
Base class for all structural entities.
Definition: sc_module.h:83
const sc_out< bool > * m_out_p
Definition: sc_reset.h:103
sc_process_b * m_process_p
Definition: sc_reset.h:66
The simulation context.
std::vector< sc_reset_target > m_targets
Definition: sc_reset.h:149
sc_process_b * m_target_p
Definition: sc_reset.h:104
Specialization of sc_in<T> for type bool.
const sc_inout< bool > * m_inout_p
Definition: sc_reset.h:102
even allow delta cycle conflicts (non-standard)
class SC_API sc_reset
Definition: sc_signal.h:399
sc_reset(const sc_signal_in_if< bool > *iface_p)
Definition: sc_reset.h:142
sc_reset_finder * m_next_p
Definition: sc_reset.h:100
const sc_signal_in_if< bool > * m_iface_p
Definition: sc_reset.h:148
The sc_signal<T> writer policy definition.
#define SC_API
Definition: sc_cmnhdr.h:168
allow multiple writers (with different ports)