Go to the documentation of this file.
53 #ifndef __SYSTEMC_EXT_DT_FX_SC_FXVAL_HH__
54 #define __SYSTEMC_EXT_DT_FX_SC_FXVAL_HH__
58 #include "../int/sc_int_base.hh"
59 #include "../int/sc_signed.hh"
60 #include "../int/sc_uint_base.hh"
61 #include "../int/sc_unsigned.hh"
65 #define SCFX_EXPLICIT_ explicit
66 #define SCFX_EXPLICIT_OTHER_ explicit
131 #define DECL_BIN_OP_T(op,tp) \
132 friend const sc_fxval operator op (const sc_fxval &, tp); \
133 friend const sc_fxval operator op (tp, const sc_fxval &);
135 #define DECL_BIN_OP_OTHER(op) \
136 DECL_BIN_OP_T(op, int64) \
137 DECL_BIN_OP_T(op, uint64) \
138 DECL_BIN_OP_T(op, const sc_int_base &) \
139 DECL_BIN_OP_T(op, const sc_uint_base &) \
140 DECL_BIN_OP_T(op, const sc_signed &) \
141 DECL_BIN_OP_T(op, const sc_unsigned &)
143 #define DECL_BIN_OP(op, dummy) \
144 friend const sc_fxval operator op (const sc_fxval &, const sc_fxval &); \
145 DECL_BIN_OP_T(op, int) \
146 DECL_BIN_OP_T(op, unsigned int) \
147 DECL_BIN_OP_T(op, long) \
148 DECL_BIN_OP_T(op, unsigned long) \
149 DECL_BIN_OP_T(op, float) \
150 DECL_BIN_OP_T(op, double) \
151 DECL_BIN_OP_T(op, const char *) \
152 DECL_BIN_OP_T(op, const sc_fxval_fast &) \
153 DECL_BIN_OP_T(op, const sc_fxnum_fast &) \
154 DECL_BIN_OP_OTHER(op)
182 #undef DECL_BIN_OP_OTHER
189 #define DECL_BIN_FNC_T(fnc, tp) \
190 friend void fnc (sc_fxval &, const sc_fxval &, tp); \
191 friend void fnc (sc_fxval &, tp, const sc_fxval &);
193 #define DECL_BIN_FNC_OTHER(fnc) \
194 DECL_BIN_FNC_T(fnc, int64) \
195 DECL_BIN_FNC_T(fnc, uint64) \
196 DECL_BIN_FNC_T(fnc, const sc_int_base &) \
197 DECL_BIN_FNC_T(fnc, const sc_uint_base &) \
198 DECL_BIN_FNC_T(fnc, const sc_signed &) \
199 DECL_BIN_FNC_T(fnc, const sc_unsigned &)
201 #define DECL_BIN_FNC(fnc) \
202 friend void fnc (sc_fxval &, const sc_fxval &, const sc_fxval &); \
203 DECL_BIN_FNC_T(fnc, int) \
204 DECL_BIN_FNC_T(fnc, unsigned int) \
205 DECL_BIN_FNC_T(fnc, long) \
206 DECL_BIN_FNC_T(fnc, unsigned long) \
207 DECL_BIN_FNC_T(fnc, float) \
208 DECL_BIN_FNC_T(fnc, double) \
209 DECL_BIN_FNC_T(fnc, const char *) \
210 DECL_BIN_FNC_T(fnc, const sc_fxval_fast &) \
211 DECL_BIN_FNC_T(fnc, const sc_fxnum_fast &) \
212 DECL_BIN_FNC_OTHER(fnc)
219 #undef DECL_BIN_FNC_T
220 #undef DECL_BIN_FNC_OTHER
227 #define DECL_REL_OP_T(op, tp) \
228 friend bool operator op (const sc_fxval &, tp); \
229 friend bool operator op (tp, const sc_fxval &);
231 #define DECL_REL_OP_OTHER(op) \
232 DECL_REL_OP_T(op, int64) \
233 DECL_REL_OP_T(op, uint64) \
234 DECL_REL_OP_T(op, const sc_int_base &) \
235 DECL_REL_OP_T(op, const sc_uint_base &) \
236 DECL_REL_OP_T(op, const sc_signed &) \
237 DECL_REL_OP_T(op, const sc_unsigned &)
239 #define DECL_REL_OP(op) \
240 friend bool operator op (const sc_fxval &, const sc_fxval &); \
241 DECL_REL_OP_T(op, int) \
242 DECL_REL_OP_T(op, unsigned int) \
243 DECL_REL_OP_T(op, long) \
244 DECL_REL_OP_T(op, unsigned long) \
245 DECL_REL_OP_T(op, float) \
246 DECL_REL_OP_T(op, double) \
247 DECL_REL_OP_T(op, const char *) \
248 DECL_REL_OP_T(op, const sc_fxval_fast &) \
249 DECL_REL_OP_T(op, const sc_fxnum_fast &) \
250 DECL_REL_OP_OTHER(op)
260 #undef DECL_REL_OP_OTHER
264 #define DECL_ASN_OP_T(op, tp) sc_fxval &operator op(tp);
266 #define DECL_ASN_OP_OTHER(op) \
267 DECL_ASN_OP_T(op, int64) \
268 DECL_ASN_OP_T(op, uint64) \
269 DECL_ASN_OP_T(op, const sc_int_base &) \
270 DECL_ASN_OP_T(op, const sc_uint_base &) \
271 DECL_ASN_OP_T(op, const sc_signed &) \
272 DECL_ASN_OP_T(op, const sc_unsigned &)
274 #define DECL_ASN_OP(op) \
275 DECL_ASN_OP_T(op, int) \
276 DECL_ASN_OP_T(op, unsigned int) \
277 DECL_ASN_OP_T(op, long) \
278 DECL_ASN_OP_T(op, unsigned long) \
279 DECL_ASN_OP_T(op, float) \
280 DECL_ASN_OP_T(op, double) \
281 DECL_ASN_OP_T(op, const char *) \
282 DECL_ASN_OP_T(op, const sc_fxval &) \
283 DECL_ASN_OP_T(op, const sc_fxval_fast &) \
284 DECL_ASN_OP_T(op, const sc_fxnum &) \
285 DECL_ASN_OP_T(op, const sc_fxnum_fast &) \
286 DECL_ASN_OP_OTHER(op)
299 #undef DECL_ASN_OP_OTHER
310 operator double()
const;
332 const std::string
to_dec()
const;
333 const std::string
to_bin()
const;
334 const std::string
to_oct()
const;
335 const std::string
to_hex()
const;
347 void print(::std::ostream & =::std::cout)
const;
348 void scan(::std::istream & =::std::cin);
349 void dump(::std::ostream & =::std::cout)
const;
418 #define DECL_BIN_OP_T(op, tp) \
419 friend const sc_fxval_fast operator op (const sc_fxval_fast &, tp); \
420 friend const sc_fxval_fast operator op (tp, const sc_fxval_fast &);
422 #define DECL_BIN_OP_OTHER(op) \
423 DECL_BIN_OP_T(op, int64) \
424 DECL_BIN_OP_T(op, uint64) \
425 DECL_BIN_OP_T(op, const sc_int_base &) \
426 DECL_BIN_OP_T(op, const sc_uint_base &) \
427 DECL_BIN_OP_T(op, const sc_signed &) \
428 DECL_BIN_OP_T(op, const sc_unsigned &)
430 #define DECL_BIN_OP(op, dummy) \
431 friend const sc_fxval_fast operator op (const sc_fxval_fast &, \
432 const sc_fxval_fast &); \
433 DECL_BIN_OP_T(op, int) \
434 DECL_BIN_OP_T(op, unsigned int) \
435 DECL_BIN_OP_T(op, long) \
436 DECL_BIN_OP_T(op, unsigned long) \
437 DECL_BIN_OP_T(op, float) \
438 DECL_BIN_OP_T(op, double) \
439 DECL_BIN_OP_T(op, const char *) \
440 DECL_BIN_OP_OTHER(op)
459 DECL_BIN_OP_T(/,
uint64) \
460 DECL_BIN_OP_T(/,
const sc_int_base &) \
461 DECL_BIN_OP_T(/,
const sc_uint_base &) \
462 DECL_BIN_OP_T(/,
const sc_signed &) \
463 DECL_BIN_OP_T(/,
const sc_unsigned &)
466 #undef DECL_BIN_OP_OTHER
473 #define DECL_BIN_FNC_T(fnc, tp) \
474 friend void fnc (sc_fxval_fast &, const sc_fxval_fast &, tp); \
475 friend void fnc (sc_fxval_fast &, tp, const sc_fxval_fast &);
477 #define DECL_BIN_FNC_OTHER(fnc) \
478 DECL_BIN_FNC_T(fnc, int64) \
479 DECL_BIN_FNC_T(fnc, uint64) \
480 DECL_BIN_FNC_T(fnc, const sc_int_base &) \
481 DECL_BIN_FNC_T(fnc, const sc_uint_base &) \
482 DECL_BIN_FNC_T(fnc, const sc_signed &) \
483 DECL_BIN_FNC_T(fnc, const sc_unsigned &)
485 #define DECL_BIN_FNC(fnc) \
486 friend void fnc (sc_fxval_fast &, const sc_fxval_fast &, \
487 const sc_fxval_fast &); \
488 DECL_BIN_FNC_T(fnc, int) \
489 DECL_BIN_FNC_T(fnc, unsigned int) \
490 DECL_BIN_FNC_T(fnc, long) \
491 DECL_BIN_FNC_T(fnc, unsigned long) \
492 DECL_BIN_FNC_T(fnc, float) \
493 DECL_BIN_FNC_T(fnc, double) \
494 DECL_BIN_FNC_T(fnc, const char *) \
495 DECL_BIN_FNC_T(fnc, const sc_fxval &) \
496 DECL_BIN_FNC_T(fnc, const sc_fxnum &) \
497 DECL_BIN_FNC_OTHER(fnc)
504 #undef DECL_BIN_FNC_T
505 #undef DECL_BIN_FNC_OTHER
512 #define DECL_REL_OP_T(op, tp) \
513 friend bool operator op (const sc_fxval_fast &, tp); \
514 friend bool operator op (tp, const sc_fxval_fast &);
516 #define DECL_REL_OP_OTHER(op) \
517 DECL_REL_OP_T(op, int64) \
518 DECL_REL_OP_T(op, uint64) \
519 DECL_REL_OP_T(op, const sc_int_base &) \
520 DECL_REL_OP_T(op, const sc_uint_base &) \
521 DECL_REL_OP_T(op, const sc_signed &) \
522 DECL_REL_OP_T(op, const sc_unsigned &)
524 #define DECL_REL_OP(op) \
525 friend bool operator op (const sc_fxval_fast &, const sc_fxval_fast &); \
526 DECL_REL_OP_T(op, int) \
527 DECL_REL_OP_T(op, unsigned int) \
528 DECL_REL_OP_T(op, long) \
529 DECL_REL_OP_T(op, unsigned long) \
530 DECL_REL_OP_T(op, float) \
531 DECL_REL_OP_T(op, double) \
532 DECL_REL_OP_T(op, const char *) \
533 DECL_REL_OP_OTHER(op)
543 #undef DECL_REL_OP_OTHER
547 #define DECL_ASN_OP_T(op, tp) sc_fxval_fast &operator op(tp);
549 #define DECL_ASN_OP_OTHER(op) \
550 DECL_ASN_OP_T(op, int64) \
551 DECL_ASN_OP_T(op, uint64) \
552 DECL_ASN_OP_T(op, const sc_int_base &) \
553 DECL_ASN_OP_T(op, const sc_uint_base &) \
554 DECL_ASN_OP_T(op, const sc_signed &) \
555 DECL_ASN_OP_T(op, const sc_unsigned &)
557 #define DECL_ASN_OP(op) \
558 DECL_ASN_OP_T(op, int) \
559 DECL_ASN_OP_T(op, unsigned int) \
560 DECL_ASN_OP_T(op, long) \
561 DECL_ASN_OP_T(op, unsigned long) \
562 DECL_ASN_OP_T(op, float) \
563 DECL_ASN_OP_T(op, double) \
564 DECL_ASN_OP_T(op, const char *) \
565 DECL_ASN_OP_T(op, const sc_fxval &) \
566 DECL_ASN_OP_T(op, const sc_fxval_fast &) \
567 DECL_ASN_OP_T(op, const sc_fxnum &) \
568 DECL_ASN_OP_T(op, const sc_fxnum_fast &) \
569 DECL_ASN_OP_OTHER(op)
582 #undef DECL_ASN_OP_OTHER
593 operator double()
const;
615 const std::string
to_dec()
const;
616 const std::string
to_bin()
const;
617 const std::string
to_oct()
const;
618 const std::string
to_hex()
const;
630 void print(::std::ostream & =::std::cout)
const;
631 void scan(::std::istream & =::std::cin);
632 void dump(::std::ostream & =::std::cout)
const;
663 m_rep(
a != 0 ?
a : new
scfx_rep), m_observer(0)
670 m_rep(new
scfx_rep), m_observer(observer_)
677 m_rep(new
scfx_rep(*
a.m_rep)), m_observer(observer_)
685 #define DEFN_CTOR_T(tp, arg) \
686 inline sc_fxval::sc_fxval(tp a, sc_fxval_observer *observer_) : \
687 m_rep(new scfx_rep(arg)), m_observer(observer_) \
689 SC_FXVAL_OBSERVER_DEFAULT_ \
690 SC_FXVAL_OBSERVER_CONSTRUCT_(*this) \
691 SC_FXVAL_OBSERVER_WRITE_(*this) \
694 #define DEFN_CTOR_T_A(tp) DEFN_CTOR_T(tp, a)
695 #define DEFN_CTOR_T_B(tp) DEFN_CTOR_T(tp, a.to_double())
696 #define DEFN_CTOR_T_C(tp) DEFN_CTOR_T(tp, a.value())
768 #define DEFN_BIN_OP_T(op, fnc, tp) \
769 inline const sc_fxval \
770 operator op (const sc_fxval &a, tp b) \
772 SC_FXVAL_OBSERVER_READ_(a) \
774 return sc_fxval(sc_dt::fnc ## _scfx_rep(*a.m_rep, *tmp.m_rep)); \
779 operator op (tp a, const sc_fxval &b) \
781 SC_FXVAL_OBSERVER_READ_(b) \
783 return sc_fxval(sc_dt::fnc ## _scfx_rep(*tmp.m_rep, *b.m_rep)); \
786 #define DEFN_BIN_OP_OTHER(op, fnc) \
787 DEFN_BIN_OP_T(op, fnc, int64) \
788 DEFN_BIN_OP_T(op, fnc, uint64) \
789 DEFN_BIN_OP_T(op, fnc, const sc_int_base &) \
790 DEFN_BIN_OP_T(op, fnc, const sc_uint_base &) \
791 DEFN_BIN_OP_T(op, fnc, const sc_signed &) \
792 DEFN_BIN_OP_T(op, fnc, const sc_unsigned &)
794 #define DEFN_BIN_OP(op, fnc) \
795 inline const sc_fxval \
796 operator op (const sc_fxval &a, const sc_fxval &b) \
798 SC_FXVAL_OBSERVER_READ_(a) \
799 SC_FXVAL_OBSERVER_READ_(b) \
800 return sc_fxval(sc_dt::fnc ## _scfx_rep( *a.m_rep, *b.m_rep)); \
803 DEFN_BIN_OP_T(op, fnc, int) \
804 DEFN_BIN_OP_T(op, fnc, unsigned int) \
805 DEFN_BIN_OP_T(op, fnc, long) \
806 DEFN_BIN_OP_T(op, fnc, unsigned long) \
807 DEFN_BIN_OP_T(op, fnc, float) \
808 DEFN_BIN_OP_T(op, fnc, double) \
809 DEFN_BIN_OP_T(op, fnc, const char *) \
810 DEFN_BIN_OP_T(op, fnc, const sc_fxval_fast &) \
811 DEFN_BIN_OP_OTHER(op, fnc)
844 #undef DEFN_BIN_OP_OTHER
862 #define DEFN_BIN_FNC_T(fnc, tp) \
864 fnc (sc_fxval &c, const sc_fxval &a, tp b) \
866 SC_FXVAL_OBSERVER_READ_(a) \
869 c.m_rep = sc_dt::fnc ## _scfx_rep(*a.m_rep, *tmp.m_rep); \
870 SC_FXVAL_OBSERVER_WRITE_(c) \
874 fnc (sc_fxval &c, tp a, const sc_fxval &b) \
876 SC_FXVAL_OBSERVER_READ_(b) \
879 c.m_rep = sc_dt::fnc ## _scfx_rep(*tmp.m_rep, *b.m_rep); \
880 SC_FXVAL_OBSERVER_WRITE_(c) \
883 #define DEFN_BIN_FNC_OTHER(fnc) \
884 DEFN_BIN_FNC_T(fnc, int64) \
885 DEFN_BIN_FNC_T(fnc, uint64) \
886 DEFN_BIN_FNC_T(fnc, const sc_int_base &) \
887 DEFN_BIN_FNC_T(fnc, const sc_uint_base &) \
888 DEFN_BIN_FNC_T(fnc, const sc_signed &) \
889 DEFN_BIN_FNC_T(fnc, const sc_unsigned &)
891 #define DEFN_BIN_FNC(fnc) \
893 fnc(sc_fxval &c, const sc_fxval &a, const sc_fxval &b) \
895 SC_FXVAL_OBSERVER_READ_(a) \
896 SC_FXVAL_OBSERVER_READ_(b) \
898 c.m_rep = sc_dt::fnc ## _scfx_rep(*a.m_rep, *b.m_rep); \
899 SC_FXVAL_OBSERVER_WRITE_(c) \
902 DEFN_BIN_FNC_T(fnc, int) \
903 DEFN_BIN_FNC_T(fnc, unsigned int) \
904 DEFN_BIN_FNC_T(fnc, long) \
905 DEFN_BIN_FNC_T(fnc, unsigned long) \
906 DEFN_BIN_FNC_T(fnc, float) \
907 DEFN_BIN_FNC_T(fnc, double) \
908 DEFN_BIN_FNC_T(fnc, const char *) \
909 DEFN_BIN_FNC_T(fnc, const sc_fxval_fast &) \
910 DEFN_BIN_FNC_OTHER(fnc)
917 #undef DEFN_BIN_FNC_T
918 #undef DEFN_BIN_FNC_OTHER
940 #define DEFN_REL_OP_T(op, ret, tp) \
942 operator op (const sc_fxval &a, tp b) \
944 SC_FXVAL_OBSERVER_READ_(a) \
946 int result = sc_dt::cmp_scfx_rep(*a.m_rep, *tmp.m_rep); \
951 operator op (tp a, const sc_fxval &b) \
953 SC_FXVAL_OBSERVER_READ_(b) \
955 int result = sc_dt::cmp_scfx_rep(*tmp.m_rep, *b.m_rep); \
959 #define DEFN_REL_OP_OTHER(op, ret) \
960 DEFN_REL_OP_T(op, ret, int64) \
961 DEFN_REL_OP_T(op, ret, uint64) \
962 DEFN_REL_OP_T(op, ret, const sc_int_base &) \
963 DEFN_REL_OP_T(op, ret, const sc_uint_base &) \
964 DEFN_REL_OP_T(op, ret, const sc_signed &) \
965 DEFN_REL_OP_T(op, ret, const sc_unsigned &)
967 #define DEFN_REL_OP(op, ret) \
969 operator op (const sc_fxval &a, const sc_fxval &b) \
971 SC_FXVAL_OBSERVER_READ_(a) \
972 SC_FXVAL_OBSERVER_READ_(b) \
973 int result = sc_dt::cmp_scfx_rep(*a.m_rep, *b.m_rep); \
977 DEFN_REL_OP_T(op, ret, int) \
978 DEFN_REL_OP_T(op, ret, unsigned int) \
979 DEFN_REL_OP_T(op, ret, long) \
980 DEFN_REL_OP_T(op, ret, unsigned long) \
981 DEFN_REL_OP_T(op, ret, float) \
982 DEFN_REL_OP_T(op, ret, double) \
983 DEFN_REL_OP_T(op, ret, const char *) \
984 DEFN_REL_OP_T(op, ret, const sc_fxval_fast &) \
985 DEFN_REL_OP_OTHER(op, ret)
995 #undef DEFN_REL_OP_OTHER
1000 sc_fxval::operator = (
const sc_fxval &
a)
1010 #define DEFN_ASN_OP_T(tp) \
1012 sc_fxval::operator = (tp b) \
1015 *m_rep = *tmp.m_rep; \
1016 SC_FXVAL_OBSERVER_WRITE_(*this) \
1036 #undef DEFN_ASN_OP_T
1038 #define DEFN_ASN_OP_T(op, fnc, tp) \
1040 sc_fxval::operator op (tp b) \
1042 SC_FXVAL_OBSERVER_READ_(*this) \
1044 scfx_rep *new_rep = sc_dt::fnc ## _scfx_rep(*m_rep, *tmp.m_rep); \
1047 SC_FXVAL_OBSERVER_WRITE_(*this) \
1051 #define DEFN_ASN_OP_OTHER(op, fnc) \
1052 DEFN_ASN_OP_T(op, fnc, int64) \
1053 DEFN_ASN_OP_T(op, fnc, uint64) \
1054 DEFN_ASN_OP_T(op, fnc, const sc_int_base &) \
1055 DEFN_ASN_OP_T(op, fnc, const sc_uint_base &) \
1056 DEFN_ASN_OP_T(op, fnc, const sc_signed &) \
1057 DEFN_ASN_OP_T(op, fnc, const sc_unsigned &)
1059 #define DEFN_ASN_OP(op, fnc) \
1061 sc_fxval::operator op (const sc_fxval &b) \
1063 SC_FXVAL_OBSERVER_READ_(*this) \
1064 SC_FXVAL_OBSERVER_READ_(b) \
1065 scfx_rep *new_rep = sc_dt::fnc ## _scfx_rep(*m_rep, *b.m_rep); \
1068 SC_FXVAL_OBSERVER_WRITE_(*this) \
1072 DEFN_ASN_OP_T(op, fnc, int) \
1073 DEFN_ASN_OP_T(op, fnc, unsigned int) \
1074 DEFN_ASN_OP_T(op, fnc, long) \
1075 DEFN_ASN_OP_T(op, fnc, unsigned long) \
1076 DEFN_ASN_OP_T(op, fnc, float) \
1077 DEFN_ASN_OP_T(op, fnc, double) \
1078 DEFN_ASN_OP_T(op, fnc, const char *) \
1079 DEFN_ASN_OP_T(op, fnc, const sc_fxval_fast &) \
1080 DEFN_ASN_OP_OTHER(op, fnc)
1087 #undef DEFN_ASN_OP_T
1088 #undef DEFN_ASN_OP_OTHER
1092 sc_fxval::operator <<= (
int b)
1141 inline sc_fxval::operator double()
const
1155 inline unsigned short
1197 inline unsigned long
1286 inline ::std::ostream &
1293 inline ::std::istream &
1308 inline sc_fxval_fast_observer *
1325 m_val(
a.m_val), m_observer(observer_)
1333 #define DEFN_CTOR_T(tp, arg) \
1334 inline sc_fxval_fast::sc_fxval_fast( \
1335 tp a, sc_fxval_fast_observer * observer_) : \
1336 m_val(arg), m_observer(observer_) \
1338 SC_FXVAL_FAST_OBSERVER_DEFAULT_ \
1339 SC_FXVAL_FAST_OBSERVER_CONSTRUCT_(*this) \
1340 SC_FXVAL_FAST_OBSERVER_WRITE_(*this) \
1343 #define DEFN_CTOR_T_A(tp) DEFN_CTOR_T(tp, static_cast<double>(a))
1344 #define DEFN_CTOR_T_B(tp) DEFN_CTOR_T(tp, from_string(a))
1345 #define DEFN_CTOR_T_C(tp) DEFN_CTOR_T(tp, a.to_double())
1364 #undef DEFN_CTOR_T_A
1365 #undef DEFN_CTOR_T_B
1366 #undef DEFN_CTOR_T_C
1367 #undef DEFN_CTOR_T_D
1368 #undef DEFN_CTOR_T_E
1411 c.m_val = -
a.m_val;
1416 #define DEFN_BIN_OP_T(op, tp) \
1417 inline const sc_fxval_fast \
1418 operator op (const sc_fxval_fast &a, tp b) \
1420 SC_FXVAL_FAST_OBSERVER_READ_(a) \
1421 sc_fxval_fast tmp(b); \
1422 return sc_fxval_fast(a.m_val op tmp.m_val); \
1425 inline const sc_fxval_fast \
1426 operator op (tp a, const sc_fxval_fast &b) \
1428 SC_FXVAL_FAST_OBSERVER_READ_(b) \
1429 sc_fxval_fast tmp(a); \
1430 return sc_fxval_fast(tmp.m_val op b.m_val); \
1433 #define DEFN_BIN_OP_OTHER(op) \
1434 DEFN_BIN_OP_T(op, int64) \
1435 DEFN_BIN_OP_T(op, uint64) \
1436 DEFN_BIN_OP_T(op, const sc_int_base &) \
1437 DEFN_BIN_OP_T(op, const sc_uint_base &) \
1438 DEFN_BIN_OP_T(op, const sc_signed &) \
1439 DEFN_BIN_OP_T(op, const sc_unsigned &)
1441 #define DEFN_BIN_OP(op, dummy) \
1442 inline const sc_fxval_fast \
1443 operator op (const sc_fxval_fast &a, const sc_fxval_fast &b) \
1445 SC_FXVAL_FAST_OBSERVER_READ_(a) \
1446 SC_FXVAL_FAST_OBSERVER_READ_(b) \
1447 return sc_fxval_fast(a.m_val op b.m_val); \
1450 DEFN_BIN_OP_T(op, int) \
1451 DEFN_BIN_OP_T(op, unsigned int) \
1452 DEFN_BIN_OP_T(op, long) \
1453 DEFN_BIN_OP_T(op, unsigned long) \
1454 DEFN_BIN_OP_T(op, float) \
1455 DEFN_BIN_OP_T(op, double) \
1456 DEFN_BIN_OP_T(op, const char *) \
1457 DEFN_BIN_OP_OTHER(op)
1463 inline const sc_fxval_fast
1488 #undef DEFN_BIN_OP_T
1489 #undef DEFN_BIN_OP_OTHER
1493 inline const sc_fxval_fast
1500 inline const sc_fxval_fast
1508 #define DEFN_BIN_FNC_T(fnc, op, tp) \
1510 fnc (sc_fxval_fast &c, const sc_fxval_fast &a, tp b) \
1512 SC_FXVAL_FAST_OBSERVER_READ_(a) \
1513 sc_fxval_fast tmp(b); \
1514 c.m_val = a.m_val op tmp.m_val; \
1515 SC_FXVAL_FAST_OBSERVER_WRITE_(c) \
1519 fnc (sc_fxval_fast &c, tp a, const sc_fxval_fast &b) \
1521 SC_FXVAL_FAST_OBSERVER_READ_(b) \
1522 sc_fxval_fast tmp(a); \
1523 c.m_val = tmp.m_val op b.m_val; \
1524 SC_FXVAL_FAST_OBSERVER_WRITE_(c) \
1527 #define DEFN_BIN_FNC_OTHER(fnc, op) \
1528 DEFN_BIN_FNC_T(fnc, op, int64) \
1529 DEFN_BIN_FNC_T(fnc, op, uint64) \
1530 DEFN_BIN_FNC_T(fnc, op, const sc_int_base &) \
1531 DEFN_BIN_FNC_T(fnc, op, const sc_uint_base &) \
1532 DEFN_BIN_FNC_T(fnc, op, const sc_signed &) \
1533 DEFN_BIN_FNC_T(fnc, op, const sc_unsigned &)
1535 #define DEFN_BIN_FNC(fnc, op) \
1537 fnc (sc_fxval_fast &c, const sc_fxval_fast &a, const sc_fxval_fast &b) \
1539 SC_FXVAL_FAST_OBSERVER_READ_(a) \
1540 SC_FXVAL_FAST_OBSERVER_READ_(b) \
1541 c.m_val = a.m_val op b.m_val; \
1542 SC_FXVAL_FAST_OBSERVER_WRITE_(c) \
1545 DEFN_BIN_FNC_T(fnc, op, int) \
1546 DEFN_BIN_FNC_T(fnc, op, unsigned int) \
1547 DEFN_BIN_FNC_T(fnc, op, long) \
1548 DEFN_BIN_FNC_T(fnc, op, unsigned long) \
1549 DEFN_BIN_FNC_T(fnc, op, float) \
1550 DEFN_BIN_FNC_T(fnc, op, double) \
1551 DEFN_BIN_FNC_T(fnc, op, const char *) \
1552 DEFN_BIN_FNC_OTHER(fnc, op)
1559 #undef DEFN_BIN_FNC_T
1560 #undef DEFN_BIN_FNC_OTHER
1580 #define DEFN_REL_OP_T(op, tp) \
1582 operator op (const sc_fxval_fast &a, tp b) \
1584 SC_FXVAL_FAST_OBSERVER_READ_(a) \
1585 sc_fxval_fast tmp(b); \
1586 return (a.m_val op tmp.m_val); \
1590 operator op (tp a, const sc_fxval_fast &b) \
1592 SC_FXVAL_FAST_OBSERVER_READ_(b) \
1593 sc_fxval_fast tmp(a); \
1594 return (tmp.m_val op b.m_val); \
1597 #define DEFN_REL_OP_OTHER(op) \
1598 DEFN_REL_OP_T(op, int64) \
1599 DEFN_REL_OP_T(op, uint64) \
1600 DEFN_REL_OP_T(op, const sc_int_base &) \
1601 DEFN_REL_OP_T(op, const sc_uint_base &) \
1602 DEFN_REL_OP_T(op, const sc_signed &) \
1603 DEFN_REL_OP_T(op, const sc_unsigned &)
1605 #define DEFN_REL_OP(op) \
1607 operator op (const sc_fxval_fast &a, const sc_fxval_fast &b) \
1609 SC_FXVAL_FAST_OBSERVER_READ_(a) \
1610 SC_FXVAL_FAST_OBSERVER_READ_(b) \
1611 return (a.m_val op b.m_val); \
1614 DEFN_REL_OP_T(op, int) \
1615 DEFN_REL_OP_T(op, unsigned int) \
1616 DEFN_REL_OP_T(op, long) \
1617 DEFN_REL_OP_T(op, unsigned long) \
1618 DEFN_REL_OP_T(op, float) \
1619 DEFN_REL_OP_T(op, double) \
1620 DEFN_REL_OP_T(op, const char *) \
1621 DEFN_REL_OP_OTHER(op)
1630 #undef DEFN_REL_OP_T
1631 #undef DEFN_REL_OP_OTHER
1635 inline sc_fxval_fast &
1636 sc_fxval_fast::operator = (
const sc_fxval_fast &
a)
1646 #define DEFN_ASN_OP_T(tp) \
1647 inline sc_fxval_fast & \
1648 sc_fxval_fast::operator = (tp a) \
1650 sc_fxval_fast tmp(a); \
1651 m_val = tmp.m_val; \
1652 SC_FXVAL_FAST_OBSERVER_WRITE_(*this) \
1672 #undef DEFN_ASN_OP_T
1674 #define DEFN_ASN_OP_T(op, tp) \
1675 inline sc_fxval_fast & \
1676 sc_fxval_fast::operator op (tp b) \
1678 SC_FXVAL_FAST_OBSERVER_READ_(*this) \
1679 sc_fxval_fast tmp(b); \
1680 m_val op tmp.m_val; \
1681 SC_FXVAL_FAST_OBSERVER_WRITE_(*this) \
1685 #define DEFN_ASN_OP_OTHER(op) \
1686 DEFN_ASN_OP_T(op, int64) \
1687 DEFN_ASN_OP_T(op, uint64) \
1688 DEFN_ASN_OP_T(op, const sc_int_base &) \
1689 DEFN_ASN_OP_T(op, const sc_uint_base &) \
1690 DEFN_ASN_OP_T(op, const sc_signed &) \
1691 DEFN_ASN_OP_T(op, const sc_unsigned &)
1693 #define DEFN_ASN_OP(op) \
1694 inline sc_fxval_fast & \
1695 sc_fxval_fast::operator op (const sc_fxval_fast &b) \
1697 SC_FXVAL_FAST_OBSERVER_READ_(*this) \
1698 SC_FXVAL_FAST_OBSERVER_READ_(b) \
1700 SC_FXVAL_FAST_OBSERVER_WRITE_(*this) \
1704 DEFN_ASN_OP_T(op, int) \
1705 DEFN_ASN_OP_T(op, unsigned int) \
1706 DEFN_ASN_OP_T(op, long) \
1707 DEFN_ASN_OP_T(op, unsigned long) \
1708 DEFN_ASN_OP_T(op, float) \
1709 DEFN_ASN_OP_T(op, double) \
1710 DEFN_ASN_OP_T(op, const char *) \
1711 DEFN_ASN_OP_T(op, const sc_fxval &) \
1712 DEFN_ASN_OP_OTHER(op)
1719 #undef DEFN_ASN_OP_T
1720 #undef DEFN_ASN_OP_OTHER
1723 inline sc_fxval_fast &
1724 sc_fxval_fast::operator <<= (
int b)
1732 inline sc_fxval_fast &
1733 sc_fxval_fast::operator >>= (
int b)
1783 inline sc_fxval_fast::operator double()
const
1797 inline unsigned short
1801 return static_cast<unsigned short>(
to_uint64());
1822 return static_cast<unsigned int>(
to_uint64());
1834 double mantissa_dbl = frexp(
m_val, &exponent);
1840 if (!(-64 < exponent && exponent < 64)) {
1844 mantissa = exponent >= 0 ? mantissa << exponent : mantissa >> -exponent;
1845 return mantissa_dbl >= 0 ? mantissa : -mantissa;
1855 inline unsigned long
1859 return static_cast<unsigned long>(
to_uint64());
1866 return static_cast<float>(
m_val);
1882 return (
id.negative() != 0);
1890 return id.is_zero();
1924 inline ::std::ostream &
1931 inline ::std::istream &
1940 #undef SCFX_EXPLICIT_
1941 #undef SCFX_EXPLICIT_OTHER_
1943 #endif // __SYSTEMC_EXT_DT_FX_SC_FXVAL_HH__
unsigned int to_uint() const
const friend sc_fxval_fast operator/(const sc_fxval_fast &, const sc_fxval_fast &)
const friend sc_fxval operator/(const sc_fxval &, const sc_fxval &)
static double from_string(const char *)
sc_fxval_fast & operator--()
void dump(::std::ostream &=::std::cout) const
bool rounding_flag() const
const std::string to_oct() const
#define SC_FXVAL_FAST_OBSERVER_CONSTRUCT_(object)
scfx_rep * div_scfx_rep(const scfx_rep &lhs, const scfx_rep &rhs, int div_wl)
void unlock_observer(sc_fxval_observer *) const
const sc_fxval_fast & operator+() const
#define SC_FXVAL_FAST_OBSERVER_DEFAULT_
friend void rshift(sc_fxval &, const sc_fxval &, int)
sc_fxval_fast_observer * observer() const
sc_signed operator<<(const sc_signed &u, const sc_int_base &v)
#define SC_FXVAL_FAST_OBSERVER_DESTRUCT_(object)
const sc_fxval operator-() const
#define DEFN_CTOR_T_A(tp)
#define SC_FXVAL_FAST_OBSERVER_READ_(object)
sc_fxval_fast & operator++()
unsigned short to_ushort() const
const friend sc_fxval operator>>(const sc_fxval &, int)
sc_signed operator/(const sc_unsigned &u, const sc_int_base &v)
const sc_fxval overflow(const scfx_params &, bool &) const
double scfx_pow2(int exp)
unsigned short to_ushort() const
#define DEFN_BIN_FNC(fnc)
const std::string to_string() const
const std::string to_oct() const
#define DEFN_BIN_OP(op, fnc)
void scan(::std::istream &=::std::cin)
const sc_fxval quantization(const scfx_params &, bool &) const
friend void neg(sc_fxval &, const sc_fxval &)
#define SC_FXVAL_OBSERVER_DEFAULT_
scfx_rep * quantization_scfx_rep(const scfx_rep &a, const scfx_params ¶ms, bool &q_flag)
const friend sc_fxval_fast operator>>(const sc_fxval_fast &, int)
const std::string to_dec() const
const std::string to_dec() const
#define SC_FXVAL_OBSERVER_DESTRUCT_(object)
const sc_fxval_fast operator-() const
#define DEFN_BIN_OP_T(op, fnc, tp)
const std::string to_hex() const
static const uint64 UINT64_ONE
#define DECL_BIN_OP(op, dummy)
const std::string to_hex() const
const scfx_rep * get_rep() const
void neg(sc_fxval &c, const sc_fxnum &a)
#define SC_FXVAL_FAST_OBSERVER_WRITE_(object)
scfx_rep * neg_scfx_rep(const scfx_rep &)
void lshift(sc_fxval &c, const sc_fxnum &a, int b)
void get_type(int &, int &, sc_enc &) const
sc_fxval_fast_observer * lock_observer() const
unsigned long to_ulong() const
#define DECL_BIN_FNC(fnc)
bool rounding_flag() const
#define DEFN_ASN_OP_T(tp)
unsigned int to_uint() const
#define DEFN_CTOR_T_B(tp)
friend void lshift(sc_fxval &, const sc_fxval &, int)
sc_fxval_observer * m_observer
const std::string to_bin() const
#define SC_FXVAL_OBSERVER_WRITE_(object)
DECL_BIN_OP_T(/, int64) DECL_BIN_OP_T(/
void print(::std::ostream &=::std::cout) const
#define SC_FXVAL_OBSERVER_READ_(object)
unsigned long to_ulong() const
void rshift(sc_fxval &c, const sc_fxnum &a, int b)
friend void rshift(sc_fxval_fast &, const sc_fxval_fast &, int)
void print(::std::ostream &=::std::cout) const
sc_fxval_observer * lock_observer() const
sc_signed operator>>(const sc_signed &u, const sc_int_base &v)
const std::string to_bin() const
const sc_fxval & operator+() const
void unlock_observer(sc_fxval_fast_observer *) const
sc_fxval_observer * observer() const
#define DECL_ASN_OP_T(op, tp)
const friend sc_fxval operator<<(const sc_fxval &, int)
#define DEFN_ASN_OP(op, fnc)
sc_fxval_fast_observer * m_observer
const std::string to_string() const
#define DEFN_CTOR_T_C(tp)
void dump(::std::ostream &=::std::cout) const
scfx_rep * lsh_scfx_rep(const scfx_rep &, int)
scfx_rep * overflow_scfx_rep(const scfx_rep &a, const scfx_params ¶ms, bool &o_flag)
friend void lshift(sc_fxval_fast &, const sc_fxval_fast &, int)
void scan(::std::istream &=::std::cin)
#define DEFN_REL_OP(op, ret)
bool rounding_flag() const
#define SC_FXVAL_OBSERVER_CONSTRUCT_(object)
#define DECL_BIN_OP_T(op, tp)
scfx_rep * rsh_scfx_rep(const scfx_rep &, int)
friend void neg(sc_fxval_fast &, const sc_fxval_fast &)
void get_type(int &, int &, sc_enc &) const
sc_fxval_fast(sc_fxval_fast_observer *=0)
Generated on Wed Sep 30 2020 14:02:15 for gem5 by doxygen 1.8.17