00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00041 
00042 
00043 
00044 
00045 
00046 
00047 
00048 
00049 
00050 
00051 
00052 
00053 
00054 
00055 
00056 
00057 #ifndef SC_FXNUM_H
00058 #define SC_FXNUM_H
00059 
00060 
00061 #include "sysc/datatypes/bit/sc_lv_base.h"
00062 #include "sysc/datatypes/fx/sc_fxval.h"
00063 #include "sysc/datatypes/fx/scfx_params.h"
00064 #include "sysc/datatypes/fx/sc_fxnum_observer.h"
00065 
00066 
00067 namespace sc_core {
00068         class vcd_sc_fxnum_trace;
00069         class vcd_sc_fxnum_fast_trace;
00070         class wif_sc_fxnum_trace;
00071         class wif_sc_fxnum_fast_trace;
00072 }
00073 
00074 
00075 namespace sc_dt
00076 {
00077 
00078 
00079 class sc_fxnum_bitref;
00080 class sc_fxnum_fast_bitref;
00081 class sc_fxnum_subref;
00082 class sc_fxnum_fast_subref;
00083 class sc_fxnum;
00084 class sc_fxnum_fast;
00085 
00086 
00087 
00088 
00089 
00090 
00091 
00092 
00093 class sc_fxnum_bitref
00094 {
00095     friend class sc_fxnum;
00096     friend class sc_fxnum_fast_bitref;
00097 
00098 
00099     bool get() const;
00100     void set( bool );
00101 
00102 
00103     
00104 
00105     sc_fxnum_bitref( sc_fxnum&, int );
00106 
00107 public:
00108 
00109     
00110 
00111     sc_fxnum_bitref( const sc_fxnum_bitref& );
00112 
00113 
00114     
00115 
00116 #define DECL_ASN_OP_T(op,tp)                                                  \
00117     sc_fxnum_bitref& operator op ( tp );
00118 
00119 #define DECL_ASN_OP(op)                                                       \
00120     DECL_ASN_OP_T(op,const sc_fxnum_bitref&)                                  \
00121     DECL_ASN_OP_T(op,const sc_fxnum_fast_bitref&)                             \
00122     DECL_ASN_OP_T(op,const sc_bit&)                                           \
00123     DECL_ASN_OP_T(op,bool)
00124 
00125     DECL_ASN_OP(=)
00126 
00127     DECL_ASN_OP(&=)
00128     DECL_ASN_OP(|=)
00129     DECL_ASN_OP(^=)
00130 
00131 #undef DECL_ASN_OP_T
00132 #undef DECL_ASN_OP
00133 
00134 
00135     
00136 
00137     operator bool() const;
00138 
00139 
00140     
00141 
00142     void print( ::std::ostream& = ::std::cout ) const;
00143     void scan( ::std::istream& = ::std::cin );
00144     void dump( ::std::ostream& = ::std::cout ) const;
00145 
00146 private:
00147 
00148     sc_fxnum& m_num;
00149     int       m_idx;
00150 
00151 private:
00152 
00153     
00154     sc_fxnum_bitref();
00155 };
00156 
00157 
00158 
00159 
00160 
00161 
00162 
00163 
00164 class sc_fxnum_fast_bitref
00165 {
00166     friend class sc_fxnum_fast;
00167     friend class sc_fxnum_bitref;
00168 
00169 
00170     bool get() const;
00171     void set( bool );
00172 
00173 
00174     
00175 
00176     sc_fxnum_fast_bitref( sc_fxnum_fast&, int );
00177 
00178 public:
00179 
00180     
00181 
00182     sc_fxnum_fast_bitref( const sc_fxnum_fast_bitref& );
00183 
00184 
00185     
00186 
00187 #define DECL_ASN_OP_T(op,tp)                                                  \
00188     sc_fxnum_fast_bitref& operator op ( tp );
00189 
00190 #define DECL_ASN_OP(op)                                                       \
00191     DECL_ASN_OP_T(op,const sc_fxnum_bitref&)                                  \
00192     DECL_ASN_OP_T(op,const sc_fxnum_fast_bitref&)                             \
00193     DECL_ASN_OP_T(op,const sc_bit&)                                           \
00194     DECL_ASN_OP_T(op,bool)
00195 
00196     DECL_ASN_OP(=)
00197 
00198     DECL_ASN_OP(&=)
00199     DECL_ASN_OP(|=)
00200     DECL_ASN_OP(^=)
00201 
00202 #undef DECL_ASN_OP_T
00203 #undef DECL_ASN_OP
00204 
00205 
00206     
00207 
00208     operator bool() const;
00209 
00210 
00211     
00212 
00213     void print( ::std::ostream& = ::std::cout ) const;
00214     void scan( ::std::istream& = ::std::cin );
00215     void dump( ::std::ostream& = ::std::cout ) const;
00216 
00217 private:
00218 
00219     sc_fxnum_fast& m_num;
00220     int            m_idx;
00221 
00222 private:
00223 
00224     
00225     sc_fxnum_fast_bitref();
00226 };
00227 
00228 
00229 
00230 
00231 
00232 
00233 
00234 
00235 
00236 class sc_fxnum_subref
00237 {
00238     friend class sc_fxnum;
00239     friend class sc_fxnum_fast_subref;
00240 
00241     bool get() const;
00242     bool set();
00243 
00244 
00245     
00246 
00247     sc_fxnum_subref( sc_fxnum&, int, int );
00248 
00249 public:
00250 
00251     
00252 
00253     sc_fxnum_subref( const sc_fxnum_subref& );
00254 
00255 
00256     
00257 
00258     ~sc_fxnum_subref();
00259 
00260 
00261     
00262 
00263 #define DECL_ASN_OP_T(tp)                                                     \
00264     sc_fxnum_subref& operator = ( tp );
00265 
00266     DECL_ASN_OP_T(const sc_fxnum_subref&)
00267     DECL_ASN_OP_T(const sc_fxnum_fast_subref&)
00268     DECL_ASN_OP_T(const sc_bv_base&)
00269     DECL_ASN_OP_T(const sc_lv_base&)
00270     DECL_ASN_OP_T(const char*)
00271     DECL_ASN_OP_T(const bool*)
00272     DECL_ASN_OP_T(const sc_signed&)
00273     DECL_ASN_OP_T(const sc_unsigned&)
00274     DECL_ASN_OP_T(const sc_int_base&)
00275     DECL_ASN_OP_T(const sc_uint_base&)
00276     DECL_ASN_OP_T(int64)
00277     DECL_ASN_OP_T(uint64)
00278     DECL_ASN_OP_T(int)
00279     DECL_ASN_OP_T(unsigned int)
00280     DECL_ASN_OP_T(long)
00281     DECL_ASN_OP_T(unsigned long)
00282     DECL_ASN_OP_T(char)
00283 
00284 #undef DECL_ASN_OP_T
00285 
00286 #define DECL_ASN_OP_T_A(op,tp)                                                \
00287     sc_fxnum_subref& operator op ## = ( tp );
00288 
00289 #define DECL_ASN_OP_A(op)                                                     \
00290     DECL_ASN_OP_T_A(op,const sc_fxnum_subref&)                                \
00291     DECL_ASN_OP_T_A(op,const sc_fxnum_fast_subref&)                           \
00292     DECL_ASN_OP_T_A(op,const sc_bv_base&)                                     \
00293     DECL_ASN_OP_T_A(op,const sc_lv_base&)
00294 
00295     DECL_ASN_OP_A(&)
00296     DECL_ASN_OP_A(|)
00297     DECL_ASN_OP_A(^)
00298 
00299 #undef DECL_ASN_OP_T_A
00300 #undef DECL_ASN_OP_A
00301 
00302 
00303     
00304 
00305 #define DECL_REL_OP_T(op,tp)                                                  \
00306     friend bool operator op ( const sc_fxnum_subref&, tp );                   \
00307     friend bool operator op ( tp, const sc_fxnum_subref& );
00308 
00309 #define DECL_REL_OP(op)                                                       \
00310     friend bool operator op ( const sc_fxnum_subref&,                         \
00311                               const sc_fxnum_subref& );                       \
00312     friend bool operator op ( const sc_fxnum_subref&,                         \
00313                               const sc_fxnum_fast_subref& );                  \
00314     DECL_REL_OP_T(op,const sc_bv_base&)                                       \
00315     DECL_REL_OP_T(op,const sc_lv_base&)                                       \
00316     DECL_REL_OP_T(op,const char*)                                             \
00317     DECL_REL_OP_T(op,const bool*)                                             \
00318     DECL_REL_OP_T(op,const sc_signed&)                                        \
00319     DECL_REL_OP_T(op,const sc_unsigned&)                                      \
00320     DECL_REL_OP_T(op,int)                                                     \
00321     DECL_REL_OP_T(op,unsigned int)                                            \
00322     DECL_REL_OP_T(op,long)                                                    \
00323     DECL_REL_OP_T(op,unsigned long)
00324 
00325     DECL_REL_OP(==)
00326     DECL_REL_OP(!=)
00327 
00328 #undef DECL_REL_OP_T
00329 #undef DECL_REL_OP
00330 
00331 
00332     
00333 
00334     bool and_reduce() const;
00335     bool nand_reduce() const;
00336     bool or_reduce() const;
00337     bool nor_reduce() const;
00338     bool xor_reduce() const;
00339     bool xnor_reduce() const;
00340 
00341 
00342     
00343 
00344     int length() const;
00345 
00346 
00347     
00348 
00349     int           to_int() const;
00350     unsigned int  to_uint() const;
00351     long          to_long() const;
00352     unsigned long to_ulong() const;
00353     int64         to_int64() const;
00354     uint64        to_uint64() const;
00355 
00356 #ifdef SC_DT_DEPRECATED
00357     int           to_signed() const;
00358     unsigned int  to_unsigned() const;
00359 #endif
00360 
00361     const std::string to_string() const;
00362     const std::string to_string( sc_numrep ) const;
00363     const std::string to_string( sc_numrep, bool ) const;
00364 
00365 
00366     
00367 
00368     operator sc_bv_base() const;
00369 
00370 
00371     
00372 
00373     void print( ::std::ostream& = ::std::cout ) const;
00374     void scan( ::std::istream& = ::std::cin );
00375     void dump( ::std::ostream& = ::std::cout ) const;
00376 
00377 private:
00378 
00379     sc_fxnum& m_num;
00380     int       m_from;
00381     int       m_to;
00382 
00383     sc_bv_base& m_bv;
00384 
00385 private:
00386 
00387     
00388     sc_fxnum_subref();
00389 };
00390 
00391 
00392 
00393 
00394 
00395 
00396 
00397 
00398 
00399 class sc_fxnum_fast_subref
00400 {
00401     friend class sc_fxnum_fast;
00402     friend class sc_fxnum_subref;
00403 
00404     bool get() const;
00405     bool set();
00406 
00407 
00408     
00409 
00410     sc_fxnum_fast_subref( sc_fxnum_fast&, int, int );
00411 
00412 public:
00413 
00414     
00415 
00416     sc_fxnum_fast_subref( const sc_fxnum_fast_subref& );
00417 
00418 
00419     
00420 
00421     ~sc_fxnum_fast_subref();
00422 
00423 
00424     
00425 
00426 #define DECL_ASN_OP_T(tp)                                                     \
00427     sc_fxnum_fast_subref& operator = ( tp );
00428 
00429     DECL_ASN_OP_T(const sc_fxnum_subref&)
00430     DECL_ASN_OP_T(const sc_fxnum_fast_subref&)
00431     DECL_ASN_OP_T(const sc_bv_base&)
00432     DECL_ASN_OP_T(const sc_lv_base&)
00433     DECL_ASN_OP_T(const char*)
00434     DECL_ASN_OP_T(const bool*)
00435     DECL_ASN_OP_T(const sc_signed&)
00436     DECL_ASN_OP_T(const sc_unsigned&)
00437     DECL_ASN_OP_T(const sc_int_base&)
00438     DECL_ASN_OP_T(const sc_uint_base&)
00439     DECL_ASN_OP_T(int64)
00440     DECL_ASN_OP_T(uint64)
00441     DECL_ASN_OP_T(int)
00442     DECL_ASN_OP_T(unsigned int)
00443     DECL_ASN_OP_T(long)
00444     DECL_ASN_OP_T(unsigned long)
00445     DECL_ASN_OP_T(char)
00446 
00447 #undef DECL_ASN_OP_T
00448 
00449 #define DECL_ASN_OP_T_A(op,tp)                                                \
00450     sc_fxnum_fast_subref& operator op ## = ( tp );
00451 
00452 #define DECL_ASN_OP_A(op)                                                     \
00453     DECL_ASN_OP_T_A(op,const sc_fxnum_subref&)                                \
00454     DECL_ASN_OP_T_A(op,const sc_fxnum_fast_subref&)                           \
00455     DECL_ASN_OP_T_A(op,const sc_bv_base&)                                     \
00456     DECL_ASN_OP_T_A(op,const sc_lv_base&)
00457 
00458     DECL_ASN_OP_A(&)
00459     DECL_ASN_OP_A(|)
00460     DECL_ASN_OP_A(^)
00461 
00462 #undef DECL_ASN_OP_T_A
00463 #undef DECL_ASN_OP_A
00464 
00465 
00466     
00467 
00468 #define DECL_REL_OP_T(op,tp)                                                  \
00469     friend bool operator op ( const sc_fxnum_fast_subref&, tp );              \
00470     friend bool operator op ( tp, const sc_fxnum_fast_subref& );
00471 
00472 #define DECL_REL_OP(op)                                                       \
00473     friend bool operator op ( const sc_fxnum_fast_subref&,                    \
00474                               const sc_fxnum_fast_subref& );                  \
00475     friend bool operator op ( const sc_fxnum_fast_subref&,                    \
00476                               const sc_fxnum_subref& );                       \
00477     DECL_REL_OP_T(op,const sc_bv_base&)                                       \
00478     DECL_REL_OP_T(op,const sc_lv_base&)                                       \
00479     DECL_REL_OP_T(op,const char*)                                             \
00480     DECL_REL_OP_T(op,const bool*)                                             \
00481     DECL_REL_OP_T(op,const sc_signed&)                                        \
00482     DECL_REL_OP_T(op,const sc_unsigned&)                                      \
00483     DECL_REL_OP_T(op,int)                                                     \
00484     DECL_REL_OP_T(op,unsigned int)                                            \
00485     DECL_REL_OP_T(op,long)                                                    \
00486     DECL_REL_OP_T(op,unsigned long)
00487 
00488     DECL_REL_OP(==)
00489     DECL_REL_OP(!=)
00490 
00491 #undef DECL_REL_OP_T
00492 #undef DECL_REL_OP
00493 
00494 
00495     
00496 
00497     bool and_reduce() const;
00498     bool nand_reduce() const;
00499     bool or_reduce() const;
00500     bool nor_reduce() const;
00501     bool xor_reduce() const;
00502     bool xnor_reduce() const;
00503 
00504 
00505     
00506 
00507     int length() const;
00508 
00509 
00510     
00511 
00512     int           to_int() const;
00513     unsigned int  to_uint() const;
00514     long          to_long() const;
00515     unsigned long to_ulong() const;
00516     int64         to_int64() const;
00517     uint64        to_uint64() const;
00518 
00519 #ifdef SC_DT_DEPRECATED
00520     int           to_signed() const;
00521     unsigned int  to_unsigned() const;
00522 #endif
00523 
00524     const std::string to_string() const;
00525     const std::string to_string( sc_numrep ) const;
00526     const std::string to_string( sc_numrep, bool ) const;
00527 
00528 
00529     
00530 
00531     operator sc_bv_base() const;
00532 
00533 
00534     
00535 
00536     void print( ::std::ostream& = ::std::cout ) const;
00537     void scan( ::std::istream& = ::std::cin );
00538     void dump( ::std::ostream& = ::std::cout ) const;
00539 
00540 private:
00541 
00542     sc_fxnum_fast& m_num;
00543     int            m_from;
00544     int            m_to;
00545 
00546     sc_bv_base& m_bv;
00547 
00548 private:
00549 
00550     
00551     sc_fxnum_fast_subref();
00552 };
00553 
00554 
00555 
00556 
00557 
00558 
00559 
00560 
00561 class sc_fxnum
00562 {
00563     friend class sc_fxval;
00564 
00565     friend class sc_fxnum_bitref;
00566     friend class sc_fxnum_subref;
00567     friend class sc_fxnum_fast_bitref;
00568     friend class sc_fxnum_fast_subref;
00569 
00570     friend class sc_core::vcd_sc_fxnum_trace;
00571     friend class sc_core::wif_sc_fxnum_trace;
00572 
00573 protected:
00574 
00575     sc_fxnum_observer* observer() const;
00576 
00577 
00578     void cast();
00579 
00580 
00581     
00582 
00583     sc_fxnum( const sc_fxtype_params&,
00584               sc_enc,
00585               const sc_fxcast_switch&,
00586               sc_fxnum_observer* );
00587 
00588 #define DECL_CTOR_T(tp)                                                       \
00589     sc_fxnum( tp,                                                             \
00590               const sc_fxtype_params&,                                        \
00591               sc_enc,                                                         \
00592               const sc_fxcast_switch&,                                        \
00593               sc_fxnum_observer* );
00594 
00595     DECL_CTOR_T(int)
00596     DECL_CTOR_T(unsigned int)
00597     DECL_CTOR_T(long)
00598     DECL_CTOR_T(unsigned long)
00599     DECL_CTOR_T(float)
00600     DECL_CTOR_T(double)
00601     DECL_CTOR_T(const char*)
00602     DECL_CTOR_T(const sc_fxval&)
00603     DECL_CTOR_T(const sc_fxval_fast&)
00604     DECL_CTOR_T(const sc_fxnum&)
00605     DECL_CTOR_T(const sc_fxnum_fast&)
00606 #ifndef SC_FX_EXCLUDE_OTHER
00607     DECL_CTOR_T(int64)
00608     DECL_CTOR_T(uint64)
00609     DECL_CTOR_T(const sc_int_base&)
00610     DECL_CTOR_T(const sc_uint_base&)
00611     DECL_CTOR_T(const sc_signed&)
00612     DECL_CTOR_T(const sc_unsigned&)
00613 #endif
00614 
00615 #undef DECL_CTOR_T
00616 
00617     ~sc_fxnum();
00618 
00619 
00620     
00621     const scfx_rep* get_rep() const;
00622 
00623 public:
00624 
00625     
00626 
00627     const sc_fxval operator - () const;
00628     const sc_fxval operator + () const;
00629 
00630 
00631     
00632 
00633     friend void neg( sc_fxval&, const sc_fxnum& );
00634     friend void neg( sc_fxnum&, const sc_fxnum& );
00635 
00636 
00637     
00638 
00639 #define DECL_BIN_OP_T(op,tp)                                                  \
00640     friend const sc_fxval operator op ( const sc_fxnum&, tp );                \
00641     friend const sc_fxval operator op ( tp, const sc_fxnum& );
00642 
00643 #ifndef SC_FX_EXCLUDE_OTHER
00644 #define DECL_BIN_OP_OTHER(op)                                                 \
00645     DECL_BIN_OP_T(op,int64)                                                   \
00646     DECL_BIN_OP_T(op,uint64)                                                  \
00647     DECL_BIN_OP_T(op,const sc_int_base&)                                      \
00648     DECL_BIN_OP_T(op,const sc_uint_base&)                                     \
00649     DECL_BIN_OP_T(op,const sc_signed&)                                        \
00650     DECL_BIN_OP_T(op,const sc_unsigned&)
00651 #else
00652 #define DECL_BIN_OP_OTHER(op)
00653 #endif
00654 
00655 #define DECL_BIN_OP(op,dummy)                                                 \
00656     friend const sc_fxval operator op ( const sc_fxnum&, const sc_fxnum& );   \
00657     DECL_BIN_OP_T(op,int)                                                     \
00658     DECL_BIN_OP_T(op,unsigned int)                                            \
00659     DECL_BIN_OP_T(op,long)                                                    \
00660     DECL_BIN_OP_T(op,unsigned long)                                           \
00661     DECL_BIN_OP_T(op,float)                                                  \
00662     DECL_BIN_OP_T(op,double)                                                  \
00663     DECL_BIN_OP_T(op,const char*)                                             \
00664     DECL_BIN_OP_T(op,const sc_fxval&)                                         \
00665     DECL_BIN_OP_T(op,const sc_fxval_fast&)                                    \
00666     DECL_BIN_OP_T(op,const sc_fxnum_fast&)                                    \
00667     DECL_BIN_OP_OTHER(op)
00668 
00669     DECL_BIN_OP(*,mult)
00670     DECL_BIN_OP(+,add)
00671     DECL_BIN_OP(-,sub)
00672 
00673 
00674     friend const sc_fxval operator / ( const sc_fxnum&, const sc_fxnum& );
00675     DECL_BIN_OP_T(/,int)
00676     DECL_BIN_OP_T(/,unsigned int)
00677     DECL_BIN_OP_T(/,long)
00678     DECL_BIN_OP_T(/,unsigned long)
00679     DECL_BIN_OP_T(/,float)
00680     DECL_BIN_OP_T(/,double)
00681     DECL_BIN_OP_T(/,const char*)
00682     DECL_BIN_OP_T(/,const sc_fxval&)
00683     DECL_BIN_OP_T(/,const sc_fxval_fast&)
00684     DECL_BIN_OP_T(/,const sc_fxnum_fast&)
00685 
00686 #ifndef SC_FX_EXCLUDE_OTHER
00687     DECL_BIN_OP_T(/,int64)
00688     DECL_BIN_OP_T(/,uint64)
00689     DECL_BIN_OP_T(/,const sc_int_base&)
00690     DECL_BIN_OP_T(/,const sc_uint_base&)
00691     DECL_BIN_OP_T(/,const sc_signed&)
00692     DECL_BIN_OP_T(/,const sc_unsigned&)
00693 #endif
00694 
00695 #undef DECL_BIN_OP_T
00696 #undef DECL_BIN_OP_OTHER
00697 #undef DECL_BIN_OP
00698 
00699     friend const sc_fxval operator << ( const sc_fxnum&, int );
00700     friend const sc_fxval operator >> ( const sc_fxnum&, int );
00701 
00702 
00703     
00704 
00705 #define DECL_BIN_FNC_T(fnc,tp)                                                \
00706     friend void fnc ( sc_fxval&, const sc_fxnum&, tp );                       \
00707     friend void fnc ( sc_fxval&, tp, const sc_fxnum& );                       \
00708     friend void fnc ( sc_fxnum&, const sc_fxnum&, tp );                       \
00709     friend void fnc ( sc_fxnum&, tp, const sc_fxnum& );
00710 
00711 #ifndef SC_FX_EXCLUDE_OTHER
00712 #define DECL_BIN_FNC_OTHER(fnc)                                               \
00713     DECL_BIN_FNC_T(fnc,int64)                                                 \
00714     DECL_BIN_FNC_T(fnc,uint64)                                                \
00715     DECL_BIN_FNC_T(fnc,const sc_int_base&)                                    \
00716     DECL_BIN_FNC_T(fnc,const sc_uint_base&)                                   \
00717     DECL_BIN_FNC_T(fnc,const sc_signed&)                                      \
00718     DECL_BIN_FNC_T(fnc,const sc_unsigned&)
00719 #else
00720 #define DECL_BIN_FNC_OTHER(fnc)
00721 #endif
00722 
00723 #define DECL_BIN_FNC(fnc)                                                     \
00724     friend void fnc ( sc_fxval&, const sc_fxnum&, const sc_fxnum& );          \
00725     friend void fnc ( sc_fxnum&, const sc_fxnum&, const sc_fxnum& );          \
00726     DECL_BIN_FNC_T(fnc,int)                                                   \
00727     DECL_BIN_FNC_T(fnc,unsigned int)                                          \
00728     DECL_BIN_FNC_T(fnc,long)                                                  \
00729     DECL_BIN_FNC_T(fnc,unsigned long)                                         \
00730     DECL_BIN_FNC_T(fnc,float)                                                \
00731     DECL_BIN_FNC_T(fnc,double)                                                \
00732     DECL_BIN_FNC_T(fnc,const char*)                                           \
00733     DECL_BIN_FNC_T(fnc,const sc_fxval&)                                       \
00734     DECL_BIN_FNC_T(fnc,const sc_fxval_fast&)                                  \
00735     DECL_BIN_FNC_T(fnc,const sc_fxnum_fast&)                                  \
00736     DECL_BIN_FNC_OTHER(fnc)
00737 
00738     DECL_BIN_FNC(mult)
00739     DECL_BIN_FNC(div)
00740     DECL_BIN_FNC(add)
00741     DECL_BIN_FNC(sub)
00742 
00743 #undef DECL_BIN_FNC_T
00744 #undef DECL_BIN_FNC_OTHER
00745 #undef DECL_BIN_FNC
00746 
00747     friend void lshift( sc_fxval&, const sc_fxnum&, int );
00748     friend void rshift( sc_fxval&, const sc_fxnum&, int );
00749     friend void lshift( sc_fxnum&, const sc_fxnum&, int );
00750     friend void rshift( sc_fxnum&, const sc_fxnum&, int );
00751 
00752 
00753     
00754 
00755 #define DECL_REL_OP_T(op,tp)                                                  \
00756     friend bool operator op ( const sc_fxnum&, tp );                          \
00757     friend bool operator op ( tp, const sc_fxnum& );
00758 
00759 #ifndef SC_FX_EXCLUDE_OTHER
00760 #define DECL_REL_OP_OTHER(op)                                                 \
00761     DECL_REL_OP_T(op,int64)                                                   \
00762     DECL_REL_OP_T(op,uint64)                                                  \
00763     DECL_REL_OP_T(op,const sc_int_base&)                                      \
00764     DECL_REL_OP_T(op,const sc_uint_base&)                                     \
00765     DECL_REL_OP_T(op,const sc_signed&)                                        \
00766     DECL_REL_OP_T(op,const sc_unsigned&)
00767 #else
00768 #define DECL_REL_OP_OTHER(op)
00769 #endif
00770 
00771 #define DECL_REL_OP(op)                                                       \
00772     friend bool operator op ( const sc_fxnum&, const sc_fxnum& );             \
00773     DECL_REL_OP_T(op,int)                                                     \
00774     DECL_REL_OP_T(op,unsigned int)                                            \
00775     DECL_REL_OP_T(op,long)                                                    \
00776     DECL_REL_OP_T(op,unsigned long)                                           \
00777     DECL_REL_OP_T(op,float)                                                  \
00778     DECL_REL_OP_T(op,double)                                                  \
00779     DECL_REL_OP_T(op,const char*)                                             \
00780     DECL_REL_OP_T(op,const sc_fxval&)                                         \
00781     DECL_REL_OP_T(op,const sc_fxval_fast&)                                    \
00782     DECL_REL_OP_T(op,const sc_fxnum_fast&)                                    \
00783     DECL_REL_OP_OTHER(op)
00784 
00785     DECL_REL_OP(<)
00786     DECL_REL_OP(<=)
00787     DECL_REL_OP(>)
00788     DECL_REL_OP(>=)
00789     DECL_REL_OP(==)
00790     DECL_REL_OP(!=)
00791 
00792 #undef DECL_REL_OP_T
00793 #undef DECL_REL_OP_OTHER
00794 #undef DECL_REL_OP
00795 
00796 
00797     
00798 
00799 #define DECL_ASN_OP_T(op,tp)                                                  \
00800     sc_fxnum& operator op( tp );
00801 
00802 #ifndef SC_FX_EXCLUDE_OTHER
00803 #define DECL_ASN_OP_OTHER(op)                                                 \
00804     DECL_ASN_OP_T(op,int64)                                                   \
00805     DECL_ASN_OP_T(op,uint64)                                                  \
00806     DECL_ASN_OP_T(op,const sc_int_base&)                                      \
00807     DECL_ASN_OP_T(op,const sc_uint_base&)                                     \
00808     DECL_ASN_OP_T(op,const sc_signed&)                                        \
00809     DECL_ASN_OP_T(op,const sc_unsigned&)
00810 #else
00811 #define DECL_ASN_OP_OTHER(op)
00812 #endif
00813 
00814 #define DECL_ASN_OP(op)                                                       \
00815     DECL_ASN_OP_T(op,int)                                                     \
00816     DECL_ASN_OP_T(op,unsigned int)                                            \
00817     DECL_ASN_OP_T(op,long)                                                    \
00818     DECL_ASN_OP_T(op,unsigned long)                                           \
00819     DECL_ASN_OP_T(op,float)                                                  \
00820     DECL_ASN_OP_T(op,double)                                                  \
00821     DECL_ASN_OP_T(op,const char*)                                             \
00822     DECL_ASN_OP_T(op,const sc_fxval&)                                         \
00823     DECL_ASN_OP_T(op,const sc_fxval_fast&)                                    \
00824     DECL_ASN_OP_T(op,const sc_fxnum&)                                         \
00825     DECL_ASN_OP_T(op,const sc_fxnum_fast&)                                    \
00826     DECL_ASN_OP_OTHER(op)
00827 
00828     DECL_ASN_OP(=)
00829 
00830     DECL_ASN_OP(*=)
00831     DECL_ASN_OP(/=)
00832     DECL_ASN_OP(+=)
00833     DECL_ASN_OP(-=)
00834 
00835     DECL_ASN_OP_T(<<=,int)
00836     DECL_ASN_OP_T(>>=,int)
00837 
00838 #undef DECL_ASN_OP_T
00839 #undef DECL_ASN_OP_OTHER
00840 #undef DECL_ASN_OP
00841 
00842 
00843     
00844 
00845     const sc_fxval operator ++ ( int );
00846     const sc_fxval operator -- ( int );
00847 
00848     sc_fxnum& operator ++ ();
00849     sc_fxnum& operator -- ();
00850 
00851 
00852     
00853 
00854     const sc_fxnum_bitref operator [] ( int ) const;
00855     sc_fxnum_bitref       operator [] ( int );
00856 
00857     const sc_fxnum_bitref bit( int ) const;
00858     sc_fxnum_bitref       bit( int );
00859 
00860 
00861     
00862 
00863     const sc_fxnum_subref operator () ( int, int ) const;
00864     sc_fxnum_subref       operator () ( int, int );
00865 
00866     const sc_fxnum_subref range( int, int ) const;
00867     sc_fxnum_subref       range( int, int );
00868 
00869 
00870     const sc_fxnum_subref operator () () const;
00871     sc_fxnum_subref       operator () ();
00872 
00873     const sc_fxnum_subref range() const;
00874     sc_fxnum_subref       range();
00875 
00876 
00877     
00878 
00879     operator double() const;            
00880 
00881 
00882     
00883 
00884     short          to_short() const;
00885     unsigned short to_ushort() const;
00886     int            to_int() const;
00887     unsigned int   to_uint() const;
00888     long           to_long() const;
00889     unsigned long  to_ulong() const;
00890     int64          to_int64() const;
00891     uint64         to_uint64() const;
00892     float          to_float() const;
00893     double         to_double() const;
00894 
00895 
00896     
00897 
00898     const std::string to_string() const;
00899     const std::string to_string( sc_numrep ) const;
00900     const std::string to_string( sc_numrep, bool ) const;
00901     const std::string to_string( sc_fmt ) const;
00902     const std::string to_string( sc_numrep, sc_fmt ) const;
00903     const std::string to_string( sc_numrep, bool, sc_fmt ) const;
00904 
00905     const std::string to_dec() const;
00906     const std::string to_bin() const;
00907     const std::string to_oct() const;
00908     const std::string to_hex() const;
00909 
00910 
00911     
00912 
00913     bool is_neg() const;
00914     bool is_zero() const;
00915 
00916     
00917     bool is_normal() const;
00918 
00919     bool quantization_flag() const;
00920     bool overflow_flag() const;
00921 
00922     const sc_fxval value() const;
00923 
00924 
00925     
00926 
00927     int       wl() const;
00928     int       iwl() const;
00929     sc_q_mode q_mode() const;
00930     sc_o_mode o_mode() const;
00931     int       n_bits() const;
00932 
00933     const sc_fxtype_params& type_params() const;
00934 
00935     const sc_fxcast_switch& cast_switch() const;
00936 
00937 
00938     
00939 
00940     void print( ::std::ostream& = ::std::cout ) const;
00941     void scan( ::std::istream& = ::std::cin );
00942     void dump( ::std::ostream& = ::std::cout ) const;
00943 
00944 
00945     
00946     void observer_read() const;
00947 
00948 
00949     
00950     bool get_bit( int ) const;
00951 
00952 protected:
00953 
00954     bool set_bit( int, bool );
00955 
00956 
00957     bool get_slice( int, int, sc_bv_base& ) const;
00958     bool set_slice( int, int, const sc_bv_base& );
00959 
00960 
00961     sc_fxnum_observer* lock_observer() const;
00962     void unlock_observer( sc_fxnum_observer* ) const;
00963 
00964 private:
00965 
00966     scfx_rep*                  m_rep;
00967 
00968     scfx_params                m_params;
00969     bool                       m_q_flag;
00970     bool                       m_o_flag;
00971 
00972     mutable sc_fxnum_observer* m_observer;
00973 
00974 private:
00975 
00976     
00977     sc_fxnum();
00978     sc_fxnum( const sc_fxnum& );
00979 };
00980 
00981 
00982 
00983 
00984 
00985 
00986 
00987 
00988 class sc_fxnum_fast
00989 {
00990     friend class sc_fxval_fast;
00991 
00992     friend class sc_fxnum_bitref;
00993     friend class sc_fxnum_subref;
00994     friend class sc_fxnum_fast_bitref;
00995     friend class sc_fxnum_fast_subref;
00996 
00997     friend class sc_core::vcd_sc_fxnum_fast_trace;
00998     friend class sc_core::wif_sc_fxnum_fast_trace;
00999 
01000 protected:
01001 
01002     sc_fxnum_fast_observer* observer() const;
01003 
01004 
01005     void cast();
01006 
01007 
01008     
01009 
01010     sc_fxnum_fast( const sc_fxtype_params&,
01011                    sc_enc,
01012                    const sc_fxcast_switch&,
01013                    sc_fxnum_fast_observer* );
01014 
01015 #define DECL_CTOR_T(tp)                                                       \
01016     sc_fxnum_fast( tp,                                                        \
01017                    const sc_fxtype_params&,                                   \
01018                    sc_enc,                                                    \
01019                    const sc_fxcast_switch&,                                   \
01020                    sc_fxnum_fast_observer* );
01021 
01022     DECL_CTOR_T(int)
01023     DECL_CTOR_T(unsigned int)
01024     DECL_CTOR_T(long)
01025     DECL_CTOR_T(unsigned long)
01026     DECL_CTOR_T(float)
01027     DECL_CTOR_T(double)
01028     DECL_CTOR_T(const char*)
01029     DECL_CTOR_T(const sc_fxval&)
01030     DECL_CTOR_T(const sc_fxval_fast&)
01031     DECL_CTOR_T(const sc_fxnum&)
01032     DECL_CTOR_T(const sc_fxnum_fast&)
01033 #ifndef SC_FX_EXCLUDE_OTHER
01034     DECL_CTOR_T(int64)
01035     DECL_CTOR_T(uint64)
01036     DECL_CTOR_T(const sc_int_base&)
01037     DECL_CTOR_T(const sc_uint_base&)
01038     DECL_CTOR_T(const sc_signed&)
01039     DECL_CTOR_T(const sc_unsigned&)
01040 #endif
01041 
01042 #undef DECL_CTOR_T
01043 
01044     ~sc_fxnum_fast();
01045 
01046 
01047     
01048     double get_val() const;
01049 
01050 public:
01051 
01052     
01053 
01054     const sc_fxval_fast operator - () const;
01055     const sc_fxval_fast operator + () const;
01056 
01057 
01058     
01059 
01060     friend void neg( sc_fxval_fast&, const sc_fxnum_fast& );
01061     friend void neg( sc_fxnum_fast&, const sc_fxnum_fast& );
01062 
01063 
01064     
01065 
01066 #define DECL_BIN_OP_T(op,tp)                                                  \
01067     friend const sc_fxval_fast operator op ( const sc_fxnum_fast&, tp );      \
01068     friend const sc_fxval_fast operator op ( tp, const sc_fxnum_fast& );
01069 
01070 #ifndef SC_FX_EXCLUDE_OTHER
01071 #define DECL_BIN_OP_OTHER(op)                                                 \
01072     DECL_BIN_OP_T(op,int64)                                                   \
01073     DECL_BIN_OP_T(op,uint64)                                                  \
01074     DECL_BIN_OP_T(op,const sc_int_base&)                                      \
01075     DECL_BIN_OP_T(op,const sc_uint_base&)                                     \
01076     DECL_BIN_OP_T(op,const sc_signed&)                                        \
01077     DECL_BIN_OP_T(op,const sc_unsigned&)
01078 #else
01079 #define DECL_BIN_OP_OTHER(op)
01080 #endif
01081 
01082 #define DECL_BIN_OP(op,dummy)                                                 \
01083     friend const sc_fxval_fast operator op ( const sc_fxnum_fast&,            \
01084                                              const sc_fxnum_fast& );          \
01085     DECL_BIN_OP_T(op,int)                                                     \
01086     DECL_BIN_OP_T(op,unsigned int)                                            \
01087     DECL_BIN_OP_T(op,long)                                                    \
01088     DECL_BIN_OP_T(op,unsigned long)                                           \
01089     DECL_BIN_OP_T(op,float)                                                  \
01090     DECL_BIN_OP_T(op,double)                                                  \
01091     DECL_BIN_OP_T(op,const char*)                                             \
01092     DECL_BIN_OP_T(op,const sc_fxval_fast&)                                    \
01093     DECL_BIN_OP_OTHER(op)
01094 
01095     DECL_BIN_OP(*,mult)
01096     DECL_BIN_OP(+,add)
01097     DECL_BIN_OP(-,sub)
01098 
01099     friend const sc_fxval_fast operator / ( const sc_fxnum_fast&,
01100                                              const sc_fxnum_fast& );
01101     DECL_BIN_OP_T(/,int)
01102     DECL_BIN_OP_T(/,unsigned int)
01103     DECL_BIN_OP_T(/,long)
01104     DECL_BIN_OP_T(/,unsigned long)
01105     DECL_BIN_OP_T(/,float)
01106     DECL_BIN_OP_T(/,double)
01107     DECL_BIN_OP_T(/,const char*)
01108     DECL_BIN_OP_T(/,const sc_fxval_fast&)
01109 
01110 #ifndef SC_FX_EXCLUDE_OTHER
01111     DECL_BIN_OP_T(/,int64)                                                   \
01112     DECL_BIN_OP_T(/,uint64)                                                  \
01113     DECL_BIN_OP_T(/,const sc_int_base&)                                      \
01114     DECL_BIN_OP_T(/,const sc_uint_base&)                                     \
01115     DECL_BIN_OP_T(/,const sc_signed&)                                        \
01116     DECL_BIN_OP_T(/,const sc_unsigned&)
01117 #endif
01118 
01119 #undef DECL_BIN_OP_T
01120 #undef DECL_BIN_OP_OTHER
01121 #undef DECL_BIN_OP
01122 
01123     friend const sc_fxval_fast operator << ( const sc_fxnum_fast&, int );
01124     friend const sc_fxval_fast operator >> ( const sc_fxnum_fast&, int );
01125 
01126 
01127     
01128 
01129 #define DECL_BIN_FNC_T(fnc,tp)                                                \
01130     friend void fnc ( sc_fxval_fast&, const sc_fxnum_fast&, tp );             \
01131     friend void fnc ( sc_fxval_fast&, tp, const sc_fxnum_fast& );             \
01132     friend void fnc ( sc_fxnum_fast&, const sc_fxnum_fast&, tp );             \
01133     friend void fnc ( sc_fxnum_fast&, tp, const sc_fxnum_fast& );
01134 
01135 #ifndef SC_FX_EXCLUDE_OTHER
01136 #define DECL_BIN_FNC_OTHER(fnc)                                               \
01137     DECL_BIN_FNC_T(fnc,int64)                                                 \
01138     DECL_BIN_FNC_T(fnc,uint64)                                                \
01139     DECL_BIN_FNC_T(fnc,const sc_int_base&)                                    \
01140     DECL_BIN_FNC_T(fnc,const sc_uint_base&)                                   \
01141     DECL_BIN_FNC_T(fnc,const sc_signed&)                                      \
01142     DECL_BIN_FNC_T(fnc,const sc_unsigned&)
01143 #else
01144 #define DECL_BIN_FNC_OTHER(fnc)
01145 #endif
01146 
01147 #define DECL_BIN_FNC(fnc)                                                     \
01148     friend void fnc ( sc_fxval_fast&, const sc_fxnum_fast&,                   \
01149                                       const sc_fxnum_fast& );                 \
01150     friend void fnc ( sc_fxnum_fast&, const sc_fxnum_fast&,                   \
01151                                       const sc_fxnum_fast& );                 \
01152     DECL_BIN_FNC_T(fnc,int)                                                   \
01153     DECL_BIN_FNC_T(fnc,unsigned int)                                          \
01154     DECL_BIN_FNC_T(fnc,long)                                                  \
01155     DECL_BIN_FNC_T(fnc,unsigned long)                                         \
01156     DECL_BIN_FNC_T(fnc,float)                                                \
01157     DECL_BIN_FNC_T(fnc,double)                                                \
01158     DECL_BIN_FNC_T(fnc,const char*)                                           \
01159     DECL_BIN_FNC_T(fnc,const sc_fxval&)                                       \
01160     DECL_BIN_FNC_T(fnc,const sc_fxval_fast&)                                  \
01161     DECL_BIN_FNC_T(fnc,const sc_fxnum&)                                       \
01162     DECL_BIN_FNC_OTHER(fnc)
01163 
01164     DECL_BIN_FNC(mult)
01165     DECL_BIN_FNC(div)
01166     DECL_BIN_FNC(add)
01167     DECL_BIN_FNC(sub)
01168 
01169 #undef DECL_BIN_FNC_T
01170 #undef DECL_BIN_FNC_OTHER
01171 #undef DECL_BIN_FNC
01172 
01173     friend void lshift( sc_fxval_fast&, const sc_fxnum_fast&, int );
01174     friend void rshift( sc_fxval_fast&, const sc_fxnum_fast&, int );
01175     friend void lshift( sc_fxnum_fast&, const sc_fxnum_fast&, int );
01176     friend void rshift( sc_fxnum_fast&, const sc_fxnum_fast&, int );
01177 
01178 
01179     
01180 
01181 #define DECL_REL_OP_T(op,tp)                                                  \
01182     friend bool operator op ( const sc_fxnum_fast&, tp );                     \
01183     friend bool operator op ( tp, const sc_fxnum_fast& );
01184 
01185 #ifndef SC_FX_EXCLUDE_OTHER
01186 #define DECL_REL_OP_OTHER(op)                                                 \
01187     DECL_REL_OP_T(op,int64)                                                   \
01188     DECL_REL_OP_T(op,uint64)                                                  \
01189     DECL_REL_OP_T(op,const sc_int_base&)                                      \
01190     DECL_REL_OP_T(op,const sc_uint_base&)                                     \
01191     DECL_REL_OP_T(op,const sc_signed&)                                        \
01192     DECL_REL_OP_T(op,const sc_unsigned&)
01193 #else
01194 #define DECL_REL_OP_OTHER(op)
01195 #endif
01196 
01197 #define DECL_REL_OP(op)                                                       \
01198     friend bool operator op ( const sc_fxnum_fast&, const sc_fxnum_fast& );   \
01199     DECL_REL_OP_T(op,int)                                                     \
01200     DECL_REL_OP_T(op,unsigned int)                                            \
01201     DECL_REL_OP_T(op,long)                                                    \
01202     DECL_REL_OP_T(op,unsigned long)                                           \
01203     DECL_REL_OP_T(op,float)                                                  \
01204     DECL_REL_OP_T(op,double)                                                  \
01205     DECL_REL_OP_T(op,const char*)                                             \
01206     DECL_REL_OP_T(op,const sc_fxval_fast&)                                    \
01207     DECL_REL_OP_OTHER(op)
01208 
01209     DECL_REL_OP(<)
01210     DECL_REL_OP(<=)
01211     DECL_REL_OP(>)
01212     DECL_REL_OP(>=)
01213     DECL_REL_OP(==)
01214     DECL_REL_OP(!=)
01215 
01216 #undef DECL_REL_OP_T
01217 #undef DECL_REL_OP_OTHER
01218 #undef DECL_REL_OP
01219 
01220 
01221     
01222 
01223 #define DECL_ASN_OP_T(op,tp)                                                  \
01224     sc_fxnum_fast& operator op( tp );
01225 
01226 #ifndef SC_FX_EXCLUDE_OTHER
01227 #define DECL_ASN_OP_OTHER(op)                                                 \
01228     DECL_ASN_OP_T(op,int64)                                                   \
01229     DECL_ASN_OP_T(op,uint64)                                                  \
01230     DECL_ASN_OP_T(op,const sc_int_base&)                                      \
01231     DECL_ASN_OP_T(op,const sc_uint_base&)                                     \
01232     DECL_ASN_OP_T(op,const sc_signed&)                                        \
01233     DECL_ASN_OP_T(op,const sc_unsigned&)
01234 #else
01235 #define DECL_ASN_OP_OTHER(op)
01236 #endif
01237 
01238 #define DECL_ASN_OP(op)                                                       \
01239     DECL_ASN_OP_T(op,int)                                                     \
01240     DECL_ASN_OP_T(op,unsigned int)                                            \
01241     DECL_ASN_OP_T(op,long)                                                    \
01242     DECL_ASN_OP_T(op,unsigned long)                                           \
01243     DECL_ASN_OP_T(op,float)                                                  \
01244     DECL_ASN_OP_T(op,double)                                                  \
01245     DECL_ASN_OP_T(op,const char*)                                             \
01246     DECL_ASN_OP_T(op,const sc_fxval&)                                         \
01247     DECL_ASN_OP_T(op,const sc_fxval_fast&)                                    \
01248     DECL_ASN_OP_T(op,const sc_fxnum&)                                         \
01249     DECL_ASN_OP_T(op,const sc_fxnum_fast&)                                    \
01250     DECL_ASN_OP_OTHER(op)
01251 
01252     DECL_ASN_OP(=)
01253 
01254     DECL_ASN_OP(*=)
01255     DECL_ASN_OP(/=)
01256     DECL_ASN_OP(+=)
01257     DECL_ASN_OP(-=)
01258 
01259     DECL_ASN_OP_T(<<=,int)
01260     DECL_ASN_OP_T(>>=,int)
01261 
01262 #undef DECL_ASN_OP_T
01263 #undef DECL_ASN_OP_OTHER
01264 #undef DECL_ASN_OP
01265 
01266 
01267     
01268 
01269     const sc_fxval_fast operator ++ ( int );
01270     const sc_fxval_fast operator -- ( int );
01271 
01272     sc_fxnum_fast& operator ++ ();
01273     sc_fxnum_fast& operator -- ();
01274 
01275 
01276     
01277 
01278     const sc_fxnum_fast_bitref operator [] ( int ) const;
01279     sc_fxnum_fast_bitref       operator [] ( int );
01280 
01281     const sc_fxnum_fast_bitref bit( int ) const;
01282     sc_fxnum_fast_bitref       bit( int );
01283 
01284 
01285     
01286 
01287     const sc_fxnum_fast_subref operator () ( int, int ) const;
01288     sc_fxnum_fast_subref       operator () ( int, int );
01289 
01290     const sc_fxnum_fast_subref range( int, int ) const;
01291     sc_fxnum_fast_subref       range( int, int );
01292 
01293 
01294     const sc_fxnum_fast_subref operator () () const;
01295     sc_fxnum_fast_subref       operator () ();
01296 
01297     const sc_fxnum_fast_subref range() const;
01298     sc_fxnum_fast_subref       range();
01299 
01300 
01301     
01302 
01303     operator double() const;            
01304 
01305 
01306     
01307 
01308     short          to_short() const;
01309     unsigned short to_ushort() const;
01310     int            to_int() const;
01311     unsigned int   to_uint() const;
01312     long           to_long() const;
01313     unsigned long  to_ulong() const;
01314     int64          to_int64() const;
01315     uint64         to_uint64() const;
01316     float          to_float() const;
01317     double         to_double() const;
01318 
01319 
01320     
01321 
01322     const std::string to_string() const;
01323     const std::string to_string( sc_numrep ) const;
01324     const std::string to_string( sc_numrep, bool ) const;
01325     const std::string to_string( sc_fmt ) const;
01326     const std::string to_string( sc_numrep, sc_fmt ) const;
01327     const std::string to_string( sc_numrep, bool, sc_fmt ) const;
01328 
01329     const std::string to_dec() const;
01330     const std::string to_bin() const;
01331     const std::string to_oct() const;
01332     const std::string to_hex() const;
01333 
01334 
01335     
01336 
01337     bool is_neg() const;
01338     bool is_zero() const;
01339 
01340     
01341     bool is_normal() const;
01342 
01343     bool quantization_flag() const;
01344     bool overflow_flag() const;
01345 
01346     const sc_fxval_fast value() const;
01347 
01348 
01349     
01350 
01351     int       wl() const;
01352     int       iwl() const;
01353     sc_q_mode q_mode() const;
01354     sc_o_mode o_mode() const;
01355     int       n_bits() const;
01356 
01357     const sc_fxtype_params& type_params() const;
01358 
01359     const sc_fxcast_switch& cast_switch() const;
01360 
01361 
01362     
01363 
01364     void print( ::std::ostream& = ::std::cout ) const;
01365     void scan( ::std::istream& = ::std::cin );
01366     void dump( ::std::ostream& = ::std::cout ) const;
01367 
01368 
01369     
01370     void observer_read() const;
01371 
01372 
01373     
01374     bool get_bit( int ) const;
01375 
01376 protected:
01377 
01378     bool set_bit( int, bool );
01379 
01380 
01381     bool get_slice( int, int, sc_bv_base& ) const;
01382     bool set_slice( int, int, const sc_bv_base& );
01383 
01384 
01385     sc_fxnum_fast_observer* lock_observer() const;
01386     void unlock_observer( sc_fxnum_fast_observer* ) const;
01387 
01388 private:
01389 
01390     double                          m_val;
01391 
01392     scfx_params                     m_params;
01393     bool                            m_q_flag;
01394     bool                            m_o_flag;
01395 
01396     mutable sc_fxnum_fast_observer* m_observer;
01397 
01398 private:
01399 
01400     
01401     sc_fxnum_fast();
01402     sc_fxnum_fast( const sc_fxnum_fast& );
01403 };
01404 
01405 
01406 
01407 
01408 
01409 
01410 
01411 
01412 
01413 
01414 
01415 
01416 inline
01417 sc_fxnum_bitref::sc_fxnum_bitref( sc_fxnum& num_, int idx_ )
01418     : m_num( num_ ), m_idx( idx_ )
01419 {}
01420 
01421 
01422 
01423 
01424 inline
01425 sc_fxnum_bitref::sc_fxnum_bitref( const sc_fxnum_bitref& a )
01426     : m_num( a.m_num ), m_idx( a.m_idx )
01427 {}
01428 
01429 
01430 
01431 
01432 inline
01433 sc_fxnum_bitref&
01434 sc_fxnum_bitref::operator = ( const sc_fxnum_bitref& a )
01435 {
01436     if( &a != this )
01437     {
01438         SC_FXNUM_OBSERVER_READ_( a.m_num )
01439         set( a.get() );
01440         SC_FXNUM_OBSERVER_WRITE_( m_num )
01441     }
01442     return *this;
01443 }
01444 
01445 inline
01446 sc_fxnum_bitref&
01447 sc_fxnum_bitref::operator = ( const sc_fxnum_fast_bitref& a )
01448 {
01449     SC_FXNUM_FAST_OBSERVER_READ_( a.m_num )
01450     set( a.get() );
01451     SC_FXNUM_OBSERVER_WRITE_( m_num )
01452     return *this;
01453 }
01454 
01455 inline
01456 sc_fxnum_bitref&
01457 sc_fxnum_bitref::operator = ( const sc_bit& a )
01458 {
01459     set( static_cast<bool>( a ) );
01460     SC_FXNUM_OBSERVER_WRITE_( m_num )
01461     return *this;
01462 }
01463 
01464 inline
01465 sc_fxnum_bitref&
01466 sc_fxnum_bitref::operator = ( bool a )
01467 {
01468     set( a );
01469     SC_FXNUM_OBSERVER_WRITE_( m_num )
01470     return *this;
01471 }
01472 
01473 
01474 inline
01475 sc_fxnum_bitref&
01476 sc_fxnum_bitref::operator &= ( const sc_fxnum_bitref& b )
01477 {
01478     SC_FXNUM_OBSERVER_READ_( m_num )
01479     SC_FXNUM_OBSERVER_READ_( b.m_num )
01480     set( get() && b.get() );
01481     SC_FXNUM_OBSERVER_WRITE_( m_num )
01482     return *this;
01483 }
01484 
01485 inline
01486 sc_fxnum_bitref&
01487 sc_fxnum_bitref::operator &= ( const sc_fxnum_fast_bitref& b )
01488 {
01489     SC_FXNUM_OBSERVER_READ_( m_num )
01490     SC_FXNUM_FAST_OBSERVER_READ_( b.m_num )
01491     set( get() && b.get() );
01492     SC_FXNUM_OBSERVER_WRITE_( m_num )
01493     return *this;
01494 }
01495 
01496 inline
01497 sc_fxnum_bitref&
01498 sc_fxnum_bitref::operator &= ( const sc_bit& b )
01499 {
01500     SC_FXNUM_OBSERVER_READ_( m_num )
01501     set( get() && static_cast<bool>( b ) );
01502     SC_FXNUM_OBSERVER_WRITE_( m_num )
01503     return *this;
01504 }
01505 
01506 inline
01507 sc_fxnum_bitref&
01508 sc_fxnum_bitref::operator &= ( bool b )
01509 {
01510     SC_FXNUM_OBSERVER_READ_( m_num )
01511     set( get() && b );
01512     SC_FXNUM_OBSERVER_WRITE_( m_num )
01513     return *this;
01514 }
01515 
01516 
01517 inline
01518 sc_fxnum_bitref&
01519 sc_fxnum_bitref::operator |= ( const sc_fxnum_bitref& b )
01520 {
01521     SC_FXNUM_OBSERVER_READ_( m_num )
01522     SC_FXNUM_OBSERVER_READ_( b.m_num )
01523     set( get() || b.get() );
01524     SC_FXNUM_OBSERVER_WRITE_( m_num )
01525     return *this;
01526 }
01527 
01528 inline
01529 sc_fxnum_bitref&
01530 sc_fxnum_bitref::operator |= ( const sc_fxnum_fast_bitref& b )
01531 {
01532     SC_FXNUM_OBSERVER_READ_( m_num )
01533     SC_FXNUM_FAST_OBSERVER_READ_( b.m_num )
01534     set( get() || b.get() );
01535     SC_FXNUM_OBSERVER_WRITE_( m_num )
01536     return *this;
01537 }
01538 
01539 inline
01540 sc_fxnum_bitref&
01541 sc_fxnum_bitref::operator |= ( const sc_bit& b )
01542 {
01543     SC_FXNUM_OBSERVER_READ_( m_num )
01544     set( get() || static_cast<bool>( b ) );
01545     SC_FXNUM_OBSERVER_WRITE_( m_num )
01546     return *this;
01547 }
01548 
01549 inline
01550 sc_fxnum_bitref&
01551 sc_fxnum_bitref::operator |= ( bool b )
01552 {
01553     SC_FXNUM_OBSERVER_READ_( m_num )
01554     set( get() || b );
01555     SC_FXNUM_OBSERVER_WRITE_( m_num )
01556     return *this;
01557 }
01558 
01559 
01560 inline
01561 sc_fxnum_bitref&
01562 sc_fxnum_bitref::operator ^= ( const sc_fxnum_bitref& b )
01563 {
01564     SC_FXNUM_OBSERVER_READ_( m_num )
01565     SC_FXNUM_OBSERVER_READ_( b.m_num )
01566     set( get() != b.get() );
01567     SC_FXNUM_OBSERVER_WRITE_( m_num )
01568     return *this;
01569 }
01570 
01571 inline
01572 sc_fxnum_bitref&
01573 sc_fxnum_bitref::operator ^= ( const sc_fxnum_fast_bitref& b )
01574 {
01575     SC_FXNUM_OBSERVER_READ_( m_num )
01576     SC_FXNUM_FAST_OBSERVER_READ_( b.m_num )
01577     set( get() != b.get() );
01578     SC_FXNUM_OBSERVER_WRITE_( m_num )
01579     return *this;
01580 }
01581 
01582 inline
01583 sc_fxnum_bitref&
01584 sc_fxnum_bitref::operator ^= ( const sc_bit& b )
01585 {
01586     SC_FXNUM_OBSERVER_READ_( m_num )
01587     set( get() != static_cast<bool>( b ) );
01588     SC_FXNUM_OBSERVER_WRITE_( m_num )
01589     return *this;
01590 }
01591 
01592 inline
01593 sc_fxnum_bitref&
01594 sc_fxnum_bitref::operator ^= ( bool b )
01595 {
01596     SC_FXNUM_OBSERVER_READ_( m_num )
01597     set( get() != b );
01598     SC_FXNUM_OBSERVER_WRITE_( m_num )
01599     return *this;
01600 }
01601 
01602 
01603 
01604 
01605 inline
01606 sc_fxnum_bitref::operator bool() const
01607 {
01608     SC_FXNUM_OBSERVER_READ_( m_num )
01609     return get();
01610 }
01611 
01612 
01613 inline
01614 ::std::ostream&
01615 operator << ( ::std::ostream& os, const sc_fxnum_bitref& a )
01616 {
01617     a.print( os );
01618     return os;
01619 }
01620 
01621 inline
01622 ::std::istream&
01623 operator >> ( ::std::istream& is, sc_fxnum_bitref& a )
01624 {
01625     a.scan( is );
01626     return is;
01627 }
01628 
01629 
01630 
01631 
01632 
01633 
01634 
01635 
01636 
01637 
01638 inline
01639 sc_fxnum_fast_bitref::sc_fxnum_fast_bitref( sc_fxnum_fast& num_, int idx_ )
01640     : m_num( num_ ), m_idx( idx_ )
01641 {}
01642 
01643 
01644 
01645 
01646 inline
01647 sc_fxnum_fast_bitref::sc_fxnum_fast_bitref( const sc_fxnum_fast_bitref& a )
01648     : m_num( a.m_num ), m_idx( a.m_idx )
01649 {}
01650 
01651 
01652 
01653 
01654 inline
01655 sc_fxnum_fast_bitref&
01656 sc_fxnum_fast_bitref::operator = ( const sc_fxnum_bitref& a )
01657 {
01658     SC_FXNUM_OBSERVER_READ_( a.m_num )
01659     set( a.get() );
01660     SC_FXNUM_FAST_OBSERVER_WRITE_( m_num )
01661     return *this;
01662 }
01663 
01664 inline
01665 sc_fxnum_fast_bitref&
01666 sc_fxnum_fast_bitref::operator = ( const sc_fxnum_fast_bitref& a )
01667 {
01668     if( &a != this )
01669     {
01670         SC_FXNUM_FAST_OBSERVER_READ_( a.m_num )
01671         set( a.get() );
01672         SC_FXNUM_FAST_OBSERVER_WRITE_( m_num )
01673     }
01674     return *this;
01675 }
01676 
01677 inline
01678 sc_fxnum_fast_bitref&
01679 sc_fxnum_fast_bitref::operator = ( const sc_bit& a )
01680 {
01681     set( static_cast<bool>( a ) );
01682     SC_FXNUM_FAST_OBSERVER_WRITE_( m_num )
01683     return *this;
01684 }
01685 
01686 inline
01687 sc_fxnum_fast_bitref&
01688 sc_fxnum_fast_bitref::operator = ( bool a )
01689 {
01690     set( a );
01691     SC_FXNUM_FAST_OBSERVER_WRITE_( m_num )
01692     return *this;
01693 }
01694 
01695 
01696 inline
01697 sc_fxnum_fast_bitref&
01698 sc_fxnum_fast_bitref::operator &= ( const sc_fxnum_bitref& b )
01699 {
01700     SC_FXNUM_FAST_OBSERVER_READ_( m_num )
01701     SC_FXNUM_OBSERVER_READ_( b.m_num )
01702     set( get() && b.get() );
01703     SC_FXNUM_FAST_OBSERVER_WRITE_( m_num )
01704     return *this;
01705 }
01706 
01707 inline
01708 sc_fxnum_fast_bitref&
01709 sc_fxnum_fast_bitref::operator &= ( const sc_fxnum_fast_bitref& b )
01710 {
01711     SC_FXNUM_FAST_OBSERVER_READ_( m_num )
01712     SC_FXNUM_FAST_OBSERVER_READ_( b.m_num )
01713     set( get() && b.get() );
01714     SC_FXNUM_FAST_OBSERVER_WRITE_( m_num )
01715     return *this;
01716 }
01717 
01718 inline
01719 sc_fxnum_fast_bitref&
01720 sc_fxnum_fast_bitref::operator &= ( const sc_bit& b )
01721 {
01722     SC_FXNUM_FAST_OBSERVER_READ_( m_num )
01723     set( get() && static_cast<bool>( b ) );
01724     SC_FXNUM_FAST_OBSERVER_WRITE_( m_num )
01725     return *this;
01726 }
01727 
01728 inline
01729 sc_fxnum_fast_bitref&
01730 sc_fxnum_fast_bitref::operator &= ( bool b )
01731 {
01732     SC_FXNUM_FAST_OBSERVER_READ_( m_num )
01733     set( get() && b );
01734     SC_FXNUM_FAST_OBSERVER_WRITE_( m_num )
01735     return *this;
01736 }
01737 
01738 
01739 inline
01740 sc_fxnum_fast_bitref&
01741 sc_fxnum_fast_bitref::operator |= ( const sc_fxnum_bitref& b )
01742 {
01743     SC_FXNUM_FAST_OBSERVER_READ_( m_num )
01744     SC_FXNUM_OBSERVER_READ_( b.m_num )
01745     set( get() || b.get() );
01746     SC_FXNUM_FAST_OBSERVER_WRITE_( m_num )
01747     return *this;
01748 }
01749 
01750 inline
01751 sc_fxnum_fast_bitref&
01752 sc_fxnum_fast_bitref::operator |= ( const sc_fxnum_fast_bitref& b )
01753 {
01754     SC_FXNUM_FAST_OBSERVER_READ_( m_num )
01755     SC_FXNUM_FAST_OBSERVER_READ_( b.m_num )
01756     set( get() || b.get() );
01757     SC_FXNUM_FAST_OBSERVER_WRITE_( m_num )
01758     return *this;
01759 }
01760 
01761 inline
01762 sc_fxnum_fast_bitref&
01763 sc_fxnum_fast_bitref::operator |= ( const sc_bit& b )
01764 {
01765     SC_FXNUM_FAST_OBSERVER_READ_( m_num )
01766     set( get() || static_cast<bool>( b ) );
01767     SC_FXNUM_FAST_OBSERVER_WRITE_( m_num )
01768     return *this;
01769 }
01770 
01771 inline
01772 sc_fxnum_fast_bitref&
01773 sc_fxnum_fast_bitref::operator |= ( bool b )
01774 {
01775     SC_FXNUM_FAST_OBSERVER_READ_( m_num )
01776     set( get() || b );
01777     SC_FXNUM_FAST_OBSERVER_WRITE_( m_num )
01778     return *this;
01779 }
01780 
01781 
01782 inline
01783 sc_fxnum_fast_bitref&
01784 sc_fxnum_fast_bitref::operator ^= ( const sc_fxnum_bitref& b )
01785 {
01786     SC_FXNUM_FAST_OBSERVER_READ_( m_num )
01787     SC_FXNUM_OBSERVER_READ_( b.m_num )
01788     set( get() != b.get() );
01789     SC_FXNUM_FAST_OBSERVER_WRITE_( m_num )
01790     return *this;
01791 }
01792 
01793 inline
01794 sc_fxnum_fast_bitref&
01795 sc_fxnum_fast_bitref::operator ^= ( const sc_fxnum_fast_bitref& b )
01796 {
01797     SC_FXNUM_FAST_OBSERVER_READ_( m_num )
01798     SC_FXNUM_FAST_OBSERVER_READ_( b.m_num )
01799     set( get() != b.get() );
01800     SC_FXNUM_FAST_OBSERVER_WRITE_( m_num )
01801     return *this;
01802 }
01803 
01804 inline
01805 sc_fxnum_fast_bitref&
01806 sc_fxnum_fast_bitref::operator ^= ( const sc_bit& b )
01807 {
01808     SC_FXNUM_FAST_OBSERVER_READ_( m_num )
01809     set( get() != static_cast<bool>( b ) );
01810     SC_FXNUM_FAST_OBSERVER_WRITE_( m_num )
01811     return *this;
01812 }
01813 
01814 inline
01815 sc_fxnum_fast_bitref&
01816 sc_fxnum_fast_bitref::operator ^= ( bool b )
01817 {
01818     SC_FXNUM_FAST_OBSERVER_READ_( m_num )
01819     set( get() != b );
01820     SC_FXNUM_FAST_OBSERVER_WRITE_( m_num )
01821     return *this;
01822 }
01823 
01824 
01825 
01826 
01827 inline
01828 sc_fxnum_fast_bitref::operator bool() const
01829 {
01830     SC_FXNUM_FAST_OBSERVER_READ_( m_num )
01831     return get();
01832 }
01833 
01834 
01835 inline
01836 ::std::ostream&
01837 operator << ( ::std::ostream& os, const sc_fxnum_fast_bitref& a )
01838 {
01839     a.print( os );
01840     return os;
01841 }
01842 
01843 inline
01844 ::std::istream&
01845 operator >> ( ::std::istream& is, sc_fxnum_fast_bitref& a )
01846 {
01847     a.scan( is );
01848     return is;
01849 }
01850 
01851 
01852 
01853 
01854 
01855 
01856 
01857 
01858 
01859 
01860 
01861 inline
01862 sc_fxnum_subref::sc_fxnum_subref( sc_fxnum& num_, int from_, int to_ )
01863     : m_num( num_ ), m_from( from_ ), m_to( to_ ),
01864       m_bv( *new sc_bv_base( sc_max( m_from, m_to ) -
01865                              sc_min( m_from, m_to ) + 1 ) )
01866 {}
01867 
01868 
01869 
01870 
01871 inline
01872 sc_fxnum_subref::sc_fxnum_subref( const sc_fxnum_subref& a )
01873     : m_num( a.m_num ), m_from( a.m_from ), m_to( a.m_to ),
01874       m_bv( *new sc_bv_base( a.m_bv ) )
01875 {}
01876 
01877 
01878 
01879 
01880 inline
01881 sc_fxnum_subref::~sc_fxnum_subref()
01882 {
01883     delete &m_bv;
01884 }
01885 
01886 
01887 
01888 
01889 inline
01890 sc_fxnum_subref&
01891 sc_fxnum_subref::operator = ( const sc_fxnum_subref& a )
01892 {
01893     if( &a != this )
01894     {
01895         m_bv = static_cast<sc_bv_base>( a );
01896         set();
01897         SC_FXNUM_OBSERVER_WRITE_( m_num )
01898     }
01899     return *this;
01900 }
01901 
01902 inline
01903 sc_fxnum_subref&
01904 sc_fxnum_subref::operator = ( const sc_fxnum_fast_subref& a )
01905 {
01906     m_bv = static_cast<sc_bv_base>( a );
01907     set();
01908     SC_FXNUM_OBSERVER_WRITE_( m_num )
01909     return *this;
01910 }
01911 
01912 #define DEFN_ASN_OP_T(tp)                                                     \
01913 inline                                                                        \
01914 sc_fxnum_subref&                                                              \
01915 sc_fxnum_subref::operator = ( tp a )                                          \
01916 {                                                                             \
01917     m_bv = a;                                                                 \
01918     set();                                                                    \
01919     SC_FXNUM_OBSERVER_WRITE_( m_num )                                         \
01920     return *this;                                                             \
01921 }
01922 
01923 DEFN_ASN_OP_T(const sc_bv_base&)
01924 DEFN_ASN_OP_T(const sc_lv_base&)
01925 DEFN_ASN_OP_T(const char*)
01926 DEFN_ASN_OP_T(const bool*)
01927 DEFN_ASN_OP_T(const sc_signed&)
01928 DEFN_ASN_OP_T(const sc_unsigned&)
01929 DEFN_ASN_OP_T(const sc_int_base&)
01930 DEFN_ASN_OP_T(const sc_uint_base&)
01931 DEFN_ASN_OP_T(int64)
01932 DEFN_ASN_OP_T(uint64)
01933 DEFN_ASN_OP_T(int)
01934 DEFN_ASN_OP_T(unsigned int)
01935 DEFN_ASN_OP_T(long)
01936 DEFN_ASN_OP_T(unsigned long)
01937 DEFN_ASN_OP_T(char)
01938 
01939 #undef DEFN_ASN_OP_T
01940 
01941 
01942 #define DEFN_ASN_OP_T(op,tp)                                                  \
01943 inline                                                                        \
01944 sc_fxnum_subref&                                                              \
01945 sc_fxnum_subref::operator op ## = ( tp a )                                    \
01946 {                                                                             \
01947     SC_FXNUM_OBSERVER_READ_( m_num )                                          \
01948     get();                                                                    \
01949     m_bv = m_bv op a;                                                         \
01950     set();                                                                    \
01951     SC_FXNUM_OBSERVER_WRITE_( m_num )                                         \
01952     return *this;                                                             \
01953 }
01954 
01955 #define DEFN_ASN_OP(op)                                                       \
01956 inline                                                                        \
01957 sc_fxnum_subref&                                                              \
01958 sc_fxnum_subref::operator op ## = ( const sc_fxnum_subref& a )                \
01959 {                                                                             \
01960     SC_FXNUM_OBSERVER_READ_( m_num )                                          \
01961     get();                                                                    \
01962     m_bv = m_bv op static_cast<sc_bv_base>( a );                              \
01963     set();                                                                    \
01964     SC_FXNUM_OBSERVER_WRITE_( m_num )                                         \
01965     return *this;                                                             \
01966 }                                                                             \
01967                                                                               \
01968 inline                                                                        \
01969 sc_fxnum_subref&                                                              \
01970 sc_fxnum_subref::operator op ## = ( const sc_fxnum_fast_subref& a )           \
01971 {                                                                             \
01972     SC_FXNUM_OBSERVER_READ_( m_num )                                          \
01973     get();                                                                    \
01974     m_bv = m_bv op static_cast<sc_bv_base>( a );                              \
01975     set();                                                                    \
01976     SC_FXNUM_OBSERVER_WRITE_( m_num )                                         \
01977     return *this;                                                             \
01978 }                                                                             \
01979                                                                               \
01980 DEFN_ASN_OP_T(op,const sc_bv_base&)                                           \
01981 DEFN_ASN_OP_T(op,const sc_lv_base&)
01982 
01983 DEFN_ASN_OP(&)
01984 DEFN_ASN_OP(|)
01985 DEFN_ASN_OP(^)
01986 
01987 #undef DEFN_ASN_OP_T
01988 #undef DEFN_ASN_OP
01989 
01990 
01991 
01992 
01993 #define DEFN_REL_OP_T(op,tp)                                                  \
01994 inline                                                                        \
01995 bool                                                                          \
01996 operator op ( const sc_fxnum_subref& a, tp b )                                \
01997 {                                                                             \
01998     return ( static_cast<sc_bv_base>( a ) op b );                             \
01999 }                                                                             \
02000                                                                               \
02001 inline                                                                        \
02002 bool                                                                          \
02003 operator op ( tp a, const sc_fxnum_subref& b )                                \
02004 {                                                                             \
02005     return ( static_cast<sc_bv_base>( b ) op a );                             \
02006 }
02007 
02008 #define DEFN_REL_OP(op)                                                       \
02009 inline                                                                        \
02010 bool                                                                          \
02011 operator op ( const sc_fxnum_subref& a, const sc_fxnum_subref& b )            \
02012 {                                                                             \
02013     return ( static_cast<sc_bv_base>( a ) op static_cast<sc_bv_base>( b ) );  \
02014 }                                                                             \
02015                                                                               \
02016 inline                                                                        \
02017 bool                                                                          \
02018 operator op ( const sc_fxnum_subref& a, const sc_fxnum_fast_subref& b )       \
02019 {                                                                             \
02020     return ( static_cast<sc_bv_base>( a ) op static_cast<sc_bv_base>( b ) );  \
02021 }                                                                             \
02022                                                                               \
02023 DEFN_REL_OP_T(op,const sc_bv_base&)                                           \
02024 DEFN_REL_OP_T(op,const sc_lv_base&)                                           \
02025 DEFN_REL_OP_T(op,const char*)                                                 \
02026 DEFN_REL_OP_T(op,const bool*)                                                 \
02027 DEFN_REL_OP_T(op,const sc_signed&)                                            \
02028 DEFN_REL_OP_T(op,const sc_unsigned&)                                          \
02029 DEFN_REL_OP_T(op,int)                                                         \
02030 DEFN_REL_OP_T(op,unsigned int)                                                \
02031 DEFN_REL_OP_T(op,long)                                                        \
02032 DEFN_REL_OP_T(op,unsigned long)
02033 
02034 DEFN_REL_OP(==)
02035 DEFN_REL_OP(!=)
02036 
02037 #undef DEFN_REL_OP_T
02038 #undef DEFN_REL_OP
02039 
02040 
02041 
02042 
02043 #define DEFN_RED_FNC(fnc)                                                     \
02044 inline                                                                        \
02045 bool                                                                          \
02046 sc_fxnum_subref::fnc() const                                                  \
02047 {                                                                             \
02048     SC_FXNUM_OBSERVER_READ_( m_num )                                          \
02049     get();                                                                    \
02050     return static_cast<bool>( m_bv.fnc() );                                   \
02051 }
02052 
02053 DEFN_RED_FNC(and_reduce)
02054 DEFN_RED_FNC(nand_reduce)
02055 DEFN_RED_FNC(or_reduce)
02056 DEFN_RED_FNC(nor_reduce)
02057 DEFN_RED_FNC(xor_reduce)
02058 DEFN_RED_FNC(xnor_reduce)
02059 
02060 #undef DEFN_RED_FNC
02061 
02062 
02063 
02064 
02065 inline
02066 int
02067 sc_fxnum_subref::length() const
02068 {
02069     return m_bv.length();
02070 }
02071 
02072 
02073 
02074 
02075 inline
02076 int
02077 sc_fxnum_subref::to_int() const
02078 {
02079     SC_FXNUM_OBSERVER_READ_( m_num )
02080     get();
02081     return m_bv.to_int();
02082 }
02083 
02084 inline
02085 int64
02086 sc_fxnum_subref::to_int64() const
02087 {
02088     SC_FXNUM_OBSERVER_READ_( m_num )
02089     get();
02090     return m_bv.to_int64();
02091 }
02092 
02093 inline
02094 unsigned int
02095 sc_fxnum_subref::to_uint() const
02096 {
02097     SC_FXNUM_OBSERVER_READ_( m_num )
02098     get();
02099     return m_bv.to_uint();
02100 }
02101 
02102 inline
02103 uint64
02104 sc_fxnum_subref::to_uint64() const
02105 {
02106     SC_FXNUM_OBSERVER_READ_( m_num )
02107     get();
02108     return m_bv.to_uint64();
02109 }
02110 
02111 inline
02112 long
02113 sc_fxnum_subref::to_long() const
02114 {
02115     SC_FXNUM_OBSERVER_READ_( m_num )
02116     get();
02117     return m_bv.to_long();
02118 }
02119 
02120 inline
02121 unsigned long
02122 sc_fxnum_subref::to_ulong() const
02123 {
02124     SC_FXNUM_OBSERVER_READ_( m_num )
02125     get();
02126     return m_bv.to_ulong();
02127 }
02128 
02129 
02130 #ifdef SC_DT_DEPRECATED
02131 
02132 inline
02133 int
02134 sc_fxnum_subref::to_signed() const
02135 {
02136     return to_int();
02137 }
02138 
02139 inline
02140 unsigned int
02141 sc_fxnum_subref::to_unsigned() const
02142 {
02143     return to_uint();
02144 }
02145 
02146 #endif
02147 
02148 
02149 inline
02150 const std::string
02151 sc_fxnum_subref::to_string() const
02152 {
02153     get();
02154     return m_bv.to_string();
02155 }
02156 
02157 inline
02158 const std::string
02159 sc_fxnum_subref::to_string( sc_numrep numrep ) const
02160 {
02161     get();
02162     return m_bv.to_string( numrep );
02163 }
02164 
02165 inline
02166 const std::string
02167 sc_fxnum_subref::to_string( sc_numrep numrep, bool w_prefix ) const
02168 {
02169     get();
02170     return m_bv.to_string( numrep, w_prefix );
02171 }
02172 
02173 
02174 
02175 
02176 inline
02177 sc_fxnum_subref::operator sc_bv_base () const
02178 {
02179     SC_FXNUM_OBSERVER_READ_( m_num )
02180     get();
02181     return m_bv;
02182 }
02183 
02184 
02185 inline
02186 ::std::ostream&
02187 operator << ( ::std::ostream& os, const sc_fxnum_subref& a )
02188 {
02189     a.print( os );
02190     return os;
02191 }
02192 
02193 inline
02194 ::std::istream&
02195 operator >> ( ::std::istream& is, sc_fxnum_subref& a )
02196 {
02197     a.scan( is );
02198     return is;
02199 }
02200 
02201 
02202 
02203 
02204 
02205 
02206 
02207 
02208 
02209 
02210 
02211 inline
02212 sc_fxnum_fast_subref::sc_fxnum_fast_subref( sc_fxnum_fast& num_,
02213                                             int from_, int to_ )
02214     : m_num( num_ ), m_from( from_ ), m_to( to_ ),
02215       m_bv( *new sc_bv_base( sc_max( m_from, m_to ) -
02216                              sc_min( m_from, m_to ) + 1 ) )
02217 {}
02218 
02219 
02220 
02221 
02222 inline
02223 sc_fxnum_fast_subref::sc_fxnum_fast_subref( const sc_fxnum_fast_subref& a )
02224     : m_num( a.m_num ), m_from( a.m_from ), m_to( a.m_to ),
02225       m_bv( *new sc_bv_base( a.m_bv ) )
02226 {}
02227 
02228 
02229 
02230 
02231 inline
02232 sc_fxnum_fast_subref::~sc_fxnum_fast_subref()
02233 {
02234     delete &m_bv;
02235 }
02236 
02237 
02238 
02239 
02240 inline
02241 sc_fxnum_fast_subref&
02242 sc_fxnum_fast_subref::operator = ( const sc_fxnum_subref& a )
02243 {
02244     m_bv = static_cast<sc_bv_base>( a );
02245     set();
02246     SC_FXNUM_FAST_OBSERVER_WRITE_( m_num )
02247     return *this;
02248 }
02249 
02250 inline
02251 sc_fxnum_fast_subref&
02252 sc_fxnum_fast_subref::operator = ( const sc_fxnum_fast_subref& a )
02253 {
02254     if( &a != this )
02255     {
02256         m_bv = static_cast<sc_bv_base>( a );
02257         set();
02258         SC_FXNUM_FAST_OBSERVER_WRITE_( m_num )
02259     }
02260     return *this;
02261 }
02262 
02263 #define DEFN_ASN_OP_T(tp)                                                     \
02264 inline                                                                        \
02265 sc_fxnum_fast_subref&                                                         \
02266 sc_fxnum_fast_subref::operator = ( tp a )                                     \
02267 {                                                                             \
02268     m_bv = a;                                                                 \
02269     set();                                                                    \
02270     SC_FXNUM_FAST_OBSERVER_WRITE_( m_num )                                    \
02271     return *this;                                                             \
02272 }
02273 
02274 DEFN_ASN_OP_T(const sc_bv_base&)
02275 DEFN_ASN_OP_T(const sc_lv_base&)
02276 DEFN_ASN_OP_T(const char*)
02277 DEFN_ASN_OP_T(const bool*)
02278 DEFN_ASN_OP_T(const sc_signed&)
02279 DEFN_ASN_OP_T(const sc_unsigned&)
02280 DEFN_ASN_OP_T(const sc_int_base&)
02281 DEFN_ASN_OP_T(const sc_uint_base&)
02282 DEFN_ASN_OP_T(int64)
02283 DEFN_ASN_OP_T(uint64)
02284 DEFN_ASN_OP_T(int)
02285 DEFN_ASN_OP_T(unsigned int)
02286 DEFN_ASN_OP_T(long)
02287 DEFN_ASN_OP_T(unsigned long)
02288 DEFN_ASN_OP_T(char)
02289 
02290 #undef DEFN_ASN_OP_T
02291 
02292 
02293 #define DEFN_ASN_OP_T(op,tp)                                                  \
02294 inline                                                                        \
02295 sc_fxnum_fast_subref&                                                         \
02296 sc_fxnum_fast_subref::operator op ## = ( tp a )                               \
02297 {                                                                             \
02298     SC_FXNUM_FAST_OBSERVER_READ_( m_num )                                     \
02299     get();                                                                    \
02300     m_bv = m_bv op a;                                                         \
02301     set();                                                                    \
02302     SC_FXNUM_FAST_OBSERVER_WRITE_( m_num )                                    \
02303     return *this;                                                             \
02304 }
02305 
02306 #define DEFN_ASN_OP(op)                                                       \
02307 inline                                                                        \
02308 sc_fxnum_fast_subref&                                                         \
02309 sc_fxnum_fast_subref::operator op ## = ( const sc_fxnum_subref& a )           \
02310 {                                                                             \
02311     SC_FXNUM_FAST_OBSERVER_READ_( m_num )                                     \
02312     get();                                                                    \
02313     m_bv = m_bv op static_cast<sc_bv_base>( a );                              \
02314     set();                                                                    \
02315     SC_FXNUM_FAST_OBSERVER_WRITE_( m_num )                                    \
02316     return *this;                                                             \
02317 }                                                                             \
02318                                                                               \
02319 inline                                                                        \
02320 sc_fxnum_fast_subref&                                                         \
02321 sc_fxnum_fast_subref::operator op ## = ( const sc_fxnum_fast_subref& a )      \
02322 {                                                                             \
02323     SC_FXNUM_FAST_OBSERVER_READ_( m_num )                                     \
02324     get();                                                                    \
02325     m_bv = m_bv op static_cast<sc_bv_base>( a );                              \
02326     set();                                                                    \
02327     SC_FXNUM_FAST_OBSERVER_WRITE_( m_num )                                    \
02328     return *this;                                                             \
02329 }                                                                             \
02330                                                                               \
02331 DEFN_ASN_OP_T(op,const sc_bv_base&)                                           \
02332 DEFN_ASN_OP_T(op,const sc_lv_base&)
02333 
02334 DEFN_ASN_OP(&)
02335 DEFN_ASN_OP(|)
02336 DEFN_ASN_OP(^)
02337 
02338 #undef DEFN_ASN_OP_T
02339 #undef DEFN_ASN_OP
02340 
02341 
02342 
02343 
02344 #define DEFN_REL_OP_T(op,tp)                                                  \
02345 inline                                                                        \
02346 bool                                                                          \
02347 operator op ( const sc_fxnum_fast_subref& a, tp b )                           \
02348 {                                                                             \
02349     return ( static_cast<sc_bv_base>( a ) op b );                             \
02350 }                                                                             \
02351                                                                               \
02352 inline                                                                        \
02353 bool                                                                          \
02354 operator op ( tp a, const sc_fxnum_fast_subref& b )                           \
02355 {                                                                             \
02356     return ( static_cast<sc_bv_base>( b ) op a );                             \
02357 }
02358 
02359 #define DEFN_REL_OP(op)                                                       \
02360 inline                                                                        \
02361 bool                                                                          \
02362 operator op ( const sc_fxnum_fast_subref& a, const sc_fxnum_fast_subref& b )  \
02363 {                                                                             \
02364     return ( static_cast<sc_bv_base>( a ) op static_cast<sc_bv_base>( b ) );  \
02365 }                                                                             \
02366                                                                               \
02367 inline                                                                        \
02368 bool                                                                          \
02369 operator op ( const sc_fxnum_fast_subref& a, const sc_fxnum_subref& b )       \
02370 {                                                                             \
02371     return ( static_cast<sc_bv_base>( a ) op static_cast<sc_bv_base>( b ) );  \
02372 }                                                                             \
02373                                                                               \
02374 DEFN_REL_OP_T(op,const sc_bv_base&)                                           \
02375 DEFN_REL_OP_T(op,const sc_lv_base&)                                           \
02376 DEFN_REL_OP_T(op,const char*)                                                 \
02377 DEFN_REL_OP_T(op,const bool*)                                                 \
02378 DEFN_REL_OP_T(op,const sc_signed&)                                            \
02379 DEFN_REL_OP_T(op,const sc_unsigned&)                                          \
02380 DEFN_REL_OP_T(op,int)                                                         \
02381 DEFN_REL_OP_T(op,unsigned int)                                                \
02382 DEFN_REL_OP_T(op,long)                                                        \
02383 DEFN_REL_OP_T(op,unsigned long)
02384 
02385 DEFN_REL_OP(==)
02386 DEFN_REL_OP(!=)
02387 
02388 #undef DEFN_REL_OP_T
02389 #undef DEFN_REL_OP
02390 
02391 
02392 
02393 
02394 #define DEFN_RED_FNC(fnc)                                                     \
02395 inline                                                                        \
02396 bool                                                                          \
02397 sc_fxnum_fast_subref::fnc() const                                             \
02398 {                                                                             \
02399     SC_FXNUM_FAST_OBSERVER_READ_( m_num )                                     \
02400     get();                                                                    \
02401     return static_cast<bool>( m_bv.fnc() );                                   \
02402 }
02403 
02404 DEFN_RED_FNC(and_reduce)
02405 DEFN_RED_FNC(nand_reduce)
02406 DEFN_RED_FNC(or_reduce)
02407 DEFN_RED_FNC(nor_reduce)
02408 DEFN_RED_FNC(xor_reduce)
02409 DEFN_RED_FNC(xnor_reduce)
02410 
02411 #undef DEFN_RED_FNC
02412 
02413 
02414 
02415 
02416 inline
02417 int
02418 sc_fxnum_fast_subref::length() const
02419 {
02420     return m_bv.length();
02421 }
02422 
02423 
02424 
02425 
02426 inline
02427 int
02428 sc_fxnum_fast_subref::to_int() const
02429 {
02430     SC_FXNUM_FAST_OBSERVER_READ_( m_num )
02431     get();
02432     return m_bv.to_int();
02433 }
02434 
02435 inline
02436 int64
02437 sc_fxnum_fast_subref::to_int64() const
02438 {
02439     SC_FXNUM_FAST_OBSERVER_READ_( m_num )
02440     get();
02441     return m_bv.to_int64();
02442 }
02443 
02444 inline
02445 unsigned int
02446 sc_fxnum_fast_subref::to_uint() const
02447 {
02448     SC_FXNUM_FAST_OBSERVER_READ_( m_num )
02449     get();
02450     return m_bv.to_uint();
02451 }
02452 
02453 inline
02454 uint64
02455 sc_fxnum_fast_subref::to_uint64() const
02456 {
02457     SC_FXNUM_FAST_OBSERVER_READ_( m_num )
02458     get();
02459     return m_bv.to_uint64();
02460 }
02461 
02462 inline
02463 long
02464 sc_fxnum_fast_subref::to_long() const
02465 {
02466     SC_FXNUM_FAST_OBSERVER_READ_( m_num )
02467     get();
02468     return m_bv.to_long();
02469 }
02470 
02471 inline
02472 unsigned long
02473 sc_fxnum_fast_subref::to_ulong() const
02474 {
02475     SC_FXNUM_FAST_OBSERVER_READ_( m_num )
02476     get();
02477     return m_bv.to_ulong();
02478 }
02479 
02480 
02481 #ifdef SC_DT_DEPRECATED
02482 
02483 inline
02484 int
02485 sc_fxnum_fast_subref::to_signed() const
02486 {
02487     return to_int();
02488 }
02489 
02490 inline
02491 unsigned int
02492 sc_fxnum_fast_subref::to_unsigned() const
02493 {
02494     return to_uint();
02495 }
02496 
02497 #endif
02498 
02499 
02500 inline
02501 const std::string
02502 sc_fxnum_fast_subref::to_string() const
02503 {
02504     get();
02505     return m_bv.to_string();
02506 }
02507 
02508 inline
02509 const std::string
02510 sc_fxnum_fast_subref::to_string( sc_numrep numrep ) const
02511 {
02512     get();
02513     return m_bv.to_string( numrep );
02514 }
02515 
02516 inline
02517 const std::string
02518 sc_fxnum_fast_subref::to_string( sc_numrep numrep, bool w_prefix ) const
02519 {
02520     get();
02521     return m_bv.to_string( numrep, w_prefix );
02522 }
02523 
02524 
02525 
02526 
02527 inline
02528 sc_fxnum_fast_subref::operator sc_bv_base () const
02529 {
02530     SC_FXNUM_FAST_OBSERVER_READ_( m_num )
02531     get();
02532     return m_bv;
02533 }
02534 
02535 
02536 inline
02537 ::std::ostream&
02538 operator << ( ::std::ostream& os, const sc_fxnum_fast_subref& a )
02539 {
02540     a.print( os );
02541     return os;
02542 }
02543 
02544 inline
02545 ::std::istream&
02546 operator >> ( ::std::istream& is, sc_fxnum_fast_subref& a )
02547 {
02548     a.scan( is );
02549     return is;
02550 }
02551 
02552 
02553 
02554 
02555 
02556 
02557 
02558 
02559 inline
02560 sc_fxnum_observer*
02561 sc_fxnum::observer() const
02562 {
02563     return m_observer;
02564 }
02565 
02566 
02567 inline
02568 void
02569 sc_fxnum::cast()
02570 {
02571     SC_ERROR_IF_( ! m_rep->is_normal(), sc_core::SC_ID_INVALID_FX_VALUE_ );
02572 
02573     if( m_params.cast_switch() == SC_ON )
02574         m_rep->cast( m_params, m_q_flag, m_o_flag );
02575 }
02576 
02577 
02578 
02579 
02580 inline
02581 sc_fxnum::sc_fxnum( const sc_fxtype_params& type_params_,
02582                     sc_enc enc_,
02583                     const sc_fxcast_switch& cast_sw,
02584                     sc_fxnum_observer* observer_ )
02585 : m_rep( new scfx_rep ),
02586   m_params( type_params_, enc_, cast_sw ),
02587   m_q_flag( false ),
02588   m_o_flag( false ),
02589   m_observer( observer_ )
02590 {
02591     SC_FXNUM_OBSERVER_DEFAULT_
02592     SC_FXNUM_OBSERVER_CONSTRUCT_( *this )
02593 }
02594 
02595 #define DEFN_CTOR_T(tp,arg)                                                   \
02596 inline                                                                        \
02597 sc_fxnum::sc_fxnum( tp a,                                                     \
02598                     const sc_fxtype_params& type_params_,                     \
02599                     sc_enc enc_,                                              \
02600                     const sc_fxcast_switch& cast_sw,                          \
02601                     sc_fxnum_observer* observer_ )                            \
02602 : m_rep( new scfx_rep( arg ) ),                                               \
02603   m_params( type_params_, enc_, cast_sw ),                                    \
02604   m_q_flag( false ),                                                          \
02605   m_o_flag( false ),                                                          \
02606   m_observer( observer_ )                                                     \
02607 {                                                                             \
02608     SC_FXNUM_OBSERVER_DEFAULT_                                                \
02609     cast();                                                                   \
02610     SC_FXNUM_OBSERVER_CONSTRUCT_( *this )                                     \
02611     SC_FXNUM_OBSERVER_WRITE_( *this )                                         \
02612 }
02613 
02614 #define DEFN_CTOR_T_A(tp) DEFN_CTOR_T(tp,a)
02615 #define DEFN_CTOR_T_B(tp) DEFN_CTOR_T(tp,*a.m_rep)
02616 #define DEFN_CTOR_T_C(tp) DEFN_CTOR_T(tp,a.to_double())
02617 #define DEFN_CTOR_T_D(tp) DEFN_CTOR_T(tp,a.value())
02618 
02619 DEFN_CTOR_T_A(int)
02620 DEFN_CTOR_T_A(unsigned int)
02621 DEFN_CTOR_T_A(long)
02622 DEFN_CTOR_T_A(unsigned long)
02623 DEFN_CTOR_T_A(float)
02624 DEFN_CTOR_T_A(double)
02625 DEFN_CTOR_T_A(const char*)
02626 DEFN_CTOR_T_B(const sc_fxval&)
02627 DEFN_CTOR_T_C(const sc_fxval_fast&)
02628 DEFN_CTOR_T_B(const sc_fxnum&)
02629 DEFN_CTOR_T_C(const sc_fxnum_fast&)
02630 #ifndef SC_FX_EXCLUDE_OTHER
02631 DEFN_CTOR_T_A(int64)
02632 DEFN_CTOR_T_A(uint64)
02633 DEFN_CTOR_T_D(const sc_int_base&)
02634 DEFN_CTOR_T_D(const sc_uint_base&)
02635 DEFN_CTOR_T_A(const sc_signed&)
02636 DEFN_CTOR_T_A(const sc_unsigned&)
02637 #endif
02638 
02639 #undef DEFN_CTOR_T
02640 #undef DEFN_CTOR_T_A
02641 #undef DEFN_CTOR_T_B
02642 #undef DEFN_CTOR_T_C
02643 #undef DEFN_CTOR_T_D
02644 
02645 
02646 inline
02647 sc_fxnum::~sc_fxnum()
02648 {
02649     SC_FXNUM_OBSERVER_DESTRUCT_( *this )
02650     delete m_rep;
02651 }
02652 
02653 
02654 
02655 inline
02656 const scfx_rep*
02657 sc_fxnum::get_rep() const
02658 {
02659     SC_FXNUM_OBSERVER_READ_( *this )
02660     return m_rep;
02661 }
02662 
02663 
02664 
02665 
02666 inline
02667 const sc_fxval
02668 sc_fxnum::operator - () const
02669 {
02670     SC_FXNUM_OBSERVER_READ_( *this )
02671     return sc_fxval( sc_dt::neg_scfx_rep( *m_rep ) );
02672 }
02673 
02674 inline
02675 const sc_fxval
02676 sc_fxnum::operator + () const
02677 {
02678     SC_FXNUM_OBSERVER_READ_( *this )
02679     return sc_fxval( new scfx_rep( *m_rep ) );
02680 }
02681 
02682 
02683 
02684 
02685 inline
02686 void
02687 neg( sc_fxval& c, const sc_fxnum& a )
02688 {
02689     SC_FXNUM_OBSERVER_READ_( a )
02690     c.set_rep( sc_dt::neg_scfx_rep( *a.m_rep ) );
02691 }
02692 
02693 inline
02694 void
02695 neg( sc_fxnum& c, const sc_fxnum& a )
02696 {
02697     SC_FXNUM_OBSERVER_READ_( a )
02698     delete c.m_rep;
02699     c.m_rep = sc_dt::neg_scfx_rep( *a.m_rep );
02700     c.cast();
02701     SC_FXNUM_OBSERVER_WRITE_( c )
02702 }
02703 
02704 
02705 
02706 
02707 #define DEFN_BIN_OP_T(op,fnc,tp)                                              \
02708 inline                                                                        \
02709 const sc_fxval                                                                \
02710 operator op ( const sc_fxnum& a, tp b )                                       \
02711 {                                                                             \
02712     SC_FXNUM_OBSERVER_READ_( a )                                              \
02713     sc_fxval tmp( b );                                                        \
02714     return sc_fxval( sc_dt::fnc ## _scfx_rep( *a.m_rep, *tmp.get_rep() ) );  \
02715 }                                                                             \
02716                                                                               \
02717 inline                                                                        \
02718 const sc_fxval                                                                \
02719 operator op ( tp a, const sc_fxnum& b )                                       \
02720 {                                                                             \
02721     SC_FXNUM_OBSERVER_READ_( b )                                              \
02722     sc_fxval tmp( a );                                                        \
02723     return sc_fxval( sc_dt::fnc ## _scfx_rep( *tmp.get_rep(), *b.m_rep ) );  \
02724 }
02725 
02726 #ifndef SC_FX_EXCLUDE_OTHER
02727 #define DEFN_BIN_OP_OTHER(op,fnc)                                             \
02728 DEFN_BIN_OP_T(op,fnc,int64)                                                   \
02729 DEFN_BIN_OP_T(op,fnc,uint64)                                                  \
02730 DEFN_BIN_OP_T(op,fnc,const sc_int_base&)                                      \
02731 DEFN_BIN_OP_T(op,fnc,const sc_uint_base&)                                     \
02732 DEFN_BIN_OP_T(op,fnc,const sc_signed&)                                        \
02733 DEFN_BIN_OP_T(op,fnc,const sc_unsigned&)
02734 #else
02735 #define DEFN_BIN_OP_OTHER(op,fnc)
02736 #endif
02737 
02738 #define DEFN_BIN_OP(op,fnc)                                                   \
02739 inline                                                                        \
02740 const sc_fxval                                                                \
02741 operator op ( const sc_fxnum& a, const sc_fxnum& b )                          \
02742 {                                                                             \
02743     SC_FXNUM_OBSERVER_READ_( a )                                              \
02744     SC_FXNUM_OBSERVER_READ_( b )                                              \
02745     return sc_fxval( sc_dt::fnc ## _scfx_rep( *a.m_rep, *b.m_rep ) );        \
02746 }                                                                             \
02747                                                                               \
02748 inline                                                                        \
02749 const sc_fxval                                                                \
02750 operator op ( const sc_fxnum& a, const sc_fxval& b )                          \
02751 {                                                                             \
02752     SC_FXNUM_OBSERVER_READ_( a )                                              \
02753     return sc_fxval( sc_dt::fnc ## _scfx_rep( *a.m_rep, *b.get_rep() ) );    \
02754 }                                                                             \
02755                                                                               \
02756 inline                                                                        \
02757 const sc_fxval                                                                \
02758 operator op ( const sc_fxval& a, const sc_fxnum& b )                          \
02759 {                                                                             \
02760     SC_FXNUM_OBSERVER_READ_( b )                                              \
02761     return sc_fxval( sc_dt::fnc ## _scfx_rep( *a.get_rep(), *b.m_rep ) );    \
02762 }                                                                             \
02763                                                                               \
02764 DEFN_BIN_OP_T(op,fnc,int)                                                     \
02765 DEFN_BIN_OP_T(op,fnc,unsigned int)                                            \
02766 DEFN_BIN_OP_T(op,fnc,long)                                                    \
02767 DEFN_BIN_OP_T(op,fnc,unsigned long)                                           \
02768 DEFN_BIN_OP_T(op,fnc,float)                                                  \
02769 DEFN_BIN_OP_T(op,fnc,double)                                                  \
02770 DEFN_BIN_OP_T(op,fnc,const char*)                                             \
02771 DEFN_BIN_OP_T(op,fnc,const sc_fxval_fast&)                                    \
02772 DEFN_BIN_OP_T(op,fnc,const sc_fxnum_fast&)                                    \
02773 DEFN_BIN_OP_OTHER(op,fnc)
02774 
02775 DEFN_BIN_OP(*,mult)
02776 DEFN_BIN_OP(+,add)
02777 DEFN_BIN_OP(-,sub)
02778 
02779 
02780 inline
02781 const sc_fxval
02782 operator / ( const sc_fxnum& a, const sc_fxnum& b )
02783 {
02784     SC_FXNUM_OBSERVER_READ_( a )
02785     SC_FXNUM_OBSERVER_READ_( b )
02786     return sc_fxval( sc_dt::div_scfx_rep( *a.m_rep, *b.m_rep ) );
02787 }
02788 
02789 inline
02790 const sc_fxval
02791 operator / ( const sc_fxnum& a, const sc_fxval& b )
02792 {
02793     SC_FXNUM_OBSERVER_READ_( a )
02794     return sc_fxval( sc_dt::div_scfx_rep( *a.m_rep, *b.get_rep() ) );
02795 }
02796 
02797 inline
02798 const sc_fxval
02799 operator / ( const sc_fxval& a, const sc_fxnum& b )
02800 {
02801     SC_FXNUM_OBSERVER_READ_( b )
02802     return sc_fxval( sc_dt::div_scfx_rep( *a.get_rep(), *b.m_rep ) );
02803 }
02804 
02805 DEFN_BIN_OP_T(/,div,int)
02806 DEFN_BIN_OP_T(/,div,unsigned int)
02807 DEFN_BIN_OP_T(/,div,long)
02808 DEFN_BIN_OP_T(/,div,unsigned long)
02809 DEFN_BIN_OP_T(/,div,float)
02810 DEFN_BIN_OP_T(/,div,double)
02811 DEFN_BIN_OP_T(/,div,const char*)
02812 DEFN_BIN_OP_T(/,div,const sc_fxval_fast&)
02813 DEFN_BIN_OP_T(/,div,const sc_fxnum_fast&)
02814 
02815 #ifndef SC_FX_EXCLUDE_OTHER
02816 DEFN_BIN_OP_T(/,div,int64)
02817 DEFN_BIN_OP_T(/,div,uint64)
02818 DEFN_BIN_OP_T(/,div,const sc_int_base&)
02819 DEFN_BIN_OP_T(/,div,const sc_uint_base&)
02820 DEFN_BIN_OP_T(/,div,const sc_signed&)
02821 DEFN_BIN_OP_T(/,div,const sc_unsigned&)
02822 #endif
02823 
02824 #undef DEFN_BIN_OP_T
02825 #undef DEFN_BIN_OP_OTHER
02826 #undef DEFN_BIN_OP
02827 
02828 
02829 inline
02830 const sc_fxval
02831 operator << ( const sc_fxnum& a, int b )
02832 {
02833     SC_FXNUM_OBSERVER_READ_( a )
02834     return sc_fxval( sc_dt::lsh_scfx_rep( *a.m_rep, b ) );
02835 }
02836 
02837 inline
02838 const sc_fxval
02839 operator >> ( const sc_fxnum& a, int b )
02840 {
02841     SC_FXNUM_OBSERVER_READ_( a )
02842     return sc_fxval( sc_dt::rsh_scfx_rep( *a.m_rep, b ) );
02843 }
02844 
02845 
02846 
02847 
02848 #define DEFN_BIN_FNC_T(fnc,tp)                                                \
02849 inline                                                                        \
02850 void                                                                          \
02851 fnc ( sc_fxval& c, const sc_fxnum& a, tp b )                                  \
02852 {                                                                             \
02853     SC_FXNUM_OBSERVER_READ_( a )                                              \
02854     sc_fxval tmp( b );                                                        \
02855     c.set_rep( sc_dt::fnc ## _scfx_rep( *a.m_rep, *tmp.get_rep() ) );        \
02856 }                                                                             \
02857                                                                               \
02858 inline                                                                        \
02859 void                                                                          \
02860 fnc ( sc_fxval& c, tp a, const sc_fxnum& b )                                  \
02861 {                                                                             \
02862     SC_FXNUM_OBSERVER_READ_( b )                                              \
02863     sc_fxval tmp( a );                                                        \
02864     c.set_rep( sc_dt::fnc ## _scfx_rep( *tmp.get_rep(), *b.m_rep ) );        \
02865 }                                                                             \
02866                                                                               \
02867 inline                                                                        \
02868 void                                                                          \
02869 fnc ( sc_fxnum& c, const sc_fxnum& a, tp b )                                  \
02870 {                                                                             \
02871     SC_FXNUM_OBSERVER_READ_( a )                                              \
02872     sc_fxval tmp( b );                                                        \
02873     delete c.m_rep;                                                           \
02874     c.m_rep = sc_dt::fnc ## _scfx_rep( *a.m_rep, *tmp.get_rep() );           \
02875     c.cast();                                                                 \
02876     SC_FXNUM_OBSERVER_WRITE_( c )                                             \
02877 }                                                                             \
02878                                                                               \
02879 inline                                                                        \
02880 void                                                                          \
02881 fnc ( sc_fxnum& c, tp a, const sc_fxnum& b )                                  \
02882 {                                                                             \
02883     SC_FXNUM_OBSERVER_READ_( b )                                              \
02884     sc_fxval tmp( a );                                                        \
02885     delete c.m_rep;                                                           \
02886     c.m_rep = sc_dt::fnc ## _scfx_rep( *tmp.get_rep(), *b.m_rep );           \
02887     c.cast();                                                                 \
02888     SC_FXNUM_OBSERVER_WRITE_( c )                                             \
02889 }
02890 
02891 #ifndef SC_FX_EXCLUDE_OTHER
02892 #define DEFN_BIN_FNC_OTHER(fnc)                                               \
02893 DEFN_BIN_FNC_T(fnc,int64)                                                     \
02894 DEFN_BIN_FNC_T(fnc,uint64)                                                    \
02895 DEFN_BIN_FNC_T(fnc,const sc_int_base&)                                        \
02896 DEFN_BIN_FNC_T(fnc,const sc_uint_base&)                                       \
02897 DEFN_BIN_FNC_T(fnc,const sc_signed&)                                          \
02898 DEFN_BIN_FNC_T(fnc,const sc_unsigned&)
02899 #else
02900 #define DEFN_BIN_FNC_OTHER(fnc)
02901 #endif
02902 
02903 #define DEFN_BIN_FNC(fnc)                                                     \
02904 inline                                                                        \
02905 void                                                                          \
02906 fnc ( sc_fxval& c, const sc_fxnum& a, const sc_fxnum& b )                     \
02907 {                                                                             \
02908     SC_FXNUM_OBSERVER_READ_( a )                                              \
02909     SC_FXNUM_OBSERVER_READ_( b )                                              \
02910     c.set_rep( sc_dt::fnc ## _scfx_rep( *a.m_rep, *b.m_rep ) );              \
02911 }                                                                             \
02912                                                                               \
02913 inline                                                                        \
02914 void                                                                          \
02915 fnc ( sc_fxnum& c, const sc_fxnum& a, const sc_fxnum& b )                     \
02916 {                                                                             \
02917     SC_FXNUM_OBSERVER_READ_( a )                                              \
02918     SC_FXNUM_OBSERVER_READ_( b )                                              \
02919     delete c.m_rep;                                                           \
02920     c.m_rep = sc_dt::fnc ## _scfx_rep( *a.m_rep, *b.m_rep );                 \
02921     c.cast();                                                                 \
02922     SC_FXNUM_OBSERVER_WRITE_( c )                                             \
02923 }                                                                             \
02924                                                                               \
02925 inline                                                                        \
02926 void                                                                          \
02927 fnc ( sc_fxval& c, const sc_fxnum& a, const sc_fxval& b )                     \
02928 {                                                                             \
02929     SC_FXNUM_OBSERVER_READ_( a )                                              \
02930     c.set_rep( sc_dt::fnc ## _scfx_rep( *a.m_rep, *b.get_rep() ) );          \
02931 }                                                                             \
02932                                                                               \
02933 inline                                                                        \
02934 void                                                                          \
02935 fnc ( sc_fxval& c, const sc_fxval& a, const sc_fxnum& b )                     \
02936 {                                                                             \
02937     SC_FXNUM_OBSERVER_READ_( b )                                              \
02938     c.set_rep( sc_dt::fnc ## _scfx_rep( *a.get_rep(), *b.m_rep ) );          \
02939 }                                                                             \
02940                                                                               \
02941 inline                                                                        \
02942 void                                                                          \
02943 fnc ( sc_fxnum& c, const sc_fxnum& a, const sc_fxval& b )                     \
02944 {                                                                             \
02945     SC_FXNUM_OBSERVER_READ_( a )                                              \
02946     delete c.m_rep;                                                           \
02947     c.m_rep = sc_dt::fnc ## _scfx_rep( *a.m_rep, *b.get_rep() );             \
02948     c.cast();                                                                 \
02949     SC_FXNUM_OBSERVER_WRITE_( c )                                             \
02950 }                                                                             \
02951                                                                               \
02952 inline                                                                        \
02953 void                                                                          \
02954 fnc ( sc_fxnum& c, const sc_fxval& a, const sc_fxnum& b )                     \
02955 {                                                                             \
02956     SC_FXNUM_OBSERVER_READ_( b )                                              \
02957     delete c.m_rep;                                                           \
02958     c.m_rep = sc_dt::fnc ## _scfx_rep( *a.get_rep(), *b.m_rep );             \
02959     c.cast();                                                                 \
02960     SC_FXNUM_OBSERVER_WRITE_( c )                                             \
02961 }                                                                             \
02962                                                                               \
02963 DEFN_BIN_FNC_T(fnc,int)                                                       \
02964 DEFN_BIN_FNC_T(fnc,unsigned int)                                              \
02965 DEFN_BIN_FNC_T(fnc,long)                                                      \
02966 DEFN_BIN_FNC_T(fnc,unsigned long)                                             \
02967 DEFN_BIN_FNC_T(fnc,float)                                                    \
02968 DEFN_BIN_FNC_T(fnc,double)                                                    \
02969 DEFN_BIN_FNC_T(fnc,const char*)                                               \
02970 DEFN_BIN_FNC_T(fnc,const sc_fxval_fast&)                                      \
02971 DEFN_BIN_FNC_T(fnc,const sc_fxnum_fast&)                                      \
02972 DEFN_BIN_FNC_OTHER(fnc)
02973 
02974 DEFN_BIN_FNC(mult)
02975 DEFN_BIN_FNC(div)
02976 DEFN_BIN_FNC(add)
02977 DEFN_BIN_FNC(sub)
02978 
02979 #undef DEFN_BIN_FNC_T
02980 #undef DEFN_BIN_FNC_OTHER
02981 #undef DEFN_BIN_FNC
02982 
02983 
02984 inline
02985 void
02986 lshift( sc_fxval& c, const sc_fxnum& a, int b )
02987 {
02988     SC_FXNUM_OBSERVER_READ_( a )
02989     c.set_rep( sc_dt::lsh_scfx_rep( *a.m_rep, b ) );
02990 }
02991 
02992 inline
02993 void
02994 rshift( sc_fxval& c, const sc_fxnum& a, int b )
02995 {
02996     SC_FXNUM_OBSERVER_READ_( a )
02997     c.set_rep( sc_dt::rsh_scfx_rep( *a.m_rep, b ) );
02998 }
02999 
03000 inline
03001 void
03002 lshift( sc_fxnum& c, const sc_fxnum& a, int b )
03003 {
03004     SC_FXNUM_OBSERVER_READ_( a )
03005     delete c.m_rep;
03006     c.m_rep = sc_dt::lsh_scfx_rep( *a.m_rep, b );
03007     c.cast();
03008     SC_FXNUM_OBSERVER_WRITE_( c )
03009 }
03010 
03011 inline
03012 void
03013 rshift( sc_fxnum& c, const sc_fxnum& a, int b )
03014 {
03015     SC_FXNUM_OBSERVER_READ_( a )
03016     delete c.m_rep;
03017     c.m_rep = sc_dt::rsh_scfx_rep( *a.m_rep, b );
03018     c.cast();
03019     SC_FXNUM_OBSERVER_WRITE_( c )
03020 }
03021 
03022 
03023 
03024 
03025 #define DEFN_REL_OP_T(op,ret,tp)                                              \
03026 inline                                                                        \
03027 bool                                                                          \
03028 operator op ( const sc_fxnum& a, tp b )                                       \
03029 {                                                                             \
03030     SC_FXNUM_OBSERVER_READ_( a )                                              \
03031     sc_fxval tmp( b );                                                        \
03032     int result = sc_dt::cmp_scfx_rep( *a.m_rep, *tmp.get_rep() );            \
03033     return ( ret );                                                           \
03034 }                                                                             \
03035                                                                               \
03036 inline                                                                        \
03037 bool                                                                          \
03038 operator op ( tp a, const sc_fxnum& b )                                       \
03039 {                                                                             \
03040     SC_FXNUM_OBSERVER_READ_( b )                                              \
03041     sc_fxval tmp( a );                                                        \
03042     int result = sc_dt::cmp_scfx_rep( *tmp.get_rep(), *b.m_rep );            \
03043     return ( ret );                                                           \
03044 }
03045 
03046 #ifndef SC_FX_EXCLUDE_OTHER
03047 #define DEFN_REL_OP_OTHER(op,ret)                                             \
03048 DEFN_REL_OP_T(op,ret,int64)                                                   \
03049 DEFN_REL_OP_T(op,ret,uint64)                                                  \
03050 DEFN_REL_OP_T(op,ret,const sc_int_base&)                                      \
03051 DEFN_REL_OP_T(op,ret,const sc_uint_base&)                                     \
03052 DEFN_REL_OP_T(op,ret,const sc_signed&)                                        \
03053 DEFN_REL_OP_T(op,ret,const sc_unsigned&)
03054 #else
03055 #define DEFN_REL_OP_OTHER(op,ret)
03056 #endif
03057 
03058 #define DEFN_REL_OP(op,ret)                                                   \
03059 inline                                                                        \
03060 bool                                                                          \
03061 operator op ( const sc_fxnum& a, const sc_fxnum& b )                          \
03062 {                                                                             \
03063     SC_FXNUM_OBSERVER_READ_( a )                                              \
03064     SC_FXNUM_OBSERVER_READ_( b )                                              \
03065     int result = sc_dt::cmp_scfx_rep( *a.m_rep, *b.m_rep );                  \
03066     return ( ret );                                                           \
03067 }                                                                             \
03068                                                                               \
03069 inline                                                                        \
03070 bool                                                                          \
03071 operator op ( const sc_fxnum& a, const sc_fxval& b )                          \
03072 {                                                                             \
03073     SC_FXNUM_OBSERVER_READ_( a )                                              \
03074     int result = sc_dt::cmp_scfx_rep( *a.m_rep, *b.get_rep() );              \
03075     return ( ret );                                                           \
03076 }                                                                             \
03077                                                                               \
03078 inline                                                                        \
03079 bool                                                                          \
03080 operator op ( const sc_fxval& a, const sc_fxnum& b )                          \
03081 {                                                                             \
03082     SC_FXNUM_OBSERVER_READ_( b )                                              \
03083     int result = sc_dt::cmp_scfx_rep( *a.get_rep(), *b.m_rep );              \
03084     return ( ret );                                                           \
03085 }                                                                             \
03086                                                                               \
03087 DEFN_REL_OP_T(op,ret,int)                                                     \
03088 DEFN_REL_OP_T(op,ret,unsigned int)                                            \
03089 DEFN_REL_OP_T(op,ret,long)                                                    \
03090 DEFN_REL_OP_T(op,ret,unsigned long)                                           \
03091 DEFN_REL_OP_T(op,ret,float)                                                  \
03092 DEFN_REL_OP_T(op,ret,double)                                                  \
03093 DEFN_REL_OP_T(op,ret,const char*)                                             \
03094 DEFN_REL_OP_T(op,ret,const sc_fxval_fast&)                                    \
03095 DEFN_REL_OP_T(op,ret,const sc_fxnum_fast&)                                    \
03096 DEFN_REL_OP_OTHER(op,ret)
03097 
03098 DEFN_REL_OP(<,result < 0)
03099 DEFN_REL_OP(<=,result <= 0)
03100 DEFN_REL_OP(>,result > 0 && result != 2)
03101 DEFN_REL_OP(>=,result >= 0 && result != 2)
03102 DEFN_REL_OP(==,result == 0)
03103 DEFN_REL_OP(!=,result != 0)
03104 
03105 #undef DEFN_REL_OP_T
03106 #undef DEFN_REL_OP_OTHER
03107 #undef DEFN_REL_OP
03108 
03109 
03110 
03111 
03112 inline
03113 sc_fxnum&
03114 sc_fxnum::operator = ( const sc_fxnum& a )
03115 {
03116     if( &a != this )
03117     {
03118         SC_FXNUM_OBSERVER_READ_( a )
03119         *m_rep = *a.m_rep;
03120         cast();
03121         SC_FXNUM_OBSERVER_WRITE_( *this )
03122     }
03123     return *this;
03124 }
03125 
03126 inline
03127 sc_fxnum&
03128 sc_fxnum::operator = ( const sc_fxval& a )
03129 {
03130     *m_rep = *a.get_rep();
03131     cast();
03132     SC_FXNUM_OBSERVER_WRITE_( *this )
03133     return *this;
03134 }
03135 
03136 #define DEFN_ASN_OP_T(tp)                                                     \
03137 inline                                                                        \
03138 sc_fxnum&                                                                     \
03139 sc_fxnum::operator = ( tp a )                                                 \
03140 {                                                                             \
03141     sc_fxval tmp( a );                                                        \
03142     *m_rep = *tmp.get_rep();                                                  \
03143     cast();                                                                   \
03144     SC_FXNUM_OBSERVER_WRITE_( *this )                                         \
03145     return *this;                                                             \
03146 }
03147 
03148 DEFN_ASN_OP_T(int)
03149 DEFN_ASN_OP_T(unsigned int)
03150 DEFN_ASN_OP_T(long)
03151 DEFN_ASN_OP_T(unsigned long)
03152 DEFN_ASN_OP_T(float)
03153 DEFN_ASN_OP_T(double)
03154 DEFN_ASN_OP_T(const char*)
03155 DEFN_ASN_OP_T(const sc_fxval_fast&)
03156 DEFN_ASN_OP_T(const sc_fxnum_fast&)
03157 #ifndef SC_FX_EXCLUDE_OTHER
03158 DEFN_ASN_OP_T(int64)
03159 DEFN_ASN_OP_T(uint64)
03160 DEFN_ASN_OP_T(const sc_int_base&)
03161 DEFN_ASN_OP_T(const sc_uint_base&)
03162 DEFN_ASN_OP_T(const sc_signed&)
03163 DEFN_ASN_OP_T(const sc_unsigned&)
03164 #endif
03165 
03166 #undef DEFN_ASN_OP_T
03167 
03168 
03169 #define DEFN_ASN_OP_T(op,fnc,tp)                                              \
03170 inline                                                                        \
03171 sc_fxnum&                                                                     \
03172 sc_fxnum::operator op ( tp b )                                                \
03173 {                                                                             \
03174     SC_FXNUM_OBSERVER_READ_( *this )                                          \
03175     sc_fxval tmp( b );                                                        \
03176     scfx_rep* new_rep = sc_dt::fnc ## _scfx_rep( *m_rep, *tmp.get_rep() );   \
03177     delete m_rep;                                                             \
03178     m_rep = new_rep;                                                          \
03179     cast();                                                                   \
03180     SC_FXNUM_OBSERVER_WRITE_( *this )                                         \
03181     return *this;                                                             \
03182 }
03183 
03184 #ifndef SC_FX_EXCLUDE_OTHER
03185 #define DEFN_ASN_OP_OTHER(op,fnc)                                             \
03186 DEFN_ASN_OP_T(op,fnc,int64)                                                   \
03187 DEFN_ASN_OP_T(op,fnc,uint64)                                                  \
03188 DEFN_ASN_OP_T(op,fnc,const sc_int_base&)                                      \
03189 DEFN_ASN_OP_T(op,fnc,const sc_uint_base&)                                     \
03190 DEFN_ASN_OP_T(op,fnc,const sc_signed&)                                        \
03191 DEFN_ASN_OP_T(op,fnc,const sc_unsigned&)
03192 #else
03193 #define DEFN_ASN_OP_OTHER(op,fnc)
03194 #endif
03195 
03196 #define DEFN_ASN_OP(op,fnc)                                                   \
03197 inline                                                                        \
03198 sc_fxnum&                                                                     \
03199 sc_fxnum::operator op ( const sc_fxnum& b )                                   \
03200 {                                                                             \
03201     SC_FXNUM_OBSERVER_READ_( *this )                                          \
03202     SC_FXNUM_OBSERVER_READ_( b )                                              \
03203     scfx_rep* new_rep = sc_dt::fnc ## _scfx_rep( *m_rep, *b.m_rep );         \
03204     delete m_rep;                                                             \
03205     m_rep = new_rep;                                                          \
03206     cast();                                                                   \
03207     SC_FXNUM_OBSERVER_WRITE_( *this )                                         \
03208     return *this;                                                             \
03209 }                                                                             \
03210                                                                               \
03211 inline                                                                        \
03212 sc_fxnum&                                                                     \
03213 sc_fxnum::operator op ( const sc_fxval& b )                                   \
03214 {                                                                             \
03215     SC_FXNUM_OBSERVER_READ_( *this )                                          \
03216     scfx_rep* new_rep = sc_dt::fnc ## _scfx_rep( *m_rep, *b.get_rep() );     \
03217     delete m_rep;                                                             \
03218     m_rep = new_rep;                                                          \
03219     cast();                                                                   \
03220     SC_FXNUM_OBSERVER_WRITE_( *this )                                         \
03221     return *this;                                                             \
03222 }                                                                             \
03223                                                                               \
03224 DEFN_ASN_OP_T(op,fnc,int)                                                     \
03225 DEFN_ASN_OP_T(op,fnc,unsigned int)                                            \
03226 DEFN_ASN_OP_T(op,fnc,long)                                                    \
03227 DEFN_ASN_OP_T(op,fnc,unsigned long)                                           \
03228 DEFN_ASN_OP_T(op,fnc,float)                                                  \
03229 DEFN_ASN_OP_T(op,fnc,double)                                                  \
03230 DEFN_ASN_OP_T(op,fnc,const char*)                                             \
03231 DEFN_ASN_OP_T(op,fnc,const sc_fxval_fast&)                                    \
03232 DEFN_ASN_OP_T(op,fnc,const sc_fxnum_fast&)                                    \
03233 DEFN_ASN_OP_OTHER(op,fnc)
03234 
03235 DEFN_ASN_OP(*=,mult)
03236 DEFN_ASN_OP(/=,div)
03237 DEFN_ASN_OP(+=,add)
03238 DEFN_ASN_OP(-=,sub)
03239 
03240 #undef DEFN_ASN_OP_T
03241 #undef DEFN_ASN_OP_OTHER
03242 #undef DEFN_ASN_OP
03243 
03244 
03245 inline
03246 sc_fxnum&
03247 sc_fxnum::operator <<= ( int b )
03248 {
03249     SC_FXNUM_OBSERVER_READ_( *this )
03250     m_rep->lshift( b );
03251     cast();
03252     SC_FXNUM_OBSERVER_WRITE_( *this )
03253     return *this;
03254 }
03255 
03256 inline
03257 sc_fxnum&
03258 sc_fxnum::operator >>= ( int b )
03259 {
03260     SC_FXNUM_OBSERVER_READ_( *this )
03261     m_rep->rshift( b );
03262     cast();
03263     SC_FXNUM_OBSERVER_WRITE_( *this )
03264     return *this;
03265 }
03266 
03267 
03268 
03269 
03270 inline
03271 const sc_fxval
03272 sc_fxnum::operator ++ ( int )
03273 {
03274     sc_fxval c( *this );
03275     (*this) += 1;
03276     return c;
03277 }
03278 
03279 inline
03280 const sc_fxval
03281 sc_fxnum::operator -- ( int )
03282 {
03283     sc_fxval c( *this );
03284     (*this) -= 1;
03285     return c;
03286 }
03287 
03288 inline
03289 sc_fxnum&
03290 sc_fxnum::operator ++ ()
03291 {
03292     (*this) += 1;
03293     return *this;
03294 }
03295 
03296 inline
03297 sc_fxnum&
03298 sc_fxnum::operator -- ()
03299 {
03300     (*this) -= 1;
03301     return *this;
03302 }
03303 
03304 
03305 
03306 
03307 inline
03308 const sc_fxnum_bitref
03309 sc_fxnum::operator [] ( int i ) const
03310 {
03311     SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
03312     return sc_fxnum_bitref( const_cast<sc_fxnum&>( *this ),
03313                             i - m_params.fwl() );
03314 }
03315 
03316 inline
03317 sc_fxnum_bitref
03318 sc_fxnum::operator [] ( int i )
03319 {
03320     SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
03321     return sc_fxnum_bitref( *this, i - m_params.fwl() );
03322 }
03323 
03324 inline
03325 const sc_fxnum_bitref
03326 sc_fxnum::bit( int i ) const
03327 {
03328     SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
03329     return sc_fxnum_bitref( const_cast<sc_fxnum&>( *this ),
03330                             i - m_params.fwl() );
03331 }
03332 
03333 inline
03334 sc_fxnum_bitref
03335 sc_fxnum::bit( int i )
03336 {
03337     SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
03338     return sc_fxnum_bitref( *this, i - m_params.fwl() );
03339 }
03340 
03341 
03342 
03343 
03344 inline
03345 const sc_fxnum_subref
03346 sc_fxnum::operator () ( int i, int j ) const
03347 {
03348     SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
03349     SC_ERROR_IF_( j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
03350 
03351     return sc_fxnum_subref( const_cast<sc_fxnum&>( *this ),
03352                             i - m_params.fwl(), j - m_params.fwl() );
03353 }
03354 
03355 inline
03356 sc_fxnum_subref
03357 sc_fxnum::operator () ( int i, int j )
03358 {
03359     SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
03360     SC_ERROR_IF_( j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
03361 
03362     return sc_fxnum_subref( *this, i - m_params.fwl(), j - m_params.fwl() );
03363 }
03364 
03365 inline
03366 const sc_fxnum_subref
03367 sc_fxnum::range( int i, int j ) const
03368 {
03369     SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
03370     SC_ERROR_IF_( j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
03371 
03372     return sc_fxnum_subref( const_cast<sc_fxnum&>( *this ),
03373                             i - m_params.fwl(), j - m_params.fwl() );
03374 }
03375 
03376 inline
03377 sc_fxnum_subref
03378 sc_fxnum::range( int i, int j )
03379 {
03380     SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
03381     SC_ERROR_IF_( j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
03382 
03383     return sc_fxnum_subref( *this, i - m_params.fwl(), j - m_params.fwl() );
03384 }
03385 
03386 
03387 inline
03388 const sc_fxnum_subref
03389 sc_fxnum::operator () () const
03390 {
03391     return this->operator () ( m_params.wl() - 1, 0 );
03392 }
03393 
03394 inline
03395 sc_fxnum_subref
03396 sc_fxnum::operator () ()
03397 {
03398     return this->operator () ( m_params.wl() - 1, 0 );
03399 }
03400 
03401 inline
03402 const sc_fxnum_subref
03403 sc_fxnum::range() const
03404 {
03405     return this->range( m_params.wl() - 1, 0 );
03406 }
03407 
03408 inline
03409 sc_fxnum_subref
03410 sc_fxnum::range()
03411 {
03412     return this->range( m_params.wl() - 1, 0 );
03413 }
03414 
03415 
03416 
03417 
03418 inline
03419 sc_fxnum::operator double() const
03420 {
03421     SC_FXNUM_OBSERVER_READ_( *this )
03422     return m_rep->to_double();
03423 }
03424 
03425 
03426 
03427 
03428 inline
03429 short
03430 sc_fxnum::to_short() const
03431 {
03432     SC_FXNUM_OBSERVER_READ_( *this )
03433     return static_cast<short>( m_rep->to_double() );
03434 }
03435 
03436 inline
03437 unsigned short
03438 sc_fxnum::to_ushort() const
03439 {
03440     SC_FXNUM_OBSERVER_READ_( *this )
03441     return static_cast<unsigned short>( m_rep->to_double() );
03442 }
03443 
03444 inline
03445 int
03446 sc_fxnum::to_int() const
03447 {
03448     SC_FXNUM_OBSERVER_READ_( *this )
03449     return static_cast<int>( m_rep->to_double() );
03450 }
03451 
03452 inline
03453 int64
03454 sc_fxnum::to_int64() const
03455 {
03456     SC_FXNUM_OBSERVER_READ_( *this )
03457     return static_cast<int64>( m_rep->to_double() );
03458 }
03459 
03460 inline
03461 unsigned int
03462 sc_fxnum::to_uint() const
03463 {
03464     SC_FXNUM_OBSERVER_READ_( *this )
03465     return static_cast<unsigned int>( m_rep->to_double() );
03466 }
03467 
03468 inline
03469 uint64
03470 sc_fxnum::to_uint64() const
03471 {
03472     SC_FXNUM_OBSERVER_READ_( *this )
03473     return static_cast<uint64>( m_rep->to_double() );
03474 }
03475 
03476 inline
03477 long
03478 sc_fxnum::to_long() const
03479 {
03480     SC_FXNUM_OBSERVER_READ_( *this )
03481     return static_cast<long>( m_rep->to_double() );
03482 }
03483 
03484 inline
03485 unsigned long
03486 sc_fxnum::to_ulong() const
03487 {
03488     SC_FXNUM_OBSERVER_READ_( *this )
03489     return static_cast<unsigned long>( m_rep->to_double() );
03490 }
03491 
03492 inline
03493 float
03494 sc_fxnum::to_float() const
03495 {
03496     SC_FXNUM_OBSERVER_READ_( *this )
03497     return static_cast<float>( m_rep->to_double() );
03498 }
03499 
03500 inline
03501 double
03502 sc_fxnum::to_double() const
03503 {
03504     SC_FXNUM_OBSERVER_READ_( *this )
03505     return m_rep->to_double();
03506 }
03507 
03508 
03509 
03510 
03511 inline
03512 bool
03513 sc_fxnum::is_neg() const
03514 {
03515     SC_FXNUM_OBSERVER_READ_( *this )
03516     return m_rep->is_neg();
03517 }
03518 
03519 inline
03520 bool
03521 sc_fxnum::is_zero() const
03522 {
03523     SC_FXNUM_OBSERVER_READ_( *this )
03524     return m_rep->is_zero();
03525 }
03526 
03527 
03528 inline
03529 bool
03530 sc_fxnum::is_normal() const
03531 {
03532     SC_FXNUM_OBSERVER_READ_( *this )
03533     return m_rep->is_normal();
03534 }
03535 
03536 inline
03537 bool
03538 sc_fxnum::quantization_flag() const
03539 {
03540     return m_q_flag;
03541 }
03542 
03543 inline
03544 bool
03545 sc_fxnum::overflow_flag() const
03546 {
03547     return m_o_flag;
03548 }
03549 
03550 
03551 inline
03552 const sc_fxval
03553 sc_fxnum::value() const
03554 {
03555     SC_FXNUM_OBSERVER_READ_( *this )
03556     return sc_fxval( new scfx_rep( *m_rep ) );
03557 }
03558 
03559 
03560 
03561 
03562 inline
03563 int
03564 sc_fxnum::wl() const
03565 {
03566     return m_params.wl();
03567 }
03568 
03569 inline
03570 int
03571 sc_fxnum::iwl() const
03572 {
03573     return m_params.iwl();
03574 }
03575 
03576 inline
03577 sc_q_mode
03578 sc_fxnum::q_mode() const
03579 {
03580     return m_params.q_mode();
03581 }
03582 
03583 inline
03584 sc_o_mode
03585 sc_fxnum::o_mode() const
03586 {
03587     return m_params.o_mode();
03588 }
03589 
03590 inline
03591 int
03592 sc_fxnum::n_bits() const
03593 {
03594     return m_params.n_bits();
03595 }
03596 
03597 
03598 inline
03599 const sc_fxtype_params&
03600 sc_fxnum::type_params() const
03601 {
03602     return m_params.type_params();
03603 }
03604 
03605 
03606 inline
03607 const sc_fxcast_switch&
03608 sc_fxnum::cast_switch() const
03609 {
03610     return m_params.cast_switch();
03611 }
03612 
03613 
03614 
03615 inline
03616 void
03617 sc_fxnum::observer_read() const
03618 {
03619     SC_FXNUM_OBSERVER_READ_( *this );
03620 }
03621 
03622 
03623 
03624 inline
03625 bool
03626 sc_fxnum::get_bit( int i ) const
03627 {
03628     return m_rep->get_bit( i );
03629 }
03630 
03631 
03632 
03633 
03634 inline
03635 bool
03636 sc_fxnum::set_bit( int i, bool high )
03637 {
03638     if( high )
03639         return m_rep->set( i, m_params );
03640     else
03641         return m_rep->clear( i, m_params );
03642 }
03643 
03644 
03645 inline
03646 bool
03647 sc_fxnum::get_slice( int i, int j, sc_bv_base& bv ) const
03648 {
03649     return m_rep->get_slice( i, j, m_params, bv );
03650 }
03651 
03652 inline
03653 bool
03654 sc_fxnum::set_slice( int i, int j, const sc_bv_base& bv )
03655 {
03656     return m_rep->set_slice( i, j, m_params, bv );
03657 }
03658 
03659 
03660 inline
03661 ::std::ostream&
03662 operator << ( ::std::ostream& os, const sc_fxnum& a )
03663 {
03664     a.print( os );
03665     return os;
03666 }
03667 
03668 inline
03669 ::std::istream&
03670 operator >> ( ::std::istream& is, sc_fxnum& a )
03671 {
03672     a.scan( is );
03673     return is;
03674 }
03675 
03676 
03677 
03678 
03679 
03680 
03681 
03682 
03683 inline
03684 sc_fxnum_fast_observer*
03685 sc_fxnum_fast::observer() const
03686 {
03687     return m_observer;
03688 }
03689 
03690 
03691 
03692 
03693 inline
03694 sc_fxnum_fast::sc_fxnum_fast( const sc_fxtype_params& type_params_,
03695                               sc_enc enc_,
03696                               const sc_fxcast_switch& cast_sw,
03697                               sc_fxnum_fast_observer* observer_ )
03698 : m_val( 0.0 ),
03699   m_params( type_params_, enc_, cast_sw ),
03700   m_q_flag( false ),
03701   m_o_flag( false ),
03702   m_observer( observer_ )
03703 {
03704     SC_FXNUM_FAST_OBSERVER_DEFAULT_
03705     SC_FXNUM_FAST_OBSERVER_CONSTRUCT_(*this)
03706 }
03707 
03708 inline
03709 sc_fxnum_fast::sc_fxnum_fast( const sc_fxnum_fast& a,
03710                               const sc_fxtype_params& type_params_,
03711                               sc_enc enc_,
03712                               const sc_fxcast_switch& cast_sw,
03713                               sc_fxnum_fast_observer* observer_ )
03714 : m_val( a.m_val ),
03715   m_params( type_params_, enc_, cast_sw ),
03716   m_q_flag( false ),
03717   m_o_flag( false ),
03718   m_observer( observer_ )
03719 {
03720     SC_FXNUM_FAST_OBSERVER_DEFAULT_
03721     SC_FXNUM_FAST_OBSERVER_READ_( a )
03722     cast();
03723     SC_FXNUM_FAST_OBSERVER_CONSTRUCT_( *this )
03724     SC_FXNUM_FAST_OBSERVER_WRITE_( *this )
03725 }
03726 
03727 #define DEFN_CTOR_T(tp,arg)                                                   \
03728 inline                                                                        \
03729 sc_fxnum_fast::sc_fxnum_fast( tp a,                                           \
03730                               const sc_fxtype_params& type_params_,           \
03731                               sc_enc enc_,                                    \
03732                               const sc_fxcast_switch& cast_sw,                \
03733                               sc_fxnum_fast_observer* observer_ )             \
03734 : m_val( arg ),                                                               \
03735   m_params( type_params_, enc_, cast_sw ),                                    \
03736   m_q_flag( false ),                                                          \
03737   m_o_flag( false ),                                                          \
03738   m_observer( observer_ )                                                     \
03739 {                                                                             \
03740     SC_FXNUM_FAST_OBSERVER_DEFAULT_                                           \
03741     cast();                                                                   \
03742     SC_FXNUM_FAST_OBSERVER_CONSTRUCT_(*this)                                  \
03743     SC_FXNUM_FAST_OBSERVER_WRITE_( *this )                                    \
03744 }
03745 
03746 #define DEFN_CTOR_T_A(tp) DEFN_CTOR_T(tp,static_cast<double>( a ))
03747 #define DEFN_CTOR_T_B(tp) DEFN_CTOR_T(tp,sc_fxval_fast::from_string( a ))
03748 #define DEFN_CTOR_T_C(tp) DEFN_CTOR_T(tp,a.to_double())
03749 
03750 DEFN_CTOR_T_A(int)
03751 DEFN_CTOR_T_A(unsigned int)
03752 DEFN_CTOR_T_A(long)
03753 DEFN_CTOR_T_A(unsigned long)
03754 DEFN_CTOR_T_A(float)
03755 DEFN_CTOR_T_A(double)
03756 DEFN_CTOR_T_B(const char*)
03757 DEFN_CTOR_T_C(const sc_fxval&)
03758 DEFN_CTOR_T_C(const sc_fxval_fast&)
03759 DEFN_CTOR_T_C(const sc_fxnum&)
03760 #ifndef SC_FX_EXCLUDE_OTHER
03761 DEFN_CTOR_T_A(int64)
03762 DEFN_CTOR_T_A(uint64)
03763 DEFN_CTOR_T_C(const sc_int_base&)
03764 DEFN_CTOR_T_C(const sc_uint_base&)
03765 DEFN_CTOR_T_C(const sc_signed&)
03766 DEFN_CTOR_T_C(const sc_unsigned&)
03767 #endif
03768 
03769 #undef DEFN_CTOR_T
03770 #undef DEFN_CTOR_T_A
03771 #undef DEFN_CTOR_T_B
03772 #undef DEFN_CTOR_T_C
03773 #undef DEFN_CTOR_T_D
03774 #undef DEFN_CTOR_T_E
03775 
03776 
03777 inline
03778 sc_fxnum_fast::~sc_fxnum_fast()
03779 {
03780     SC_FXNUM_FAST_OBSERVER_DESTRUCT_( *this )
03781 }
03782 
03783 
03784 
03785 inline
03786 double
03787 sc_fxnum_fast::get_val() const
03788 {
03789     SC_FXNUM_FAST_OBSERVER_READ_( *this )
03790     return m_val;
03791 }
03792 
03793 
03794 
03795 
03796 inline
03797 const sc_fxval_fast
03798 sc_fxnum_fast::operator - () const
03799 {
03800     SC_FXNUM_FAST_OBSERVER_READ_( *this )
03801     return sc_fxval_fast( - m_val );
03802 }
03803 
03804 inline
03805 const sc_fxval_fast
03806 sc_fxnum_fast::operator + () const
03807 {
03808     SC_FXNUM_FAST_OBSERVER_READ_( *this )
03809     return sc_fxval_fast( m_val );
03810 }
03811 
03812 
03813 
03814 
03815 inline
03816 void
03817 neg( sc_fxval_fast& c, const sc_fxnum_fast& a )
03818 {
03819     SC_FXNUM_FAST_OBSERVER_READ_( a )
03820     c.set_val( - a.m_val );
03821 }
03822 
03823 inline
03824 void
03825 neg( sc_fxnum_fast& c, const sc_fxnum_fast& a )
03826 {
03827     SC_FXNUM_FAST_OBSERVER_READ_( a )
03828     c.m_val = - a.m_val;
03829     c.cast();
03830     SC_FXNUM_FAST_OBSERVER_WRITE_( c )
03831 }
03832 
03833 
03834 
03835 
03836 #define DEFN_BIN_OP_T(op,tp)                                                  \
03837 inline                                                                        \
03838 const sc_fxval_fast                                                           \
03839 operator op ( const sc_fxnum_fast& a, tp b )                                  \
03840 {                                                                             \
03841     SC_FXNUM_FAST_OBSERVER_READ_( a )                                         \
03842     sc_fxval_fast tmp( b );                                                   \
03843     return sc_fxval_fast( a.m_val op tmp.get_val() );                         \
03844 }                                                                             \
03845                                                                               \
03846 inline                                                                        \
03847 const sc_fxval_fast                                                           \
03848 operator op ( tp a, const sc_fxnum_fast& b )                                  \
03849 {                                                                             \
03850     SC_FXNUM_FAST_OBSERVER_READ_( b )                                         \
03851     sc_fxval_fast tmp( a );                                                   \
03852     return sc_fxval_fast( tmp.get_val() op b.m_val );                         \
03853 }
03854 
03855 #ifndef SC_FX_EXCLUDE_OTHER
03856 #define DEFN_BIN_OP_OTHER(op)                                                 \
03857 DEFN_BIN_OP_T(op,int64)                                                       \
03858 DEFN_BIN_OP_T(op,uint64)                                                      \
03859 DEFN_BIN_OP_T(op,const sc_int_base&)                                          \
03860 DEFN_BIN_OP_T(op,const sc_uint_base&)                                         \
03861 DEFN_BIN_OP_T(op,const sc_signed&)                                            \
03862 DEFN_BIN_OP_T(op,const sc_unsigned&)
03863 #else
03864 #define DEFN_BIN_OP_OTHER(op)
03865 #endif
03866 
03867 #define DEFN_BIN_OP(op,dummy)                                                 \
03868 inline                                                                        \
03869 const sc_fxval_fast                                                           \
03870 operator op ( const sc_fxnum_fast& a, const sc_fxnum_fast& b )                \
03871 {                                                                             \
03872     SC_FXNUM_FAST_OBSERVER_READ_( a )                                         \
03873     SC_FXNUM_FAST_OBSERVER_READ_( b )                                         \
03874     return sc_fxval_fast( a.m_val op b.m_val );                               \
03875 }                                                                             \
03876                                                                               \
03877 inline                                                                        \
03878 const sc_fxval_fast                                                           \
03879 operator op ( const sc_fxnum_fast& a, const sc_fxval_fast& b )                \
03880 {                                                                             \
03881     SC_FXNUM_FAST_OBSERVER_READ_( a )                                         \
03882     return sc_fxval_fast( a.m_val op b.get_val() );                           \
03883 }                                                                             \
03884                                                                               \
03885 inline                                                                        \
03886 const sc_fxval_fast                                                           \
03887 operator op ( const sc_fxval_fast& a, const sc_fxnum_fast& b )                \
03888 {                                                                             \
03889     SC_FXNUM_FAST_OBSERVER_READ_( b )                                         \
03890     return sc_fxval_fast( a.get_val() op b.m_val );                           \
03891 }                                                                             \
03892                                                                               \
03893 DEFN_BIN_OP_T(op,int)                                                         \
03894 DEFN_BIN_OP_T(op,unsigned int)                                                \
03895 DEFN_BIN_OP_T(op,long)                                                        \
03896 DEFN_BIN_OP_T(op,unsigned long)                                               \
03897 DEFN_BIN_OP_T(op,float)                                                      \
03898 DEFN_BIN_OP_T(op,double)                                                      \
03899 DEFN_BIN_OP_T(op,const char*)                                                 \
03900 DEFN_BIN_OP_OTHER(op)
03901 
03902 DEFN_BIN_OP(*,mult)
03903 DEFN_BIN_OP(+,add)
03904 DEFN_BIN_OP(-,sub)
03905 
03906 inline
03907 const sc_fxval_fast
03908 operator / ( const sc_fxnum_fast& a, const sc_fxnum_fast& b )
03909 {
03910     SC_FXNUM_FAST_OBSERVER_READ_( a )
03911     SC_FXNUM_FAST_OBSERVER_READ_( b )
03912     return sc_fxval_fast( a.m_val / b.m_val );
03913 }
03914 
03915 inline
03916 const sc_fxval_fast
03917 operator / ( const sc_fxnum_fast& a, const sc_fxval_fast& b )
03918 {
03919     SC_FXNUM_FAST_OBSERVER_READ_( a )
03920     return sc_fxval_fast( a.m_val / b.get_val() );
03921 }
03922 
03923 inline
03924 const sc_fxval_fast
03925 operator / ( const sc_fxval_fast& a, const sc_fxnum_fast& b )
03926 {
03927     SC_FXNUM_FAST_OBSERVER_READ_( b )
03928     return sc_fxval_fast( a.get_val() / b.m_val );
03929 }
03930 
03931 DEFN_BIN_OP_T(/,int)
03932 DEFN_BIN_OP_T(/,unsigned int)
03933 DEFN_BIN_OP_T(/,long)
03934 DEFN_BIN_OP_T(/,unsigned long)
03935 DEFN_BIN_OP_T(/,float)
03936 DEFN_BIN_OP_T(/,double)
03937 DEFN_BIN_OP_T(/,const char*)
03938 
03939 #ifndef SC_FX_EXCLUDE_OTHER
03940 DEFN_BIN_OP_T(/,int64)
03941 DEFN_BIN_OP_T(/,uint64)
03942 DEFN_BIN_OP_T(/,const sc_int_base&)
03943 DEFN_BIN_OP_T(/,const sc_uint_base&)
03944 DEFN_BIN_OP_T(/,const sc_signed&)
03945 DEFN_BIN_OP_T(/,const sc_unsigned&)
03946 #endif
03947 
03948 #undef DEFN_BIN_OP_T
03949 #undef DEFN_BIN_OP_OTHER
03950 #undef DEFN_BIN_OP
03951 
03952 
03953 inline
03954 const sc_fxval_fast
03955 operator << ( const sc_fxnum_fast& a, int b )
03956 {
03957     SC_FXNUM_FAST_OBSERVER_READ_( a )
03958     return sc_fxval_fast( a.m_val * scfx_pow2( b ) );
03959 }
03960 
03961 inline
03962 const sc_fxval_fast
03963 operator >> ( const sc_fxnum_fast& a, int b )
03964 {
03965     SC_FXNUM_FAST_OBSERVER_READ_( a )
03966     return sc_fxval_fast( a.m_val * scfx_pow2( -b ) );
03967 }
03968 
03969 
03970 
03971 
03972 #define DEFN_BIN_FNC_T(fnc,op,tp)                                             \
03973 inline                                                                        \
03974 void                                                                          \
03975 fnc ( sc_fxval_fast& c, const sc_fxnum_fast& a, tp b )                        \
03976 {                                                                             \
03977     SC_FXNUM_FAST_OBSERVER_READ_( a )                                         \
03978     sc_fxval_fast tmp( b );                                                   \
03979     c.set_val( a.m_val op tmp.get_val() );                                    \
03980 }                                                                             \
03981                                                                               \
03982 inline                                                                        \
03983 void                                                                          \
03984 fnc ( sc_fxval_fast& c, tp a, const sc_fxnum_fast& b )                        \
03985 {                                                                             \
03986     SC_FXNUM_FAST_OBSERVER_READ_( b )                                         \
03987     sc_fxval_fast tmp( a );                                                   \
03988     c.set_val( tmp.get_val() op b.m_val );                                    \
03989 }                                                                             \
03990                                                                               \
03991 inline                                                                        \
03992 void                                                                          \
03993 fnc ( sc_fxnum_fast& c, const sc_fxnum_fast& a, tp b )                        \
03994 {                                                                             \
03995     SC_FXNUM_FAST_OBSERVER_READ_( a )                                         \
03996     sc_fxval_fast tmp( b );                                                   \
03997     c.m_val = a.m_val op tmp.get_val();                                       \
03998     c.cast();                                                                 \
03999     SC_FXNUM_FAST_OBSERVER_WRITE_( c )                                        \
04000 }                                                                             \
04001                                                                               \
04002 inline                                                                        \
04003 void                                                                          \
04004 fnc ( sc_fxnum_fast& c, tp a, const sc_fxnum_fast& b )                        \
04005 {                                                                             \
04006     SC_FXNUM_FAST_OBSERVER_READ_( b )                                         \
04007     sc_fxval_fast tmp( a );                                                   \
04008     c.m_val = tmp.get_val() op b.m_val;                                       \
04009     c.cast();                                                                 \
04010     SC_FXNUM_FAST_OBSERVER_WRITE_( c )                                        \
04011 }
04012 
04013 #ifndef SC_FX_EXCLUDE_OTHER
04014 #define DEFN_BIN_FNC_OTHER(fnc,op)                                            \
04015 DEFN_BIN_FNC_T(fnc,op,int64)                                                  \
04016 DEFN_BIN_FNC_T(fnc,op,uint64)                                                 \
04017 DEFN_BIN_FNC_T(fnc,op,const sc_int_base&)                                     \
04018 DEFN_BIN_FNC_T(fnc,op,const sc_uint_base&)                                    \
04019 DEFN_BIN_FNC_T(fnc,op,const sc_signed&)                                       \
04020 DEFN_BIN_FNC_T(fnc,op,const sc_unsigned&)
04021 #else
04022 #define DEFN_BIN_FNC_OTHER(fnc,op)
04023 #endif
04024 
04025 #define DEFN_BIN_FNC(fnc,op)                                                  \
04026 inline                                                                        \
04027 void                                                                          \
04028 fnc ( sc_fxval_fast& c, const sc_fxnum_fast& a, const sc_fxnum_fast& b )      \
04029 {                                                                             \
04030     SC_FXNUM_FAST_OBSERVER_READ_( a )                                         \
04031     SC_FXNUM_FAST_OBSERVER_READ_( b )                                         \
04032     c.set_val( a.m_val op b.m_val );                                          \
04033 }                                                                             \
04034                                                                               \
04035 inline                                                                        \
04036 void                                                                          \
04037 fnc ( sc_fxnum_fast& c, const sc_fxnum_fast& a, const sc_fxnum_fast& b )      \
04038 {                                                                             \
04039     SC_FXNUM_FAST_OBSERVER_READ_( a )                                         \
04040     SC_FXNUM_FAST_OBSERVER_READ_( b )                                         \
04041     c.m_val = a.m_val op b.m_val;                                             \
04042     c.cast();                                                                 \
04043     SC_FXNUM_FAST_OBSERVER_WRITE_( c )                                        \
04044 }                                                                             \
04045                                                                               \
04046 inline                                                                        \
04047 void                                                                          \
04048 fnc ( sc_fxval_fast& c, const sc_fxnum_fast& a, const sc_fxval_fast& b )      \
04049 {                                                                             \
04050     SC_FXNUM_FAST_OBSERVER_READ_( a )                                         \
04051     c.set_val( a.m_val op b.get_val() );                                      \
04052 }                                                                             \
04053                                                                               \
04054 inline                                                                        \
04055 void                                                                          \
04056 fnc ( sc_fxval_fast& c, const sc_fxval_fast& a, const sc_fxnum_fast& b )      \
04057 {                                                                             \
04058     SC_FXNUM_FAST_OBSERVER_READ_( b )                                         \
04059     c.set_val( a.get_val() op b.m_val );                                      \
04060 }                                                                             \
04061                                                                               \
04062 inline                                                                        \
04063 void                                                                          \
04064 fnc ( sc_fxnum_fast& c, const sc_fxnum_fast& a, const sc_fxval_fast& b )      \
04065 {                                                                             \
04066     SC_FXNUM_FAST_OBSERVER_READ_( a )                                         \
04067     c.m_val = a.m_val op b.get_val();                                         \
04068     c.cast();                                                                 \
04069     SC_FXNUM_FAST_OBSERVER_WRITE_( c )                                        \
04070 }                                                                             \
04071                                                                               \
04072 inline                                                                        \
04073 void                                                                          \
04074 fnc ( sc_fxnum_fast& c, const sc_fxval_fast& a, const sc_fxnum_fast& b )      \
04075 {                                                                             \
04076     SC_FXNUM_FAST_OBSERVER_READ_( b )                                         \
04077     c.m_val = a.get_val() op b.m_val;                                         \
04078     c.cast();                                                                 \
04079     SC_FXNUM_FAST_OBSERVER_WRITE_( c )                                        \
04080 }                                                                             \
04081                                                                               \
04082 DEFN_BIN_FNC_T(fnc,op,int)                                                    \
04083 DEFN_BIN_FNC_T(fnc,op,unsigned int)                                           \
04084 DEFN_BIN_FNC_T(fnc,op,long)                                                   \
04085 DEFN_BIN_FNC_T(fnc,op,unsigned long)                                          \
04086 DEFN_BIN_FNC_T(fnc,op,float)                                                 \
04087 DEFN_BIN_FNC_T(fnc,op,double)                                                 \
04088 DEFN_BIN_FNC_T(fnc,op,const char*)                                            \
04089 DEFN_BIN_FNC_T(fnc,op,const sc_fxval&)                                        \
04090 DEFN_BIN_FNC_T(fnc,op,const sc_fxnum&)                                        \
04091 DEFN_BIN_FNC_OTHER(fnc,op)
04092 
04093 DEFN_BIN_FNC(mult,*)
04094 DEFN_BIN_FNC(div,/)
04095 DEFN_BIN_FNC(add,+)
04096 DEFN_BIN_FNC(sub,-)
04097 
04098 #undef DEFN_BIN_FNC_T
04099 #undef DEFN_BIN_FNC_OTHER
04100 #undef DEFN_BIN_FNC
04101 
04102 
04103 inline
04104 void
04105 lshift( sc_fxval_fast& c, const sc_fxnum_fast& a, int b )
04106 {
04107     SC_FXNUM_FAST_OBSERVER_READ_( a )
04108     c.set_val( a.m_val * scfx_pow2( b ) );
04109 }
04110 
04111 inline
04112 void
04113 rshift( sc_fxval_fast& c, const sc_fxnum_fast& a, int b )
04114 {
04115     SC_FXNUM_FAST_OBSERVER_READ_( a )
04116     c.set_val( a.m_val * scfx_pow2( -b ) );
04117 }
04118 
04119 inline
04120 void
04121 lshift( sc_fxnum_fast& c, const sc_fxnum_fast& a, int b )
04122 {
04123     SC_FXNUM_FAST_OBSERVER_READ_( a )
04124     c.m_val = a.m_val * scfx_pow2( b );
04125     c.cast();
04126     SC_FXNUM_FAST_OBSERVER_WRITE_( c )
04127 }
04128 
04129 inline
04130 void
04131 rshift( sc_fxnum_fast& c, const sc_fxnum_fast& a, int b )
04132 {
04133     SC_FXNUM_FAST_OBSERVER_READ_( a )
04134     c.m_val = a.m_val * scfx_pow2( -b );
04135     c.cast();
04136     SC_FXNUM_FAST_OBSERVER_WRITE_( c )
04137 }
04138 
04139 
04140 
04141 
04142 #define DEFN_REL_OP_T(op,tp)                                                  \
04143 inline                                                                        \
04144 bool                                                                          \
04145 operator op ( const sc_fxnum_fast& a, tp b )                                  \
04146 {                                                                             \
04147     SC_FXNUM_FAST_OBSERVER_READ_( a )                                         \
04148     sc_fxval_fast tmp( b );                                                   \
04149     return ( a.m_val op tmp.get_val() );                                      \
04150 }                                                                             \
04151                                                                               \
04152 inline                                                                        \
04153 bool                                                                          \
04154 operator op ( tp a, const sc_fxnum_fast& b )                                  \
04155 {                                                                             \
04156     SC_FXNUM_FAST_OBSERVER_READ_( b )                                         \
04157     sc_fxval_fast tmp( a );                                                   \
04158     return ( tmp.get_val() op b.m_val );                                      \
04159 }
04160 
04161 #ifndef SC_FX_EXCLUDE_OTHER
04162 #define DEFN_REL_OP_OTHER(op)                                                 \
04163 DEFN_REL_OP_T(op,int64)                                                       \
04164 DEFN_REL_OP_T(op,uint64)                                                      \
04165 DEFN_REL_OP_T(op,const sc_int_base&)                                          \
04166 DEFN_REL_OP_T(op,const sc_uint_base&)                                         \
04167 DEFN_REL_OP_T(op,const sc_signed&)                                            \
04168 DEFN_REL_OP_T(op,const sc_unsigned&)
04169 #else
04170 #define DEFN_REL_OP_OTHER(op)
04171 #endif
04172 
04173 #define DEFN_REL_OP(op)                                                       \
04174 inline                                                                        \
04175 bool                                                                          \
04176 operator op ( const sc_fxnum_fast& a, const sc_fxnum_fast& b )                \
04177 {                                                                             \
04178     SC_FXNUM_FAST_OBSERVER_READ_( a )                                         \
04179     SC_FXNUM_FAST_OBSERVER_READ_( b )                                         \
04180     return ( a.m_val op b.m_val );                                            \
04181 }                                                                             \
04182                                                                               \
04183 inline                                                                        \
04184 bool                                                                          \
04185 operator op ( const sc_fxnum_fast& a, const sc_fxval_fast& b )                \
04186 {                                                                             \
04187     SC_FXNUM_FAST_OBSERVER_READ_( a )                                         \
04188     return ( a.m_val op b.get_val() );                                        \
04189 }                                                                             \
04190                                                                               \
04191 inline                                                                        \
04192 bool                                                                          \
04193 operator op ( const sc_fxval_fast& a, const sc_fxnum_fast& b )                \
04194 {                                                                             \
04195     SC_FXNUM_FAST_OBSERVER_READ_( b )                                         \
04196     return ( a.get_val() op b.m_val );                                        \
04197 }                                                                             \
04198                                                                               \
04199 DEFN_REL_OP_T(op,int)                                                         \
04200 DEFN_REL_OP_T(op,unsigned int)                                                \
04201 DEFN_REL_OP_T(op,long)                                                        \
04202 DEFN_REL_OP_T(op,unsigned long)                                               \
04203 DEFN_REL_OP_T(op,float)                                                      \
04204 DEFN_REL_OP_T(op,double)                                                      \
04205 DEFN_REL_OP_T(op,const char*)                                                 \
04206 DEFN_REL_OP_OTHER(op)
04207 
04208 DEFN_REL_OP(<)
04209 DEFN_REL_OP(<=)
04210 DEFN_REL_OP(>)
04211 DEFN_REL_OP(>=)
04212 DEFN_REL_OP(==)
04213 DEFN_REL_OP(!=)
04214 
04215 #undef DEFN_REL_OP_T
04216 #undef DEFN_REL_OP_OTHER
04217 #undef DEFN_REL_OP
04218 
04219 
04220 
04221 
04222 inline
04223 sc_fxnum_fast&
04224 sc_fxnum_fast::operator = ( const sc_fxnum_fast& a )
04225 {
04226     if( &a != this )
04227     {
04228         SC_FXNUM_FAST_OBSERVER_READ_( a )
04229         m_val = a.m_val;
04230         cast();
04231         SC_FXNUM_FAST_OBSERVER_WRITE_( *this )
04232     }
04233     return *this;
04234 }
04235 
04236 inline
04237 sc_fxnum_fast&
04238 sc_fxnum_fast::operator = ( const sc_fxval_fast& a )
04239 {
04240     m_val = a.get_val();
04241     cast();
04242     SC_FXNUM_FAST_OBSERVER_WRITE_( *this )
04243     return *this;
04244 }
04245 
04246 #define DEFN_ASN_OP_T(tp)                                                     \
04247 inline                                                                        \
04248 sc_fxnum_fast&                                                                \
04249 sc_fxnum_fast::operator = ( tp a )                                            \
04250 {                                                                             \
04251     sc_fxval_fast tmp( a );                                                   \
04252     m_val = tmp.get_val();                                                    \
04253     cast();                                                                   \
04254     SC_FXNUM_FAST_OBSERVER_WRITE_( *this )                                    \
04255     return *this;                                                             \
04256 }
04257 
04258 DEFN_ASN_OP_T(int)
04259 DEFN_ASN_OP_T(unsigned int)
04260 DEFN_ASN_OP_T(long)
04261 DEFN_ASN_OP_T(unsigned long)
04262 DEFN_ASN_OP_T(float)
04263 DEFN_ASN_OP_T(double)
04264 DEFN_ASN_OP_T(const char*)
04265 DEFN_ASN_OP_T(const sc_fxval&)
04266 DEFN_ASN_OP_T(const sc_fxnum&)
04267 #ifndef SC_FX_EXCLUDE_OTHER
04268 DEFN_ASN_OP_T(int64)
04269 DEFN_ASN_OP_T(uint64)
04270 DEFN_ASN_OP_T(const sc_int_base&)
04271 DEFN_ASN_OP_T(const sc_uint_base&)
04272 DEFN_ASN_OP_T(const sc_signed&)
04273 DEFN_ASN_OP_T(const sc_unsigned&)
04274 #endif
04275 
04276 #undef DEFN_ASN_OP_T
04277 
04278 
04279 #define DEFN_ASN_OP_T(op,tp)                                                  \
04280 inline                                                                        \
04281 sc_fxnum_fast&                                                                \
04282 sc_fxnum_fast::operator op ( tp b )                                           \
04283 {                                                                             \
04284     SC_FXNUM_FAST_OBSERVER_READ_( *this )                                     \
04285     sc_fxval_fast tmp( b );                                                   \
04286     m_val op tmp.get_val();                                                   \
04287     cast();                                                                   \
04288     SC_FXNUM_FAST_OBSERVER_WRITE_( *this )                                    \
04289     return *this;                                                             \
04290 }
04291 
04292 #ifndef SC_FX_EXCLUDE_OTHER
04293 #define DEFN_ASN_OP_OTHER(op)                                                 \
04294 DEFN_ASN_OP_T(op,int64)                                                       \
04295 DEFN_ASN_OP_T(op,uint64)                                                      \
04296 DEFN_ASN_OP_T(op,const sc_int_base&)                                          \
04297 DEFN_ASN_OP_T(op,const sc_uint_base&)                                         \
04298 DEFN_ASN_OP_T(op,const sc_signed&)                                            \
04299 DEFN_ASN_OP_T(op,const sc_unsigned&)
04300 #else
04301 #define DEFN_ASN_OP_OTHER(op)
04302 #endif
04303 
04304 #define DEFN_ASN_OP(op)                                                       \
04305 inline                                                                        \
04306 sc_fxnum_fast&                                                                \
04307 sc_fxnum_fast::operator op ( const sc_fxnum_fast& b )                         \
04308 {                                                                             \
04309     SC_FXNUM_FAST_OBSERVER_READ_( *this )                                     \
04310     SC_FXNUM_FAST_OBSERVER_READ_( b )                                         \
04311     m_val op b.m_val;                                                         \
04312     cast();                                                                   \
04313     SC_FXNUM_FAST_OBSERVER_WRITE_( *this )                                    \
04314     return *this;                                                             \
04315 }                                                                             \
04316                                                                               \
04317 inline                                                                        \
04318 sc_fxnum_fast&                                                                \
04319 sc_fxnum_fast::operator op ( const sc_fxval_fast& b )                         \
04320 {                                                                             \
04321     SC_FXNUM_FAST_OBSERVER_READ_( *this )                                     \
04322     m_val op b.get_val();                                                     \
04323     cast();                                                                   \
04324     SC_FXNUM_FAST_OBSERVER_WRITE_( *this )                                    \
04325     return *this;                                                             \
04326 }                                                                             \
04327                                                                               \
04328 DEFN_ASN_OP_T(op,int)                                                         \
04329 DEFN_ASN_OP_T(op,unsigned int)                                                \
04330 DEFN_ASN_OP_T(op,long)                                                        \
04331 DEFN_ASN_OP_T(op,unsigned long)                                               \
04332 DEFN_ASN_OP_T(op,float)                                                      \
04333 DEFN_ASN_OP_T(op,double)                                                      \
04334 DEFN_ASN_OP_T(op,const char*)                                                 \
04335 DEFN_ASN_OP_T(op,const sc_fxval&)                                             \
04336 DEFN_ASN_OP_T(op,const sc_fxnum&)                                             \
04337 DEFN_ASN_OP_OTHER(op)
04338 
04339 DEFN_ASN_OP(*=)
04340 DEFN_ASN_OP(/=)
04341 DEFN_ASN_OP(+=)
04342 DEFN_ASN_OP(-=)
04343 
04344 #undef DEFN_ASN_OP_T
04345 #undef DEFN_ASN_OP_OTHER
04346 #undef DEFN_ASN_OP
04347 
04348 
04349 inline
04350 sc_fxnum_fast&
04351 sc_fxnum_fast::operator <<= ( int b )
04352 {
04353     SC_FXNUM_FAST_OBSERVER_READ_( *this )
04354     m_val *= scfx_pow2( b );
04355     cast();
04356     SC_FXNUM_FAST_OBSERVER_WRITE_( *this )
04357     return *this;
04358 }
04359 
04360 inline
04361 sc_fxnum_fast&
04362 sc_fxnum_fast::operator >>= ( int b )
04363 {
04364     SC_FXNUM_FAST_OBSERVER_READ_( *this )
04365     m_val *= scfx_pow2( -b );
04366     cast();
04367     SC_FXNUM_FAST_OBSERVER_WRITE_( *this )
04368     return *this;
04369 }
04370 
04371 
04372 
04373 
04374 inline
04375 const sc_fxval_fast
04376 sc_fxnum_fast::operator ++ ( int )
04377 {
04378     SC_FXNUM_FAST_OBSERVER_READ_( *this )
04379     SC_FXNUM_FAST_OBSERVER_READ_( *this )
04380     double c = m_val;
04381     m_val = m_val + 1;
04382     cast();
04383     SC_FXNUM_FAST_OBSERVER_WRITE_( *this )
04384     return sc_fxval_fast( c );
04385 }
04386 
04387 inline
04388 const sc_fxval_fast
04389 sc_fxnum_fast::operator -- ( int )
04390 {
04391     SC_FXNUM_FAST_OBSERVER_READ_( *this )
04392     SC_FXNUM_FAST_OBSERVER_READ_( *this )
04393     double c = m_val;
04394     m_val = m_val - 1;
04395     cast();
04396     SC_FXNUM_FAST_OBSERVER_WRITE_( *this )
04397     return sc_fxval_fast( c );
04398 }
04399 
04400 inline
04401 sc_fxnum_fast&
04402 sc_fxnum_fast::operator ++ ()
04403 {
04404     SC_FXNUM_FAST_OBSERVER_READ_( *this )
04405     m_val = m_val + 1;
04406     cast();
04407     SC_FXNUM_FAST_OBSERVER_WRITE_( *this )
04408     return *this;
04409 }
04410 
04411 inline
04412 sc_fxnum_fast&
04413 sc_fxnum_fast::operator -- ()
04414 {
04415     SC_FXNUM_FAST_OBSERVER_READ_( *this )
04416     m_val = m_val - 1;
04417     cast();
04418     SC_FXNUM_FAST_OBSERVER_WRITE_( *this )
04419     return *this;
04420 }
04421 
04422 
04423 
04424 
04425 inline
04426 const sc_fxnum_fast_bitref
04427 sc_fxnum_fast::operator [] ( int i ) const
04428 {
04429     SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
04430     return sc_fxnum_fast_bitref( const_cast<sc_fxnum_fast&>( *this ),
04431                                  i - m_params.fwl() );
04432 }
04433 
04434 inline
04435 sc_fxnum_fast_bitref
04436 sc_fxnum_fast::operator [] ( int i )
04437 {
04438     SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
04439     return sc_fxnum_fast_bitref( *this, i - m_params.fwl() );
04440 }
04441 
04442 inline
04443 const sc_fxnum_fast_bitref
04444 sc_fxnum_fast::bit( int i ) const
04445 {
04446     SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
04447     return sc_fxnum_fast_bitref( const_cast<sc_fxnum_fast&>( *this ),
04448                                  i - m_params.fwl() );
04449 }
04450 
04451 inline
04452 sc_fxnum_fast_bitref
04453 sc_fxnum_fast::bit( int i )
04454 {
04455     SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
04456     return sc_fxnum_fast_bitref( *this, i - m_params.fwl() );
04457 }
04458 
04459 
04460 
04461 
04462 inline
04463 const sc_fxnum_fast_subref
04464 sc_fxnum_fast::operator () ( int i, int j ) const
04465 {
04466     SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
04467     SC_ERROR_IF_( j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
04468 
04469     return sc_fxnum_fast_subref( const_cast<sc_fxnum_fast&>( *this ),
04470                                  i - m_params.fwl(), j - m_params.fwl() );
04471 }
04472 
04473 inline
04474 sc_fxnum_fast_subref
04475 sc_fxnum_fast::operator () ( int i, int j )
04476 {
04477     SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
04478     SC_ERROR_IF_( j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
04479 
04480     return sc_fxnum_fast_subref( *this,
04481                                  i - m_params.fwl(), j - m_params.fwl() );
04482 }
04483 
04484 inline
04485 const sc_fxnum_fast_subref
04486 sc_fxnum_fast::range( int i, int j ) const
04487 {
04488     SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
04489     SC_ERROR_IF_( j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
04490 
04491     return sc_fxnum_fast_subref( const_cast<sc_fxnum_fast&>( *this ),
04492                                  i - m_params.fwl(), j - m_params.fwl() );
04493 }
04494 
04495 inline
04496 sc_fxnum_fast_subref
04497 sc_fxnum_fast::range( int i, int j )
04498 {
04499     SC_ERROR_IF_( i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
04500     SC_ERROR_IF_( j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_ );
04501 
04502     return sc_fxnum_fast_subref( *this,
04503                                  i - m_params.fwl(), j - m_params.fwl() );
04504 }
04505 
04506 inline
04507 const sc_fxnum_fast_subref
04508 sc_fxnum_fast::operator () () const
04509 {
04510     return this->operator () ( m_params.wl() - 1, 0 );
04511 }
04512 
04513 inline
04514 sc_fxnum_fast_subref
04515 sc_fxnum_fast::operator () ()
04516 {
04517     return this->operator () ( m_params.wl() - 1, 0 );
04518 }
04519 
04520 inline
04521 const sc_fxnum_fast_subref
04522 sc_fxnum_fast::range() const
04523 {
04524     return this->range( m_params.wl() - 1, 0 );
04525 }
04526 
04527 inline
04528 sc_fxnum_fast_subref
04529 sc_fxnum_fast::range()
04530 {
04531     return this->range( m_params.wl() - 1, 0 );
04532 }
04533 
04534 
04535 
04536 
04537 inline
04538 sc_fxnum_fast::operator double() const
04539 {
04540     SC_FXNUM_FAST_OBSERVER_READ_( *this )
04541     return m_val;
04542 }
04543 
04544 
04545 
04546 
04547 inline
04548 short
04549 sc_fxnum_fast::to_short() const
04550 {
04551     SC_FXNUM_FAST_OBSERVER_READ_( *this )
04552     return static_cast<short>( m_val );
04553 }
04554 
04555 inline
04556 unsigned short
04557 sc_fxnum_fast::to_ushort() const
04558 {
04559     SC_FXNUM_FAST_OBSERVER_READ_( *this )
04560     return static_cast<unsigned short>( m_val );
04561 }
04562 
04563 inline
04564 int
04565 sc_fxnum_fast::to_int() const
04566 {
04567     SC_FXNUM_FAST_OBSERVER_READ_( *this )
04568     return static_cast<int>( m_val );
04569 }
04570 
04571 inline
04572 int64
04573 sc_fxnum_fast::to_int64() const
04574 {
04575     SC_FXNUM_FAST_OBSERVER_READ_( *this )
04576     return static_cast<int64>( m_val );
04577 }
04578 
04579 inline
04580 unsigned int
04581 sc_fxnum_fast::to_uint() const
04582 {
04583     SC_FXNUM_FAST_OBSERVER_READ_( *this )
04584     return static_cast<unsigned int>( m_val );
04585 }
04586 
04587 inline
04588 uint64
04589 sc_fxnum_fast::to_uint64() const
04590 {
04591     SC_FXNUM_FAST_OBSERVER_READ_( *this )
04592     return static_cast<uint64>( m_val );
04593 }
04594 
04595 inline
04596 long
04597 sc_fxnum_fast::to_long() const
04598 {
04599     SC_FXNUM_FAST_OBSERVER_READ_( *this )
04600     return static_cast<long>( m_val );
04601 }
04602 
04603 inline
04604 unsigned long
04605 sc_fxnum_fast::to_ulong() const
04606 {
04607     SC_FXNUM_FAST_OBSERVER_READ_( *this )
04608     return static_cast<unsigned long>( m_val );
04609 }
04610 
04611 inline
04612 float
04613 sc_fxnum_fast::to_float() const
04614 {
04615     SC_FXNUM_FAST_OBSERVER_READ_( *this )
04616     return static_cast<float>( m_val );
04617 }
04618 
04619 inline
04620 double
04621 sc_fxnum_fast::to_double() const
04622 {
04623     SC_FXNUM_FAST_OBSERVER_READ_( *this )
04624     return m_val;
04625 }
04626 
04627 
04628 
04629 
04630 inline
04631 bool
04632 sc_fxnum_fast::is_neg() const
04633 {
04634     SC_FXNUM_FAST_OBSERVER_READ_( *this )
04635     scfx_ieee_double id( m_val );
04636     return ( id.negative() != 0 );
04637 }
04638 
04639 inline
04640 bool
04641 sc_fxnum_fast::is_zero() const
04642 {
04643     SC_FXNUM_FAST_OBSERVER_READ_( *this )
04644     scfx_ieee_double id( m_val );
04645     return id.is_zero();
04646 }
04647 
04648 
04649 inline
04650 bool
04651 sc_fxnum_fast::is_normal() const
04652 {
04653     SC_FXNUM_FAST_OBSERVER_READ_( *this )
04654     scfx_ieee_double id( m_val );
04655     return ( id.is_normal() || id.is_subnormal() || id.is_zero() );
04656 }
04657 
04658 
04659 inline
04660 bool
04661 sc_fxnum_fast::quantization_flag() const
04662 {
04663     return m_q_flag;
04664 }
04665 
04666 inline
04667 bool
04668 sc_fxnum_fast::overflow_flag() const
04669 {
04670     return m_o_flag;
04671 }
04672 
04673 
04674 inline
04675 const sc_fxval_fast
04676 sc_fxnum_fast::value() const
04677 {
04678     SC_FXNUM_FAST_OBSERVER_READ_( *this )
04679     return sc_fxval_fast( m_val );
04680 }
04681 
04682 
04683 
04684 
04685 inline
04686 int
04687 sc_fxnum_fast::wl() const
04688 {
04689     return m_params.wl();
04690 }
04691 
04692 inline
04693 int
04694 sc_fxnum_fast::iwl() const
04695 {
04696     return m_params.iwl();
04697 }
04698 
04699 inline
04700 sc_q_mode
04701 sc_fxnum_fast::q_mode() const
04702 {
04703     return m_params.q_mode();
04704 }
04705 
04706 inline
04707 sc_o_mode
04708 sc_fxnum_fast::o_mode() const
04709 {
04710     return m_params.o_mode();
04711 }
04712 
04713 inline
04714 int
04715 sc_fxnum_fast::n_bits() const
04716 {
04717     return m_params.n_bits();
04718 }
04719 
04720 
04721 inline
04722 const sc_fxtype_params&
04723 sc_fxnum_fast::type_params() const
04724 {
04725     return m_params.type_params();
04726 }
04727 
04728 
04729 inline
04730 const sc_fxcast_switch&
04731 sc_fxnum_fast::cast_switch() const
04732 {
04733     return m_params.cast_switch();
04734 }
04735 
04736 
04737 
04738 inline
04739 void
04740 sc_fxnum_fast::observer_read() const
04741 {
04742     SC_FXNUM_OBSERVER_READ_( *this );
04743 }
04744 
04745 
04746 inline
04747 ::std::ostream&
04748 operator << ( ::std::ostream& os, const sc_fxnum_fast& a )
04749 {
04750     a.print( os );
04751     return os;
04752 }
04753 
04754 inline
04755 ::std::istream&
04756 operator >> ( ::std::istream& is, sc_fxnum_fast& a )
04757 {
04758     a.scan( is );
04759     return is;
04760 }
04761 
04762 
04763 
04764 
04765 
04766 
04767 
04768 
04769 
04770 
04771 inline
04772 sc_fxval::sc_fxval( const sc_fxnum& a,
04773                     sc_fxval_observer* observer_ )
04774 : m_rep( new scfx_rep( *a.get_rep() ) ),
04775   m_observer( observer_ )
04776 {
04777     SC_FXVAL_OBSERVER_DEFAULT_
04778     SC_FXVAL_OBSERVER_CONSTRUCT_( *this )
04779     SC_FXVAL_OBSERVER_WRITE_( *this )
04780 }
04781 
04782 inline
04783 sc_fxval::sc_fxval( const sc_fxnum_fast& a,
04784                     sc_fxval_observer* observer_ )
04785 : m_rep( new scfx_rep( a.to_double() ) ),
04786   m_observer( observer_ )
04787 {
04788     SC_FXVAL_OBSERVER_DEFAULT_
04789     SC_FXVAL_OBSERVER_CONSTRUCT_( *this )
04790     SC_FXVAL_OBSERVER_WRITE_( *this )
04791 }
04792 
04793 
04794 
04795 
04796 #define DEFN_BIN_OP_T(op,fnc,tp)                                              \
04797 inline                                                                        \
04798 const sc_fxval                                                                \
04799 operator op ( const sc_fxval& a, tp b )                                       \
04800 {                                                                             \
04801     SC_FXVAL_OBSERVER_READ_( a )                                              \
04802     sc_fxval tmp( b );                                                        \
04803     return sc_fxval( sc_dt::fnc ## _scfx_rep( *a.m_rep, *tmp.m_rep ) );      \
04804 }                                                                             \
04805                                                                               \
04806 inline                                                                        \
04807 const sc_fxval                                                                \
04808 operator op ( tp a, const sc_fxval& b )                                       \
04809 {                                                                             \
04810     SC_FXVAL_OBSERVER_READ_( b )                                              \
04811     sc_fxval tmp( a );                                                        \
04812     return sc_fxval( sc_dt::fnc ## _scfx_rep( *tmp.m_rep, *b.m_rep ) );      \
04813 }
04814 
04815 #define DEFN_BIN_OP(op,fnc)                                                   \
04816 DEFN_BIN_OP_T(op,fnc,const sc_fxnum_fast&)
04817 
04818 DEFN_BIN_OP(*,mult)
04819 DEFN_BIN_OP(+,add)
04820 DEFN_BIN_OP(-,sub)
04821 
04822 DEFN_BIN_OP_T(/,div,const sc_fxnum_fast&)
04823 
04824 #undef DEFN_BIN_OP_T
04825 #undef DEFN_BIN_OP
04826 
04827 
04828 
04829 
04830 #define DEFN_BIN_FNC_T(fnc,tp)                                                \
04831 inline                                                                        \
04832 void                                                                          \
04833 fnc ( sc_fxval& c, const sc_fxval& a, tp b )                                  \
04834 {                                                                             \
04835     SC_FXVAL_OBSERVER_READ_( a )                                              \
04836     sc_fxval tmp( b );                                                        \
04837     delete c.m_rep;                                                           \
04838     c.m_rep = sc_dt::fnc ## _scfx_rep( *a.m_rep, *tmp.m_rep );               \
04839     SC_FXVAL_OBSERVER_WRITE_( c )                                             \
04840 }                                                                             \
04841                                                                               \
04842 inline                                                                        \
04843 void                                                                          \
04844 fnc ( sc_fxval& c, tp a, const sc_fxval& b )                                  \
04845 {                                                                             \
04846     SC_FXVAL_OBSERVER_READ_( b )                                              \
04847     sc_fxval tmp( a );                                                        \
04848     delete c.m_rep;                                                           \
04849     c.m_rep = sc_dt::fnc ## _scfx_rep( *tmp.m_rep, *b.m_rep );               \
04850     SC_FXVAL_OBSERVER_WRITE_( c )                                             \
04851 }
04852 
04853 #define DEFN_BIN_FNC(fnc)                                                     \
04854 DEFN_BIN_FNC_T(fnc,const sc_fxnum_fast&)
04855 
04856 DEFN_BIN_FNC(mult)
04857 DEFN_BIN_FNC(div)
04858 DEFN_BIN_FNC(add)
04859 DEFN_BIN_FNC(sub)
04860 
04861 #undef DEFN_BIN_FNC_T
04862 #undef DEFN_BIN_FNC
04863 
04864 
04865 
04866 
04867 #define DEFN_REL_OP_T(op,ret,tp)                                              \
04868 inline                                                                        \
04869 bool                                                                          \
04870 operator op ( const sc_fxval& a, tp b )                                       \
04871 {                                                                             \
04872     SC_FXVAL_OBSERVER_READ_( a )                                              \
04873     sc_fxval tmp( b );                                                        \
04874     int result = sc_dt::cmp_scfx_rep( *a.m_rep, *tmp.m_rep );                \
04875     return ( ret );                                                           \
04876 }                                                                             \
04877                                                                               \
04878 inline                                                                        \
04879 bool                                                                          \
04880 operator op ( tp a, const sc_fxval& b )                                       \
04881 {                                                                             \
04882     SC_FXVAL_OBSERVER_READ_( b )                                              \
04883     sc_fxval tmp( a );                                                        \
04884     int result = sc_dt::cmp_scfx_rep( *tmp.m_rep, *b.m_rep );                \
04885     return ( ret );                                                           \
04886 }
04887 
04888 
04889 #define DEFN_REL_OP(op,ret)                                                   \
04890 DEFN_REL_OP_T(op,ret,const sc_fxnum_fast&)
04891 
04892 DEFN_REL_OP(<,result < 0)
04893 DEFN_REL_OP(<=,result <= 0)
04894 DEFN_REL_OP(>,result > 0 && result != 2)
04895 DEFN_REL_OP(>=,result >= 0 && result != 2)
04896 DEFN_REL_OP(==,result == 0)
04897 DEFN_REL_OP(!=,result != 0)
04898 
04899 #undef DEFN_REL_OP_T
04900 #undef DEFN_REL_OP
04901 
04902 
04903 
04904 
04905 inline
04906 sc_fxval&
04907 sc_fxval::operator = ( const sc_fxnum& a )
04908 {
04909     *m_rep = *a.get_rep();
04910     SC_FXVAL_OBSERVER_WRITE_( *this )
04911     return *this;
04912 }
04913 
04914 #define DEFN_ASN_OP_T(tp)                                                     \
04915 inline                                                                        \
04916 sc_fxval&                                                                     \
04917 sc_fxval::operator = ( tp b )                                                 \
04918 {                                                                             \
04919     sc_fxval tmp( b );                                                        \
04920     *m_rep = *tmp.m_rep;                                                      \
04921     SC_FXVAL_OBSERVER_WRITE_( *this )                                         \
04922     return *this;                                                             \
04923 }
04924 
04925 DEFN_ASN_OP_T(const sc_fxnum_fast&)
04926 
04927 #undef DEFN_ASN_OP_T
04928 
04929 
04930 #define DEFN_ASN_OP_T(op,fnc,tp)                                              \
04931 inline                                                                        \
04932 sc_fxval&                                                                     \
04933 sc_fxval::operator op ( tp b )                                                \
04934 {                                                                             \
04935     SC_FXVAL_OBSERVER_READ_( *this )                                          \
04936     sc_fxval tmp( b );                                                        \
04937     scfx_rep* new_rep = sc_dt::fnc ## _scfx_rep( *m_rep, *tmp.m_rep );       \
04938     delete m_rep;                                                             \
04939     m_rep = new_rep;                                                          \
04940     SC_FXVAL_OBSERVER_WRITE_( *this )                                         \
04941     return *this;                                                             \
04942 }
04943 
04944 #define DEFN_ASN_OP(op,fnc)                                                   \
04945 inline                                                                        \
04946 sc_fxval&                                                                     \
04947 sc_fxval::operator op ( const sc_fxnum& b )                                   \
04948 {                                                                             \
04949     SC_FXVAL_OBSERVER_READ_( *this )                                          \
04950     scfx_rep* new_rep = sc_dt::fnc ## _scfx_rep( *m_rep, *b.get_rep() );     \
04951     delete m_rep;                                                             \
04952     m_rep = new_rep;                                                          \
04953     SC_FXVAL_OBSERVER_WRITE_( *this )                                         \
04954     return *this;                                                             \
04955 }                                                                             \
04956                                                                               \
04957 DEFN_ASN_OP_T(op,fnc,const sc_fxnum_fast&)
04958 
04959 DEFN_ASN_OP(*=,mult)
04960 DEFN_ASN_OP(/=,div)
04961 DEFN_ASN_OP(+=,add)
04962 DEFN_ASN_OP(-=,sub)
04963 
04964 #undef DEFN_ASN_OP_T
04965 #undef DEFN_ASN_OP
04966 
04967 
04968 
04969 
04970 
04971 
04972 
04973 
04974 
04975 
04976 inline
04977 sc_fxval_fast::sc_fxval_fast( const sc_fxnum& a,
04978                               sc_fxval_fast_observer* observer_ )
04979 : m_val( a.to_double() ),
04980   m_observer( observer_ )
04981 {
04982     SC_FXVAL_FAST_OBSERVER_DEFAULT_
04983     SC_FXVAL_FAST_OBSERVER_CONSTRUCT_( *this )
04984     SC_FXVAL_FAST_OBSERVER_WRITE_( *this )
04985 }
04986 
04987 inline
04988 sc_fxval_fast::sc_fxval_fast( const sc_fxnum_fast& a,
04989                               sc_fxval_fast_observer* observer_ )
04990 : m_val( a.get_val() ),
04991   m_observer( observer_ )
04992 {
04993     SC_FXVAL_FAST_OBSERVER_DEFAULT_
04994     SC_FXVAL_FAST_OBSERVER_CONSTRUCT_( *this )
04995     SC_FXVAL_FAST_OBSERVER_WRITE_( *this )
04996 }
04997 
04998 
04999 
05000 
05001 #define DEFN_BIN_FNC_T(fnc,op,tp)                                             \
05002 inline                                                                        \
05003 void                                                                          \
05004 fnc ( sc_fxval_fast& c, const sc_fxval_fast& a, tp b )                        \
05005 {                                                                             \
05006     SC_FXVAL_FAST_OBSERVER_READ_( a )                                         \
05007     sc_fxval_fast tmp( b );                                                   \
05008     c.m_val = a.m_val op tmp.m_val;                                           \
05009     SC_FXVAL_FAST_OBSERVER_WRITE_( c )                                        \
05010 }                                                                             \
05011                                                                               \
05012 inline                                                                        \
05013 void                                                                          \
05014 fnc ( sc_fxval_fast& c, tp a, const sc_fxval_fast& b )                        \
05015 {                                                                             \
05016     SC_FXVAL_FAST_OBSERVER_READ_( b )                                         \
05017     sc_fxval_fast tmp( a );                                                   \
05018     c.m_val = tmp.m_val op b.m_val;                                           \
05019     SC_FXVAL_FAST_OBSERVER_WRITE_( c )                                        \
05020 }
05021 
05022 #define DEFN_BIN_FNC(fnc,op)                                                  \
05023 DEFN_BIN_FNC_T(fnc,op,const sc_fxval&)                                        \
05024 DEFN_BIN_FNC_T(fnc,op,const sc_fxnum&)
05025 
05026 DEFN_BIN_FNC(mult,*)
05027 DEFN_BIN_FNC(div,/)
05028 DEFN_BIN_FNC(add,+)
05029 DEFN_BIN_FNC(sub,-)
05030 
05031 #undef DEFN_BIN_FNC_T
05032 #undef DEFN_BIN_FNC
05033 
05034 
05035 
05036 
05037 inline
05038 sc_fxval_fast&
05039 sc_fxval_fast::operator = ( const sc_fxnum_fast& a )
05040 {
05041     m_val = a.get_val();
05042     SC_FXVAL_FAST_OBSERVER_WRITE_( *this )
05043     return *this;
05044 }
05045 
05046 #define DEFN_ASN_OP_T(tp)                                                     \
05047 inline                                                                        \
05048 sc_fxval_fast&                                                                \
05049 sc_fxval_fast::operator = ( tp a )                                            \
05050 {                                                                             \
05051     sc_fxval_fast tmp( a );                                                   \
05052     m_val = tmp.m_val;                                                        \
05053     SC_FXVAL_FAST_OBSERVER_WRITE_( *this )                                    \
05054     return *this;                                                             \
05055 }
05056 
05057 DEFN_ASN_OP_T(const sc_fxnum&)
05058 
05059 #undef DEFN_ASN_OP_T
05060 
05061 
05062 #define DEFN_ASN_OP_T(op,tp)                                                  \
05063 inline                                                                        \
05064 sc_fxval_fast&                                                                \
05065 sc_fxval_fast::operator op ( tp b )                                           \
05066 {                                                                             \
05067     SC_FXVAL_FAST_OBSERVER_READ_( *this )                                     \
05068     sc_fxval_fast tmp( b );                                                   \
05069     m_val op tmp.m_val;                                                       \
05070     SC_FXVAL_FAST_OBSERVER_WRITE_( *this )                                    \
05071     return *this;                                                             \
05072 }
05073 
05074 #define DEFN_ASN_OP(op)                                                       \
05075 inline                                                                        \
05076 sc_fxval_fast&                                                                \
05077 sc_fxval_fast::operator op ( const sc_fxnum_fast& b )                         \
05078 {                                                                             \
05079     SC_FXVAL_FAST_OBSERVER_READ_( *this )                                     \
05080     m_val op b.get_val();                                                     \
05081     SC_FXVAL_FAST_OBSERVER_WRITE_( *this )                                    \
05082     return *this;                                                             \
05083 }                                                                             \
05084                                                                               \
05085 DEFN_ASN_OP_T(op,const sc_fxnum&)
05086 
05087 DEFN_ASN_OP(*=)
05088 DEFN_ASN_OP(/=)
05089 DEFN_ASN_OP(+=)
05090 DEFN_ASN_OP(-=)
05091 
05092 #undef DEFN_ASN_OP_T
05093 #undef DEFN_ASN_OP
05094 
05095 } 
05096 
05097 
05098 #endif
05099 
05100