src/sysc/datatypes/fx/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-2005 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.4 (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 "sysc/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_switch(),
01238                  observer_ )
01239 {}
01240 
01241 inline
01242 sc_fix_fast::sc_fix_fast( sc_q_mode qm, sc_o_mode om,
01243                           sc_fxnum_fast_observer* observer_ )
01244 : sc_fxnum_fast( sc_fxtype_params( qm, om ),
01245                  SC_TC_,
01246                  sc_fxcast_switch(),
01247                  observer_ )
01248 {}
01249 
01250 inline
01251 sc_fix_fast::sc_fix_fast( sc_q_mode qm, sc_o_mode om, int nb,
01252                           sc_fxnum_fast_observer* observer_ )
01253 : sc_fxnum_fast( sc_fxtype_params( qm, om, nb ),
01254                  SC_TC_,
01255                  sc_fxcast_switch(),
01256                  observer_ )
01257 {}
01258 
01259 inline
01260 sc_fix_fast::sc_fix_fast( int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
01261                           sc_fxnum_fast_observer* observer_ )
01262 : sc_fxnum_fast( sc_fxtype_params( wl_, iwl_, qm, om ),
01263                  SC_TC_,
01264                  sc_fxcast_switch(),
01265                  observer_ )
01266 {}
01267 
01268 inline
01269 sc_fix_fast::sc_fix_fast( int wl_, int iwl_,
01270                           sc_q_mode qm, sc_o_mode om, int nb,
01271                           sc_fxnum_fast_observer* observer_ )
01272 : sc_fxnum_fast( sc_fxtype_params( wl_, iwl_, qm, om, nb ),
01273                  SC_TC_,
01274                  sc_fxcast_switch(),
01275                  observer_ )
01276 {}
01277 
01278 inline
01279 sc_fix_fast::sc_fix_fast( const sc_fxcast_switch& cast_sw,
01280                           sc_fxnum_fast_observer* observer_ )
01281 : sc_fxnum_fast( sc_fxtype_params(),
01282                  SC_TC_,
01283                  cast_sw,
01284                  observer_ )
01285 {}
01286 
01287 inline
01288 sc_fix_fast::sc_fix_fast( int wl_, int iwl_,
01289                           const sc_fxcast_switch& cast_sw,
01290                           sc_fxnum_fast_observer* observer_ )
01291 : sc_fxnum_fast( sc_fxtype_params( wl_, iwl_ ),
01292                  SC_TC_,
01293                  cast_sw,
01294                  observer_ )
01295 {}
01296 
01297 inline
01298 sc_fix_fast::sc_fix_fast( sc_q_mode qm, sc_o_mode om,
01299                           const sc_fxcast_switch& cast_sw,
01300                           sc_fxnum_fast_observer* observer_ )
01301 : sc_fxnum_fast( sc_fxtype_params( qm, om ),
01302                  SC_TC_,
01303                  cast_sw,
01304                  observer_ )
01305 {}
01306 
01307 inline
01308 sc_fix_fast::sc_fix_fast( sc_q_mode qm, sc_o_mode om, int nb,
01309                           const sc_fxcast_switch& cast_sw,
01310                           sc_fxnum_fast_observer* observer_ )
01311 : sc_fxnum_fast( sc_fxtype_params( qm, om, nb ),
01312                  SC_TC_,
01313                  cast_sw,
01314                  observer_ )
01315 {}
01316 
01317 inline
01318 sc_fix_fast::sc_fix_fast( int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,
01319                           const sc_fxcast_switch& cast_sw,
01320                           sc_fxnum_fast_observer* observer_ )
01321 : sc_fxnum_fast( sc_fxtype_params( wl_, iwl_, qm, om ),
01322                  SC_TC_,
01323                  cast_sw,
01324                  observer_ )
01325 {}
01326 
01327 inline
01328 sc_fix_fast::sc_fix_fast( int wl_, int iwl_,
01329                           sc_q_mode qm, sc_o_mode om, int nb,
01330                           const sc_fxcast_switch& cast_sw,
01331                           sc_fxnum_fast_observer* observer_ )
01332 : sc_fxnum_fast( sc_fxtype_params( wl_, iwl_, qm, om, nb ),
01333                  SC_TC_,
01334                  cast_sw,
01335                  observer_ )
01336 {}
01337 
01338 inline
01339 sc_fix_fast::sc_fix_fast( const sc_fxtype_params& type_params,
01340                           sc_fxnum_fast_observer* observer_ )
01341 : sc_fxnum_fast( type_params,
01342                  SC_TC_,
01343                  sc_fxcast_switch(),
01344                  observer_ )
01345 {}
01346 
01347 inline
01348 sc_fix_fast::sc_fix_fast( const sc_fxtype_params& type_params,
01349                           const sc_fxcast_switch& cast_sw,
01350                           sc_fxnum_fast_observer* observer_ )
01351 : sc_fxnum_fast( type_params,
01352                  SC_TC_,
01353                  cast_sw,
01354                  observer_ )
01355 {}
01356 
01357 #define DEFN_CTORS_T_A(tp)                                                    \
01358 inline                                                                        \
01359 sc_fix_fast::sc_fix_fast( tp a,                                               \
01360                           sc_fxnum_fast_observer* observer_ )                 \
01361 : sc_fxnum_fast( a,                                                           \
01362                  sc_fxtype_params(),                                          \
01363                  SC_TC_,                                                      \
01364                  sc_fxcast_switch(),                                          \
01365                  observer_ )                                                  \
01366 {}                                                                            \
01367                                                                               \
01368 inline                                                                        \
01369 sc_fix_fast::sc_fix_fast( tp a,                                               \
01370                           int wl_, int iwl_,                                  \
01371                           sc_fxnum_fast_observer* observer_ )                 \
01372 : sc_fxnum_fast( a,                                                           \
01373                  sc_fxtype_params( wl_, iwl_ ),                               \
01374                  SC_TC_,                                                      \
01375                  sc_fxcast_switch(),                                          \
01376                  observer_ )                                                  \
01377 {}                                                                            \
01378                                                                               \
01379 inline                                                                        \
01380 sc_fix_fast::sc_fix_fast( tp a,                                               \
01381                           sc_q_mode qm, sc_o_mode om,                         \
01382                           sc_fxnum_fast_observer* observer_ )                 \
01383 : sc_fxnum_fast( a,                                                           \
01384                  sc_fxtype_params( qm, om ),                                  \
01385                  SC_TC_,                                                      \
01386                  sc_fxcast_switch(),                                          \
01387                  observer_ )                                                  \
01388 {}                                                                            \
01389                                                                               \
01390 inline                                                                        \
01391 sc_fix_fast::sc_fix_fast( tp a,                                               \
01392                           sc_q_mode qm, sc_o_mode om, int nb,                 \
01393                           sc_fxnum_fast_observer* observer_ )                 \
01394 : sc_fxnum_fast( a,                                                           \
01395                  sc_fxtype_params( qm, om, nb ),                              \
01396                  SC_TC_,                                                      \
01397                  sc_fxcast_switch(),                                          \
01398                  observer_ )                                                  \
01399 {}                                                                            \
01400                                                                               \
01401 inline                                                                        \
01402 sc_fix_fast::sc_fix_fast( tp a,                                               \
01403                           int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,      \
01404                           sc_fxnum_fast_observer* observer_ )                 \
01405 : sc_fxnum_fast( a,                                                           \
01406                  sc_fxtype_params( wl_, iwl_, qm, om ),                       \
01407                  SC_TC_,                                                      \
01408                  sc_fxcast_switch(),                                          \
01409                  observer_ )                                                  \
01410 {}                                                                            \
01411                                                                               \
01412 inline                                                                        \
01413 sc_fix_fast::sc_fix_fast( tp a,                                               \
01414                           int wl_, int iwl_,                                  \
01415                           sc_q_mode qm, sc_o_mode om, int nb,                 \
01416                           sc_fxnum_fast_observer* observer_ )                 \
01417 : sc_fxnum_fast( a,                                                           \
01418                  sc_fxtype_params( wl_, iwl_, qm, om, nb ),                   \
01419                  SC_TC_,                                                      \
01420                  sc_fxcast_switch(),                                          \
01421                  observer_ )                                                  \
01422 {}                                                                            \
01423                                                                               \
01424 inline                                                                        \
01425 sc_fix_fast::sc_fix_fast( tp a,                                               \
01426                           const sc_fxcast_switch& cast_sw,                    \
01427                           sc_fxnum_fast_observer* observer_ )                 \
01428 : sc_fxnum_fast( a,                                                           \
01429                  sc_fxtype_params(),                                          \
01430                  SC_TC_,                                                      \
01431                  cast_sw,                                                     \
01432                  observer_ )                                                  \
01433 {}                                                                            \
01434                                                                               \
01435 inline                                                                        \
01436 sc_fix_fast::sc_fix_fast( tp a,                                               \
01437                           int wl_, int iwl_,                                  \
01438                           const sc_fxcast_switch& cast_sw,                    \
01439                           sc_fxnum_fast_observer* observer_ )                 \
01440 : sc_fxnum_fast( a,                                                           \
01441                  sc_fxtype_params( wl_, iwl_ ),                               \
01442                  SC_TC_,                                                      \
01443                  cast_sw,                                                     \
01444                  observer_ )                                                  \
01445 {}                                                                            \
01446                                                                               \
01447 inline                                                                        \
01448 sc_fix_fast::sc_fix_fast( tp a,                                               \
01449                           sc_q_mode qm, sc_o_mode om,                         \
01450                           const sc_fxcast_switch& cast_sw,                    \
01451                           sc_fxnum_fast_observer* observer_ )                 \
01452 : sc_fxnum_fast( a,                                                           \
01453                  sc_fxtype_params( qm, om ),                                  \
01454                  SC_TC_,                                                      \
01455                  cast_sw,                                                     \
01456                  observer_ )                                                  \
01457 {}                                                                            \
01458                                                                               \
01459 inline                                                                        \
01460 sc_fix_fast::sc_fix_fast( tp a,                                               \
01461                           sc_q_mode qm, sc_o_mode om, int nb,                 \
01462                           const sc_fxcast_switch& cast_sw,                    \
01463                           sc_fxnum_fast_observer* observer_ )                 \
01464 : sc_fxnum_fast( a,                                                           \
01465                  sc_fxtype_params( qm, om, nb ),                              \
01466                  SC_TC_,                                                      \
01467                  cast_sw,                                                     \
01468                  observer_ )                                                  \
01469 {}                                                                            \
01470                                                                               \
01471 inline                                                                        \
01472 sc_fix_fast::sc_fix_fast( tp a,                                               \
01473                           int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,      \
01474                           const sc_fxcast_switch& cast_sw,                    \
01475                           sc_fxnum_fast_observer* observer_ )                 \
01476 : sc_fxnum_fast( a,                                                           \
01477                  sc_fxtype_params( wl_, iwl_, qm, om ),                       \
01478                  SC_TC_,                                                      \
01479                  cast_sw,                                                     \
01480                  observer_ )                                                  \
01481 {}                                                                            \
01482                                                                               \
01483 inline                                                                        \
01484 sc_fix_fast::sc_fix_fast( tp a,                                               \
01485                           int wl_, int iwl_,                                  \
01486                           sc_q_mode qm, sc_o_mode om, int nb,                 \
01487                           const sc_fxcast_switch& cast_sw,                    \
01488                           sc_fxnum_fast_observer* observer_ )                 \
01489 : sc_fxnum_fast( a,                                                           \
01490                  sc_fxtype_params( wl_, iwl_, qm, om, nb ),                   \
01491                  SC_TC_,                                                      \
01492                  cast_sw,                                                     \
01493                  observer_ )                                                  \
01494 {}                                                                            \
01495                                                                               \
01496 inline                                                                        \
01497 sc_fix_fast::sc_fix_fast( tp a,                                               \
01498                           const sc_fxtype_params& type_params,                \
01499                           sc_fxnum_fast_observer* observer_ )                 \
01500 : sc_fxnum_fast( a,                                                           \
01501                  type_params,                                                 \
01502                  SC_TC_,                                                      \
01503                  sc_fxcast_switch(),                                          \
01504                  observer_ )                                                  \
01505 {}                                                                            \
01506                                                                               \
01507 inline                                                                        \
01508 sc_fix_fast::sc_fix_fast( tp a,                                               \
01509                           const sc_fxtype_params& type_params,                \
01510                           const sc_fxcast_switch& cast_sw,                    \
01511                           sc_fxnum_fast_observer* observer_ )                 \
01512 : sc_fxnum_fast( a,                                                           \
01513                  type_params,                                                 \
01514                  SC_TC_,                                                      \
01515                  cast_sw,                                                     \
01516                  observer_ )                                                  \
01517 {}
01518 
01519 #define DEFN_CTORS_T_B(tp)                                                    \
01520 inline                                                                        \
01521 sc_fix_fast::sc_fix_fast( tp a,                                               \
01522                           sc_fxnum_fast_observer* observer_ )                 \
01523 : sc_fxnum_fast( a,                                                           \
01524                  a.type_params(),                                             \
01525                  SC_TC_,                                                      \
01526                  sc_fxcast_switch(),                                          \
01527                  observer_ )                                                  \
01528 {}                                                                            \
01529                                                                               \
01530 inline                                                                        \
01531 sc_fix_fast::sc_fix_fast( tp a,                                               \
01532                           int wl_, int iwl_,                                  \
01533                           sc_fxnum_fast_observer* observer_ )                 \
01534 : sc_fxnum_fast( a,                                                           \
01535                  sc_fxtype_params( a.type_params(), wl_, iwl_ ),              \
01536                  SC_TC_,                                                      \
01537                  sc_fxcast_switch(),                                          \
01538                  observer_ )                                                  \
01539 {}                                                                            \
01540                                                                               \
01541 inline                                                                        \
01542 sc_fix_fast::sc_fix_fast( tp a,                                               \
01543                           sc_q_mode qm, sc_o_mode om,                         \
01544                           sc_fxnum_fast_observer* observer_ )                 \
01545 : sc_fxnum_fast( a,                                                           \
01546                  sc_fxtype_params( a.type_params(), qm, om ),                 \
01547                  SC_TC_,                                                      \
01548                  sc_fxcast_switch(),                                          \
01549                  observer_ )                                                  \
01550 {}                                                                            \
01551                                                                               \
01552 inline                                                                        \
01553 sc_fix_fast::sc_fix_fast( tp a,                                               \
01554                           sc_q_mode qm, sc_o_mode om, int nb,                 \
01555                           sc_fxnum_fast_observer* observer_ )                 \
01556 : sc_fxnum_fast( a,                                                           \
01557                  sc_fxtype_params( a.type_params(), qm, om, nb ),             \
01558                  SC_TC_,                                                      \
01559                  sc_fxcast_switch(),                                          \
01560                  observer_ )                                                  \
01561 {}                                                                            \
01562                                                                               \
01563 inline                                                                        \
01564 sc_fix_fast::sc_fix_fast( tp a,                                               \
01565                           int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,      \
01566                           sc_fxnum_fast_observer* observer_ )                 \
01567 : sc_fxnum_fast( a,                                                           \
01568                  sc_fxtype_params( wl_, iwl_, qm, om ),                       \
01569                  SC_TC_,                                                      \
01570                  sc_fxcast_switch(),                                          \
01571                  observer_ )                                                  \
01572 {}                                                                            \
01573                                                                               \
01574 inline                                                                        \
01575 sc_fix_fast::sc_fix_fast( tp a,                                               \
01576                           int wl_, int iwl_,                                  \
01577                           sc_q_mode qm, sc_o_mode om, int nb,                 \
01578                           sc_fxnum_fast_observer* observer_ )                 \
01579 : sc_fxnum_fast( a,                                                           \
01580                  sc_fxtype_params( wl_, iwl_, qm, om, nb ),                   \
01581                  SC_TC_,                                                      \
01582                  sc_fxcast_switch(),                                          \
01583                  observer_ )                                                  \
01584 {}                                                                            \
01585                                                                               \
01586 inline                                                                        \
01587 sc_fix_fast::sc_fix_fast( tp a,                                               \
01588                           const sc_fxcast_switch& cast_sw,                    \
01589                           sc_fxnum_fast_observer* observer_ )                 \
01590 : sc_fxnum_fast( a,                                                           \
01591                  a.type_params(),                                             \
01592                  SC_TC_,                                                      \
01593                  cast_sw,                                                     \
01594                  observer_ )                                                  \
01595 {}                                                                            \
01596                                                                               \
01597 inline                                                                        \
01598 sc_fix_fast::sc_fix_fast( tp a,                                               \
01599                           int wl_, int iwl_,                                  \
01600                           const sc_fxcast_switch& cast_sw,                    \
01601                           sc_fxnum_fast_observer* observer_ )                 \
01602 : sc_fxnum_fast( a,                                                           \
01603                  sc_fxtype_params( a.type_params(), wl_, iwl_ ),              \
01604                  SC_TC_,                                                      \
01605                  cast_sw,                                                     \
01606                  observer_ )                                                  \
01607 {}                                                                            \
01608                                                                               \
01609 inline                                                                        \
01610 sc_fix_fast::sc_fix_fast( tp a,                                               \
01611                           sc_q_mode qm, sc_o_mode om,                         \
01612                           const sc_fxcast_switch& cast_sw,                    \
01613                           sc_fxnum_fast_observer* observer_ )                 \
01614 : sc_fxnum_fast( a,                                                           \
01615                  sc_fxtype_params( a.type_params(), qm, om ),                 \
01616                  SC_TC_,                                                      \
01617                  cast_sw,                                                     \
01618                  observer_ )                                                  \
01619 {}                                                                            \
01620                                                                               \
01621 inline                                                                        \
01622 sc_fix_fast::sc_fix_fast( tp a,                                               \
01623                           sc_q_mode qm, sc_o_mode om, int nb,                 \
01624                           const sc_fxcast_switch& cast_sw,                    \
01625                           sc_fxnum_fast_observer* observer_ )                 \
01626 : sc_fxnum_fast( a,                                                           \
01627                  sc_fxtype_params( a.type_params(), qm, om, nb ),             \
01628                  SC_TC_,                                                      \
01629                  cast_sw,                                                     \
01630                  observer_ )                                                  \
01631 {}                                                                            \
01632                                                                               \
01633 inline                                                                        \
01634 sc_fix_fast::sc_fix_fast( tp a,                                               \
01635                           int wl_, int iwl_, sc_q_mode qm, sc_o_mode om,      \
01636                           const sc_fxcast_switch& cast_sw,                    \
01637                           sc_fxnum_fast_observer* observer_ )                 \
01638 : sc_fxnum_fast( a,                                                           \
01639                  sc_fxtype_params( wl_, iwl_, qm, om ),                       \
01640                  SC_TC_,                                                      \
01641                  cast_sw,                                                     \
01642                  observer_ )                                                  \
01643 {}                                                                            \
01644                                                                               \
01645 inline                                                                        \
01646 sc_fix_fast::sc_fix_fast( tp a,                                               \
01647                           int wl_, int iwl_,                                  \
01648                           sc_q_mode qm, sc_o_mode om, int nb,                 \
01649                           const sc_fxcast_switch& cast_sw,                    \
01650                           sc_fxnum_fast_observer* observer_ )                 \
01651 : sc_fxnum_fast( a,                                                           \
01652                  sc_fxtype_params( wl_, iwl_, qm, om, nb ),                   \
01653                  SC_TC_,                                                      \
01654                  cast_sw,                                                     \
01655                  observer_ )                                                  \
01656 {}                                                                            \
01657                                                                               \
01658 inline                                                                        \
01659 sc_fix_fast::sc_fix_fast( tp a,                                               \
01660                           const sc_fxtype_params& type_params,                \
01661                           sc_fxnum_fast_observer* observer_ )                 \
01662 : sc_fxnum_fast( a,                                                           \
01663                  type_params,                                                 \
01664                  SC_TC_,                                                      \
01665                  sc_fxcast_switch(),                                          \
01666                  observer_ )                                                  \
01667 {}                                                                            \
01668                                                                               \
01669 inline                                                                        \
01670 sc_fix_fast::sc_fix_fast( tp a,                                               \
01671                           const sc_fxtype_params& type_params,                \
01672                           const sc_fxcast_switch& cast_sw,                    \
01673                           sc_fxnum_fast_observer* observer_ )                 \
01674 : sc_fxnum_fast( a,                                                           \
01675                  type_params,                                                 \
01676                  SC_TC_,                                                      \
01677                  cast_sw,                                                     \
01678                  observer_ )                                                  \
01679 {}
01680 
01681 DEFN_CTORS_T_A(int)
01682 DEFN_CTORS_T_A(unsigned int)
01683 DEFN_CTORS_T_A(long)
01684 DEFN_CTORS_T_A(unsigned long)
01685 DEFN_CTORS_T_A(double)
01686 DEFN_CTORS_T_A(const char*)
01687 DEFN_CTORS_T_A(const sc_fxval&)
01688 DEFN_CTORS_T_A(const sc_fxval_fast&)
01689 DEFN_CTORS_T_B(const sc_fxnum&)
01690 DEFN_CTORS_T_B(const sc_fxnum_fast&)
01691 #ifndef SC_FX_EXCLUDE_OTHER
01692 DEFN_CTORS_T_A(int64)
01693 DEFN_CTORS_T_A(uint64)
01694 DEFN_CTORS_T_A(const sc_int_base&)
01695 DEFN_CTORS_T_A(const sc_uint_base&)
01696 DEFN_CTORS_T_A(const sc_signed&)
01697 DEFN_CTORS_T_A(const sc_unsigned&)
01698 #endif
01699 
01700 #undef DEFN_CTORS_T_A
01701 #undef DEFN_CTORS_T_B
01702 
01703 // copy constructor
01704 
01705 inline
01706 sc_fix_fast::sc_fix_fast( const sc_fix_fast& a )
01707 : sc_fxnum_fast( a,
01708                  a.type_params(),
01709                  SC_TC_,
01710                  sc_fxcast_switch(),
01711                  0 )
01712 {}
01713 
01714 
01715 // unary bitwise operators
01716 
01717 inline
01718 const sc_fix_fast
01719 sc_fix_fast::operator ~ () const
01720 {
01721     SC_FXNUM_FAST_OBSERVER_READ_( *this )
01722     int iwl_c = iwl();
01723     int wl_c = wl();
01724     sc_fix_fast c( wl_c, iwl_c );
01725     for( int i = iwl_c - wl_c; i < iwl_c; ++ i )
01726         c.set_bit( i, ! get_bit( i ) );
01727     return sc_fix_fast( c, wl_c, iwl_c );
01728 }
01729 
01730 
01731 // unary bitwise functions
01732 
01733 inline
01734 void
01735 b_not( sc_fix_fast& c, const sc_fix_fast& a )
01736 {
01737     SC_FXNUM_FAST_OBSERVER_READ_( a )
01738     int iwl_c = c.iwl();
01739     for( int i = iwl_c - c.wl(); i < iwl_c; ++ i )
01740         c.set_bit( i, ! a.get_bit( i ) );
01741     c.cast();
01742     SC_FXNUM_FAST_OBSERVER_WRITE_( c )
01743 }
01744 
01745 
01746 // binary bitwise operators
01747 
01748 #define DEFN_BIN_OP_T(op,op2,tp1,tp2)                                         \
01749 inline                                                                        \
01750 const sc_fix_fast                                                             \
01751 operator op ( const tp1& a, const tp2& b )                                    \
01752 {                                                                             \
01753     a.observer_read();                                                        \
01754     b.observer_read();                                                        \
01755     int iwl_a = a.iwl();                                                      \
01756     int iwl_b = b.iwl();                                                      \
01757     int iwl_c = sc_max( iwl_a, iwl_b );                              \
01758     int fwl_c = sc_max( a.wl() - iwl_a, b.wl() - iwl_b );            \
01759     sc_fix_fast c( iwl_c + fwl_c, iwl_c );                                    \
01760     for( int i = -fwl_c; i < iwl_c; ++ i )                                    \
01761         c.set_bit( i, a.get_bit( i ) op2 b.get_bit( i ) );                    \
01762     return sc_fix_fast( c, iwl_c + fwl_c, iwl_c );                            \
01763 }
01764 
01765 DEFN_BIN_OP_T(&,&&,sc_fix_fast,sc_fix_fast)
01766 DEFN_BIN_OP_T(|,||,sc_fix_fast,sc_fix_fast)
01767 DEFN_BIN_OP_T(^,!=,sc_fix_fast,sc_fix_fast)
01768 
01769 #undef DEFN_BIN_OP_T
01770 
01771 
01772 // binary bitwise functions
01773 
01774 #define DEFN_BIN_FNC_T(fnc,op2,tp1,tp2)                                       \
01775 inline                                                                        \
01776 void                                                                          \
01777 fnc ( sc_fix_fast& c, const tp1& a, const tp2& b )                            \
01778 {                                                                             \
01779     a.observer_read();                                                        \
01780     b.observer_read();                                                        \
01781     int iwl_c = c.iwl();                                                      \
01782     for( int i = iwl_c - c.wl(); i < iwl_c; ++ i )                            \
01783         c.set_bit( i, a.get_bit( i ) op2 b.get_bit( i ) );                    \
01784     c.cast();                                                                 \
01785     SC_FXNUM_FAST_OBSERVER_WRITE_( c )                                        \
01786 }
01787 
01788 DEFN_BIN_FNC_T(b_and,&&,sc_fix_fast,sc_fix_fast)
01789 DEFN_BIN_FNC_T(b_or,||,sc_fix_fast,sc_fix_fast)
01790 DEFN_BIN_FNC_T(b_xor,!=,sc_fix_fast,sc_fix_fast)
01791 
01792 #undef DEFN_BIN_FNC_T
01793 
01794 
01795 // assignment operators
01796 
01797 inline
01798 sc_fix_fast&
01799 sc_fix_fast::operator = ( const sc_fix_fast& a )
01800 {
01801     sc_fxnum_fast::operator = ( a );
01802     return *this;
01803 }
01804 
01805 #define DEFN_ASN_OP_T(op,tp)                                                  \
01806 inline                                                                        \
01807 sc_fix_fast&                                                                  \
01808 sc_fix_fast::operator op ( tp a )                                             \
01809 {                                                                             \
01810     sc_fxnum_fast::operator op( a );                                          \
01811     return *this;                                                             \
01812 }
01813 
01814 #ifndef SC_FX_EXCLUDE_OTHER
01815 #define DEFN_ASN_OP_OTHER(op)                                                 \
01816 DEFN_ASN_OP_T(op,int64)                                                       \
01817 DEFN_ASN_OP_T(op,uint64)                                                      \
01818 DEFN_ASN_OP_T(op,const sc_int_base&)                                          \
01819 DEFN_ASN_OP_T(op,const sc_uint_base&)                                         \
01820 DEFN_ASN_OP_T(op,const sc_signed&)                                            \
01821 DEFN_ASN_OP_T(op,const sc_unsigned&)
01822 #else
01823 #define DEFN_ASN_OP_OTHER(op)
01824 #endif
01825 
01826 #define DEFN_ASN_OP(op)                                                       \
01827 DEFN_ASN_OP_T(op,int)                                                         \
01828 DEFN_ASN_OP_T(op,unsigned int)                                                \
01829 DEFN_ASN_OP_T(op,long)                                                        \
01830 DEFN_ASN_OP_T(op,unsigned long)                                               \
01831 DEFN_ASN_OP_T(op,double)                                                      \
01832 DEFN_ASN_OP_T(op,const char*)                                                 \
01833 DEFN_ASN_OP_T(op,const sc_fxval&)                                             \
01834 DEFN_ASN_OP_T(op,const sc_fxval_fast&)                                        \
01835 DEFN_ASN_OP_T(op,const sc_fxnum&)                                             \
01836 DEFN_ASN_OP_T(op,const sc_fxnum_fast&)                                        \
01837 DEFN_ASN_OP_OTHER(op)
01838 
01839 DEFN_ASN_OP(=)
01840 
01841 DEFN_ASN_OP(*=)
01842 DEFN_ASN_OP(/=)
01843 DEFN_ASN_OP(+=)
01844 DEFN_ASN_OP(-=)
01845 
01846 DEFN_ASN_OP_T(<<=,int)
01847 DEFN_ASN_OP_T(>>=,int)
01848 
01849 #undef DEFN_ASN_OP_T
01850 #undef DEFN_ASN_OP_OTHER
01851 #undef DEFN_ASN_OP
01852 
01853 
01854 #define DEFN_ASN_OP_T(op,op2,tp)                                              \
01855 inline                                                                        \
01856 sc_fix_fast&                                                                  \
01857 sc_fix_fast::operator op ( const tp& b )                                      \
01858 {                                                                             \
01859     SC_FXNUM_FAST_OBSERVER_READ_( *this )                                     \
01860     b.observer_read();                                                        \
01861     int iwl_c = iwl();                                                        \
01862     for( int i = iwl_c - wl(); i < iwl_c; ++ i )                              \
01863         set_bit( i, get_bit( i ) op2 b.get_bit( i ) );                        \
01864     cast();                                                                   \
01865     SC_FXNUM_FAST_OBSERVER_WRITE_( *this )                                    \
01866     return *this;                                                             \
01867 }
01868 
01869 DEFN_ASN_OP_T(&=,&&,sc_fix)
01870 DEFN_ASN_OP_T(&=,&&,sc_fix_fast)
01871 DEFN_ASN_OP_T(|=,||,sc_fix)
01872 DEFN_ASN_OP_T(|=,||,sc_fix_fast)
01873 DEFN_ASN_OP_T(^=,!=,sc_fix)
01874 DEFN_ASN_OP_T(^=,!=,sc_fix_fast)
01875 
01876 #undef DEFN_ASN_OP_T
01877 
01878 
01879 // auto-increment and auto-decrement
01880 
01881 inline
01882 const sc_fxval_fast
01883 sc_fix_fast::operator ++ ( int )
01884 {
01885     return sc_fxval_fast( sc_fxnum_fast::operator ++ ( 0 ) );
01886 }
01887 
01888 inline
01889 const sc_fxval_fast
01890 sc_fix_fast::operator -- ( int )
01891 {
01892     return sc_fxval_fast( sc_fxnum_fast::operator -- ( 0 ) );
01893 }
01894 
01895 inline
01896 sc_fix_fast&
01897 sc_fix_fast::operator ++ ()
01898 {
01899     sc_fxnum_fast::operator ++ ();
01900     return *this;
01901 }
01902 
01903 inline
01904 sc_fix_fast&
01905 sc_fix_fast::operator -- ()
01906 {
01907     sc_fxnum_fast::operator -- ();
01908     return *this;
01909 }
01910 
01911 } // namespace sc_dt
01912 
01913 
01914 #endif
01915 
01916 // Taf!

Generated on Wed Apr 25 13:53:26 2007 for SystemC by  doxygen 1.5.1