SystemC  2.3.1
Accellera SystemC proof-of-concept library
sc_reset.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_reset.h -- Process reset support.
21 
22  Original Author: Andy Goodrich, Forte Design Systems, 17 June 2003
23 
24  CHANGE LOG AT THE END OF THE FILE
25  *****************************************************************************/
26 
27 #if !defined(sc_reset_h_INCLUDED)
28 #define sc_reset_h_INCLUDED
29 
31 
32 namespace sc_core {
33 
34 // FORWARD CLASS REFERENCES:
35 
36 template<typename DATA> class sc_signal_in_if;
37 template<typename IF, sc_writer_policy POL> class sc_signal;
38 template<typename DATA> class sc_in;
39 template<typename DATA> class sc_inout;
40 template<typename DATA> class sc_out;
41 template<typename SOURCE> class sc_spawn_reset;
42 class sc_reset;
43 class sc_process_b;
44 
45 //==============================================================================
46 // CLASS sc_reset_target - RESET ENTRY FOR AN sc_process_b TARGET
47 //
48 // This class describes a reset condition associated with an sc_process_b
49 // instance.
50 //==============================================================================
52  public:
53  bool m_async; // true asynchronous reset, false synchronous.
54  bool m_level; // level for reset.
55  sc_process_b* m_process_p; // process this reset entry is for.
56 };
57 
58 inline std::ostream& operator << ( std::ostream& os,
59  const sc_reset_target& target )
60 {
61  os << "[";
62  os << target.m_async << ",";
63  os << target.m_level << ",";
64  os << target.m_process_p << ",";
65  return os;
66 }
67 
68 //==============================================================================
69 // CLASS sc_reset - RESET INFORMATION FOR A RESET SIGNAL
70 //
71 // See the top of sc_reset.cpp for an explaination of how the reset mechanism
72 // is implemented.
73 //==============================================================================
74 class sc_reset {
75  friend class sc_cthread_process;
76  friend class sc_method_process;
77  friend class sc_module;
78  friend class sc_process_b;
79  friend class sc_signal<bool, SC_ONE_WRITER>;
80  friend class sc_signal<bool, SC_MANY_WRITERS>;
81  friend class sc_signal<bool, SC_UNCHECKED_WRITERS>;
82  friend class sc_simcontext;
83  template<typename SOURCE> friend class sc_spawn_reset;
84  friend class sc_thread_process;
85 
86  protected:
87  static void reconcile_resets();
88  static void
89  reset_signal_is(bool async, const sc_signal_in_if<bool>& iface,
90  bool level);
91  static void
92  reset_signal_is( bool async, const sc_in<bool>& iface, bool level);
93  static void
94  reset_signal_is( bool async, const sc_inout<bool>& iface, bool level);
95  static void
96  reset_signal_is( bool async, const sc_out<bool>& iface, bool level);
97 
98  protected:
99  sc_reset( const sc_signal_in_if<bool>* iface_p ) :
100  m_iface_p(iface_p), m_targets() {}
101  void notify_processes();
102  void remove_process( sc_process_b* );
103 
104  protected:
105  const sc_signal_in_if<bool>* m_iface_p; // Interface to read.
106  std::vector<sc_reset_target> m_targets; // List of processes to reset.
107 
108  private: // disabled
109  sc_reset( const sc_reset& );
110  const sc_reset& operator = ( const sc_reset& );
111 };
112 
113 // $Log: sc_reset.h,v $
114 // Revision 1.11 2011/08/26 20:46:10 acg
115 // Andy Goodrich: moved the modification log to the end of the file to
116 // eliminate source line number skew when check-ins are done.
117 //
118 // Revision 1.10 2011/08/24 22:05:51 acg
119 // Torsten Maehne: initialization changes to remove warnings.
120 //
121 // Revision 1.9 2011/04/08 22:38:30 acg
122 // Andy Goodrich: added comment pointing to the description of how the
123 // reset mechanism works that is in sc_reset.cpp.
124 //
125 // Revision 1.8 2011/02/18 20:27:14 acg
126 // Andy Goodrich: Updated Copyrights.
127 //
128 // Revision 1.7 2011/02/13 21:47:37 acg
129 // Andy Goodrich: update copyright notice.
130 //
131 // Revision 1.6 2011/01/06 18:00:32 acg
132 // Andy Goodrich: Removed commented out code.
133 //
134 // Revision 1.5 2010/12/07 20:09:14 acg
135 // Andy Goodrich: removed sc_signal signatures since already have sc_signal_in_if signatures.
136 //
137 // Revision 1.4 2010/11/20 17:10:57 acg
138 // Andy Goodrich: reset processing changes for new IEEE 1666 standard.
139 //
140 // Revision 1.3 2009/05/22 16:06:29 acg
141 // Andy Goodrich: process control updates.
142 //
143 // Revision 1.2 2008/05/22 17:06:26 acg
144 // Andy Goodrich: updated copyright notice to include 2008.
145 //
146 // Revision 1.1.1.1 2006/12/15 20:20:05 acg
147 // SystemC 2.3
148 //
149 // Revision 1.6 2006/12/02 20:58:19 acg
150 // Andy Goodrich: updates from 2.2 for IEEE 1666 support.
151 //
152 // Revision 1.4 2006/04/11 23:13:21 acg
153 // Andy Goodrich: Changes for reduced reset support that only includes
154 // sc_cthread, but has preliminary hooks for expanding to method and thread
155 // processes also.
156 //
157 // Revision 1.3 2006/01/13 18:44:30 acg
158 // Added $Log to record CVS changes into the source.
159 
160 } // namespace sc_core
161 
162 #endif // !defined(sc_reset_h_INCLUDED)
static void reset_signal_is(bool async, const sc_signal_in_if< bool > &iface, bool level)
inline::std::ostream & operator<<(::std::ostream &os, const sc_fifo< T > &a)
Definition: sc_fifo.h:424
unique writer (from a unique port)
static void reconcile_resets()
void remove_process(sc_process_b *)
allow multiple writers (with different ports)
std::vector< sc_reset_target > m_targets
Definition: sc_reset.h:106
sc_process_b * m_process_p
Definition: sc_reset.h:55
even allow delta cycle conflicts (non-standard)
sc_reset(const sc_signal_in_if< bool > *iface_p)
Definition: sc_reset.h:99
const sc_signal_in_if< bool > * m_iface_p
Definition: sc_reset.h:105