125 int wi()
const {
return m_wi; }
126 int bi()
const {
return m_bi; }
128 void wi(
int wi_ ) { m_wi = wi_; }
180 void*
operator new( std::size_t );
181 void operator delete(
void*, std::size_t );
184 void from_string(
const char*,
int );
186 double to_double()
const;
197 void operator = (
const scfx_rep& );
217 bool is_zero()
const;
220 bool is_normal()
const;
222 void set_zero(
int = 1 );
226 bool get_bit(
int )
const;
233 void print( ::std::ostream& )
const;
234 void dump( ::std::ostream& )
const;
236 void get_type(
int&,
int&,
sc_enc& )
const;
245 bool rounding_flag()
const;
253 unsigned int divide_by_ten();
254 int find_lsw()
const;
255 int find_msw()
const;
257 void multiply_by_ten();
258 void normalize(
int );
261 void set_oct(
int,
int );
262 void set_hex(
int,
int );
263 void shift_left(
int );
264 void shift_right(
int );
282 void resize_to(
int,
int = 0 );
317 m_wp = m_msw = m_lsw = 0;
326 m_mant.resize_to( min_mant );
327 m_state = not_a_number;
334 m_mant.resize_to( min_mant );
344 : m_mant( min_mant ), m_wp( 2 ), m_sign( 1 ), m_state( normal ),
345 m_msw(0), m_lsw(0), m_r_flag( false )
381 c.m_sign = - c.m_sign;
414 scfx_rep::size()
const 416 return m_mant.
size();
423 return ( m_sign == -1 );
430 if( m_state != normal )
433 for(
int i = 0; i < size(); i ++ )
446 return ( m_state == not_a_number );
453 return ( m_state == infinity );
460 return ( m_state == normal );
470 c.quantization( params, q_flag );
481 c.overflow( params, o_flag );
494 scfx_rep::resize_to(
int new_size,
int restore )
498 int size_incr = new_size - size();
508 scfx_rep::calc_indices(
int n )
const 510 int wi = n / bits_in_word + m_wp;
529 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
531 if( enc ==
SC_US_ || ( m_mant[wi] & ( ((
word)1) << bi ) ) == 0 )
533 if( bi != bits_in_word - 1 )
534 m_mant[wi] &= ~( ((
word)-1) << ( bi + 1 ) );
535 for(
int i = wi + 1; i < size(); ++ i )
541 if( bi != bits_in_word - 1 )
542 m_mant[wi] |= ( ((
word)-1) << ( bi + 1 ) );
543 for(
int i = wi + 1; i < size(); ++ i )
544 m_mant[i] = static_cast<word>( -1 );
551 scfx_rep::o_bit_at(
const scfx_index& x )
const 556 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
558 return ( m_mant[wi] & ( ((
word)1) << bi ) ) != 0;
563 scfx_rep::o_zero_left(
const scfx_index& x )
const 568 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
571 if( bi != bits_in_word - 1 )
572 zero = ( m_mant[wi] & ( ((
word)-1) << ( bi + 1 ) ) ) == 0;
573 for(
int i = wi + 1; i < size(); ++ i )
574 zero = zero && m_mant[i] == 0;
581 scfx_rep::o_zero_right(
const scfx_index& x )
const 586 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
588 bool zero = ( m_mant[wi] & ~( ((
word)-1) << bi ) ) == 0;
589 for(
int i = wi - 1; i >= 0; -- i )
590 zero = zero && m_mant[i] == 0;
602 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
608 m_mant[wi] |= ( ((
word)1) << bi );
625 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
626 SC_ASSERT_( wi2 >= 0 && wi2 < size(),
"word index out of range" );
630 for( i = 0; i < size(); ++ i )
631 m_mant[i] = static_cast<word>( -1 );
633 m_mant[wi] &= ~( ((
word)-1) << bi );
634 for( i = wi + 1; i < size(); ++ i )
637 m_mant[wi2] &= ( ((
word)-1) << bi2 );
638 for( i = wi2 - 1; i >= 0; -- i )
645 m_mant[wi] |= ( ((
word)1) << bi );
660 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
661 SC_ASSERT_( wi3 >= 0 && wi3 < size(),
"word index out of range" );
663 if( bi3 != bits_in_word - 1 )
666 m_mant[wi3] &= ~( ((
word)-1) << ( bi3 + 1 ) );
668 m_mant[wi3] |= ( ((
word)-1) << ( bi3 + 1 ) );
670 for(
int i = wi3 + 1; i < size(); ++ i )
675 m_mant[i] =
static_cast<word>( -1 );
681 m_mant[wi] |= ( ((
word)1) << bi );
683 m_mant[wi] &= ~( ((
word)1) << bi );
694 m_mant[wi2] ^= ( ((
word)-1) << bi2 );
695 for(
int i = wi2 + 1; i < size(); ++ i )
696 m_mant[i] = ~ m_mant[i];
706 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
709 return ( m_mant[wi] & ( ((
word)1) << ( bi - 1 ) ) ) != 0;
711 return ( m_mant[wi - 1] & ( ((
word)1) << ( bits_in_word - 1 ) ) ) != 0;
723 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
725 m_mant[wi] &= ( ((
word)-1) << bi );
726 for(
int i = wi - 1; i >= 0; -- i )
737 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
739 word old_val = m_mant[wi];
740 m_mant[wi] += ( ((
word)1) << bi );
741 if( m_mant[wi] <= old_val )
743 if( wi + 1 == size() )
744 resize_to( size() + 1, 1 );
746 for(
int i = wi + 1; i < size(); ++ i )
748 if( ++ m_mant[i] != 0 )
761 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
763 return ( m_mant[wi] & ( ((
word)1) << bi ) ) != 0;
773 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
779 zero = ( m_mant[wi] & ~( ((
word)-1) << (bi - 1) ) ) == 0;
780 for(
int i = wi - 1; i >= 0; -- i )
781 zero = zero && m_mant[i] == 0;
785 zero = ( m_mant[wi - 1] & ~( ((
word)-1) << (bits_in_word - 1) ) ) == 0;
786 for(
int i = wi - 2; i >= 0; -- i )
787 zero = zero && m_mant[i] == 0;
797 scfx_rep::find_lsw()
const 799 for(
int i = 0; i < size(); i ++ )
809 scfx_rep::find_msw()
const 811 for(
int i = size() - 1; i >= 0; i -- )
829 scfx_rep::toggle_tc()
friend scfx_rep * overflow_scfx_rep(const scfx_rep &, const scfx_params &, bool &)
void from_string(const char *, int)
void inc(scfx_mant &mant)
sc_enc
Enumeration of sign encodings.
friend SC_API scfx_rep * neg_scfx_rep(const scfx_rep &)
Mantissa reference class.
void operator=(const scfx_rep &)
Arbitrary precision signed number.
void lshift(sc_fxval &c, const sc_fxnum &a, int b)
Arbitrary precision unsigned number.
Simple string class for internal use.
uint64 const sc_uint_base int b
friend SC_API scfx_rep * mult_scfx_rep(const scfx_rep &, const scfx_rep &, int)
void complement(scfx_mant &target, const scfx_mant &source, int size)
scfx_index(int wi_, int bi_)
void rshift(sc_fxval &c, const sc_fxnum &a, int b)
SC_API scfx_rep * neg_scfx_rep(const scfx_rep &)
SC_API scfx_rep * lsh_scfx_rep(const scfx_rep &, int)
Arbitrary-precision fixed-point implementation class.
scfx_rep * overflow_scfx_rep(const scfx_rep &a, const scfx_params ¶ms, bool &o_flag)
SC_API scfx_rep * mult_scfx_rep(const scfx_rep &, const scfx_rep &, int max_wl=SC_DEFAULT_MAX_WL_)
friend SC_API scfx_rep * rsh_scfx_rep(const scfx_rep &, int)
friend SC_API scfx_rep * lsh_scfx_rep(const scfx_rep &, int)
sc_fmt
Enumeration of formats for character string conversion.
SC_API const std::string to_string(sc_enc)
SC_API scfx_rep * rsh_scfx_rep(const scfx_rep &, int)
sc_numrep
Enumeration of number representations for character string conversion.
SC_API scfx_rep * add_scfx_rep(const scfx_rep &, const scfx_rep &, int max_wl=SC_DEFAULT_MAX_WL_)
SC_API int cmp_scfx_rep(const scfx_rep &, const scfx_rep &)
SC_API scfx_rep * div_scfx_rep(const scfx_rep &, const scfx_rep &, int max_wl=SC_DEFAULT_DIV_WL_)
const int SC_DEFAULT_MAX_WL_
void resize_to(int, int=0)
SC_API scfx_rep * sub_scfx_rep(const scfx_rep &, const scfx_rep &, int max_wl=SC_DEFAULT_MAX_WL_)
Arbitrary size bit vector base class.
const int SC_DEFAULT_DIV_WL_
#define SC_ASSERT_(cnd, msg)
scfx_rep * quantization_scfx_rep(const scfx_rep &a, const scfx_params ¶ms, bool &q_flag)
bool rounding_flag() const
friend scfx_rep * quantization_scfx_rep(const scfx_rep &, const scfx_params &, bool &)
SC_API void multiply(scfx_rep &, const scfx_rep &, const scfx_rep &, int max_wl=SC_DEFAULT_MAX_WL_)
const int SC_DEFAULT_CTE_WL_