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