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-2005 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 
00036 #ifndef SC_FIFO_PORTS_H
00037 #define SC_FIFO_PORTS_H
00038 
00039 
00040 #include "sysc/communication/sc_port.h"
00041 #include "sysc/communication/sc_fifo_ifs.h"
00042 
00043 namespace sc_core {
00044 
00045 // ----------------------------------------------------------------------------
00046 //  CLASS : sc_fifo_in<T>
00047 //
00048 //  The sc_fifo<T> input port class.
00049 // ----------------------------------------------------------------------------
00050 
00051 template <class T>
00052 class sc_fifo_in
00053 : public sc_port<sc_fifo_in_if<T>,0>
00054 {
00055 public:
00056 
00057     // typedefs
00058 
00059     typedef T                        data_type;
00060 
00061     typedef sc_fifo_in_if<data_type> if_type;
00062     typedef sc_port<if_type,0>       base_type;
00063     typedef sc_fifo_in<data_type>    this_type;
00064 
00065     typedef if_type                  in_if_type;
00066     typedef sc_port_b<in_if_type>    in_port_type;
00067 
00068 public:
00069 
00070     // constructors
00071 
00072     sc_fifo_in()
00073         : base_type()
00074         {}
00075 
00076     explicit sc_fifo_in( const char* name_ )
00077         : base_type( name_ )
00078         {}
00079 
00080     explicit sc_fifo_in( in_if_type& interface_ )
00081         : base_type( interface_ )
00082         {}
00083 
00084     sc_fifo_in( const char* name_, in_if_type& interface_ )
00085         : base_type( name_, interface_ )
00086         {}
00087 
00088     explicit sc_fifo_in( in_port_type& parent_ )
00089         : base_type( parent_ )
00090         {}
00091 
00092     sc_fifo_in( const char* name_, in_port_type& parent_ )
00093         : base_type( name_, parent_ )
00094         {}
00095 
00096     sc_fifo_in( this_type& parent_ )
00097         : base_type( parent_ )
00098         {}
00099 
00100     sc_fifo_in( const char* name_, this_type& parent_ )
00101         : base_type( name_, parent_ )
00102         {}
00103 
00104 
00105     // destructor (does nothing)
00106 
00107     virtual ~sc_fifo_in()
00108         {}
00109 
00110 
00111     // interface access shortcut methods
00112 
00113     // blocking read
00114 
00115     void read( data_type& value_ )
00116         { (*this)->read( value_ ); }
00117 
00118     data_type read()
00119         { return (*this)->read(); }
00120 
00121 
00122     // non-blocking read
00123 
00124     bool nb_read( data_type& value_ )
00125         { return (*this)->nb_read( value_ ); }
00126 
00127 
00128     // get the number of available samples
00129 
00130     int num_available() const
00131         { return (*this)->num_available(); }
00132 
00133 
00134     // get the data written event
00135 
00136     const sc_event& data_written_event() const
00137         { return (*this)->data_written_event(); }
00138 
00139 
00140     // use for static sensitivity to data written event
00141 
00142     sc_event_finder& data_written() const
00143     {
00144         return *new sc_event_finder_t<in_if_type>(
00145             *this, &in_if_type::data_written_event );
00146     }
00147 
00148     virtual const char* kind() const
00149         { return "sc_fifo_in"; }
00150 
00151 private:
00152 
00153     // disabled
00154     sc_fifo_in( const this_type& );
00155     this_type& operator = ( const this_type& );
00156 };
00157 
00158 
00159 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
00160 
00161 // ----------------------------------------------------------------------------
00162 //  CLASS : sc_fifo_out<T>
00163 //
00164 //  The sc_fifo<T> output port class.
00165 // ----------------------------------------------------------------------------
00166 
00167 template <class T>
00168 class sc_fifo_out
00169 : public sc_port<sc_fifo_out_if<T>,0>
00170 {
00171 public:
00172 
00173     // typedefs
00174 
00175     typedef T                         data_type;
00176 
00177     typedef sc_fifo_out_if<data_type> if_type;
00178     typedef sc_port<if_type,0>        base_type;
00179     typedef sc_fifo_out<data_type>    this_type;
00180 
00181     typedef if_type                   out_if_type;
00182     typedef sc_port_b<out_if_type>    out_port_type;
00183 
00184 public:
00185 
00186     // constructors
00187 
00188     sc_fifo_out()
00189         : base_type()
00190         {}
00191 
00192     explicit sc_fifo_out( const char* name_ )
00193         : base_type( name_ )
00194         {}
00195 
00196     explicit sc_fifo_out( out_if_type& interface_ )
00197         : base_type( interface_ )
00198         {}
00199 
00200     sc_fifo_out( const char* name_, out_if_type& interface_ )
00201         : base_type( name_, interface_ )
00202         {}
00203 
00204     explicit sc_fifo_out( out_port_type& parent_ )
00205         : base_type( parent_ )
00206         {}
00207 
00208     sc_fifo_out( const char* name_, out_port_type& parent_ )
00209         : base_type( name_, parent_ )
00210         {}
00211 
00212     sc_fifo_out( this_type& parent_ )
00213         : base_type( parent_ )
00214         {}
00215 
00216     sc_fifo_out( const char* name_, this_type& parent_ )
00217         : base_type( name_, parent_ )
00218         {}
00219 
00220 
00221     // destructor (does nothing)
00222 
00223     virtual ~sc_fifo_out()
00224         {}
00225 
00226 
00227     // interface access shortcut methods
00228 
00229     // blocking write
00230 
00231     void write( const data_type& value_ )
00232         { (*this)->write( value_ ); }
00233 
00234 
00235     // non-blocking write
00236 
00237     bool nb_write( const data_type& value_ )
00238         { return (*this)->nb_write( value_ ); }
00239 
00240 
00241     // get the number of free spaces
00242 
00243     int num_free() const
00244         { return (*this)->num_free(); }
00245 
00246 
00247     // get the data read event
00248 
00249     const sc_event& data_read_event() const
00250         { return (*this)->data_read_event(); }
00251 
00252 
00253     // use for static sensitivity to data read event
00254 
00255     sc_event_finder& data_read() const
00256     {
00257         return *new sc_event_finder_t<out_if_type>(
00258             *this, &out_if_type::data_read_event );
00259     }
00260 
00261     virtual const char* kind() const
00262         { return "sc_fifo_out"; }
00263 
00264 private:
00265 
00266     // disabled
00267     sc_fifo_out( const this_type& );
00268     this_type& operator = ( const this_type& );
00269 };
00270 
00271 
00272 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
00273 
00274 } // namespace sc_core
00275 
00276 #endif
00277 
00278 // Taf!
Generated by
Matthieu Moy <Matthieu.Moy@st.com>
Back to Pinapa Home Page