53#ifndef __SYSTEMC_EXT_DT_FX_SC_FXVAL_HH__
54#define __SYSTEMC_EXT_DT_FX_SC_FXVAL_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)
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;
326 const std::string
to_string(sc_numrep)
const;
327 const std::string
to_string(sc_numrep,
bool)
const;
328 const std::string
to_string(sc_fmt)
const;
329 const std::string
to_string(sc_numrep, sc_fmt)
const;
330 const std::string
to_string(sc_numrep,
bool, sc_fmt)
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)
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)
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) \
686inline 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) \
769inline const sc_fxval \
770operator 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)); \
779operator 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) \
787DEFN_BIN_OP_T(op, fnc, int64) \
788DEFN_BIN_OP_T(op, fnc, uint64) \
789DEFN_BIN_OP_T(op, fnc, const sc_int_base &) \
790DEFN_BIN_OP_T(op, fnc, const sc_uint_base &) \
791DEFN_BIN_OP_T(op, fnc, const sc_signed &) \
792DEFN_BIN_OP_T(op, fnc, const sc_unsigned &)
794#define DEFN_BIN_OP(op, fnc) \
795inline const sc_fxval \
796operator 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)); \
803DEFN_BIN_OP_T(op, fnc, int) \
804DEFN_BIN_OP_T(op, fnc, unsigned int) \
805DEFN_BIN_OP_T(op, fnc, long) \
806DEFN_BIN_OP_T(op, fnc, unsigned long) \
807DEFN_BIN_OP_T(op, fnc, float) \
808DEFN_BIN_OP_T(op, fnc, double) \
809DEFN_BIN_OP_T(op, fnc, const char *) \
810DEFN_BIN_OP_T(op, fnc, const sc_fxval_fast &) \
811DEFN_BIN_OP_OTHER(op, fnc)
844#undef DEFN_BIN_OP_OTHER
862#define DEFN_BIN_FNC_T(fnc, tp) \
864fnc (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) \
874fnc (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) \
884DEFN_BIN_FNC_T(fnc, int64) \
885DEFN_BIN_FNC_T(fnc, uint64) \
886DEFN_BIN_FNC_T(fnc, const sc_int_base &) \
887DEFN_BIN_FNC_T(fnc, const sc_uint_base &) \
888DEFN_BIN_FNC_T(fnc, const sc_signed &) \
889DEFN_BIN_FNC_T(fnc, const sc_unsigned &)
891#define DEFN_BIN_FNC(fnc) \
893fnc(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) \
902DEFN_BIN_FNC_T(fnc, int) \
903DEFN_BIN_FNC_T(fnc, unsigned int) \
904DEFN_BIN_FNC_T(fnc, long) \
905DEFN_BIN_FNC_T(fnc, unsigned long) \
906DEFN_BIN_FNC_T(fnc, float) \
907DEFN_BIN_FNC_T(fnc, double) \
908DEFN_BIN_FNC_T(fnc, const char *) \
909DEFN_BIN_FNC_T(fnc, const sc_fxval_fast &) \
910DEFN_BIN_FNC_OTHER(fnc)
918#undef DEFN_BIN_FNC_OTHER
940#define DEFN_REL_OP_T(op, ret, tp) \
942operator 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); \
951operator 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) \
960DEFN_REL_OP_T(op, ret, int64) \
961DEFN_REL_OP_T(op, ret, uint64) \
962DEFN_REL_OP_T(op, ret, const sc_int_base &) \
963DEFN_REL_OP_T(op, ret, const sc_uint_base &) \
964DEFN_REL_OP_T(op, ret, const sc_signed &) \
965DEFN_REL_OP_T(op, ret, const sc_unsigned &)
967#define DEFN_REL_OP(op, ret) \
969operator 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); \
977DEFN_REL_OP_T(op, ret, int) \
978DEFN_REL_OP_T(op, ret, unsigned int) \
979DEFN_REL_OP_T(op, ret, long) \
980DEFN_REL_OP_T(op, ret, unsigned long) \
981DEFN_REL_OP_T(op, ret, float) \
982DEFN_REL_OP_T(op, ret, double) \
983DEFN_REL_OP_T(op, ret, const char *) \
984DEFN_REL_OP_T(op, ret, const sc_fxval_fast &) \
985DEFN_REL_OP_OTHER(op, ret)
995#undef DEFN_REL_OP_OTHER
1010#define DEFN_ASN_OP_T(tp) \
1012sc_fxval::operator = (tp b) \
1015 *m_rep = *tmp.m_rep; \
1016 SC_FXVAL_OBSERVER_WRITE_(*this) \
1038#define DEFN_ASN_OP_T(op, fnc, tp) \
1040sc_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) \
1052DEFN_ASN_OP_T(op, fnc, int64) \
1053DEFN_ASN_OP_T(op, fnc, uint64) \
1054DEFN_ASN_OP_T(op, fnc, const sc_int_base &) \
1055DEFN_ASN_OP_T(op, fnc, const sc_uint_base &) \
1056DEFN_ASN_OP_T(op, fnc, const sc_signed &) \
1057DEFN_ASN_OP_T(op, fnc, const sc_unsigned &)
1059#define DEFN_ASN_OP(op, fnc) \
1061sc_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) \
1072DEFN_ASN_OP_T(op, fnc, int) \
1073DEFN_ASN_OP_T(op, fnc, unsigned int) \
1074DEFN_ASN_OP_T(op, fnc, long) \
1075DEFN_ASN_OP_T(op, fnc, unsigned long) \
1076DEFN_ASN_OP_T(op, fnc, float) \
1077DEFN_ASN_OP_T(op, fnc, double) \
1078DEFN_ASN_OP_T(op, fnc, const char *) \
1079DEFN_ASN_OP_T(op, fnc, const sc_fxval_fast &) \
1080DEFN_ASN_OP_OTHER(op, fnc)
1088#undef DEFN_ASN_OP_OTHER
1092sc_fxval::operator <<= (
int b)
1101sc_fxval::operator >>= (
int b)
1141inline sc_fxval::operator double()
const
1155inline unsigned short
1286inline ::std::ostream &
1293inline ::std::istream &
1308inline sc_fxval_fast_observer *
1325 m_val(
a.m_val), m_observer(observer_)
1333#define DEFN_CTOR_T(tp, arg) \
1334inline 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())
1411 c.m_val = -
a.m_val;
1416#define DEFN_BIN_OP_T(op, tp) \
1417inline const sc_fxval_fast \
1418operator 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); \
1425inline const sc_fxval_fast \
1426operator 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) \
1434DEFN_BIN_OP_T(op, int64) \
1435DEFN_BIN_OP_T(op, uint64) \
1436DEFN_BIN_OP_T(op, const sc_int_base &) \
1437DEFN_BIN_OP_T(op, const sc_uint_base &) \
1438DEFN_BIN_OP_T(op, const sc_signed &) \
1439DEFN_BIN_OP_T(op, const sc_unsigned &)
1441#define DEFN_BIN_OP(op, dummy) \
1442inline const sc_fxval_fast \
1443operator 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); \
1450DEFN_BIN_OP_T(op, int) \
1451DEFN_BIN_OP_T(op, unsigned int) \
1452DEFN_BIN_OP_T(op, long) \
1453DEFN_BIN_OP_T(op, unsigned long) \
1454DEFN_BIN_OP_T(op, float) \
1455DEFN_BIN_OP_T(op, double) \
1456DEFN_BIN_OP_T(op, const char *) \
1457DEFN_BIN_OP_OTHER(op)
1489#undef DEFN_BIN_OP_OTHER
1500inline const sc_fxval_fast
1508#define DEFN_BIN_FNC_T(fnc, op, tp) \
1510fnc (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) \
1519fnc (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) \
1528DEFN_BIN_FNC_T(fnc, op, int64) \
1529DEFN_BIN_FNC_T(fnc, op, uint64) \
1530DEFN_BIN_FNC_T(fnc, op, const sc_int_base &) \
1531DEFN_BIN_FNC_T(fnc, op, const sc_uint_base &) \
1532DEFN_BIN_FNC_T(fnc, op, const sc_signed &) \
1533DEFN_BIN_FNC_T(fnc, op, const sc_unsigned &)
1535#define DEFN_BIN_FNC(fnc, op) \
1537fnc (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) \
1545DEFN_BIN_FNC_T(fnc, op, int) \
1546DEFN_BIN_FNC_T(fnc, op, unsigned int) \
1547DEFN_BIN_FNC_T(fnc, op, long) \
1548DEFN_BIN_FNC_T(fnc, op, unsigned long) \
1549DEFN_BIN_FNC_T(fnc, op, float) \
1550DEFN_BIN_FNC_T(fnc, op, double) \
1551DEFN_BIN_FNC_T(fnc, op, const char *) \
1552DEFN_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) \
1582operator 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); \
1590operator 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) \
1598DEFN_REL_OP_T(op, int64) \
1599DEFN_REL_OP_T(op, uint64) \
1600DEFN_REL_OP_T(op, const sc_int_base &) \
1601DEFN_REL_OP_T(op, const sc_uint_base &) \
1602DEFN_REL_OP_T(op, const sc_signed &) \
1603DEFN_REL_OP_T(op, const sc_unsigned &)
1605#define DEFN_REL_OP(op) \
1607operator 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); \
1614DEFN_REL_OP_T(op, int) \
1615DEFN_REL_OP_T(op, unsigned int) \
1616DEFN_REL_OP_T(op, long) \
1617DEFN_REL_OP_T(op, unsigned long) \
1618DEFN_REL_OP_T(op, float) \
1619DEFN_REL_OP_T(op, double) \
1620DEFN_REL_OP_T(op, const char *) \
1621DEFN_REL_OP_OTHER(op)
1631#undef DEFN_REL_OP_OTHER
1646#define DEFN_ASN_OP_T(tp) \
1647inline sc_fxval_fast & \
1648sc_fxval_fast::operator = (tp a) \
1650 sc_fxval_fast tmp(a); \
1651 m_val = tmp.m_val; \
1652 SC_FXVAL_FAST_OBSERVER_WRITE_(*this) \
1674#define DEFN_ASN_OP_T(op, tp) \
1675inline sc_fxval_fast & \
1676sc_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) \
1686DEFN_ASN_OP_T(op, int64) \
1687DEFN_ASN_OP_T(op, uint64) \
1688DEFN_ASN_OP_T(op, const sc_int_base &) \
1689DEFN_ASN_OP_T(op, const sc_uint_base &) \
1690DEFN_ASN_OP_T(op, const sc_signed &) \
1691DEFN_ASN_OP_T(op, const sc_unsigned &)
1693#define DEFN_ASN_OP(op) \
1694inline sc_fxval_fast & \
1695sc_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) \
1704DEFN_ASN_OP_T(op, int) \
1705DEFN_ASN_OP_T(op, unsigned int) \
1706DEFN_ASN_OP_T(op, long) \
1707DEFN_ASN_OP_T(op, unsigned long) \
1708DEFN_ASN_OP_T(op, float) \
1709DEFN_ASN_OP_T(op, double) \
1710DEFN_ASN_OP_T(op, const char *) \
1711DEFN_ASN_OP_T(op, const sc_fxval &) \
1712DEFN_ASN_OP_OTHER(op)
1720#undef DEFN_ASN_OP_OTHER
1723inline sc_fxval_fast &
1724sc_fxval_fast::operator <<= (
int b)
1783inline sc_fxval_fast::operator double()
const
1797inline 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;
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();
1924inline ::std::ostream &
1931inline ::std::istream &
1940#undef SCFX_EXPLICIT_
1941#undef SCFX_EXPLICIT_OTHER_
sc_fxval_fast(const sc_uint_base &, sc_fxval_fast_observer *=0)
sc_fxval_fast(const sc_int_base &, sc_fxval_fast_observer *=0)
void print(::std::ostream &=::std::cout) const
sc_fxval_fast_observer * m_observer
sc_fxval_fast_observer * lock_observer() const
const std::string to_string() const
sc_fxval_fast(unsigned long, sc_fxval_fast_observer *=0)
sc_fxval_fast(const char *, sc_fxval_fast_observer *=0)
void dump(::std::ostream &=::std::cout) const
const std::string to_oct() const
sc_fxval_fast(float, sc_fxval_fast_observer *=0)
sc_fxval_fast(const sc_unsigned &, sc_fxval_fast_observer *=0)
friend const sc_fxval_fast operator/(const sc_fxval_fast &, const sc_fxval_fast &)
sc_fxval_fast_observer * observer() const
friend const sc_fxval_fast operator>>(const sc_fxval_fast &, int)
const std::string to_hex() const
void scan(::std::istream &=::std::cin)
static double from_string(const char *)
friend void rshift(sc_fxval_fast &, const sc_fxval_fast &, int)
unsigned short to_ushort() const
unsigned long to_ulong() const
void unlock_observer(sc_fxval_fast_observer *) const
sc_fxval_fast(unsigned int, sc_fxval_fast_observer *=0)
sc_fxval_fast(sc_fxval_fast_observer *=0)
const sc_fxval_fast & operator+() const
const std::string to_bin() const
friend void lshift(sc_fxval_fast &, const sc_fxval_fast &, int)
const std::string to_dec() const
bool rounding_flag() const
sc_fxval_fast(const sc_signed &, sc_fxval_fast_observer *=0)
friend void neg(sc_fxval_fast &, const sc_fxval_fast &)
sc_fxval_fast & operator--()
sc_fxval_fast(long, sc_fxval_fast_observer *=0)
unsigned int to_uint() const
sc_fxval_fast(int, sc_fxval_fast_observer *=0)
sc_fxval_fast(uint64, sc_fxval_fast_observer *=0)
const sc_fxval_fast operator-() const
sc_fxval_fast & operator++()
sc_fxval_fast(double, sc_fxval_fast_observer *=0)
sc_fxval_fast(int64, sc_fxval_fast_observer *=0)
sc_fxval_fast(const sc_fxval &, sc_fxval_fast_observer *=0)
friend void lshift(sc_fxval &, const sc_fxval &, int)
const std::string to_string() const
sc_fxval(unsigned int, sc_fxval_observer *=0)
sc_fxval(const sc_int_base &, sc_fxval_observer *=0)
const scfx_rep * get_rep() const
sc_fxval(const sc_unsigned &, sc_fxval_observer *=0)
sc_fxval(uint64, sc_fxval_observer *=0)
sc_fxval(int64, sc_fxval_observer *=0)
const std::string to_bin() const
const std::string to_dec() const
sc_fxval(unsigned long, sc_fxval_observer *=0)
const sc_fxval quantization(const scfx_params &, bool &) const
friend const sc_fxval operator<<(const sc_fxval &, int)
const sc_fxval & operator+() const
unsigned int to_uint() const
const sc_fxval operator-() const
void scan(::std::istream &=::std::cin)
sc_fxval(float, sc_fxval_observer *=0)
sc_fxval(long, sc_fxval_observer *=0)
sc_fxval(const sc_signed &, sc_fxval_observer *=0)
friend void rshift(sc_fxval &, const sc_fxval &, int)
sc_fxval(const sc_uint_base &, sc_fxval_observer *=0)
sc_fxval(double, sc_fxval_observer *=0)
void unlock_observer(sc_fxval_observer *) const
const std::string to_hex() const
const std::string to_oct() const
unsigned long to_ulong() const
friend void neg(sc_fxval &, const sc_fxval &)
const sc_fxval overflow(const scfx_params &, bool &) const
sc_fxval_observer * lock_observer() const
sc_fxval(int, sc_fxval_observer *=0)
sc_fxval(const char *, sc_fxval_observer *=0)
sc_fxval_observer * observer() const
void print(::std::ostream &=::std::cout) const
friend const sc_fxval operator>>(const sc_fxval &, int)
friend const sc_fxval operator/(const sc_fxval &, const sc_fxval &)
bool rounding_flag() const
unsigned short to_ushort() const
void dump(::std::ostream &=::std::cout) const
void get_type(int &, int &, sc_enc &) const
sc_fxval_observer * m_observer
sc_fxval(const sc_fxval_fast &, sc_fxval_observer *=0)
bool rounding_flag() const
void get_type(int &, int &, sc_enc &) const
void neg(sc_fxval &c, const sc_fxnum &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)
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)
scfx_rep * quantization_scfx_rep(const scfx_rep &a, const scfx_params ¶ms, bool &q_flag)
sc_signed operator>>(const sc_signed &u, const sc_int_base &v)
scfx_rep * overflow_scfx_rep(const scfx_rep &a, const scfx_params ¶ms, bool &o_flag)
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 DECL_BIN_FNC(fnc)
#define DECL_BIN_OP_T(op, tp)
#define DEFN_BIN_FNC(fnc)
#define DEFN_CTOR_T_B(tp)
#define DEFN_CTOR_T_C(tp)
#define DEFN_CTOR_T_A(tp)
#define DECL_BIN_OP(op, dummy)
#define SC_FXVAL_OBSERVER_DEFAULT_
#define SC_FXVAL_FAST_OBSERVER_DESTRUCT_(object)
#define SC_FXVAL_OBSERVER_DESTRUCT_(object)
#define SC_FXVAL_OBSERVER_WRITE_(object)
#define SC_FXVAL_FAST_OBSERVER_READ_(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_READ_(object)
#define SC_FXVAL_OBSERVER_CONSTRUCT_(object)
#define DEFN_BIN_OP_T(ret, op, tp)
#define DEFN_BIN_OP(ret, op)