SystemC  2.3.2
Accellera SystemC proof-of-concept library
sc_buffer.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_buffer.h -- The sc_buffer<T> primitive channel class.
23 */
34 #ifndef SC_BUFFER_H
35 #define SC_BUFFER_H
36 
37 
39 
40 namespace sc_core {
41 
48 template< typename T, sc_writer_policy POL = SC_DEFAULT_WRITER_POLICY >
49 class sc_buffer
50 : public sc_signal<T,POL>
51 {
52 public:
53 
54  // typedefs
55 
58  typedef T value_type;
59 
60 public:
61 
62  // constructors
63 
65  : base_type( sc_gen_unique_name( "buffer" ) )
66  {}
67 
68  explicit sc_buffer( const char* name_ )
69  : base_type( name_ )
70  {}
71 
72  sc_buffer( const char* name_, const value_type& initial_value_ )
73  : base_type( name_, initial_value_ )
74  {}
75 
76  // interface methods
77 
78  // write the new value
79  virtual void write( const T& );
80 
81 
82  // other methods
83 
84  virtual const char* kind() const
85  { return "sc_buffer"; }
86 
87 
88  // assignment
89  this_type& operator = ( const value_type& a )
90  { base_type::operator=(a); return *this; }
91 
93  { base_type::operator=(a); return *this; }
94 
95  this_type& operator = ( const this_type& a )
96  { base_type::operator=(a); return *this; }
97 
98 protected:
99 
100  virtual void update();
101 
102 private:
103 
104  // disabled
105  sc_buffer( const this_type& );
106 };
107 
108 
109 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
110 
111 // write the new value
112 
113 template< typename T, sc_writer_policy POL >
114 inline
115 void
116 sc_buffer<T,POL>::write( const T& value_ )
117 {
118  if( !base_type::policy_type::check_write(this,true) )
119  return;
120 
121  this->m_new_val = value_;
122  this->request_update();
123 }
124 
125 
126 template< typename T, sc_writer_policy POL >
127 inline
128 void
130 {
131  base_type::policy_type::update();
133 }
134 
135 } // namespace sc_core
136 
137 #endif
138 
139 //$Log: sc_buffer.h,v $
140 //Revision 1.7 2011/08/26 20:45:39 acg
141 // Andy Goodrich: moved the modification log to the end of the file to
142 // eliminate source line number skew when check-ins are done.
143 //
144 //Revision 1.6 2011/04/08 18:22:45 acg
145 // Philipp A. Hartmann: use the context of the primitive channel to get
146 // the change stamp value.
147 //
148 //Revision 1.5 2011/04/05 20:48:09 acg
149 // Andy Goodrich: changes to make sure that event(), posedge() and negedge()
150 // only return true if the clock has not moved.
151 //
152 //Revision 1.4 2011/04/05 06:15:18 acg
153 // Philipp A. Hartmann: sc_writer_policy: ignore no-ops in delta check.
154 //
155 //Revision 1.3 2011/02/18 20:23:45 acg
156 // Andy Goodrich: Copyright update.
157 //
158 //Revision 1.2 2010/12/07 19:50:36 acg
159 // Andy Goodrich: addition of writer policies, courtesy of Philipp Hartmann.
160 //
161 //Revision 1.1.1.1 2006/12/15 20:20:04 acg
162 //SystemC 2.3
163 //
164 //Revision 1.8 2006/03/13 20:19:43 acg
165 // Andy Goodrich: changed sc_event instances into pointers to sc_event instances
166 // that are allocated as needed. This saves considerable storage for large
167 // numbers of signals, etc.
168 //
169 //Revision 1.7 2006/01/26 21:00:49 acg
170 // Andy Goodrich: conversion to use sc_event::notify(SC_ZERO_TIME) instead of
171 // sc_event::notify_delayed()
172 //
173 //Revision 1.6 2006/01/24 20:46:31 acg
174 //Andy Goodrich: changes to eliminate use of deprecated features. For instance,
175 //using notify(SC_ZERO_TIME) in place of notify_delayed().
176 //
177 //Revision 1.5 2006/01/19 19:18:25 acg
178 //Andy Goodrich: eliminated check_writer in favor of inline code within the
179 //write() method since we always execute the check_writer code even when
180 //check writing is turned off.
181 //
182 //Revision 1.4 2006/01/19 00:30:57 acg
183 //Andy Goodrich: Yet another implementation for disabling write checks on
184 //signals. This version uses an environment variable, SC_SIGNAL_WRITE_CHECK,
185 //that when set to DISABLE will turn off write checking.
186 //
187 //Revision 1.3 2006/01/13 18:47:20 acg
188 //Reversed sense of multiwriter signal check. It now defaults to ON unless the
189 //user defines SC_NO_WRITE_CHEK before inclusion of the file.
190 //
191 //Revision 1.2 2006/01/03 23:18:26 acg
192 //Changed copyright to include 2006.
193 //
194 //Revision 1.1.1.1 2005/12/19 23:16:43 acg
195 //First check in of SystemC 2.1 into its own archive.
196 //
197 //Revision 1.9 2005/06/10 22:43:55 acg
198 //Added CVS change log annotation.
199 //
200 
201 // Taf!
The sc_signal<T> primitive channel class.
virtual void write(const T &)
Definition: sc_buffer.h:116
virtual const char * kind() const
Definition: sc_buffer.h:84
this_type & operator=(const value_type &a)
Definition: sc_signal.h:378
sc_buffer< T, POL > this_type
Definition: sc_buffer.h:56
this_type & operator=(const value_type &a)
Definition: sc_buffer.h:89
SC_API const char * sc_gen_unique_name(const char *, bool preserve_first)
sc_signal< T, POL > base_type
Definition: sc_buffer.h:57
sc_buffer(const char *name_, const value_type &initial_value_)
Definition: sc_buffer.h:72
sc_buffer(const char *name_)
Definition: sc_buffer.h:68
virtual void update()
Definition: sc_buffer.h:129