SystemC  2.3.1
Accellera SystemC proof-of-concept library
sc_writer_policy.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_writer_policy.h -- The sc_signal<T> writer policy definition
21 
22  Original Author: Philipp A: Hartmann, OFFIS
23 
24  CHANGE LOG IS AT THE END OF THE FILE
25  *****************************************************************************/
26 
27 
28 #ifndef SC_WRITER_POLICY_H_INCLUDED_
29 #define SC_WRITER_POLICY_H_INCLUDED_
30 
31 #if !defined(SC_DEFAULT_WRITER_POLICY)
32 # if defined(SC_NO_WRITE_CHECK)
33 # define SC_DEFAULT_WRITER_POLICY SC_UNCHECKED_WRITERS
34 # else
35 # define SC_DEFAULT_WRITER_POLICY SC_ONE_WRITER
36 # endif
37 #endif
38 
39 namespace sc_core {
40 
41 class sc_object;
42 class sc_port_base;
43 extern
44 void
45 sc_signal_invalid_writer( sc_object* target, sc_object* first_writer,
46  sc_object* second_writer, bool check_delta );
47 
48 // SIGNAL WRITING POLICIES
49 //
50 // Note: if you add a new policy to the enum below you will need to add
51 // an additional overload of sc_reset::reset_signal_is() for the sc_signal<bool>
52 // instance. That will require changes to sysc/kernel/sc_reset.cpp and
53 // sysc/kernel/sc_reset.h
54 
56 {
60 };
61 
62 // signal forward declaration
63 template< typename T, sc_writer_policy POL = SC_DEFAULT_WRITER_POLICY >
64 class sc_signal;
65 
66 template< sc_writer_policy >
68 
70 {
71  bool check_write( sc_object* /* target */, bool /* value_changed */ )
72  { return true; }
73  void update(){}
74 };
75 
77 {
78  bool check_write( sc_object* target, bool value_changed );
79  void update(){}
80 protected:
81  sc_writer_policy_check_write( bool check_delta = false )
82  : m_check_delta( check_delta ), m_writer_p(NULL) {}
83  const bool m_check_delta;
85 };
86 
89 {
90 
93 
94  bool check_write( sc_object* target, bool value_changed )
95  {
96  if( value_changed )
97  return sc_writer_policy_check_write::check_write( target, true );
98  return true;
99  }
100 
101  void update(){ m_writer_p = NULL; }
102 };
103 
105 {
107  { return true; }
108 };
109 
111 {
112  bool check_port( sc_object* target, sc_port_base* port, bool is_output );
113 
114 protected:
117 };
118 
119 template<>
123 {};
124 
125 template<>
129 {};
130 
131 template<>
135 {};
136 
137 } // namespace sc_core
138 
139 #endif
140 
141 // Taf!
unique writer (from a unique port)
bool check_port(sc_object *target, sc_port_base *port, bool is_output)
sc_writer_policy_check_write(bool check_delta=false)
allow multiple writers (with different ports)
even allow delta cycle conflicts (non-standard)
bool check_port(sc_object *, sc_port_base *, bool)
void sc_signal_invalid_writer(sc_object *target, sc_object *first_writer, sc_object *second_writer, bool check_delta)
bool check_write(sc_object *target, bool value_changed)
Definition: sc_signal.h:52
bool check_write(sc_object *target, bool value_changed)