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