Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

sc_fxnum.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002 
00003   The following code is derived, directly or indirectly, from the SystemC
00004   source code Copyright (c) 1996-2004 by all Contributors.
00005   All Rights reserved.
00006 
00007   The contents of this file are subject to the restrictions and limitations
00008   set forth in the SystemC Open Source License Version 2.3 (the "License");
00009   You may not use this file except in compliance with such restrictions and
00010   limitations. You may obtain instructions on how to receive a copy of the
00011   License at http://www.systemc.org/. Software distributed by Contributors
00012   under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
00013   ANY KIND, either express or implied. See the License for the specific
00014   language governing rights and limitations under the License.
00015 
00016  *****************************************************************************/
00017 
00018 /*****************************************************************************
00019 
00020   sc_fxnum.h - 
00021 
00022   Original Author: Martin Janssen, Synopsys, Inc.
00023 
00024  *****************************************************************************/
00025 
00026 /*****************************************************************************
00027 
00028   MODIFICATION LOG - modifiers, enter your name, affiliation, date and
00029   changes you are making here.
00030 
00031       Name, Affiliation, Date:
00032   Description of Modification:
00033 
00034  *****************************************************************************/
00035 
00036 #ifndef SC_FXNUM_H
00037 #define SC_FXNUM_H
00038 
00039 
00040 #include "systemc/datatypes/bit/sc_lv_base.h"
00041 #include "systemc/datatypes/fx/sc_fxval.h"
00042 #include "systemc/datatypes/fx/scfx_params.h"
00043 #include "systemc/datatypes/fx/sc_fxnum_observer.h"
00044 
00045 
00046 class vcd_sc_fxnum_trace;
00047 class vcd_sc_fxnum_fast_trace;
00048 class wif_sc_fxnum_trace;
00049 class wif_sc_fxnum_fast_trace;
00050 
00051 
00052 namespace sc_dt
00053 {
00054 
00055 // classes defined in this module
00056 class sc_fxnum_bitref;
00057 class sc_fxnum_fast_bitref;
00058 class sc_fxnum_subref;
00059 class sc_fxnum_fast_subref;
00060 class sc_fxnum;
00061 class sc_fxnum_fast;
00062 
00063 
00064 // ----------------------------------------------------------------------------
00065 //  CLASS : sc_fxnum_bitref
00066 //
00067 //  Proxy class for bit-selection in class sc_fxnum, behaves like sc_bit.
00068 // ----------------------------------------------------------------------------
00069 
00070 class sc_fxnum_bitref
00071 {
00072     friend class sc_fxnum;
00073     friend class sc_fxnum_fast_bitref;
00074 
00075 
00076     bool get() const;
00077     void set( bool );
00078 
00079 
00080     // constructor
00081 
00082     sc_fxnum_bitref( sc_fxnum&, int );
00083 
00084 public:
00085 
00086     // copy constructor
00087 
00088     sc_fxnum_bitref( const sc_fxnum_bitref& );
00089 
00090 
00091     // assignment operators
00092 
00093 #define DECL_ASN_OP_T(op,tp)                                                  \
00094     sc_fxnum_bitref& operator op ( tp );
00095 
00096 #define DECL_ASN_OP(op)                                                       \
00097     DECL_ASN_OP_T(op,const sc_fxnum_bitref&)                                  \
00098     DECL_ASN_OP_T(op,const sc_fxnum_fast_bitref&)                             \
00099     DECL_ASN_OP_T(op,const sc_bit&)                                           \
00100     DECL_ASN_OP_T(op,bool)
00101 
00102     DECL_ASN_OP(=)
00103 
00104     DECL_ASN_OP(&=)
00105     DECL_ASN_OP(|=)
00106     DECL_ASN_OP(^=)
00107 
00108 #undef DECL_ASN_OP_T
00109 #undef DECL_ASN_OP
00110 
00111 
00112     // implicit conversion
00113 
00114     operator bool() const;
00115 
00116 
00117     // print or dump content
00118 
00119     void print( ostream& = cout ) const;
00120     void scan( istream& = cin );
00121     void dump( ostream& = cout ) const;
00122 
00123 private:
00124 
00125     sc_fxnum& m_num;
00126     int       m_idx;
00127 
00128 private:
00129 
00130     // disabled
00131     sc_fxnum_bitref();
00132 };
00133 
00134 
00135 // ----------------------------------------------------------------------------
00136 //  CLASS : sc_fxnum_fast_bitref
00137 //
00138 //  Proxy class for bit-selection in class sc_fxnum_fast, behaves like sc_bit.
00139 // ----------------------------------------------------------------------------
00140 
00141 class sc_fxnum_fast_bitref
00142 {
00143     friend class sc_fxnum_fast;
00144     friend class sc_fxnum_bitref;
00145 
00146 
00147     bool get() const;
00148     void set( bool );
00149 
00150 
00151     // constructor
00152 
00153     sc_fxnum_fast_bitref( sc_fxnum_fast&, int );
00154 
00155 public:
00156 
00157     // copy constructor
00158 
00159     sc_fxnum_fast_bitref( const sc_fxnum_fast_bitref& );
00160 
00161 
00162     // assignment operators
00163 
00164 #define DECL_ASN_OP_T(op,tp)                                                  \
00165     sc_fxnum_fast_bitref& operator op ( tp );
00166 
00167 #define DECL_ASN_OP(op)                                                       \
00168     DECL_ASN_OP_T(op,const sc_fxnum_bitref&)                                  \
00169     DECL_ASN_OP_T(op,const sc_fxnum_fast_bitref&)                             \
00170     DECL_ASN_OP_T(op,const sc_bit&)                                           \
00171     DECL_ASN_OP_T(op,bool)
00172 
00173     DECL_ASN_OP(=)
00174 
00175     DECL_ASN_OP(&=)
00176     DECL_ASN_OP(|=)
00177     DECL_ASN_OP(^=)
00178 
00179 #undef DECL_ASN_OP_T
00180 #undef DECL_ASN_OP
00181 
00182 
00183     // implicit conversion
00184 
00185     operator bool() const;
00186 
00187 
00188     // print or dump content
00189 
00190     void print( ostream& = cout ) const;
00191     void scan( istream& = cin );
00192     void dump( ostream& = cout ) const;
00193 
00194 private:
00195 
00196     sc_fxnum_fast& m_num;
00197     int            m_idx;
00198 
00199 private:
00200 
00201     // disabled
00202     sc_fxnum_fast_bitref();
00203 };
00204 
00205 
00206 // ----------------------------------------------------------------------------
00207 //  CLASS : sc_fxnum_subref
00208 //
00209 //  Proxy class for part-selection in class sc_fxnum,
00210 //  behaves like sc_bv_base.
00211 // ----------------------------------------------------------------------------
00212 
00213 class sc_fxnum_subref
00214 {
00215     friend class sc_fxnum;
00216     friend class sc_fxnum_fast_subref;
00217 
00218     bool get() const;
00219     bool set();
00220 
00221 
00222     // constructor
00223 
00224     sc_fxnum_subref( sc_fxnum&, int, int );
00225 
00226 public:
00227 
00228     // copy constructor
00229 
00230     sc_fxnum_subref( const sc_fxnum_subref& );
00231 
00232 
00233     // destructor
00234 
00235     ~sc_fxnum_subref();
00236 
00237 
00238     // assignment operators
00239 
00240 #define DECL_ASN_OP_T(tp)                                                     \
00241     sc_fxnum_subref& operator = ( tp );
00242 
00243     DECL_ASN_OP_T(const sc_fxnum_subref&)
00244     DECL_ASN_OP_T(const sc_fxnum_fast_subref&)
00245     DECL_ASN_OP_T(const sc_bv_base&)
00246     DECL_ASN_OP_T(const sc_lv_base&)
00247     DECL_ASN_OP_T(const char*)
00248     DECL_ASN_OP_T(const bool*)
00249     DECL_ASN_OP_T(const sc_signed&)
00250     DECL_ASN_OP_T(const sc_unsigned&)
00251     DECL_ASN_OP_T(const sc_int_base&)
00252     DECL_ASN_OP_T(const sc_uint_base&)
00253     DECL_ASN_OP_T(int64)
00254     DECL_ASN_OP_T(uint64)
00255     DECL_ASN_OP_T(int)
00256     DECL_ASN_OP_T(unsigned int)
00257     DECL_ASN_OP_T(long)
00258     DECL_ASN_OP_T(unsigned long)
00259     DECL_ASN_OP_T(char)
00260 
00261 #undef DECL_ASN_OP_T
00262 
00263 #define DECL_ASN_OP_T_A(op,tp)                                                \
00264     sc_fxnum_subref& operator op ## = ( tp );
00265 
00266 #define DECL_ASN_OP_A(op)                                                     \
00267     DECL_ASN_OP_T_A(op,const sc_fxnum_subref&)                                \
00268     DECL_ASN_OP_T_A(op,const sc_fxnum_fast_subref&)                           \
00269     DECL_ASN_OP_T_A(op,const sc_bv_base&)                                     \
00270     DECL_ASN_OP_T_A(op,const sc_lv_base&)
00271 
00272     DECL_ASN_OP_A(&)
00273     DECL_ASN_OP_A(|)
00274     DECL_ASN_OP_A(^)
00275 
00276 #undef DECL_ASN_OP_T_A
00277 #undef DECL_ASN_OP_A
00278 
00279 
00280     // relational operators
00281 
00282 #define DECL_REL_OP_T(op,tp)                                                  \
00283     friend bool operator op ( const sc_fxnum_subref&, tp );                   \
00284     friend bool operator op ( tp, const sc_fxnum_subref& );
00285 
00286 #define DECL_REL_OP(op)                                                       \
00287     friend bool operator op ( const sc_fxnum_subref&,                         \
00288             const sc_fxnum_subref& );                       \
00289     friend bool operator op ( const sc_fxnum_subref&,                         \
00290             const sc_fxnum_fast_subref& );                  \
00291     DECL_REL_OP_T(op,const sc_bv_base&)                                       \
00292     DECL_REL_OP_T(op,const sc_lv_base&)                                       \
00293     DECL_REL_OP_T(op,const char*)                                             \
00294     DECL_REL_OP_T(op,const bool*)                                             \
00295     DECL_REL_OP_T(op,const sc_signed&)                                        \
00296     DECL_REL_OP_T(op,const sc_unsigned&)                                      \
00297     DECL_REL_OP_T(op,int)                                                     \
00298     DECL_REL_OP_T(op,unsigned int)                                            \
00299     DECL_REL_OP_T(op,long)                                                    \
00300     DECL_REL_OP_T(op,unsigned long)
00301 
00302     DECL_REL_OP(==)
00303     DECL_REL_OP(!=)
00304 
00305 #undef DECL_REL_OP_T
00306 #undef DECL_REL_OP
00307 
00308 
00309     // reduce functions
00310 
00311     bool and_reduce() const;
00312     bool nand_reduce() const;
00313     bool or_reduce() const;
00314     bool nor_reduce() const;
00315     bool xor_reduce() const;
00316     bool xnor_reduce() const;
00317 
00318 
00319     // query parameter
00320 
00321     int length() const;
00322 
00323 
00324     // explicit conversions
00325 
00326     int           to_int() const;
00327     unsigned int  to_uint() const;
00328     long          to_long() const;
00329     unsigned long to_ulong() const;
00330 
00331 #ifdef SC_DT_DEPRECATED
00332     int           to_signed() const;
00333     unsigned int  to_unsigned() const;
00334 #endif
00335 
00336     const sc_string to_string() const;
00337     const sc_string to_string( sc_numrep ) const;
00338     const sc_string to_string( sc_numrep, bool ) const;
00339 
00340 
00341     // implicit conversion
00342 
00343     operator sc_bv_base() const;
00344 
00345 
00346     // print or dump content
00347 
00348     void print( ostream& = cout ) const;
00349     void scan( istream& = cin );
00350     void dump( ostream& = cout ) const;
00351 
00352 private:
00353 
00354     sc_fxnum& m_num;
00355     int       m_from;
00356     int       m_to;
00357 
00358     sc_bv_base& m_bv;
00359 
00360 private:
00361 
00362     // disabled
00363     sc_fxnum_subref();
00364 };
00365 
00366 
00367 // ----------------------------------------------------------------------------
00368 //  CLASS : sc_fxnum_fast_subref
00369 //
00370 //  Proxy class for part-selection in class sc_fxnum_fast,
00371 //  behaves like sc_bv_base.
00372 // ----------------------------------------------------------------------------
00373 
00374 class sc_fxnum_fast_subref
00375 {
00376     friend class sc_fxnum_fast;
00377     friend class sc_fxnum_subref;
00378 
00379     bool get() const;
00380     bool set();
00381 
00382 
00383     // constructor
00384 
00385     sc_fxnum_fast_subref( sc_fxnum_fast&, int, int );
00386 
00387 public:
00388 
00389     // copy constructor
00390 
00391     sc_fxnum_fast_subref( const sc_fxnum_fast_subref& );
00392 
00393 
00394     // destructor
00395 
00396     ~sc_fxnum_fast_subref();
00397 
00398 
00399     // assignment operators
00400 
00401 #define DECL_ASN_OP_T(tp)                                                     \
00402     sc_fxnum_fast_subref& operator = ( tp );
00403 
00404     DECL_ASN_OP_T(const sc_fxnum_subref&)
00405     DECL_ASN_OP_T(const sc_fxnum_fast_subref&)
00406     DECL_ASN_OP_T(const sc_bv_base&)
00407     DECL_ASN_OP_T(const sc_lv_base&)
00408     DECL_ASN_OP_T(const char*)
00409     DECL_ASN_OP_T(const bool*)
00410     DECL_ASN_OP_T(const sc_signed&)
00411     DECL_ASN_OP_T(const sc_unsigned&)
00412     DECL_ASN_OP_T(const sc_int_base&)
00413     DECL_ASN_OP_T(const sc_uint_base&)
00414     DECL_ASN_OP_T(int64)
00415     DECL_ASN_OP_T(uint64)
00416     DECL_ASN_OP_T(int)
00417     DECL_ASN_OP_T(unsigned int)
00418     DECL_ASN_OP_T(long)
00419     DECL_ASN_OP_T(unsigned long)
00420     DECL_ASN_OP_T(char)
00421 
00422 #undef DECL_ASN_OP_T
00423 
00424 #define DECL_ASN_OP_T_A(op,tp)                                                \
00425     sc_fxnum_fast_subref& operator op ## = ( tp );
00426 
00427 #define DECL_ASN_OP_A(op)                                                     \
00428     DECL_ASN_OP_T_A(op,const sc_fxnum_subref&)                                \
00429     DECL_ASN_OP_T_A(op,const sc_fxnum_fast_subref&)                           \
00430     DECL_ASN_OP_T_A(op,const sc_bv_base&)                                     \
00431     DECL_ASN_OP_T_A(op,const sc_lv_base&)
00432 
00433     DECL_ASN_OP_A(&)
00434     DECL_ASN_OP_A(|)
00435     DECL_ASN_OP_A(^)
00436 
00437 #undef DECL_ASN_OP_T_A
00438 #undef DECL_ASN_OP_A
00439 
00440 
00441     // relational operators
00442 
00443 #define DECL_REL_OP_T(op,tp)                                                  \
00444     friend bool operator op ( const sc_fxnum_fast_subref&, tp );              \
00445     friend bool operator op ( tp, const sc_fxnum_fast_subref& );
00446 
00447 #define DECL_REL_OP(op)                                                       \
00448     friend bool operator op ( const sc_fxnum_fast_subref&,                    \
00449             const sc_fxnum_fast_subref& );                  \
00450     friend bool operator op ( const sc_fxnum_fast_subref&,                    \
00451             const sc_fxnum_subref& );                       \
00452     DECL_REL_OP_T(op,const sc_bv_base&)                                       \
00453     DECL_REL_OP_T(op,const sc_lv_base&)                                       \
00454     DECL_REL_OP_T(op,const char*)                                             \
00455     DECL_REL_OP_T(op,const bool*)                                             \
00456     DECL_REL_OP_T(op,const sc_signed&)                                        \
00457     DECL_REL_OP_T(op,const sc_unsigned&)                                      \
00458     DECL_REL_OP_T(op,int)                                                     \
00459     DECL_REL_OP_T(op,unsigned int)                                            \
00460     DECL_REL_OP_T(op,long)                                                    \
00461     DECL_REL_OP_T(op,unsigned long)
00462 
00463     DECL_REL_OP(==)
00464     DECL_REL_OP(!=)
00465 
00466 #undef DECL_REL_OP_T
00467 #undef DECL_REL_OP
00468 
00469 
00470     // reduce functions
00471 
00472     bool and_reduce() const;
00473     bool nand_reduce() const;
00474     bool or_reduce() const;
00475     bool nor_reduce() const;
00476     bool xor_reduce() const;
00477     bool xnor_reduce() const;
00478 
00479 
00480     // query parameter
00481 
00482     int length() const;
00483 
00484 
00485     // explicit conversions
00486 
00487     int           to_int() const;
00488     unsigned int  to_uint() const;
00489     long          to_long() const;
00490     unsigned long to_ulong() const;
00491 
00492 #ifdef SC_DT_DEPRECATED
00493     int           to_signed() const;
00494     unsigned int  to_unsigned() const;
00495 #endif
00496 
00497     const sc_string to_string() const;
00498     const sc_string to_string( sc_numrep ) const;
00499     const sc_string to_string( sc_numrep, bool ) const;
00500 
00501 
00502     // implicit conversion
00503 
00504     operator sc_bv_base() const;
00505 
00506 
00507     // print or dump content
00508 
00509     void print( ostream& = cout ) const;
00510     void scan( istream& = cin );
00511     void dump( ostream& = cout ) const;
00512 
00513 private:
00514 
00515     sc_fxnum_fast& m_num;
00516     int            m_from;
00517     int            m_to;
00518 
00519     sc_bv_base& m_bv;
00520 
00521 private:
00522 
00523     // disabled
00524     sc_fxnum_fast_subref();
00525 };
00526 
00527 
00528 // ----------------------------------------------------------------------------
00529 //  CLASS : sc_fxnum
00530 //
00531 //  Base class for the fixed-point types; arbitrary precision.
00532 // ----------------------------------------------------------------------------
00533 
00534 class sc_fxnum
00535 {
00536     friend class sc_fxval;
00537 
00538     friend class sc_fxnum_bitref;
00539     friend class sc_fxnum_subref;
00540     friend class sc_fxnum_fast_bitref;
00541     friend class sc_fxnum_fast_subref;
00542 
00543     friend class ::vcd_sc_fxnum_trace;
00544     friend class ::wif_sc_fxnum_trace;
00545 
00546 protected:
00547 
00548     sc_fxnum_observer* observer() const;
00549 
00550 
00551     void cast();
00552 
00553 
00554     // constructors
00555 
00556     sc_fxnum( const sc_fxtype_params&,
00557         sc_enc,
00558         const sc_fxcast_switch&,
00559         sc_fxnum_observer* );
00560 
00561 #define DECL_CTOR_T(tp)                                                       \
00562     sc_fxnum( tp,                                                             \
00563         const sc_fxtype_params&,                                        \
00564         sc_enc,                                                         \
00565         const sc_fxcast_switch&,                                        \
00566         sc_fxnum_observer* );
00567 
00568     DECL_CTOR_T(int)
00569     DECL_CTOR_T(unsigned int)
00570     DECL_CTOR_T(long)
00571     DECL_CTOR_T(unsigned long)
00572     DECL_CTOR_T(double)
00573     DECL_CTOR_T(const char*)
00574     DECL_CTOR_T(const sc_fxval&)
00575     DECL_CTOR_T(const sc_fxval_fast&)
00576     DECL_CTOR_T(const sc_fxnum&)
00577     DECL_CTOR_T(const sc_fxnum_fast&)
00578 #ifndef SC_FX_EXCLUDE_OTHER
00579     DECL_CTOR_T(int64)
00580     DECL_CTOR_T(uint64)
00581     DECL_CTOR_T(const sc_int_base&)
00582     DECL_CTOR_T(const sc_uint_base&)
00583     DECL_CTOR_T(const sc_signed&)
00584     DECL_CTOR_T(const sc_unsigned&)
00585 #endif
00586 
00587 #undef DECL_CTOR_T
00588 
00589     ~sc_fxnum();
00590 
00591 
00592     // internal use only;
00593     const scfx_rep* get_rep() const;
00594 
00595 public:
00596 
00597     // unary operators
00598 
00599     const sc_fxval operator - () const;
00600     const sc_fxval operator + () const;
00601 
00602 
00603     // unary functions
00604 
00605     friend void neg( sc_fxval&, const sc_fxnum& );
00606     friend void neg( sc_fxnum&, const sc_fxnum& );
00607 
00608 
00609     // binary operators
00610 
00611 #define DECL_BIN_OP_T(op,tp)                                                  \
00612     friend const sc_fxval operator op ( const sc_fxnum&, tp );                \
00613     friend const sc_fxval operator op ( tp, const sc_fxnum& );
00614 
00615 #ifndef SC_FX_EXCLUDE_OTHER
00616 #define DECL_BIN_OP_OTHER(op)                                                 \
00617     DECL_BIN_OP_T(op,int64)                                                   \
00618     DECL_BIN_OP_T(op,uint64)                                                  \
00619     DECL_BIN_OP_T(op,const sc_int_base&)                                      \
00620     DECL_BIN_OP_T(op,const sc_uint_base&)                                     \
00621     DECL_BIN_OP_T(op,const sc_signed&)                                        \
00622     DECL_BIN_OP_T(op,const sc_unsigned&)
00623 #else
00624 #define DECL_BIN_OP_OTHER(op)
00625 #endif
00626 
00627 #define DECL_BIN_OP(op,dummy)                                                 \
00628     friend const sc_fxval operator op ( const sc_fxnum&, const sc_fxnum& );   \
00629     DECL_BIN_OP_T(op,int)                                                     \
00630     DECL_BIN_OP_T(op,unsigned int)                                            \
00631     DECL_BIN_OP_T(op,long)                                                    \
00632     DECL_BIN_OP_T(op,unsigned long)                                           \
00633     DECL_BIN_OP_T(op,double)                                                  \
00634     DECL_BIN_OP_T(op,const char*)                                             \
00635     DECL_BIN_OP_T(op,const sc_fxval&)                                         \
00636     DECL_BIN_OP_T(op,const sc_fxval_fast&)                                    \
00637     DECL_BIN_OP_T(op,const sc_fxnum_fast&)                                    \
00638     DECL_BIN_OP_OTHER(op)
00639 
00640     DECL_BIN_OP(*,mult)
00641     DECL_BIN_OP(+,add)
00642     DECL_BIN_OP(-,sub)
00643 // don't use macros
00644 //    DECL_BIN_OP(/,div)
00645     friend const sc_fxval operator / ( const sc_fxnum&, const sc_fxnum& );
00646     DECL_BIN_OP_T(/,int)
00647     DECL_BIN_OP_T(/,unsigned int)
00648     DECL_BIN_OP_T(/,long)
00649     DECL_BIN_OP_T(/,unsigned long)
00650     DECL_BIN_OP_T(/,double)
00651     DECL_BIN_OP_T(/,const char*)
00652     DECL_BIN_OP_T(/,const sc_fxval&)
00653     DECL_BIN_OP_T(/,const sc_fxval_fast&)
00654     DECL_BIN_OP_T(/,const sc_fxnum_fast&)
00655 //    DECL_BIN_OP_OTHER(op)
00656 #ifndef SC_FX_EXCLUDE_OTHER
00657     DECL_BIN_OP_T(/,int64)
00658     DECL_BIN_OP_T(/,uint64)
00659     DECL_BIN_OP_T(/,const sc_int_base&)
00660     DECL_BIN_OP_T(/,const sc_uint_base&)
00661     DECL_BIN_OP_T(/,const sc_signed&)
00662     DECL_BIN_OP_T(/,const sc_unsigned&)
00663 #endif
00664 
00665 #undef DECL_BIN_OP_T
00666 #undef DECL_BIN_OP_OTHER
00667 #undef DECL_BIN_OP
00668 
00669     friend const sc_fxval operator << ( const sc_fxnum&, int );
00670     friend const sc_fxval operator >> ( const sc_fxnum&, int );
00671 
00672 
00673     // binary functions
00674 
00675 #define DECL_BIN_FNC_T(fnc,tp)                                                \
00676     friend void fnc ( sc_fxval&, const sc_fxnum&, tp );                       \
00677     friend void fnc ( sc_fxval&, tp, const sc_fxnum& );                       \
00678     friend void fnc ( sc_fxnum&, const sc_fxnum&, tp );                       \
00679     friend void fnc ( sc_fxnum&, tp, const sc_fxnum& );
00680 
00681 #ifndef SC_FX_EXCLUDE_OTHER
00682 #define DECL_BIN_FNC_OTHER(fnc)                                               \
00683     DECL_BIN_FNC_T(fnc,int64)                                                 \
00684     DECL_BIN_FNC_T(fnc,uint64)                                                \
00685     DECL_BIN_FNC_T(fnc,const sc_int_base&)                                    \
00686     DECL_BIN_FNC_T(fnc,const sc_uint_base&)                                   \
00687     DECL_BIN_FNC_T(fnc,const sc_signed&)                                      \
00688     DECL_BIN_FNC_T(fnc,const sc_unsigned&)
00689 #else
00690 #define DECL_BIN_FNC_OTHER(fnc)
00691 #endif
00692 
00693 #define DECL_BIN_FNC(fnc)                                                     \
00694     friend void fnc ( sc_fxval&, const sc_fxnum&, const sc_fxnum& );          \
00695     friend void fnc ( sc_fxnum&, const sc_fxnum&, const sc_fxnum& );          \
00696     DECL_BIN_FNC_T(fnc,int)                                                   \
00697     DECL_BIN_FNC_T(fnc,unsigned int)                                          \
00698     DECL_BIN_FNC_T(fnc,long)                                                  \
00699     DECL_BIN_FNC_T(fnc,unsigned long)                                         \
00700     DECL_BIN_FNC_T(fnc,double)                                                \
00701     DECL_BIN_FNC_T(fnc,const char*)                                           \
00702     DECL_BIN_FNC_T(fnc,const sc_fxval&)                                       \
00703     DECL_BIN_FNC_T(fnc,const sc_fxval_fast&)                                  \
00704     DECL_BIN_FNC_T(fnc,const sc_fxnum_fast&)                                  \
00705     DECL_BIN_FNC_OTHER(fnc)
00706 
00707     DECL_BIN_FNC(mult)
00708     DECL_BIN_FNC(div)
00709     DECL_BIN_FNC(add)
00710     DECL_BIN_FNC(sub)
00711 
00712 #undef DECL_BIN_FNC_T
00713 #undef DECL_BIN_FNC_OTHER
00714 #undef DECL_BIN_FNC
00715 
00716     friend void lshift( sc_fxval&, const sc_fxnum&, int );
00717     friend void rshift( sc_fxval&, const sc_fxnum&, int );
00718     friend void lshift( sc_fxnum&, const sc_fxnum&, int );
00719     friend void rshift( sc_fxnum&, const sc_fxnum&, int );
00720 
00721 
00722     // relational (including equality) operators
00723 
00724 #define DECL_REL_OP_T(op,tp)                                                  \
00725     friend bool operator op ( const sc_fxnum&, tp );                          \
00726     friend bool operator op ( tp, const sc_fxnum& );
00727 
00728 #ifndef SC_FX_EXCLUDE_OTHER
00729 #define DECL_REL_OP_OTHER(op)                                                 \
00730     DECL_REL_OP_T(op,int64)                                                   \
00731     DECL_REL_OP_T(op,uint64)                                                  \
00732     DECL_REL_OP_T(op,const sc_int_base&)                                      \
00733     DECL_REL_OP_T(op,const sc_uint_base&)                                     \
00734     DECL_REL_OP_T(op,const sc_signed&)                                        \
00735     DECL_REL_OP_T(op,const sc_unsigned&)
00736 #else
00737 #define DECL_REL_OP_OTHER(op)
00738 #endif
00739 
00740 #define DECL_REL_OP(op)                                                       \
00741     friend bool operator op ( const sc_fxnum&, const sc_fxnum& );             \
00742     DECL_REL_OP_T(op,int)                                                     \
00743     DECL_REL_OP_T(op,unsigned int)                                            \
00744     DECL_REL_OP_T(op,long)                                                    \
00745     DECL_REL_OP_T(op,unsigned long)                                           \
00746     DECL_REL_OP_T(op,double)                                                  \
00747     DECL_REL_OP_T(op,const char*)                                             \
00748     DECL_REL_OP_T(op,const sc_fxval&)                                         \
00749     DECL_REL_OP_T(op,const sc_fxval_fast&)                                    \
00750     DECL_REL_OP_T(op,const sc_fxnum_fast&)                                    \
00751     DECL_REL_OP_OTHER(op)
00752 
00753     DECL_REL_OP(<)
00754     DECL_REL_OP(<=)
00755     DECL_REL_OP(>)
00756     DECL_REL_OP(>=)
00757     DECL_REL_OP(==)
00758     DECL_REL_OP(!=)
00759 
00760 #undef DECL_REL_OP_T
00761 #undef DECL_REL_OP_OTHER
00762 #undef DECL_REL_OP
00763 
00764 
00765     // assignment operators
00766 
00767 #define DECL_ASN_OP_T(op,tp)                                                  \
00768     sc_fxnum& operator op( tp );
00769 
00770 #ifndef SC_FX_EXCLUDE_OTHER
00771 #define DECL_ASN_OP_OTHER(op)                                                 \
00772     DECL_ASN_OP_T(op,int64)                                                   \
00773     DECL_ASN_OP_T(op,uint64)                                                  \
00774     DECL_ASN_OP_T(op,const sc_int_base&)                                      \
00775     DECL_ASN_OP_T(op,const sc_uint_base&)                                     \
00776     DECL_ASN_OP_T(op,const sc_signed&)                                        \
00777     DECL_ASN_OP_T(op,const sc_unsigned&)
00778 #else
00779 #define DECL_ASN_OP_OTHER(op)
00780 #endif
00781 
00782 #define DECL_ASN_OP(op)                                                       \
00783     DECL_ASN_OP_T(op,int)                                                     \
00784     DECL_ASN_OP_T(op,unsigned int)                                            \
00785     DECL_ASN_OP_T(op,long)                                                    \
00786     DECL_ASN_OP_T(op,unsigned long)                                           \
00787     DECL_ASN_OP_T(op,double)                                                  \
00788     DECL_ASN_OP_T(op,const char*)                                             \
00789     DECL_ASN_OP_T(op,const sc_fxval&)                                         \
00790     DECL_ASN_OP_T(op,const sc_fxval_fast&)                                    \
00791     DECL_ASN_OP_T(op,const sc_fxnum&)                                         \
00792     DECL_ASN_OP_T(op,const sc_fxnum_fast&)                                    \
00793     DECL_ASN_OP_OTHER(op)
00794 
00795     DECL_ASN_OP(=)
00796 
00797     DECL_ASN_OP(*=)
00798     DECL_ASN_OP(/=)
00799     DECL_ASN_OP(+=)
00800     DECL_ASN_OP(-=)
00801 
00802     DECL_ASN_OP_T(<<=,int)
00803     DECL_ASN_OP_T(>>=,int)
00804 
00805 #undef DECL_ASN_OP_T
00806 #undef DECL_ASN_OP_OTHER
00807 #undef DECL_ASN_OP
00808 
00809 
00810     // auto-increment and auto-decrement
00811 
00812     const sc_fxval operator ++ ( int );
00813     const sc_fxval operator -- ( int );
00814 
00815     sc_fxnum& operator ++ ();
00816     sc_fxnum& operator -- ();
00817 
00818 
00819     // bit selection
00820 
00821     const sc_fxnum_bitref operator [] ( int ) const;
00822     sc_fxnum_bitref       operator [] ( int );
00823 
00824     const sc_fxnum_bitref bit( int ) const;
00825     sc_fxnum_bitref       bit( int );
00826 
00827 
00828     // part selection
00829 
00830     const sc_fxnum_subref operator () ( int, int ) const;
00831     sc_fxnum_subref       operator () ( int, int );
00832 
00833     const sc_fxnum_subref range( int, int ) const;
00834     sc_fxnum_subref       range( int, int );
00835 
00836 
00837     const sc_fxnum_subref operator () () const;
00838     sc_fxnum_subref       operator () ();
00839 
00840     const sc_fxnum_subref range() const;
00841     sc_fxnum_subref       range();
00842 
00843 
00844     // implicit conversion
00845 
00846     operator double() const;    // necessary evil!
00847 
00848 
00849     // explicit conversion to primitive types
00850 
00851     short          to_short() const;
00852     unsigned short to_ushort() const;
00853     int            to_int() const;
00854     unsigned int   to_uint() const;
00855     long           to_long() const;
00856     unsigned long  to_ulong() const;
00857     float          to_float() const;
00858     double         to_double() const;
00859 
00860 
00861     // explicit conversion to character string
00862 
00863     const sc_string to_string() const;
00864     const sc_string to_string( sc_numrep ) const;
00865     const sc_string to_string( sc_numrep, bool ) const;
00866     const sc_string to_string( sc_fmt ) const;
00867     const sc_string to_string( sc_numrep, sc_fmt ) const;
00868     const sc_string to_string( sc_numrep, bool, sc_fmt ) const;
00869 
00870     const sc_string to_dec() const;
00871     const sc_string to_bin() const;
00872     const sc_string to_oct() const;
00873     const sc_string to_hex() const;
00874 
00875 
00876     // query value
00877 
00878     bool is_neg() const;
00879     bool is_zero() const;
00880 
00881     // internal use only;
00882     bool is_normal() const;
00883 
00884     bool quantization_flag() const;
00885     bool overflow_flag() const;
00886 
00887     const sc_fxval value() const;
00888 
00889 
00890     // query parameters
00891 
00892     int       wl() const;
00893     int       iwl() const;
00894     sc_q_mode q_mode() const;
00895     sc_o_mode o_mode() const;
00896     int       n_bits() const;
00897 
00898     const sc_fxtype_params& type_params() const;
00899 
00900     const sc_fxcast_switch& cast_switch() const;
00901 
00902 
00903     // print or dump content
00904 
00905     void print( ostream& = cout ) const;
00906     void scan( istream& = cin );
00907     void dump( ostream& = cout ) const;
00908 
00909 
00910     // internal use only;
00911     void observer_read() const;
00912 
00913 
00914     // internal use only;
00915     bool get_bit( int ) const;
00916 
00917 protected:
00918 
00919     bool set_bit( int, bool );
00920 
00921 
00922     bool get_slice( int, int, sc_bv_base& ) const;
00923     bool set_slice( int, int, const sc_bv_base& );
00924 
00925 
00926     sc_fxnum_observer* lock_observer() const;
00927     void unlock_observer( sc_fxnum_observer* ) const;
00928 
00929 private:
00930 
00931     scfx_rep*                  m_rep;
00932 
00933     scfx_params                m_params;
00934     bool                       m_q_flag;
00935     bool                       m_o_flag;
00936 
00937     mutable sc_fxnum_observer* m_observer;
00938 
00939 private:
00940 
00941     // disabled
00942     sc_fxnum();
00943     sc_fxnum( const sc_fxnum& );
00944 };
00945 
00946 
00947 // ----------------------------------------------------------------------------
00948 //  CLASS : sc_fxnum_fast
00949 //
00950 //  Base class for the fixed-point types; limited precision.
00951 // ----------------------------------------------------------------------------
00952 
00953 class sc_fxnum_fast
00954 {
00955     friend class sc_fxval_fast;
00956 
00957     friend class sc_fxnum_bitref;
00958     friend class sc_fxnum_subref;
00959     friend class sc_fxnum_fast_bitref;
00960     friend class sc_fxnum_fast_subref;
00961 
00962     friend class ::vcd_sc_fxnum_fast_trace;
00963     friend class ::wif_sc_fxnum_fast_trace;
00964 
00965 protected:
00966 
00967     sc_fxnum_fast_observer* observer() const;
00968 
00969 
00970     void cast();
00971 
00972 
00973     // constructors
00974 
00975     sc_fxnum_fast( const sc_fxtype_params&,
00976        sc_enc,
00977        const sc_fxcast_switch&,
00978        sc_fxnum_fast_observer* );
00979 
00980 #define DECL_CTOR_T(tp)                                                       \
00981     sc_fxnum_fast( tp,                                                        \
00982              const sc_fxtype_params&,                                   \
00983              sc_enc,                                                    \
00984              const sc_fxcast_switch&,                                   \
00985              sc_fxnum_fast_observer* );
00986 
00987     DECL_CTOR_T(int)
00988     DECL_CTOR_T(unsigned int)
00989     DECL_CTOR_T(long)
00990     DECL_CTOR_T(unsigned long)
00991     DECL_CTOR_T(double)
00992     DECL_CTOR_T(const char*)
00993     DECL_CTOR_T(const sc_fxval&)
00994     DECL_CTOR_T(const sc_fxval_fast&)
00995     DECL_CTOR_T(const sc_fxnum&)
00996     DECL_CTOR_T(const sc_fxnum_fast&)
00997 #ifndef SC_FX_EXCLUDE_OTHER
00998     DECL_CTOR_T(int64)
00999     DECL_CTOR_T(uint64)
01000     DECL_CTOR_T(const sc_int_base&)
01001     DECL_CTOR_T(const sc_uint_base&)
01002     DECL_CTOR_T(const sc_signed&)
01003     DECL_CTOR_T(const sc_unsigned&)
01004 #endif
01005 
01006 #undef DECL_CTOR_T
01007 
01008     ~sc_fxnum_fast();
01009 
01010 
01011     // internal use only;
01012     double get_val() const;
01013 
01014 public:
01015 
01016     // unary operators
01017 
01018     const sc_fxval_fast operator - () const;
01019     const sc_fxval_fast operator + () const;
01020 
01021 
01022     // unary functions
01023 
01024     friend void neg( sc_fxval_fast&, const sc_fxnum_fast& );
01025     friend void neg( sc_fxnum_fast&, const sc_fxnum_fast& );
01026 
01027 
01028     // binary operators
01029 
01030 #define DECL_BIN_OP_T(op,tp)                                                  \
01031     friend const sc_fxval_fast operator op ( const sc_fxnum_fast&, tp );      \
01032     friend const sc_fxval_fast operator op ( tp, const sc_fxnum_fast& );
01033 
01034 #ifndef SC_FX_EXCLUDE_OTHER
01035 #define DECL_BIN_OP_OTHER(op)                                                 \
01036     DECL_BIN_OP_T(op,int64)                                                   \
01037     DECL_BIN_OP_T(op,uint64)                                                  \
01038     DECL_BIN_OP_T(op,const sc_int_base&)                                      \
01039     DECL_BIN_OP_T(op,const sc_uint_base&)                                     \
01040     DECL_BIN_OP_T(op,const sc_signed&)                                        \
01041     DECL_BIN_OP_T(op,const sc_unsigned&)
01042 #else
01043 #define DECL_BIN_OP_OTHER(op)
01044 #endif
01045 
01046 #define DECL_BIN_OP(op,dummy)                                                 \
01047     friend const sc_fxval_fast operator op ( const sc_fxnum_fast&,            \
01048                const sc_fxnum_fast& );          \
01049     DECL_BIN_OP_T(op,int)                                                     \
01050     DECL_BIN_OP_T(op,unsigned int)                                            \
01051     DECL_BIN_OP_T(op,long)                                                    \
01052     DECL_BIN_OP_T(op,unsigned long)                                           \
01053     DECL_BIN_OP_T(op,double)                                                  \
01054     DECL_BIN_OP_T(op,const char*)                                             \
01055     DECL_BIN_OP_T(op,const sc_fxval_fast&)                                    \
01056     DECL_BIN_OP_OTHER(op)
01057 
01058     DECL_BIN_OP(*,mult)
01059     DECL_BIN_OP(+,add)
01060     DECL_BIN_OP(-,sub)
01061 //    DECL_BIN_OP(/,div)
01062     friend const sc_fxval_fast operator / ( const sc_fxnum_fast&,
01063                const sc_fxnum_fast& );
01064     DECL_BIN_OP_T(/,int)
01065     DECL_BIN_OP_T(/,unsigned int)
01066     DECL_BIN_OP_T(/,long)
01067     DECL_BIN_OP_T(/,unsigned long)
01068     DECL_BIN_OP_T(/,double)
01069     DECL_BIN_OP_T(/,const char*)
01070     DECL_BIN_OP_T(/,const sc_fxval_fast&)
01071 //    DECL_BIN_OP_OTHER(op)
01072 #ifndef SC_FX_EXCLUDE_OTHER
01073     DECL_BIN_OP_T(/,int64)                                                   \
01074     DECL_BIN_OP_T(/,uint64)                                                  \
01075     DECL_BIN_OP_T(/,const sc_int_base&)                                      \
01076     DECL_BIN_OP_T(/,const sc_uint_base&)                                     \
01077     DECL_BIN_OP_T(/,const sc_signed&)                                        \
01078     DECL_BIN_OP_T(/,const sc_unsigned&)
01079 #endif
01080 
01081 #undef DECL_BIN_OP_T
01082 #undef DECL_BIN_OP_OTHER
01083 #undef DECL_BIN_OP
01084 
01085     friend const sc_fxval_fast operator << ( const sc_fxnum_fast&, int );
01086     friend const sc_fxval_fast operator >> ( const sc_fxnum_fast&, int );
01087 
01088 
01089     // binary functions
01090 
01091 #define DECL_BIN_FNC_T(fnc,tp)                                                \
01092     friend void fnc ( sc_fxval_fast&, const sc_fxnum_fast&, tp );             \
01093     friend void fnc ( sc_fxval_fast&, tp, const sc_fxnum_fast& );             \
01094     friend void fnc ( sc_fxnum_fast&, const sc_fxnum_fast&, tp );             \
01095     friend void fnc ( sc_fxnum_fast&, tp, const sc_fxnum_fast& );
01096 
01097 #ifndef SC_FX_EXCLUDE_OTHER
01098 #define DECL_BIN_FNC_OTHER(fnc)                                               \
01099     DECL_BIN_FNC_T(fnc,int64)                                                 \
01100     DECL_BIN_FNC_T(fnc,uint64)                                                \
01101     DECL_BIN_FNC_T(fnc,const sc_int_base&)                                    \
01102     DECL_BIN_FNC_T(fnc,const sc_uint_base&)                                   \
01103     DECL_BIN_FNC_T(fnc,const sc_signed&)                                      \
01104     DECL_BIN_FNC_T(fnc,const sc_unsigned&)
01105 #else
01106 #define DECL_BIN_FNC_OTHER(fnc)
01107 #endif
01108 
01109 #define DECL_BIN_FNC(fnc)                                                     \
01110     friend void fnc ( sc_fxval_fast&, const sc_fxnum_fast&,                   \
01111                           const sc_fxnum_fast& );                 \
01112     friend void fnc ( sc_fxnum_fast&, const sc_fxnum_fast&,                   \
01113                           const sc_fxnum_fast& );                 \
01114     DECL_BIN_FNC_T(fnc,int)                                                   \
01115     DECL_BIN_FNC_T(fnc,unsigned int)                                          \
01116     DECL_BIN_FNC_T(fnc,long)                                                  \
01117     DECL_BIN_FNC_T(fnc,unsigned long)                                         \
01118     DECL_BIN_FNC_T(fnc,double)                                                \
01119     DECL_BIN_FNC_T(fnc,const char*)                                           \
01120     DECL_BIN_FNC_T(fnc,const sc_fxval&)                                       \
01121     DECL_BIN_FNC_T(fnc,const sc_fxval_fast&)                                  \
01122     DECL_BIN_FNC_T(fnc,const sc_fxnum&)                                       \
01123     DECL_BIN_FNC_OTHER(fnc)
01124 
01125     DECL_BIN_FNC(mult)
01126     DECL_BIN_FNC(div)
01127     DECL_BIN_FNC(add)
01128     DECL_BIN_FNC(sub)
01129 
01130 #undef DECL_BIN_FNC_T
01131 #undef DECL_BIN_FNC_OTHER
01132 #undef DECL_BIN_FNC
01133 
01134     friend void lshift( sc_fxval_fast&, const sc_fxnum_fast&, int );
01135     friend void rshift( sc_fxval_fast&, const sc_fxnum_fast&, int );
01136     friend void lshift( sc_fxnum_fast&, const sc_fxnum_fast&, int );
01137     friend void rshift( sc_fxnum_fast&, const sc_fxnum_fast&, int );
01138 
01139 
01140     // relational (including equality) operators
01141 
01142 #define DECL_REL_OP_T(op,tp)                                                  \
01143     friend bool operator op ( const sc_fxnum_fast&, tp );                     \
01144     friend bool operator op ( tp, const sc_fxnum_fast& );
01145 
01146 #ifndef SC_FX_EXCLUDE_OTHER
01147 #define DECL_REL_OP_OTHER(op)                                                 \
01148     DECL_REL_OP_T(op,int64)                                                   \
01149     DECL_REL_OP_T(op,uint64)                                                  \
01150     DECL_REL_OP_T(op,const sc_int_base&)                                      \
01151     DECL_REL_OP_T(op,const sc_uint_base&)                                     \
01152     DECL_REL_OP_T(op,const sc_signed&)                                        \
01153     DECL_REL_OP_T(op,const sc_unsigned&)
01154 #else
01155 #define DECL_REL_OP_OTHER(op)
01156 #endif
01157 
01158 #define DECL_REL_OP(op)                                                       \
01159     friend bool operator op ( const sc_fxnum_fast&, const sc_fxnum_fast& );   \
01160     DECL_REL_OP_T(op,int)                                                     \
01161     DECL_REL_OP_T(op,unsigned int)                                            \
01162     DECL_REL_OP_T(op,long)                                                    \
01163     DECL_REL_OP_T(op,unsigned long)                                           \
01164     DECL_REL_OP_T(op,double)                                                  \
01165     DECL_REL_OP_T(op,const char*)                                             \
01166     DECL_REL_OP_T(op,const sc_fxval_fast&)                                    \
01167     DECL_REL_OP_OTHER(op)
01168 
01169     DECL_REL_OP(<)
01170     DECL_REL_OP(<=)
01171     DECL_REL_OP(>)
01172     DECL_REL_OP(>=)
01173     DECL_REL_OP(==)
01174     DECL_REL_OP(!=)
01175 
01176 #undef DECL_REL_OP_T
01177 #undef DECL_REL_OP_OTHER
01178 #undef DECL_REL_OP
01179 
01180 
01181     // assignment operators
01182 
01183 #define DECL_ASN_OP_T(op,tp)                                                  \
01184     sc_fxnum_fast& operator op( tp );
01185 
01186 #ifndef SC_FX_EXCLUDE_OTHER
01187 #define DECL_ASN_OP_OTHER(op)                                                 \
01188     DECL_ASN_OP_T(op,int64)                                                   \
01189     DECL_ASN_OP_T(op,uint64)                                                  \
01190     DECL_ASN_OP_T(op,const sc_int_base&)                                      \
01191     DECL_ASN_OP_T(op,const sc_uint_base&)                                     \
01192     DECL_ASN_OP_T(op,const sc_signed&)                                        \
01193     DECL_ASN_OP_T(op,const sc_unsigned&)
01194 #else
01195 #define DECL_ASN_OP_OTHER(op)
01196 #endif
01197 
01198 #define DECL_ASN_OP(op)                                                       \
01199     DECL_ASN_OP_T(op,int)                                                     \
01200     DECL_ASN_OP_T(op,unsigned int)                                            \
01201     DECL_ASN_OP_T(op,long)                                                    \
01202     DECL_ASN_OP_T(op,unsigned long)                                           \
01203     DECL_ASN_OP_T(op,double)                                                  \
01204     DECL_ASN_OP_T(op,const char*)                                             \
01205     DECL_ASN_OP_T(op,const sc_fxval&)                                         \
01206     DECL_ASN_OP_T(op,const sc_fxval_fast&)                                    \
01207     DECL_ASN_OP_T(op,const sc_fxnum&)                                         \
01208     DECL_ASN_OP_T(op,const sc_fxnum_fast&)                                    \
01209     DECL_ASN_OP_OTHER(op)
01210 
01211     DECL_ASN_OP(=)
01212 
01213     DECL_ASN_OP(*=)
01214     DECL_ASN_OP(/=)
01215     DECL_ASN_OP(+=)
01216     DECL_ASN_OP(-=)
01217 
01218     DECL_ASN_OP_T(<<=,int)
01219     DECL_ASN_OP_T(>>=,int)
01220 
01221 #undef DECL_ASN_OP_T
01222 #undef DECL_ASN_OP_OTHER
01223 #undef DECL_ASN_OP
01224 
01225 
01226     // auto-increment and auto-decrement
01227 
01228     const sc_fxval_fast operator ++ ( int );
01229     const sc_fxval_fast operator -- ( int );
01230 
01231     sc_fxnum_fast& operator ++ ();
01232     sc_fxnum_fast& operator -- ();
01233 
01234 
01235     // bit selection
01236 
01237     const sc_fxnum_fast_bitref operator [] ( int ) const;
01238     sc_fxnum_fast_bitref       operator [] ( int );
01239 
01240     const sc_fxnum_fast_bitref bit( int ) const;
01241     sc_fxnum_fast_bitref       bit( int );
01242 
01243 
01244     // part selection
01245 
01246     const sc_fxnum_fast_subref operator () ( int, int ) const;
01247     sc_fxnum_fast_subref       operator () ( int, int );
01248 
01249     const sc_fxnum_fast_subref range( int, int ) const;
01250     sc_fxnum_fast_subref       range( int, int );
01251 
01252 
01253     const sc_fxnum_fast_subref operator () () const;
01254     sc_fxnum_fast_subref       operator () ();
01255 
01256     const sc_fxnum_fast_subref range() const;
01257     sc_fxnum_fast_subref       range();
01258 
01259 
01260     // implicit conversion
01261 
01262     operator double() const;    // necessary evil!
01263 
01264 
01265     // explicit conversion to primitive types
01266 
01267     short          to_short() const;
01268     unsigned short to_ushort() const;
01269     int            to_int() const;
01270     unsigned int   to_uint() const;
01271     long           to_long() const;
01272     unsigned long  to_ulong() const;
01273     float          to_float() const;
01274     double         to_double() const;
01275 
01276 
01277     // explicit conversion to character string
01278 
01279     const sc_string to_string() const;
01280     const sc_string to_string( sc_numrep ) const;
01281     const sc_string to_string( sc_numrep, bool ) const;
01282     const sc_string to_string( sc_fmt ) const;
01283     const sc_string to_string( sc_numrep, sc_fmt ) const;
01284     const sc_string to_string( sc_numrep, bool, sc_fmt ) const;
01285 
01286     const sc_string to_dec() const;
01287     const sc_string to_bin() const;
01288     const sc_string to_oct() const;
01289     const sc_string to_hex() const;
01290 
01291 
01292     // query value
01293 
01294     bool is_neg() const;
01295     bool is_zero() const;
01296 
01297     // internal use only;
01298     bool is_normal() const;
01299 
01300     bool quantization_flag() const;
01301     bool overflow_flag() const;
01302 
01303     const sc_fxval_fast value() const;
01304 
01305 
01306     // query parameters
01307 
01308     int       wl() const;
01309     int       iwl() const;
01310     sc_q_mode q_mode() const;
01311     sc_o_mode o_mode() const;
01312     int       n_bits() const;
01313 
01314     const sc_fxtype_params& type_params() const;
01315 
01316     const sc_fxcast_switch& cast_switch() const;
01317 
01318 
01319     // print or dump content
01320 
01321     void print( ostream& = cout ) const;
01322     void scan( istream& = cin );
01323     void dump( ostream& = cout ) const;
01324 
01325 
01326     // internal use only;
01327     void observer_read() const;
01328 
01329 
01330     // internal use only;
01331     bool get_bit( int ) const;
01332 
01333 protected:
01334 
01335     bool set_bit( int, bool );
01336 
01337 
01338     bool get_slice( int, int, sc_bv_base& ) const;
01339     bool set_slice( int, int, const sc_bv_base& );
01340 
01341 
01342     sc_fxnum_fast_observer* lock_observer() const;
01343     void unlock_observer( sc_fxnum_fast_observer* ) const;
01344 
01345 private:
01346 
01347     double                          m_val;
01348 
01349     scfx_params                     m_params;
01350     bool                            m_q_flag;
01351     bool                            m_o_flag;
01352 
01353     mutable sc_fxnum_fast_observer* m_observer;
01354 
01355 private:
01356 
01357     // disabled
01358