59#ifndef __SYSTEMC_EXT_DT_FX_SC_FXNUM_HH__
60#define __SYSTEMC_EXT_DT_FX_SC_FXNUM_HH__
73template <
typename T,
typename B>
74class TraceValFxnumBase;
84class sc_fxnum_fast_bitref;
86class sc_fxnum_fast_subref;
113#define DECL_ASN_OP_T(op, tp) \
114 sc_fxnum_bitref &operator op (tp);
116#define DECL_ASN_OP(op) \
117 DECL_ASN_OP_T(op, const sc_fxnum_bitref &) \
118 DECL_ASN_OP_T(op, const sc_fxnum_fast_bitref &) \
119 DECL_ASN_OP_T(op, const sc_bit &) \
120 DECL_ASN_OP_T(op, bool)
132 operator bool()
const;
135 void print(::std::ostream & =::std::cout)
const;
136 void scan(::std::istream & =::std::cin);
137 void dump(::std::ostream & =::std::cout)
const;
171#define DECL_ASN_OP_T(op, tp) sc_fxnum_fast_bitref &operator op (tp);
173#define DECL_ASN_OP(op) \
174 DECL_ASN_OP_T(op, const sc_fxnum_bitref &) \
175 DECL_ASN_OP_T(op, const sc_fxnum_fast_bitref &) \
176 DECL_ASN_OP_T(op, const sc_bit &) \
177 DECL_ASN_OP_T(op, bool)
189 operator bool()
const;
192 void print(::std::ostream & =::std::cout)
const;
193 void scan(::std::istream & =::std::cin);
194 void dump(::std::ostream & =::std::cout)
const;
232#define DECL_ASN_OP_T(tp) \
233 sc_fxnum_subref &operator = (tp);
255#define DECL_ASN_OP_T_A(op, tp) \
256 sc_fxnum_subref &operator op ## = (tp);
258#define DECL_ASN_OP_A(op) \
259 DECL_ASN_OP_T_A(op, const sc_fxnum_subref &) \
260 DECL_ASN_OP_T_A(op, const sc_fxnum_fast_subref &) \
261 DECL_ASN_OP_T_A(op, const sc_bv_base &) \
262 DECL_ASN_OP_T_A(op, const sc_lv_base &)
268#undef DECL_ASN_OP_T_A
272#define DECL_REL_OP_T(op, tp) \
273 friend bool operator op (const sc_fxnum_subref &, tp); \
274 friend bool operator op (tp, const sc_fxnum_subref &);
276#define DECL_REL_OP(op) \
277 friend bool operator op (const sc_fxnum_subref &, \
278 const sc_fxnum_subref &); \
279 friend bool operator op (const sc_fxnum_subref &, \
280 const sc_fxnum_fast_subref &); \
281 DECL_REL_OP_T(op, const sc_bv_base &) \
282 DECL_REL_OP_T(op, const sc_lv_base &) \
283 DECL_REL_OP_T(op, const char *) \
284 DECL_REL_OP_T(op, const bool *) \
285 DECL_REL_OP_T(op, const sc_signed &) \
286 DECL_REL_OP_T(op, const sc_unsigned &) \
287 DECL_REL_OP_T(op, int) \
288 DECL_REL_OP_T(op, unsigned int) \
289 DECL_REL_OP_T(op, long) \
290 DECL_REL_OP_T(op, unsigned long)
325 void print(::std::ostream & =::std::cout)
const;
326 void scan(::std::istream & =::std::cin);
327 void dump(::std::ostream & =::std::cout)
const;
368#define DECL_ASN_OP_T(tp) \
369 sc_fxnum_fast_subref &operator = (tp);
391#define DECL_ASN_OP_T_A(op, tp) sc_fxnum_fast_subref &operator op ## = (tp);
393#define DECL_ASN_OP_A(op) \
394 DECL_ASN_OP_T_A(op, const sc_fxnum_subref &) \
395 DECL_ASN_OP_T_A(op, const sc_fxnum_fast_subref &) \
396 DECL_ASN_OP_T_A(op, const sc_bv_base &) \
397 DECL_ASN_OP_T_A(op, const sc_lv_base &)
403#undef DECL_ASN_OP_T_A
407#define DECL_REL_OP_T(op, tp) \
408 friend bool operator op (const sc_fxnum_fast_subref &, tp); \
409 friend bool operator op (tp, const sc_fxnum_fast_subref &);
411#define DECL_REL_OP(op) \
412 friend bool operator op (const sc_fxnum_fast_subref &, \
413 const sc_fxnum_fast_subref &); \
414 friend bool operator op (const sc_fxnum_fast_subref &, \
415 const sc_fxnum_subref &); \
416 DECL_REL_OP_T(op, const sc_bv_base &) \
417 DECL_REL_OP_T(op, const sc_lv_base &) \
418 DECL_REL_OP_T(op, const char *) \
419 DECL_REL_OP_T(op, const bool *) \
420 DECL_REL_OP_T(op, const sc_signed &) \
421 DECL_REL_OP_T(op, const sc_unsigned &) \
422 DECL_REL_OP_T(op, int) \
423 DECL_REL_OP_T(op, unsigned int) \
424 DECL_REL_OP_T(op, long) \
425 DECL_REL_OP_T(op, unsigned long)
460 void print(::std::ostream & =::std::cout)
const;
461 void scan(::std::istream & =::std::cin);
462 void dump(::std::ostream & =::std::cout)
const;
492 template <
typename T,
typename B>
504#define DECL_CTOR_T(tp) \
505 sc_fxnum(tp, const sc_fxtype_params &, sc_enc, const sc_fxcast_switch &, \
506 sc_fxnum_observer *);
532 const scfx_rep *
get_rep()
const;
544#define DECL_BIN_OP_T(op, tp) \
545 friend const sc_fxval operator op (const sc_fxnum &, tp); \
546 friend const sc_fxval operator op (tp, const sc_fxnum &);
548#define DECL_BIN_OP_OTHER(op) \
549 DECL_BIN_OP_T(op, int64) \
550 DECL_BIN_OP_T(op, uint64) \
551 DECL_BIN_OP_T(op, const sc_int_base &) \
552 DECL_BIN_OP_T(op, const sc_uint_base &) \
553 DECL_BIN_OP_T(op, const sc_signed &) \
554 DECL_BIN_OP_T(op, const sc_unsigned &)
556#define DECL_BIN_OP(op, dummy) \
557 friend const sc_fxval operator op (const sc_fxnum &, const sc_fxnum &); \
558 DECL_BIN_OP_T(op, int) \
559 DECL_BIN_OP_T(op, unsigned int) \
560 DECL_BIN_OP_T(op, long) \
561 DECL_BIN_OP_T(op, unsigned long) \
562 DECL_BIN_OP_T(op, float) \
563 DECL_BIN_OP_T(op, double) \
564 DECL_BIN_OP_T(op, const char *) \
565 DECL_BIN_OP_T(op, const sc_fxval &) \
566 DECL_BIN_OP_T(op, const sc_fxval_fast &) \
567 DECL_BIN_OP_T(op, const sc_fxnum_fast &) \
568 DECL_BIN_OP_OTHER(op)
596#undef DECL_BIN_OP_OTHER
603#define DECL_BIN_FNC_T(fnc, tp) \
604 friend void fnc (sc_fxval &, const sc_fxnum &, tp); \
605 friend void fnc (sc_fxval &, tp, const sc_fxnum &); \
606 friend void fnc (sc_fxnum &, const sc_fxnum &, tp); \
607 friend void fnc (sc_fxnum &, tp, const sc_fxnum &);
609#define DECL_BIN_FNC_OTHER(fnc) \
610 DECL_BIN_FNC_T(fnc, int64) \
611 DECL_BIN_FNC_T(fnc, uint64) \
612 DECL_BIN_FNC_T(fnc, const sc_int_base &) \
613 DECL_BIN_FNC_T(fnc, const sc_uint_base &) \
614 DECL_BIN_FNC_T(fnc, const sc_signed &) \
615 DECL_BIN_FNC_T(fnc, const sc_unsigned &)
617#define DECL_BIN_FNC(fnc) \
618 friend void fnc (sc_fxval &, const sc_fxnum &, const sc_fxnum &); \
619 friend void fnc (sc_fxnum &, const sc_fxnum &, const sc_fxnum &); \
620 DECL_BIN_FNC_T(fnc, int) \
621 DECL_BIN_FNC_T(fnc, unsigned int) \
622 DECL_BIN_FNC_T(fnc, long) \
623 DECL_BIN_FNC_T(fnc, unsigned long) \
624 DECL_BIN_FNC_T(fnc, float) \
625 DECL_BIN_FNC_T(fnc, double) \
626 DECL_BIN_FNC_T(fnc, const char *) \
627 DECL_BIN_FNC_T(fnc, const sc_fxval &) \
628 DECL_BIN_FNC_T(fnc, const sc_fxval_fast &) \
629 DECL_BIN_FNC_T(fnc, const sc_fxnum_fast &) \
630 DECL_BIN_FNC_OTHER(fnc)
638#undef DECL_BIN_FNC_OTHER
647#define DECL_REL_OP_T(op, tp) \
648 friend bool operator op (const sc_fxnum &, tp); \
649 friend bool operator op (tp, const sc_fxnum &);
651#define DECL_REL_OP_OTHER(op) \
652 DECL_REL_OP_T(op, int64) \
653 DECL_REL_OP_T(op, uint64) \
654 DECL_REL_OP_T(op, const sc_int_base &) \
655 DECL_REL_OP_T(op, const sc_uint_base &) \
656 DECL_REL_OP_T(op, const sc_signed &) \
657 DECL_REL_OP_T(op, const sc_unsigned &)
659#define DECL_REL_OP(op) \
660 friend bool operator op (const sc_fxnum &, const sc_fxnum &); \
661 DECL_REL_OP_T(op, int) \
662 DECL_REL_OP_T(op, unsigned int) \
663 DECL_REL_OP_T(op, long) \
664 DECL_REL_OP_T(op, unsigned long) \
665 DECL_REL_OP_T(op, float) \
666 DECL_REL_OP_T(op, double) \
667 DECL_REL_OP_T(op, const char *) \
668 DECL_REL_OP_T(op, const sc_fxval &) \
669 DECL_REL_OP_T(op, const sc_fxval_fast &) \
670 DECL_REL_OP_T(op, const sc_fxnum_fast &) \
671 DECL_REL_OP_OTHER(op)
681#undef DECL_REL_OP_OTHER
685#define DECL_ASN_OP_T(op, tp) \
686 sc_fxnum &operator op(tp);
688#define DECL_ASN_OP_OTHER(op) \
689 DECL_ASN_OP_T(op, int64) \
690 DECL_ASN_OP_T(op, uint64) \
691 DECL_ASN_OP_T(op, const sc_int_base &) \
692 DECL_ASN_OP_T(op, const sc_uint_base &) \
693 DECL_ASN_OP_T(op, const sc_signed &) \
694 DECL_ASN_OP_T(op, const sc_unsigned &)
696#define DECL_ASN_OP(op) \
697 DECL_ASN_OP_T(op, int) \
698 DECL_ASN_OP_T(op, unsigned int) \
699 DECL_ASN_OP_T(op, long) \
700 DECL_ASN_OP_T(op, unsigned long) \
701 DECL_ASN_OP_T(op, float) \
702 DECL_ASN_OP_T(op, double) \
703 DECL_ASN_OP_T(op, const char *) \
704 DECL_ASN_OP_T(op, const sc_fxval &) \
705 DECL_ASN_OP_T(op, const sc_fxval_fast &) \
706 DECL_ASN_OP_T(op, const sc_fxnum &) \
707 DECL_ASN_OP_T(op, const sc_fxnum_fast &) \
708 DECL_ASN_OP_OTHER(op)
721#undef DECL_ASN_OP_OTHER
752 operator double()
const;
768 const std::string
to_string(sc_numrep)
const;
769 const std::string
to_string(sc_numrep,
bool)
const;
770 const std::string
to_string(sc_fmt)
const;
771 const std::string
to_string(sc_numrep, sc_fmt)
const;
772 const std::string
to_string(sc_numrep,
bool, sc_fmt)
const;
774 const std::string
to_dec()
const;
775 const std::string
to_bin()
const;
776 const std::string
to_oct()
const;
777 const std::string
to_hex()
const;
803 void print(::std::ostream & =::std::cout)
const;
804 void scan(::std::istream & =::std::cin);
805 void dump(::std::ostream & =::std::cout)
const;
816 bool get_slice(
int,
int, sc_bv_base &)
const;
817 bool set_slice(
int,
int,
const sc_bv_base &);
853 template <
typename T,
typename B>
865#define DECL_CTOR_T(tp) \
866 sc_fxnum_fast(tp, const sc_fxtype_params &, sc_enc, \
867 const sc_fxcast_switch &, sc_fxnum_fast_observer *);
905#define DECL_BIN_OP_T(op, tp) \
906 friend const sc_fxval_fast operator op (const sc_fxnum_fast &, tp); \
907 friend const sc_fxval_fast operator op (tp, const sc_fxnum_fast &);
909#define DECL_BIN_OP_OTHER(op) \
910 DECL_BIN_OP_T(op, int64) \
911 DECL_BIN_OP_T(op, uint64) \
912 DECL_BIN_OP_T(op, const sc_int_base &) \
913 DECL_BIN_OP_T(op, const sc_uint_base &) \
914 DECL_BIN_OP_T(op, const sc_signed &) \
915 DECL_BIN_OP_T(op, const sc_unsigned &)
917#define DECL_BIN_OP(op, dummy) \
918 friend const sc_fxval_fast operator op (const sc_fxnum_fast &, \
919 const sc_fxnum_fast &); \
920 DECL_BIN_OP_T(op, int) \
921 DECL_BIN_OP_T(op, unsigned int) \
922 DECL_BIN_OP_T(op, long) \
923 DECL_BIN_OP_T(op, unsigned long) \
924 DECL_BIN_OP_T(op, float) \
925 DECL_BIN_OP_T(op, double) \
926 DECL_BIN_OP_T(op, const char *) \
927 DECL_BIN_OP_T(op, const sc_fxval_fast &) \
928 DECL_BIN_OP_OTHER(op)
954#undef DECL_BIN_OP_OTHER
961#define DECL_BIN_FNC_T(fnc, tp) \
962 friend void fnc (sc_fxval_fast &, const sc_fxnum_fast &, tp); \
963 friend void fnc (sc_fxval_fast &, tp, const sc_fxnum_fast &); \
964 friend void fnc (sc_fxnum_fast &, const sc_fxnum_fast &, tp); \
965 friend void fnc (sc_fxnum_fast &, tp, const sc_fxnum_fast &);
967#define DECL_BIN_FNC_OTHER(fnc) \
968 DECL_BIN_FNC_T(fnc, int64) \
969 DECL_BIN_FNC_T(fnc, uint64) \
970 DECL_BIN_FNC_T(fnc, const sc_int_base &) \
971 DECL_BIN_FNC_T(fnc, const sc_uint_base &) \
972 DECL_BIN_FNC_T(fnc, const sc_signed &) \
973 DECL_BIN_FNC_T(fnc, const sc_unsigned &)
975#define DECL_BIN_FNC(fnc) \
976 friend void fnc (sc_fxval_fast &, const sc_fxnum_fast &, \
977 const sc_fxnum_fast &); \
978 friend void fnc (sc_fxnum_fast &, const sc_fxnum_fast &, \
979 const sc_fxnum_fast &); \
980 DECL_BIN_FNC_T(fnc, int) \
981 DECL_BIN_FNC_T(fnc, unsigned int) \
982 DECL_BIN_FNC_T(fnc, long) \
983 DECL_BIN_FNC_T(fnc, unsigned long) \
984 DECL_BIN_FNC_T(fnc, float) \
985 DECL_BIN_FNC_T(fnc, double) \
986 DECL_BIN_FNC_T(fnc, const char *) \
987 DECL_BIN_FNC_T(fnc, const sc_fxval &) \
988 DECL_BIN_FNC_T(fnc, const sc_fxval_fast &) \
989 DECL_BIN_FNC_T(fnc, const sc_fxnum &) \
990 DECL_BIN_FNC_OTHER(fnc)
998#undef DECL_BIN_FNC_OTHER
1007#define DECL_REL_OP_T(op, tp) \
1008 friend bool operator op (const sc_fxnum_fast &, tp); \
1009 friend bool operator op (tp, const sc_fxnum_fast &);
1011#define DECL_REL_OP_OTHER(op) \
1012 DECL_REL_OP_T(op, int64) \
1013 DECL_REL_OP_T(op, uint64) \
1014 DECL_REL_OP_T(op, const sc_int_base &) \
1015 DECL_REL_OP_T(op, const sc_uint_base &) \
1016 DECL_REL_OP_T(op, const sc_signed &) \
1017 DECL_REL_OP_T(op, const sc_unsigned &)
1019#define DECL_REL_OP(op) \
1020 friend bool operator op (const sc_fxnum_fast &, const sc_fxnum_fast &); \
1021 DECL_REL_OP_T(op, int) \
1022 DECL_REL_OP_T(op, unsigned int) \
1023 DECL_REL_OP_T(op, long) \
1024 DECL_REL_OP_T(op, unsigned long) \
1025 DECL_REL_OP_T(op, float) \
1026 DECL_REL_OP_T(op, double) \
1027 DECL_REL_OP_T(op, const char *) \
1028 DECL_REL_OP_T(op, const sc_fxval_fast &) \
1029 DECL_REL_OP_OTHER(op)
1039#undef DECL_REL_OP_OTHER
1043#define DECL_ASN_OP_T(op, tp) sc_fxnum_fast &operator op(tp);
1045#define DECL_ASN_OP_OTHER(op) \
1046 DECL_ASN_OP_T(op, int64) \
1047 DECL_ASN_OP_T(op, uint64) \
1048 DECL_ASN_OP_T(op, const sc_int_base &) \
1049 DECL_ASN_OP_T(op, const sc_uint_base &) \
1050 DECL_ASN_OP_T(op, const sc_signed &) \
1051 DECL_ASN_OP_T(op, const sc_unsigned &)
1053#define DECL_ASN_OP(op) \
1054 DECL_ASN_OP_T(op, int) \
1055 DECL_ASN_OP_T(op, unsigned int) \
1056 DECL_ASN_OP_T(op, long) \
1057 DECL_ASN_OP_T(op, unsigned long) \
1058 DECL_ASN_OP_T(op, float) \
1059 DECL_ASN_OP_T(op, double) \
1060 DECL_ASN_OP_T(op, const char *) \
1061 DECL_ASN_OP_T(op, const sc_fxval &) \
1062 DECL_ASN_OP_T(op, const sc_fxval_fast &) \
1063 DECL_ASN_OP_T(op, const sc_fxnum &) \
1064 DECL_ASN_OP_T(op, const sc_fxnum_fast &) \
1065 DECL_ASN_OP_OTHER(op)
1078#undef DECL_ASN_OP_OTHER
1110 operator double()
const;
1132 const std::string
to_dec()
const;
1133 const std::string
to_bin()
const;
1134 const std::string
to_oct()
const;
1135 const std::string
to_hex()
const;
1161 void print(::std::ostream & =::std::cout)
const;
1162 void scan(::std::istream & =::std::cin);
1163 void dump(::std::ostream & =::std::cout)
const;
1208 m_num(num_), m_idx(idx_)
1213 m_num(
a.m_num), m_idx(
a.m_idx)
1240 set(
static_cast<bool>(
a));
1246sc_fxnum_bitref::operator = (
bool a)
1277 set(
get() &&
static_cast<bool>(
b));
1283sc_fxnum_bitref::operator &= (
bool b)
1316 set(
get() ||
static_cast<bool>(
b));
1322sc_fxnum_bitref::operator |= (
bool b)
1355 set(
get() !=
static_cast<bool>(
b));
1361sc_fxnum_bitref::operator ^= (
bool b)
1370inline sc_fxnum_bitref::operator bool()
const
1376inline ::std::ostream &
1383inline ::std::istream &
1431 set(
static_cast<bool>(
a));
1437sc_fxnum_fast_bitref::operator = (
bool a)
1469 set(
get() &&
static_cast<bool>(
b));
1475sc_fxnum_fast_bitref::operator &= (
bool b)
1508 set(
get() ||
static_cast<bool>(
b));
1514sc_fxnum_fast_bitref::operator |= (
bool b)
1547 set(
get() !=
static_cast<bool>(
b));
1553sc_fxnum_fast_bitref::operator ^= (
bool b)
1563inline sc_fxnum_fast_bitref::operator bool()
const
1569inline ::std::ostream &
1576inline ::std::istream &
1593 m_num(num_), m_from(from_), m_to(to_),
1594 m_bv(*new
sc_bv_base(sc_max(m_from, m_to) - sc_min(m_from, m_to) + 1))
1599 m_num(
a.m_num), m_from(
a.m_from), m_to(
a.m_to),
1621inline sc_fxnum_subref &
1622sc_fxnum_subref::operator = (
const sc_fxnum_fast_subref &
a)
1624 m_bv =
static_cast<sc_bv_base
>(
a);
1630#define DEFN_ASN_OP_T(tp) \
1631inline sc_fxnum_subref & \
1632sc_fxnum_subref::operator = (tp a) \
1636 SC_FXNUM_OBSERVER_WRITE_(m_num) \
1658#define DEFN_ASN_OP_T(op, tp) \
1659inline sc_fxnum_subref & \
1660sc_fxnum_subref::operator op ## = (tp a) \
1662 SC_FXNUM_OBSERVER_READ_(m_num) \
1666 SC_FXNUM_OBSERVER_WRITE_(m_num) \
1670#define DEFN_ASN_OP(op) \
1671inline sc_fxnum_subref & \
1672sc_fxnum_subref::operator op ## = (const sc_fxnum_subref &a) \
1674 SC_FXNUM_OBSERVER_READ_(m_num) \
1676 m_bv = m_bv op static_cast<sc_bv_base>(a); \
1678 SC_FXNUM_OBSERVER_WRITE_(m_num) \
1682inline sc_fxnum_subref & \
1683sc_fxnum_subref::operator op ## = (const sc_fxnum_fast_subref &a) \
1685 SC_FXNUM_OBSERVER_READ_(m_num) \
1687 m_bv = m_bv op static_cast<sc_bv_base>(a); \
1689 SC_FXNUM_OBSERVER_WRITE_(m_num) \
1693DEFN_ASN_OP_T(op, const sc_bv_base &) \
1694DEFN_ASN_OP_T(op, const sc_lv_base &)
1704#define DEFN_REL_OP_T(op, tp) \
1706operator op (const sc_fxnum_subref &a, tp b) \
1708 return (static_cast<sc_bv_base>(a) op b); \
1712operator op (tp a, const sc_fxnum_subref &b) \
1714 return (static_cast<sc_bv_base>(b) op a); \
1717#define DEFN_REL_OP(op) \
1719operator op (const sc_fxnum_subref &a, const sc_fxnum_subref &b) \
1721 return (static_cast<sc_bv_base>(a) op static_cast<sc_bv_base>(b)); \
1725operator op (const sc_fxnum_subref &a, const sc_fxnum_fast_subref &b) \
1727 return (static_cast<sc_bv_base>(a) op static_cast<sc_bv_base>(b)); \
1730DEFN_REL_OP_T(op, const sc_bv_base &) \
1731DEFN_REL_OP_T(op, const sc_lv_base &) \
1732DEFN_REL_OP_T(op, const char *) \
1733DEFN_REL_OP_T(op, const bool *) \
1734DEFN_REL_OP_T(op, const sc_signed &) \
1735DEFN_REL_OP_T(op, const sc_unsigned &) \
1736DEFN_REL_OP_T(op, int) \
1737DEFN_REL_OP_T(op, unsigned int) \
1738DEFN_REL_OP_T(op, long) \
1739DEFN_REL_OP_T(op, unsigned long)
1750#define DEFN_RED_FNC(fnc) \
1752sc_fxnum_subref::fnc() const \
1754 SC_FXNUM_OBSERVER_READ_(m_num) \
1756 return static_cast<bool>(m_bv.fnc()); \
1825inline const std::string
1832inline const std::string
1839inline const std::string
1856inline ::std::ostream &
1863inline ::std::istream &
1882 m_num(num_), m_from(from_), m_to(to_),
1883 m_bv(*new
sc_bv_base(sc_max(m_from, m_to) - sc_min(m_from, m_to) + 1))
1890 m_num(
a.m_num), m_from(
a.m_from), m_to(
a.m_to),
1912inline sc_fxnum_fast_subref &
1913sc_fxnum_fast_subref::operator = (
const sc_fxnum_fast_subref &
a)
1916 m_bv =
static_cast<sc_bv_base
>(
a);
1923#define DEFN_ASN_OP_T(tp) \
1924inline sc_fxnum_fast_subref & \
1925sc_fxnum_fast_subref::operator = (tp a) \
1929 SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) \
1952#define DEFN_ASN_OP_T(op, tp) \
1953inline sc_fxnum_fast_subref & \
1954sc_fxnum_fast_subref::operator op ## = (tp a) \
1956 SC_FXNUM_FAST_OBSERVER_READ_(m_num) \
1960 SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) \
1964#define DEFN_ASN_OP(op) \
1965inline sc_fxnum_fast_subref & \
1966sc_fxnum_fast_subref::operator op ## = (const sc_fxnum_subref &a) \
1968 SC_FXNUM_FAST_OBSERVER_READ_(m_num) \
1970 m_bv = m_bv op static_cast<sc_bv_base>(a); \
1972 SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) \
1976inline sc_fxnum_fast_subref & \
1977sc_fxnum_fast_subref::operator op ## = (const sc_fxnum_fast_subref &a) \
1979 SC_FXNUM_FAST_OBSERVER_READ_(m_num) \
1981 m_bv = m_bv op static_cast<sc_bv_base>(a); \
1983 SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) \
1987DEFN_ASN_OP_T(op, const sc_bv_base &) \
1988DEFN_ASN_OP_T(op, const sc_lv_base &)
2000#define DEFN_REL_OP_T(op, tp) \
2002operator op (const sc_fxnum_fast_subref &a, tp b) \
2004 return (static_cast<sc_bv_base>(a) op b); \
2008operator op (tp a, const sc_fxnum_fast_subref &b) \
2010 return (static_cast<sc_bv_base>(b) op a); \
2013#define DEFN_REL_OP(op) \
2015operator op (const sc_fxnum_fast_subref &a, const sc_fxnum_fast_subref &b) \
2017 return (static_cast<sc_bv_base>(a) op static_cast<sc_bv_base>(b)); \
2021operator op (const sc_fxnum_fast_subref &a, const sc_fxnum_subref &b) \
2023 return (static_cast<sc_bv_base>(a) op static_cast<sc_bv_base>(b)); \
2026DEFN_REL_OP_T(op, const sc_bv_base &) \
2027DEFN_REL_OP_T(op, const sc_lv_base &) \
2028DEFN_REL_OP_T(op, const char *) \
2029DEFN_REL_OP_T(op, const bool *) \
2030DEFN_REL_OP_T(op, const sc_signed &) \
2031DEFN_REL_OP_T(op, const sc_unsigned &) \
2032DEFN_REL_OP_T(op, int) \
2033DEFN_REL_OP_T(op, unsigned int) \
2034DEFN_REL_OP_T(op, long) \
2035DEFN_REL_OP_T(op, unsigned long)
2044#define DEFN_RED_FNC(fnc) \
2046sc_fxnum_fast_subref::fnc() const \
2048 SC_FXNUM_FAST_OBSERVER_READ_(m_num) \
2050 return static_cast<bool>(m_bv.fnc()); \
2118inline const std::string
2125inline const std::string
2132inline const std::string
2148inline ::std::ostream &
2155inline ::std::istream &
2169inline sc_fxnum_observer *
2188 m_rep(new
scfx_rep), m_params(type_params_, enc_, cast_sw),
2189 m_q_flag(false), m_o_flag(false), m_observer(observer_)
2195#define DEFN_CTOR_T(tp, arg) \
2196inline sc_fxnum::sc_fxnum(tp a, const sc_fxtype_params &type_params_, \
2197 sc_enc enc_, const sc_fxcast_switch &cast_sw, \
2198 sc_fxnum_observer *observer_) : \
2199 m_rep(new scfx_rep(arg)), m_params(type_params_, enc_, cast_sw), \
2200 m_q_flag(false), m_o_flag(false), m_observer(observer_) \
2202 SC_FXNUM_OBSERVER_DEFAULT_ \
2204 SC_FXNUM_OBSERVER_CONSTRUCT_(*this) \
2205 SC_FXNUM_OBSERVER_WRITE_(*this) \
2208#define DEFN_CTOR_T_A(tp) DEFN_CTOR_T(tp, a)
2209#define DEFN_CTOR_T_B(tp) DEFN_CTOR_T(tp, *a.m_rep)
2210#define DEFN_CTOR_T_C(tp) DEFN_CTOR_T(tp, a.to_double())
2211#define DEFN_CTOR_T_D(tp) DEFN_CTOR_T(tp, a.value())
2224#ifndef SC_FX_EXCLUDE_OTHER
2287#define DEFN_BIN_OP_T(op, fnc, tp) \
2288inline const sc_fxval \
2289operator op (const sc_fxnum &a, tp b) \
2291 SC_FXNUM_OBSERVER_READ_(a) \
2293 return sc_fxval(sc_dt::fnc ## _scfx_rep(*a.m_rep, *tmp.get_rep())); \
2296inline const sc_fxval \
2297operator op (tp a, const sc_fxnum &b) \
2299 SC_FXNUM_OBSERVER_READ_(b) \
2301 return sc_fxval(sc_dt::fnc ## _scfx_rep(*tmp.get_rep(), *b.m_rep)); \
2304#ifndef SC_FX_EXCLUDE_OTHER
2305#define DEFN_BIN_OP_OTHER(op, fnc) \
2306DEFN_BIN_OP_T(op, fnc, int64) \
2307DEFN_BIN_OP_T(op, fnc, uint64) \
2308DEFN_BIN_OP_T(op, fnc, const sc_int_base &) \
2309DEFN_BIN_OP_T(op, fnc, const sc_uint_base &) \
2310DEFN_BIN_OP_T(op, fnc, const sc_signed &) \
2311DEFN_BIN_OP_T(op, fnc, const sc_unsigned &)
2313#define DEFN_BIN_OP_OTHER(op, fnc)
2316#define DEFN_BIN_OP(op, fnc) \
2317inline const sc_fxval \
2318operator op (const sc_fxnum &a, const sc_fxnum &b) \
2320 SC_FXNUM_OBSERVER_READ_(a) \
2321 SC_FXNUM_OBSERVER_READ_(b) \
2322 return sc_fxval(sc_dt::fnc ## _scfx_rep(*a.m_rep, *b.m_rep)); \
2325inline const sc_fxval \
2326operator op (const sc_fxnum &a, const sc_fxval &b) \
2328 SC_FXNUM_OBSERVER_READ_(a) \
2329 return sc_fxval(sc_dt::fnc ## _scfx_rep(*a.m_rep, *b.get_rep())); \
2332inline const sc_fxval \
2333operator op (const sc_fxval &a, const sc_fxnum &b) \
2335 SC_FXNUM_OBSERVER_READ_(b) \
2336 return sc_fxval(sc_dt::fnc ## _scfx_rep(*a.get_rep(), *b.m_rep)); \
2339DEFN_BIN_OP_T(op, fnc, int) \
2340DEFN_BIN_OP_T(op, fnc, unsigned int) \
2341DEFN_BIN_OP_T(op, fnc, long) \
2342DEFN_BIN_OP_T(op, fnc, unsigned long) \
2343DEFN_BIN_OP_T(op, fnc, float) \
2344DEFN_BIN_OP_T(op, fnc, double) \
2345DEFN_BIN_OP_T(op, fnc, const char *) \
2346DEFN_BIN_OP_T(op, fnc, const sc_fxval_fast &) \
2347DEFN_BIN_OP_T(op, fnc, const sc_fxnum_fast &) \
2348DEFN_BIN_OP_OTHER(op, fnc)
2396#undef DEFN_BIN_OP_OTHER
2414#define DEFN_BIN_FNC_T(fnc, tp) \
2416fnc (sc_fxval &c, const sc_fxnum &a, tp b) \
2418 SC_FXNUM_OBSERVER_READ_(a) \
2420 c.set_rep(sc_dt::fnc ## _scfx_rep(*a.m_rep, *tmp.get_rep())); \
2424fnc (sc_fxval &c, tp a, const sc_fxnum &b) \
2426 SC_FXNUM_OBSERVER_READ_(b) \
2428 c.set_rep(sc_dt::fnc ## _scfx_rep(*tmp.get_rep(), *b.m_rep)); \
2432fnc (sc_fxnum &c, const sc_fxnum &a, tp b) \
2434 SC_FXNUM_OBSERVER_READ_(a) \
2437 c.m_rep = sc_dt::fnc ## _scfx_rep(*a.m_rep, *tmp.get_rep()); \
2439 SC_FXNUM_OBSERVER_WRITE_(c) \
2443fnc (sc_fxnum &c, tp a, const sc_fxnum &b) \
2445 SC_FXNUM_OBSERVER_READ_(b) \
2448 c.m_rep = sc_dt::fnc ## _scfx_rep(*tmp.get_rep(), *b.m_rep); \
2450 SC_FXNUM_OBSERVER_WRITE_(c) \
2453#define DEFN_BIN_FNC_OTHER(fnc) \
2454DEFN_BIN_FNC_T(fnc, int64) \
2455DEFN_BIN_FNC_T(fnc, uint64) \
2456DEFN_BIN_FNC_T(fnc, const sc_int_base &) \
2457DEFN_BIN_FNC_T(fnc, const sc_uint_base &) \
2458DEFN_BIN_FNC_T(fnc, const sc_signed &) \
2459DEFN_BIN_FNC_T(fnc, const sc_unsigned &)
2461#define DEFN_BIN_FNC(fnc) \
2463fnc (sc_fxval &c, const sc_fxnum &a, const sc_fxnum &b) \
2465 SC_FXNUM_OBSERVER_READ_(a) \
2466 SC_FXNUM_OBSERVER_READ_(b) \
2467 c.set_rep(sc_dt::fnc ## _scfx_rep(*a.m_rep, *b.m_rep)); \
2471fnc (sc_fxnum &c, const sc_fxnum &a, const sc_fxnum &b) \
2473 SC_FXNUM_OBSERVER_READ_(a) \
2474 SC_FXNUM_OBSERVER_READ_(b) \
2476 c.m_rep = sc_dt::fnc ## _scfx_rep(*a.m_rep, *b.m_rep); \
2478 SC_FXNUM_OBSERVER_WRITE_(c) \
2482fnc (sc_fxval &c, const sc_fxnum &a, const sc_fxval &b) \
2484 SC_FXNUM_OBSERVER_READ_(a) \
2485 c.set_rep(sc_dt::fnc ## _scfx_rep(*a.m_rep, *b.get_rep())); \
2489fnc (sc_fxval &c, const sc_fxval &a, const sc_fxnum &b) \
2491 SC_FXNUM_OBSERVER_READ_(b) \
2492 c.set_rep(sc_dt::fnc ## _scfx_rep(*a.get_rep(), *b.m_rep)); \
2496fnc (sc_fxnum &c, const sc_fxnum &a, const sc_fxval &b) \
2498 SC_FXNUM_OBSERVER_READ_(a) \
2500 c.m_rep = sc_dt::fnc ## _scfx_rep(*a.m_rep, *b.get_rep()); \
2502 SC_FXNUM_OBSERVER_WRITE_(c) \
2506fnc (sc_fxnum &c, const sc_fxval &a, const sc_fxnum &b) \
2508 SC_FXNUM_OBSERVER_READ_(b) \
2510 c.m_rep = sc_dt::fnc ## _scfx_rep(*a.get_rep(), *b.m_rep); \
2512 SC_FXNUM_OBSERVER_WRITE_(c) \
2515DEFN_BIN_FNC_T(fnc, int) \
2516DEFN_BIN_FNC_T(fnc, unsigned int) \
2517DEFN_BIN_FNC_T(fnc, long) \
2518DEFN_BIN_FNC_T(fnc, unsigned long) \
2519DEFN_BIN_FNC_T(fnc, float) \
2520DEFN_BIN_FNC_T(fnc, double) \
2521DEFN_BIN_FNC_T(fnc, const char *) \
2522DEFN_BIN_FNC_T(fnc, const sc_fxval_fast &) \
2523DEFN_BIN_FNC_T(fnc, const sc_fxnum_fast &) \
2524DEFN_BIN_FNC_OTHER(fnc)
2531#undef DEFN_BIN_FNC_T
2532#undef DEFN_BIN_FNC_OTHER
2570#define DEFN_REL_OP_T(op, ret, tp) \
2572operator op (const sc_fxnum &a, tp b) \
2574 SC_FXNUM_OBSERVER_READ_(a) \
2576 int result = sc_dt::cmp_scfx_rep(*a.m_rep, *tmp.get_rep()); \
2581operator op (tp a, const sc_fxnum &b) \
2583 SC_FXNUM_OBSERVER_READ_(b) \
2585 int result = sc_dt::cmp_scfx_rep(*tmp.get_rep(), *b.m_rep); \
2589#define DEFN_REL_OP_OTHER(op, ret) \
2590DEFN_REL_OP_T(op, ret, int64) \
2591DEFN_REL_OP_T(op, ret, uint64) \
2592DEFN_REL_OP_T(op, ret, const sc_int_base &) \
2593DEFN_REL_OP_T(op, ret, const sc_uint_base &) \
2594DEFN_REL_OP_T(op, ret, const sc_signed &) \
2595DEFN_REL_OP_T(op, ret, const sc_unsigned &)
2597#define DEFN_REL_OP(op, ret) \
2599operator op (const sc_fxnum &a, const sc_fxnum &b) \
2601 SC_FXNUM_OBSERVER_READ_(a) \
2602 SC_FXNUM_OBSERVER_READ_(b) \
2603 int result = sc_dt::cmp_scfx_rep(*a.m_rep, *b.m_rep); \
2608operator op (const sc_fxnum &a, const sc_fxval &b) \
2610 SC_FXNUM_OBSERVER_READ_(a) \
2611 int result = sc_dt::cmp_scfx_rep(*a.m_rep, *b.get_rep()); \
2616operator op (const sc_fxval &a, const sc_fxnum &b) \
2618 SC_FXNUM_OBSERVER_READ_(b) \
2619 int result = sc_dt::cmp_scfx_rep(*a.get_rep(), *b.m_rep); \
2623DEFN_REL_OP_T(op, ret, int) \
2624DEFN_REL_OP_T(op, ret, unsigned int) \
2625DEFN_REL_OP_T(op, ret, long) \
2626DEFN_REL_OP_T(op, ret, unsigned long) \
2627DEFN_REL_OP_T(op, ret, float) \
2628DEFN_REL_OP_T(op, ret, double) \
2629DEFN_REL_OP_T(op, ret, const char *) \
2630DEFN_REL_OP_T(op, ret, const sc_fxval_fast &) \
2631DEFN_REL_OP_T(op, ret, const sc_fxnum_fast &) \
2632DEFN_REL_OP_OTHER(op, ret)
2642#undef DEFN_REL_OP_OTHER
2647sc_fxnum::operator = (
const sc_fxnum &
a)
2667#define DEFN_ASN_OP_T(tp) \
2669sc_fxnum::operator = (tp a) \
2672 *m_rep = *tmp.get_rep(); \
2674 SC_FXNUM_OBSERVER_WRITE_(*this) \
2698#define DEFN_ASN_OP_T(op, fnc, tp) \
2700sc_fxnum::operator op (tp b) \
2702 SC_FXNUM_OBSERVER_READ_(*this) \
2704 scfx_rep *new_rep = sc_dt::fnc ## _scfx_rep(*m_rep, *tmp.get_rep()); \
2708 SC_FXNUM_OBSERVER_WRITE_(*this) \
2712#define DEFN_ASN_OP_OTHER(op, fnc) \
2713DEFN_ASN_OP_T(op, fnc, int64) \
2714DEFN_ASN_OP_T(op, fnc, uint64) \
2715DEFN_ASN_OP_T(op, fnc, const sc_int_base &) \
2716DEFN_ASN_OP_T(op, fnc, const sc_uint_base &) \
2717DEFN_ASN_OP_T(op, fnc, const sc_signed &) \
2718DEFN_ASN_OP_T(op, fnc, const sc_unsigned &)
2720#define DEFN_ASN_OP(op, fnc) \
2722sc_fxnum::operator op (const sc_fxnum &b) \
2724 SC_FXNUM_OBSERVER_READ_(*this) \
2725 SC_FXNUM_OBSERVER_READ_(b) \
2726 scfx_rep *new_rep = sc_dt::fnc ## _scfx_rep(*m_rep, *b.m_rep); \
2730 SC_FXNUM_OBSERVER_WRITE_(*this) \
2735sc_fxnum::operator op (const sc_fxval &b) \
2737 SC_FXNUM_OBSERVER_READ_(*this) \
2738 scfx_rep *new_rep = sc_dt::fnc ## _scfx_rep(*m_rep, *b.get_rep()); \
2742 SC_FXNUM_OBSERVER_WRITE_(*this) \
2746DEFN_ASN_OP_T(op, fnc, int) \
2747DEFN_ASN_OP_T(op, fnc, unsigned int) \
2748DEFN_ASN_OP_T(op, fnc, long) \
2749DEFN_ASN_OP_T(op, fnc, unsigned long) \
2750DEFN_ASN_OP_T(op, fnc, float) \
2751DEFN_ASN_OP_T(op, fnc, double) \
2752DEFN_ASN_OP_T(op, fnc, const char *) \
2753DEFN_ASN_OP_T(op, fnc, const sc_fxval_fast &) \
2754DEFN_ASN_OP_T(op, fnc, const sc_fxnum_fast &) \
2755DEFN_ASN_OP_OTHER(op, fnc)
2763#undef DEFN_ASN_OP_OTHER
2768sc_fxnum::operator <<= (
int b)
2778sc_fxnum::operator >>= (
int b)
2915inline sc_fxnum::operator double()
const
2929inline unsigned short
3114inline ::std::ostream &
3121inline ::std::istream &
3135inline sc_fxnum_fast_observer *
3159 m_val(
a.m_val), m_params(type_params_, enc_, cast_sw), m_q_flag(false),
3160 m_o_flag(false), m_observer(observer_)
3169#define DEFN_CTOR_T(tp, arg) \
3170inline sc_fxnum_fast::sc_fxnum_fast( \
3171 tp a, const sc_fxtype_params &type_params_, sc_enc enc_, \
3172 const sc_fxcast_switch &cast_sw, \
3173 sc_fxnum_fast_observer *observer_) : \
3174 m_val(arg), m_params(type_params_, enc_, cast_sw), m_q_flag(false), \
3175 m_o_flag(false), m_observer(observer_) \
3177 SC_FXNUM_FAST_OBSERVER_DEFAULT_ \
3179 SC_FXNUM_FAST_OBSERVER_CONSTRUCT_(*this) \
3180 SC_FXNUM_FAST_OBSERVER_WRITE_(*this) \
3183#define DEFN_CTOR_T_A(tp) DEFN_CTOR_T(tp, static_cast<double>(a))
3184#define DEFN_CTOR_T_B(tp) DEFN_CTOR_T(tp, sc_fxval_fast::from_string(a))
3185#define DEFN_CTOR_T_C(tp) DEFN_CTOR_T(tp, a.to_double())
3245 c.set_val(-
a.m_val);
3252 c.m_val = -
a.m_val;
3258#define DEFN_BIN_OP_T(op, tp) \
3259inline const sc_fxval_fast \
3260operator op (const sc_fxnum_fast &a, tp b) \
3262 SC_FXNUM_FAST_OBSERVER_READ_(a) \
3263 sc_fxval_fast tmp(b); \
3264 return sc_fxval_fast(a.m_val op tmp.get_val()); \
3267inline const sc_fxval_fast \
3268operator op (tp a, const sc_fxnum_fast &b) \
3270 SC_FXNUM_FAST_OBSERVER_READ_(b) \
3271 sc_fxval_fast tmp(a); \
3272 return sc_fxval_fast(tmp.get_val() op b.m_val); \
3275#define DEFN_BIN_OP_OTHER(op) \
3276DEFN_BIN_OP_T(op, int64) \
3277DEFN_BIN_OP_T(op, uint64) \
3278DEFN_BIN_OP_T(op, const sc_int_base &) \
3279DEFN_BIN_OP_T(op, const sc_uint_base &) \
3280DEFN_BIN_OP_T(op, const sc_signed &) \
3281DEFN_BIN_OP_T(op, const sc_unsigned &)
3283#define DEFN_BIN_OP(op, dummy) \
3284inline const sc_fxval_fast \
3285operator op (const sc_fxnum_fast &a, const sc_fxnum_fast &b) \
3287 SC_FXNUM_FAST_OBSERVER_READ_(a) \
3288 SC_FXNUM_FAST_OBSERVER_READ_(b) \
3289 return sc_fxval_fast(a.m_val op b.m_val); \
3292inline const sc_fxval_fast \
3293operator op (const sc_fxnum_fast &a, const sc_fxval_fast &b) \
3295 SC_FXNUM_FAST_OBSERVER_READ_(a) \
3296 return sc_fxval_fast(a.m_val op b.get_val()); \
3299inline const sc_fxval_fast \
3300operator op (const sc_fxval_fast &a, const sc_fxnum_fast &b) \
3302 SC_FXNUM_FAST_OBSERVER_READ_(b) \
3303 return sc_fxval_fast(a.get_val() op b.m_val); \
3306DEFN_BIN_OP_T(op, int) \
3307DEFN_BIN_OP_T(op, unsigned int) \
3308DEFN_BIN_OP_T(op, long) \
3309DEFN_BIN_OP_T(op, unsigned long) \
3310DEFN_BIN_OP_T(op, float) \
3311DEFN_BIN_OP_T(op, double) \
3312DEFN_BIN_OP_T(op, const char *) \
3313DEFN_BIN_OP_OTHER(op)
3358#undef DEFN_BIN_OP_OTHER
3376#define DEFN_BIN_FNC_T(fnc, op, tp) \
3378fnc (sc_fxval_fast &c, const sc_fxnum_fast &a, tp b) \
3380 SC_FXNUM_FAST_OBSERVER_READ_(a) \
3381 sc_fxval_fast tmp(b); \
3382 c.set_val(a.m_val op tmp.get_val()); \
3386fnc (sc_fxval_fast &c, tp a, const sc_fxnum_fast &b) \
3388 SC_FXNUM_FAST_OBSERVER_READ_(b) \
3389 sc_fxval_fast tmp(a); \
3390 c.set_val(tmp.get_val() op b.m_val); \
3394fnc (sc_fxnum_fast &c, const sc_fxnum_fast &a, tp b) \
3396 SC_FXNUM_FAST_OBSERVER_READ_(a) \
3397 sc_fxval_fast tmp(b); \
3398 c.m_val = a.m_val op tmp.get_val(); \
3400 SC_FXNUM_FAST_OBSERVER_WRITE_(c) \
3404fnc (sc_fxnum_fast &c, tp a, const sc_fxnum_fast &b) \
3406 SC_FXNUM_FAST_OBSERVER_READ_(b) \
3407 sc_fxval_fast tmp(a); \
3408 c.m_val = tmp.get_val() op b.m_val; \
3410 SC_FXNUM_FAST_OBSERVER_WRITE_(c) \
3413#define DEFN_BIN_FNC_OTHER(fnc, op) \
3414DEFN_BIN_FNC_T(fnc, op, int64) \
3415DEFN_BIN_FNC_T(fnc, op, uint64) \
3416DEFN_BIN_FNC_T(fnc, op, const sc_int_base &) \
3417DEFN_BIN_FNC_T(fnc, op, const sc_uint_base &) \
3418DEFN_BIN_FNC_T(fnc, op, const sc_signed &) \
3419DEFN_BIN_FNC_T(fnc, op, const sc_unsigned &)
3421#define DEFN_BIN_FNC(fnc, op) \
3423fnc (sc_fxval_fast &c, const sc_fxnum_fast &a, const sc_fxnum_fast &b) \
3425 SC_FXNUM_FAST_OBSERVER_READ_(a) \
3426 SC_FXNUM_FAST_OBSERVER_READ_(b) \
3427 c.set_val(a.m_val op b.m_val); \
3431fnc (sc_fxnum_fast &c, const sc_fxnum_fast &a, const sc_fxnum_fast &b) \
3433 SC_FXNUM_FAST_OBSERVER_READ_(a) \
3434 SC_FXNUM_FAST_OBSERVER_READ_(b) \
3435 c.m_val = a.m_val op b.m_val; \
3437 SC_FXNUM_FAST_OBSERVER_WRITE_(c) \
3441fnc (sc_fxval_fast &c, const sc_fxnum_fast &a, const sc_fxval_fast &b) \
3443 SC_FXNUM_FAST_OBSERVER_READ_(a) \
3444 c.set_val(a.m_val op b.get_val()); \
3448fnc (sc_fxval_fast &c, const sc_fxval_fast &a, const sc_fxnum_fast &b) \
3450 SC_FXNUM_FAST_OBSERVER_READ_(b) \
3451 c.set_val(a.get_val() op b.m_val); \
3455fnc (sc_fxnum_fast &c, const sc_fxnum_fast &a, const sc_fxval_fast &b) \
3457 SC_FXNUM_FAST_OBSERVER_READ_(a) \
3458 c.m_val = a.m_val op b.get_val(); \
3460 SC_FXNUM_FAST_OBSERVER_WRITE_(c) \
3464fnc (sc_fxnum_fast &c, const sc_fxval_fast &a, const sc_fxnum_fast &b) \
3466 SC_FXNUM_FAST_OBSERVER_READ_(b) \
3467 c.m_val = a.get_val() op b.m_val; \
3469 SC_FXNUM_FAST_OBSERVER_WRITE_(c) \
3472DEFN_BIN_FNC_T(fnc, op, int) \
3473DEFN_BIN_FNC_T(fnc, op, unsigned int) \
3474DEFN_BIN_FNC_T(fnc, op, long) \
3475DEFN_BIN_FNC_T(fnc, op, unsigned long) \
3476DEFN_BIN_FNC_T(fnc, op, float) \
3477DEFN_BIN_FNC_T(fnc, op, double) \
3478DEFN_BIN_FNC_T(fnc, op, const char *) \
3479DEFN_BIN_FNC_T(fnc, op, const sc_fxval &) \
3480DEFN_BIN_FNC_T(fnc, op, const sc_fxnum &) \
3481DEFN_BIN_FNC_OTHER(fnc, op)
3488#undef DEFN_BIN_FNC_T
3489#undef DEFN_BIN_FNC_OTHER
3525#define DEFN_REL_OP_T(op, tp) \
3527operator op (const sc_fxnum_fast &a, tp b) \
3529 SC_FXNUM_FAST_OBSERVER_READ_(a) \
3530 sc_fxval_fast tmp(b); \
3531 return (a.m_val op tmp.get_val()); \
3535operator op (tp a, const sc_fxnum_fast &b) \
3537 SC_FXNUM_FAST_OBSERVER_READ_(b) \
3538 sc_fxval_fast tmp(a); \
3539 return (tmp.get_val() op b.m_val); \
3542#define DEFN_REL_OP_OTHER(op) \
3543DEFN_REL_OP_T(op, int64) \
3544DEFN_REL_OP_T(op, uint64) \
3545DEFN_REL_OP_T(op, const sc_int_base &) \
3546DEFN_REL_OP_T(op, const sc_uint_base &) \
3547DEFN_REL_OP_T(op, const sc_signed &) \
3548DEFN_REL_OP_T(op, const sc_unsigned &)
3550#define DEFN_REL_OP(op) \
3552operator op (const sc_fxnum_fast &a, const sc_fxnum_fast &b) \
3554 SC_FXNUM_FAST_OBSERVER_READ_(a) \
3555 SC_FXNUM_FAST_OBSERVER_READ_(b) \
3556 return (a.m_val op b.m_val); \
3560operator op (const sc_fxnum_fast &a, const sc_fxval_fast &b) \
3562 SC_FXNUM_FAST_OBSERVER_READ_(a) \
3563 return (a.m_val op b.get_val()); \
3567operator op (const sc_fxval_fast &a, const sc_fxnum_fast &b) \
3569 SC_FXNUM_FAST_OBSERVER_READ_(b) \
3570 return (a.get_val() op b.m_val); \
3573DEFN_REL_OP_T(op, int) \
3574DEFN_REL_OP_T(op, unsigned int) \
3575DEFN_REL_OP_T(op, long) \
3576DEFN_REL_OP_T(op, unsigned long) \
3577DEFN_REL_OP_T(op, float) \
3578DEFN_REL_OP_T(op, double) \
3579DEFN_REL_OP_T(op, const char *) \
3580DEFN_REL_OP_OTHER(op)
3590#undef DEFN_REL_OP_OTHER
3616#define DEFN_ASN_OP_T(tp) \
3617inline sc_fxnum_fast & \
3618sc_fxnum_fast::operator = (tp a) \
3620 sc_fxval_fast tmp(a); \
3621 m_val = tmp.get_val(); \
3623 SC_FXNUM_FAST_OBSERVER_WRITE_(*this) \
3646#define DEFN_ASN_OP_T(op, tp) \
3647inline sc_fxnum_fast & \
3648sc_fxnum_fast::operator op (tp b) \
3650 SC_FXNUM_FAST_OBSERVER_READ_(*this) \
3651 sc_fxval_fast tmp(b); \
3652 m_val op tmp.get_val(); \
3654 SC_FXNUM_FAST_OBSERVER_WRITE_(*this) \
3658#define DEFN_ASN_OP_OTHER(op) \
3659DEFN_ASN_OP_T(op, int64) \
3660DEFN_ASN_OP_T(op, uint64) \
3661DEFN_ASN_OP_T(op, const sc_int_base &) \
3662DEFN_ASN_OP_T(op, const sc_uint_base &) \
3663DEFN_ASN_OP_T(op, const sc_signed &) \
3664DEFN_ASN_OP_T(op, const sc_unsigned &)
3666#define DEFN_ASN_OP(op) \
3667inline sc_fxnum_fast & \
3668sc_fxnum_fast::operator op (const sc_fxnum_fast &b) \
3670 SC_FXNUM_FAST_OBSERVER_READ_(*this) \
3671 SC_FXNUM_FAST_OBSERVER_READ_(b) \
3674 SC_FXNUM_FAST_OBSERVER_WRITE_(*this) \
3678inline sc_fxnum_fast & \
3679sc_fxnum_fast::operator op (const sc_fxval_fast &b) \
3681 SC_FXNUM_FAST_OBSERVER_READ_(*this) \
3682 m_val op b.get_val(); \
3684 SC_FXNUM_FAST_OBSERVER_WRITE_(*this) \
3688DEFN_ASN_OP_T(op, int) \
3689DEFN_ASN_OP_T(op, unsigned int) \
3690DEFN_ASN_OP_T(op, long) \
3691DEFN_ASN_OP_T(op, unsigned long) \
3692DEFN_ASN_OP_T(op, float) \
3693DEFN_ASN_OP_T(op, double) \
3694DEFN_ASN_OP_T(op, const char *) \
3695DEFN_ASN_OP_T(op, const sc_fxval &) \
3696DEFN_ASN_OP_T(op, const sc_fxnum &) \
3697DEFN_ASN_OP_OTHER(op)
3705#undef DEFN_ASN_OP_OTHER
3709sc_fxnum_fast::operator <<= (
int b)
3868inline sc_fxnum_fast::operator double()
const
3882inline unsigned short
3886 return static_cast<unsigned short>(
to_uint64());
3907 return static_cast<unsigned int>(
to_uint64());
3919 double mantissa_dbl = frexp(
m_val, &exponent);
3921 uint64 mantissa =
static_cast<uint64>(fabs(mantissa_dbl) *
3925 if (!(-64 < exponent && exponent < 64)) {
3929 mantissa = exponent >= 0 ? mantissa << exponent : mantissa >> -exponent;
3930 return mantissa_dbl >= 0 ? mantissa : -mantissa;
3944 return static_cast<unsigned long>(
to_uint64());
3951 return static_cast<float>(
m_val);
3967 return (
id.negative() != 0);
3975 return id.is_zero();
4056inline ::std::ostream &
4063inline ::std::istream &
4088 m_rep(new
scfx_rep(
a.to_double())), m_observer(observer_)
4096#define DEFN_BIN_OP_T(op, fnc, tp) \
4097inline const sc_fxval \
4098operator op (const sc_fxval &a, tp b) \
4100 SC_FXVAL_OBSERVER_READ_(a) \
4102 return sc_fxval(sc_dt::fnc ## _scfx_rep(*a.m_rep, *tmp.m_rep)); \
4105inline const sc_fxval \
4106operator op (tp a, const sc_fxval &b) \
4108 SC_FXVAL_OBSERVER_READ_(b) \
4110 return sc_fxval(sc_dt::fnc ## _scfx_rep(*tmp.m_rep, *b.m_rep)); \
4113#define DEFN_BIN_OP(op, fnc) \
4114DEFN_BIN_OP_T(op, fnc, const sc_fxnum_fast &)
4127#define DEFN_BIN_FNC_T(fnc, tp) \
4129fnc (sc_fxval &c, const sc_fxval &a, tp b) \
4131 SC_FXVAL_OBSERVER_READ_(a) \
4134 c.m_rep = sc_dt::fnc ## _scfx_rep(*a.m_rep, *tmp.m_rep); \
4135 SC_FXVAL_OBSERVER_WRITE_(c) \
4139fnc (sc_fxval &c, tp a, const sc_fxval &b) \
4141 SC_FXVAL_OBSERVER_READ_(b) \
4144 c.m_rep = sc_dt::fnc ## _scfx_rep(*tmp.m_rep, *b.m_rep); \
4145 SC_FXVAL_OBSERVER_WRITE_(c) \
4148#define DEFN_BIN_FNC(fnc) \
4149DEFN_BIN_FNC_T(fnc, const sc_fxnum_fast &)
4156#undef DEFN_BIN_FNC_T
4161#define DEFN_REL_OP_T(op, ret, tp) \
4163operator op (const sc_fxval &a, tp b) \
4165 SC_FXVAL_OBSERVER_READ_(a) \
4167 int result = sc_dt::cmp_scfx_rep(*a.m_rep, *tmp.m_rep); \
4172operator op (tp a, const sc_fxval &b) \
4174 SC_FXVAL_OBSERVER_READ_(b) \
4176 int result = sc_dt::cmp_scfx_rep(*tmp.m_rep, *b.m_rep); \
4180#define DEFN_REL_OP(op, ret) \
4181DEFN_REL_OP_T(op, ret, const sc_fxnum_fast &)
4202#define DEFN_ASN_OP_T(tp) \
4204sc_fxval::operator = (tp b) \
4207 *m_rep = *tmp.m_rep; \
4208 SC_FXVAL_OBSERVER_WRITE_(*this) \
4216#define DEFN_ASN_OP_T(op, fnc, tp) \
4218sc_fxval::operator op (tp b) \
4220 SC_FXVAL_OBSERVER_READ_(*this) \
4222 scfx_rep *new_rep = sc_dt::fnc ## _scfx_rep(*m_rep, *tmp.m_rep); \
4225 SC_FXVAL_OBSERVER_WRITE_(*this) \
4229#define DEFN_ASN_OP(op, fnc) \
4231sc_fxval::operator op (const sc_fxnum &b) \
4233 SC_FXVAL_OBSERVER_READ_(*this) \
4234 scfx_rep *new_rep = sc_dt::fnc ## _scfx_rep(*m_rep, *b.get_rep()); \
4237 SC_FXVAL_OBSERVER_WRITE_(*this) \
4241DEFN_ASN_OP_T(op, fnc, const sc_fxnum_fast &)
4272 m_val(
a.get_val()), m_observer(observer_)
4281#define DEFN_BIN_FNC_T(fnc, op, tp) \
4283fnc (sc_fxval_fast &c, const sc_fxval_fast &a, tp b) \
4285 SC_FXVAL_FAST_OBSERVER_READ_(a) \
4286 sc_fxval_fast tmp(b); \
4287 c.m_val = a.m_val op tmp.m_val; \
4288 SC_FXVAL_FAST_OBSERVER_WRITE_(c) \
4292fnc (sc_fxval_fast &c, tp a, const sc_fxval_fast &b) \
4294 SC_FXVAL_FAST_OBSERVER_READ_(b) \
4295 sc_fxval_fast tmp(a); \
4296 c.m_val = tmp.m_val op b.m_val; \
4297 SC_FXVAL_FAST_OBSERVER_WRITE_(c) \
4300#define DEFN_BIN_FNC(fnc, op) \
4301DEFN_BIN_FNC_T(fnc, op, const sc_fxval &) \
4302DEFN_BIN_FNC_T(fnc, op, const sc_fxnum &)
4309#undef DEFN_BIN_FNC_T
4322#define DEFN_ASN_OP_T(tp) \
4323inline sc_fxval_fast & \
4324sc_fxval_fast::operator = (tp a) \
4326 sc_fxval_fast tmp(a); \
4327 m_val = tmp.m_val; \
4328 SC_FXVAL_FAST_OBSERVER_WRITE_(*this) \
4336#define DEFN_ASN_OP_T(op, tp) \
4337inline sc_fxval_fast & \
4338sc_fxval_fast::operator op (tp b) \
4340 SC_FXVAL_FAST_OBSERVER_READ_(*this) \
4341 sc_fxval_fast tmp(b); \
4342 m_val op tmp.m_val; \
4343 SC_FXVAL_FAST_OBSERVER_WRITE_(*this) \
4347#define DEFN_ASN_OP(op) \
4348inline sc_fxval_fast & \
4349sc_fxval_fast::operator op (const sc_fxnum_fast &b) \
4351 SC_FXVAL_FAST_OBSERVER_READ_(*this) \
4352 m_val op b.get_val(); \
4353 SC_FXVAL_FAST_OBSERVER_WRITE_(*this) \
4357DEFN_ASN_OP_T(op, const sc_fxnum &)
void print(::std::ostream &=::std::cout) const
void scan(::std::istream &=::std::cin)
void dump(::std::ostream &=::std::cout) const
friend class sc_fxnum_fast_bitref
void scan(::std::istream &=::std::cin)
void print(::std::ostream &=::std::cout) const
void dump(::std::ostream &=::std::cout) const
friend class sc_fxnum_bitref
void dump(::std::ostream &=::std::cout) const
const std::string to_string() const
void print(::std::ostream &=::std::cout) const
unsigned long to_ulong() const
void scan(::std::istream &=::std::cin)
unsigned int to_uint() const
const std::string to_hex() const
sc_fxnum_fast & operator--()
friend void lshift(sc_fxval_fast &, const sc_fxnum_fast &, int)
void unlock_observer(sc_fxnum_fast_observer *) const
sc_fxnum_fast & operator++()
const std::string to_dec() const
friend class sc_fxnum_fast_subref
const std::string to_oct() const
friend void neg(sc_fxval_fast &, const sc_fxnum_fast &)
const sc_fxtype_params & type_params() const
const sc_fxval_fast value() const
bool set_slice(int, int, const sc_bv_base &)
const sc_fxnum_fast_subref range() const
sc_fxnum_fast_observer * m_observer
unsigned short to_ushort() const
const std::string to_string() const
sc_fxnum_fast(const sc_fxnum_fast &)
const sc_fxval_fast operator+() const
const sc_fxnum_fast_bitref operator[](int) const
const sc_fxcast_switch & cast_switch() const
const sc_fxnum_fast_subref operator()() const
void dump(::std::ostream &=::std::cout) const
void print(::std::ostream &=::std::cout) const
friend class sc_fxval_fast
void observer_read() const
void scan(::std::istream &=::std::cin)
bool quantization_flag() const
const sc_fxnum_fast_bitref bit(int) const
const std::string to_bin() const
friend class sc_fxnum_fast_bitref
friend const sc_fxval_fast operator/(const sc_fxnum_fast &, const sc_fxnum_fast &)
friend const sc_fxval_fast operator>>(const sc_fxnum_fast &, int)
sc_fxnum_fast_observer * lock_observer() const
bool overflow_flag() const
const sc_fxval_fast operator-() const
bool get_slice(int, int, sc_bv_base &) const
unsigned long to_ulong() const
sc_fxnum_fast_observer * observer() const
friend void rshift(sc_fxval_fast &, const sc_fxnum_fast &, int)
unsigned int to_uint() const
unsigned int to_uint() const
const std::string to_string() const
void print(::std::ostream &=::std::cout) const
void dump(::std::ostream &=::std::cout) const
void scan(::std::istream &=::std::cin)
unsigned long to_ulong() const
const sc_fxcast_switch & cast_switch() const
void dump(::std::ostream &=::std::cout) const
void unlock_observer(sc_fxnum_observer *) const
const sc_fxnum_subref range() const
bool get_slice(int, int, sc_bv_base &) const
friend const sc_fxval operator/(const sc_fxnum &, const sc_fxnum &)
bool set_slice(int, int, const sc_bv_base &)
const std::string to_hex() const
const sc_fxnum_bitref operator[](int) const
void print(::std::ostream &=::std::cout) const
const std::string to_dec() const
sc_fxnum(const sc_fxnum &)
sc_fxnum_observer * lock_observer() const
const sc_fxval operator-() const
friend class sc_fxnum_subref
friend const sc_fxval operator<<(const sc_fxnum &, int)
const sc_fxnum_subref operator()() const
const std::string to_bin() const
const std::string to_oct() const
void observer_read() const
void scan(::std::istream &=::std::cin)
const sc_fxtype_params & type_params() const
unsigned int to_uint() const
friend void neg(sc_fxval &, const sc_fxnum &)
sc_fxnum_observer * m_observer
const std::string to_string() const
bool quantization_flag() const
bool overflow_flag() const
friend void rshift(sc_fxval &, const sc_fxnum &, int)
unsigned long to_ulong() const
unsigned short to_ushort() const
friend const sc_fxval operator>>(const sc_fxnum &, int)
const sc_fxnum_bitref bit(int) const
const sc_fxval value() const
sc_fxnum_observer * observer() const
const sc_fxval operator+() const
const scfx_rep * get_rep() const
friend void lshift(sc_fxval &, const sc_fxnum &, int)
friend class sc_fxnum_bitref
sc_fxval_fast(sc_fxval_fast_observer *=0)
sc_fxval_observer * m_observer
unsigned int to_uint() const
unsigned long to_ulong() const
const std::string to_string() const
const sc_fxcast_switch & cast_switch() const
const sc_fxtype_params & type_params() const
bool get_slice(int, int, const scfx_params &, sc_bv_base &) const
void cast(const scfx_params &, bool &, bool &)
bool set_slice(int, int, const scfx_params &, const sc_bv_base &)
bool clear(int, const scfx_params &)
bool set(int, const scfx_params &)
const char SC_ID_OUT_OF_RANGE_[]
const char SC_ID_INVALID_FX_VALUE_[]
void neg(sc_fxval &c, const sc_fxnum &a)
sc_proxy< X >::value_type or_reduce(const sc_proxy< X > &a)
sc_proxy< X >::value_type xor_reduce(const sc_proxy< X > &a)
scfx_rep * rsh_scfx_rep(const scfx_rep &, int)
scfx_rep * lsh_scfx_rep(const scfx_rep &, int)
void rshift(sc_fxval &c, const sc_fxnum &a, int b)
sc_proxy< X >::value_type nor_reduce(const sc_proxy< X > &a)
static const uint64 UINT64_ONE
void lshift(sc_fxval &c, const sc_fxnum &a, int b)
scfx_rep * neg_scfx_rep(const scfx_rep &)
scfx_rep * div_scfx_rep(const scfx_rep &lhs, const scfx_rep &rhs, int div_wl)
double scfx_pow2(int exp)
sc_signed operator<<(const sc_signed &u, const sc_int_base &v)
sc_proxy< X >::value_type and_reduce(const sc_proxy< X > &a)
sc_proxy< X >::value_type xnor_reduce(const sc_proxy< X > &a)
sc_proxy< X >::value_type nand_reduce(const sc_proxy< X > &a)
sc_signed operator>>(const sc_signed &u, const sc_int_base &v)
sc_signed operator/(const sc_unsigned &u, const sc_int_base &v)
#define DEFN_ASN_OP_T(op, tp)
#define DECL_ASN_OP_T(op, tp)
#define SC_ERROR_IF_(cnd, id)
#define DECL_BIN_FNC(fnc)
#define DECL_BIN_OP_T(op, tp)
#define DEFN_BIN_FNC(fnc)
#define DEFN_RED_FNC(fnc)
#define DEFN_CTOR_T_B(tp)
#define DEFN_CTOR_T_C(tp)
#define DEFN_CTOR_T_A(tp)
#define DEFN_CTOR_T_D(tp)
#define DECL_ASN_OP_A(op)
#define DECL_BIN_OP(op, dummy)
#define SC_FXNUM_OBSERVER_WRITE_(object)
#define SC_FXNUM_OBSERVER_DEFAULT_
#define SC_FXNUM_OBSERVER_READ_(object)
#define SC_FXNUM_FAST_OBSERVER_DESTRUCT_(object)
#define SC_FXNUM_OBSERVER_CONSTRUCT_(object)
#define SC_FXNUM_OBSERVER_DESTRUCT_(object)
#define SC_FXNUM_FAST_OBSERVER_CONSTRUCT_(object)
#define SC_FXNUM_FAST_OBSERVER_WRITE_(object)
#define SC_FXNUM_FAST_OBSERVER_READ_(object)
#define SC_FXNUM_FAST_OBSERVER_DEFAULT_
#define SC_FXVAL_OBSERVER_DEFAULT_
#define SC_FXVAL_OBSERVER_WRITE_(object)
#define SC_FXVAL_FAST_OBSERVER_CONSTRUCT_(object)
#define SC_FXVAL_FAST_OBSERVER_DEFAULT_
#define SC_FXVAL_FAST_OBSERVER_WRITE_(object)
#define SC_FXVAL_OBSERVER_CONSTRUCT_(object)
#define DEFN_BIN_OP_T(ret, op, tp)
#define DEFN_BIN_OP(ret, op)