90 void multiply( scfx_rep&,
const scfx_rep&,
const scfx_rep&,
95 scfx_rep*
div_scfx_rep(
const scfx_rep&,
const scfx_rep&,
97 scfx_rep*
add_scfx_rep(
const scfx_rep&,
const scfx_rep&,
99 scfx_rep*
sub_scfx_rep(
const scfx_rep&,
const scfx_rep&,
123 int wi()
const {
return m_wi; }
124 int bi()
const {
return m_bi; }
126 void wi(
int wi_ ) { m_wi = wi_; }
178 void*
operator new( std::size_t );
179 void operator delete(
void*, std::size_t );
230 void print( ::std::ostream& )
const;
231 void dump( ::std::ostream& )
const;
250 unsigned int divide_by_ten();
251 int find_lsw()
const;
252 int find_msw()
const;
254 void multiply_by_ten();
255 void normalize(
int );
258 void set_oct(
int,
int );
259 void set_hex(
int,
int );
260 void shift_left(
int );
261 void shift_right(
int );
279 void resize_to(
int,
int = 0 );
314 m_wp = m_msw = m_lsw = 0;
324 m_state = not_a_number;
341 : m_mant(
min_mant ), m_wp( 2 ), m_sign( 1 ), m_state( normal ),
342 m_msw(0), m_lsw(0), m_r_flag( false )
378 c.m_sign = - c.m_sign;
411 scfx_rep::size()
const
413 return m_mant.
size();
420 return ( m_sign == -1 );
427 if( m_state != normal )
430 for(
int i = 0; i < size(); i ++ )
443 return ( m_state == not_a_number );
450 return ( m_state == infinity );
457 return ( m_state == normal );
467 c.quantization( params, q_flag );
478 c.overflow( params, o_flag );
491 scfx_rep::resize_to(
int new_size,
int restore )
495 int size_incr = new_size - size();
505 scfx_rep::calc_indices(
int n )
const
516 return scfx_index( wi, bi );
521 scfx_rep::o_extend(
const scfx_index& x,
sc_enc enc )
526 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
528 if( enc ==
SC_US_ || ( m_mant[wi] & ( ((
word)1) << bi ) ) == 0 )
531 m_mant[wi] &= ~( ((
word)-1) << ( bi + 1 ) );
532 for(
int i = wi + 1; i < size(); ++ i )
539 m_mant[wi] |= ( ((
word)-1) << ( bi + 1 ) );
540 for(
int i = wi + 1; i < size(); ++ i )
541 m_mant[i] = static_cast<word>( -1 );
548 scfx_rep::o_bit_at(
const scfx_index& x )
const
553 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
555 return ( m_mant[wi] & ( ((
word)1) << bi ) ) != 0;
560 scfx_rep::o_zero_left(
const scfx_index& x )
const
565 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
569 zero = ( m_mant[wi] & ( ((
word)-1) << ( bi + 1 ) ) ) == 0;
570 for(
int i = wi + 1; i < size(); ++ i )
571 zero = zero && m_mant[i] == 0;
578 scfx_rep::o_zero_right(
const scfx_index& x )
const
583 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
585 bool zero = ( m_mant[wi] & ~( ((
word)-1) << bi ) ) == 0;
586 for(
int i = wi - 1; i >= 0; -- i )
587 zero = zero && m_mant[i] == 0;
594 scfx_rep::o_set_low(
const scfx_index& x,
sc_enc enc )
599 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
605 m_mant[wi] |= ( ((
word)1) << bi );
614 scfx_rep::o_set_high(
const scfx_index& x,
const scfx_index& x2,
622 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
623 SC_ASSERT_( wi2 >= 0 && wi2 < size(),
"word index out of range" );
627 for( i = 0; i < size(); ++ i )
628 m_mant[i] = static_cast<word>( -1 );
630 m_mant[wi] &= ~( ((
word)-1) << bi );
631 for( i = wi + 1; i < size(); ++ i )
634 m_mant[wi2] &= ( ((
word)-1) << bi2 );
635 for( i = wi2 - 1; i >= 0; -- i )
642 m_mant[wi] |= ( ((
word)1) << bi );
649 scfx_rep::o_set(
const scfx_index& x,
const scfx_index& x3,
657 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
658 SC_ASSERT_( wi3 >= 0 && wi3 < size(),
"word index out of range" );
663 m_mant[wi3] &= ~( ((
word)-1) << ( bi3 + 1 ) );
665 m_mant[wi3] |= ( ((
word)-1) << ( bi3 + 1 ) );
667 for(
int i = wi3 + 1; i < size(); ++ i )
672 m_mant[i] =
static_cast<word>( -1 );
678 m_mant[wi] |= ( ((
word)1) << bi );
680 m_mant[wi] &= ~( ((
word)1) << bi );
686 scfx_rep::o_invert(
const scfx_index& x2 )
691 m_mant[wi2] ^= ( ((
word)-1) << bi2 );
692 for(
int i = wi2 + 1; i < size(); ++ i )
693 m_mant[i] = ~ m_mant[i];
698 scfx_rep::q_bit(
const scfx_index& x )
const
703 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
706 return ( m_mant[wi] & ( ((
word)1) << ( bi - 1 ) ) ) != 0;
715 scfx_rep::q_clear(
const scfx_index& x )
720 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
722 m_mant[wi] &= ( ((
word)-1) << bi );
723 for(
int i = wi - 1; i >= 0; -- i )
729 scfx_rep::q_incr(
const scfx_index& x )
734 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
736 word old_val = m_mant[wi];
737 m_mant[wi] += ( ((
word)1) << bi );
738 if( m_mant[wi] <= old_val )
740 if( wi + 1 == size() )
741 resize_to( size() + 1, 1 );
743 for(
int i = wi + 1; i < size(); ++ i )
745 if( ++ m_mant[i] != 0 )
753 scfx_rep::q_odd(
const scfx_index& x )
const
758 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
760 return ( m_mant[wi] & ( ((
word)1) << bi ) ) != 0;
765 scfx_rep::q_zero(
const scfx_index& x )
const
770 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
776 zero = ( m_mant[wi] & ~( ((
word)-1) << (bi - 1) ) ) == 0;
777 for(
int i = wi - 1; i >= 0; -- i )
778 zero = zero && m_mant[i] == 0;
783 for(
int i = wi - 2; i >= 0; -- i )
784 zero = zero && m_mant[i] == 0;
794 scfx_rep::find_lsw()
const
796 for(
int i = 0; i < size(); i ++ )
806 scfx_rep::find_msw()
const
808 for(
int i = size() - 1; i >= 0; i -- )
826 scfx_rep::toggle_tc()
friend void print_dec(scfx_string &, const scfx_rep &, int, sc_fmt)
bool set_slice(int, int, const scfx_params &, const sc_bv_base &)
friend int compare_msw(const scfx_rep &, const scfx_rep &)
const int SC_DEFAULT_DIV_WL_
scfx_rep * rsh_scfx_rep(const scfx_rep &, int)
friend void multiply(scfx_rep &, const scfx_rep &, const scfx_rep &, int)
friend void align(const scfx_rep &, const scfx_rep &, int &, int &, scfx_mant_ref &, scfx_mant_ref &)
friend int compare_msw_ff(const scfx_rep &lhs, const scfx_rep &rhs)
#define SC_ASSERT_(cnd, msg)
void resize_to(int, int=0)
uint64 const sc_uint_base int b
scfx_rep * neg_scfx_rep(const scfx_rep &)
void multiply(scfx_rep &, const scfx_rep &, const scfx_rep &, int max_wl=SC_DEFAULT_MAX_WL_)
int cmp_scfx_rep(const scfx_rep &, const scfx_rep &)
scfx_rep * overflow_scfx_rep(const scfx_rep &a, const scfx_params ¶ms, bool &o_flag)
bool set(int, const scfx_params &)
bool get_slice(int, int, const scfx_params &, sc_bv_base &) const
void from_string(const char *, int)
friend int compare_abs(const scfx_rep &, const scfx_rep &)
const char * to_string(sc_numrep, int, sc_fmt, const scfx_params *=0) const
friend scfx_rep * rsh_scfx_rep(const scfx_rep &, int)
scfx_rep * mult_scfx_rep(const scfx_rep &, const scfx_rep &, int max_wl=SC_DEFAULT_MAX_WL_)
friend scfx_rep * lsh_scfx_rep(const scfx_rep &, int)
void get_type(int &, int &, sc_enc &) const
scfx_index(int wi_, int bi_)
bool rounding_flag() const
scfx_rep * quantization_scfx_rep(const scfx_rep &a, const scfx_params ¶ms, bool &q_flag)
void complement(scfx_mant &target, const scfx_mant &source, int size)
bool clear(int, const scfx_params &)
scfx_rep * lsh_scfx_rep(const scfx_rep &, int)
const int SC_DEFAULT_MAX_WL_
friend scfx_rep * add_scfx_rep(const scfx_rep &, const scfx_rep &, int)
void print(::std::ostream &) const
friend scfx_rep * overflow_scfx_rep(const scfx_rep &, const scfx_params &, bool &)
friend scfx_rep * quantization_scfx_rep(const scfx_rep &, const scfx_params &, bool &)
scfx_rep * sub_scfx_rep(const scfx_rep &, const scfx_rep &, int max_wl=SC_DEFAULT_MAX_WL_)
void cast(const scfx_params &, bool &, bool &)
scfx_rep * div_scfx_rep(const scfx_rep &, const scfx_rep &, int max_wl=SC_DEFAULT_DIV_WL_)
friend scfx_rep * neg_scfx_rep(const scfx_rep &)
friend scfx_rep * mult_scfx_rep(const scfx_rep &, const scfx_rep &, int)
void dump(::std::ostream &) const
friend void print_other(scfx_string &, const scfx_rep &, sc_numrep, int, sc_fmt, const scfx_params *)
void inc(scfx_mant &mant)
friend scfx_rep * div_scfx_rep(const scfx_rep &, const scfx_rep &, int)
const int SC_DEFAULT_CTE_WL_
scfx_rep * add_scfx_rep(const scfx_rep &, const scfx_rep &, int max_wl=SC_DEFAULT_MAX_WL_)
friend int cmp_scfx_rep(const scfx_rep &, const scfx_rep &)
void operator=(const scfx_rep &)
friend scfx_rep * sub_scfx_rep(const scfx_rep &, const scfx_rep &, int)