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&,
153 int wi()
const {
return m_wi; }
154 int bi()
const {
return m_bi; }
156 void wi(
int wi_ ) { m_wi = wi_; }
208 void*
operator new( std::size_t );
209 void operator delete(
void*, std::size_t );
260 void print( ::std::ostream& )
const;
261 void dump( ::std::ostream& )
const;
280 unsigned int divide_by_ten();
281 int find_lsw()
const;
282 int find_msw()
const;
284 void multiply_by_ten();
285 void normalize(
int );
288 void set_oct(
int,
int );
289 void set_hex(
int,
int );
290 void shift_left(
int );
291 void shift_right(
int );
309 void resize_to(
int,
int = 0 );
344 m_wp = m_msw = m_lsw = 0;
354 m_state = not_a_number;
371 : m_mant(
min_mant ), m_wp( 2 ), m_sign( 1 ), m_state( normal ),
372 m_msw(0), m_lsw(0), m_r_flag( false )
408 c.m_sign = - c.m_sign;
441 scfx_rep::size()
const
443 return m_mant.
size();
450 return ( m_sign == -1 );
457 if( m_state != normal )
460 for(
int i = 0; i < size(); i ++ )
473 return ( m_state == not_a_number );
480 return ( m_state == infinity );
487 return ( m_state == normal );
497 c.quantization( params, q_flag );
508 c.overflow( params, o_flag );
521 scfx_rep::resize_to(
int new_size,
int restore )
525 int size_incr = new_size - size();
535 scfx_rep::calc_indices(
int n )
const
546 return scfx_index( wi, bi );
551 scfx_rep::o_extend(
const scfx_index& x,
sc_enc enc )
556 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
558 if( enc ==
SC_US_ || ( m_mant[wi] & ( ((
word)1) << bi ) ) == 0 )
561 m_mant[wi] &= ~( ((
word)-1) << ( bi + 1 ) );
562 for(
int i = wi + 1; i < size(); ++ i )
569 m_mant[wi] |= ( ((
word)-1) << ( bi + 1 ) );
570 for(
int i = wi + 1; i < size(); ++ i )
571 m_mant[i] = static_cast<word>( -1 );
578 scfx_rep::o_bit_at(
const scfx_index& x )
const
583 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
585 return ( m_mant[wi] & ( ((
word)1) << bi ) ) != 0;
590 scfx_rep::o_zero_left(
const scfx_index& x )
const
595 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
599 zero = ( m_mant[wi] & ( ((
word)-1) << ( bi + 1 ) ) ) == 0;
600 for(
int i = wi + 1; i < size(); ++ i )
601 zero = zero && m_mant[i] == 0;
608 scfx_rep::o_zero_right(
const scfx_index& x )
const
613 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
615 bool zero = ( m_mant[wi] & ~( ((
word)-1) << bi ) ) == 0;
616 for(
int i = wi - 1; i >= 0; -- i )
617 zero = zero && m_mant[i] == 0;
624 scfx_rep::o_set_low(
const scfx_index& x,
sc_enc enc )
629 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
635 m_mant[wi] |= ( ((
word)1) << bi );
644 scfx_rep::o_set_high(
const scfx_index& x,
const scfx_index& x2,
652 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
653 SC_ASSERT_( wi2 >= 0 && wi2 < size(),
"word index out of range" );
657 for( i = 0; i < size(); ++ i )
658 m_mant[i] = static_cast<word>( -1 );
660 m_mant[wi] &= ~( ((
word)-1) << bi );
661 for( i = wi + 1; i < size(); ++ i )
664 m_mant[wi2] &= ( ((
word)-1) << bi2 );
665 for( i = wi2 - 1; i >= 0; -- i )
672 m_mant[wi] |= ( ((
word)1) << bi );
679 scfx_rep::o_set(
const scfx_index& x,
const scfx_index& x3,
687 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
688 SC_ASSERT_( wi3 >= 0 && wi3 < size(),
"word index out of range" );
693 m_mant[wi3] &= ~( ((
word)-1) << ( bi3 + 1 ) );
695 m_mant[wi3] |= ( ((
word)-1) << ( bi3 + 1 ) );
697 for(
int i = wi3 + 1; i < size(); ++ i )
702 m_mant[i] =
static_cast<word>( -1 );
708 m_mant[wi] |= ( ((
word)1) << bi );
710 m_mant[wi] &= ~( ((
word)1) << bi );
716 scfx_rep::o_invert(
const scfx_index& x2 )
721 m_mant[wi2] ^= ( ((
word)-1) << bi2 );
722 for(
int i = wi2 + 1; i < size(); ++ i )
723 m_mant[i] = ~ m_mant[i];
728 scfx_rep::q_bit(
const scfx_index& x )
const
733 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
736 return ( m_mant[wi] & ( ((
word)1) << ( bi - 1 ) ) ) != 0;
745 scfx_rep::q_clear(
const scfx_index& x )
750 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
752 m_mant[wi] &= ( ((
word)-1) << bi );
753 for(
int i = wi - 1; i >= 0; -- i )
759 scfx_rep::q_incr(
const scfx_index& x )
764 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
766 word old_val = m_mant[wi];
767 m_mant[wi] += ( ((
word)1) << bi );
768 if( m_mant[wi] <= old_val )
770 if( wi + 1 == size() )
771 resize_to( size() + 1, 1 );
773 for(
int i = wi + 1; i < size(); ++ i )
775 if( ++ m_mant[i] != 0 )
783 scfx_rep::q_odd(
const scfx_index& x )
const
788 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
790 return ( m_mant[wi] & ( ((
word)1) << bi ) ) != 0;
795 scfx_rep::q_zero(
const scfx_index& x )
const
800 SC_ASSERT_( wi >= 0 && wi < size(),
"word index out of range" );
806 zero = ( m_mant[wi] & ~( ((
word)-1) << (bi - 1) ) ) == 0;
807 for(
int i = wi - 1; i >= 0; -- i )
808 zero = zero && m_mant[i] == 0;
813 for(
int i = wi - 2; i >= 0; -- i )
814 zero = zero && m_mant[i] == 0;
824 scfx_rep::find_lsw()
const
826 for(
int i = 0; i < size(); i ++ )
836 scfx_rep::find_msw()
const
838 for(
int i = size() - 1; i >= 0; i -- )
856 scfx_rep::toggle_tc()
friend scfx_rep * add_scfx_rep(const scfx_rep &, const scfx_rep &, int)
void inc(scfx_mant &mant)
scfx_rep * sub_scfx_rep(const scfx_rep &, const scfx_rep &, int max_wl=SC_DEFAULT_MAX_WL_)
friend scfx_rep * mult_scfx_rep(const scfx_rep &, const scfx_rep &, int)
void from_string(const char *, int)
const char * to_string(sc_numrep, int, sc_fmt, const scfx_params *=0) const
~scfx_rep_scfx_string_lock()
static pthread_mutex_t m_mutex
void print(::std::ostream &) const
scfx_rep * add_scfx_rep(const scfx_rep &, const scfx_rep &, int max_wl=SC_DEFAULT_MAX_WL_)
#define SC_ASSERT_(cnd, msg)
void cast(const scfx_params &, bool &, bool &)
friend scfx_rep * rsh_scfx_rep(const scfx_rep &, int)
A scoped mutex for static scfx_rep_node* list.
void get_type(int &, int &, sc_enc &) const
friend scfx_rep * sub_scfx_rep(const scfx_rep &, const scfx_rep &, int)
friend void multiply(scfx_rep &, const scfx_rep &, const scfx_rep &, int)
bool get_slice(int, int, const scfx_params &, sc_bv_base &) const
scfx_rep * rsh_scfx_rep(const scfx_rep &, int)
bool clear(int, const scfx_params &)
friend int compare_abs(const scfx_rep &, const scfx_rep &)
friend scfx_rep * div_scfx_rep(const scfx_rep &, const scfx_rep &, int)
void operator=(const scfx_rep &)
scfx_rep * lsh_scfx_rep(const scfx_rep &, int)
scfx_rep * overflow_scfx_rep(const scfx_rep &a, const scfx_params ¶ms, bool &o_flag)
scfx_rep_scfx_string_lock()
scfx_rep * neg_scfx_rep(const scfx_rep &)
uint64 const sc_uint_base int b
scfx_rep * mult_scfx_rep(const scfx_rep &, const scfx_rep &, int max_wl=SC_DEFAULT_MAX_WL_)
A scoped mutex for scfx_rep::to_string.
friend scfx_rep * neg_scfx_rep(const scfx_rep &)
void dump(::std::ostream &) const
bool set_slice(int, int, const scfx_params &, const sc_bv_base &)
scfx_index(int wi_, int bi_)
friend int compare_msw(const scfx_rep &, const scfx_rep &)
bool rounding_flag() const
friend void align(const scfx_rep &, const scfx_rep &, int &, int &, scfx_mant_ref &, scfx_mant_ref &)
bool set(int, const scfx_params &)
scfx_rep * div_scfx_rep(const scfx_rep &, const scfx_rep &, int max_wl=SC_DEFAULT_DIV_WL_)
friend int compare_msw_ff(const scfx_rep &lhs, const scfx_rep &rhs)
friend void print_dec(scfx_string &, const scfx_rep &, int, sc_fmt)
int cmp_scfx_rep(const scfx_rep &, const scfx_rep &)
static pthread_mutex_t m_mutex
static pthread_mutex_t m_mutex
const int SC_DEFAULT_MAX_WL_
~scfx_rep_pow10_fx_lock()
void multiply(scfx_rep &, const scfx_rep &, const scfx_rep &, int max_wl=SC_DEFAULT_MAX_WL_)
scfx_rep * quantization_scfx_rep(const scfx_rep &a, const scfx_params ¶ms, bool &q_flag)
A scoped mutex for static scfx_pow10 pow10_fx.
friend void print_other(scfx_string &, const scfx_rep &, sc_numrep, int, sc_fmt, const scfx_params *)
void resize_to(int, int=0)
const int SC_DEFAULT_DIV_WL_
void complement(scfx_mant &target, const scfx_mant &source, int size)
friend int cmp_scfx_rep(const scfx_rep &, const scfx_rep &)
friend scfx_rep * overflow_scfx_rep(const scfx_rep &, const scfx_params &, bool &)
const int SC_DEFAULT_CTE_WL_
friend scfx_rep * quantization_scfx_rep(const scfx_rep &, const scfx_params &, bool &)
friend scfx_rep * lsh_scfx_rep(const scfx_rep &, int)