sc_fifo_ports.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002 
00003   The following code is derived, directly or indirectly, from the SystemC
00004   source code Copyright (c) 1996-2006 by all Contributors.
00005   All Rights reserved.
00006 
00007   The contents of this file are subject to the restrictions and limitations
00008   set forth in the SystemC Open Source License Version 2.4 (the "License");
00009   You may not use this file except in compliance with such restrictions and
00010   limitations. You may obtain instructions on how to receive a copy of the
00011   License at http://www.systemc.org/. Software distributed by Contributors
00012   under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
00013   ANY KIND, either express or implied. See the License for the specific
00014   language governing rights and limitations under the License.
00015 
00016  *****************************************************************************/
00017 
00018 /*****************************************************************************
00019 
00020   sc_fifo_ports.h -- The sc_fifo<T> port classes.
00021 
00022   Original Author: Martin Janssen, Synopsys, Inc., 2001-05-21
00023 
00024  *****************************************************************************/
00025 
00026 /*****************************************************************************
00027 
00028   MODIFICATION LOG - modifiers, enter your name, affiliation, date and
00029   changes you are making here.
00030 
00031       Name, Affiliation, Date:
00032   Description of Modification:
00033     
00034  *****************************************************************************/
00035 //$Log: sc_fifo_ports.h,v $
00036 //Revision 1.1.1.1  2006/12/15 20:31:35  acg
00037 //SystemC 2.2
00038 //
00039 //Revision 1.2  2006/01/03 23:18:26  acg
00040 //Changed copyright to include 2006.
00041 //
00042 //Revision 1.1.1.1  2005/12/19 23:16:43  acg
00043 //First check in of SystemC 2.1 into its own archive.
00044 //
00045 //Revision 1.10  2005/09/15 23:01:51  acg
00046 //Added std:: prefix to appropriate methods and types to get around
00047 //issues with the Edison Front End.
00048 //
00049 //Revision 1.9  2005/06/10 22:43:55  acg
00050 //Added CVS change log annotation.
00051 //
00052 
00053 #ifndef SC_FIFO_PORTS_H
00054 #define SC_FIFO_PORTS_H
00055 
00056 
00057 #include "sysc/communication/sc_port.h"
00058 #include "sysc/communication/sc_fifo_ifs.h"
00059 
00060 namespace sc_core {
00061 
00062 // ----------------------------------------------------------------------------
00063 //  CLASS : sc_fifo_in<T>
00064 //
00065 //  The sc_fifo<T> input port class.
00066 // ----------------------------------------------------------------------------
00067 
00068 template <class T>
00069 class sc_fifo_in
00070 : public sc_port<sc_fifo_in_if<T>,0,SC_ONE_OR_MORE_BOUND>
00071 {
00072 public:
00073 
00074     // typedefs
00075 
00076     typedef T                                       data_type;
00077 
00078     typedef sc_fifo_in_if<data_type>                if_type;
00079     typedef sc_port<if_type,0,SC_ONE_OR_MORE_BOUND> base_type;
00080     typedef sc_fifo_in<data_type>                   this_type;
00081 
00082     typedef if_type                                 in_if_type;
00083     typedef sc_port_b<in_if_type>                   in_port_type;
00084 
00085 public:
00086 
00087     // constructors
00088 
00089     sc_fifo_in()
00090     : base_type()
00091     {}
00092 
00093     explicit sc_fifo_in( const char* name_ )
00094     : base_type( name_ )
00095     {}
00096 
00097     explicit sc_fifo_in( in_if_type& interface_ )
00098     : base_type( interface_ )
00099     {}
00100 
00101     sc_fifo_in( const char* name_, in_if_type& interface_ )
00102     : base_type( name_, interface_ )
00103     {}
00104 
00105     explicit sc_fifo_in( in_port_type& parent_ )
00106     : base_type( parent_ )
00107     {}
00108 
00109     sc_fifo_in( const char* name_, in_port_type& parent_ )
00110     : base_type( name_, parent_ )
00111     {}
00112 
00113     sc_fifo_in( this_type& parent_ )
00114     : base_type( parent_ )
00115     {}
00116 
00117     sc_fifo_in( const char* name_, this_type& parent_ )
00118     : base_type( name_, parent_ )
00119     {}
00120 
00121 
00122     // destructor (does nothing)
00123 
00124     virtual ~sc_fifo_in()
00125     {}
00126 
00127 
00128     // interface access shortcut methods
00129 
00130     // blocking read
00131 
00132     void read( data_type& value_ )
00133         { (*this)->read( value_ ); }
00134 
00135     data_type read()
00136         { return (*this)->read(); }
00137 
00138 
00139     // non-blocking read
00140 
00141     bool nb_read( data_type& value_ )
00142         { return (*this)->nb_read( value_ ); }
00143 
00144 
00145     // get the number of available samples
00146 
00147     int num_available() const
00148         { return (*this)->num_available(); }
00149 
00150 
00151     // get the data written event
00152 
00153     const sc_event& data_written_event() const
00154     { return (*this)->data_written_event(); }
00155 
00156 
00157     // use for static sensitivity to data written event
00158 
00159     sc_event_finder& data_written() const
00160     {
00161     return *new sc_event_finder_t<in_if_type>(
00162         *this, &in_if_type::data_written_event );
00163     }
00164 
00165     virtual const char* kind() const
00166         { return "sc_fifo_in"; }
00167 
00168 private:
00169 
00170     // disabled
00171     sc_fifo_in( const this_type& );
00172     this_type& operator = ( const this_type& );
00173 };
00174 
00175 
00176 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
00177 
00178 // ----------------------------------------------------------------------------
00179 //  CLASS : sc_fifo_out<T>
00180 //
00181 //  The sc_fifo<T> output port class.
00182 // ----------------------------------------------------------------------------
00183 
00184 template <class T>
00185 class sc_fifo_out
00186 : public sc_port<sc_fifo_out_if<T>,0,SC_ONE_OR_MORE_BOUND>
00187 {
00188 public:
00189 
00190     // typedefs
00191 
00192     typedef T                                        data_type;
00193 
00194     typedef sc_fifo_out_if<data_type>                if_type;
00195     typedef sc_port<if_type,0,SC_ONE_OR_MORE_BOUND>  base_type;
00196     typedef sc_fifo_out<data_type>                   this_type;
00197 
00198     typedef if_type                                  out_if_type;
00199     typedef sc_port_b<out_if_type>                   out_port_type;
00200 
00201 public:
00202 
00203     // constructors
00204 
00205     sc_fifo_out()
00206     : base_type()
00207     {}
00208 
00209     explicit sc_fifo_out( const char* name_ )
00210     : base_type( name_ )
00211     {}
00212 
00213     explicit sc_fifo_out( out_if_type& interface_ )
00214     : base_type( interface_ )
00215     {}
00216 
00217     sc_fifo_out( const char* name_, out_if_type& interface_ )
00218     : base_type( name_, interface_ )
00219     {}
00220 
00221     explicit sc_fifo_out( out_port_type& parent_ )
00222     : base_type( parent_ )
00223     {}
00224 
00225     sc_fifo_out( const char* name_, out_port_type& parent_ )
00226     : base_type( name_, parent_ )
00227     {}
00228 
00229     sc_fifo_out( this_type& parent_ )
00230     : base_type( parent_ )
00231     {}
00232 
00233     sc_fifo_out( const char* name_, this_type& parent_ )
00234     : base_type( name_, parent_ )
00235     {}
00236 
00237 
00238     // destructor (does nothing)
00239 
00240     virtual ~sc_fifo_out()
00241     {}
00242 
00243 
00244     // interface access shortcut methods
00245 
00246     // blocking write
00247 
00248     void write( const data_type& value_ )
00249         { (*this)->write( value_ ); }
00250 
00251 
00252     // non-blocking write
00253 
00254     bool nb_write( const data_type& value_ )
00255         { return (*this)->nb_write( value_ ); }
00256 
00257 
00258     // get the number of free spaces
00259 
00260     int num_free() const
00261         { return (*this)->num_free(); }
00262 
00263 
00264     // get the data read event
00265 
00266     const sc_event& data_read_event() const
00267     { return (*this)->data_read_event(); }
00268 
00269 
00270     // use for static sensitivity to data read event
00271 
00272     sc_event_finder& data_read() const
00273     {
00274     return *new sc_event_finder_t<out_if_type>(
00275         *this, &out_if_type::data_read_event );
00276     }
00277 
00278     virtual const char* kind() const
00279         { return "sc_fifo_out"; }
00280 
00281 private:
00282 
00283     // disabled
00284     sc_fifo_out( const this_type& );
00285     this_type& operator = ( const this_type& );
00286 };
00287 
00288 
00289 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
00290 
00291 } // namespace sc_core
00292 
00293 #endif
00294 
00295 // Taf!

Generated on Wed Jan 21 15:32:06 2009 for SystemC by  doxygen 1.5.5