SystemC  2.3.2
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 */
33 #ifndef SC_FIFO_PORTS_H
34 #define SC_FIFO_PORTS_H
35 
36 
39 
40 namespace sc_core {
41 
48 template <class T>
50 : public sc_port<sc_fifo_in_if<T>,0,SC_ONE_OR_MORE_BOUND>
51 {
52 public:
53 
54  // typedefs
55 
56  typedef T data_type;
57 
61 
62  typedef if_type in_if_type;
64 
65 public:
66 
67  // constructors
68 
70  : base_type()
71  {}
72 
73  explicit sc_fifo_in( const char* name_ )
74  : base_type( name_ )
75  {}
76 
77  explicit sc_fifo_in( in_if_type& interface_ )
78  : base_type( interface_ )
79  {}
80 
81  sc_fifo_in( const char* name_, in_if_type& interface_ )
82  : base_type( name_, interface_ )
83  {}
84 
85  explicit sc_fifo_in( in_port_type& parent_ )
86  : base_type( parent_ )
87  {}
88 
89  sc_fifo_in( const char* name_, in_port_type& parent_ )
90  : base_type( name_, parent_ )
91  {}
92 
93  sc_fifo_in( this_type& parent_ )
94  : base_type( parent_ )
95  {}
96 
97  sc_fifo_in( const char* name_, this_type& parent_ )
98  : base_type( name_, parent_ )
99  {}
100 
101 
102  // destructor (does nothing)
103 
104  virtual ~sc_fifo_in()
105  {}
106 
107 
108  // interface access shortcut methods
109 
110  // blocking read
111 
112  void read( data_type& value_ )
113  { (*this)->read( value_ ); }
114 
115  data_type read()
116  { return (*this)->read(); }
117 
118 
119  // non-blocking read
120 
121  bool nb_read( data_type& value_ )
122  { return (*this)->nb_read( value_ ); }
123 
124 
125  // get the number of available samples
126 
127  int num_available() const
128  { return (*this)->num_available(); }
129 
130 
131  // get the data written event
132 
134  { return (*this)->data_written_event(); }
135 
136 
137  // use for static sensitivity to data written event
138 
140  {
141  return *new sc_event_finder_t<in_if_type>(
143  }
144 
145  virtual const char* kind() const
146  { return "sc_fifo_in"; }
147 
148 private:
149 
150  // disabled
151  sc_fifo_in( const this_type& );
152  this_type& operator = ( const this_type& );
153 };
154 
155 
156 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
157 
164 template <class T>
166 : public sc_port<sc_fifo_out_if<T>,0,SC_ONE_OR_MORE_BOUND>
167 {
168 public:
169 
170  // typedefs
171 
172  typedef T data_type;
173 
177 
178  typedef if_type out_if_type;
180 
181 public:
182 
183  // constructors
184 
186  : base_type()
187  {}
188 
189  explicit sc_fifo_out( const char* name_ )
190  : base_type( name_ )
191  {}
192 
193  explicit sc_fifo_out( out_if_type& interface_ )
194  : base_type( interface_ )
195  {}
196 
197  sc_fifo_out( const char* name_, out_if_type& interface_ )
198  : base_type( name_, interface_ )
199  {}
200 
201  explicit sc_fifo_out( out_port_type& parent_ )
202  : base_type( parent_ )
203  {}
204 
205  sc_fifo_out( const char* name_, out_port_type& parent_ )
206  : base_type( name_, parent_ )
207  {}
208 
209  sc_fifo_out( this_type& parent_ )
210  : base_type( parent_ )
211  {}
212 
213  sc_fifo_out( const char* name_, this_type& parent_ )
214  : base_type( name_, parent_ )
215  {}
216 
217 
218  // destructor (does nothing)
219 
220  virtual ~sc_fifo_out()
221  {}
222 
223 
224  // interface access shortcut methods
225 
226  // blocking write
227 
228  void write( const data_type& value_ )
229  { (*this)->write( value_ ); }
230 
231 
232  // non-blocking write
233 
234  bool nb_write( const data_type& value_ )
235  { return (*this)->nb_write( value_ ); }
236 
237 
238  // get the number of free spaces
239 
240  int num_free() const
241  { return (*this)->num_free(); }
242 
243 
244  // get the data read event
245 
246  const sc_event& data_read_event() const
247  { return (*this)->data_read_event(); }
248 
249 
250  // use for static sensitivity to data read event
251 
253  {
254  return *new sc_event_finder_t<out_if_type>(
255  *this, &out_if_type::data_read_event );
256  }
257 
258  virtual const char* kind() const
259  { return "sc_fifo_out"; }
260 
261 private:
262 
263  // disabled
264  sc_fifo_out( const this_type& );
265  this_type& operator = ( const this_type& );
266 };
267 
268 
269 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
270 
271 } // namespace sc_core
272 
273 //$Log: sc_fifo_ports.h,v $
274 //Revision 1.3 2011/08/26 20:45:40 acg
275 // Andy Goodrich: moved the modification log to the end of the file to
276 // eliminate source line number skew when check-ins are done.
277 //
278 //Revision 1.2 2011/02/18 20:23:45 acg
279 // Andy Goodrich: Copyright update.
280 //
281 //Revision 1.1.1.1 2006/12/15 20:20:04 acg
282 //SystemC 2.3
283 //
284 //Revision 1.2 2006/01/03 23:18:26 acg
285 //Changed copyright to include 2006.
286 //
287 //Revision 1.1.1.1 2005/12/19 23:16:43 acg
288 //First check in of SystemC 2.1 into its own archive.
289 //
290 //Revision 1.10 2005/09/15 23:01:51 acg
291 //Added std:: prefix to appropriate methods and types to get around
292 //issues with the Edison Front End.
293 //
294 //Revision 1.9 2005/06/10 22:43:55 acg
295 //Added CVS change log annotation.
296 //
297 
298 #endif
299 
300 // Taf!
sc_fifo_in(const char *name_)
Definition: sc_fifo_ports.h:73
sc_fifo_out< data_type > this_type
sc_fifo_in_if< data_type > if_type
Definition: sc_fifo_ports.h:58
sc_fifo_in(in_if_type &interface_)
Definition: sc_fifo_ports.h:77
sc_port< if_type, 0, SC_ONE_OR_MORE_BOUND > base_type
Definition: sc_fifo_ports.h:59
sc_event_finder & data_written() const
sc_fifo_in< data_type > this_type
Definition: sc_fifo_ports.h:60
virtual const char * kind() const
sc_fifo_out(const char *name_, this_type &parent_)
sc_fifo_in(const char *name_, this_type &parent_)
Definition: sc_fifo_ports.h:97
Base classes of all port classes.
sc_port< if_type, 0, SC_ONE_OR_MORE_BOUND > base_type
Generic port class and base class for other port classes.
Definition: sc_port.h:391
Event finder base class.
virtual const sc_event & data_written_event() const =0
The event class.
Definition: sc_event.h:256
bool nb_read(data_type &value_)
void write(const data_type &value_)
const sc_event & data_read_event() const
Abstract base class for class sc_port.
Definition: sc_port.h:267
virtual const char * kind() const
sc_fifo_out(this_type &parent_)
The sc_fifo<T> interface classes.
sc_fifo_out(const char *name_, out_port_type &parent_)
sc_fifo_out_if< data_type > if_type
sc_port_b< in_if_type > in_port_type
Definition: sc_fifo_ports.h:63
bool nb_write(const data_type &value_)
sc_fifo_out(const char *name_)
const sc_event & data_written_event() const
sc_fifo_in(in_port_type &parent_)
Definition: sc_fifo_ports.h:85
sc_fifo_out(const char *name_, out_if_type &interface_)
void read(data_type &value_)
sc_fifo_out(out_if_type &interface_)
sc_fifo_out(out_port_type &parent_)
sc_port_b< out_if_type > out_port_type
sc_event_finder & data_read() const
sc_fifo_in(const char *name_, in_if_type &interface_)
Definition: sc_fifo_ports.h:81
int num_available() const
sc_fifo_in(this_type &parent_)
Definition: sc_fifo_ports.h:93
sc_fifo_in(const char *name_, in_port_type &parent_)
Definition: sc_fifo_ports.h:89