Go to the documentation of this file.
59 #ifndef __SYSTEMC_EXT_DT_FX_SC_FXNUM_HH__
60 #define __SYSTEMC_EXT_DT_FX_SC_FXNUM_HH__
64 #include "../bit/sc_lv_base.hh"
73 template <
typename T,
typename B>
74 class TraceValFxnumBase;
83 class sc_fxnum_bitref;
84 class sc_fxnum_fast_bitref;
85 class sc_fxnum_subref;
86 class 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)
457 operator sc_bv_base()
const;
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 *);
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)
637 #undef DECL_BIN_FNC_T
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;
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;
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)
947 DECL_BIN_OP_T(/,
uint64) \
948 DECL_BIN_OP_T(/,
const sc_int_base &) \
949 DECL_BIN_OP_T(/,
const sc_uint_base &) \
950 DECL_BIN_OP_T(/,
const sc_signed &) \
951 DECL_BIN_OP_T(/,
const sc_unsigned &)
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)
997 #undef DECL_BIN_FNC_T
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)
1038 #undef DECL_REL_OP_T
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)
1077 #undef DECL_ASN_OP_T
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;
1174 bool get_slice(
int,
int, sc_bv_base &)
const;
1175 bool set_slice(
int,
int,
const sc_bv_base &);
1208 m_num(num_), m_idx(idx_)
1213 m_num(
a.m_num), m_idx(
a.m_idx)
1240 set(
static_cast<bool>(
a));
1246 sc_fxnum_bitref::operator = (
bool a)
1277 set(
get() &&
static_cast<bool>(
b));
1316 set(
get() ||
static_cast<bool>(
b));
1355 set(
get() !=
static_cast<bool>(
b));
1370 inline sc_fxnum_bitref::operator bool()
const
1376 inline ::std::ostream &
1383 inline ::std::istream &
1431 set(
static_cast<bool>(
a));
1437 sc_fxnum_fast_bitref::operator = (
bool a)
1469 set(
get() &&
static_cast<bool>(
b));
1508 set(
get() ||
static_cast<bool>(
b));
1547 set(
get() !=
static_cast<bool>(
b));
1563 inline sc_fxnum_fast_bitref::operator bool()
const
1569 inline ::std::ostream &
1576 inline ::std::istream &
1593 m_num(num_), m_from(from_), m_to(to_),
1599 m_num(
a.m_num), m_from(
a.m_from), m_to(
a.m_to),
1621 inline sc_fxnum_subref &
1622 sc_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) \
1631 inline sc_fxnum_subref & \
1632 sc_fxnum_subref::operator = (tp a) \
1636 SC_FXNUM_OBSERVER_WRITE_(m_num) \
1656 #undef DEFN_ASN_OP_T
1658 #define DEFN_ASN_OP_T(op, tp) \
1659 inline sc_fxnum_subref & \
1660 sc_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) \
1671 inline sc_fxnum_subref & \
1672 sc_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) \
1682 inline sc_fxnum_subref & \
1683 sc_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) \
1693 DEFN_ASN_OP_T(op, const sc_bv_base &) \
1694 DEFN_ASN_OP_T(op, const sc_lv_base &)
1700 #undef DEFN_ASN_OP_T
1704 #define DEFN_REL_OP_T(op, tp) \
1706 operator op (const sc_fxnum_subref &a, tp b) \
1708 return (static_cast<sc_bv_base>(a) op b); \
1712 operator op (tp a, const sc_fxnum_subref &b) \
1714 return (static_cast<sc_bv_base>(b) op a); \
1717 #define DEFN_REL_OP(op) \
1719 operator 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)); \
1725 operator 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)); \
1730 DEFN_REL_OP_T(op, const sc_bv_base &) \
1731 DEFN_REL_OP_T(op, const sc_lv_base &) \
1732 DEFN_REL_OP_T(op, const char *) \
1733 DEFN_REL_OP_T(op, const bool *) \
1734 DEFN_REL_OP_T(op, const sc_signed &) \
1735 DEFN_REL_OP_T(op, const sc_unsigned &) \
1736 DEFN_REL_OP_T(op, int) \
1737 DEFN_REL_OP_T(op, unsigned int) \
1738 DEFN_REL_OP_T(op, long) \
1739 DEFN_REL_OP_T(op, unsigned long)
1744 #undef DEFN_REL_OP_T
1750 #define DEFN_RED_FNC(fnc) \
1752 sc_fxnum_subref::fnc() const \
1754 SC_FXNUM_OBSERVER_READ_(m_num) \
1756 return static_cast<bool>(m_bv.fnc()); \
1816 inline unsigned long
1825 inline const std::string
1832 inline const std::string
1839 inline const std::string
1856 inline ::std::ostream &
1863 inline ::std::istream &
1882 m_num(num_), m_from(from_), m_to(to_),
1890 m_num(
a.m_num), m_from(
a.m_from), m_to(
a.m_to),
1912 inline sc_fxnum_fast_subref &
1913 sc_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) \
1924 inline sc_fxnum_fast_subref & \
1925 sc_fxnum_fast_subref::operator = (tp a) \
1929 SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) \
1949 #undef DEFN_ASN_OP_T
1952 #define DEFN_ASN_OP_T(op, tp) \
1953 inline sc_fxnum_fast_subref & \
1954 sc_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) \
1965 inline sc_fxnum_fast_subref & \
1966 sc_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) \
1976 inline sc_fxnum_fast_subref & \
1977 sc_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) \
1987 DEFN_ASN_OP_T(op, const sc_bv_base &) \
1988 DEFN_ASN_OP_T(op, const sc_lv_base &)
1994 #undef DEFN_ASN_OP_T
2000 #define DEFN_REL_OP_T(op, tp) \
2002 operator op (const sc_fxnum_fast_subref &a, tp b) \
2004 return (static_cast<sc_bv_base>(a) op b); \
2008 operator 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) \
2015 operator 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)); \
2021 operator 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)); \
2026 DEFN_REL_OP_T(op, const sc_bv_base &) \
2027 DEFN_REL_OP_T(op, const sc_lv_base &) \
2028 DEFN_REL_OP_T(op, const char *) \
2029 DEFN_REL_OP_T(op, const bool *) \
2030 DEFN_REL_OP_T(op, const sc_signed &) \
2031 DEFN_REL_OP_T(op, const sc_unsigned &) \
2032 DEFN_REL_OP_T(op, int) \
2033 DEFN_REL_OP_T(op, unsigned int) \
2034 DEFN_REL_OP_T(op, long) \
2035 DEFN_REL_OP_T(op, unsigned long)
2040 #undef DEFN_REL_OP_T
2044 #define DEFN_RED_FNC(fnc) \
2046 sc_fxnum_fast_subref::fnc() const \
2048 SC_FXNUM_FAST_OBSERVER_READ_(m_num) \
2050 return static_cast<bool>(m_bv.fnc()); \
2110 inline unsigned long
2118 inline const std::string
2125 inline const std::string
2132 inline const std::string
2148 inline ::std::ostream &
2155 inline ::std::istream &
2169 inline 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) \
2196 inline 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
2234 #undef DEFN_CTOR_T_A
2235 #undef DEFN_CTOR_T_B
2236 #undef DEFN_CTOR_T_C
2237 #undef DEFN_CTOR_T_D
2287 #define DEFN_BIN_OP_T(op, fnc, tp) \
2288 inline const sc_fxval \
2289 operator 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())); \
2296 inline const sc_fxval \
2297 operator 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) \
2306 DEFN_BIN_OP_T(op, fnc, int64) \
2307 DEFN_BIN_OP_T(op, fnc, uint64) \
2308 DEFN_BIN_OP_T(op, fnc, const sc_int_base &) \
2309 DEFN_BIN_OP_T(op, fnc, const sc_uint_base &) \
2310 DEFN_BIN_OP_T(op, fnc, const sc_signed &) \
2311 DEFN_BIN_OP_T(op, fnc, const sc_unsigned &)
2313 #define DEFN_BIN_OP_OTHER(op, fnc)
2316 #define DEFN_BIN_OP(op, fnc) \
2317 inline const sc_fxval \
2318 operator 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)); \
2325 inline const sc_fxval \
2326 operator 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())); \
2332 inline const sc_fxval \
2333 operator 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)); \
2339 DEFN_BIN_OP_T(op, fnc, int) \
2340 DEFN_BIN_OP_T(op, fnc, unsigned int) \
2341 DEFN_BIN_OP_T(op, fnc, long) \
2342 DEFN_BIN_OP_T(op, fnc, unsigned long) \
2343 DEFN_BIN_OP_T(op, fnc, float) \
2344 DEFN_BIN_OP_T(op, fnc, double) \
2345 DEFN_BIN_OP_T(op, fnc, const char *) \
2346 DEFN_BIN_OP_T(op, fnc, const sc_fxval_fast &) \
2347 DEFN_BIN_OP_T(op, fnc, const sc_fxnum_fast &) \
2348 DEFN_BIN_OP_OTHER(op, fnc)
2395 #undef DEFN_BIN_OP_T
2396 #undef DEFN_BIN_OP_OTHER
2414 #define DEFN_BIN_FNC_T(fnc, tp) \
2416 fnc (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())); \
2424 fnc (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)); \
2432 fnc (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) \
2443 fnc (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) \
2454 DEFN_BIN_FNC_T(fnc, int64) \
2455 DEFN_BIN_FNC_T(fnc, uint64) \
2456 DEFN_BIN_FNC_T(fnc, const sc_int_base &) \
2457 DEFN_BIN_FNC_T(fnc, const sc_uint_base &) \
2458 DEFN_BIN_FNC_T(fnc, const sc_signed &) \
2459 DEFN_BIN_FNC_T(fnc, const sc_unsigned &)
2461 #define DEFN_BIN_FNC(fnc) \
2463 fnc (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)); \
2471 fnc (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) \
2482 fnc (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())); \
2489 fnc (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)); \
2496 fnc (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) \
2506 fnc (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) \
2515 DEFN_BIN_FNC_T(fnc, int) \
2516 DEFN_BIN_FNC_T(fnc, unsigned int) \
2517 DEFN_BIN_FNC_T(fnc, long) \
2518 DEFN_BIN_FNC_T(fnc, unsigned long) \
2519 DEFN_BIN_FNC_T(fnc, float) \
2520 DEFN_BIN_FNC_T(fnc, double) \
2521 DEFN_BIN_FNC_T(fnc, const char *) \
2522 DEFN_BIN_FNC_T(fnc, const sc_fxval_fast &) \
2523 DEFN_BIN_FNC_T(fnc, const sc_fxnum_fast &) \
2524 DEFN_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) \
2572 operator 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()); \
2581 operator 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) \
2590 DEFN_REL_OP_T(op, ret, int64) \
2591 DEFN_REL_OP_T(op, ret, uint64) \
2592 DEFN_REL_OP_T(op, ret, const sc_int_base &) \
2593 DEFN_REL_OP_T(op, ret, const sc_uint_base &) \
2594 DEFN_REL_OP_T(op, ret, const sc_signed &) \
2595 DEFN_REL_OP_T(op, ret, const sc_unsigned &)
2597 #define DEFN_REL_OP(op, ret) \
2599 operator 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); \
2608 operator 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()); \
2616 operator 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); \
2623 DEFN_REL_OP_T(op, ret, int) \
2624 DEFN_REL_OP_T(op, ret, unsigned int) \
2625 DEFN_REL_OP_T(op, ret, long) \
2626 DEFN_REL_OP_T(op, ret, unsigned long) \
2627 DEFN_REL_OP_T(op, ret, float) \
2628 DEFN_REL_OP_T(op, ret, double) \
2629 DEFN_REL_OP_T(op, ret, const char *) \
2630 DEFN_REL_OP_T(op, ret, const sc_fxval_fast &) \
2631 DEFN_REL_OP_T(op, ret, const sc_fxnum_fast &) \
2632 DEFN_REL_OP_OTHER(op, ret)
2641 #undef DEFN_REL_OP_T
2642 #undef DEFN_REL_OP_OTHER
2647 sc_fxnum::operator = (
const sc_fxnum &
a)
2659 sc_fxnum::operator = (
const sc_fxval &
a)
2667 #define DEFN_ASN_OP_T(tp) \
2669 sc_fxnum::operator = (tp a) \
2672 *m_rep = *tmp.get_rep(); \
2674 SC_FXNUM_OBSERVER_WRITE_(*this) \
2695 #undef DEFN_ASN_OP_T
2698 #define DEFN_ASN_OP_T(op, fnc, tp) \
2700 sc_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) \
2713 DEFN_ASN_OP_T(op, fnc, int64) \
2714 DEFN_ASN_OP_T(op, fnc, uint64) \
2715 DEFN_ASN_OP_T(op, fnc, const sc_int_base &) \
2716 DEFN_ASN_OP_T(op, fnc, const sc_uint_base &) \
2717 DEFN_ASN_OP_T(op, fnc, const sc_signed &) \
2718 DEFN_ASN_OP_T(op, fnc, const sc_unsigned &)
2720 #define DEFN_ASN_OP(op, fnc) \
2722 sc_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) \
2735 sc_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) \
2746 DEFN_ASN_OP_T(op, fnc, int) \
2747 DEFN_ASN_OP_T(op, fnc, unsigned int) \
2748 DEFN_ASN_OP_T(op, fnc, long) \
2749 DEFN_ASN_OP_T(op, fnc, unsigned long) \
2750 DEFN_ASN_OP_T(op, fnc, float) \
2751 DEFN_ASN_OP_T(op, fnc, double) \
2752 DEFN_ASN_OP_T(op, fnc, const char *) \
2753 DEFN_ASN_OP_T(op, fnc, const sc_fxval_fast &) \
2754 DEFN_ASN_OP_T(op, fnc, const sc_fxnum_fast &) \
2755 DEFN_ASN_OP_OTHER(op, fnc)
2762 #undef DEFN_ASN_OP_T
2763 #undef DEFN_ASN_OP_OTHER
2768 sc_fxnum::operator <<= (
int b)
2915 inline sc_fxnum::operator double()
const
2929 inline unsigned short
2971 inline unsigned long
3114 inline ::std::ostream &
3121 inline ::std::istream &
3135 inline 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) \
3170 inline 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())
3206 #undef DEFN_CTOR_T_A
3207 #undef DEFN_CTOR_T_B
3208 #undef DEFN_CTOR_T_C
3209 #undef DEFN_CTOR_T_D
3210 #undef DEFN_CTOR_T_E
3245 c.set_val(-
a.m_val);
3252 c.m_val = -
a.m_val;
3258 #define DEFN_BIN_OP_T(op, tp) \
3259 inline const sc_fxval_fast \
3260 operator 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()); \
3267 inline const sc_fxval_fast \
3268 operator 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) \
3276 DEFN_BIN_OP_T(op, int64) \
3277 DEFN_BIN_OP_T(op, uint64) \
3278 DEFN_BIN_OP_T(op, const sc_int_base &) \
3279 DEFN_BIN_OP_T(op, const sc_uint_base &) \
3280 DEFN_BIN_OP_T(op, const sc_signed &) \
3281 DEFN_BIN_OP_T(op, const sc_unsigned &)
3283 #define DEFN_BIN_OP(op, dummy) \
3284 inline const sc_fxval_fast \
3285 operator 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); \
3292 inline const sc_fxval_fast \
3293 operator 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()); \
3299 inline const sc_fxval_fast \
3300 operator 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); \
3306 DEFN_BIN_OP_T(op, int) \
3307 DEFN_BIN_OP_T(op, unsigned int) \
3308 DEFN_BIN_OP_T(op, long) \
3309 DEFN_BIN_OP_T(op, unsigned long) \
3310 DEFN_BIN_OP_T(op, float) \
3311 DEFN_BIN_OP_T(op, double) \
3312 DEFN_BIN_OP_T(op, const char *) \
3313 DEFN_BIN_OP_OTHER(op)
3357 #undef DEFN_BIN_OP_T
3358 #undef DEFN_BIN_OP_OTHER
3376 #define DEFN_BIN_FNC_T(fnc, op, tp) \
3378 fnc (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()); \
3386 fnc (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); \
3394 fnc (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) \
3404 fnc (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) \
3414 DEFN_BIN_FNC_T(fnc, op, int64) \
3415 DEFN_BIN_FNC_T(fnc, op, uint64) \
3416 DEFN_BIN_FNC_T(fnc, op, const sc_int_base &) \
3417 DEFN_BIN_FNC_T(fnc, op, const sc_uint_base &) \
3418 DEFN_BIN_FNC_T(fnc, op, const sc_signed &) \
3419 DEFN_BIN_FNC_T(fnc, op, const sc_unsigned &)
3421 #define DEFN_BIN_FNC(fnc, op) \
3423 fnc (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); \
3431 fnc (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) \
3441 fnc (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()); \
3448 fnc (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); \
3455 fnc (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) \
3464 fnc (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) \
3472 DEFN_BIN_FNC_T(fnc, op, int) \
3473 DEFN_BIN_FNC_T(fnc, op, unsigned int) \
3474 DEFN_BIN_FNC_T(fnc, op, long) \
3475 DEFN_BIN_FNC_T(fnc, op, unsigned long) \
3476 DEFN_BIN_FNC_T(fnc, op, float) \
3477 DEFN_BIN_FNC_T(fnc, op, double) \
3478 DEFN_BIN_FNC_T(fnc, op, const char *) \
3479 DEFN_BIN_FNC_T(fnc, op, const sc_fxval &) \
3480 DEFN_BIN_FNC_T(fnc, op, const sc_fxnum &) \
3481 DEFN_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) \
3527 operator 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()); \
3535 operator 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) \
3543 DEFN_REL_OP_T(op, int64) \
3544 DEFN_REL_OP_T(op, uint64) \
3545 DEFN_REL_OP_T(op, const sc_int_base &) \
3546 DEFN_REL_OP_T(op, const sc_uint_base &) \
3547 DEFN_REL_OP_T(op, const sc_signed &) \
3548 DEFN_REL_OP_T(op, const sc_unsigned &)
3550 #define DEFN_REL_OP(op) \
3552 operator 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); \
3560 operator 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()); \
3567 operator 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); \
3573 DEFN_REL_OP_T(op, int) \
3574 DEFN_REL_OP_T(op, unsigned int) \
3575 DEFN_REL_OP_T(op, long) \
3576 DEFN_REL_OP_T(op, unsigned long) \
3577 DEFN_REL_OP_T(op, float) \
3578 DEFN_REL_OP_T(op, double) \
3579 DEFN_REL_OP_T(op, const char *) \
3580 DEFN_REL_OP_OTHER(op)
3589 #undef DEFN_REL_OP_T
3590 #undef DEFN_REL_OP_OTHER
3616 #define DEFN_ASN_OP_T(tp) \
3617 inline sc_fxnum_fast & \
3618 sc_fxnum_fast::operator = (tp a) \
3620 sc_fxval_fast tmp(a); \
3621 m_val = tmp.get_val(); \
3623 SC_FXNUM_FAST_OBSERVER_WRITE_(*this) \
3644 #undef DEFN_ASN_OP_T
3646 #define DEFN_ASN_OP_T(op, tp) \
3647 inline sc_fxnum_fast & \
3648 sc_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) \
3659 DEFN_ASN_OP_T(op, int64) \
3660 DEFN_ASN_OP_T(op, uint64) \
3661 DEFN_ASN_OP_T(op, const sc_int_base &) \
3662 DEFN_ASN_OP_T(op, const sc_uint_base &) \
3663 DEFN_ASN_OP_T(op, const sc_signed &) \
3664 DEFN_ASN_OP_T(op, const sc_unsigned &)
3666 #define DEFN_ASN_OP(op) \
3667 inline sc_fxnum_fast & \
3668 sc_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) \
3678 inline sc_fxnum_fast & \
3679 sc_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) \
3688 DEFN_ASN_OP_T(op, int) \
3689 DEFN_ASN_OP_T(op, unsigned int) \
3690 DEFN_ASN_OP_T(op, long) \
3691 DEFN_ASN_OP_T(op, unsigned long) \
3692 DEFN_ASN_OP_T(op, float) \
3693 DEFN_ASN_OP_T(op, double) \
3694 DEFN_ASN_OP_T(op, const char *) \
3695 DEFN_ASN_OP_T(op, const sc_fxval &) \
3696 DEFN_ASN_OP_T(op, const sc_fxnum &) \
3697 DEFN_ASN_OP_OTHER(op)
3704 #undef DEFN_ASN_OP_T
3705 #undef DEFN_ASN_OP_OTHER
3709 sc_fxnum_fast::operator <<= (
int b)
3719 sc_fxnum_fast::operator >>= (
int b)
3868 inline sc_fxnum_fast::operator double()
const
3882 inline 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;
3940 inline unsigned long
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();
4056 inline ::std::ostream &
4063 inline ::std::istream &
4088 m_rep(new
scfx_rep(
a.to_double())), m_observer(observer_)
4096 #define DEFN_BIN_OP_T(op, fnc, tp) \
4097 inline const sc_fxval \
4098 operator 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)); \
4105 inline const sc_fxval \
4106 operator 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) \
4114 DEFN_BIN_OP_T(op, fnc, const sc_fxnum_fast &)
4122 #undef DEFN_BIN_OP_T
4127 #define DEFN_BIN_FNC_T(fnc, tp) \
4129 fnc (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) \
4139 fnc (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) \
4149 DEFN_BIN_FNC_T(fnc, const sc_fxnum_fast &)
4156 #undef DEFN_BIN_FNC_T
4161 #define DEFN_REL_OP_T(op, ret, tp) \
4163 operator 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); \
4172 operator 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) \
4181 DEFN_REL_OP_T(op, ret, const sc_fxnum_fast &)
4190 #undef DEFN_REL_OP_T
4195 sc_fxval::operator = (
const sc_fxnum &
a)
4202 #define DEFN_ASN_OP_T(tp) \
4204 sc_fxval::operator = (tp b) \
4207 *m_rep = *tmp.m_rep; \
4208 SC_FXVAL_OBSERVER_WRITE_(*this) \
4214 #undef DEFN_ASN_OP_T
4216 #define DEFN_ASN_OP_T(op, fnc, tp) \
4218 sc_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) \
4231 sc_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) \
4241 DEFN_ASN_OP_T(op, fnc, const sc_fxnum_fast &)
4248 #undef DEFN_ASN_OP_T
4263 m_val(
a.to_double()), m_observer(observer_)
4272 m_val(
a.get_val()), m_observer(observer_)
4281 #define DEFN_BIN_FNC_T(fnc, op, tp) \
4283 fnc (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) \
4292 fnc (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) \
4301 DEFN_BIN_FNC_T(fnc, op, const sc_fxval &) \
4302 DEFN_BIN_FNC_T(fnc, op, const sc_fxnum &)
4309 #undef DEFN_BIN_FNC_T
4314 inline sc_fxval_fast &
4315 sc_fxval_fast::operator = (
const sc_fxnum_fast &
a)
4322 #define DEFN_ASN_OP_T(tp) \
4323 inline sc_fxval_fast & \
4324 sc_fxval_fast::operator = (tp a) \
4326 sc_fxval_fast tmp(a); \
4327 m_val = tmp.m_val; \
4328 SC_FXVAL_FAST_OBSERVER_WRITE_(*this) \
4334 #undef DEFN_ASN_OP_T
4336 #define DEFN_ASN_OP_T(op, tp) \
4337 inline sc_fxval_fast & \
4338 sc_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) \
4348 inline sc_fxval_fast & \
4349 sc_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) \
4357 DEFN_ASN_OP_T(op, const sc_fxnum &)
4364 #undef DEFN_ASN_OP_T
4369 #endif // __SYSTEMC_EXT_DT_FX_SC_FXNUM_HH__
friend class sc_fxnum_bitref
const std::string to_string() const
sc_fxnum_observer * observer() const
unsigned long to_ulong() const
unsigned long to_ulong() const
void print(::std::ostream &=::std::cout) const
void observer_read() const
unsigned int to_uint() const
const sc_fxval operator+() const
unsigned short to_ushort() const
#define DEFN_CTOR_T_C(tp)
void scan(::std::istream &=::std::cin)
const sc_fxnum_fast_subref operator()() const
X & operator|=(sc_proxy< X > &px, const sc_proxy< Y > &py)
unsigned long to_ulong() const
#define SC_FXNUM_OBSERVER_CONSTRUCT_(object)
#define SC_FXNUM_FAST_OBSERVER_DESTRUCT_(object)
friend class sc_fxnum_fast_subref
#define SC_FXVAL_FAST_OBSERVER_CONSTRUCT_(object)
scfx_rep * div_scfx_rep(const scfx_rep &lhs, const scfx_rep &rhs, int div_wl)
#define DEFN_CTOR_T_D(tp)
#define DEFN_CTOR_T_A(tp)
bool clear(int, const scfx_params &)
#define SC_FXVAL_FAST_OBSERVER_DEFAULT_
const std::string to_oct() const
bool get_slice(int, int, sc_bv_base &) const
sc_signed operator<<(const sc_signed &u, const sc_int_base &v)
const friend sc_fxval operator>>(const sc_fxnum &, int)
void observer_read() const
sc_fxnum_observer * m_observer
unsigned long to_ulong() const
const std::string to_bin() const
X & operator&=(sc_proxy< X > &px, const sc_proxy< Y > &py)
const std::string to_string() const
sc_signed operator/(const sc_unsigned &u, const sc_int_base &v)
const std::string to_hex() const
const std::string to_string() const
double scfx_pow2(int exp)
const std::string to_bin() const
sc_fxnum_fast_observer * lock_observer() const
void dump(::std::ostream &=::std::cout) const
const sc_fxval operator-() const
friend void neg(sc_fxval &, const sc_fxnum &)
void print(::std::ostream &=::std::cout) const
sc_proxy< X >::value_type xor_reduce(const sc_proxy< X > &a)
void print(::std::ostream &=::std::cout) const
#define DECL_BIN_OP(op, dummy)
void scan(::std::istream &=::std::cin)
bool set_slice(int, int, const sc_bv_base &)
#define SC_FXNUM_FAST_OBSERVER_CONSTRUCT_(object)
#define DECL_BIN_OP_T(op, tp)
sc_proxy< X >::value_type xnor_reduce(const sc_proxy< X > &a)
#define SC_FXVAL_OBSERVER_DEFAULT_
const char SC_ID_OUT_OF_RANGE_[]
const sc_fxnum_subref range() const
const sc_fxval_fast operator+() const
sc_proxy< X >::value_type or_reduce(const sc_proxy< X > &a)
void cast(const scfx_params &, bool &, bool &)
sc_fxnum_fast_observer * observer() const
const std::string to_string() const
#define DEFN_CTOR_T_B(tp)
#define DEFN_BIN_OP_T(op, fnc, tp)
void scan(::std::istream &=::std::cin)
const friend sc_fxval operator/(const sc_fxnum &, const sc_fxnum &)
void print(::std::ostream &=::std::cout) const
#define DECL_ASN_OP_A(op)
bool get_slice(int, int, sc_bv_base &) const
const sc_fxnum_subref operator()() const
#define SC_FXNUM_OBSERVER_WRITE_(object)
const sc_fxval_fast operator-() const
static const uint64 UINT64_ONE
const char SC_ID_INVALID_FX_VALUE_[]
sc_proxy< X >::value_type nand_reduce(const sc_proxy< X > &a)
void scan(::std::istream &=::std::cin)
const std::string to_oct() const
void neg(sc_fxval &c, const sc_fxnum &a)
const friend sc_fxval_fast operator>>(const sc_fxnum_fast &, int)
#define DEFN_BIN_FNC(fnc)
#define SC_FXVAL_FAST_OBSERVER_WRITE_(object)
scfx_rep * neg_scfx_rep(const scfx_rep &)
const std::string to_string() const
unsigned int to_uint() const
sc_fxnum_fast & operator--()
void lshift(sc_fxval &c, const sc_fxnum &a, int b)
#define SC_FXNUM_OBSERVER_DESTRUCT_(object)
friend void rshift(sc_fxval &, const sc_fxnum &, int)
DECL_BIN_OP_T(/, int64) DECL_BIN_OP_T(/
const friend sc_fxval operator<<(const sc_fxnum &, int)
bool set_slice(int, int, const sc_bv_base &)
#define SC_FXNUM_OBSERVER_READ_(object)
bool set(int, const scfx_params &)
friend class sc_fxnum_bitref
bool set_slice(int, int, const scfx_params &, const sc_bv_base &)
#define DEFN_ASN_OP_T(tp)
unsigned int to_uint() const
#define SC_FXNUM_OBSERVER_DEFAULT_
const sc_fxnum_fast_bitref operator[](int) const
unsigned short to_ushort() const
const sc_fxtype_params & type_params() const
bool overflow_flag() const
#define DECL_ASN_OP_T(op, tp)
const std::string to_hex() const
sc_fxnum_observer * lock_observer() const
#define SC_FXNUM_FAST_OBSERVER_READ_(object)
sc_proxy< X >::value_type nor_reduce(const sc_proxy< X > &a)
void unlock_observer(sc_fxnum_fast_observer *) const
friend class sc_fxnum_fast_bitref
unsigned int to_uint() const
#define SC_FXVAL_OBSERVER_WRITE_(object)
void dump(::std::ostream &=::std::cout) const
friend void lshift(sc_fxval_fast &, const sc_fxnum_fast &, int)
const scfx_rep * get_rep() const
const T sc_min(const T &a, const T &b)
void scan(::std::istream &=::std::cin)
const sc_fxnum_fast_bitref bit(int) const
const std::string to_dec() const
friend class sc_fxnum_fast_bitref
void rshift(sc_fxval &c, const sc_fxnum &a, int b)
const sc_fxcast_switch & cast_switch() const
#define SC_FXNUM_FAST_OBSERVER_WRITE_(object)
void dump(::std::ostream &=::std::cout) const
void print(::std::ostream &=::std::cout) const
void print(::std::ostream &=::std::cout) const
sc_signed operator>>(const sc_signed &u, const sc_int_base &v)
const sc_fxnum_fast_subref range() const
const T sc_max(const T &a, const T &b)
sc_fxnum_fast & operator++()
void dump(::std::ostream &=::std::cout) const
const std::string to_dec() const
const sc_fxval_fast value() const
void dump(::std::ostream &=::std::cout) const
const sc_fxtype_params & type_params() const
const sc_fxtype_params & type_params() const
unsigned long to_ulong() const
const friend sc_fxval_fast operator/(const sc_fxnum_fast &, const sc_fxnum_fast &)
sc_proxy< X >::value_type and_reduce(const sc_proxy< X > &a)
X & operator^=(sc_proxy< X > &px, const sc_proxy< Y > &py)
#define DECL_BIN_FNC(fnc)
friend void neg(sc_fxval_fast &, const sc_fxnum_fast &)
friend void lshift(sc_fxval &, const sc_fxnum &, int)
friend class sc_fxnum_subref
const sc_fxnum_bitref bit(int) const
void unlock_observer(sc_fxnum_observer *) const
#define SC_FXNUM_FAST_OBSERVER_DEFAULT_
#define DEFN_BIN_OP(op, fnc)
scfx_rep * lsh_scfx_rep(const scfx_rep &, int)
unsigned int to_uint() const
#define SC_ERROR_IF_(cnd, id)
#define SC_FXVAL_OBSERVER_CONSTRUCT_(object)
bool quantization_flag() const
scfx_rep * rsh_scfx_rep(const scfx_rep &, int)
sc_fxnum_fast_observer * m_observer
void scan(::std::istream &=::std::cin)
bool overflow_flag() const
sc_fxval_fast(sc_fxval_fast_observer *=0)
const sc_fxcast_switch & cast_switch() const
bool quantization_flag() const
friend class sc_fxval_fast
void dump(::std::ostream &=::std::cout) const
const sc_fxcast_switch & cast_switch() const
bool get_slice(int, int, const scfx_params &, sc_bv_base &) const
const sc_fxnum_bitref operator[](int) const
const sc_fxval value() const
#define DEFN_RED_FNC(fnc)
friend void rshift(sc_fxval_fast &, const sc_fxnum_fast &, int)
Generated on Wed Sep 30 2020 14:02:15 for gem5 by doxygen 1.8.17