00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 #ifndef SC_FIFO_PORTS_H
00028 #define SC_FIFO_PORTS_H
00029 
00030 
00031 #include "sysc/communication/sc_port.h"
00032 #include "sysc/communication/sc_fifo_ifs.h"
00033 
00034 namespace sc_core {
00035 
00036 
00042 template <class T>
00043 class sc_fifo_in
00044 : public sc_port<sc_fifo_in_if<T>,0,SC_ONE_OR_MORE_BOUND>
00045 {
00046 public:
00047 
00048     
00049 
00050     typedef T                                       data_type;
00051 
00052     typedef sc_fifo_in_if<data_type>                if_type;
00053     typedef sc_port<if_type,0,SC_ONE_OR_MORE_BOUND> base_type;
00054     typedef sc_fifo_in<data_type>                   this_type;
00055 
00056     typedef if_type                                 in_if_type;
00057     typedef sc_port_b<in_if_type>                   in_port_type;
00058 
00059 public:
00060 
00061     
00062 
00063     sc_fifo_in()
00064         : base_type()
00065     {}
00066 
00067     explicit sc_fifo_in( const char* name_ )
00068         : base_type( name_ )
00069     {}
00070 
00071     explicit sc_fifo_in( in_if_type& interface_ )
00072         : base_type( interface_ )
00073     {}
00074 
00075     sc_fifo_in( const char* name_, in_if_type& interface_ )
00076         : base_type( name_, interface_ )
00077     {}
00078 
00079     explicit sc_fifo_in( in_port_type& parent_ )
00080         : base_type( parent_ )
00081     {}
00082 
00083     sc_fifo_in( const char* name_, in_port_type& parent_ )
00084         : base_type( name_, parent_ )
00085     {}
00086 
00087     sc_fifo_in( this_type& parent_ )
00088         : base_type( parent_ )
00089     {}
00090 
00091     sc_fifo_in( const char* name_, this_type& parent_ )
00092         : base_type( name_, parent_ )
00093     {}
00094 
00095 
00096     
00097 
00098     virtual ~sc_fifo_in()
00099     {}
00100 
00101 
00102     
00103 
00104     
00105 
00110     
00111     void read( data_type& value_, int seg_id )
00112     { (*this)->read( value_, seg_id ); }
00113 
00118     
00119     data_type read( int seg_id )
00120     { return (*this)->read( seg_id ); }
00121 
00122 
00123     
00124 
00125     bool nb_read( data_type& value_ )
00126     { return (*this)->nb_read( value_ ); }
00127 
00128 
00129     
00130 
00131     int num_available() const
00132     { return (*this)->num_available(); }
00133 
00134 
00135     
00136 
00137     const sc_event& data_written_event() const
00138     { return (*this)->data_written_event(); }
00139 
00140 
00141     
00142 
00143     sc_event_finder& data_written() const
00144     {
00145         return *new sc_event_finder_t<in_if_type>(
00146             *this, &in_if_type::data_written_event );
00147     }
00148 
00149     virtual const char* kind() const
00150     { return "sc_fifo_in"; }
00151 
00152 private:
00153 
00154     
00155     sc_fifo_in( const this_type& );
00156     this_type& operator = ( const this_type& );
00157 };
00158 
00159 
00160 
00161 
00162 
00168 template <class T>
00169 class sc_fifo_out
00170 : public sc_port<sc_fifo_out_if<T>,0,SC_ONE_OR_MORE_BOUND>
00171 {
00172 public:
00173 
00174     
00175 
00176     typedef T                                        data_type;
00177 
00178     typedef sc_fifo_out_if<data_type>                if_type;
00179     typedef sc_port<if_type,0,SC_ONE_OR_MORE_BOUND>  base_type;
00180     typedef sc_fifo_out<data_type>                   this_type;
00181 
00182     typedef if_type                                  out_if_type;
00183     typedef sc_port_b<out_if_type>                   out_port_type;
00184 
00185 public:
00186 
00187     
00188 
00189     sc_fifo_out()
00190         : base_type()
00191     {}
00192 
00193     explicit sc_fifo_out( const char* name_ )
00194         : base_type( name_ )
00195     {}
00196 
00197     explicit sc_fifo_out( out_if_type& interface_ )
00198         : base_type( interface_ )
00199     {}
00200 
00201     sc_fifo_out( const char* name_, out_if_type& interface_ )
00202         : base_type( name_, interface_ )
00203     {}
00204 
00205     explicit sc_fifo_out( out_port_type& parent_ )
00206         : base_type( parent_ )
00207     {}
00208 
00209     sc_fifo_out( const char* name_, out_port_type& parent_ )
00210         : base_type( name_, parent_ )
00211     {}
00212 
00213     sc_fifo_out( this_type& parent_ )
00214         : base_type( parent_ )
00215     {}
00216 
00217     sc_fifo_out( const char* name_, this_type& parent_ )
00218         : base_type( name_, parent_ )
00219     {}
00220 
00221 
00222     
00223 
00224     virtual ~sc_fifo_out()
00225     {}
00226 
00227 
00228     
00229 
00230     
00231 
00236     
00237     void write( const data_type& value_, int seg_id )
00238     { (*this)->write( value_, seg_id ); }
00239 
00240 
00241     
00242 
00243     bool nb_write( const data_type& value_ )
00244     { return (*this)->nb_write( value_ ); }
00245 
00246 
00247     
00248 
00249     int num_free() const
00250     { return (*this)->num_free(); }
00251 
00252 
00253     
00254 
00255     const sc_event& data_read_event() const
00256     { return (*this)->data_read_event(); }
00257 
00258 
00259     
00260 
00261     sc_event_finder& data_read() const
00262     {
00263         return *new sc_event_finder_t<out_if_type>(
00264             *this, &out_if_type::data_read_event );
00265     }
00266 
00267     virtual const char* kind() const
00268     { return "sc_fifo_out"; }
00269 
00270 private:
00271 
00272     
00273     sc_fifo_out( const this_type& );
00274     this_type& operator = ( const this_type& );
00275 };
00276 
00277 
00278 
00279 
00280 } 
00281 
00282 
00283 
00284 
00285 
00286 
00287 
00288 
00289 
00290 
00291 
00292 
00293 
00294 
00295 
00296 
00297 
00298 
00299 
00300 
00301 
00302 
00303 
00304 
00305 
00306 
00307 #endif
00308 
00309