クラス sc_dt::scfx_mant

#include <scfx_mant.h>

すべてのメンバ一覧

Public メソッド

 scfx_mant (std::size_t)
 scfx_mant (const scfx_mant &)
scfx_mantoperator= (const scfx_mant &)
 ~scfx_mant ()
void clear ()
void resize_to (int, int=0)
int size () const
word operator[] (int) const
wordoperator[] (int)
half_word half_at (int) const
half_wordhalf_at (int)
half_wordhalf_addr (int=0) const

Static Private メソッド

static wordalloc (std::size_t)
static void free (word *, std::size_t)
static wordalloc_word (std::size_t size)
static void free_word (word *array, std::size_t size)

Private 変数

wordm_array
int m_size


説明

scfx_mant.h73 行で定義されています。


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

sc_dt::scfx_mant::scfx_mant ( std::size_t  size  )  [inline, explicit]

scfx_mant.h170 行で定義されています。

00171 {
00172     m_array = alloc( m_size = size );
00173 }

sc_dt::scfx_mant::scfx_mant ( const scfx_mant rhs  )  [inline]

scfx_mant.h176 行で定義されています。

00177 {
00178     m_array = alloc( m_size = rhs.m_size );
00179     for( int i = 0; i < m_size; i ++ )
00180     {
00181         (*this)[i] = rhs[i];
00182     }
00183 }

sc_dt::scfx_mant::~scfx_mant (  )  [inline]

scfx_mant.h206 行で定義されています。

00207 {
00208     if( m_array != 0 )
00209     {
00210         free( m_array, m_size );
00211     }
00212 }


関数

scfx_mant & sc_dt::scfx_mant::operator= ( const scfx_mant rhs  )  [inline]

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

00188 {
00189     if( &rhs != this )
00190     {
00191         if( m_size != rhs.m_size )
00192         {
00193             free( m_array, m_size );
00194             m_array = alloc( m_size = rhs.m_size );
00195         }
00196 
00197         for( int i = 0; i < m_size; i ++ )
00198         {
00199             (*this)[i] = rhs[i];
00200         }
00201     }
00202     return *this;
00203 }

void sc_dt::scfx_mant::clear (  )  [inline]

scfx_mant.h216 行で定義されています。

00217 {
00218     for( int i = 0; i < m_size; i ++ )
00219     {
00220         (*this)[i] = 0;
00221     }
00222 }

void sc_dt::scfx_mant::resize_to ( int  size,
int  restore = 0 
) [inline]

scfx_mant.h226 行で定義されています。

00227 {
00228     if( size == m_size )
00229     {
00230         return;
00231     }
00232 
00233     if( ! m_array )
00234     {
00235         m_array = alloc( m_size = size );
00236     }
00237     else
00238     {
00239         word* p = alloc( size );
00240 
00241         if( restore )
00242         {
00243             int end = sc_min( size, m_size );
00244             if( restore == 1 )          // msb resized -> align at 0
00245             {
00246                 for( int i = 0; i < size; i ++ )
00247                 {
00248                     if( i < end )
00249                     {
00250 #if defined( SC_BIG_ENDIAN )
00251                         p[-i] = m_array[-i];
00252 #elif defined( SC_LITTLE_ENDIAN )
00253                         p[i] = m_array[i];
00254 #endif
00255                     }
00256                     else
00257                     {
00258 #if defined( SC_BIG_ENDIAN )
00259                         p[-i] = 0;
00260 #elif defined( SC_LITTLE_ENDIAN )
00261                         p[i] = 0;
00262 #endif
00263                     }
00264                 }
00265             }
00266             else                        // lsb resized -> align at size-1
00267             {
00268                 for( int i = 0; i < size; i ++ )
00269                 {
00270                     if( i < end )
00271                     {
00272 #if defined( SC_BIG_ENDIAN )
00273                         p[-size+1+i] = m_array[-m_size+1+i];
00274 #elif defined( SC_LITTLE_ENDIAN )
00275                         p[size-1-i] = m_array[m_size-1-i];
00276 #endif
00277                     }
00278                     else
00279                     {
00280 #if defined( SC_BIG_ENDIAN )
00281                         p[-size+1+i] = 0;
00282 #elif defined( SC_LITTLE_ENDIAN )
00283                         p[size-1-i] = 0;
00284 #endif
00285                     }
00286                 }
00287             }
00288         }
00289 
00290         free( m_array, m_size );
00291         m_array = p;
00292         m_size = size;
00293     }
00294 }

int sc_dt::scfx_mant::size (  )  const [inline]

scfx_mant.h117 行で定義されています。

00118 {
00119     return m_size;
00120 }

word sc_dt::scfx_mant::operator[] ( int  i  )  const [inline]

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

00148 {
00149     SC_ASSERT_( i >= 0 && i < m_size, "mantissa index out of range" );
00150 #if defined( SC_BIG_ENDIAN )
00151     return m_array[-i];
00152 #elif defined( SC_LITTLE_ENDIAN )
00153     return m_array[i];
00154 #endif
00155 }

word & sc_dt::scfx_mant::operator[] ( int  i  )  [inline]

scfx_mant.h159 行で定義されています。

00160 {
00161     SC_ASSERT_( i >= 0 && i < m_size, "mantissa index out of range" );
00162 #if defined( SC_BIG_ENDIAN )
00163     return m_array[-i];
00164 #elif defined( SC_LITTLE_ENDIAN )
00165     return m_array[i];
00166 #endif
00167 }

half_word sc_dt::scfx_mant::half_at ( int  i  )  const [inline]

scfx_mant.h298 行で定義されています。

00299 {
00300     SC_ASSERT_( ( i >> 1 ) >= 0 && ( i >> 1 ) < m_size,
00301                 "mantissa index out of range" );
00302 #if defined( SC_BIG_ENDIAN )
00303     return reinterpret_cast<half_word*>( m_array )[-i];
00304 #elif defined( SC_LITTLE_ENDIAN )
00305     return reinterpret_cast<half_word*>( m_array )[i];
00306 #endif
00307 }

half_word & sc_dt::scfx_mant::half_at ( int  i  )  [inline]

scfx_mant.h311 行で定義されています。

00312 {
00313     SC_ASSERT_( ( i >> 1 ) >= 0 && ( i >> 1 ) < m_size,
00314                 "mantissa index out of range" );
00315 #if defined( SC_BIG_ENDIAN )
00316     return reinterpret_cast<half_word*>( m_array )[-i];
00317 #elif defined( SC_LITTLE_ENDIAN )
00318     return reinterpret_cast<half_word*>( m_array )[i];
00319 #endif
00320 }

half_word * sc_dt::scfx_mant::half_addr ( int  i = 0  )  const [inline]

scfx_mant.h324 行で定義されています。

00325 {
00326     SC_ASSERT_( i >= 0 && i < m_size, "mantissa index out of range" );
00327 #if defined( SC_BIG_ENDIAN )
00328     return reinterpret_cast<half_word*>( m_array - i ) + 1;
00329 #elif defined( SC_LITTLE_ENDIAN )
00330     return reinterpret_cast<half_word*>( m_array + i );
00331 #endif
00332 }

word * sc_dt::scfx_mant::alloc ( std::size_t  size  )  [inline, static, private]

scfx_mant.h125 行で定義されています。

00126 {
00127 #if defined( SC_BIG_ENDIAN )
00128     return alloc_word( size ) + ( size - 1 );
00129 #elif defined( SC_LITTLE_ENDIAN )
00130     return alloc_word( size );
00131 #endif
00132 }

void sc_dt::scfx_mant::free ( word mant,
std::size_t  size 
) [inline, static, private]

scfx_mant.h136 行で定義されています。

00137 {
00138 #if defined( SC_BIG_ENDIAN )
00139     free_word( mant - ( size - 1 ), size );
00140 #elif defined( SC_LITTLE_ENDIAN )
00141     free_word( mant, size );
00142 #endif
00143 }

word * sc_dt::scfx_mant::alloc_word ( std::size_t  size  )  [static, private]

scfx_mant.cpp81 行で定義されています。

00082 {
00083     const int ALLOC_SIZE = 128;
00084 
00085     int slot_index = next_pow2_index( size );
00086 
00087     int alloc_size = ( 1 << slot_index );
00088 
00089     word_list*& slot = free_words[slot_index];
00090 
00091     if( ! slot )
00092     {
00093         slot = new word_list[ALLOC_SIZE * alloc_size];
00094         int i;
00095         for( i = 0; i < alloc_size*(ALLOC_SIZE-1) ; i+=alloc_size )
00096         {
00097             slot[i].m_next_p = &slot[i+alloc_size];
00098         }
00099         slot[i].m_next_p = 0;
00100     }
00101 
00102     word* result = (word*)slot;
00103     free_words[slot_index] = slot[0].m_next_p;
00104     return result;
00105 }

void sc_dt::scfx_mant::free_word ( word array,
std::size_t  size 
) [static, private]

scfx_mant.cpp108 行で定義されています。

00109 {
00110     if( array && size )
00111     {
00112         int slot_index = next_pow2_index( size );
00113         word_list* wl_p = (word_list*)array;
00114 
00115         wl_p->m_next_p = free_words[slot_index];
00116         free_words[slot_index] = wl_p;
00117     }
00118 }


変数

scfx_mant.h76 行で定義されています。

int sc_dt::scfx_mant::m_size [private]

scfx_mant.h77 行で定義されています。


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

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