クラス テンプレート sc_core::sc_fifo< T >

#include <sc_fifo.h>

sc_core::sc_fifo< T >に対する継承グラフ

Inheritance graph
[凡例]

すべてのメンバ一覧

Public メソッド

 sc_fifo (int size_=16)
 sc_fifo (const char *name_, int size_=16)
virtual ~sc_fifo ()
virtual void register_port (sc_port_base &, const char *)
virtual void read (T &)
virtual T read ()
virtual bool nb_read (T &)
virtual int num_available () const
virtual const sc_eventdata_written_event () const
virtual void write (const T &)
virtual bool nb_write (const T &)
virtual int num_free () const
virtual const sc_eventdata_read_event () const
 operator T ()
sc_fifo< T > & operator= (const T &a)
void trace (sc_trace_file *tf) const
virtual void print (::std::ostream &=::std::cout) const
virtual void dump (::std::ostream &=::std::cout) const
virtual const char * kind () const

Protected メソッド

virtual void update ()
void init (int)
void buf_init (int)
bool buf_write (const T &)
bool buf_read (T &)

Protected 変数

int m_size
T * m_buf
int m_free
int m_ri
int m_wi
sc_port_basem_reader
sc_port_basem_writer
int m_num_readable
int m_num_read
int m_num_written
sc_event m_data_read_event
sc_event m_data_written_event

Private メソッド

 sc_fifo (const sc_fifo< T > &)
sc_fifooperator= (const sc_fifo< T > &)


説明

template<class T>
class sc_core::sc_fifo< T >

sc_fifo.h83 行で定義されています。


コンストラクタとデストラクタ

template<class T>
sc_core::sc_fifo< T >::sc_fifo ( int  size_ = 16  )  [inline, explicit]

sc_fifo.h92 行で定義されています。

00093         : sc_prim_channel( sc_gen_unique_name( "fifo" ) )
00094         { init( size_ ); }

template<class T>
sc_core::sc_fifo< T >::sc_fifo ( const char *  name_,
int  size_ = 16 
) [inline, explicit]

sc_fifo.h96 行で定義されています。

00097         : sc_prim_channel( name_ )
00098         { init( size_ ); }

template<class T>
virtual sc_core::sc_fifo< T >::~sc_fifo (  )  [inline, virtual]

sc_fifo.h103 行で定義されています。

00104         { delete [] m_buf; }

template<class T>
sc_core::sc_fifo< T >::sc_fifo ( const sc_fifo< T > &   )  [private]


関数

template<class T>
void sc_core::sc_fifo< T >::register_port ( sc_port_base port_,
const char *  if_typename_ 
) [inline, virtual]

sc_core::sc_interfaceを再定義しています。

sc_fifo.h213 行で定義されています。

00215 {
00216     std::string nm( if_typename_ );
00217     if( nm == typeid( sc_fifo_in_if<T> ).name() ) {
00218         // only one reader can be connected
00219         if( m_reader != 0 ) {
00220             SC_REPORT_ERROR( SC_ID_MORE_THAN_ONE_FIFO_READER_, 0 );
00221         }
00222         m_reader = &port_;
00223     } else {  // nm == typeid( sc_fifo_out_if<T> ).name()
00224         // only one writer can be connected
00225         if( m_writer != 0 ) {
00226             SC_REPORT_ERROR( SC_ID_MORE_THAN_ONE_FIFO_WRITER_, 0 );
00227         }
00228         m_writer = &port_;
00229     }
00230 }

template<class T>
void sc_core::sc_fifo< T >::read ( T &  val_  )  [inline, virtual]

sc_core::sc_fifo_blocking_in_if< T >を実装しています。

sc_fifo.h238 行で定義されています。

00239 {
00240     while( num_available() == 0 ) {
00241         sc_core::wait( m_data_written_event );
00242     }
00243     m_num_read ++;
00244     buf_read( val_ );
00245     request_update();
00246 }

template<class T>
T sc_core::sc_fifo< T >::read (  )  [inline, virtual]

sc_core::sc_fifo_blocking_in_if< T >を実装しています。

sc_fifo.h251 行で定義されています。

00252 {
00253     T tmp;
00254     read( tmp );
00255     return tmp;
00256 }

template<class T>
bool sc_core::sc_fifo< T >::nb_read ( T &  val_  )  [inline, virtual]

sc_core::sc_fifo_nonblocking_in_if< T >を実装しています。

sc_fifo.h263 行で定義されています。

00264 {
00265     if( num_available() == 0 ) {
00266         return false;
00267     }
00268     m_num_read ++;
00269     buf_read( val_ );
00270     request_update();
00271     return true;
00272 }

template<class T>
virtual int sc_core::sc_fifo< T >::num_available (  )  const [inline, virtual]

sc_core::sc_fifo_in_if< T >を実装しています。

sc_fifo.h122 行で定義されています。

00123         { return ( m_num_readable - m_num_read ); }

template<class T>
virtual const sc_event& sc_core::sc_fifo< T >::data_written_event (  )  const [inline, virtual]

sc_core::sc_fifo_nonblocking_in_if< T >を実装しています。

sc_fifo.h128 行で定義されています。

00129         { return m_data_written_event; }

template<class T>
void sc_core::sc_fifo< T >::write ( const T &  val_  )  [inline, virtual]

sc_core::sc_fifo_blocking_out_if< T >を実装しています。

sc_fifo.h280 行で定義されています。

00281 {
00282     while( num_free() == 0 ) {
00283         sc_core::wait( m_data_read_event );
00284     }
00285     m_num_written ++;
00286     buf_write( val_ );
00287     request_update();
00288 }

template<class T>
bool sc_core::sc_fifo< T >::nb_write ( const T &  val_  )  [inline, virtual]

sc_core::sc_fifo_nonblocking_out_if< T >を実装しています。

sc_fifo.h295 行で定義されています。

00296 {
00297     if( num_free() == 0 ) {
00298         return false;
00299     }
00300     m_num_written ++;
00301     buf_write( val_ );
00302     request_update();
00303     return true;
00304 }

template<class T>
virtual int sc_core::sc_fifo< T >::num_free (  )  const [inline, virtual]

sc_core::sc_fifo_out_if< T >を実装しています。

sc_fifo.h141 行で定義されています。

00142         { return ( m_size - m_num_readable - m_num_written ); }

template<class T>
virtual const sc_event& sc_core::sc_fifo< T >::data_read_event (  )  const [inline, virtual]

sc_core::sc_fifo_nonblocking_out_if< T >を実装しています。

sc_fifo.h147 行で定義されています。

00148         { return m_data_read_event; }

template<class T>
sc_core::sc_fifo< T >::operator T (  )  [inline]

sc_fifo.h153 行で定義されています。

00154         { return read(); }

template<class T>
sc_fifo<T>& sc_core::sc_fifo< T >::operator= ( const T &  a  )  [inline]

sc_fifo.h157 行で定義されています。

00158         { write( a ); return *this; }

template<class T>
void sc_core::sc_fifo< T >::trace ( sc_trace_file tf  )  const [inline, virtual]

sc_core::sc_objectを再定義しています。

sc_fifo.h310 行で定義されています。

00311 {
00312 #if defined(DEBUG_SYSTEMC)
00313     char buf[32];
00314     std::string nm = name();
00315     for( int i = 0; i < m_size; ++ i ) {
00316         std::sprintf( buf, "_%d", i );
00317         sc_trace( tf, m_buf[i], nm + buf );
00318     }
00319 #endif
00320 }

template<class T>
void sc_core::sc_fifo< T >::print ( ::std::ostream &  os = ::std::cout  )  const [inline, virtual]

sc_core::sc_objectを再定義しています。

sc_fifo.h326 行で定義されています。

00327 {
00328     if( m_free != m_size ) {
00329         int i = m_ri;
00330         do {
00331             os << m_buf[i] << ::std::endl;
00332             i = ( i + 1 ) % m_size;
00333         } while( i != m_wi );
00334     }
00335 }

template<class T>
void sc_core::sc_fifo< T >::dump ( ::std::ostream &  os = ::std::cout  )  const [inline, virtual]

sc_core::sc_objectを再定義しています。

sc_fifo.h340 行で定義されています。

00341 {
00342     os << "name = " << name() << ::std::endl;
00343     if( m_free != m_size ) {
00344         int i = m_ri;
00345         int j = 0;
00346         do {
00347             os << "value[" << i << "] = " << m_buf[i] << ::std::endl;
00348             i = ( i + 1 ) % m_size;
00349             j ++;
00350         } while( i != m_wi );
00351     }
00352 }

template<class T>
virtual const char* sc_core::sc_fifo< T >::kind (  )  const [inline, virtual]

sc_core::sc_prim_channelを再定義しています。

sc_fifo.h167 行で定義されています。

00168         { return "sc_fifo"; }

template<class T>
void sc_core::sc_fifo< T >::update (  )  [inline, protected, virtual]

sc_core::sc_prim_channelを再定義しています。

sc_fifo.h358 行で定義されています。

00359 {
00360     if( m_num_read > 0 ) {
00361         m_data_read_event.notify(SC_ZERO_TIME);
00362     }
00363 
00364     if( m_num_written > 0 ) {
00365         m_data_written_event.notify(SC_ZERO_TIME);
00366     }
00367 
00368     m_num_readable = m_size - m_free;
00369     m_num_read = 0;
00370     m_num_written = 0;
00371 }

template<class T>
void sc_core::sc_fifo< T >::init ( int  size_  )  [inline, protected]

sc_fifo.h379 行で定義されています。

00380 {
00381     buf_init( size_ );
00382 
00383     m_reader = 0;
00384     m_writer = 0;
00385 
00386     m_num_readable = 0;
00387     m_num_read = 0;
00388     m_num_written = 0;
00389 }

template<class T>
void sc_core::sc_fifo< T >::buf_init ( int  size_  )  [inline, protected]

sc_fifo.h395 行で定義されています。

00396 {
00397     if( size_ <= 0 ) {
00398         SC_REPORT_ERROR( SC_ID_INVALID_FIFO_SIZE_, 0 );
00399     }
00400     m_size = size_;
00401     m_buf = new T[m_size];
00402     m_free = m_size;
00403     m_ri = 0;
00404     m_wi = 0;
00405 }

template<class T>
bool sc_core::sc_fifo< T >::buf_write ( const T &  val_  )  [inline, protected]

sc_fifo.h410 行で定義されています。

00411 {
00412     if( m_free == 0 ) {
00413         return false;
00414     }
00415     m_buf[m_wi] = val_;
00416     m_wi = ( m_wi + 1 ) % m_size;
00417     m_free --;
00418     return true;
00419 }

template<class T>
bool sc_core::sc_fifo< T >::buf_read ( T &  val_  )  [inline, protected]

sc_fifo.h424 行で定義されています。

00425 {
00426     if( m_free == m_size ) {
00427         return false;
00428     }
00429     val_ = m_buf[m_ri];
00430     m_ri = ( m_ri + 1 ) % m_size;
00431     m_free ++;
00432     return true;
00433 }

template<class T>
sc_fifo& sc_core::sc_fifo< T >::operator= ( const sc_fifo< T > &   )  [private]


変数

template<class T>
int sc_core::sc_fifo< T >::m_size [protected]

sc_fifo.h184 行で定義されています。

template<class T>
T* sc_core::sc_fifo< T >::m_buf [protected]

sc_fifo.h185 行で定義されています。

template<class T>
int sc_core::sc_fifo< T >::m_free [protected]

sc_fifo.h186 行で定義されています。

template<class T>
int sc_core::sc_fifo< T >::m_ri [protected]

sc_fifo.h187 行で定義されています。

template<class T>
int sc_core::sc_fifo< T >::m_wi [protected]

sc_fifo.h188 行で定義されています。

template<class T>
sc_port_base* sc_core::sc_fifo< T >::m_reader [protected]

sc_fifo.h190 行で定義されています。

template<class T>
sc_port_base* sc_core::sc_fifo< T >::m_writer [protected]

sc_fifo.h191 行で定義されています。

template<class T>
int sc_core::sc_fifo< T >::m_num_readable [protected]

sc_fifo.h193 行で定義されています。

template<class T>
int sc_core::sc_fifo< T >::m_num_read [protected]

sc_fifo.h194 行で定義されています。

template<class T>
int sc_core::sc_fifo< T >::m_num_written [protected]

sc_fifo.h195 行で定義されています。

template<class T>
sc_event sc_core::sc_fifo< T >::m_data_read_event [protected]

sc_fifo.h197 行で定義されています。

template<class T>
sc_event sc_core::sc_fifo< T >::m_data_written_event [protected]

sc_fifo.h198 行で定義されています。


このクラスの説明は次のファイルから生成されました:

SystemCに対してFri Jun 6 20:11:42 2008に生成されました。  doxygen 1.5.6