50 #ifndef __SYSTEMC_EXT_DT_FX_SC_FIX_HH__
51 #define __SYSTEMC_EXT_DT_FX_SC_FIX_HH__
69 class sc_fix :
public sc_fxnum
73 explicit sc_fix(sc_fxnum_observer * =0);
74 sc_fix(
int,
int, sc_fxnum_observer * =0);
79 explicit sc_fix(
const sc_fxcast_switch &, sc_fxnum_observer * =0);
80 sc_fix(
int,
int,
const sc_fxcast_switch &, sc_fxnum_observer * =0);
82 sc_fxnum_observer * =0);
84 sc_fxnum_observer * =0);
86 sc_fxnum_observer * =0);
88 sc_fxnum_observer * =0);
89 explicit sc_fix(
const sc_fxtype_params &, sc_fxnum_observer * =0);
90 sc_fix(
const sc_fxtype_params &,
const sc_fxcast_switch &,
91 sc_fxnum_observer * =0);
93 #define DECL_CTORS_T(tp) \
94 sc_fix(tp, int, int, sc_fxnum_observer * =0); \
95 sc_fix(tp, sc_q_mode, sc_o_mode, sc_fxnum_observer * =0); \
96 sc_fix(tp, sc_q_mode, sc_o_mode, int, sc_fxnum_observer * =0); \
97 sc_fix(tp, int, int, sc_q_mode, sc_o_mode, sc_fxnum_observer * =0); \
98 sc_fix(tp, int, int, sc_q_mode, sc_o_mode, int, sc_fxnum_observer * =0); \
99 sc_fix(tp, const sc_fxcast_switch &, sc_fxnum_observer * =0); \
100 sc_fix(tp, int, int, const sc_fxcast_switch &, sc_fxnum_observer * =0); \
101 sc_fix(tp, sc_q_mode, sc_o_mode, const sc_fxcast_switch &, \
102 sc_fxnum_observer * =0); \
103 sc_fix(tp, sc_q_mode, sc_o_mode, int, const sc_fxcast_switch &, \
104 sc_fxnum_observer * =0); \
105 sc_fix(tp, int, int, sc_q_mode, sc_o_mode, const sc_fxcast_switch &, \
106 sc_fxnum_observer * =0); \
107 sc_fix(tp, int, int, sc_q_mode, sc_o_mode, int, \
108 const sc_fxcast_switch &, sc_fxnum_observer * =0); \
109 sc_fix(tp, const sc_fxtype_params &, sc_fxnum_observer * =0); \
110 sc_fix(tp, const sc_fxtype_params &, const sc_fxcast_switch &, \
111 sc_fxnum_observer * =0);
113 #define DECL_CTORS_T_A(tp) \
114 sc_fix(tp, sc_fxnum_observer * =0); \
117 #define DECL_CTORS_T_B(tp) \
118 explicit sc_fix(tp, sc_fxnum_observer * =0); \
141 #undef DECL_CTORS_T_A
142 #undef DECL_CTORS_T_B
178 #define DECL_ASN_OP_T(op, tp) sc_fix &operator op (tp);
180 #define DECL_ASN_OP_OTHER(op) \
181 DECL_ASN_OP_T(op, int64) \
182 DECL_ASN_OP_T(op, uint64) \
183 DECL_ASN_OP_T(op, const sc_int_base &) \
184 DECL_ASN_OP_T(op, const sc_uint_base &) \
185 DECL_ASN_OP_T(op, const sc_signed &) \
186 DECL_ASN_OP_T(op, const sc_unsigned &)
188 #define DECL_ASN_OP(op) \
189 DECL_ASN_OP_T(op, int) \
190 DECL_ASN_OP_T(op, unsigned int) \
191 DECL_ASN_OP_T(op, long) \
192 DECL_ASN_OP_T(op, unsigned long) \
193 DECL_ASN_OP_T(op, float) \
194 DECL_ASN_OP_T(op, double) \
195 DECL_ASN_OP_T(op, const char *) \
196 DECL_ASN_OP_T(op, const sc_fxval &) \
197 DECL_ASN_OP_T(op, const sc_fxval_fast &) \
198 DECL_ASN_OP_T(op, const sc_fxnum &) \
199 DECL_ASN_OP_T(op, const sc_fxnum_fast &) \
200 DECL_ASN_OP_OTHER(op)
220 #undef DECL_ASN_OP_OTHER
266 #define DECL_CTORS_T(tp) \
267 sc_fix_fast(tp, int, int, sc_fxnum_fast_observer * = 0); \
268 sc_fix_fast(tp, sc_q_mode, sc_o_mode, sc_fxnum_fast_observer * = 0); \
269 sc_fix_fast(tp, sc_q_mode, sc_o_mode, int, sc_fxnum_fast_observer * = 0); \
270 sc_fix_fast(tp, int, int, sc_q_mode, sc_o_mode, \
271 sc_fxnum_fast_observer * = 0); \
272 sc_fix_fast(tp, int, int, sc_q_mode, sc_o_mode, int, \
273 sc_fxnum_fast_observer * = 0); \
274 sc_fix_fast(tp, const sc_fxcast_switch &, sc_fxnum_fast_observer * = 0); \
275 sc_fix_fast(tp, int, int, const sc_fxcast_switch &, \
276 sc_fxnum_fast_observer * = 0); \
277 sc_fix_fast(tp, sc_q_mode, sc_o_mode, const sc_fxcast_switch &, \
278 sc_fxnum_fast_observer * = 0); \
279 sc_fix_fast(tp, sc_q_mode, sc_o_mode, int, const sc_fxcast_switch &, \
280 sc_fxnum_fast_observer * = 0); \
281 sc_fix_fast(tp, int, int, sc_q_mode, sc_o_mode, const sc_fxcast_switch &, \
282 sc_fxnum_fast_observer * = 0); \
283 sc_fix_fast(tp, int, int, sc_q_mode, sc_o_mode, int, \
284 const sc_fxcast_switch &, sc_fxnum_fast_observer * = 0); \
285 sc_fix_fast(tp, const sc_fxtype_params &, sc_fxnum_fast_observer * = 0); \
286 sc_fix_fast(tp, const sc_fxtype_params &, const sc_fxcast_switch &, \
287 sc_fxnum_fast_observer * = 0);
289 #define DECL_CTORS_T_A(tp) \
290 sc_fix_fast(tp, sc_fxnum_fast_observer * =0); \
293 #define DECL_CTORS_T_B(tp) \
294 explicit sc_fix_fast(tp, sc_fxnum_fast_observer * =0); \
317 #undef DECL_CTORS_T_A
318 #undef DECL_CTORS_T_B
345 #define DECL_ASN_OP_T(op,tp) sc_fix_fast &operator op (tp);
347 #define DECL_ASN_OP_OTHER(op) \
348 DECL_ASN_OP_T(op, int64) \
349 DECL_ASN_OP_T(op, uint64) \
350 DECL_ASN_OP_T(op, const sc_int_base &) \
351 DECL_ASN_OP_T(op, const sc_uint_base &) \
352 DECL_ASN_OP_T(op, const sc_signed &) \
353 DECL_ASN_OP_T(op, const sc_unsigned &)
355 #define DECL_ASN_OP(op) \
356 DECL_ASN_OP_T(op, int) \
357 DECL_ASN_OP_T(op, unsigned int) \
358 DECL_ASN_OP_T(op, long) \
359 DECL_ASN_OP_T(op, unsigned long) \
360 DECL_ASN_OP_T(op, float) \
361 DECL_ASN_OP_T(op, double) \
362 DECL_ASN_OP_T(op, const char *) \
363 DECL_ASN_OP_T(op, const sc_fxval &) \
364 DECL_ASN_OP_T(op, const sc_fxval_fast &) \
365 DECL_ASN_OP_T(op, const sc_fxnum &) \
366 DECL_ASN_OP_T(op, const sc_fxnum_fast &) \
367 DECL_ASN_OP_OTHER(op)
387 #undef DECL_ASN_OP_OTHER
409 sc_fxnum(sc_fxtype_params(),
SC_TC_, sc_fxcast_switch(), observer_)
412 inline sc_fix::sc_fix(
int wl_,
int iwl_, sc_fxnum_observer *observer_) :
413 sc_fxnum(sc_fxtype_params(wl_, iwl_),
SC_TC_, sc_fxcast_switch(),
418 sc_fxnum_observer *observer_) :
419 sc_fxnum(sc_fxtype_params(qm, om),
SC_TC_, sc_fxcast_switch(),
424 sc_fxnum_observer *observer_) :
425 sc_fxnum(sc_fxtype_params(qm, om, nb),
SC_TC_, sc_fxcast_switch(),
430 sc_fxnum_observer *observer_) :
431 sc_fxnum(sc_fxtype_params(wl_, iwl_, qm, om),
SC_TC_,
432 sc_fxcast_switch(), observer_)
436 sc_fxnum_observer* observer_) :
437 sc_fxnum(sc_fxtype_params(wl_, iwl_, qm, om, nb),
SC_TC_,
438 sc_fxcast_switch(), observer_)
488 #define DEFN_CTORS_T_A(tp) \
489 inline sc_fix::sc_fix(tp a, sc_fxnum_observer *observer_) : \
490 sc_fxnum(a, sc_fxtype_params(), SC_TC_, sc_fxcast_switch(), \
494 inline sc_fix::sc_fix(tp a, int wl_, int iwl_, \
495 sc_fxnum_observer *observer_) : \
496 sc_fxnum(a, sc_fxtype_params(wl_, iwl_), SC_TC_, sc_fxcast_switch(), \
500 inline sc_fix::sc_fix(tp a, sc_q_mode qm, sc_o_mode om, \
501 sc_fxnum_observer *observer_) : \
502 sc_fxnum(a, sc_fxtype_params(qm, om), SC_TC_, sc_fxcast_switch(), \
506 inline sc_fix::sc_fix(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
507 sc_fxnum_observer *observer_) : \
508 sc_fxnum(a, sc_fxtype_params(qm, om, nb), SC_TC_, \
509 sc_fxcast_switch(), observer_) \
512 inline sc_fix::sc_fix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
513 sc_fxnum_observer *observer_) : \
514 sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, \
515 sc_fxcast_switch(), observer_) \
518 inline sc_fix::sc_fix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
519 int nb, sc_fxnum_observer *observer_) : \
520 sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, \
521 sc_fxcast_switch(), observer_) \
524 inline sc_fix::sc_fix(tp a, const sc_fxcast_switch &cast_sw, \
525 sc_fxnum_observer *observer_) : \
526 sc_fxnum(a, sc_fxtype_params(), SC_TC_, cast_sw, observer_) \
529 inline sc_fix::sc_fix(tp a, int wl_, int iwl_, \
530 const sc_fxcast_switch &cast_sw, \
531 sc_fxnum_observer *observer_) : \
532 sc_fxnum(a, sc_fxtype_params(wl_, iwl_), SC_TC_, cast_sw, observer_) \
535 inline sc_fix::sc_fix(tp a, sc_q_mode qm, sc_o_mode om, \
536 const sc_fxcast_switch &cast_sw, \
537 sc_fxnum_observer *observer_) : \
538 sc_fxnum(a, sc_fxtype_params(qm, om), SC_TC_, cast_sw, observer_) \
541 inline sc_fix::sc_fix(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
542 const sc_fxcast_switch &cast_sw, \
543 sc_fxnum_observer *observer_) : \
544 sc_fxnum(a, sc_fxtype_params(qm, om, nb), SC_TC_, cast_sw, observer_) \
547 inline sc_fix::sc_fix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
548 const sc_fxcast_switch &cast_sw, \
549 sc_fxnum_observer *observer_) : \
550 sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, cast_sw, \
554 inline sc_fix::sc_fix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
555 int nb, const sc_fxcast_switch &cast_sw, \
556 sc_fxnum_observer *observer_) : \
557 sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, cast_sw, \
561 inline sc_fix::sc_fix(tp a, const sc_fxtype_params &type_params_, \
562 sc_fxnum_observer *observer_) : \
563 sc_fxnum(a, type_params_, SC_TC_, sc_fxcast_switch(), observer_) \
566 inline sc_fix::sc_fix(tp a, const sc_fxtype_params &type_params_, \
567 const sc_fxcast_switch &cast_sw, \
568 sc_fxnum_observer *observer_) : \
569 sc_fxnum(a, type_params_, SC_TC_, cast_sw, observer_) \
572 #define DEFN_CTORS_T_B(tp) \
573 inline sc_fix::sc_fix(tp a, sc_fxnum_observer *observer_) : \
574 sc_fxnum(a, a.type_params(), SC_TC_, sc_fxcast_switch(), observer_) \
577 inline sc_fix::sc_fix(tp a, int wl_, int iwl_, \
578 sc_fxnum_observer *observer_) : \
579 sc_fxnum(a, sc_fxtype_params(a.type_params(), wl_, iwl_), SC_TC_, \
580 sc_fxcast_switch(), observer_) \
583 inline sc_fix::sc_fix(tp a, sc_q_mode qm, sc_o_mode om, \
584 sc_fxnum_observer *observer_) : \
585 sc_fxnum(a, sc_fxtype_params(a.type_params(), qm, om), SC_TC_, \
586 sc_fxcast_switch(), observer_) \
589 inline sc_fix::sc_fix(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
590 sc_fxnum_observer *observer_) : \
591 sc_fxnum(a, sc_fxtype_params(a.type_params(), qm, om, nb), SC_TC_, \
592 sc_fxcast_switch(), observer_) \
595 inline sc_fix::sc_fix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
596 sc_fxnum_observer *observer_) : \
597 sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, \
598 sc_fxcast_switch(), observer_) \
601 inline sc_fix::sc_fix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
602 int nb, sc_fxnum_observer *observer_) : \
603 sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, \
604 sc_fxcast_switch(), observer_) \
607 inline sc_fix::sc_fix(tp a, const sc_fxcast_switch &cast_sw, \
608 sc_fxnum_observer *observer_) : \
609 sc_fxnum(a, a.type_params(), SC_TC_, cast_sw, observer_) \
612 inline sc_fix::sc_fix(tp a, int wl_, int iwl_, \
613 const sc_fxcast_switch &cast_sw, \
614 sc_fxnum_observer *observer_) : \
615 sc_fxnum(a, sc_fxtype_params(a.type_params(), wl_, iwl_), SC_TC_, \
616 cast_sw, observer_) \
619 inline sc_fix::sc_fix(tp a, sc_q_mode qm, sc_o_mode om, \
620 const sc_fxcast_switch &cast_sw, \
621 sc_fxnum_observer *observer_) : \
622 sc_fxnum(a, sc_fxtype_params(a.type_params(), qm, om), SC_TC_, \
623 cast_sw, observer_) \
626 inline sc_fix::sc_fix(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
627 const sc_fxcast_switch &cast_sw, \
628 sc_fxnum_observer *observer_) : \
629 sc_fxnum(a, sc_fxtype_params(a.type_params(), qm, om, nb), SC_TC_, \
630 cast_sw, observer_) \
633 inline sc_fix::sc_fix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
634 const sc_fxcast_switch &cast_sw, \
635 sc_fxnum_observer *observer_) : \
636 sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, cast_sw, \
640 inline sc_fix::sc_fix(tp a, int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, \
641 int nb, const sc_fxcast_switch &cast_sw, \
642 sc_fxnum_observer *observer_) : \
643 sc_fxnum(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, cast_sw, \
647 inline sc_fix::sc_fix(tp a, const sc_fxtype_params &type_params_, \
648 sc_fxnum_observer *observer_) : \
649 sc_fxnum(a, type_params_, SC_TC_, sc_fxcast_switch(), observer_) \
652 inline sc_fix::sc_fix(tp a, const sc_fxtype_params &type_params_, \
653 const sc_fxcast_switch &cast_sw, \
654 sc_fxnum_observer *observer_) : \
655 sc_fxnum(a, type_params_, SC_TC_, cast_sw, observer_) \
677 #undef DEFN_CTORS_T_A
678 #undef DEFN_CTORS_T_B
692 for (
int i = iwl_c - wl_c;
i < iwl_c; ++
i)
703 for (
int i = iwl_c -
c.wl();
i < iwl_c; ++
i)
704 c.set_bit(
i, !
a.get_bit(
i));
710 #define DEFN_BIN_OP_T(op, op2, tp1, tp2) \
711 inline const sc_fix \
712 operator op (const tp1 &a, const tp2 &b) \
716 int iwl_a = a.iwl(); \
717 int iwl_b = b.iwl(); \
718 int iwl_c = sc_max(iwl_a, iwl_b); \
719 int fwl_c = sc_max(a.wl() - iwl_a, b.wl() - iwl_b); \
720 sc_fix c(iwl_c + fwl_c, iwl_c); \
721 for (int i = -fwl_c; i < iwl_c; ++ i) \
722 c.set_bit(i, a.get_bit(i) op2 b.get_bit(i)); \
723 return sc_fix(c, iwl_c + fwl_c, iwl_c); \
741 #define DEFN_BIN_FNC_T(fnc, op2, tp1, tp2) \
743 fnc (sc_fix &c, const tp1 &a, const tp2 &b) \
747 int iwl_c = c.iwl(); \
748 for (int i = iwl_c - c.wl(); i < iwl_c; ++i) \
749 c.set_bit(i, a.get_bit(i) op2 b.get_bit(i)); \
751 SC_FXNUM_OBSERVER_WRITE_(c) \
766 #undef DEFN_BIN_FNC_T
773 sc_fxnum::operator = (
a);
777 #define DEFN_ASN_OP_T(op, tp) \
779 sc_fix::operator op (tp a) \
781 sc_fxnum::operator op(a); \
785 #define DEFN_ASN_OP_OTHER(op) \
786 DEFN_ASN_OP_T(op, int64) \
787 DEFN_ASN_OP_T(op, uint64) \
788 DEFN_ASN_OP_T(op, const sc_int_base &) \
789 DEFN_ASN_OP_T(op, const sc_uint_base &) \
790 DEFN_ASN_OP_T(op, const sc_signed &) \
791 DEFN_ASN_OP_T(op, const sc_unsigned &)
793 #define DEFN_ASN_OP(op) \
794 DEFN_ASN_OP_T(op, int) \
795 DEFN_ASN_OP_T(op, unsigned int) \
796 DEFN_ASN_OP_T(op, long) \
797 DEFN_ASN_OP_T(op, unsigned long) \
798 DEFN_ASN_OP_T(op, float) \
799 DEFN_ASN_OP_T(op, double) \
800 DEFN_ASN_OP_T(op, const char *) \
801 DEFN_ASN_OP_T(op, const sc_fxval &) \
802 DEFN_ASN_OP_T(op, const sc_fxval_fast &) \
803 DEFN_ASN_OP_T(op, const sc_fxnum &) \
804 DEFN_ASN_OP_T(op, const sc_fxnum_fast &) \
805 DEFN_ASN_OP_OTHER(op)
818 #undef DEFN_ASN_OP_OTHER
821 #define DEFN_ASN_OP_T(op, op2, tp) \
823 sc_fix::operator op (const tp &b) \
825 SC_FXNUM_OBSERVER_READ_(*this) \
828 for (int i = iwl_c - wl(); i < iwl_c; ++i) \
829 set_bit(i, get_bit(i) op2 b.get_bit(i)); \
831 SC_FXNUM_OBSERVER_WRITE_(*this) \
848 return sc_fxval(sc_fxnum::operator ++ (0));
854 return sc_fxval(sc_fxnum::operator -- (0));
909 int nb, sc_fxnum_fast_observer *observer_) :
962 #define DEFN_CTORS_T_A(tp) \
963 inline sc_fix_fast::sc_fix_fast(tp a, sc_fxnum_fast_observer *observer_ ) : \
964 sc_fxnum_fast(a, sc_fxtype_params(), SC_TC_, sc_fxcast_switch(), \
968 inline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, \
969 sc_fxnum_fast_observer *observer_) : \
970 sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_), SC_TC_, \
971 sc_fxcast_switch(), observer_) \
974 inline sc_fix_fast::sc_fix_fast(tp a, sc_q_mode qm, sc_o_mode om, \
975 sc_fxnum_fast_observer *observer_) : \
976 sc_fxnum_fast(a, sc_fxtype_params(qm, om), SC_TC_, \
977 sc_fxcast_switch(), observer_) \
980 inline sc_fix_fast::sc_fix_fast(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
981 sc_fxnum_fast_observer *observer_ ) : \
982 sc_fxnum_fast(a, sc_fxtype_params(qm, om, nb), SC_TC_, \
983 sc_fxcast_switch(), observer_) \
986 inline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, sc_q_mode qm, \
988 sc_fxnum_fast_observer *observer_) : \
989 sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, \
990 sc_fxcast_switch(), observer_) \
993 inline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, sc_q_mode qm, \
994 sc_o_mode om, int nb, \
995 sc_fxnum_fast_observer *observer_) : \
996 sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, \
997 sc_fxcast_switch(), observer_) \
1000 inline sc_fix_fast::sc_fix_fast(tp a, const sc_fxcast_switch &cast_sw, \
1001 sc_fxnum_fast_observer *observer_) : \
1002 sc_fxnum_fast(a, sc_fxtype_params(), SC_TC_, cast_sw, observer_) \
1005 inline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, \
1006 const sc_fxcast_switch &cast_sw, \
1007 sc_fxnum_fast_observer *observer_) : \
1008 sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_), SC_TC_, cast_sw, \
1012 inline sc_fix_fast::sc_fix_fast(tp a, sc_q_mode qm, sc_o_mode om, \
1013 const sc_fxcast_switch &cast_sw, \
1014 sc_fxnum_fast_observer *observer_) : \
1015 sc_fxnum_fast(a, sc_fxtype_params(qm, om), SC_TC_, cast_sw, \
1019 inline sc_fix_fast::sc_fix_fast(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
1020 const sc_fxcast_switch &cast_sw, \
1021 sc_fxnum_fast_observer *observer_) : \
1022 sc_fxnum_fast(a, sc_fxtype_params(qm, om, nb), SC_TC_, cast_sw, \
1026 inline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, sc_q_mode qm, \
1028 const sc_fxcast_switch &cast_sw, \
1029 sc_fxnum_fast_observer *observer_) : \
1030 sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, \
1031 cast_sw, observer_) \
1034 inline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, sc_q_mode qm, \
1035 sc_o_mode om, int nb, \
1036 const sc_fxcast_switch &cast_sw, \
1037 sc_fxnum_fast_observer *observer_) : \
1038 sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, \
1039 cast_sw, observer_) \
1042 inline sc_fix_fast::sc_fix_fast(tp a, const sc_fxtype_params &type_params_, \
1043 sc_fxnum_fast_observer *observer_) : \
1044 sc_fxnum_fast(a, type_params_, SC_TC_, sc_fxcast_switch(), observer_) \
1047 inline sc_fix_fast::sc_fix_fast(tp a, const sc_fxtype_params &type_params_, \
1048 const sc_fxcast_switch &cast_sw, \
1049 sc_fxnum_fast_observer *observer_) : \
1050 sc_fxnum_fast(a, type_params_, SC_TC_, cast_sw, observer_) \
1053 #define DEFN_CTORS_T_B(tp) \
1054 inline sc_fix_fast::sc_fix_fast(tp a, sc_fxnum_fast_observer *observer_) : \
1055 sc_fxnum_fast(a, a.type_params(), SC_TC_, sc_fxcast_switch(), \
1059 inline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, \
1060 sc_fxnum_fast_observer *observer_) : \
1061 sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), wl_, iwl_), \
1062 SC_TC_, sc_fxcast_switch(), observer_) \
1065 inline sc_fix_fast::sc_fix_fast(tp a, sc_q_mode qm, sc_o_mode om, \
1066 sc_fxnum_fast_observer *observer_) : \
1067 sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), qm, om), SC_TC_, \
1068 sc_fxcast_switch(), observer_) \
1071 inline sc_fix_fast::sc_fix_fast(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
1072 sc_fxnum_fast_observer *observer_) : \
1073 sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), qm, om, nb), \
1074 SC_TC_, sc_fxcast_switch(), observer_) \
1077 inline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, sc_q_mode qm, \
1079 sc_fxnum_fast_observer *observer_) : \
1080 sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, \
1081 sc_fxcast_switch(), observer_) \
1084 inline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, sc_q_mode qm, \
1085 sc_o_mode om, int nb, \
1086 sc_fxnum_fast_observer *observer_) : \
1087 sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, \
1088 sc_fxcast_switch(), observer_) \
1091 inline sc_fix_fast::sc_fix_fast(tp a, const sc_fxcast_switch &cast_sw, \
1092 sc_fxnum_fast_observer *observer_) : \
1093 sc_fxnum_fast(a, a.type_params(), SC_TC_, cast_sw, observer_) \
1096 inline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, \
1097 const sc_fxcast_switch &cast_sw, \
1098 sc_fxnum_fast_observer *observer_) : \
1099 sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), wl_, iwl_), \
1100 SC_TC_, cast_sw, observer_) \
1103 inline sc_fix_fast::sc_fix_fast(tp a, sc_q_mode qm, sc_o_mode om, \
1104 const sc_fxcast_switch &cast_sw, \
1105 sc_fxnum_fast_observer *observer_) : \
1106 sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), qm, om), SC_TC_, \
1107 cast_sw, observer_) \
1110 inline sc_fix_fast::sc_fix_fast(tp a, sc_q_mode qm, sc_o_mode om, int nb, \
1111 const sc_fxcast_switch &cast_sw, \
1112 sc_fxnum_fast_observer *observer_) : \
1113 sc_fxnum_fast(a, sc_fxtype_params(a.type_params(), qm, om, nb), \
1114 SC_TC_, cast_sw, observer_) \
1117 inline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, sc_q_mode qm, \
1119 const sc_fxcast_switch &cast_sw, \
1120 sc_fxnum_fast_observer *observer_) : \
1121 sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om), SC_TC_, \
1122 cast_sw, observer_) \
1125 inline sc_fix_fast::sc_fix_fast(tp a, int wl_, int iwl_, sc_q_mode qm, \
1126 sc_o_mode om, int nb, \
1127 const sc_fxcast_switch &cast_sw, \
1128 sc_fxnum_fast_observer *observer_) : \
1129 sc_fxnum_fast(a, sc_fxtype_params(wl_, iwl_, qm, om, nb), SC_TC_, \
1130 cast_sw, observer_) \
1133 inline sc_fix_fast::sc_fix_fast(tp a, const sc_fxtype_params &type_params_, \
1134 sc_fxnum_fast_observer *observer_) : \
1135 sc_fxnum_fast(a, type_params_, SC_TC_, sc_fxcast_switch(), observer_) \
1138 inline sc_fix_fast::sc_fix_fast(tp a, const sc_fxtype_params &type_params_, \
1139 const sc_fxcast_switch &cast_sw, \
1140 sc_fxnum_fast_observer *observer_) : \
1141 sc_fxnum_fast(a, type_params_, SC_TC_, cast_sw, observer_ ) \
1163 #undef DEFN_CTORS_T_A
1164 #undef DEFN_CTORS_T_B
1168 sc_fxnum_fast(
a,
a.type_params(),
SC_TC_, sc_fxcast_switch(), 0)
1172 inline const sc_fix_fast
1178 sc_fix_fast
c(wl_c, iwl_c);
1179 for (
int i = iwl_c - wl_c;
i < iwl_c; ++
i)
1180 c.set_bit(
i, !get_bit(
i));
1181 return sc_fix_fast(
c, wl_c, iwl_c);
1186 b_not(sc_fix_fast &
c, const sc_fix_fast &
a)
1189 int iwl_c =
c.iwl();
1190 for (
int i = iwl_c -
c.wl();
i < iwl_c; ++
i)
1191 c.set_bit(
i, !
a.get_bit(
i));
1197 #define DEFN_BIN_OP_T(op, op2, tp1, tp2) \
1198 inline const sc_fix_fast \
1199 operator op (const tp1 &a, const tp2 &b) \
1201 a.observer_read(); \
1202 b.observer_read(); \
1203 int iwl_a = a.iwl(); \
1204 int iwl_b = b.iwl(); \
1205 int iwl_c = sc_max(iwl_a, iwl_b); \
1206 int fwl_c = sc_max(a.wl() - iwl_a, b.wl() - iwl_b); \
1207 sc_fix_fast c(iwl_c + fwl_c, iwl_c); \
1208 for (int i = -fwl_c; i < iwl_c; ++i) \
1209 c.set_bit(i, a.get_bit(i) op2 b.get_bit(i)); \
1210 return sc_fix_fast(c, iwl_c + fwl_c, iwl_c); \
1217 #undef DEFN_BIN_OP_T
1220 #define DEFN_BIN_FNC_T(fnc, op2, tp1, tp2) \
1222 fnc(sc_fix_fast &c, const tp1 &a, const tp2 &b) \
1224 a.observer_read(); \
1225 b.observer_read(); \
1226 int iwl_c = c.iwl(); \
1227 for (int i = iwl_c - c.wl(); i < iwl_c; ++i) \
1228 c.set_bit(i, a.get_bit(i) op2 b.get_bit(i)); \
1230 SC_FXNUM_FAST_OBSERVER_WRITE_(c) \
1237 #undef DEFN_BIN_FNC_T
1240 inline sc_fix_fast &
1241 sc_fix_fast::operator = (
const sc_fix_fast &
a)
1243 sc_fxnum_fast::operator = (
a);
1247 #define DEFN_ASN_OP_T(op, tp) \
1248 inline sc_fix_fast & \
1249 sc_fix_fast::operator op (tp a) \
1251 sc_fxnum_fast::operator op(a); \
1255 #define DEFN_ASN_OP_OTHER(op) \
1256 DEFN_ASN_OP_T(op, int64) \
1257 DEFN_ASN_OP_T(op, uint64) \
1258 DEFN_ASN_OP_T(op, const sc_int_base &) \
1259 DEFN_ASN_OP_T(op, const sc_uint_base &) \
1260 DEFN_ASN_OP_T(op, const sc_signed &) \
1261 DEFN_ASN_OP_T(op, const sc_unsigned &)
1263 #define DEFN_ASN_OP(op) \
1264 DEFN_ASN_OP_T(op, int) \
1265 DEFN_ASN_OP_T(op, unsigned int) \
1266 DEFN_ASN_OP_T(op, long) \
1267 DEFN_ASN_OP_T(op, unsigned long) \
1268 DEFN_ASN_OP_T(op, float) \
1269 DEFN_ASN_OP_T(op, double) \
1270 DEFN_ASN_OP_T(op, const char *) \
1271 DEFN_ASN_OP_T(op, const sc_fxval &) \
1272 DEFN_ASN_OP_T(op, const sc_fxval_fast &) \
1273 DEFN_ASN_OP_T(op, const sc_fxnum &) \
1274 DEFN_ASN_OP_T(op, const sc_fxnum_fast &) \
1275 DEFN_ASN_OP_OTHER(op)
1287 #undef DEFN_ASN_OP_T
1288 #undef DEFN_ASN_OP_OTHER
1291 #define DEFN_ASN_OP_T(op, op2, tp) \
1292 inline sc_fix_fast & \
1293 sc_fix_fast::operator op (const tp &b) \
1295 SC_FXNUM_FAST_OBSERVER_READ_(*this) \
1296 b.observer_read(); \
1297 int iwl_c = iwl(); \
1298 for (int i = iwl_c - wl(); i < iwl_c; ++i) \
1299 set_bit(i, get_bit(i) op2 b.get_bit(i)); \
1301 SC_FXNUM_FAST_OBSERVER_WRITE_(*this) \
1312 #undef DEFN_ASN_OP_T
1315 inline const sc_fxval_fast
1316 sc_fix_fast::operator ++ (
int)
1318 return sc_fxval_fast(sc_fxnum_fast::operator ++ (0));
1321 inline const sc_fxval_fast
1322 sc_fix_fast::operator -- (
int)
1324 return sc_fxval_fast(sc_fxnum_fast::operator -- (0));
1327 inline sc_fix_fast &
1328 sc_fix_fast::operator ++ ()
1330 sc_fxnum_fast::operator ++ ();
1334 inline sc_fix_fast &
1335 sc_fix_fast::operator -- ()
1337 sc_fxnum_fast::operator -- ();
1343 #endif // __SYSTEMC_EXT_DT_FX_SC_FIX_HH__