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

sc_fix.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_fix.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_FIX_H
00037 #define SC_FIX_H
00038 
00039 
00040 #include "systemc/datatypes/fx/sc_fxnum.h"
00041 
00042 
00043 namespace sc_dt
00044 {
00045 
00046 // classes defined in this module
00047 class sc_fix;
00048 class sc_fix_fast;
00049 
00050 
00051 // ----------------------------------------------------------------------------
00052 //  CLASS : sc_fix
00053 //
00054 //  "Unconstrained" signed fixed-point class; arbitrary precision.
00055 // ----------------------------------------------------------------------------
00056 
00057 class sc_fix : public sc_fxnum
00058 {
00059 
00060 public:
00061 
00062     // constructors
00063 
00064     explicit sc_fix( sc_fxnum_observer* = 0 );
00065              sc_fix( int, int,
00066          sc_fxnum_observer* = 0 );
00067              sc_fix( sc_q_mode, sc_o_mode,
00068          sc_fxnum_observer* = 0 );
00069              sc_fix( sc_q_mode, sc_o_mode, int,
00070          sc_fxnum_observer* = 0 );
00071              sc_fix( int, int, sc_q_mode, sc_o_mode,
00072          sc_fxnum_observer* = 0 );
00073              sc_fix( int, int, sc_q_mode, sc_o_mode, int,
00074          sc_fxnum_observer* = 0 );
00075     explicit sc_fix( const sc_fxcast_switch&,
00076          sc_fxnum_observer* = 0 );
00077              sc_fix( int, int,
00078          const sc_fxcast_switch&,
00079          sc_fxnum_observer* = 0 );
00080              sc_fix( sc_q_mode, sc_o_mode,
00081          const sc_fxcast_switch&,
00082          sc_fxnum_observer* = 0 );
00083              sc_fix( sc_q_mode, sc_o_mode, int,
00084          const sc_fxcast_switch&,
00085          sc_fxnum_observer* = 0 );
00086              sc_fix( int, int, sc_q_mode, sc_o_mode,
00087          const sc_fxcast_switch&,
00088          sc_fxnum_observer* = 0 );
00089              sc_fix( int, int, sc_q_mode, sc_o_mode, int,
00090          const sc_fxcast_switch&,
00091          sc_fxnum_observer* = 0 );
00092     explicit sc_fix( const sc_fxtype_params&,
00093          sc_fxnum_observer* = 0 );
00094              sc_fix( const sc_fxtype_params&,
00095          const sc_fxcast_switch&,
00096          sc_fxnum_observer* = 0 );
00097 
00098 #define DECL_CTORS_T(tp)                                                      \
00099              sc_fix( tp,                                                      \
00100                int, int,                                                \
00101                sc_fxnum_observer* = 0 );                                \
00102              sc_fix( tp,                                                      \
00103                sc_q_mode, sc_o_mode,                                    \
00104                sc_fxnum_observer* = 0 );                                \
00105              sc_fix( tp,                                                      \
00106                sc_q_mode, sc_o_mode, int,                               \
00107                sc_fxnum_observer* = 0 );                                \
00108              sc_fix( tp,                                                      \
00109                int, int, sc_q_mode, sc_o_mode,                          \
00110                sc_fxnum_observer* = 0 );                                \
00111              sc_fix( tp,                                                      \
00112                int, int, sc_q_mode, sc_o_mode, int,                     \
00113                sc_fxnum_observer* = 0 );                                \
00114              sc_fix( tp,                                                      \
00115                const sc_fxcast_switch&,                                 \
00116                sc_fxnum_observer* = 0 );                                \
00117              sc_fix( tp,                                                      \
00118                int, int,                                                \
00119                const sc_fxcast_switch&,                                 \
00120                sc_fxnum_observer* = 0 );                                \
00121              sc_fix( tp,                                                      \
00122                sc_q_mode, sc_o_mode,                                    \
00123                const sc_fxcast_switch&,                                 \
00124                sc_fxnum_observer* = 0 );                                \
00125              sc_fix( tp,                                                      \
00126                sc_q_mode, sc_o_mode, int,                               \
00127                const sc_fxcast_switch&,                                 \
00128                sc_fxnum_observer* = 0 );                                \
00129              sc_fix( tp,                                                      \
00130                int, int, sc_q_mode, sc_o_mode,                          \
00131                const sc_fxcast_switch&,                                 \
00132                sc_fxnum_observer* = 0 );                                \
00133              sc_fix( tp,                                                      \
00134                int, int, sc_q_mode, sc_o_mode, int,                     \
00135                const sc_fxcast_switch&,                                 \
00136                sc_fxnum_observer* = 0 );                                \
00137              sc_fix( tp,                                                      \
00138                const sc_fxtype_params&,                                 \
00139                sc_fxnum_observer* = 0 );                                \
00140              sc_fix( tp,                                                      \
00141                const sc_fxtype_params&,                                 \
00142                const sc_fxcast_switch&,                                 \
00143                sc_fxnum_observer* = 0 );
00144 
00145 #define DECL_CTORS_T_A(tp)                                                    \
00146              sc_fix( tp,                                                      \
00147                sc_fxnum_observer* = 0 );                                \
00148     DECL_CTORS_T(tp)
00149 
00150 #define DECL_CTORS_T_B(tp)                                                    \
00151     explicit sc_fix( tp,                                                      \
00152                sc_fxnum_observer* = 0 );                                \
00153     DECL_CTORS_T(tp)
00154 
00155     DECL_CTORS_T_A(int)
00156     DECL_CTORS_T_A(unsigned int)
00157     DECL_CTORS_T_A(long)
00158     DECL_CTORS_T_A(unsigned long)
00159     DECL_CTORS_T_A(double)
00160     DECL_CTORS_T_A(const char*)
00161     DECL_CTORS_T_A(const sc_fxval&)
00162     DECL_CTORS_T_A(const sc_fxval_fast&)
00163     DECL_CTORS_T_A(const sc_fxnum&)
00164     DECL_CTORS_T_A(const sc_fxnum_fast&)
00165 #ifndef SC_FX_EXCLUDE_OTHER
00166     DECL_CTORS_T_B(int64)
00167     DECL_CTORS_T_B(uint64)
00168     DECL_CTORS_T_B(const sc_int_base&)
00169     DECL_CTORS_T_B(const sc_uint_base&)
00170     DECL_CTORS_T_B(const sc_signed&)
00171     DECL_CTORS_T_B(const sc_unsigned&)
00172 #endif
00173 
00174 #undef DECL_CTORS_T
00175 #undef DECL_CTORS_T_A
00176 #undef DECL_CTORS_T_B
00177 
00178     // copy constructor
00179 
00180     sc_fix( const sc_fix& );
00181 
00182 
00183     // unary bitwise operators
00184 
00185     const sc_fix operator ~ () const;
00186 
00187 
00188     // unary bitwise functions
00189 
00190     friend void b_not( sc_fix&, const sc_fix& );
00191 
00192 
00193     // binary bitwise operators
00194 
00195     friend const sc_fix operator & ( const sc_fix&, const sc_fix& );
00196     friend const sc_fix operator & ( const sc_fix&, const sc_fix_fast& );
00197     friend const sc_fix operator & ( const sc_fix_fast&, const sc_fix& );
00198     friend const sc_fix operator | ( const sc_fix&, const sc_fix& );
00199     friend const sc_fix operator | ( const sc_fix&, const sc_fix_fast& );
00200     friend const sc_fix operator | ( const sc_fix_fast&, const sc_fix& );
00201     friend const sc_fix operator ^ ( const sc_fix&, const sc_fix& );
00202     friend const sc_fix operator ^ ( const sc_fix&, const sc_fix_fast& );
00203     friend const sc_fix operator ^ ( const sc_fix_fast&, const sc_fix& );
00204 
00205 
00206     // binary bitwise functions
00207 
00208     friend void b_and( sc_fix&, const sc_fix&, const sc_fix& );
00209     friend void b_and( sc_fix&, const sc_fix&, const sc_fix_fast& );
00210     friend void b_and( sc_fix&, const sc_fix_fast&, const sc_fix& );
00211     friend void b_or ( sc_fix&, const sc_fix&, const sc_fix& );
00212     friend void b_or ( sc_fix&, const sc_fix&, const sc_fix_fast& );
00213     friend void b_or ( sc_fix&, const sc_fix_fast&, const sc_fix& );
00214     friend void b_xor( sc_fix&, const sc_fix&, const sc_fix& );
00215     friend void b_xor( sc_fix&, const sc_fix&, const sc_fix_fast& );
00216     friend void b_xor( sc_fix&, const sc_fix_fast&, const sc_fix& );
00217 
00218 
00219     // assignment operators
00220 
00221     sc_fix& operator = ( const sc_fix& );
00222 
00223 #define DECL_ASN_OP_T(op,tp)                                                  \
00224     sc_fix& operator op ( tp );
00225 
00226 #ifndef SC_FX_EXCLUDE_OTHER
00227 #define DECL_ASN_OP_OTHER(op)                                                 \
00228     DECL_ASN_OP_T(op,int64)                                                   \
00229     DECL_ASN_OP_T(op,uint64)                                                  \
00230     DECL_ASN_OP_T(op,const sc_int_base&)                                      \
00231     DECL_ASN_OP_T(op,const sc_uint_base&)                                     \
00232     DECL_ASN_OP_T(op,const sc_signed&)                                        \
00233     DECL_ASN_OP_T(op,const sc_unsigned&)
00234 #else
00235 #define DECL_ASN_OP_OTHER(op)
00236 #endif
00237 
00238 #define DECL_ASN_OP(op)                                                       \
00239     DECL_ASN_OP_T(op,int)                                                     \
00240     DECL_ASN_OP_T(op,unsigned int)                                            \
00241     DECL_ASN_OP_T(op,long)                                                    \
00242     DECL_ASN_OP_T(op,unsigned long)                                           \
00243     DECL_ASN_OP_T(op,double)                                                  \
00244     DECL_ASN_OP_T(op,const char*)                                             \
00245     DECL_ASN_OP_T(op,const sc_fxval&)                                         \
00246     DECL_ASN_OP_T(op,const sc_fxval_fast&)                                    \
00247     DECL_ASN_OP_T(op,const sc_fxnum&)                                         \
00248     DECL_ASN_OP_T(op,const sc_fxnum_fast&)                                    \
00249     DECL_ASN_OP_OTHER(op)
00250 
00251     DECL_ASN_OP(=)
00252 
00253     DECL_ASN_OP(*=)
00254     DECL_ASN_OP(/=)
00255     DECL_ASN_OP(+=)
00256     DECL_ASN_OP(-=)
00257 
00258     DECL_ASN_OP_T(<<=,int)
00259     DECL_ASN_OP_T(>>=,int)
00260 
00261     DECL_ASN_OP_T(&=,const sc_fix&)
00262     DECL_ASN_OP_T(&=,const sc_fix_fast&)
00263     DECL_ASN_OP_T(|=,const sc_fix&)
00264     DECL_ASN_OP_T(|=,const sc_fix_fast&)
00265     DECL_ASN_OP_T(^=,const sc_fix&)
00266     DECL_ASN_OP_T(^=,const sc_fix_fast&)
00267 
00268 #undef DECL_ASN_OP_T
00269 #undef DECL_ASN_OP_OTHER
00270 #undef DECL_ASN_OP
00271 
00272 
00273     // auto-increment and auto-decrement
00274 
00275     const sc_fxval operator ++ ( int );
00276     const sc_fxval operator -- ( int );
00277 
00278     sc_fix& operator ++ ();
00279     sc_fix& operator -- ();
00280 
00281 };
00282 
00283 
00284 // ----------------------------------------------------------------------------
00285 //  CLASS : sc_fix_fast
00286 //
00287 //  "Unconstrained" signed fixed-point class; limited precision.
00288 // ----------------------------------------------------------------------------
00289 
00290 class sc_fix_fast : public sc_fxnum_fast
00291 {
00292 
00293 public:
00294 
00295     // constructors
00296 
00297     explicit sc_fix_fast( sc_fxnum_fast_observer* = 0 );
00298              sc_fix_fast( int, int,
00299         sc_fxnum_fast_observer* = 0 );
00300              sc_fix_fast( sc_q_mode, sc_o_mode,
00301         sc_fxnum_fast_observer* = 0 );
00302              sc_fix_fast( sc_q_mode, sc_o_mode, int,
00303         sc_fxnum_fast_observer* = 0 );
00304              sc_fix_fast( int, int, sc_q_mode, sc_o_mode,
00305         sc_fxnum_fast_observer* = 0 );
00306              sc_fix_fast( int, int, sc_q_mode, sc_o_mode, int,
00307         sc_fxnum_fast_observer* = 0 );
00308     explicit sc_fix_fast( const sc_fxcast_switch&,
00309         sc_fxnum_fast_observer* = 0 );
00310              sc_fix_fast( int, int,
00311         const sc_fxcast_switch&,
00312         sc_fxnum_fast_observer* = 0 );
00313              sc_fix_fast( sc_q_mode, sc_o_mode,
00314         const sc_fxcast_switch&,
00315         sc_fxnum_fast_observer* = 0 );
00316              sc_fix_fast( sc_q_mode, sc_o_mode, int,
00317         const sc_fxcast_switch&,
00318         sc_fxnum_fast_observer* = 0 );
00319              sc_fix_fast( int, int, sc_q_mode, sc_o_mode,
00320         const sc_fxcast_switch&,
00321         sc_fxnum_fast_observer* = 0 );
00322              sc_fix_fast( int, int, sc_q_mode, sc_o_mode, int,
00323         const sc_fxcast_switch&,
00324         sc_fxnum_fast_observer* = 0 );
00325     explicit sc_fix_fast( const sc_fxtype_params&,
00326         sc_fxnum_fast_observer* = 0 );
00327              sc_fix_fast( const sc_fxtype_params&,
00328         const sc_fxcast_switch&,
00329         sc_fxnum_fast_observer* = 0 );
00330 
00331 #define DECL_CTORS_T(tp)                                                      \
00332              sc_fix_fast( tp,                                                 \
00333               int, int,                                           \
00334               sc_fxnum_fast_observer* = 0 );                      \
00335              sc_fix_fast( tp,                                                 \
00336               sc_q_mode, sc_o_mode,                               \
00337               sc_fxnum_fast_observer* = 0 );                      \
00338              sc_fix_fast( tp,                                                 \
00339               sc_q_mode, sc_o_mode, int,                          \
00340               sc_fxnum_fast_observer* = 0 );                      \
00341              sc_fix_fast( tp,                                                 \
00342               int, int, sc_q_mode, sc_o_mode,                     \
00343               sc_fxnum_fast_observer* = 0 );                      \
00344              sc_fix_fast( tp,                                                 \
00345               int, int, sc_q_mode, sc_o_mode, int,                \
00346               sc_fxnum_fast_observer* = 0 );                      \
00347              sc_fix_fast( tp,                                                 \
00348               const sc_fxcast_switch&,                            \
00349               sc_fxnum_fast_observer* = 0 );                      \
00350              sc_fix_fast( tp,                                                 \
00351               int, int,                                           \
00352               const sc_fxcast_switch&,                            \
00353               sc_fxnum_fast_observer* = 0 );                      \
00354              sc_fix_fast( tp,                                                 \
00355               sc_q_mode, sc_o_mode,                               \
00356               const sc_fxcast_switch&,                            \
00357               sc_fxnum_fast_observer* = 0 );                      \
00358              sc_fix_fast( tp,                                                 \
00359               sc_q_mode, sc_o_mode, int,                          \
00360               const sc_fxcast_switch&,                            \
00361               sc_fxnum_fast_observer* = 0 );                      \
00362              sc_fix_fast( tp,                                                 \
00363               int, int, sc_q_mode, sc_o_mode,                     \
00364               const sc_fxcast_switch&,                            \
00365               sc_fxnum_fast_observer* = 0 );                      \
00366              sc_fix_fast( tp,                                                 \
00367               int, int, sc_q_mode, sc_o_mode, int,                \
00368               const sc_fxcast_switch&,                            \
00369               sc_fxnum_fast_observer* = 0 );                      \
00370              sc_fix_fast( tp,                                                 \
00371               const sc_fxtype_params&,                            \
00372               sc_fxnum_fast_observer* = 0 );                      \
00373              sc_fix_fast( tp,                                                 \
00374               const sc_fxtype_params&,                            \
00375               const sc_fxcast_switch&,                            \
00376               sc_fxnum_fast_observer* = 0 );
00377 
00378 #define DECL_CTORS_T_A(tp)                                                    \
00379              sc_fix_fast( tp,                                                 \
00380               sc_fxnum_fast_observer* = 0 );                      \
00381     DECL_CTORS_T(tp)
00382 
00383 #define DECL_CTORS_T_B(tp)                                                    \
00384     explicit sc_fix_fast( tp,                                                 \
00385               sc_fxnum_fast_observer* = 0 );                      \
00386     DECL_CTORS_T(tp)
00387 
00388     DECL_CTORS_T_A(int)
00389     DECL_CTORS_T_A(unsigned int)
00390     DECL_CTORS_T_A(long)
00391     DECL_CTORS_T_A(unsigned long)
00392     DECL_CTORS_T_A(double)
00393     DECL_CTORS_T_A(const char*)
00394     DECL_CTORS_T_A(const sc_fxval&)
00395     DECL_CTORS_T_A(const sc_fxval_fast&)
00396     DECL_CTORS_T_A(const sc_fxnum&)
00397     DECL_CTORS_T_A(const sc_fxnum_fast&)
00398 #ifndef SC_FX_EXCLUDE_OTHER
00399     DECL_CTORS_T_B(int64)
00400     DECL_CTORS_T_B(uint64)
00401     DECL_CTORS_T_B(const sc_int_base&)
00402     DECL_CTORS_T_B(const sc_uint_base&)
00403     DECL_CTORS_T_B(const sc_signed&)
00404     DECL_CTORS_T_B(const sc_unsigned&)
00405 #endif
00406 
00407 #undef DECL_CTORS_T
00408 #undef DECL_CTORS_T_A
00409 #undef DECL_CTORS_T_B
00410 
00411     // copy constructor
00412 
00413     sc_fix_fast( const sc_fix_fast& );
00414 
00415 
00416     // unary bitwise operators
00417 
00418     const sc_fix_fast operator ~ () const;
00419 
00420 
00421     // unary bitwise functions
00422 
00423     friend void b_not( sc_fix_fast&, const sc_fix_fast& );
00424 
00425 
00426     // binary bitwise operators
00427 
00428     friend const sc_fix_fast operator & ( const sc_fix_fast&,
00429             const sc_fix_fast& );
00430     friend const sc_fix_fast operator ^ ( const sc_fix_fast&,
00431             const sc_fix_fast& );
00432     friend const sc_fix_fast operator | ( const sc_fix_fast&,
00433             const sc_fix_fast& );
00434 
00435 
00436     // binary bitwise functions
00437 
00438     friend void b_and( sc_fix_fast&, const sc_fix_fast&, const sc_fix_fast& );
00439     friend void b_or ( sc_fix_fast&, const sc_fix_fast&, const sc_fix_fast& );
00440     friend void b_xor( sc_fix_fast&, const sc_fix_fast&, const sc_fix_fast& );
00441 
00442 
00443     // assignment operators
00444 
00445     sc_fix_fast& operator = ( const sc_fix_fast& );
00446 
00447 #define DECL_ASN_OP_T(op,tp)                                                  \
00448     sc_fix_fast& operator op ( tp );
00449 
00450 #ifndef SC_FX_EXCLUDE_OTHER
00451 #define DECL_ASN_OP_OTHER(op)                                                 \
00452     DECL_ASN_OP_T(op,int64)                                                   \
00453     DECL_ASN_OP_T(op,uint64)                                                  \
00454     DECL_ASN_OP_T(op,const sc_int_base&)                                      \
00455     DECL_ASN_OP_T(op,const sc_uint_base&)                                     \
00456     DECL_ASN_OP_T(op,const sc_signed&)                                        \
00457     DECL_ASN_OP_T(op,const sc_unsigned&)
00458 #else
00459 #define DECL_ASN_OP_OTHER(op)
00460 #endif
00461 
00462 #define DECL_ASN_OP(op)                                                       \
00463     DECL_ASN_OP_T(op,int)                                                     \
00464     DECL_ASN_OP_T(op,unsigned int)                                            \
00465     DECL_ASN_OP_T(op,long)                                                    \
00466     DECL_ASN_OP_T(op,unsigned long)                                           \
00467     DECL_ASN_OP_T(op,double)                                                  \
00468     DECL_ASN_OP_T(op,const char*)                                             \
00469     DECL_ASN_OP_T(op,const sc_fxval&)                                         \
00470     DECL_ASN_OP_T(op,const sc_fxval_fast&)                                    \
00471     DECL_ASN_OP_T(op,const sc_fxnum&)                                         \
00472     DECL_ASN_OP_T(op,const sc_fxnum_fast&)                                    \
00473     DECL_ASN_OP_OTHER(op)
00474 
00475     DECL_ASN_OP(=)
00476 
00477     DECL_ASN_OP(*=)
00478     DECL_ASN_OP(/=)
00479     DECL_ASN_OP(+=)
00480     DECL_ASN_OP(-=)
00481 
00482     DECL_ASN_OP_T(<<=,int)
00483     DECL_ASN_OP_T(>>=,int)
00484 
00485     DECL_ASN_OP_T(&=,const sc_fix&)
00486     DECL_ASN_OP_T(&=,const sc_fix_fast&)
00487     DECL_ASN_OP_T(|=,const sc_fix&)
00488     DECL_ASN_OP_T(|=,const sc_fix_fast&)
00489     DECL_ASN_OP_T(^=,const sc_fix&)
00490     DECL_ASN_OP_T(^=,const sc_fix_fast&)
00491 
00492 #undef DECL_ASN_OP_T
00493 #undef DECL_ASN_OP_OTHER
00494 #undef DECL_ASN_OP
00495 
00496 
00497     // auto-increment and auto-decrement
00498 
00499     const sc_fxval_fast operator ++ ( int );
00500     const sc_fxval_fast operator -- ( int );
00501 
00502     sc_fix_fast& operator ++ ();
00503     sc_fix_fast& operator -- ();
00504 
00505 };
00506 
00507 
00508 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
00509 
00510 // ----------------------------------------------------------------------------
00511 //  CLASS : sc_fix
00512 //
00513 //  "Unconstrained" signed fixed-point class; arbitrary precision.
00514 // ----------------------------------------------------------------------------
00515 
00516 // constructors
00517 
00518 inline
00519 sc_fix::sc_fix( sc_fxnum_observer* observer_ )
00520 : sc_fxnum( sc_fxtype_params(),
00521       SC_TC_,
00522       sc_fxcast_switch(),
00523       observer_ )
00524 {}
00525 
00526 inline
00527 sc_fix::sc_fix( int wl_, int iwl_,
00528     sc_fxnum_observer* observer_ )
00529 : sc_fxnum( sc_fxtype_params( wl_, iwl_ ),
00530       SC_TC_,
00531       sc_fxcast_switch(),
00532       observer_ )
00533 {}
00534 
00535 inline
00536 sc_fix::sc_fix( sc_q_mode qm, sc_o_mode om,
00537     sc_fxnum_observer* observer_ )
00538 : sc_fxnum( sc_fxtype_params( qm, om ),
00539       SC_TC_,
00540       sc_fxcast_switch(),
00541       observer_ )
00542 {}
00543 
00544 inline
00545 sc_fix::sc_fix( sc_q_mode qm, sc_o_mode om, int nb,
00546     sc_fxnum_observer* observer_ )
00547 : sc_fxnum( sc_fxtype_params( qm, om, nb ),
00548       SC_TC_,
00549       sc_fxcast_switch(),
00550       observer_ )
00551 {}
00552 
00553 inline
00554 sc_fix::sc_fix( int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
00555     sc_fxnum_observer* observer_ )
00556 : sc_fxnum( sc_fxtype_params( wl_, iwl_, qm, om ),
00557       SC_TC_,
00558       sc_fxcast_switch(),
00559       observer_ )
00560 {}
00561 
00562 inline
00563 sc_fix::sc_fix( int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,
00564     sc_fxnum_observer* observer_ )
00565 : sc_fxnum( sc_fxtype_params( wl_, iwl_, qm, om, nb ),
00566       SC_TC_,
00567       sc_fxcast_switch(),
00568       observer_ )
00569 {}
00570 
00571 inline
00572 sc_fix::sc_fix( const sc_fxcast_switch& cast_sw,
00573     sc_fxnum_observer* observer_ )
00574 : sc_fxnum( sc_fxtype_params(),
00575       SC_TC_,
00576       cast_sw,
00577       observer_ )
00578 {}
00579 
00580 inline
00581 sc_fix::sc_fix( int wl_, int iwl_,
00582     const sc_fxcast_switch& cast_sw,
00583     sc_fxnum_observer* observer_ )
00584 : sc_fxnum( sc_fxtype_params( wl_, iwl_ ),
00585       SC_TC_,
00586       cast_sw,
00587       observer_ )
00588 {}
00589 
00590 inline
00591 sc_fix::sc_fix( sc_q_mode qm, sc_o_mode om,
00592     const sc_fxcast_switch& cast_sw,
00593     sc_fxnum_observer* observer_ )
00594 : sc_fxnum( sc_fxtype_params( qm, om ),
00595       SC_TC_,
00596       cast_sw,
00597       observer_ )
00598 {}
00599 
00600 inline
00601 sc_fix::sc_fix( sc_q_mode qm, sc_o_mode om, int nb,
00602     const sc_fxcast_switch& cast_sw,
00603     sc_fxnum_observer* observer_ )
00604 : sc_fxnum( sc_fxtype_params( qm, om, nb ),
00605       SC_TC_,
00606       cast_sw,
00607       observer_ )
00608 {}
00609 
00610 inline
00611 sc_fix::sc_fix( int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
00612     const sc_fxcast_switch& cast_sw,
00613     sc_fxnum_observer* observer_ )
00614 : sc_fxnum( sc_fxtype_params( wl_, iwl_, qm, om ),
00615       SC_TC_,
00616       cast_sw,
00617       observer_ )
00618 {}
00619 
00620 inline
00621 sc_fix::sc_fix( int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,
00622     const sc_fxcast_switch& cast_sw,
00623     sc_fxnum_observer* observer_ )
00624 : sc_fxnum( sc_fxtype_params( wl_, iwl_, qm, om, nb ),
00625       SC_TC_,
00626       cast_sw,
00627       observer_ )
00628 {}
00629 
00630 inline
00631 sc_fix::sc_fix( const sc_fxtype_params& type_params,
00632     sc_fxnum_observer* observer_ )
00633 : sc_fxnum( type_params,
00634       SC_TC_,
00635       sc_fxcast_switch(),
00636       observer_ )
00637 {}
00638 
00639 inline
00640 sc_fix::sc_fix( const sc_fxtype_params& type_params,
00641     const sc_fxcast_switch& cast_sw,
00642     sc_fxnum_observer* observer_ )
00643 : sc_fxnum( type_params,
00644       SC_TC_,
00645       cast_sw,
00646       observer_ )
00647 {}
00648 
00649 #define DEFN_CTORS_T_A(tp)                                                    \
00650 inline                                                                        \
00651 sc_fix::sc_fix( tp a,                                                         \
00652     sc_fxnum_observer* observer_ )                                \
00653 : sc_fxnum( a,                                                                \
00654       sc_fxtype_params(),                                               \
00655       SC_TC_,                                                           \
00656       sc_fxcast_switch(),                                               \
00657       observer_ )                                                       \
00658 {}                                                                            \
00659                                                                               \
00660 inline                                                                        \
00661 sc_fix::sc_fix( tp a,                                                         \
00662     int wl_, int iwl_,                                            \
00663     sc_fxnum_observer* observer_ )                                \
00664 : sc_fxnum( a,                                                                \
00665       sc_fxtype_params( wl_, iwl_ ),                                    \
00666       SC_TC_,                                                           \
00667       sc_fxcast_switch(),                                               \
00668       observer_ )                                                       \
00669 {}                                                                            \
00670                                                                               \
00671 inline                                                                        \
00672 sc_fix::sc_fix( tp a,                                                         \
00673     sc_q_mode qm, sc_o_mode om,                                   \
00674     sc_fxnum_observer* observer_ )                                \
00675 : sc_fxnum( a,                                                                \
00676       sc_fxtype_params( qm, om ),                                       \
00677       SC_TC_,                                                           \
00678       sc_fxcast_switch(),                                               \
00679       observer_ )                                                       \
00680 {}                                                                            \
00681                                                                               \
00682 inline                                                                        \
00683 sc_fix::sc_fix( tp a,                                                         \
00684     sc_q_mode qm, sc_o_mode om, int nb,                           \
00685     sc_fxnum_observer* observer_ )                                \
00686 : sc_fxnum( a,                                                                \
00687       sc_fxtype_params( qm, om, nb ),                                   \
00688       SC_TC_,                                                           \
00689       sc_fxcast_switch(),                                               \
00690       observer_ )                                                       \
00691 {}                                                                            \
00692                                                                               \
00693 inline                                                                        \
00694 sc_fix::sc_fix( tp a,                                                         \
00695     int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,                \
00696     sc_fxnum_observer* observer_ )                                \
00697 : sc_fxnum( a,                                                                \
00698       sc_fxtype_params( wl_, iwl_, qm, om ),                            \
00699       SC_TC_,                                                           \
00700       sc_fxcast_switch(),                                               \
00701       observer_ )                                                       \
00702 {}                                                                            \
00703                                                                               \
00704 inline                                                                        \
00705 sc_fix::sc_fix( tp a,                                                         \
00706     int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,        \
00707     sc_fxnum_observer* observer_ )                                \
00708 : sc_fxnum( a,                                                                \
00709       sc_fxtype_params( wl_, iwl_, qm, om, nb ),                        \
00710       SC_TC_,                                                           \
00711       sc_fxcast_switch(),                                               \
00712       observer_ )                                                       \
00713 {}                                                                            \
00714                                                                               \
00715 inline                                                                        \
00716 sc_fix::sc_fix( tp a,                                                         \
00717     const sc_fxcast_switch& cast_sw,                              \
00718     sc_fxnum_observer* observer_ )                                \
00719 : sc_fxnum( a,                                                                \
00720       sc_fxtype_params(),                                               \
00721       SC_TC_,                                                           \
00722       cast_sw,                                                          \
00723       observer_ )                                                       \
00724 {}                                                                            \
00725                                                                               \
00726 inline                                                                        \
00727 sc_fix::sc_fix( tp a,                                                         \
00728     int wl_, int iwl_,                                            \
00729     const sc_fxcast_switch& cast_sw,                              \
00730     sc_fxnum_observer* observer_ )                                \
00731 : sc_fxnum( a,                                                                \
00732       sc_fxtype_params( wl_, iwl_ ),                                    \
00733       SC_TC_,                                                           \
00734       cast_sw,                                                          \
00735       observer_ )                                                       \
00736 {}                                                                            \
00737                                                                               \
00738 inline                                                                        \
00739 sc_fix::sc_fix( tp a,                                                         \
00740     sc_q_mode qm, sc_o_mode om,                                   \
00741     const sc_fxcast_switch& cast_sw,                              \
00742     sc_fxnum_observer* observer_ )                                \
00743 : sc_fxnum( a,                                                                \
00744       sc_fxtype_params( qm, om ),                                       \
00745       SC_TC_,                                                           \
00746       cast_sw,                                                          \
00747       observer_ )                                                       \
00748 {}                                                                            \
00749                                                                               \
00750 inline                                                                        \
00751 sc_fix::sc_fix( tp a,                                                         \
00752     sc_q_mode qm, sc_o_mode om, int nb,                           \
00753     const sc_fxcast_switch& cast_sw,                              \
00754     sc_fxnum_observer* observer_ )                                \
00755 : sc_fxnum( a,                                                                \
00756       sc_fxtype_params( qm, om, nb ),                                   \
00757       SC_TC_,                                                           \
00758       cast_sw,                                                          \
00759       observer_ )                                                       \
00760 {}                                                                            \
00761                                                                               \
00762 inline                                                                        \
00763 sc_fix::sc_fix( tp a,                                                         \
00764     int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,                \
00765     const sc_fxcast_switch& cast_sw,                              \
00766     sc_fxnum_observer* observer_ )                                \
00767 : sc_fxnum( a,                                                                \
00768       sc_fxtype_params( wl_, iwl_, qm, om ),                            \
00769       SC_TC_,                                                           \
00770       cast_sw,                                                          \
00771       observer_ )                                                       \
00772 {}                                                                            \
00773                                                                               \
00774 inline                                                                        \
00775 sc_fix::sc_fix( tp a,                                                         \
00776     int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,        \
00777     const sc_fxcast_switch& cast_sw,                              \
00778     sc_fxnum_observer* observer_ )                                \
00779 : sc_fxnum( a,                                                                \
00780       sc_fxtype_params( wl_, iwl_, qm, om, nb ),                        \
00781       SC_TC_,                                                           \
00782       cast_sw,                                                          \
00783       observer_ )                                                       \
00784 {}                                                                            \
00785                                                                               \
00786 inline                                                                        \
00787 sc_fix::sc_fix( tp a,                                                         \
00788     const sc_fxtype_params& type_params,                          \
00789     sc_fxnum_observer* observer_ )                                \
00790 : sc_fxnum( a,                                                                \
00791       type_params,                                                      \
00792       SC_TC_,                                                           \
00793       sc_fxcast_switch(),                                               \
00794       observer_ )                                                       \
00795 {}                                                                            \
00796                                                                               \
00797 inline                                                                        \
00798 sc_fix::sc_fix( tp a,                                                         \
00799     const sc_fxtype_params& type_params,                          \
00800     const sc_fxcast_switch& cast_sw,                              \
00801     sc_fxnum_observer* observer_ )                                \
00802 : sc_fxnum( a,                                                                \
00803       type_params,                                                      \
00804       SC_TC_,                                                           \
00805       cast_sw,                                                          \
00806       observer_ )                                                       \
00807 {}
00808 
00809 #define DEFN_CTORS_T_B(tp)                                                    \
00810 inline                                                                        \
00811 sc_fix::sc_fix( tp a,                                                         \
00812     sc_fxnum_observer* observer_ )                                \
00813 : sc_fxnum( a,                                                                \
00814       a.type_params(),                                                  \
00815       SC_TC_,                                                           \
00816       sc_fxcast_switch(),                                               \
00817       observer_ )                                                       \
00818 {}                                                                            \
00819                                                                               \
00820 inline                                                                        \
00821 sc_fix::sc_fix( tp a,                                                         \
00822     int wl_, int iwl_,                                            \
00823     sc_fxnum_observer* observer_ )                                \
00824 : sc_fxnum( a,                                                                \
00825       sc_fxtype_params( a.type_params(), wl_, iwl_ ),                   \
00826       SC_TC_,                                                           \
00827       sc_fxcast_switch(),                                               \
00828       observer_ )                                                       \
00829 {}                                                                            \
00830                                                                               \
00831 inline                                                                        \
00832 sc_fix::sc_fix( tp a,                                                         \
00833     sc_q_mode qm, sc_o_mode om,                                   \
00834     sc_fxnum_observer* observer_ )                                \
00835 : sc_fxnum( a,                                                                \
00836       sc_fxtype_params( a.type_params(), qm, om ),                      \
00837       SC_TC_,                                                           \
00838       sc_fxcast_switch(),                                               \
00839       observer_ )                                                       \
00840 {}                                                                            \
00841                                                                               \
00842 inline                                                                        \
00843 sc_fix::sc_fix( tp a,                                                         \
00844     sc_q_mode qm, sc_o_mode om, int nb,                           \
00845     sc_fxnum_observer* observer_ )                                \
00846 : sc_fxnum( a,                                                                \
00847       sc_fxtype_params( a.type_params(), qm, om, nb ),                  \
00848       SC_TC_,                                                           \
00849       sc_fxcast_switch(),                                               \
00850       observer_ )                                                       \
00851 {}                                                                            \
00852                                                                               \
00853 inline                                                                        \
00854 sc_fix::sc_fix( tp a,                                                         \
00855     int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,                \
00856     sc_fxnum_observer* observer_ )                                \
00857 : sc_fxnum( a,                                                                \
00858       sc_fxtype_params( wl_, iwl_, qm, om ),                            \
00859       SC_TC_,                                                           \
00860       sc_fxcast_switch(),                                               \
00861       observer_ )                                                       \
00862 {}                                                                            \
00863                                                                               \
00864 inline                                                                        \
00865 sc_fix::sc_fix( tp a,                                                         \
00866     int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,        \
00867     sc_fxnum_observer* observer_ )                                \
00868 : sc_fxnum( a,                                                                \
00869       sc_fxtype_params( wl_, iwl_, qm, om, nb ),                        \
00870       SC_TC_,                                                           \
00871       sc_fxcast_switch(),                                               \
00872       observer_ )                                                       \
00873 {}                                                                            \
00874                                                                               \
00875 inline                                                                        \
00876 sc_fix::sc_fix( tp a,                                                         \
00877     const sc_fxcast_switch& cast_sw,                              \
00878     sc_fxnum_observer* observer_ )                                \
00879 : sc_fxnum( a,                                                                \
00880       a.type_params(),                                                  \
00881       SC_TC_,                                                           \
00882       cast_sw,                                                          \
00883       observer_ )                                                       \
00884 {}                                                                            \
00885                                                                               \
00886 inline                                                                        \
00887 sc_fix::sc_fix( tp a,                                                         \
00888     int wl_, int iwl_,                                            \
00889     const sc_fxcast_switch& cast_sw,                              \
00890     sc_fxnum_observer* observer_ )                                \
00891 : sc_fxnum( a,                                                                \
00892       sc_fxtype_params( a.type_params(), wl_, iwl_ ),                   \
00893       SC_TC_,                                                           \
00894       cast_sw,                                                          \
00895       observer_ )                                                       \
00896 {}                                                                            \
00897                                                                               \
00898 inline                                                                        \
00899 sc_fix::sc_fix( tp a,                                                         \
00900     sc_q_mode qm, sc_o_mode om,                                   \
00901     const sc_fxcast_switch& cast_sw,                              \
00902     sc_fxnum_observer* observer_ )                                \
00903 : sc_fxnum( a,                                                                \
00904       sc_fxtype_params( a.type_params(), qm, om ),                      \
00905       SC_TC_,                                                           \
00906       cast_sw,                                                          \
00907       observer_ )                                                       \
00908 {}                                                                            \
00909                                                                               \
00910 inline                                                                        \
00911 sc_fix::sc_fix( tp a,                                                         \
00912     sc_q_mode qm, sc_o_mode om, int nb,                           \
00913     const sc_fxcast_switch& cast_sw,                              \
00914     sc_fxnum_observer* observer_ )                                \
00915 : sc_fxnum( a,                                                                \
00916       sc_fxtype_params( a.type_params(), qm, om, nb ),                  \
00917       SC_TC_,                                                           \
00918       cast_sw,                                                          \
00919       observer_ )                                                       \
00920 {}                                                                            \
00921                                                                               \
00922 inline                                                                        \
00923 sc_fix::sc_fix( tp a,                                                         \
00924     int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,                \
00925     const sc_fxcast_switch& cast_sw,                              \
00926     sc_fxnum_observer* observer_ )                                \
00927 : sc_fxnum( a,                                                                \
00928       sc_fxtype_params( wl_, iwl_, qm, om ),                            \
00929       SC_TC_,                                                           \
00930       cast_sw,                                                          \
00931       observer_ )                                                       \
00932 {}                                                                            \
00933                                                                               \
00934 inline                                                                        \
00935 sc_fix::sc_fix( tp a,                                                         \
00936     int wl_, int iwl_, sc_q_mode qm, sc_o_mode om, int nb,        \
00937     const sc_fxcast_switch& cast_sw,                              \
00938     sc_fxnum_observer* observer_ )                                \
00939 : sc_fxnum( a,                                                                \
00940       sc_fxtype_params( wl_, iwl_, qm, om, nb ),                        \
00941       SC_TC_,                                                           \
00942       cast_sw,                                                          \
00943       observer_ )                                                       \
00944 {}                                                                            \
00945                                                                               \
00946 inline                                                                        \
00947 sc_fix::sc_fix( tp a,                                                         \
00948     const sc_fxtype_params& type_params,                          \
00949     sc_fxnum_observer* observer_ )                                \
00950 : sc_fxnum( a,                                                                \
00951       type_params,                                                      \
00952       SC_TC_,                                                           \
00953       sc_fxcast_switch(),                                               \
00954       observer_ )                                                       \
00955 {}                                                                            \
00956                                                                               \
00957 inline                                                                        \
00958 sc_fix::sc_fix( tp a,                                                         \
00959     const sc_fxtype_params& type_params,                          \
00960     const sc_fxcast_switch& cast_sw,                              \
00961     sc_fxnum_observer* observer_ )                                \
00962 : sc_fxnum( a,                                                                \
00963       type_params,                                                      \
00964       SC_TC_,                                                           \
00965       cast_sw,                                                          \
00966       observer_ )                                                       \
00967 {}
00968 
00969 DEFN_CTORS_T_A(int)
00970 DEFN_CTORS_T_A(unsigned int)
00971 DEFN_CTORS_T_A(long)
00972 DEFN_CTORS_T_A(unsigned long)
00973 DEFN_CTORS_T_A(double)
00974 DEFN_CTORS_T_A(const char*)
00975 DEFN_CTORS_T_A(const sc_fxval&)
00976 DEFN_CTORS_T_A(const sc_fxval_fast&)
00977 DEFN_CTORS_T_B(const sc_fxnum&)
00978 DEFN_CTORS_T_B(const sc_fxnum_fast&)
00979 #ifndef SC_FX_EXCLUDE_OTHER
00980 DEFN_CTORS_T_A(int64)
00981 DEFN_CTORS_T_A(uint64)
00982 DEFN_CTORS_T_A(const sc_int_base&)
00983 DEFN_CTORS_T_A(const sc_uint_base&)
00984 DEFN_CTORS_T_A(const sc_signed&)
00985 DEFN_CTORS_T_A(const sc_unsigned&)
00986 #endif
00987 
00988 #undef DEFN_CTORS_T_A
00989 #undef DEFN_CTORS_T_B
00990 
00991 // copy constructor
00992 
00993 inline
00994 sc_fix::sc_fix( const sc_fix& a )
00995 : sc_fxnum( a,
00996       a.type_params(),
00997       SC_TC_,
00998       sc_fxcast_switch(),
00999       0 )
01000 {}
01001 
01002 
01003 // unary bitwise operators
01004 
01005 inline
01006 const sc_fix
01007 sc_fix::operator ~ () const
01008 {
01009     SC_FXNUM_OBSERVER_READ_( *this )
01010     int iwl_c = iwl();
01011     int wl_c = wl();
01012     sc_fix c( wl_c, iwl_c );
01013     for( int i = iwl_c - wl_c; i < iwl_c; ++ i )
01014   c.set_bit( i, ! get_bit( i ) );
01015     return sc_fix( c, wl_c, iwl_c );
01016 }
01017 
01018 
01019 // unary bitwise functions
01020 
01021 inline
01022 void
01023 b_not( sc_fix& c, const sc_fix& a )
01024 {
01025     SC_FXNUM_OBSERVER_READ_( a )
01026     int iwl_c = c.iwl();
01027     for( int i = iwl_c - c.wl(); i < iwl_c; ++ i )
01028   c.set_bit( i, ! a.get_bit( i ) );
01029     c.cast();
01030     SC_FXNUM_OBSERVER_WRITE_( c )
01031 }
01032 
01033 
01034 // binary bitwise operators
01035 
01036 #define DEFN_BIN_OP_T(op,op2,tp1,tp2)                                         \
01037 inline                                                                        \
01038 const sc_fix                                                                  \
01039 operator op ( const tp1& a, const tp2& b )                                    \
01040 {                                                                             \
01041     a.observer_read();                                                        \
01042     b.observer_read();                                                        \
01043     int iwl_a = a.iwl();                                                      \
01044     int iwl_b = b.iwl();                                                      \
01045     int iwl_c = sc_max( iwl_a, iwl_b );                                       \
01046     int fwl_c = sc_max( a.wl() - iwl_a, b.wl() - iwl_b );                     \
01047     sc_fix c( iwl_c + fwl_c, iwl_c );                                         \
01048     for( int i = -fwl_c; i < iwl_c; ++ i )                                    \
01049   c.set_bit( i, a.get_bit( i ) op2 b.get_bit( i ) );                    \
01050     return sc_fix( c, iwl_c + fwl_c, iwl_c );                                 \
01051 }
01052 
01053 DEFN_BIN_OP_T(&,&&,sc_fix,sc_fix)
01054 DEFN_BIN_OP_T(&,&&,sc_fix,sc_fix_fast)
01055 DEFN_BIN_OP_T(&,&&,sc_fix_fast,sc_fix)
01056 
01057 DEFN_BIN_OP_T(|,||,sc_fix,sc_fix)
01058 DEFN_BIN_OP_T(|,||,sc_fix,sc_fix_fast)
01059 DEFN_BIN_OP_T(|,||,sc_fix_fast,sc_fix)
01060 
01061 DEFN_BIN_OP_T(^,!=,sc_fix,sc_fix)
01062 DEFN_BIN_OP_T(^,!=,sc_fix,sc_fix_fast)
01063 DEFN_BIN_OP_T(^,!=,sc_fix_fast,sc_fix)
01064 
01065 #undef DEFN_BIN_OP_T
01066 
01067 
01068 // binary bitwise functions
01069 
01070 #define DEFN_BIN_FNC_T(fnc,op2,tp1,tp2)                                       \
01071 inline                                                                        \
01072 void                                                                          \
01073 fnc ( sc_fix& c, const tp1& a, const tp2& b )                                 \
01074 {                                                                             \
01075     a.observer_read();                                                        \
01076     b.observer_read();                                                        \
01077     int iwl_c = c.iwl();                                                      \
01078     for( int i = iwl_c - c.wl(); i < iwl_c; ++ i )                            \
01079   c.set_bit( i, a.get_bit( i ) op2 b.get_bit( i ) );                    \
01080     c.cast();                                                                 \
01081     SC_FXNUM_OBSERVER_WRITE_( c )                                             \
01082 }
01083 
01084 DEFN_BIN_FNC_T(b_and,&&,sc_fix,sc_fix)
01085 DEFN_BIN_FNC_T(b_and,&&,sc_fix,sc_fix_fast)
01086 DEFN_BIN_FNC_T(b_and,&&,sc_fix_fast,sc_fix)
01087 
01088 DEFN_BIN_FNC_T(b_or,||,sc_fix,sc_fix)
01089 DEFN_BIN_FNC_T(b_or,||,sc_fix,sc_fix_fast)
01090 DEFN_BIN_FNC_T(b_or,||,sc_fix_fast,sc_fix)
01091 
01092 DEFN_BIN_FNC_T(b_xor,!=,sc_fix,sc_fix)
01093 DEFN_BIN_FNC_T(b_xor,!=,sc_fix,sc_fix_fast)
01094 DEFN_BIN_FNC_T(b_xor,!=,sc_fix_fast,sc_fix)
01095 
01096 #undef DEFN_BIN_FNC_T
01097 
01098 
01099 // assignment operators
01100 
01101 inline
01102 sc_fix&
01103 sc_fix::operator = ( const sc_fix& a )
01104 {
01105     sc_fxnum::operator = ( a );
01106     return *this;
01107 }
01108 
01109 #define DEFN_ASN_OP_T(op,tp)                                                  \
01110 inline                                                                        \
01111 sc_fix&                                                                       \
01112 sc_fix::operator op ( tp a )                                                  \
01113 {                                                                             \
01114     sc_fxnum::operator op( a );                                               \
01115     return *this;                                                             \
01116 }
01117 
01118 #ifndef SC_FX_EXCLUDE_OTHER
01119 #define DEFN_ASN_OP_OTHER(op)                                                 \
01120 DEFN_ASN_OP_T(op,int64)                                                       \
01121 DEFN_ASN_OP_T(op,uint64)                                                      \
01122 DEFN_ASN_OP_T(op,const sc_int_base&)                                          \
01123 DEFN_ASN_OP_T(op,const sc_uint_base&)                                         \
01124 DEFN_ASN_OP_T(op,const sc_signed&)                                            \
01125 DEFN_ASN_OP_T(op,const sc_unsigned&)
01126 #else
01127 #define DEFN_ASN_OP_OTHER(op)
01128 #endif
01129 
01130 #define DEFN_ASN_OP(op)                                                       \
01131 DEFN_ASN_OP_T(op,int)                                                         \
01132 DEFN_ASN_OP_T(op,unsigned int)                                                \
01133 DEFN_ASN_OP_T(op,long)                                                        \
01134 DEFN_ASN_OP_T(op,unsigned long)                                               \
01135 DEFN_ASN_OP_T(op,double)                                                      \
01136 DEFN_ASN_OP_T(op,const char*)                                                 \
01137 DEFN_ASN_OP_T(op,const sc_fxval&)                                             \
01138 DEFN_ASN_OP_T(op,const sc_fxval_fast&)                                        \
01139 DEFN_ASN_OP_T(op,const sc_fxnum&)                                             \
01140 DEFN_ASN_OP_T(op,const sc_fxnum_fast&)                                        \
01141 DEFN_ASN_OP_OTHER(op)
01142 
01143 DEFN_ASN_OP(=)
01144 
01145 DEFN_ASN_OP(*=)
01146 DEFN_ASN_OP(/=)
01147 DEFN_ASN_OP(+=)
01148 DEFN_ASN_OP(-=)
01149 
01150 DEFN_ASN_OP_T(<<=,int)
01151 DEFN_ASN_OP_T(>>=,int)
01152 
01153 #undef DEFN_ASN_OP_T
01154 #undef DEFN_ASN_OP_OTHER
01155 #undef DEFN_ASN_OP
01156 
01157 
01158 #define DEFN_ASN_OP_T(op,op2,tp)                                              \
01159 inline                                                                        \
01160 sc_fix&                                                                       \
01161 sc_fix::operator op ( const tp& b )                                           \
01162 {                                                                             \
01163     SC_FXNUM_OBSERVER_READ_( *this )                                          \
01164     b.observer_read();                                                        \
01165     int iwl_c = iwl();                                                        \
01166     for( int i = iwl_c - wl(); i < iwl_c; ++ i )                              \
01167   set_bit( i, get_bit( i ) op2 b.get_bit( i ) );                        \
01168     cast();                                                                   \
01169     SC_FXNUM_OBSERVER_WRITE_( *this )                                         \
01170     return *this;                                                             \
01171 }
01172 
01173 DEFN_ASN_OP_T(&=,&&,sc_fix)
01174 DEFN_ASN_OP_T(&=,&&,sc_fix_fast)
01175 DEFN_ASN_OP_T(|=,||,sc_fix)
01176 DEFN_ASN_OP_T(|=,||,sc_fix_fast)
01177 DEFN_ASN_OP_T(^=,!=,sc_fix)
01178 DEFN_ASN_OP_T(^=,!=,sc_fix_fast)
01179 
01180 #undef DEFN_ASN_OP_T
01181 
01182 
01183 // auto-increment and auto-decrement
01184 
01185 inline
01186 const sc_fxval
01187 sc_fix::operator ++ ( int )
01188 {
01189     return sc_fxval( sc_fxnum::operator ++ ( 0 ) );
01190 }
01191 
01192 inline
01193 const sc_fxval
01194 sc_fix::operator -- ( int )
01195 {
01196     return sc_fxval( sc_fxnum::operator -- ( 0 ) );
01197 }
01198 
01199 inline
01200 sc_fix&
01201 sc_fix::operator ++ ()
01202 {
01203     sc_fxnum::operator ++ ();
01204     return *this;
01205 }
01206 
01207 inline
01208 sc_fix&
01209 sc_fix::operator -- ()
01210 {
01211     sc_fxnum::operator -- ();
01212     return *this;
01213 }
01214 
01215 
01216 // ----------------------------------------------------------------------------
01217 //  CLASS : sc_fix_fast
01218 //
01219 //  "Unconstrained" signed fixed-point class; limited precision.
01220 // ----------------------------------------------------------------------------
01221 
01222 // constructors
01223 
01224 inline
01225 sc_fix_fast::sc_fix_fast( sc_fxnum_fast_observer* observer_ )
01226 : sc_fxnum_fast( sc_fxtype_params(),
01227      SC_TC_,
01228      sc_fxcast_switch(),
01229      observer_ )
01230 {}
01231 
01232 inline
01233 sc_fix_fast::sc_fix_fast( int wl_, int iwl_,
01234         sc_fxnum_fast_observer* observer_ )
01235 : sc_fxnum_fast( sc_fxtype_params( wl_, iwl_ ),
01236      SC_TC_,
01237      sc_fxcast_switc