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