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