⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sc_fxval.h

📁 system C源码 一种替代verilog的语言
💻 H
📖 第 1 页 / 共 5 页
字号:
/*****************************************************************************  The following code is derived, directly or indirectly, from the SystemC  source code Copyright (c) 1996-2006 by all Contributors.  All Rights reserved.  The contents of this file are subject to the restrictions and limitations  set forth in the SystemC Open Source License Version 2.4 (the "License");  You may not use this file except in compliance with such restrictions and  limitations. You may obtain instructions on how to receive a copy of the  License at http://www.systemc.org/. Software distributed by Contributors  under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF  ANY KIND, either express or implied. See the License for the specific  language governing rights and limitations under the License. *****************************************************************************//*****************************************************************************  sc_fxval.h -   Original Author: Martin Janssen, Synopsys, Inc. *****************************************************************************//*****************************************************************************  MODIFICATION LOG - modifiers, enter your name, affiliation, date and  changes you are making here.      Name, Affiliation, Date:  Description of Modification: *****************************************************************************/// $Log: sc_fxval.h,v $// Revision 1.1.1.1  2006/12/15 20:31:36  acg// SystemC 2.2//// Revision 1.3  2006/01/13 18:53:58  acg// Andy Goodrich: added $Log command so that CVS comments are reproduced in// the source.//#ifndef SC_FXVAL_H#define SC_FXVAL_H#include "sysc/datatypes/fx/scfx_rep.h"#ifndef SC_FX_EXCLUDE_OTHER#include "sysc/datatypes/int/sc_int_base.h"#include "sysc/datatypes/int/sc_uint_base.h"#include "sysc/datatypes/int/sc_signed.h"#include "sysc/datatypes/int/sc_unsigned.h"#endif#include "sysc/datatypes/fx/sc_fxval_observer.h"namespace sc_dt{// classes defined in this moduleclass sc_fxval;class sc_fxval_fast;// forward class declarationsclass sc_fxnum;class sc_fxnum_fast;// ----------------------------------------------------------------------------//  CLASS : sc_fxval////  Fixed-point value type; arbitrary precision.// ----------------------------------------------------------------------------class sc_fxval{    friend class sc_fxnum;protected:    sc_fxval_observer* observer() const;public:    // internal use only;    sc_fxval( scfx_rep* );    explicit sc_fxval( sc_fxval_observer* = 0 );             sc_fxval( int,		       sc_fxval_observer* = 0 );             sc_fxval( unsigned int,		       sc_fxval_observer* = 0 );             sc_fxval( long,		       sc_fxval_observer* = 0 );             sc_fxval( unsigned long,		       sc_fxval_observer* = 0 );             sc_fxval( double,		       sc_fxval_observer* = 0 );             sc_fxval( const char*,		       sc_fxval_observer* = 0 );             sc_fxval( const sc_fxval&,		       sc_fxval_observer* = 0 );             sc_fxval( const sc_fxval_fast&,		       sc_fxval_observer* = 0 );             sc_fxval( const sc_fxnum&,		       sc_fxval_observer* = 0 );             sc_fxval( const sc_fxnum_fast&,		       sc_fxval_observer* = 0 );#ifndef SC_FX_EXCLUDE_OTHER    explicit sc_fxval( int64,		       sc_fxval_observer* = 0 );    explicit sc_fxval( uint64,		       sc_fxval_observer* = 0 );    explicit sc_fxval( const sc_int_base&,		       sc_fxval_observer* = 0 );    explicit sc_fxval( const sc_uint_base&,		       sc_fxval_observer* = 0 );    explicit sc_fxval( const sc_signed&,		       sc_fxval_observer* = 0 );    explicit sc_fxval( const sc_unsigned&,		       sc_fxval_observer* = 0 );#endif    ~sc_fxval();    // internal use only;    const scfx_rep* get_rep() const;    void            set_rep( scfx_rep* );    // unary operators    const sc_fxval  operator - () const;    const sc_fxval& operator + () const;    // unary functions    friend void neg( sc_fxval&, const sc_fxval& );    // binary operators#define DECL_BIN_OP_T(op,tp)                                                  \    friend const sc_fxval operator op ( const sc_fxval&, tp );                \    friend const sc_fxval operator op ( tp, const sc_fxval& );#ifndef SC_FX_EXCLUDE_OTHER#define DECL_BIN_OP_OTHER(op)                                                 \    DECL_BIN_OP_T(op,int64)                                                   \    DECL_BIN_OP_T(op,uint64)                                                  \    DECL_BIN_OP_T(op,const sc_int_base&)                                      \    DECL_BIN_OP_T(op,const sc_uint_base&)                                     \    DECL_BIN_OP_T(op,const sc_signed&)                                        \    DECL_BIN_OP_T(op,const sc_unsigned&)#else#define DECL_BIN_OP_OTHER(op)#endif#define DECL_BIN_OP(op,dummy)                                                 \    friend const sc_fxval operator op ( const sc_fxval&, const sc_fxval& );   \    DECL_BIN_OP_T(op,int)                                                     \    DECL_BIN_OP_T(op,unsigned int)                                            \    DECL_BIN_OP_T(op,long)                                                    \    DECL_BIN_OP_T(op,unsigned long)                                           \    DECL_BIN_OP_T(op,double)                                                  \    DECL_BIN_OP_T(op,const char*)                                             \    DECL_BIN_OP_T(op,const sc_fxval_fast&)                                    \    DECL_BIN_OP_T(op,const sc_fxnum_fast&)                                    \    DECL_BIN_OP_OTHER(op)    DECL_BIN_OP(*,mult)    DECL_BIN_OP(+,add)    DECL_BIN_OP(-,sub)// declaration below doesn't compile with BCB5 (E2206)//    DECL_BIN_OP(/,div)// previous macro expanded    friend const sc_fxval operator / ( const sc_fxval&, const sc_fxval& );    DECL_BIN_OP_T(/,int)    DECL_BIN_OP_T(/,unsigned int)    DECL_BIN_OP_T(/,long)    DECL_BIN_OP_T(/,unsigned long)    DECL_BIN_OP_T(/,double)    DECL_BIN_OP_T(/,const char*)    DECL_BIN_OP_T(/,const sc_fxval_fast&)    DECL_BIN_OP_T(/,const sc_fxnum_fast&)//    DECL_BIN_OP_OTHER(/)#ifndef SC_FX_EXCLUDE_OTHER    DECL_BIN_OP_T(/,int64)                                                   \    DECL_BIN_OP_T(/,uint64)                                                  \    DECL_BIN_OP_T(/,const sc_int_base&)                                      \    DECL_BIN_OP_T(/,const sc_uint_base&)                                     \    DECL_BIN_OP_T(/,const sc_signed&)                                        \    DECL_BIN_OP_T(/,const sc_unsigned&)#endif#undef DECL_BIN_OP_T#undef DECL_BIN_OP_OTHER#undef DECL_BIN_OP    friend const sc_fxval operator << ( const sc_fxval&, int );    friend const sc_fxval operator >> ( const sc_fxval&, int );    // binary functions#define DECL_BIN_FNC_T(fnc,tp)                                                \    friend void fnc ( sc_fxval&, const sc_fxval&, tp );                       \    friend void fnc ( sc_fxval&, tp, const sc_fxval& );#ifndef SC_FX_EXCLUDE_OTHER#define DECL_BIN_FNC_OTHER(fnc)                                               \    DECL_BIN_FNC_T(fnc,int64)                                                 \    DECL_BIN_FNC_T(fnc,uint64)                                                \    DECL_BIN_FNC_T(fnc,const sc_int_base&)                                    \    DECL_BIN_FNC_T(fnc,const sc_uint_base&)                                   \    DECL_BIN_FNC_T(fnc,const sc_signed&)                                      \    DECL_BIN_FNC_T(fnc,const sc_unsigned&)#else#define DECL_BIN_FNC_OTHER(fnc)#endif#define DECL_BIN_FNC(fnc)                                                     \    friend void fnc ( sc_fxval&, const sc_fxval&, const sc_fxval& );          \    DECL_BIN_FNC_T(fnc,int)                                                   \    DECL_BIN_FNC_T(fnc,unsigned int)                                          \    DECL_BIN_FNC_T(fnc,long)                                                  \    DECL_BIN_FNC_T(fnc,unsigned long)                                         \    DECL_BIN_FNC_T(fnc,double)                                                \    DECL_BIN_FNC_T(fnc,const char*)                                           \    DECL_BIN_FNC_T(fnc,const sc_fxval_fast&)                                  \    DECL_BIN_FNC_T(fnc,const sc_fxnum_fast&)                                  \    DECL_BIN_FNC_OTHER(fnc)    DECL_BIN_FNC(mult)    DECL_BIN_FNC(div)    DECL_BIN_FNC(add)    DECL_BIN_FNC(sub)#undef DECL_BIN_FNC_T#undef DECL_BIN_FNC_OTHER#undef DECL_BIN_FNC    friend void lshift( sc_fxval&, const sc_fxval&, int );    friend void rshift( sc_fxval&, const sc_fxval&, int );    // relational (including equality) operators#define DECL_REL_OP_T(op,tp)                                                  \    friend bool operator op ( const sc_fxval&, tp );                          \    friend bool operator op ( tp, const sc_fxval& );#ifndef SC_FX_EXCLUDE_OTHER#define DECL_REL_OP_OTHER(op)                                                 \    DECL_REL_OP_T(op,int64)                                                   \    DECL_REL_OP_T(op,uint64)                                                  \    DECL_REL_OP_T(op,const sc_int_base&)                                      \    DECL_REL_OP_T(op,const sc_uint_base&)                                     \    DECL_REL_OP_T(op,const sc_signed&)                                        \    DECL_REL_OP_T(op,const sc_unsigned&)#else#define DECL_REL_OP_OTHER(op)#endif#define DECL_REL_OP(op)                                                       \    friend bool operator op ( const sc_fxval&, const sc_fxval& );             \    DECL_REL_OP_T(op,int)                                                     \    DECL_REL_OP_T(op,unsigned int)                                            \    DECL_REL_OP_T(op,long)                                                    \    DECL_REL_OP_T(op,unsigned long)                                           \    DECL_REL_OP_T(op,double)                                                  \    DECL_REL_OP_T(op,const char*)                                             \    DECL_REL_OP_T(op,const sc_fxval_fast&)                                    \    DECL_REL_OP_T(op,const sc_fxnum_fast&)                                    \    DECL_REL_OP_OTHER(op)    DECL_REL_OP(<)    DECL_REL_OP(<=)    DECL_REL_OP(>)    DECL_REL_OP(>=)    DECL_REL_OP(==)    DECL_REL_OP(!=)#undef DECL_REL_OP_T#undef DECL_REL_OP_OTHER#undef DECL_REL_OP    // assignment operators#define DECL_ASN_OP_T(op,tp)                                                  \    sc_fxval& operator op( tp );#ifndef SC_FX_EXCLUDE_OTHER#define DECL_ASN_OP_OTHER(op)                                                 \    DECL_ASN_OP_T(op,int64)                                                   \    DECL_ASN_OP_T(op,uint64)                                                  \    DECL_ASN_OP_T(op,const sc_int_base&)                                      \    DECL_ASN_OP_T(op,const sc_uint_base&)                                     \    DECL_ASN_OP_T(op,const sc_signed&)                                        \    DECL_ASN_OP_T(op,const sc_unsigned&)#else#define DECL_ASN_OP_OTHER(op)#endif#define DECL_ASN_OP(op)                                                       \    DECL_ASN_OP_T(op,int)                                                     \    DECL_ASN_OP_T(op,unsigned int)                                            \    DECL_ASN_OP_T(op,long)                                                    \    DECL_ASN_OP_T(op,unsigned long)                                           \    DECL_ASN_OP_T(op,double)                                                  \    DECL_ASN_OP_T(op,const char*)                                             \    DECL_ASN_OP_T(op,const sc_fxval&)                                         \    DECL_ASN_OP_T(op,const sc_fxval_fast&)                                    \    DECL_ASN_OP_T(op,const sc_fxnum&)                                         \    DECL_ASN_OP_T(op,const sc_fxnum_fast&)                                    \    DECL_ASN_OP_OTHER(op)    DECL_ASN_OP(=)    DECL_ASN_OP(*=)    DECL_ASN_OP(/=)    DECL_ASN_OP(+=)    DECL_ASN_OP(-=)    DECL_ASN_OP_T(<<=,int)    DECL_ASN_OP_T(>>=,int)#undef DECL_ASN_OP_T#undef DECL_ASN_OP_OTHER#undef DECL_ASN_OP    // auto-increment and auto-decrement    const sc_fxval operator ++ ( int );    const sc_fxval operator -- ( int );    sc_fxval& operator ++ ();    sc_fxval& operator -- ();    // implicit conversion    operator double() const;            // necessary evil!    // explicit conversion to primitive types    short          to_short() const;    unsigned short to_ushort() const;    int            to_int() const;    unsigned int   to_uint() const;    long           to_long() const;    unsigned long  to_ulong() const;    int64          to_int64() const;    uint64         to_uint64() const;    float          to_float() const;    double         to_double() const;    // explicit conversion to character string    const std::string to_string() const;    const std::string to_string( sc_numrep ) const;    const std::string to_string( sc_numrep, bool ) const;    const std::string to_string( sc_fmt ) const;    const std::string to_string( sc_numrep, sc_fmt ) const;    const std::string to_string( sc_numrep, bool, sc_fmt ) const;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -