SystemC  2.3.2
Accellera SystemC proof-of-concept library
sc_writer_policy.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_writer_policy.h -- The sc_signal<T> writer policy definition
23 */
34 #ifndef SC_WRITER_POLICY_H_INCLUDED_
35 #define SC_WRITER_POLICY_H_INCLUDED_
36 
37 #if !defined(SC_DEFAULT_WRITER_POLICY)
38 # if defined(SC_NO_WRITE_CHECK)
39 # define SC_DEFAULT_WRITER_POLICY SC_UNCHECKED_WRITERS
40 # else
41 # define SC_DEFAULT_WRITER_POLICY SC_ONE_WRITER
42 # endif
43 #endif
44 
46 
47 #if defined(_MSC_VER) && _MSC_VER < 1800
48 # pragma warning(push)
49 # pragma warning(disable:4512) // assignment operator could not be generated
50 #endif // _MSC_VER < 1800
51 
52 namespace sc_core {
53 
54 class sc_object;
55 class sc_port_base;
56 extern
57 SC_API void
58 sc_signal_invalid_writer( sc_object* target, sc_object* first_writer,
59  sc_object* second_writer, bool check_delta );
60 
61 // SIGNAL WRITING POLICIES
62 //
63 // Note: if you add a new policy to the enum below you will need to add
64 // an additional overload of sc_reset::reset_signal_is() for the sc_signal<bool>
65 // instance. That will require changes to sysc/kernel/sc_reset.cpp and
66 // sysc/kernel/sc_reset.h
67 
69 {
73 };
74 
75 // signal forward declaration
76 template< typename T, sc_writer_policy POL = SC_DEFAULT_WRITER_POLICY >
77 class sc_signal;
78 
79 template< sc_writer_policy >
81 
83 {
84  bool check_write( sc_object* /* target */, bool /* value_changed */ )
85  { return true; }
86  bool needs_update() const { return false; }
87  void update() {}
88 };
89 
91 {
92  bool check_write( sc_object* target, bool value_changed );
93  bool needs_update() const { return m_delta_only; }
94  void update();
95 
96 private:
97  static bool only_delta();
98 
99 protected:
100  sc_writer_policy_check_write( bool delta_only = only_delta() )
101  : m_delta_only( delta_only ), m_writer_p() {}
102 
103  const bool m_delta_only;
105 };
106 
109 {
110  // bool write_check(sc_object*, bool); /* inherited */
111 
112  // always force update phase to reset process
113  bool needs_update() const { return true; }
114 
115  // reset current writer during update phase
116  void update() { sc_process_handle().swap( m_writer_p ); }
117 
118 protected:
121 };
122 
124 {
126  { return true; }
127 };
128 
130 {
131  bool check_port( sc_object* target, sc_port_base* port, bool is_output );
132 
133 protected:
134  sc_writer_policy_check_port() : m_output(0) {}
136 };
137 
138 template<>
142 {};
143 
144 template<>
148 {};
149 
150 template<>
154 {};
155 
156 } // namespace sc_core
157 
158 #if defined(_MSC_VER) && _MSC_VER < 1800
159 # pragma warning(pop)
160 #endif // _MSC_VER < 1800
161 
162 #endif // SC_WRITER_POLICY_H_INCLUDED_
163 // Taf!
Abstract base class of all SystemC `simulation&#39; objects.
Definition: sc_object.h:61
unique writer (from a unique port)
Abstract base class for class sc_port_b.
Definition: sc_port.h:81
Process access support.
sc_writer_policy_check_write(bool delta_only=only_delta())
void swap(sc_process_handle &other)
class SC_API sc_port_base
Definition: sc_interface.h:41
even allow delta cycle conflicts (non-standard)
bool check_port(sc_object *, sc_port_base *, bool)
SC_API void sc_signal_invalid_writer(sc_object *target, sc_object *first_writer, sc_object *second_writer, bool check_delta)
#define SC_API
Definition: sc_cmnhdr.h:168
allow multiple writers (with different ports)