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;
230 return std::string(m_rep->to_string(
SC_DEC, -1,
SC_F, &m_params));
236 return std::string(m_rep->to_string(numrep, -1,
SC_F, &m_params));
242 return std::string(m_rep->to_string(numrep, (w_prefix ? 1 : 0),
249 return std::string(m_rep->to_string(
SC_DEC, -1, fmt, &m_params));
255 return std::string(m_rep->to_string(numrep, -1, fmt, &m_params));
261 return std::string(m_rep->to_string(numrep, (w_prefix ? 1 : 0),
269 return std::string(m_rep->to_string(
SC_DEC, -1,
SC_F, &m_params));
275 return std::string(m_rep->to_string(
SC_BIN, -1,
SC_F, &m_params));
281 return std::string(m_rep->to_string(
SC_OCT, -1,
SC_F, &m_params));
287 return std::string(m_rep->to_string(
SC_HEX, -1,
SC_F, &m_params));
295 os << m_rep->to_string(
SC_DEC, -1,
SC_F, &m_params);
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;
330 SC_ASSERT_(m_observer != 0,
"lock observer failed");
339 SC_ASSERT_(observer_ != 0,
"unlock observer failed");
340 m_observer = observer_;
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;
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();
514 val = -val - resolution;
517 val -= floor(val / full_circle) * full_circle;
520 }
else if (n_bits == 1) {
523 val = -val - resolution;
526 val -= floor(val / full_circle) * full_circle;
529 }
else if (n_bits < params.
wl()) {
532 val = -val - resolution;
537 val -= floor(val / X) *
X;
538 if (val > (X - resolution))
545 val += full_circle / 2.0 -
X;
570 if (m_params.cast_switch() ==
SC_ON) {
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);
752 if (m_params.enc() ==
SC_TC_ && i == m_params.iwl() - 1)
760 if (m_params.enc() ==
SC_TC_ && i == m_params.iwl() - 1)
778 unsigned int m0 =
id.mantissa0();
779 unsigned int m1 =
id.mantissa1();
784 if (
id.negative() != 0) {
787 unsigned int tmp = m1;
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);
829 if (m_params.enc() ==
SC_TC_ && l == m_params.iwl() - 1)
836 if (m_params.enc() ==
SC_TC_ && l == m_params.iwl() - 1)
855 SC_ASSERT_(m_observer != 0,
"lock observer failed");
864 SC_ASSERT_(observer_ != 0,
"unlock observer failed");
865 m_observer = observer_;
const char SC_ID_WRAP_SM_NOT_DEFINED_[]
const std::string to_oct() const
bool get_slice(int, int, sc_bv_base &) const
bool to_bool(const std::string &value, bool &retval)
Turn a string representation of a boolean into a boolean value.
void dump(::std::ostream &=::std::cout) const
double scfx_pow2(int exp)
static void overflow(double &c, const scfx_params ¶ms, bool &o_flag)
void dump(::std::ostream &=::std::cout) const
void dump(::std::ostream &=::std::cout) const
static void quantization(double &c, const scfx_params ¶ms, bool &q_flag)
void print(::std::ostream &=::std::cout) const
void scan(::std::istream &=::std::cin)
const std::string to_bin() const
void print(::std::ostream &=::std::cout) const
const std::string to_dec() const
const std::string to_string() const
void dump(::std::ostream &=::std::cout) const
const std::string to_hex() const
void scan(::std::istream &=::std::cin)
const std::string to_oct() const
sc_fxnum_observer * lock_observer() const
bool set_slice(int, int, const sc_bv_base &)
const char SC_ID_INVALID_FX_VALUE_[]
void scan(::std::istream &=::std::cin)
void print(::std::ostream &=::std::cout) const
const std::string to_hex() const
void print(::std::ostream &=::std::cout) const
void scan(::std::istream &=::std::cin)
#define SC_ASSERT_(cnd, msg)
const std::string to_dec() const
void dump(::std::ostream &=::std::cout) const
void print(::std::ostream &=::std::cout) const
void unlock_observer(sc_fxnum_observer *) const
void print(::std::ostream &=::std::cout) const
const std::string to_string() const
bool get_slice(int, int, sc_bv_base &) const
const std::string to_bin() const
void scan(::std::istream &=::std::cin)
void scan(::std::istream &=::std::cin)
void unlock_observer(sc_fxnum_fast_observer *) const
bool set_slice(int, int, const sc_bv_base &)
#define SC_ERROR_IF_(cnd, id)
sc_fxnum_fast_observer * lock_observer() const
const std::string to_string(sc_enc enc)
void dump(::std::ostream &=::std::cout) const