85 os <<
"sc_fxnum_bitref" << ::std::endl;
86 os <<
"(" << ::std::endl;
89 os <<
"idx = " <<
m_idx << ::std::endl;
90 os <<
")" << ::std::endl;
117 os <<
"sc_fxnum_fast_bitref" << ::std::endl;
118 os <<
"(" << ::std::endl;
121 os <<
"idx = " <<
m_idx << ::std::endl;
122 os <<
")" << ::std::endl;
162 os <<
"sc_fxnum_subref" << ::std::endl;
163 os <<
"(" << ::std::endl;
166 os <<
"from = " <<
m_from << ::std::endl;
167 os <<
"to = " <<
m_to << ::std::endl;
168 os <<
")" << ::std::endl;
209 os <<
"sc_fxnum_fast_subref" << ::std::endl;
210 os <<
"(" << ::std::endl;
213 os <<
"from = " <<
m_from << ::std::endl;
214 os <<
"to = " <<
m_to << ::std::endl;
215 os <<
")" << ::std::endl;
309 os <<
"sc_fxnum" << ::std::endl;
310 os <<
"(" << ::std::endl;
315 os <<
"q_flag = " <<
m_q_flag << ::std::endl;
316 os <<
"o_flag = " <<
m_o_flag << ::std::endl;
323 os <<
")" << ::std::endl;
339 SC_ASSERT_(observer_ != 0,
"unlock observer failed");
353 int fwl = params.
wl() - params.
iwl();
355 double val = scale *
c;
357 double frac_part = modf(val, &int_part);
359 q_flag = (frac_part != 0.0);
364 switch (params.
q_mode()) {
373 if (frac_part >= 0.5)
375 else if (frac_part < -0.5)
385 if (frac_part >= 0.5)
387 else if (frac_part <= -0.5)
393 if (frac_part > 0.5 ||
394 (frac_part == 0.5 && fmod(int_part, 2.0) != 0.0)) {
396 }
else if (frac_part < -0.5 ||
397 (frac_part == -0.5 && fmod(int_part, 2.0) != 0.0)) {
406 else if (frac_part < -0.5)
414 else if (frac_part <= -0.5)
430 int iwl = params.
iwl();
431 int fwl = params.
wl() - iwl;
436 high = full_circle / 2.0 - resolution;
437 if (params.
o_mode() == SC_SAT_SYM)
440 low = - full_circle / 2.0;
443 high = full_circle - resolution;
448 bool under = (val < low);
449 bool over = (val > high);
451 o_flag = (under || over);
454 switch (params.
o_mode()) {
457 int n_bits = params.
n_bits();
461 val -= floor(val / full_circle) * full_circle;
464 }
else if (n_bits < params.
wl()) {
468 val -= floor(val / X) * X;
469 if (val > (X - resolution))
477 val += full_circle / 2.0 - X;
479 val += full_circle - X;
509 int n_bits = params.
n_bits();
513 if (c2.get_bit(iwl) != c2.get_bit(iwl - 1))
514 val = -val - resolution;
517 val -= floor(val / full_circle) * full_circle;
520 }
else if (n_bits == 1) {
522 if (c2.is_neg() != c2.get_bit(iwl - 1))
523 val = -val - resolution;
526 val -= floor(val / full_circle) * full_circle;
529 }
else if (n_bits < params.
wl()) {
531 if (c2.is_neg() == c2.get_bit(iwl - n_bits))
532 val = -val - resolution;
537 val -= floor(val / X) * X;
538 if (val > (X - resolution))
545 val += full_circle / 2.0 - X;
577 if (
id.negative() != 0)
588 if (
id.
is_zero() &&
id.negative() != 0) {
688 os <<
"sc_fxnum_fast" << ::std::endl;
689 os <<
"(" << ::std::endl;
690 os <<
"val = " <<
m_val << ::std::endl;
693 os <<
"q_flag = " <<
m_q_flag << ::std::endl;
694 os <<
"o_flag = " <<
m_o_flag << ::std::endl;
701 os <<
")" << ::std::endl;
713 unsigned int m0 =
id.mantissa0();
714 unsigned int m1 =
id.mantissa1();
719 if (
id.negative() != 0) {
722 unsigned int tmp = m1;
729 int j = i -
id.exponent();
731 return ((m0 & 1U << 31) != 0);
733 return ((m0 & 1U << j) != 0);
734 else if ((j += 32) >= 0)
735 return ((m1 & 1U << j) != 0);
778 unsigned int m0 =
id.mantissa0();
779 unsigned int m1 =
id.mantissa1();
784 if (
id.negative() != 0) {
787 unsigned int tmp = m1;
795 for (
int k = 0; k < bv.
length(); ++ k) {
798 int n = l -
id.exponent();
800 b = ((m0 & 1U << 31) != 0);
802 b = ((m0 & 1U << n) != 0);
803 else if ((n += 32) >= 0)
804 b = ((m1 & 1U << n) != 0);
826 for (
int k = 0; k < bv.
length(); ++k) {
827 if (bv[k].to_bool()) {
864 SC_ASSERT_(observer_ != 0,
"unlock observer failed");
void print(::std::ostream &=::std::cout) const
void scan(::std::istream &=::std::cin)
void dump(::std::ostream &=::std::cout) const
void scan(::std::istream &=::std::cin)
void print(::std::ostream &=::std::cout) const
void dump(::std::ostream &=::std::cout) const
void dump(::std::ostream &=::std::cout) const
void print(::std::ostream &=::std::cout) const
void scan(::std::istream &=::std::cin)
const std::string to_hex() const
void unlock_observer(sc_fxnum_fast_observer *) const
const std::string to_dec() const
const std::string to_oct() const
bool set_slice(int, int, const sc_bv_base &)
sc_fxnum_fast_observer * m_observer
const std::string to_string() const
void dump(::std::ostream &=::std::cout) const
void print(::std::ostream &=::std::cout) const
void scan(::std::istream &=::std::cin)
const std::string to_bin() const
sc_fxnum_fast_observer * lock_observer() const
bool get_slice(int, int, sc_bv_base &) const
void print(::std::ostream &=::std::cout) const
void dump(::std::ostream &=::std::cout) const
void scan(::std::istream &=::std::cin)
void dump(::std::ostream &=::std::cout) const
void unlock_observer(sc_fxnum_observer *) const
bool get_slice(int, int, sc_bv_base &) const
bool set_slice(int, int, const sc_bv_base &)
const std::string to_hex() const
void print(::std::ostream &=::std::cout) const
const std::string to_dec() const
sc_fxnum_observer * lock_observer() const
const std::string to_bin() const
const std::string to_oct() const
void scan(::std::istream &=::std::cin)
sc_fxnum_observer * m_observer
const std::string to_string() const
void scan(::std::istream &is=::std::cin)
void print(::std::ostream &os=::std::cout) const
const sc_fxcast_switch & cast_switch() const
void dump(::std::ostream &) const
void dump(::std::ostream &) const
const char * to_string(sc_numrep, int, sc_fmt, const scfx_params *=0) const
const char SC_ID_INVALID_FX_VALUE_[]
const char SC_ID_WRAP_SM_NOT_DEFINED_[]
static void quantization(double &c, const scfx_params ¶ms, bool &q_flag)
double scfx_pow2(int exp)
static void overflow(double &c, const scfx_params ¶ms, bool &o_flag)
const std::string to_string(sc_enc enc)
#define SC_ERROR_IF_(cnd, id)
#define SC_ASSERT_(cnd, msg)