SystemC 3.0.0
Accellera SystemC proof-of-concept library
sc_fifo_ports.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_fifo_ports.h -- The sc_fifo<T> port classes.
23
24 Original Author: Martin Janssen, Synopsys, Inc., 2001-05-21
25
26 CHANGE LOG IS AT THE END OF THE FILE
27 *****************************************************************************/
28
29#ifndef SC_FIFO_PORTS_H
30#define SC_FIFO_PORTS_H
31
32
35
36namespace sc_core {
37
38// ----------------------------------------------------------------------------
39// CLASS : sc_fifo_in<T>
40//
41// The sc_fifo<T> input port class.
42// ----------------------------------------------------------------------------
43
44template <class T>
46: public sc_port<sc_fifo_in_if<T>,0,SC_ONE_OR_MORE_BOUND>
47{
48public:
49
50 // typedefs
51
52 typedef T data_type;
53
57
60
61public:
62
63 // constructors
64
66 : base_type()
67 , m_written_finder_p()
68 {}
69
70 explicit sc_fifo_in( const char* name_ )
71 : base_type( name_ )
72 , m_written_finder_p()
73 {}
74
75 explicit sc_fifo_in( in_if_type& interface_ )
76 : base_type( interface_ )
77 , m_written_finder_p()
78 {}
79
80 sc_fifo_in( const char* name_, in_if_type& interface_ )
81 : base_type( name_, interface_ )
82 , m_written_finder_p()
83 {}
84
85 explicit sc_fifo_in( in_port_type& parent_ )
86 : base_type( parent_ )
87 , m_written_finder_p()
88 {}
89
90 sc_fifo_in( const char* name_, in_port_type& parent_ )
91 : base_type( name_, parent_ )
92 , m_written_finder_p()
93 {}
94
96 : base_type( parent_ )
97 , m_written_finder_p()
98 {}
99
100 sc_fifo_in( const char* name_, this_type& parent_ )
101 : base_type( name_, parent_ )
102 , m_written_finder_p()
103 {}
104
105
106 // destructor
107
108 virtual ~sc_fifo_in()
109 {
110 delete m_written_finder_p;
111 }
112
113
114 // interface access shortcut methods
115
116 // blocking read
117
118 void read( data_type& value_ )
119 { (*this)->read( value_ ); }
120
122 { return (*this)->read(); }
123
124
125 // non-blocking read
126
127 bool nb_read( data_type& value_ )
128 { return (*this)->nb_read( value_ ); }
129
130
131 // get the number of available samples
132
133 int num_available() const
134 { return (*this)->num_available(); }
135
136
137 // get the data written event
138
140 { return (*this)->data_written_event(); }
141
142
143 // use for static sensitivity to data written event
144
146 {
148 ( m_written_finder_p, *this, &in_if_type::data_written_event );
149 }
150
151 virtual const char* kind() const
152 { return "sc_fifo_in"; }
153
154private:
155 mutable sc_event_finder* m_written_finder_p;
156
157 // disabled
158 sc_fifo_in( const this_type& );
159 this_type& operator = ( const this_type& );
160};
161
162
163// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
164
165// ----------------------------------------------------------------------------
166// CLASS : sc_fifo_out<T>
167//
168// The sc_fifo<T> output port class.
169// ----------------------------------------------------------------------------
170
171template <class T>
173: public sc_port<sc_fifo_out_if<T>,0,SC_ONE_OR_MORE_BOUND>
174{
175public:
176
177 // typedefs
178
179 typedef T data_type;
180
184
187
188public:
189
190 // constructors
191
193 : base_type()
194 , m_read_finder_p()
195 {}
196
197 explicit sc_fifo_out( const char* name_ )
198 : base_type( name_ )
199 , m_read_finder_p()
200 {}
201
202 explicit sc_fifo_out( out_if_type& interface_ )
203 : base_type( interface_ )
204 , m_read_finder_p()
205 {}
206
207 sc_fifo_out( const char* name_, out_if_type& interface_ )
208 : base_type( name_, interface_ )
209 , m_read_finder_p()
210 {}
211
212 explicit sc_fifo_out( out_port_type& parent_ )
213 : base_type( parent_ )
214 , m_read_finder_p()
215 {}
216
217 sc_fifo_out( const char* name_, out_port_type& parent_ )
218 : base_type( name_, parent_ )
219 , m_read_finder_p()
220 {}
221
223 : base_type( parent_ )
224 , m_read_finder_p()
225 {}
226
227 sc_fifo_out( const char* name_, this_type& parent_ )
228 : base_type( name_, parent_ )
229 , m_read_finder_p()
230 {}
231
232
233 // destructor
234
235 virtual ~sc_fifo_out()
236 {
237 delete m_read_finder_p;
238 }
239
240
241 // interface access shortcut methods
242
243 // blocking write
244
245 void write( const data_type& value_ )
246 { (*this)->write( value_ ); }
247
248
249 // non-blocking write
250
251 bool nb_write( const data_type& value_ )
252 { return (*this)->nb_write( value_ ); }
253
254
255 // get the number of free spaces
256
257 int num_free() const
258 { return (*this)->num_free(); }
259
260
261 // get the data read event
262
264 { return (*this)->data_read_event(); }
265
266
267 // use for static sensitivity to data read event
268
270 {
272 ( m_read_finder_p, *this, &out_if_type::data_read_event );
273 }
274
275 virtual const char* kind() const
276 { return "sc_fifo_out"; }
277
278private:
279 mutable sc_event_finder* m_read_finder_p;
280
281 // disabled
282 sc_fifo_out( const this_type& );
283 this_type& operator = ( const this_type& );
284};
285
286
287// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
288
289} // namespace sc_core
290
291//$Log: sc_fifo_ports.h,v $
292//Revision 1.3 2011/08/26 20:45:40 acg
293// Andy Goodrich: moved the modification log to the end of the file to
294// eliminate source line number skew when check-ins are done.
295//
296//Revision 1.2 2011/02/18 20:23:45 acg
297// Andy Goodrich: Copyright update.
298//
299//Revision 1.1.1.1 2006/12/15 20:20:04 acg
300//SystemC 2.3
301//
302//Revision 1.2 2006/01/03 23:18:26 acg
303//Changed copyright to include 2006.
304//
305//Revision 1.1.1.1 2005/12/19 23:16:43 acg
306//First check in of SystemC 2.1 into its own archive.
307//
308//Revision 1.10 2005/09/15 23:01:51 acg
309//Added std:: prefix to appropriate methods and types to get around
310//issues with the Edison Front End.
311//
312//Revision 1.9 2005/06/10 22:43:55 acg
313//Added CVS change log annotation.
314//
315
316#endif
317
318// Taf!
static sc_event_finder & cached_create(sc_event_finder *&cache_p, const sc_port_base &port_, const sc_event &(IF::*ef_p)() const)
virtual const sc_event & data_written_event() const =0
virtual const sc_event & data_read_event() const =0
void read(data_type &value_)
sc_port_b< in_if_type > in_port_type
Definition: sc_fifo_ports.h:59
sc_fifo_in< data_type > this_type
Definition: sc_fifo_ports.h:56
sc_port< if_type, 0, SC_ONE_OR_MORE_BOUND > base_type
Definition: sc_fifo_ports.h:55
sc_fifo_in(const char *name_, in_port_type &parent_)
Definition: sc_fifo_ports.h:90
sc_fifo_in_if< data_type > if_type
Definition: sc_fifo_ports.h:54
sc_event_finder & data_written() const
int num_available() const
sc_fifo_in(const char *name_, in_if_type &interface_)
Definition: sc_fifo_ports.h:80
const sc_event & data_written_event() const
sc_fifo_in(in_if_type &interface_)
Definition: sc_fifo_ports.h:75
bool nb_read(data_type &value_)
virtual const char * kind() const
sc_fifo_in(const char *name_, this_type &parent_)
sc_fifo_in(in_port_type &parent_)
Definition: sc_fifo_ports.h:85
sc_fifo_in(this_type &parent_)
Definition: sc_fifo_ports.h:95
sc_fifo_in(const char *name_)
Definition: sc_fifo_ports.h:70
void write(const data_type &value_)
sc_port< if_type, 0, SC_ONE_OR_MORE_BOUND > base_type
sc_fifo_out(this_type &parent_)
sc_fifo_out(out_port_type &parent_)
sc_fifo_out(out_if_type &interface_)
sc_fifo_out(const char *name_)
bool nb_write(const data_type &value_)
sc_fifo_out(const char *name_, out_if_type &interface_)
sc_fifo_out(const char *name_, out_port_type &parent_)
sc_fifo_out(const char *name_, this_type &parent_)
sc_fifo_out_if< data_type > if_type
sc_port_b< out_if_type > out_port_type
sc_fifo_out< data_type > this_type
virtual const char * kind() const
sc_event_finder & data_read() const
const sc_event & data_read_event() const