112853Sgabeblack@google.com/***************************************************************************** 212853Sgabeblack@google.com 312853Sgabeblack@google.com Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 412853Sgabeblack@google.com more contributor license agreements. See the NOTICE file distributed 512853Sgabeblack@google.com with this work for additional information regarding copyright ownership. 612853Sgabeblack@google.com Accellera licenses this file to you under the Apache License, Version 2.0 712853Sgabeblack@google.com (the "License"); you may not use this file except in compliance with the 812853Sgabeblack@google.com License. You may obtain a copy of the License at 912853Sgabeblack@google.com 1012853Sgabeblack@google.com http://www.apache.org/licenses/LICENSE-2.0 1112853Sgabeblack@google.com 1212853Sgabeblack@google.com Unless required by applicable law or agreed to in writing, software 1312853Sgabeblack@google.com distributed under the License is distributed on an "AS IS" BASIS, 1412853Sgabeblack@google.com WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 1512853Sgabeblack@google.com implied. See the License for the specific language governing 1612853Sgabeblack@google.com permissions and limitations under the License. 1712853Sgabeblack@google.com 1812853Sgabeblack@google.com *****************************************************************************/ 1912853Sgabeblack@google.com 2012853Sgabeblack@google.com/***************************************************************************** 2112853Sgabeblack@google.com 2212853Sgabeblack@google.com sc_fxnum.h - 2312853Sgabeblack@google.com 2412853Sgabeblack@google.com Original Author: Martin Janssen, Synopsys, Inc. 2512853Sgabeblack@google.com 2612853Sgabeblack@google.com *****************************************************************************/ 2712853Sgabeblack@google.com 2812853Sgabeblack@google.com/***************************************************************************** 2912853Sgabeblack@google.com 3012853Sgabeblack@google.com MODIFICATION LOG - modifiers, enter your name, affiliation, date and 3112853Sgabeblack@google.com changes you are making here. 3212853Sgabeblack@google.com 3312853Sgabeblack@google.com Name, Affiliation, Date: 3412853Sgabeblack@google.com Description of Modification: 3512853Sgabeblack@google.com 3612853Sgabeblack@google.com *****************************************************************************/ 3712853Sgabeblack@google.com 3812853Sgabeblack@google.com// $Log: sc_fxnum.h,v $ 3912853Sgabeblack@google.com// Revision 1.5 2011/08/29 18:04:32 acg 4012853Sgabeblack@google.com// Philipp A. Hartmann: miscellaneous clean ups. 4112853Sgabeblack@google.com// 4212853Sgabeblack@google.com// Revision 1.4 2011/08/24 22:05:43 acg 4312853Sgabeblack@google.com// Torsten Maehne: initialization changes to remove warnings. 4412853Sgabeblack@google.com// 4512853Sgabeblack@google.com// Revision 1.3 2011/01/19 18:57:40 acg 4612853Sgabeblack@google.com// Andy Goodrich: changes for IEEE_1666_2011. 4712853Sgabeblack@google.com// 4812853Sgabeblack@google.com// Revision 1.2 2009/03/09 17:26:46 acg 4912853Sgabeblack@google.com// Andy Goodrich: removed ; from namespace { } 5012853Sgabeblack@google.com// 5112853Sgabeblack@google.com// Revision 1.1.1.1 2006/12/15 20:20:04 acg 5212853Sgabeblack@google.com// SystemC 2.3 5312853Sgabeblack@google.com// 5412853Sgabeblack@google.com// Revision 1.3 2006/01/13 18:53:58 acg 5512853Sgabeblack@google.com// Andy Goodrich: added $Log command so that CVS comments are reproduced in 5612853Sgabeblack@google.com// the source. 5712853Sgabeblack@google.com// 5812853Sgabeblack@google.com 5912853Sgabeblack@google.com#ifndef __SYSTEMC_EXT_DT_FX_SC_FXNUM_HH__ 6012853Sgabeblack@google.com#define __SYSTEMC_EXT_DT_FX_SC_FXNUM_HH__ 6112853Sgabeblack@google.com 6212853Sgabeblack@google.com#include <iostream> 6312853Sgabeblack@google.com 6412853Sgabeblack@google.com#include "../bit/sc_lv_base.hh" 6513325Sgabeblack@google.com#include "messages.hh" 6612853Sgabeblack@google.com#include "sc_fxnum_observer.hh" 6712853Sgabeblack@google.com#include "sc_fxval.hh" 6812853Sgabeblack@google.com#include "scfx_params.hh" 6912853Sgabeblack@google.com 7013245Sgabeblack@google.comnamespace sc_gem5 7112853Sgabeblack@google.com{ 7212853Sgabeblack@google.com 7313245Sgabeblack@google.comtemplate <typename T, typename B> 7413245Sgabeblack@google.comclass TraceValFxnumBase; 7512853Sgabeblack@google.com 7612853Sgabeblack@google.com} // namespace sc_core 7712853Sgabeblack@google.com 7812853Sgabeblack@google.com 7912853Sgabeblack@google.comnamespace sc_dt 8012853Sgabeblack@google.com{ 8112853Sgabeblack@google.com 8212853Sgabeblack@google.com// classes defined in this module 8312853Sgabeblack@google.comclass sc_fxnum_bitref; 8412853Sgabeblack@google.comclass sc_fxnum_fast_bitref; 8512853Sgabeblack@google.comclass sc_fxnum_subref; 8612853Sgabeblack@google.comclass sc_fxnum_fast_subref; 8712853Sgabeblack@google.comclass sc_fxnum; 8812853Sgabeblack@google.comclass sc_fxnum_fast; 8912853Sgabeblack@google.com 9012853Sgabeblack@google.com 9112853Sgabeblack@google.com// ---------------------------------------------------------------------------- 9212853Sgabeblack@google.com// CLASS : sc_fxnum_bitref 9312853Sgabeblack@google.com// 9412853Sgabeblack@google.com// Proxy class for bit-selection in class sc_fxnum, behaves like sc_bit. 9512853Sgabeblack@google.com// ---------------------------------------------------------------------------- 9612853Sgabeblack@google.com 9712853Sgabeblack@google.comclass sc_fxnum_bitref 9812853Sgabeblack@google.com{ 9912853Sgabeblack@google.com friend class sc_fxnum; 10012853Sgabeblack@google.com friend class sc_fxnum_fast_bitref; 10112853Sgabeblack@google.com 10212853Sgabeblack@google.com bool get() const; 10312853Sgabeblack@google.com void set(bool); 10412853Sgabeblack@google.com 10512853Sgabeblack@google.com // constructor 10612853Sgabeblack@google.com sc_fxnum_bitref(sc_fxnum &, int); 10712853Sgabeblack@google.com 10812853Sgabeblack@google.com public: 10912853Sgabeblack@google.com // copy constructor 11012853Sgabeblack@google.com sc_fxnum_bitref(const sc_fxnum_bitref &); 11112853Sgabeblack@google.com 11212853Sgabeblack@google.com // assignment operators 11312853Sgabeblack@google.com#define DECL_ASN_OP_T(op, tp) \ 11412853Sgabeblack@google.com sc_fxnum_bitref &operator op (tp); 11512853Sgabeblack@google.com 11612853Sgabeblack@google.com#define DECL_ASN_OP(op) \ 11712853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_fxnum_bitref &) \ 11812853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_fxnum_fast_bitref &) \ 11912853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_bit &) \ 12012853Sgabeblack@google.com DECL_ASN_OP_T(op, bool) 12112853Sgabeblack@google.com 12212853Sgabeblack@google.com DECL_ASN_OP(=) 12312853Sgabeblack@google.com 12412853Sgabeblack@google.com DECL_ASN_OP(&=) 12512853Sgabeblack@google.com DECL_ASN_OP(|=) 12612853Sgabeblack@google.com DECL_ASN_OP(^=) 12712853Sgabeblack@google.com 12812853Sgabeblack@google.com#undef DECL_ASN_OP_T 12912853Sgabeblack@google.com#undef DECL_ASN_OP 13012853Sgabeblack@google.com 13112853Sgabeblack@google.com // implicit conversion 13212853Sgabeblack@google.com operator bool() const; 13312853Sgabeblack@google.com 13412853Sgabeblack@google.com // print or dump content 13512853Sgabeblack@google.com void print(::std::ostream & =::std::cout) const; 13612853Sgabeblack@google.com void scan(::std::istream & =::std::cin); 13712853Sgabeblack@google.com void dump(::std::ostream & =::std::cout) const; 13812853Sgabeblack@google.com 13912853Sgabeblack@google.com private: 14012853Sgabeblack@google.com sc_fxnum &m_num; 14112853Sgabeblack@google.com int m_idx; 14212853Sgabeblack@google.com 14312853Sgabeblack@google.com private: 14412853Sgabeblack@google.com // disabled 14512853Sgabeblack@google.com sc_fxnum_bitref(); 14612853Sgabeblack@google.com}; 14712853Sgabeblack@google.com 14812853Sgabeblack@google.com 14912853Sgabeblack@google.com// ---------------------------------------------------------------------------- 15012853Sgabeblack@google.com// CLASS : sc_fxnum_fast_bitref 15112853Sgabeblack@google.com// 15212853Sgabeblack@google.com// Proxy class for bit-selection in class sc_fxnum_fast, behaves like sc_bit. 15312853Sgabeblack@google.com// ---------------------------------------------------------------------------- 15412853Sgabeblack@google.com 15512853Sgabeblack@google.comclass sc_fxnum_fast_bitref 15612853Sgabeblack@google.com{ 15712853Sgabeblack@google.com friend class sc_fxnum_fast; 15812853Sgabeblack@google.com friend class sc_fxnum_bitref; 15912853Sgabeblack@google.com 16012853Sgabeblack@google.com bool get() const; 16112853Sgabeblack@google.com void set(bool); 16212853Sgabeblack@google.com 16312853Sgabeblack@google.com // constructor 16412853Sgabeblack@google.com sc_fxnum_fast_bitref(sc_fxnum_fast &, int); 16512853Sgabeblack@google.com 16612853Sgabeblack@google.com public: 16712853Sgabeblack@google.com // copy constructor 16812853Sgabeblack@google.com sc_fxnum_fast_bitref(const sc_fxnum_fast_bitref &); 16912853Sgabeblack@google.com 17012853Sgabeblack@google.com // assignment operators 17112853Sgabeblack@google.com#define DECL_ASN_OP_T(op, tp) sc_fxnum_fast_bitref &operator op (tp); 17212853Sgabeblack@google.com 17312853Sgabeblack@google.com#define DECL_ASN_OP(op) \ 17412853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_fxnum_bitref &) \ 17512853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_fxnum_fast_bitref &) \ 17612853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_bit &) \ 17712853Sgabeblack@google.com DECL_ASN_OP_T(op, bool) 17812853Sgabeblack@google.com 17912853Sgabeblack@google.com DECL_ASN_OP(=) 18012853Sgabeblack@google.com 18112853Sgabeblack@google.com DECL_ASN_OP(&=) 18212853Sgabeblack@google.com DECL_ASN_OP(|=) 18312853Sgabeblack@google.com DECL_ASN_OP(^=) 18412853Sgabeblack@google.com 18512853Sgabeblack@google.com#undef DECL_ASN_OP_T 18612853Sgabeblack@google.com#undef DECL_ASN_OP 18712853Sgabeblack@google.com 18812853Sgabeblack@google.com // implicit conversion 18912853Sgabeblack@google.com operator bool() const; 19012853Sgabeblack@google.com 19112853Sgabeblack@google.com // print or dump content 19212853Sgabeblack@google.com void print(::std::ostream & =::std::cout) const; 19312853Sgabeblack@google.com void scan(::std::istream & =::std::cin); 19412853Sgabeblack@google.com void dump(::std::ostream & =::std::cout) const; 19512853Sgabeblack@google.com 19612853Sgabeblack@google.com private: 19712853Sgabeblack@google.com sc_fxnum_fast &m_num; 19812853Sgabeblack@google.com int m_idx; 19912853Sgabeblack@google.com 20012853Sgabeblack@google.com private: 20112853Sgabeblack@google.com // Disabled 20212853Sgabeblack@google.com sc_fxnum_fast_bitref(); 20312853Sgabeblack@google.com}; 20412853Sgabeblack@google.com 20512853Sgabeblack@google.com 20612853Sgabeblack@google.com// ---------------------------------------------------------------------------- 20712853Sgabeblack@google.com// CLASS : sc_fxnum_subref 20812853Sgabeblack@google.com// 20912853Sgabeblack@google.com// Proxy class for part-selection in class sc_fxnum, 21012853Sgabeblack@google.com// behaves like sc_bv_base. 21112853Sgabeblack@google.com// ---------------------------------------------------------------------------- 21212853Sgabeblack@google.com 21312853Sgabeblack@google.comclass sc_fxnum_subref 21412853Sgabeblack@google.com{ 21512853Sgabeblack@google.com friend class sc_fxnum; 21612853Sgabeblack@google.com friend class sc_fxnum_fast_subref; 21712853Sgabeblack@google.com 21812853Sgabeblack@google.com bool get() const; 21912853Sgabeblack@google.com bool set(); 22012853Sgabeblack@google.com 22112853Sgabeblack@google.com // constructor 22212853Sgabeblack@google.com sc_fxnum_subref(sc_fxnum &, int, int); 22312853Sgabeblack@google.com 22412853Sgabeblack@google.com public: 22512853Sgabeblack@google.com // copy constructor 22612853Sgabeblack@google.com sc_fxnum_subref(const sc_fxnum_subref &); 22712853Sgabeblack@google.com 22812853Sgabeblack@google.com // destructor 22912853Sgabeblack@google.com ~sc_fxnum_subref(); 23012853Sgabeblack@google.com 23112853Sgabeblack@google.com // assignment operators 23212853Sgabeblack@google.com#define DECL_ASN_OP_T(tp) \ 23312853Sgabeblack@google.com sc_fxnum_subref &operator = (tp); 23412853Sgabeblack@google.com 23512853Sgabeblack@google.com DECL_ASN_OP_T(const sc_fxnum_subref &) 23612853Sgabeblack@google.com DECL_ASN_OP_T(const sc_fxnum_fast_subref &) 23712853Sgabeblack@google.com DECL_ASN_OP_T(const sc_bv_base &) 23812853Sgabeblack@google.com DECL_ASN_OP_T(const sc_lv_base &) 23912853Sgabeblack@google.com DECL_ASN_OP_T(const char *) 24012853Sgabeblack@google.com DECL_ASN_OP_T(const bool *) 24112853Sgabeblack@google.com DECL_ASN_OP_T(const sc_signed &) 24212853Sgabeblack@google.com DECL_ASN_OP_T(const sc_unsigned &) 24312853Sgabeblack@google.com DECL_ASN_OP_T(const sc_int_base &) 24412853Sgabeblack@google.com DECL_ASN_OP_T(const sc_uint_base &) 24512853Sgabeblack@google.com DECL_ASN_OP_T(int64) 24612853Sgabeblack@google.com DECL_ASN_OP_T(uint64) 24712853Sgabeblack@google.com DECL_ASN_OP_T(int) 24812853Sgabeblack@google.com DECL_ASN_OP_T(unsigned int) 24912853Sgabeblack@google.com DECL_ASN_OP_T(long) 25012853Sgabeblack@google.com DECL_ASN_OP_T(unsigned long) 25112853Sgabeblack@google.com DECL_ASN_OP_T(char) 25212853Sgabeblack@google.com 25312853Sgabeblack@google.com#undef DECL_ASN_OP_T 25412853Sgabeblack@google.com 25512853Sgabeblack@google.com#define DECL_ASN_OP_T_A(op, tp) \ 25612853Sgabeblack@google.com sc_fxnum_subref &operator op ## = (tp); 25712853Sgabeblack@google.com 25812853Sgabeblack@google.com#define DECL_ASN_OP_A(op) \ 25912853Sgabeblack@google.com DECL_ASN_OP_T_A(op, const sc_fxnum_subref &) \ 26012853Sgabeblack@google.com DECL_ASN_OP_T_A(op, const sc_fxnum_fast_subref &) \ 26112853Sgabeblack@google.com DECL_ASN_OP_T_A(op, const sc_bv_base &) \ 26212853Sgabeblack@google.com DECL_ASN_OP_T_A(op, const sc_lv_base &) 26312853Sgabeblack@google.com 26412853Sgabeblack@google.com DECL_ASN_OP_A( &) 26512853Sgabeblack@google.com DECL_ASN_OP_A(|) 26612853Sgabeblack@google.com DECL_ASN_OP_A(^) 26712853Sgabeblack@google.com 26812853Sgabeblack@google.com#undef DECL_ASN_OP_T_A 26912853Sgabeblack@google.com#undef DECL_ASN_OP_A 27012853Sgabeblack@google.com 27112853Sgabeblack@google.com // relational operators 27212853Sgabeblack@google.com#define DECL_REL_OP_T(op, tp) \ 27312853Sgabeblack@google.com friend bool operator op (const sc_fxnum_subref &, tp); \ 27412853Sgabeblack@google.com friend bool operator op (tp, const sc_fxnum_subref &); 27512853Sgabeblack@google.com 27612853Sgabeblack@google.com#define DECL_REL_OP(op) \ 27712853Sgabeblack@google.com friend bool operator op (const sc_fxnum_subref &, \ 27812853Sgabeblack@google.com const sc_fxnum_subref &); \ 27912853Sgabeblack@google.com friend bool operator op (const sc_fxnum_subref &, \ 28012853Sgabeblack@google.com const sc_fxnum_fast_subref &); \ 28112853Sgabeblack@google.com DECL_REL_OP_T(op, const sc_bv_base &) \ 28212853Sgabeblack@google.com DECL_REL_OP_T(op, const sc_lv_base &) \ 28312853Sgabeblack@google.com DECL_REL_OP_T(op, const char *) \ 28412853Sgabeblack@google.com DECL_REL_OP_T(op, const bool *) \ 28512853Sgabeblack@google.com DECL_REL_OP_T(op, const sc_signed &) \ 28612853Sgabeblack@google.com DECL_REL_OP_T(op, const sc_unsigned &) \ 28712853Sgabeblack@google.com DECL_REL_OP_T(op, int) \ 28812853Sgabeblack@google.com DECL_REL_OP_T(op, unsigned int) \ 28912853Sgabeblack@google.com DECL_REL_OP_T(op, long) \ 29012853Sgabeblack@google.com DECL_REL_OP_T(op, unsigned long) 29112853Sgabeblack@google.com 29212853Sgabeblack@google.com DECL_REL_OP(==) 29312853Sgabeblack@google.com DECL_REL_OP(!=) 29412853Sgabeblack@google.com 29512853Sgabeblack@google.com#undef DECL_REL_OP_T 29612853Sgabeblack@google.com#undef DECL_REL_OP 29712853Sgabeblack@google.com 29812853Sgabeblack@google.com // reduce functions 29912853Sgabeblack@google.com bool and_reduce() const; 30012853Sgabeblack@google.com bool nand_reduce() const; 30112853Sgabeblack@google.com bool or_reduce() const; 30212853Sgabeblack@google.com bool nor_reduce() const; 30312853Sgabeblack@google.com bool xor_reduce() const; 30412853Sgabeblack@google.com bool xnor_reduce() const; 30512853Sgabeblack@google.com 30612853Sgabeblack@google.com // query parameter 30712853Sgabeblack@google.com int length() const; 30812853Sgabeblack@google.com 30912853Sgabeblack@google.com // explicit conversions 31012853Sgabeblack@google.com int to_int() const; 31112853Sgabeblack@google.com unsigned int to_uint() const; 31212853Sgabeblack@google.com long to_long() const; 31312853Sgabeblack@google.com unsigned long to_ulong() const; 31412853Sgabeblack@google.com int64 to_int64() const; 31512853Sgabeblack@google.com uint64 to_uint64() const; 31612853Sgabeblack@google.com 31712853Sgabeblack@google.com const std::string to_string() const; 31812853Sgabeblack@google.com const std::string to_string(sc_numrep) const; 31912853Sgabeblack@google.com const std::string to_string(sc_numrep, bool) const; 32012853Sgabeblack@google.com 32112853Sgabeblack@google.com // implicit conversion 32212853Sgabeblack@google.com operator sc_bv_base() const; 32312853Sgabeblack@google.com 32412853Sgabeblack@google.com // print or dump content 32512853Sgabeblack@google.com void print(::std::ostream & =::std::cout) const; 32612853Sgabeblack@google.com void scan(::std::istream & =::std::cin); 32712853Sgabeblack@google.com void dump(::std::ostream & =::std::cout) const; 32812853Sgabeblack@google.com 32912853Sgabeblack@google.com private: 33012853Sgabeblack@google.com sc_fxnum &m_num; 33112853Sgabeblack@google.com int m_from; 33212853Sgabeblack@google.com int m_to; 33312853Sgabeblack@google.com 33412853Sgabeblack@google.com sc_bv_base &m_bv; 33512853Sgabeblack@google.com 33612853Sgabeblack@google.com private: 33712853Sgabeblack@google.com // Disabled 33812853Sgabeblack@google.com sc_fxnum_subref(); 33912853Sgabeblack@google.com}; 34012853Sgabeblack@google.com 34112853Sgabeblack@google.com 34212853Sgabeblack@google.com// ---------------------------------------------------------------------------- 34312853Sgabeblack@google.com// CLASS : sc_fxnum_fast_subref 34412853Sgabeblack@google.com// 34512853Sgabeblack@google.com// Proxy class for part-selection in class sc_fxnum_fast, 34612853Sgabeblack@google.com// behaves like sc_bv_base. 34712853Sgabeblack@google.com// ---------------------------------------------------------------------------- 34812853Sgabeblack@google.com 34912853Sgabeblack@google.comclass sc_fxnum_fast_subref 35012853Sgabeblack@google.com{ 35112853Sgabeblack@google.com friend class sc_fxnum_fast; 35212853Sgabeblack@google.com friend class sc_fxnum_subref; 35312853Sgabeblack@google.com 35412853Sgabeblack@google.com bool get() const; 35512853Sgabeblack@google.com bool set(); 35612853Sgabeblack@google.com 35712853Sgabeblack@google.com // constructor 35812853Sgabeblack@google.com sc_fxnum_fast_subref(sc_fxnum_fast &, int, int); 35912853Sgabeblack@google.com 36012853Sgabeblack@google.com public: 36112853Sgabeblack@google.com // copy constructor 36212853Sgabeblack@google.com sc_fxnum_fast_subref(const sc_fxnum_fast_subref &); 36312853Sgabeblack@google.com 36412853Sgabeblack@google.com // destructor 36512853Sgabeblack@google.com ~sc_fxnum_fast_subref(); 36612853Sgabeblack@google.com 36712853Sgabeblack@google.com // assignment operators 36812853Sgabeblack@google.com#define DECL_ASN_OP_T(tp) \ 36912853Sgabeblack@google.com sc_fxnum_fast_subref &operator = (tp); 37012853Sgabeblack@google.com 37112853Sgabeblack@google.com DECL_ASN_OP_T(const sc_fxnum_subref &) 37212853Sgabeblack@google.com DECL_ASN_OP_T(const sc_fxnum_fast_subref &) 37312853Sgabeblack@google.com DECL_ASN_OP_T(const sc_bv_base &) 37412853Sgabeblack@google.com DECL_ASN_OP_T(const sc_lv_base &) 37512853Sgabeblack@google.com DECL_ASN_OP_T(const char *) 37612853Sgabeblack@google.com DECL_ASN_OP_T(const bool *) 37712853Sgabeblack@google.com DECL_ASN_OP_T(const sc_signed &) 37812853Sgabeblack@google.com DECL_ASN_OP_T(const sc_unsigned &) 37912853Sgabeblack@google.com DECL_ASN_OP_T(const sc_int_base &) 38012853Sgabeblack@google.com DECL_ASN_OP_T(const sc_uint_base &) 38112853Sgabeblack@google.com DECL_ASN_OP_T(int64) 38212853Sgabeblack@google.com DECL_ASN_OP_T(uint64) 38312853Sgabeblack@google.com DECL_ASN_OP_T(int) 38412853Sgabeblack@google.com DECL_ASN_OP_T(unsigned int) 38512853Sgabeblack@google.com DECL_ASN_OP_T(long) 38612853Sgabeblack@google.com DECL_ASN_OP_T(unsigned long) 38712853Sgabeblack@google.com DECL_ASN_OP_T(char) 38812853Sgabeblack@google.com 38912853Sgabeblack@google.com#undef DECL_ASN_OP_T 39012853Sgabeblack@google.com 39112853Sgabeblack@google.com#define DECL_ASN_OP_T_A(op, tp) sc_fxnum_fast_subref &operator op ## = (tp); 39212853Sgabeblack@google.com 39312853Sgabeblack@google.com#define DECL_ASN_OP_A(op) \ 39412853Sgabeblack@google.com DECL_ASN_OP_T_A(op, const sc_fxnum_subref &) \ 39512853Sgabeblack@google.com DECL_ASN_OP_T_A(op, const sc_fxnum_fast_subref &) \ 39612853Sgabeblack@google.com DECL_ASN_OP_T_A(op, const sc_bv_base &) \ 39712853Sgabeblack@google.com DECL_ASN_OP_T_A(op, const sc_lv_base &) 39812853Sgabeblack@google.com 39912853Sgabeblack@google.com DECL_ASN_OP_A(&) 40012853Sgabeblack@google.com DECL_ASN_OP_A(|) 40112853Sgabeblack@google.com DECL_ASN_OP_A(^) 40212853Sgabeblack@google.com 40312853Sgabeblack@google.com#undef DECL_ASN_OP_T_A 40412853Sgabeblack@google.com#undef DECL_ASN_OP_A 40512853Sgabeblack@google.com 40612853Sgabeblack@google.com // relational operators 40712853Sgabeblack@google.com#define DECL_REL_OP_T(op, tp) \ 40812853Sgabeblack@google.com friend bool operator op (const sc_fxnum_fast_subref &, tp); \ 40912853Sgabeblack@google.com friend bool operator op (tp, const sc_fxnum_fast_subref &); 41012853Sgabeblack@google.com 41112853Sgabeblack@google.com#define DECL_REL_OP(op) \ 41212853Sgabeblack@google.com friend bool operator op (const sc_fxnum_fast_subref &, \ 41312853Sgabeblack@google.com const sc_fxnum_fast_subref &); \ 41412853Sgabeblack@google.com friend bool operator op (const sc_fxnum_fast_subref &, \ 41512853Sgabeblack@google.com const sc_fxnum_subref &); \ 41612853Sgabeblack@google.com DECL_REL_OP_T(op, const sc_bv_base &) \ 41712853Sgabeblack@google.com DECL_REL_OP_T(op, const sc_lv_base &) \ 41812853Sgabeblack@google.com DECL_REL_OP_T(op, const char *) \ 41912853Sgabeblack@google.com DECL_REL_OP_T(op, const bool *) \ 42012853Sgabeblack@google.com DECL_REL_OP_T(op, const sc_signed &) \ 42112853Sgabeblack@google.com DECL_REL_OP_T(op, const sc_unsigned &) \ 42212853Sgabeblack@google.com DECL_REL_OP_T(op, int) \ 42312853Sgabeblack@google.com DECL_REL_OP_T(op, unsigned int) \ 42412853Sgabeblack@google.com DECL_REL_OP_T(op, long) \ 42512853Sgabeblack@google.com DECL_REL_OP_T(op, unsigned long) 42612853Sgabeblack@google.com 42712853Sgabeblack@google.com DECL_REL_OP(==) 42812853Sgabeblack@google.com DECL_REL_OP(!=) 42912853Sgabeblack@google.com 43012853Sgabeblack@google.com#undef DECL_REL_OP_T 43112853Sgabeblack@google.com#undef DECL_REL_OP 43212853Sgabeblack@google.com 43312853Sgabeblack@google.com // reduce functions 43412853Sgabeblack@google.com bool and_reduce() const; 43512853Sgabeblack@google.com bool nand_reduce() const; 43612853Sgabeblack@google.com bool or_reduce() const; 43712853Sgabeblack@google.com bool nor_reduce() const; 43812853Sgabeblack@google.com bool xor_reduce() const; 43912853Sgabeblack@google.com bool xnor_reduce() const; 44012853Sgabeblack@google.com 44112853Sgabeblack@google.com // query parameter 44212853Sgabeblack@google.com int length() const; 44312853Sgabeblack@google.com 44412853Sgabeblack@google.com // explicit conversions 44512853Sgabeblack@google.com int to_int() const; 44612853Sgabeblack@google.com unsigned int to_uint() const; 44712853Sgabeblack@google.com long to_long() const; 44812853Sgabeblack@google.com unsigned long to_ulong() const; 44912853Sgabeblack@google.com int64 to_int64() const; 45012853Sgabeblack@google.com uint64 to_uint64() const; 45112853Sgabeblack@google.com 45212853Sgabeblack@google.com const std::string to_string() const; 45312853Sgabeblack@google.com const std::string to_string(sc_numrep) const; 45412853Sgabeblack@google.com const std::string to_string(sc_numrep, bool) const; 45512853Sgabeblack@google.com 45612853Sgabeblack@google.com // implicit conversion 45712853Sgabeblack@google.com operator sc_bv_base() const; 45812853Sgabeblack@google.com 45912853Sgabeblack@google.com // print or dump content 46012853Sgabeblack@google.com void print(::std::ostream & =::std::cout) const; 46112853Sgabeblack@google.com void scan(::std::istream & =::std::cin); 46212853Sgabeblack@google.com void dump(::std::ostream & =::std::cout) const; 46312853Sgabeblack@google.com 46412853Sgabeblack@google.com private: 46512853Sgabeblack@google.com sc_fxnum_fast &m_num; 46612853Sgabeblack@google.com int m_from; 46712853Sgabeblack@google.com int m_to; 46812853Sgabeblack@google.com 46912853Sgabeblack@google.com sc_bv_base &m_bv; 47012853Sgabeblack@google.com 47112853Sgabeblack@google.com private: 47212853Sgabeblack@google.com // Disabled 47312853Sgabeblack@google.com sc_fxnum_fast_subref(); 47412853Sgabeblack@google.com}; 47512853Sgabeblack@google.com 47612853Sgabeblack@google.com 47712853Sgabeblack@google.com// ---------------------------------------------------------------------------- 47812853Sgabeblack@google.com// CLASS : sc_fxnum 47912853Sgabeblack@google.com// 48012853Sgabeblack@google.com// Base class for the fixed-point types; arbitrary precision. 48112853Sgabeblack@google.com// ---------------------------------------------------------------------------- 48212853Sgabeblack@google.com 48312853Sgabeblack@google.comclass sc_fxnum 48412853Sgabeblack@google.com{ 48512853Sgabeblack@google.com friend class sc_fxval; 48612853Sgabeblack@google.com 48712853Sgabeblack@google.com friend class sc_fxnum_bitref; 48812853Sgabeblack@google.com friend class sc_fxnum_subref; 48912853Sgabeblack@google.com friend class sc_fxnum_fast_bitref; 49012853Sgabeblack@google.com friend class sc_fxnum_fast_subref; 49112853Sgabeblack@google.com 49213245Sgabeblack@google.com template <typename T, typename B> 49313245Sgabeblack@google.com friend class sc_gem5::TraceValFxnumBase; 49412853Sgabeblack@google.com 49512853Sgabeblack@google.com protected: 49612853Sgabeblack@google.com sc_fxnum_observer *observer() const; 49712853Sgabeblack@google.com 49812853Sgabeblack@google.com void cast(); 49912853Sgabeblack@google.com 50012853Sgabeblack@google.com // constructors 50112853Sgabeblack@google.com sc_fxnum(const sc_fxtype_params &, sc_enc, const sc_fxcast_switch &, 50212853Sgabeblack@google.com sc_fxnum_observer *); 50312853Sgabeblack@google.com 50412853Sgabeblack@google.com#define DECL_CTOR_T(tp) \ 50512853Sgabeblack@google.com sc_fxnum(tp, const sc_fxtype_params &, sc_enc, const sc_fxcast_switch &, \ 50612853Sgabeblack@google.com sc_fxnum_observer *); 50712853Sgabeblack@google.com 50812853Sgabeblack@google.com DECL_CTOR_T(int) 50912853Sgabeblack@google.com DECL_CTOR_T(unsigned int) 51012853Sgabeblack@google.com DECL_CTOR_T(long) 51112853Sgabeblack@google.com DECL_CTOR_T(unsigned long) 51212853Sgabeblack@google.com DECL_CTOR_T(float) 51312853Sgabeblack@google.com DECL_CTOR_T(double) 51412853Sgabeblack@google.com DECL_CTOR_T(const char *) 51512853Sgabeblack@google.com DECL_CTOR_T(const sc_fxval &) 51612853Sgabeblack@google.com DECL_CTOR_T(const sc_fxval_fast &) 51712853Sgabeblack@google.com DECL_CTOR_T(const sc_fxnum &) 51812853Sgabeblack@google.com DECL_CTOR_T(const sc_fxnum_fast &) 51912853Sgabeblack@google.com 52012853Sgabeblack@google.com DECL_CTOR_T(int64) 52112853Sgabeblack@google.com DECL_CTOR_T(uint64) 52212853Sgabeblack@google.com DECL_CTOR_T(const sc_int_base &) 52312853Sgabeblack@google.com DECL_CTOR_T(const sc_uint_base &) 52412853Sgabeblack@google.com DECL_CTOR_T(const sc_signed &) 52512853Sgabeblack@google.com DECL_CTOR_T(const sc_unsigned &) 52612853Sgabeblack@google.com 52712853Sgabeblack@google.com#undef DECL_CTOR_T 52812853Sgabeblack@google.com 52912853Sgabeblack@google.com ~sc_fxnum(); 53012853Sgabeblack@google.com 53112853Sgabeblack@google.com // internal use only; 53212853Sgabeblack@google.com const scfx_rep *get_rep() const; 53312853Sgabeblack@google.com 53412853Sgabeblack@google.com public: 53512853Sgabeblack@google.com // unary operators 53612853Sgabeblack@google.com const sc_fxval operator - () const; 53712853Sgabeblack@google.com const sc_fxval operator + () const; 53812853Sgabeblack@google.com 53912853Sgabeblack@google.com // unary functions 54012853Sgabeblack@google.com friend void neg(sc_fxval &, const sc_fxnum &); 54112853Sgabeblack@google.com friend void neg(sc_fxnum &, const sc_fxnum &); 54212853Sgabeblack@google.com 54312853Sgabeblack@google.com // binary operators 54412853Sgabeblack@google.com#define DECL_BIN_OP_T(op, tp) \ 54512853Sgabeblack@google.com friend const sc_fxval operator op (const sc_fxnum &, tp); \ 54612853Sgabeblack@google.com friend const sc_fxval operator op (tp, const sc_fxnum &); 54712853Sgabeblack@google.com 54812853Sgabeblack@google.com#define DECL_BIN_OP_OTHER(op) \ 54912853Sgabeblack@google.com DECL_BIN_OP_T(op, int64) \ 55012853Sgabeblack@google.com DECL_BIN_OP_T(op, uint64) \ 55112853Sgabeblack@google.com DECL_BIN_OP_T(op, const sc_int_base &) \ 55212853Sgabeblack@google.com DECL_BIN_OP_T(op, const sc_uint_base &) \ 55312853Sgabeblack@google.com DECL_BIN_OP_T(op, const sc_signed &) \ 55412853Sgabeblack@google.com DECL_BIN_OP_T(op, const sc_unsigned &) 55512853Sgabeblack@google.com 55612853Sgabeblack@google.com#define DECL_BIN_OP(op, dummy) \ 55712853Sgabeblack@google.com friend const sc_fxval operator op (const sc_fxnum &, const sc_fxnum &); \ 55812853Sgabeblack@google.com DECL_BIN_OP_T(op, int) \ 55912853Sgabeblack@google.com DECL_BIN_OP_T(op, unsigned int) \ 56012853Sgabeblack@google.com DECL_BIN_OP_T(op, long) \ 56112853Sgabeblack@google.com DECL_BIN_OP_T(op, unsigned long) \ 56212853Sgabeblack@google.com DECL_BIN_OP_T(op, float) \ 56312853Sgabeblack@google.com DECL_BIN_OP_T(op, double) \ 56412853Sgabeblack@google.com DECL_BIN_OP_T(op, const char *) \ 56512853Sgabeblack@google.com DECL_BIN_OP_T(op, const sc_fxval &) \ 56612853Sgabeblack@google.com DECL_BIN_OP_T(op, const sc_fxval_fast &) \ 56712853Sgabeblack@google.com DECL_BIN_OP_T(op, const sc_fxnum_fast &) \ 56812853Sgabeblack@google.com DECL_BIN_OP_OTHER(op) 56912853Sgabeblack@google.com 57012853Sgabeblack@google.com DECL_BIN_OP(*, mult) 57112853Sgabeblack@google.com DECL_BIN_OP(+, add) 57212853Sgabeblack@google.com DECL_BIN_OP(-, sub) 57312853Sgabeblack@google.com// don't use macros 57412853Sgabeblack@google.com// DECL_BIN_OP(/, div) 57512853Sgabeblack@google.com friend const sc_fxval operator / (const sc_fxnum &, const sc_fxnum &); 57612853Sgabeblack@google.com DECL_BIN_OP_T(/, int) 57712853Sgabeblack@google.com DECL_BIN_OP_T(/, unsigned int) 57812853Sgabeblack@google.com DECL_BIN_OP_T(/, long) 57912853Sgabeblack@google.com DECL_BIN_OP_T(/, unsigned long) 58012853Sgabeblack@google.com DECL_BIN_OP_T(/, float) 58112853Sgabeblack@google.com DECL_BIN_OP_T(/, double) 58212853Sgabeblack@google.com DECL_BIN_OP_T(/, const char *) 58312853Sgabeblack@google.com DECL_BIN_OP_T(/, const sc_fxval &) 58412853Sgabeblack@google.com DECL_BIN_OP_T(/, const sc_fxval_fast &) 58512853Sgabeblack@google.com DECL_BIN_OP_T(/, const sc_fxnum_fast &) 58612853Sgabeblack@google.com// DECL_BIN_OP_OTHER(op) 58712853Sgabeblack@google.com 58812853Sgabeblack@google.com DECL_BIN_OP_T(/, int64) 58912853Sgabeblack@google.com DECL_BIN_OP_T(/, uint64) 59012853Sgabeblack@google.com DECL_BIN_OP_T(/, const sc_int_base &) 59112853Sgabeblack@google.com DECL_BIN_OP_T(/, const sc_uint_base &) 59212853Sgabeblack@google.com DECL_BIN_OP_T(/, const sc_signed &) 59312853Sgabeblack@google.com DECL_BIN_OP_T(/, const sc_unsigned &) 59412853Sgabeblack@google.com 59512853Sgabeblack@google.com#undef DECL_BIN_OP_T 59612853Sgabeblack@google.com#undef DECL_BIN_OP_OTHER 59712853Sgabeblack@google.com#undef DECL_BIN_OP 59812853Sgabeblack@google.com 59912853Sgabeblack@google.com friend const sc_fxval operator << (const sc_fxnum &, int); 60012853Sgabeblack@google.com friend const sc_fxval operator >> (const sc_fxnum &, int); 60112853Sgabeblack@google.com 60212853Sgabeblack@google.com // binary functions 60312853Sgabeblack@google.com#define DECL_BIN_FNC_T(fnc, tp) \ 60412853Sgabeblack@google.com friend void fnc (sc_fxval &, const sc_fxnum &, tp); \ 60512853Sgabeblack@google.com friend void fnc (sc_fxval &, tp, const sc_fxnum &); \ 60612853Sgabeblack@google.com friend void fnc (sc_fxnum &, const sc_fxnum &, tp); \ 60712853Sgabeblack@google.com friend void fnc (sc_fxnum &, tp, const sc_fxnum &); 60812853Sgabeblack@google.com 60912853Sgabeblack@google.com#define DECL_BIN_FNC_OTHER(fnc) \ 61012853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, int64) \ 61112853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, uint64) \ 61212853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, const sc_int_base &) \ 61312853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, const sc_uint_base &) \ 61412853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, const sc_signed &) \ 61512853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, const sc_unsigned &) 61612853Sgabeblack@google.com 61712853Sgabeblack@google.com#define DECL_BIN_FNC(fnc) \ 61812853Sgabeblack@google.com friend void fnc (sc_fxval &, const sc_fxnum &, const sc_fxnum &); \ 61912853Sgabeblack@google.com friend void fnc (sc_fxnum &, const sc_fxnum &, const sc_fxnum &); \ 62012853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, int) \ 62112853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, unsigned int) \ 62212853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, long) \ 62312853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, unsigned long) \ 62412853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, float) \ 62512853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, double) \ 62612853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, const char *) \ 62712853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, const sc_fxval &) \ 62812853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, const sc_fxval_fast &) \ 62912853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, const sc_fxnum_fast &) \ 63012853Sgabeblack@google.com DECL_BIN_FNC_OTHER(fnc) 63112853Sgabeblack@google.com 63212853Sgabeblack@google.com DECL_BIN_FNC(mult) 63312853Sgabeblack@google.com DECL_BIN_FNC(div) 63412853Sgabeblack@google.com DECL_BIN_FNC(add) 63512853Sgabeblack@google.com DECL_BIN_FNC(sub) 63612853Sgabeblack@google.com 63712853Sgabeblack@google.com#undef DECL_BIN_FNC_T 63812853Sgabeblack@google.com#undef DECL_BIN_FNC_OTHER 63912853Sgabeblack@google.com#undef DECL_BIN_FNC 64012853Sgabeblack@google.com 64112853Sgabeblack@google.com friend void lshift(sc_fxval &, const sc_fxnum &, int); 64212853Sgabeblack@google.com friend void rshift(sc_fxval &, const sc_fxnum &, int); 64312853Sgabeblack@google.com friend void lshift(sc_fxnum &, const sc_fxnum &, int); 64412853Sgabeblack@google.com friend void rshift(sc_fxnum &, const sc_fxnum &, int); 64512853Sgabeblack@google.com 64612853Sgabeblack@google.com // relational (including equality) operators 64712853Sgabeblack@google.com#define DECL_REL_OP_T(op, tp) \ 64812853Sgabeblack@google.com friend bool operator op (const sc_fxnum &, tp); \ 64912853Sgabeblack@google.com friend bool operator op (tp, const sc_fxnum &); 65012853Sgabeblack@google.com 65112853Sgabeblack@google.com#define DECL_REL_OP_OTHER(op) \ 65212853Sgabeblack@google.com DECL_REL_OP_T(op, int64) \ 65312853Sgabeblack@google.com DECL_REL_OP_T(op, uint64) \ 65412853Sgabeblack@google.com DECL_REL_OP_T(op, const sc_int_base &) \ 65512853Sgabeblack@google.com DECL_REL_OP_T(op, const sc_uint_base &) \ 65612853Sgabeblack@google.com DECL_REL_OP_T(op, const sc_signed &) \ 65712853Sgabeblack@google.com DECL_REL_OP_T(op, const sc_unsigned &) 65812853Sgabeblack@google.com 65912853Sgabeblack@google.com#define DECL_REL_OP(op) \ 66012853Sgabeblack@google.com friend bool operator op (const sc_fxnum &, const sc_fxnum &); \ 66112853Sgabeblack@google.com DECL_REL_OP_T(op, int) \ 66212853Sgabeblack@google.com DECL_REL_OP_T(op, unsigned int) \ 66312853Sgabeblack@google.com DECL_REL_OP_T(op, long) \ 66412853Sgabeblack@google.com DECL_REL_OP_T(op, unsigned long) \ 66512853Sgabeblack@google.com DECL_REL_OP_T(op, float) \ 66612853Sgabeblack@google.com DECL_REL_OP_T(op, double) \ 66712853Sgabeblack@google.com DECL_REL_OP_T(op, const char *) \ 66812853Sgabeblack@google.com DECL_REL_OP_T(op, const sc_fxval &) \ 66912853Sgabeblack@google.com DECL_REL_OP_T(op, const sc_fxval_fast &) \ 67012853Sgabeblack@google.com DECL_REL_OP_T(op, const sc_fxnum_fast &) \ 67112853Sgabeblack@google.com DECL_REL_OP_OTHER(op) 67212853Sgabeblack@google.com 67312853Sgabeblack@google.com DECL_REL_OP(<) 67412853Sgabeblack@google.com DECL_REL_OP(<=) 67512853Sgabeblack@google.com DECL_REL_OP(>) 67612853Sgabeblack@google.com DECL_REL_OP(>=) 67712853Sgabeblack@google.com DECL_REL_OP(==) 67812853Sgabeblack@google.com DECL_REL_OP(!=) 67912853Sgabeblack@google.com 68012853Sgabeblack@google.com#undef DECL_REL_OP_T 68112853Sgabeblack@google.com#undef DECL_REL_OP_OTHER 68212853Sgabeblack@google.com#undef DECL_REL_OP 68312853Sgabeblack@google.com 68412853Sgabeblack@google.com // assignment operators 68512853Sgabeblack@google.com#define DECL_ASN_OP_T(op, tp) \ 68612853Sgabeblack@google.com sc_fxnum &operator op(tp); 68712853Sgabeblack@google.com 68812853Sgabeblack@google.com#define DECL_ASN_OP_OTHER(op) \ 68912853Sgabeblack@google.com DECL_ASN_OP_T(op, int64) \ 69012853Sgabeblack@google.com DECL_ASN_OP_T(op, uint64) \ 69112853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_int_base &) \ 69212853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_uint_base &) \ 69312853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_signed &) \ 69412853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_unsigned &) 69512853Sgabeblack@google.com 69612853Sgabeblack@google.com#define DECL_ASN_OP(op) \ 69712853Sgabeblack@google.com DECL_ASN_OP_T(op, int) \ 69812853Sgabeblack@google.com DECL_ASN_OP_T(op, unsigned int) \ 69912853Sgabeblack@google.com DECL_ASN_OP_T(op, long) \ 70012853Sgabeblack@google.com DECL_ASN_OP_T(op, unsigned long) \ 70112853Sgabeblack@google.com DECL_ASN_OP_T(op, float) \ 70212853Sgabeblack@google.com DECL_ASN_OP_T(op, double) \ 70312853Sgabeblack@google.com DECL_ASN_OP_T(op, const char *) \ 70412853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_fxval &) \ 70512853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_fxval_fast &) \ 70612853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_fxnum &) \ 70712853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_fxnum_fast &) \ 70812853Sgabeblack@google.com DECL_ASN_OP_OTHER(op) 70912853Sgabeblack@google.com 71012853Sgabeblack@google.com DECL_ASN_OP(=) 71112853Sgabeblack@google.com 71212853Sgabeblack@google.com DECL_ASN_OP(*=) 71312853Sgabeblack@google.com DECL_ASN_OP(/=) 71412853Sgabeblack@google.com DECL_ASN_OP(+=) 71512853Sgabeblack@google.com DECL_ASN_OP(-=) 71612853Sgabeblack@google.com 71712853Sgabeblack@google.com DECL_ASN_OP_T(<<=, int) 71812853Sgabeblack@google.com DECL_ASN_OP_T(>>=, int) 71912853Sgabeblack@google.com 72012853Sgabeblack@google.com#undef DECL_ASN_OP_T 72112853Sgabeblack@google.com#undef DECL_ASN_OP_OTHER 72212853Sgabeblack@google.com#undef DECL_ASN_OP 72312853Sgabeblack@google.com 72412853Sgabeblack@google.com // auto-increment and auto-decrement 72512853Sgabeblack@google.com const sc_fxval operator ++ (int); 72612853Sgabeblack@google.com const sc_fxval operator -- (int); 72712853Sgabeblack@google.com 72812853Sgabeblack@google.com sc_fxnum &operator ++ (); 72912853Sgabeblack@google.com sc_fxnum &operator -- (); 73012853Sgabeblack@google.com 73112853Sgabeblack@google.com // bit selection 73212853Sgabeblack@google.com const sc_fxnum_bitref operator [] (int) const; 73312853Sgabeblack@google.com sc_fxnum_bitref operator [] (int); 73412853Sgabeblack@google.com 73512853Sgabeblack@google.com const sc_fxnum_bitref bit(int) const; 73612853Sgabeblack@google.com sc_fxnum_bitref bit(int); 73712853Sgabeblack@google.com 73812853Sgabeblack@google.com // part selection 73912853Sgabeblack@google.com const sc_fxnum_subref operator () (int, int) const; 74012853Sgabeblack@google.com sc_fxnum_subref operator () (int, int); 74112853Sgabeblack@google.com 74212853Sgabeblack@google.com const sc_fxnum_subref range(int, int) const; 74312853Sgabeblack@google.com sc_fxnum_subref range(int, int); 74412853Sgabeblack@google.com 74512853Sgabeblack@google.com const sc_fxnum_subref operator () () const; 74612853Sgabeblack@google.com sc_fxnum_subref operator () (); 74712853Sgabeblack@google.com 74812853Sgabeblack@google.com const sc_fxnum_subref range() const; 74912853Sgabeblack@google.com sc_fxnum_subref range(); 75012853Sgabeblack@google.com 75112853Sgabeblack@google.com // implicit conversion 75212853Sgabeblack@google.com operator double() const; // necessary evil! 75312853Sgabeblack@google.com 75412853Sgabeblack@google.com // explicit conversion to primitive types 75512853Sgabeblack@google.com short to_short() const; 75612853Sgabeblack@google.com unsigned short to_ushort() const; 75712853Sgabeblack@google.com int to_int() const; 75812853Sgabeblack@google.com unsigned int to_uint() const; 75912853Sgabeblack@google.com long to_long() const; 76012853Sgabeblack@google.com unsigned long to_ulong() const; 76112853Sgabeblack@google.com int64 to_int64() const; 76212853Sgabeblack@google.com uint64 to_uint64() const; 76312853Sgabeblack@google.com float to_float() const; 76412853Sgabeblack@google.com double to_double() const; 76512853Sgabeblack@google.com 76612853Sgabeblack@google.com // explicit conversion to character string 76712853Sgabeblack@google.com const std::string to_string() const; 76812853Sgabeblack@google.com const std::string to_string(sc_numrep) const; 76912853Sgabeblack@google.com const std::string to_string(sc_numrep, bool) const; 77012853Sgabeblack@google.com const std::string to_string(sc_fmt) const; 77112853Sgabeblack@google.com const std::string to_string(sc_numrep, sc_fmt) const; 77212853Sgabeblack@google.com const std::string to_string(sc_numrep, bool, sc_fmt) const; 77312853Sgabeblack@google.com 77412853Sgabeblack@google.com const std::string to_dec() const; 77512853Sgabeblack@google.com const std::string to_bin() const; 77612853Sgabeblack@google.com const std::string to_oct() const; 77712853Sgabeblack@google.com const std::string to_hex() const; 77812853Sgabeblack@google.com 77912853Sgabeblack@google.com // query value 78012853Sgabeblack@google.com bool is_neg() const; 78112853Sgabeblack@google.com bool is_zero() const; 78212853Sgabeblack@google.com 78312853Sgabeblack@google.com // internal use only; 78412853Sgabeblack@google.com bool is_normal() const; 78512853Sgabeblack@google.com 78612853Sgabeblack@google.com bool quantization_flag() const; 78712853Sgabeblack@google.com bool overflow_flag() const; 78812853Sgabeblack@google.com 78912853Sgabeblack@google.com const sc_fxval value() const; 79012853Sgabeblack@google.com 79112853Sgabeblack@google.com // query parameters 79212853Sgabeblack@google.com int wl() const; 79312853Sgabeblack@google.com int iwl() const; 79412853Sgabeblack@google.com sc_q_mode q_mode() const; 79512853Sgabeblack@google.com sc_o_mode o_mode() const; 79612853Sgabeblack@google.com int n_bits() const; 79712853Sgabeblack@google.com 79812853Sgabeblack@google.com const sc_fxtype_params &type_params() const; 79912853Sgabeblack@google.com 80012853Sgabeblack@google.com const sc_fxcast_switch &cast_switch() const; 80112853Sgabeblack@google.com 80212853Sgabeblack@google.com // print or dump content 80312853Sgabeblack@google.com void print(::std::ostream & =::std::cout) const; 80412853Sgabeblack@google.com void scan(::std::istream & =::std::cin); 80512853Sgabeblack@google.com void dump(::std::ostream & =::std::cout) const; 80612853Sgabeblack@google.com 80712853Sgabeblack@google.com // internal use only; 80812853Sgabeblack@google.com void observer_read() const; 80912853Sgabeblack@google.com 81012853Sgabeblack@google.com // internal use only; 81112853Sgabeblack@google.com bool get_bit(int) const; 81212853Sgabeblack@google.com 81312853Sgabeblack@google.com protected: 81412853Sgabeblack@google.com bool set_bit(int, bool); 81512853Sgabeblack@google.com 81612853Sgabeblack@google.com bool get_slice(int, int, sc_bv_base &) const; 81712853Sgabeblack@google.com bool set_slice(int, int, const sc_bv_base &); 81812853Sgabeblack@google.com 81912853Sgabeblack@google.com sc_fxnum_observer *lock_observer() const; 82012853Sgabeblack@google.com void unlock_observer(sc_fxnum_observer *) const; 82112853Sgabeblack@google.com 82212853Sgabeblack@google.com private: 82312853Sgabeblack@google.com scfx_rep *m_rep; 82412853Sgabeblack@google.com 82512853Sgabeblack@google.com scfx_params m_params; 82612853Sgabeblack@google.com bool m_q_flag; 82712853Sgabeblack@google.com bool m_o_flag; 82812853Sgabeblack@google.com 82912853Sgabeblack@google.com mutable sc_fxnum_observer *m_observer; 83012853Sgabeblack@google.com 83112853Sgabeblack@google.com private: 83212853Sgabeblack@google.com // disabled 83312853Sgabeblack@google.com sc_fxnum(); 83412853Sgabeblack@google.com sc_fxnum(const sc_fxnum &); 83512853Sgabeblack@google.com}; 83612853Sgabeblack@google.com 83712853Sgabeblack@google.com 83812853Sgabeblack@google.com// ---------------------------------------------------------------------------- 83912853Sgabeblack@google.com// CLASS : sc_fxnum_fast 84012853Sgabeblack@google.com// 84112853Sgabeblack@google.com// Base class for the fixed-point types; limited precision. 84212853Sgabeblack@google.com// ---------------------------------------------------------------------------- 84312853Sgabeblack@google.com 84412853Sgabeblack@google.comclass sc_fxnum_fast 84512853Sgabeblack@google.com{ 84612853Sgabeblack@google.com friend class sc_fxval_fast; 84712853Sgabeblack@google.com 84812853Sgabeblack@google.com friend class sc_fxnum_bitref; 84912853Sgabeblack@google.com friend class sc_fxnum_subref; 85012853Sgabeblack@google.com friend class sc_fxnum_fast_bitref; 85112853Sgabeblack@google.com friend class sc_fxnum_fast_subref; 85212853Sgabeblack@google.com 85313245Sgabeblack@google.com template <typename T, typename B> 85413245Sgabeblack@google.com friend class sc_gem5::TraceValFxnumBase; 85512853Sgabeblack@google.com 85612853Sgabeblack@google.com protected: 85712853Sgabeblack@google.com sc_fxnum_fast_observer *observer() const; 85812853Sgabeblack@google.com 85912853Sgabeblack@google.com void cast(); 86012853Sgabeblack@google.com 86112853Sgabeblack@google.com // constructors 86212853Sgabeblack@google.com sc_fxnum_fast(const sc_fxtype_params &, sc_enc, const sc_fxcast_switch &, 86312853Sgabeblack@google.com sc_fxnum_fast_observer *); 86412853Sgabeblack@google.com 86512853Sgabeblack@google.com#define DECL_CTOR_T(tp) \ 86612853Sgabeblack@google.com sc_fxnum_fast(tp, const sc_fxtype_params &, sc_enc, \ 86712853Sgabeblack@google.com const sc_fxcast_switch &, sc_fxnum_fast_observer *); 86812853Sgabeblack@google.com 86912853Sgabeblack@google.com DECL_CTOR_T(int) 87012853Sgabeblack@google.com DECL_CTOR_T(unsigned int) 87112853Sgabeblack@google.com DECL_CTOR_T(long) 87212853Sgabeblack@google.com DECL_CTOR_T(unsigned long) 87312853Sgabeblack@google.com DECL_CTOR_T(float) 87412853Sgabeblack@google.com DECL_CTOR_T(double) 87512853Sgabeblack@google.com DECL_CTOR_T(const char *) 87612853Sgabeblack@google.com DECL_CTOR_T(const sc_fxval &) 87712853Sgabeblack@google.com DECL_CTOR_T(const sc_fxval_fast &) 87812853Sgabeblack@google.com DECL_CTOR_T(const sc_fxnum &) 87912853Sgabeblack@google.com DECL_CTOR_T(const sc_fxnum_fast &) 88012853Sgabeblack@google.com 88112853Sgabeblack@google.com DECL_CTOR_T(int64) 88212853Sgabeblack@google.com DECL_CTOR_T(uint64) 88312853Sgabeblack@google.com DECL_CTOR_T(const sc_int_base &) 88412853Sgabeblack@google.com DECL_CTOR_T(const sc_uint_base &) 88512853Sgabeblack@google.com DECL_CTOR_T(const sc_signed &) 88612853Sgabeblack@google.com DECL_CTOR_T(const sc_unsigned &) 88712853Sgabeblack@google.com 88812853Sgabeblack@google.com#undef DECL_CTOR_T 88912853Sgabeblack@google.com ~sc_fxnum_fast(); 89012853Sgabeblack@google.com 89112853Sgabeblack@google.com // internal use only; 89212853Sgabeblack@google.com double get_val() const; 89312853Sgabeblack@google.com 89412853Sgabeblack@google.com public: 89512853Sgabeblack@google.com // unary operators 89612853Sgabeblack@google.com const sc_fxval_fast operator - () const; 89712853Sgabeblack@google.com const sc_fxval_fast operator + () const; 89812853Sgabeblack@google.com 89912853Sgabeblack@google.com // unary functions 90012853Sgabeblack@google.com friend void neg(sc_fxval_fast &, const sc_fxnum_fast &); 90112853Sgabeblack@google.com friend void neg(sc_fxnum_fast &, const sc_fxnum_fast &); 90212853Sgabeblack@google.com 90312853Sgabeblack@google.com 90412853Sgabeblack@google.com // binary operators 90512853Sgabeblack@google.com#define DECL_BIN_OP_T(op, tp) \ 90612853Sgabeblack@google.com friend const sc_fxval_fast operator op (const sc_fxnum_fast &, tp); \ 90712853Sgabeblack@google.com friend const sc_fxval_fast operator op (tp, const sc_fxnum_fast &); 90812853Sgabeblack@google.com 90912853Sgabeblack@google.com#define DECL_BIN_OP_OTHER(op) \ 91012853Sgabeblack@google.com DECL_BIN_OP_T(op, int64) \ 91112853Sgabeblack@google.com DECL_BIN_OP_T(op, uint64) \ 91212853Sgabeblack@google.com DECL_BIN_OP_T(op, const sc_int_base &) \ 91312853Sgabeblack@google.com DECL_BIN_OP_T(op, const sc_uint_base &) \ 91412853Sgabeblack@google.com DECL_BIN_OP_T(op, const sc_signed &) \ 91512853Sgabeblack@google.com DECL_BIN_OP_T(op, const sc_unsigned &) 91612853Sgabeblack@google.com 91712853Sgabeblack@google.com#define DECL_BIN_OP(op, dummy) \ 91812853Sgabeblack@google.com friend const sc_fxval_fast operator op (const sc_fxnum_fast &, \ 91912853Sgabeblack@google.com const sc_fxnum_fast &); \ 92012853Sgabeblack@google.com DECL_BIN_OP_T(op, int) \ 92112853Sgabeblack@google.com DECL_BIN_OP_T(op, unsigned int) \ 92212853Sgabeblack@google.com DECL_BIN_OP_T(op, long) \ 92312853Sgabeblack@google.com DECL_BIN_OP_T(op, unsigned long) \ 92412853Sgabeblack@google.com DECL_BIN_OP_T(op, float) \ 92512853Sgabeblack@google.com DECL_BIN_OP_T(op, double) \ 92612853Sgabeblack@google.com DECL_BIN_OP_T(op, const char *) \ 92712853Sgabeblack@google.com DECL_BIN_OP_T(op, const sc_fxval_fast &) \ 92812853Sgabeblack@google.com DECL_BIN_OP_OTHER(op) 92912853Sgabeblack@google.com 93012853Sgabeblack@google.com DECL_BIN_OP(*, mult) 93112853Sgabeblack@google.com DECL_BIN_OP(+, add) 93212853Sgabeblack@google.com DECL_BIN_OP(-, sub) 93312853Sgabeblack@google.com// DECL_BIN_OP(/, div) 93412853Sgabeblack@google.com friend const sc_fxval_fast operator / (const sc_fxnum_fast &, 93512853Sgabeblack@google.com const sc_fxnum_fast &); 93612853Sgabeblack@google.com DECL_BIN_OP_T(/, int) 93712853Sgabeblack@google.com DECL_BIN_OP_T(/, unsigned int) 93812853Sgabeblack@google.com DECL_BIN_OP_T(/, long) 93912853Sgabeblack@google.com DECL_BIN_OP_T(/, unsigned long) 94012853Sgabeblack@google.com DECL_BIN_OP_T(/, float) 94112853Sgabeblack@google.com DECL_BIN_OP_T(/, double) 94212853Sgabeblack@google.com DECL_BIN_OP_T(/, const char *) 94312853Sgabeblack@google.com DECL_BIN_OP_T(/, const sc_fxval_fast &) 94412853Sgabeblack@google.com// DECL_BIN_OP_OTHER(op) 94512853Sgabeblack@google.com 94612853Sgabeblack@google.com DECL_BIN_OP_T(/, int64) \ 94712853Sgabeblack@google.com DECL_BIN_OP_T(/, uint64) \ 94812853Sgabeblack@google.com DECL_BIN_OP_T(/, const sc_int_base &) \ 94912853Sgabeblack@google.com DECL_BIN_OP_T(/, const sc_uint_base &) \ 95012853Sgabeblack@google.com DECL_BIN_OP_T(/, const sc_signed &) \ 95112853Sgabeblack@google.com DECL_BIN_OP_T(/, const sc_unsigned &) 95212853Sgabeblack@google.com 95312853Sgabeblack@google.com#undef DECL_BIN_OP_T 95412853Sgabeblack@google.com#undef DECL_BIN_OP_OTHER 95512853Sgabeblack@google.com#undef DECL_BIN_OP 95612853Sgabeblack@google.com 95712853Sgabeblack@google.com friend const sc_fxval_fast operator << (const sc_fxnum_fast &, int); 95812853Sgabeblack@google.com friend const sc_fxval_fast operator >> (const sc_fxnum_fast &, int); 95912853Sgabeblack@google.com 96012853Sgabeblack@google.com // binary functions 96112853Sgabeblack@google.com#define DECL_BIN_FNC_T(fnc, tp) \ 96212853Sgabeblack@google.com friend void fnc (sc_fxval_fast &, const sc_fxnum_fast &, tp); \ 96312853Sgabeblack@google.com friend void fnc (sc_fxval_fast &, tp, const sc_fxnum_fast &); \ 96412853Sgabeblack@google.com friend void fnc (sc_fxnum_fast &, const sc_fxnum_fast &, tp); \ 96512853Sgabeblack@google.com friend void fnc (sc_fxnum_fast &, tp, const sc_fxnum_fast &); 96612853Sgabeblack@google.com 96712853Sgabeblack@google.com#define DECL_BIN_FNC_OTHER(fnc) \ 96812853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, int64) \ 96912853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, uint64) \ 97012853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, const sc_int_base &) \ 97112853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, const sc_uint_base &) \ 97212853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, const sc_signed &) \ 97312853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, const sc_unsigned &) 97412853Sgabeblack@google.com 97512853Sgabeblack@google.com#define DECL_BIN_FNC(fnc) \ 97612853Sgabeblack@google.com friend void fnc (sc_fxval_fast &, const sc_fxnum_fast &, \ 97712853Sgabeblack@google.com const sc_fxnum_fast &); \ 97812853Sgabeblack@google.com friend void fnc (sc_fxnum_fast &, const sc_fxnum_fast &, \ 97912853Sgabeblack@google.com const sc_fxnum_fast &); \ 98012853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, int) \ 98112853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, unsigned int) \ 98212853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, long) \ 98312853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, unsigned long) \ 98412853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, float) \ 98512853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, double) \ 98612853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, const char *) \ 98712853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, const sc_fxval &) \ 98812853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, const sc_fxval_fast &) \ 98912853Sgabeblack@google.com DECL_BIN_FNC_T(fnc, const sc_fxnum &) \ 99012853Sgabeblack@google.com DECL_BIN_FNC_OTHER(fnc) 99112853Sgabeblack@google.com 99212853Sgabeblack@google.com DECL_BIN_FNC(mult) 99312853Sgabeblack@google.com DECL_BIN_FNC(div) 99412853Sgabeblack@google.com DECL_BIN_FNC(add) 99512853Sgabeblack@google.com DECL_BIN_FNC(sub) 99612853Sgabeblack@google.com 99712853Sgabeblack@google.com#undef DECL_BIN_FNC_T 99812853Sgabeblack@google.com#undef DECL_BIN_FNC_OTHER 99912853Sgabeblack@google.com#undef DECL_BIN_FNC 100012853Sgabeblack@google.com 100112853Sgabeblack@google.com friend void lshift(sc_fxval_fast &, const sc_fxnum_fast &, int); 100212853Sgabeblack@google.com friend void rshift(sc_fxval_fast &, const sc_fxnum_fast &, int); 100312853Sgabeblack@google.com friend void lshift(sc_fxnum_fast &, const sc_fxnum_fast &, int); 100412853Sgabeblack@google.com friend void rshift(sc_fxnum_fast &, const sc_fxnum_fast &, int); 100512853Sgabeblack@google.com 100612853Sgabeblack@google.com // relational (including equality) operators 100712853Sgabeblack@google.com#define DECL_REL_OP_T(op, tp) \ 100812853Sgabeblack@google.com friend bool operator op (const sc_fxnum_fast &, tp); \ 100912853Sgabeblack@google.com friend bool operator op (tp, const sc_fxnum_fast &); 101012853Sgabeblack@google.com 101112853Sgabeblack@google.com#define DECL_REL_OP_OTHER(op) \ 101212853Sgabeblack@google.com DECL_REL_OP_T(op, int64) \ 101312853Sgabeblack@google.com DECL_REL_OP_T(op, uint64) \ 101412853Sgabeblack@google.com DECL_REL_OP_T(op, const sc_int_base &) \ 101512853Sgabeblack@google.com DECL_REL_OP_T(op, const sc_uint_base &) \ 101612853Sgabeblack@google.com DECL_REL_OP_T(op, const sc_signed &) \ 101712853Sgabeblack@google.com DECL_REL_OP_T(op, const sc_unsigned &) 101812853Sgabeblack@google.com 101912853Sgabeblack@google.com#define DECL_REL_OP(op) \ 102012853Sgabeblack@google.com friend bool operator op (const sc_fxnum_fast &, const sc_fxnum_fast &); \ 102112853Sgabeblack@google.com DECL_REL_OP_T(op, int) \ 102212853Sgabeblack@google.com DECL_REL_OP_T(op, unsigned int) \ 102312853Sgabeblack@google.com DECL_REL_OP_T(op, long) \ 102412853Sgabeblack@google.com DECL_REL_OP_T(op, unsigned long) \ 102512853Sgabeblack@google.com DECL_REL_OP_T(op, float) \ 102612853Sgabeblack@google.com DECL_REL_OP_T(op, double) \ 102712853Sgabeblack@google.com DECL_REL_OP_T(op, const char *) \ 102812853Sgabeblack@google.com DECL_REL_OP_T(op, const sc_fxval_fast &) \ 102912853Sgabeblack@google.com DECL_REL_OP_OTHER(op) 103012853Sgabeblack@google.com 103112853Sgabeblack@google.com DECL_REL_OP(<) 103212853Sgabeblack@google.com DECL_REL_OP(<=) 103312853Sgabeblack@google.com DECL_REL_OP(>) 103412853Sgabeblack@google.com DECL_REL_OP(>=) 103512853Sgabeblack@google.com DECL_REL_OP(==) 103612853Sgabeblack@google.com DECL_REL_OP(!=) 103712853Sgabeblack@google.com 103812853Sgabeblack@google.com#undef DECL_REL_OP_T 103912853Sgabeblack@google.com#undef DECL_REL_OP_OTHER 104012853Sgabeblack@google.com#undef DECL_REL_OP 104112853Sgabeblack@google.com 104212853Sgabeblack@google.com // assignment operators 104312853Sgabeblack@google.com#define DECL_ASN_OP_T(op, tp) sc_fxnum_fast &operator op(tp); 104412853Sgabeblack@google.com 104512853Sgabeblack@google.com#define DECL_ASN_OP_OTHER(op) \ 104612853Sgabeblack@google.com DECL_ASN_OP_T(op, int64) \ 104712853Sgabeblack@google.com DECL_ASN_OP_T(op, uint64) \ 104812853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_int_base &) \ 104912853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_uint_base &) \ 105012853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_signed &) \ 105112853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_unsigned &) 105212853Sgabeblack@google.com 105312853Sgabeblack@google.com#define DECL_ASN_OP(op) \ 105412853Sgabeblack@google.com DECL_ASN_OP_T(op, int) \ 105512853Sgabeblack@google.com DECL_ASN_OP_T(op, unsigned int) \ 105612853Sgabeblack@google.com DECL_ASN_OP_T(op, long) \ 105712853Sgabeblack@google.com DECL_ASN_OP_T(op, unsigned long) \ 105812853Sgabeblack@google.com DECL_ASN_OP_T(op, float) \ 105912853Sgabeblack@google.com DECL_ASN_OP_T(op, double) \ 106012853Sgabeblack@google.com DECL_ASN_OP_T(op, const char *) \ 106112853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_fxval &) \ 106212853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_fxval_fast &) \ 106312853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_fxnum &) \ 106412853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_fxnum_fast &) \ 106512853Sgabeblack@google.com DECL_ASN_OP_OTHER(op) 106612853Sgabeblack@google.com 106712853Sgabeblack@google.com DECL_ASN_OP(=) 106812853Sgabeblack@google.com 106912853Sgabeblack@google.com DECL_ASN_OP(*=) 107012853Sgabeblack@google.com DECL_ASN_OP(/=) 107112853Sgabeblack@google.com DECL_ASN_OP(+=) 107212853Sgabeblack@google.com DECL_ASN_OP(-=) 107312853Sgabeblack@google.com 107412853Sgabeblack@google.com DECL_ASN_OP_T(<<=, int) 107512853Sgabeblack@google.com DECL_ASN_OP_T(>>=, int) 107612853Sgabeblack@google.com 107712853Sgabeblack@google.com#undef DECL_ASN_OP_T 107812853Sgabeblack@google.com#undef DECL_ASN_OP_OTHER 107912853Sgabeblack@google.com#undef DECL_ASN_OP 108012853Sgabeblack@google.com 108112853Sgabeblack@google.com // auto-increment and auto-decrement 108212853Sgabeblack@google.com const sc_fxval_fast operator ++ (int); 108312853Sgabeblack@google.com const sc_fxval_fast operator -- (int); 108412853Sgabeblack@google.com 108512853Sgabeblack@google.com sc_fxnum_fast &operator ++ (); 108612853Sgabeblack@google.com sc_fxnum_fast &operator -- (); 108712853Sgabeblack@google.com 108812853Sgabeblack@google.com // bit selection 108912853Sgabeblack@google.com const sc_fxnum_fast_bitref operator [] (int) const; 109012853Sgabeblack@google.com sc_fxnum_fast_bitref operator [] (int); 109112853Sgabeblack@google.com 109212853Sgabeblack@google.com const sc_fxnum_fast_bitref bit(int) const; 109312853Sgabeblack@google.com sc_fxnum_fast_bitref bit(int); 109412853Sgabeblack@google.com 109512853Sgabeblack@google.com // part selection 109612853Sgabeblack@google.com const sc_fxnum_fast_subref operator () (int, int) const; 109712853Sgabeblack@google.com sc_fxnum_fast_subref operator () (int, int); 109812853Sgabeblack@google.com 109912853Sgabeblack@google.com const sc_fxnum_fast_subref range(int, int) const; 110012853Sgabeblack@google.com sc_fxnum_fast_subref range(int, int); 110112853Sgabeblack@google.com 110212853Sgabeblack@google.com 110312853Sgabeblack@google.com const sc_fxnum_fast_subref operator () () const; 110412853Sgabeblack@google.com sc_fxnum_fast_subref operator () (); 110512853Sgabeblack@google.com 110612853Sgabeblack@google.com const sc_fxnum_fast_subref range() const; 110712853Sgabeblack@google.com sc_fxnum_fast_subref range(); 110812853Sgabeblack@google.com 110912853Sgabeblack@google.com // implicit conversion 111012853Sgabeblack@google.com operator double() const; // necessary evil! 111112853Sgabeblack@google.com 111212853Sgabeblack@google.com // explicit conversion to primitive types 111312853Sgabeblack@google.com short to_short() const; 111412853Sgabeblack@google.com unsigned short to_ushort() const; 111512853Sgabeblack@google.com int to_int() const; 111612853Sgabeblack@google.com unsigned int to_uint() const; 111712853Sgabeblack@google.com long to_long() const; 111812853Sgabeblack@google.com unsigned long to_ulong() const; 111912853Sgabeblack@google.com int64 to_int64() const; 112012853Sgabeblack@google.com uint64 to_uint64() const; 112112853Sgabeblack@google.com float to_float() const; 112212853Sgabeblack@google.com double to_double() const; 112312853Sgabeblack@google.com 112412853Sgabeblack@google.com // explicit conversion to character string 112512853Sgabeblack@google.com const std::string to_string() const; 112612853Sgabeblack@google.com const std::string to_string(sc_numrep) const; 112712853Sgabeblack@google.com const std::string to_string(sc_numrep, bool) const; 112812853Sgabeblack@google.com const std::string to_string(sc_fmt) const; 112912853Sgabeblack@google.com const std::string to_string(sc_numrep, sc_fmt) const; 113012853Sgabeblack@google.com const std::string to_string(sc_numrep, bool, sc_fmt) const; 113112853Sgabeblack@google.com 113212853Sgabeblack@google.com const std::string to_dec() const; 113312853Sgabeblack@google.com const std::string to_bin() const; 113412853Sgabeblack@google.com const std::string to_oct() const; 113512853Sgabeblack@google.com const std::string to_hex() const; 113612853Sgabeblack@google.com 113712853Sgabeblack@google.com // query value 113812853Sgabeblack@google.com bool is_neg() const; 113912853Sgabeblack@google.com bool is_zero() const; 114012853Sgabeblack@google.com 114112853Sgabeblack@google.com // internal use only; 114212853Sgabeblack@google.com bool is_normal() const; 114312853Sgabeblack@google.com 114412853Sgabeblack@google.com bool quantization_flag() const; 114512853Sgabeblack@google.com bool overflow_flag() const; 114612853Sgabeblack@google.com 114712853Sgabeblack@google.com const sc_fxval_fast value() const; 114812853Sgabeblack@google.com 114912853Sgabeblack@google.com // query parameters 115012853Sgabeblack@google.com int wl() const; 115112853Sgabeblack@google.com int iwl() const; 115212853Sgabeblack@google.com sc_q_mode q_mode() const; 115312853Sgabeblack@google.com sc_o_mode o_mode() const; 115412853Sgabeblack@google.com int n_bits() const; 115512853Sgabeblack@google.com 115612853Sgabeblack@google.com const sc_fxtype_params &type_params() const; 115712853Sgabeblack@google.com 115812853Sgabeblack@google.com const sc_fxcast_switch &cast_switch() const; 115912853Sgabeblack@google.com 116012853Sgabeblack@google.com // print or dump content 116112853Sgabeblack@google.com void print(::std::ostream & =::std::cout) const; 116212853Sgabeblack@google.com void scan(::std::istream & =::std::cin); 116312853Sgabeblack@google.com void dump(::std::ostream & =::std::cout) const; 116412853Sgabeblack@google.com 116512853Sgabeblack@google.com // internal use only; 116612853Sgabeblack@google.com void observer_read() const; 116712853Sgabeblack@google.com 116812853Sgabeblack@google.com // internal use only; 116912853Sgabeblack@google.com bool get_bit(int) const; 117012853Sgabeblack@google.com 117112853Sgabeblack@google.com protected: 117212853Sgabeblack@google.com bool set_bit(int, bool); 117312853Sgabeblack@google.com 117412853Sgabeblack@google.com bool get_slice(int, int, sc_bv_base &) const; 117512853Sgabeblack@google.com bool set_slice(int, int, const sc_bv_base &); 117612853Sgabeblack@google.com 117712853Sgabeblack@google.com sc_fxnum_fast_observer *lock_observer() const; 117812853Sgabeblack@google.com void unlock_observer(sc_fxnum_fast_observer *) const; 117912853Sgabeblack@google.com 118012853Sgabeblack@google.com private: 118112853Sgabeblack@google.com double m_val; 118212853Sgabeblack@google.com 118312853Sgabeblack@google.com scfx_params m_params; 118412853Sgabeblack@google.com bool m_q_flag; 118512853Sgabeblack@google.com bool m_o_flag; 118612853Sgabeblack@google.com 118712853Sgabeblack@google.com mutable sc_fxnum_fast_observer *m_observer; 118812853Sgabeblack@google.com 118912853Sgabeblack@google.com private: 119012853Sgabeblack@google.com // Disabled 119112853Sgabeblack@google.com sc_fxnum_fast(); 119212853Sgabeblack@google.com sc_fxnum_fast(const sc_fxnum_fast &); 119312853Sgabeblack@google.com}; 119412853Sgabeblack@google.com 119512853Sgabeblack@google.com 119612853Sgabeblack@google.com// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 119712853Sgabeblack@google.com 119812853Sgabeblack@google.com// ---------------------------------------------------------------------------- 119912853Sgabeblack@google.com// CLASS : sc_fxnum_bitref 120012853Sgabeblack@google.com// 120112853Sgabeblack@google.com// Proxy class for bit-selection in class sc_fxnum, behaves like sc_bit. 120212853Sgabeblack@google.com// ---------------------------------------------------------------------------- 120312853Sgabeblack@google.com 120412853Sgabeblack@google.com// constructor 120512853Sgabeblack@google.com 120612853Sgabeblack@google.cominline 120712853Sgabeblack@google.comsc_fxnum_bitref::sc_fxnum_bitref(sc_fxnum &num_, int idx_) : 120812853Sgabeblack@google.com m_num(num_), m_idx(idx_) 120912853Sgabeblack@google.com{} 121012853Sgabeblack@google.com 121112853Sgabeblack@google.com// copy constructor 121212853Sgabeblack@google.cominline sc_fxnum_bitref::sc_fxnum_bitref(const sc_fxnum_bitref &a) : 121312853Sgabeblack@google.com m_num(a.m_num), m_idx(a.m_idx) 121412853Sgabeblack@google.com{} 121512853Sgabeblack@google.com 121612853Sgabeblack@google.com// assignment operators 121712853Sgabeblack@google.cominline sc_fxnum_bitref & 121812853Sgabeblack@google.comsc_fxnum_bitref::operator = (const sc_fxnum_bitref &a) 121912853Sgabeblack@google.com{ 122012853Sgabeblack@google.com if (&a != this) { 122112853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(a.m_num) 122212853Sgabeblack@google.com set(a.get()); 122312853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(m_num) 122412853Sgabeblack@google.com } 122512853Sgabeblack@google.com return *this; 122612853Sgabeblack@google.com} 122712853Sgabeblack@google.com 122812853Sgabeblack@google.cominline sc_fxnum_bitref & 122912853Sgabeblack@google.comsc_fxnum_bitref::operator = (const sc_fxnum_fast_bitref &a) 123012853Sgabeblack@google.com{ 123112853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(a.m_num) 123212853Sgabeblack@google.com set(a.get()); 123312853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(m_num) 123412853Sgabeblack@google.com return *this; 123512853Sgabeblack@google.com} 123612853Sgabeblack@google.com 123712853Sgabeblack@google.cominline sc_fxnum_bitref & 123812853Sgabeblack@google.comsc_fxnum_bitref::operator = (const sc_bit &a) 123912853Sgabeblack@google.com{ 124012853Sgabeblack@google.com set(static_cast<bool>(a)); 124112853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(m_num) 124212853Sgabeblack@google.com return *this; 124312853Sgabeblack@google.com} 124412853Sgabeblack@google.com 124512853Sgabeblack@google.cominline sc_fxnum_bitref & 124612853Sgabeblack@google.comsc_fxnum_bitref::operator = (bool a) 124712853Sgabeblack@google.com{ 124812853Sgabeblack@google.com set(a); 124912853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(m_num) 125012853Sgabeblack@google.com return *this; 125112853Sgabeblack@google.com} 125212853Sgabeblack@google.com 125312853Sgabeblack@google.cominline sc_fxnum_bitref & 125412853Sgabeblack@google.comsc_fxnum_bitref::operator &= (const sc_fxnum_bitref &b) 125512853Sgabeblack@google.com{ 125612853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(m_num) 125712853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(b.m_num) 125812853Sgabeblack@google.com set(get() && b.get()); 125912853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(m_num) 126012853Sgabeblack@google.com return *this; 126112853Sgabeblack@google.com} 126212853Sgabeblack@google.com 126312853Sgabeblack@google.cominline sc_fxnum_bitref & 126412853Sgabeblack@google.comsc_fxnum_bitref::operator &= (const sc_fxnum_fast_bitref &b) 126512853Sgabeblack@google.com{ 126612853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(m_num) 126712853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(b.m_num) 126812853Sgabeblack@google.com set(get() && b.get()); 126912853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(m_num) 127012853Sgabeblack@google.com return *this; 127112853Sgabeblack@google.com} 127212853Sgabeblack@google.com 127312853Sgabeblack@google.cominline sc_fxnum_bitref & 127412853Sgabeblack@google.comsc_fxnum_bitref::operator &= (const sc_bit &b) 127512853Sgabeblack@google.com{ 127612853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(m_num) 127712853Sgabeblack@google.com set(get() && static_cast<bool>(b)); 127812853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(m_num) 127912853Sgabeblack@google.com return *this; 128012853Sgabeblack@google.com} 128112853Sgabeblack@google.com 128212853Sgabeblack@google.cominline sc_fxnum_bitref & 128312853Sgabeblack@google.comsc_fxnum_bitref::operator &= (bool b) 128412853Sgabeblack@google.com{ 128512853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(m_num) 128612853Sgabeblack@google.com set(get() && b); 128712853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(m_num) 128812853Sgabeblack@google.com return *this; 128912853Sgabeblack@google.com} 129012853Sgabeblack@google.com 129112853Sgabeblack@google.com 129212853Sgabeblack@google.cominline sc_fxnum_bitref & 129312853Sgabeblack@google.comsc_fxnum_bitref::operator |= (const sc_fxnum_bitref &b) 129412853Sgabeblack@google.com{ 129512853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(m_num) 129612853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(b.m_num) 129712853Sgabeblack@google.com set(get() || b.get()); 129812853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(m_num) 129912853Sgabeblack@google.com return *this; 130012853Sgabeblack@google.com} 130112853Sgabeblack@google.com 130212853Sgabeblack@google.cominline sc_fxnum_bitref & 130312853Sgabeblack@google.comsc_fxnum_bitref::operator |= (const sc_fxnum_fast_bitref &b) 130412853Sgabeblack@google.com{ 130512853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(m_num) 130612853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(b.m_num) 130712853Sgabeblack@google.com set(get() || b.get()); 130812853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(m_num) 130912853Sgabeblack@google.com return *this; 131012853Sgabeblack@google.com} 131112853Sgabeblack@google.com 131212853Sgabeblack@google.cominline sc_fxnum_bitref & 131312853Sgabeblack@google.comsc_fxnum_bitref::operator |= (const sc_bit &b) 131412853Sgabeblack@google.com{ 131512853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(m_num) 131612853Sgabeblack@google.com set(get() || static_cast<bool>(b)); 131712853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(m_num) 131812853Sgabeblack@google.com return *this; 131912853Sgabeblack@google.com} 132012853Sgabeblack@google.com 132112853Sgabeblack@google.cominline sc_fxnum_bitref & 132212853Sgabeblack@google.comsc_fxnum_bitref::operator |= (bool b) 132312853Sgabeblack@google.com{ 132412853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(m_num) 132512853Sgabeblack@google.com set(get() || b); 132612853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(m_num) 132712853Sgabeblack@google.com return *this; 132812853Sgabeblack@google.com} 132912853Sgabeblack@google.com 133012853Sgabeblack@google.com 133112853Sgabeblack@google.cominline sc_fxnum_bitref & 133212853Sgabeblack@google.comsc_fxnum_bitref::operator ^= (const sc_fxnum_bitref &b) 133312853Sgabeblack@google.com{ 133412853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(m_num) 133512853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(b.m_num) 133612853Sgabeblack@google.com set(get() != b.get()); 133712853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(m_num) 133812853Sgabeblack@google.com return *this; 133912853Sgabeblack@google.com} 134012853Sgabeblack@google.com 134112853Sgabeblack@google.cominline sc_fxnum_bitref & 134212853Sgabeblack@google.comsc_fxnum_bitref::operator ^= (const sc_fxnum_fast_bitref &b) 134312853Sgabeblack@google.com{ 134412853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(m_num) 134512853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(b.m_num) 134612853Sgabeblack@google.com set(get() != b.get()); 134712853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(m_num) 134812853Sgabeblack@google.com return *this; 134912853Sgabeblack@google.com} 135012853Sgabeblack@google.com 135112853Sgabeblack@google.cominline sc_fxnum_bitref & 135212853Sgabeblack@google.comsc_fxnum_bitref::operator ^= (const sc_bit &b) 135312853Sgabeblack@google.com{ 135412853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(m_num) 135512853Sgabeblack@google.com set(get() != static_cast<bool>(b)); 135612853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(m_num) 135712853Sgabeblack@google.com return *this; 135812853Sgabeblack@google.com} 135912853Sgabeblack@google.com 136012853Sgabeblack@google.cominline sc_fxnum_bitref & 136112853Sgabeblack@google.comsc_fxnum_bitref::operator ^= (bool b) 136212853Sgabeblack@google.com{ 136312853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(m_num) 136412853Sgabeblack@google.com set(get() != b); 136512853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(m_num) 136612853Sgabeblack@google.com return *this; 136712853Sgabeblack@google.com} 136812853Sgabeblack@google.com 136912853Sgabeblack@google.com// implicit conversion 137012853Sgabeblack@google.cominline sc_fxnum_bitref::operator bool() const 137112853Sgabeblack@google.com{ 137212853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(m_num) 137312853Sgabeblack@google.com return get(); 137412853Sgabeblack@google.com} 137512853Sgabeblack@google.com 137612853Sgabeblack@google.cominline ::std::ostream & 137712853Sgabeblack@google.comoperator << (::std::ostream &os, const sc_fxnum_bitref &a) 137812853Sgabeblack@google.com{ 137912853Sgabeblack@google.com a.print(os); 138012853Sgabeblack@google.com return os; 138112853Sgabeblack@google.com} 138212853Sgabeblack@google.com 138312853Sgabeblack@google.cominline ::std::istream & 138412853Sgabeblack@google.comoperator >> (::std::istream &is, sc_fxnum_bitref &a) 138512853Sgabeblack@google.com{ 138612853Sgabeblack@google.com a.scan(is); 138712853Sgabeblack@google.com return is; 138812853Sgabeblack@google.com} 138912853Sgabeblack@google.com 139012853Sgabeblack@google.com 139112853Sgabeblack@google.com// ---------------------------------------------------------------------------- 139212853Sgabeblack@google.com// CLASS : sc_fxnum_fast_bitref 139312853Sgabeblack@google.com// 139412853Sgabeblack@google.com// Proxy class for bit-selection in class sc_fxnum_fast, behaves like sc_bit. 139512853Sgabeblack@google.com// ---------------------------------------------------------------------------- 139612853Sgabeblack@google.com 139712853Sgabeblack@google.com// constructor 139812853Sgabeblack@google.cominline sc_fxnum_fast_bitref::sc_fxnum_fast_bitref( 139912853Sgabeblack@google.com sc_fxnum_fast &num_, int idx_) : m_num(num_), m_idx(idx_) 140012853Sgabeblack@google.com{} 140112853Sgabeblack@google.com 140212853Sgabeblack@google.com// copy constructor 140312853Sgabeblack@google.cominline sc_fxnum_fast_bitref::sc_fxnum_fast_bitref( 140412853Sgabeblack@google.com const sc_fxnum_fast_bitref &a) : m_num(a.m_num), m_idx(a.m_idx) 140512853Sgabeblack@google.com{} 140612853Sgabeblack@google.com 140712853Sgabeblack@google.com// assignment operators 140812853Sgabeblack@google.cominline sc_fxnum_fast_bitref & 140912853Sgabeblack@google.comsc_fxnum_fast_bitref::operator = (const sc_fxnum_bitref &a) 141012853Sgabeblack@google.com{ 141112853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(a.m_num) 141212853Sgabeblack@google.com set(a.get()); 141312853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) 141412853Sgabeblack@google.com return *this; 141512853Sgabeblack@google.com} 141612853Sgabeblack@google.com 141712853Sgabeblack@google.cominline sc_fxnum_fast_bitref & 141812853Sgabeblack@google.comsc_fxnum_fast_bitref::operator = (const sc_fxnum_fast_bitref &a) 141912853Sgabeblack@google.com{ 142012853Sgabeblack@google.com if (&a != this) { 142112853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(a.m_num) 142212853Sgabeblack@google.com set(a.get()); 142312853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) 142412853Sgabeblack@google.com } 142512853Sgabeblack@google.com return *this; 142612853Sgabeblack@google.com} 142712853Sgabeblack@google.com 142812853Sgabeblack@google.cominline sc_fxnum_fast_bitref & 142912853Sgabeblack@google.comsc_fxnum_fast_bitref::operator = (const sc_bit &a) 143012853Sgabeblack@google.com{ 143112853Sgabeblack@google.com set(static_cast<bool>(a)); 143212853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) 143312853Sgabeblack@google.com return *this; 143412853Sgabeblack@google.com} 143512853Sgabeblack@google.com 143612853Sgabeblack@google.cominline sc_fxnum_fast_bitref & 143712853Sgabeblack@google.comsc_fxnum_fast_bitref::operator = (bool a) 143812853Sgabeblack@google.com{ 143912853Sgabeblack@google.com set(a); 144012853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) 144112853Sgabeblack@google.com return *this; 144212853Sgabeblack@google.com} 144312853Sgabeblack@google.com 144412853Sgabeblack@google.com 144512853Sgabeblack@google.cominline sc_fxnum_fast_bitref & 144612853Sgabeblack@google.comsc_fxnum_fast_bitref::operator &= (const sc_fxnum_bitref &b) 144712853Sgabeblack@google.com{ 144812853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(m_num) 144912853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(b.m_num) 145012853Sgabeblack@google.com set(get() && b.get()); 145112853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) 145212853Sgabeblack@google.com return *this; 145312853Sgabeblack@google.com} 145412853Sgabeblack@google.com 145512853Sgabeblack@google.cominline sc_fxnum_fast_bitref & 145612853Sgabeblack@google.comsc_fxnum_fast_bitref::operator &= (const sc_fxnum_fast_bitref &b) 145712853Sgabeblack@google.com{ 145812853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(m_num) 145912853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(b.m_num) 146012853Sgabeblack@google.com set(get() && b.get()); 146112853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) 146212853Sgabeblack@google.com return *this; 146312853Sgabeblack@google.com} 146412853Sgabeblack@google.com 146512853Sgabeblack@google.cominline sc_fxnum_fast_bitref & 146612853Sgabeblack@google.comsc_fxnum_fast_bitref::operator &= (const sc_bit &b) 146712853Sgabeblack@google.com{ 146812853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(m_num) 146912853Sgabeblack@google.com set(get() && static_cast<bool>(b)); 147012853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) 147112853Sgabeblack@google.com return *this; 147212853Sgabeblack@google.com} 147312853Sgabeblack@google.com 147412853Sgabeblack@google.cominline sc_fxnum_fast_bitref & 147512853Sgabeblack@google.comsc_fxnum_fast_bitref::operator &= (bool b) 147612853Sgabeblack@google.com{ 147712853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(m_num) 147812853Sgabeblack@google.com set(get() && b); 147912853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) 148012853Sgabeblack@google.com return *this; 148112853Sgabeblack@google.com} 148212853Sgabeblack@google.com 148312853Sgabeblack@google.com 148412853Sgabeblack@google.cominline sc_fxnum_fast_bitref & 148512853Sgabeblack@google.comsc_fxnum_fast_bitref::operator |= (const sc_fxnum_bitref &b) 148612853Sgabeblack@google.com{ 148712853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(m_num) 148812853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(b.m_num) 148912853Sgabeblack@google.com set(get() || b.get()); 149012853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) 149112853Sgabeblack@google.com return *this; 149212853Sgabeblack@google.com} 149312853Sgabeblack@google.com 149412853Sgabeblack@google.cominline sc_fxnum_fast_bitref & 149512853Sgabeblack@google.comsc_fxnum_fast_bitref::operator |= (const sc_fxnum_fast_bitref &b) 149612853Sgabeblack@google.com{ 149712853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(m_num) 149812853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(b.m_num) 149912853Sgabeblack@google.com set(get() || b.get()); 150012853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) 150112853Sgabeblack@google.com return *this; 150212853Sgabeblack@google.com} 150312853Sgabeblack@google.com 150412853Sgabeblack@google.cominline sc_fxnum_fast_bitref & 150512853Sgabeblack@google.comsc_fxnum_fast_bitref::operator |= (const sc_bit &b) 150612853Sgabeblack@google.com{ 150712853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(m_num) 150812853Sgabeblack@google.com set(get() || static_cast<bool>(b)); 150912853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) 151012853Sgabeblack@google.com return *this; 151112853Sgabeblack@google.com} 151212853Sgabeblack@google.com 151312853Sgabeblack@google.cominline sc_fxnum_fast_bitref & 151412853Sgabeblack@google.comsc_fxnum_fast_bitref::operator |= (bool b) 151512853Sgabeblack@google.com{ 151612853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(m_num) 151712853Sgabeblack@google.com set(get() || b); 151812853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) 151912853Sgabeblack@google.com return *this; 152012853Sgabeblack@google.com} 152112853Sgabeblack@google.com 152212853Sgabeblack@google.com 152312853Sgabeblack@google.cominline sc_fxnum_fast_bitref & 152412853Sgabeblack@google.comsc_fxnum_fast_bitref::operator ^= (const sc_fxnum_bitref &b) 152512853Sgabeblack@google.com{ 152612853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(m_num) 152712853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(b.m_num) 152812853Sgabeblack@google.com set(get() != b.get()); 152912853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) 153012853Sgabeblack@google.com return *this; 153112853Sgabeblack@google.com} 153212853Sgabeblack@google.com 153312853Sgabeblack@google.cominline sc_fxnum_fast_bitref & 153412853Sgabeblack@google.comsc_fxnum_fast_bitref::operator ^= (const sc_fxnum_fast_bitref &b) 153512853Sgabeblack@google.com{ 153612853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(m_num) 153712853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(b.m_num) 153812853Sgabeblack@google.com set(get() != b.get()); 153912853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) 154012853Sgabeblack@google.com return *this; 154112853Sgabeblack@google.com} 154212853Sgabeblack@google.com 154312853Sgabeblack@google.cominline sc_fxnum_fast_bitref & 154412853Sgabeblack@google.comsc_fxnum_fast_bitref::operator ^= (const sc_bit &b) 154512853Sgabeblack@google.com{ 154612853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(m_num) 154712853Sgabeblack@google.com set(get() != static_cast<bool>(b)); 154812853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) 154912853Sgabeblack@google.com return *this; 155012853Sgabeblack@google.com} 155112853Sgabeblack@google.com 155212853Sgabeblack@google.cominline sc_fxnum_fast_bitref & 155312853Sgabeblack@google.comsc_fxnum_fast_bitref::operator ^= (bool b) 155412853Sgabeblack@google.com{ 155512853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(m_num) 155612853Sgabeblack@google.com set(get() != b); 155712853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) 155812853Sgabeblack@google.com return *this; 155912853Sgabeblack@google.com} 156012853Sgabeblack@google.com 156112853Sgabeblack@google.com 156212853Sgabeblack@google.com// implicit conversion 156312853Sgabeblack@google.cominline sc_fxnum_fast_bitref::operator bool() const 156412853Sgabeblack@google.com{ 156512853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(m_num) 156612853Sgabeblack@google.com return get(); 156712853Sgabeblack@google.com} 156812853Sgabeblack@google.com 156912853Sgabeblack@google.cominline ::std::ostream & 157012853Sgabeblack@google.comoperator << (::std::ostream &os, const sc_fxnum_fast_bitref &a) 157112853Sgabeblack@google.com{ 157212853Sgabeblack@google.com a.print(os); 157312853Sgabeblack@google.com return os; 157412853Sgabeblack@google.com} 157512853Sgabeblack@google.com 157612853Sgabeblack@google.cominline ::std::istream & 157712853Sgabeblack@google.comoperator >> (::std::istream &is, sc_fxnum_fast_bitref &a) 157812853Sgabeblack@google.com{ 157912853Sgabeblack@google.com a.scan(is); 158012853Sgabeblack@google.com return is; 158112853Sgabeblack@google.com} 158212853Sgabeblack@google.com 158312853Sgabeblack@google.com 158412853Sgabeblack@google.com// ---------------------------------------------------------------------------- 158512853Sgabeblack@google.com// CLASS : sc_fxnum_subref 158612853Sgabeblack@google.com// 158712853Sgabeblack@google.com// Proxy class for part-selection in class sc_fxnum, 158812853Sgabeblack@google.com// behaves like sc_bv_base. 158912853Sgabeblack@google.com// ---------------------------------------------------------------------------- 159012853Sgabeblack@google.com 159112853Sgabeblack@google.com// constructor 159212853Sgabeblack@google.cominline sc_fxnum_subref::sc_fxnum_subref(sc_fxnum &num_, int from_, int to_) : 159312853Sgabeblack@google.com m_num(num_), m_from(from_), m_to(to_), 159412853Sgabeblack@google.com m_bv(*new sc_bv_base(sc_max(m_from, m_to) - sc_min(m_from, m_to) + 1)) 159512853Sgabeblack@google.com{} 159612853Sgabeblack@google.com 159712853Sgabeblack@google.com// copy constructor 159812853Sgabeblack@google.cominline sc_fxnum_subref::sc_fxnum_subref(const sc_fxnum_subref &a) : 159912853Sgabeblack@google.com m_num(a.m_num), m_from(a.m_from), m_to(a.m_to), 160012853Sgabeblack@google.com m_bv(*new sc_bv_base(a.m_bv)) 160112853Sgabeblack@google.com{} 160212853Sgabeblack@google.com 160312853Sgabeblack@google.com// destructor 160412853Sgabeblack@google.cominline sc_fxnum_subref::~sc_fxnum_subref() 160512853Sgabeblack@google.com{ 160612853Sgabeblack@google.com delete &m_bv; 160712853Sgabeblack@google.com} 160812853Sgabeblack@google.com 160912853Sgabeblack@google.com// assignment operators 161012853Sgabeblack@google.cominline sc_fxnum_subref & 161112853Sgabeblack@google.comsc_fxnum_subref::operator = (const sc_fxnum_subref &a) 161212853Sgabeblack@google.com{ 161312853Sgabeblack@google.com if (&a != this) { 161412853Sgabeblack@google.com m_bv = static_cast<sc_bv_base>(a); 161512853Sgabeblack@google.com set(); 161612853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(m_num) 161712853Sgabeblack@google.com } 161812853Sgabeblack@google.com return *this; 161912853Sgabeblack@google.com} 162012853Sgabeblack@google.com 162112853Sgabeblack@google.cominline sc_fxnum_subref & 162212853Sgabeblack@google.comsc_fxnum_subref::operator = (const sc_fxnum_fast_subref &a) 162312853Sgabeblack@google.com{ 162412853Sgabeblack@google.com m_bv = static_cast<sc_bv_base>(a); 162512853Sgabeblack@google.com set(); 162612853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(m_num) 162712853Sgabeblack@google.com return *this; 162812853Sgabeblack@google.com} 162912853Sgabeblack@google.com 163012853Sgabeblack@google.com#define DEFN_ASN_OP_T(tp) \ 163112853Sgabeblack@google.cominline sc_fxnum_subref & \ 163212853Sgabeblack@google.comsc_fxnum_subref::operator = (tp a) \ 163312853Sgabeblack@google.com{ \ 163412853Sgabeblack@google.com m_bv = a; \ 163512853Sgabeblack@google.com set(); \ 163612853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(m_num) \ 163712853Sgabeblack@google.com return *this; \ 163812853Sgabeblack@google.com} 163912853Sgabeblack@google.com 164012853Sgabeblack@google.comDEFN_ASN_OP_T(const sc_bv_base &) 164112853Sgabeblack@google.comDEFN_ASN_OP_T(const sc_lv_base &) 164212853Sgabeblack@google.comDEFN_ASN_OP_T(const char *) 164312853Sgabeblack@google.comDEFN_ASN_OP_T(const bool *) 164412853Sgabeblack@google.comDEFN_ASN_OP_T(const sc_signed &) 164512853Sgabeblack@google.comDEFN_ASN_OP_T(const sc_unsigned &) 164612853Sgabeblack@google.comDEFN_ASN_OP_T(const sc_int_base &) 164712853Sgabeblack@google.comDEFN_ASN_OP_T(const sc_uint_base &) 164812853Sgabeblack@google.comDEFN_ASN_OP_T(int64) 164912853Sgabeblack@google.comDEFN_ASN_OP_T(uint64) 165012853Sgabeblack@google.comDEFN_ASN_OP_T(int) 165112853Sgabeblack@google.comDEFN_ASN_OP_T(unsigned int) 165212853Sgabeblack@google.comDEFN_ASN_OP_T(long) 165312853Sgabeblack@google.comDEFN_ASN_OP_T(unsigned long) 165412853Sgabeblack@google.comDEFN_ASN_OP_T(char) 165512853Sgabeblack@google.com 165612853Sgabeblack@google.com#undef DEFN_ASN_OP_T 165712853Sgabeblack@google.com 165812853Sgabeblack@google.com#define DEFN_ASN_OP_T(op, tp) \ 165912853Sgabeblack@google.cominline sc_fxnum_subref & \ 166012853Sgabeblack@google.comsc_fxnum_subref::operator op ## = (tp a) \ 166112853Sgabeblack@google.com{ \ 166212853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(m_num) \ 166312853Sgabeblack@google.com get(); \ 166412853Sgabeblack@google.com m_bv = m_bv op a; \ 166512853Sgabeblack@google.com set(); \ 166612853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(m_num) \ 166712853Sgabeblack@google.com return *this; \ 166812853Sgabeblack@google.com} 166912853Sgabeblack@google.com 167012853Sgabeblack@google.com#define DEFN_ASN_OP(op) \ 167112853Sgabeblack@google.cominline sc_fxnum_subref & \ 167212853Sgabeblack@google.comsc_fxnum_subref::operator op ## = (const sc_fxnum_subref &a) \ 167312853Sgabeblack@google.com{ \ 167412853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(m_num) \ 167512853Sgabeblack@google.com get(); \ 167612853Sgabeblack@google.com m_bv = m_bv op static_cast<sc_bv_base>(a); \ 167712853Sgabeblack@google.com set(); \ 167812853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(m_num) \ 167912853Sgabeblack@google.com return *this; \ 168012853Sgabeblack@google.com} \ 168112853Sgabeblack@google.com \ 168212853Sgabeblack@google.cominline sc_fxnum_subref & \ 168312853Sgabeblack@google.comsc_fxnum_subref::operator op ## = (const sc_fxnum_fast_subref &a) \ 168412853Sgabeblack@google.com{ \ 168512853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(m_num) \ 168612853Sgabeblack@google.com get(); \ 168712853Sgabeblack@google.com m_bv = m_bv op static_cast<sc_bv_base>(a); \ 168812853Sgabeblack@google.com set(); \ 168912853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(m_num) \ 169012853Sgabeblack@google.com return *this; \ 169112853Sgabeblack@google.com} \ 169212853Sgabeblack@google.com \ 169312853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_bv_base &) \ 169412853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_lv_base &) 169512853Sgabeblack@google.com 169612853Sgabeblack@google.comDEFN_ASN_OP( &) 169712853Sgabeblack@google.comDEFN_ASN_OP(|) 169812853Sgabeblack@google.comDEFN_ASN_OP(^) 169912853Sgabeblack@google.com 170012853Sgabeblack@google.com#undef DEFN_ASN_OP_T 170112853Sgabeblack@google.com#undef DEFN_ASN_OP 170212853Sgabeblack@google.com 170312853Sgabeblack@google.com// relational operators 170412853Sgabeblack@google.com#define DEFN_REL_OP_T(op, tp) \ 170512853Sgabeblack@google.cominline bool \ 170612853Sgabeblack@google.comoperator op (const sc_fxnum_subref &a, tp b) \ 170712853Sgabeblack@google.com{ \ 170812853Sgabeblack@google.com return (static_cast<sc_bv_base>(a) op b); \ 170912853Sgabeblack@google.com} \ 171012853Sgabeblack@google.com \ 171112853Sgabeblack@google.cominline bool \ 171212853Sgabeblack@google.comoperator op (tp a, const sc_fxnum_subref &b) \ 171312853Sgabeblack@google.com{ \ 171412853Sgabeblack@google.com return (static_cast<sc_bv_base>(b) op a); \ 171512853Sgabeblack@google.com} 171612853Sgabeblack@google.com 171712853Sgabeblack@google.com#define DEFN_REL_OP(op) \ 171812853Sgabeblack@google.cominline bool \ 171912853Sgabeblack@google.comoperator op (const sc_fxnum_subref &a, const sc_fxnum_subref &b) \ 172012853Sgabeblack@google.com{ \ 172112853Sgabeblack@google.com return (static_cast<sc_bv_base>(a) op static_cast<sc_bv_base>(b)); \ 172212853Sgabeblack@google.com} \ 172312853Sgabeblack@google.com \ 172412853Sgabeblack@google.cominline bool \ 172512853Sgabeblack@google.comoperator op (const sc_fxnum_subref &a, const sc_fxnum_fast_subref &b) \ 172612853Sgabeblack@google.com{ \ 172712853Sgabeblack@google.com return (static_cast<sc_bv_base>(a) op static_cast<sc_bv_base>(b)); \ 172812853Sgabeblack@google.com} \ 172912853Sgabeblack@google.com \ 173012853Sgabeblack@google.comDEFN_REL_OP_T(op, const sc_bv_base &) \ 173112853Sgabeblack@google.comDEFN_REL_OP_T(op, const sc_lv_base &) \ 173212853Sgabeblack@google.comDEFN_REL_OP_T(op, const char *) \ 173312853Sgabeblack@google.comDEFN_REL_OP_T(op, const bool *) \ 173412853Sgabeblack@google.comDEFN_REL_OP_T(op, const sc_signed &) \ 173512853Sgabeblack@google.comDEFN_REL_OP_T(op, const sc_unsigned &) \ 173612853Sgabeblack@google.comDEFN_REL_OP_T(op, int) \ 173712853Sgabeblack@google.comDEFN_REL_OP_T(op, unsigned int) \ 173812853Sgabeblack@google.comDEFN_REL_OP_T(op, long) \ 173912853Sgabeblack@google.comDEFN_REL_OP_T(op, unsigned long) 174012853Sgabeblack@google.com 174112853Sgabeblack@google.comDEFN_REL_OP(==) 174212853Sgabeblack@google.comDEFN_REL_OP(!=) 174312853Sgabeblack@google.com 174412853Sgabeblack@google.com#undef DEFN_REL_OP_T 174512853Sgabeblack@google.com#undef DEFN_REL_OP 174612853Sgabeblack@google.com 174712853Sgabeblack@google.com 174812853Sgabeblack@google.com// reduce functions 174912853Sgabeblack@google.com 175012853Sgabeblack@google.com#define DEFN_RED_FNC(fnc) \ 175112853Sgabeblack@google.cominline bool \ 175212853Sgabeblack@google.comsc_fxnum_subref::fnc() const \ 175312853Sgabeblack@google.com{ \ 175412853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(m_num) \ 175512853Sgabeblack@google.com get(); \ 175612853Sgabeblack@google.com return static_cast<bool>(m_bv.fnc()); \ 175712853Sgabeblack@google.com} 175812853Sgabeblack@google.com 175912853Sgabeblack@google.comDEFN_RED_FNC(and_reduce) 176012853Sgabeblack@google.comDEFN_RED_FNC(nand_reduce) 176112853Sgabeblack@google.comDEFN_RED_FNC(or_reduce) 176212853Sgabeblack@google.comDEFN_RED_FNC(nor_reduce) 176312853Sgabeblack@google.comDEFN_RED_FNC(xor_reduce) 176412853Sgabeblack@google.comDEFN_RED_FNC(xnor_reduce) 176512853Sgabeblack@google.com 176612853Sgabeblack@google.com#undef DEFN_RED_FNC 176712853Sgabeblack@google.com 176812853Sgabeblack@google.com// query parameter 176912853Sgabeblack@google.cominline int 177012853Sgabeblack@google.comsc_fxnum_subref::length() const 177112853Sgabeblack@google.com{ 177212853Sgabeblack@google.com return m_bv.length(); 177312853Sgabeblack@google.com} 177412853Sgabeblack@google.com 177512853Sgabeblack@google.com// explicit conversions 177612853Sgabeblack@google.cominline int 177712853Sgabeblack@google.comsc_fxnum_subref::to_int() const 177812853Sgabeblack@google.com{ 177912853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(m_num) 178012853Sgabeblack@google.com get(); 178112853Sgabeblack@google.com return m_bv.to_int(); 178212853Sgabeblack@google.com} 178312853Sgabeblack@google.com 178412853Sgabeblack@google.cominline int64 178512853Sgabeblack@google.comsc_fxnum_subref::to_int64() const 178612853Sgabeblack@google.com{ 178712853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(m_num) 178812853Sgabeblack@google.com get(); 178912853Sgabeblack@google.com return m_bv.to_int64(); 179012853Sgabeblack@google.com} 179112853Sgabeblack@google.com 179212853Sgabeblack@google.cominline unsigned int 179312853Sgabeblack@google.comsc_fxnum_subref::to_uint() const 179412853Sgabeblack@google.com{ 179512853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(m_num) 179612853Sgabeblack@google.com get(); 179712853Sgabeblack@google.com return m_bv.to_uint(); 179812853Sgabeblack@google.com} 179912853Sgabeblack@google.com 180012853Sgabeblack@google.cominline uint64 180112853Sgabeblack@google.comsc_fxnum_subref::to_uint64() const 180212853Sgabeblack@google.com{ 180312853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(m_num) 180412853Sgabeblack@google.com get(); 180512853Sgabeblack@google.com return m_bv.to_uint64(); 180612853Sgabeblack@google.com} 180712853Sgabeblack@google.com 180812853Sgabeblack@google.cominline long 180912853Sgabeblack@google.comsc_fxnum_subref::to_long() const 181012853Sgabeblack@google.com{ 181112853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(m_num) 181212853Sgabeblack@google.com get(); 181312853Sgabeblack@google.com return m_bv.to_long(); 181412853Sgabeblack@google.com} 181512853Sgabeblack@google.com 181612853Sgabeblack@google.cominline unsigned long 181712853Sgabeblack@google.comsc_fxnum_subref::to_ulong() const 181812853Sgabeblack@google.com{ 181912853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(m_num) 182012853Sgabeblack@google.com get(); 182112853Sgabeblack@google.com return m_bv.to_ulong(); 182212853Sgabeblack@google.com} 182312853Sgabeblack@google.com 182412853Sgabeblack@google.com 182512853Sgabeblack@google.cominline const std::string 182612853Sgabeblack@google.comsc_fxnum_subref::to_string() const 182712853Sgabeblack@google.com{ 182812853Sgabeblack@google.com get(); 182912853Sgabeblack@google.com return m_bv.to_string(); 183012853Sgabeblack@google.com} 183112853Sgabeblack@google.com 183212853Sgabeblack@google.cominline const std::string 183312853Sgabeblack@google.comsc_fxnum_subref::to_string(sc_numrep numrep) const 183412853Sgabeblack@google.com{ 183512853Sgabeblack@google.com get(); 183612853Sgabeblack@google.com return m_bv.to_string(numrep); 183712853Sgabeblack@google.com} 183812853Sgabeblack@google.com 183912853Sgabeblack@google.cominline const std::string 184012853Sgabeblack@google.comsc_fxnum_subref::to_string(sc_numrep numrep, bool w_prefix) const 184112853Sgabeblack@google.com{ 184212853Sgabeblack@google.com get(); 184312853Sgabeblack@google.com return m_bv.to_string(numrep, w_prefix); 184412853Sgabeblack@google.com} 184512853Sgabeblack@google.com 184612853Sgabeblack@google.com 184712853Sgabeblack@google.com// implicit conversion 184812853Sgabeblack@google.cominline sc_fxnum_subref::operator sc_bv_base () const 184912853Sgabeblack@google.com{ 185012853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(m_num) 185112853Sgabeblack@google.com get(); 185212853Sgabeblack@google.com return m_bv; 185312853Sgabeblack@google.com} 185412853Sgabeblack@google.com 185512853Sgabeblack@google.com 185612853Sgabeblack@google.cominline ::std::ostream & 185712853Sgabeblack@google.comoperator << (::std::ostream &os, const sc_fxnum_subref &a) 185812853Sgabeblack@google.com{ 185912853Sgabeblack@google.com a.print(os); 186012853Sgabeblack@google.com return os; 186112853Sgabeblack@google.com} 186212853Sgabeblack@google.com 186312853Sgabeblack@google.cominline ::std::istream & 186412853Sgabeblack@google.comoperator >> (::std::istream &is, sc_fxnum_subref &a) 186512853Sgabeblack@google.com{ 186612853Sgabeblack@google.com a.scan(is); 186712853Sgabeblack@google.com return is; 186812853Sgabeblack@google.com} 186912853Sgabeblack@google.com 187012853Sgabeblack@google.com 187112853Sgabeblack@google.com// ---------------------------------------------------------------------------- 187212853Sgabeblack@google.com// CLASS : sc_fxnum_fast_subref 187312853Sgabeblack@google.com// 187412853Sgabeblack@google.com// Proxy class for part-selection in class sc_fxnum_fast, 187512853Sgabeblack@google.com// behaves like sc_bv_base. 187612853Sgabeblack@google.com// ---------------------------------------------------------------------------- 187712853Sgabeblack@google.com 187812853Sgabeblack@google.com// constructor 187912853Sgabeblack@google.com 188012853Sgabeblack@google.cominline sc_fxnum_fast_subref::sc_fxnum_fast_subref( 188112853Sgabeblack@google.com sc_fxnum_fast &num_, int from_, int to_) : 188212853Sgabeblack@google.com m_num(num_), m_from(from_), m_to(to_), 188312853Sgabeblack@google.com m_bv(*new sc_bv_base(sc_max(m_from, m_to) - sc_min(m_from, m_to) + 1)) 188412853Sgabeblack@google.com{} 188512853Sgabeblack@google.com 188612853Sgabeblack@google.com 188712853Sgabeblack@google.com// copy constructor 188812853Sgabeblack@google.cominline sc_fxnum_fast_subref::sc_fxnum_fast_subref( 188912853Sgabeblack@google.com const sc_fxnum_fast_subref &a) : 189012853Sgabeblack@google.com m_num(a.m_num), m_from(a.m_from), m_to(a.m_to), 189112853Sgabeblack@google.com m_bv(*new sc_bv_base(a.m_bv)) 189212853Sgabeblack@google.com{} 189312853Sgabeblack@google.com 189412853Sgabeblack@google.com 189512853Sgabeblack@google.com// destructor 189612853Sgabeblack@google.cominline sc_fxnum_fast_subref::~sc_fxnum_fast_subref() 189712853Sgabeblack@google.com{ 189812853Sgabeblack@google.com delete &m_bv; 189912853Sgabeblack@google.com} 190012853Sgabeblack@google.com 190112853Sgabeblack@google.com 190212853Sgabeblack@google.com// assignment operators 190312853Sgabeblack@google.cominline sc_fxnum_fast_subref & 190412853Sgabeblack@google.comsc_fxnum_fast_subref::operator = (const sc_fxnum_subref &a) 190512853Sgabeblack@google.com{ 190612853Sgabeblack@google.com m_bv = static_cast<sc_bv_base>(a); 190712853Sgabeblack@google.com set(); 190812853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) 190912853Sgabeblack@google.com return *this; 191012853Sgabeblack@google.com} 191112853Sgabeblack@google.com 191212853Sgabeblack@google.cominline sc_fxnum_fast_subref & 191312853Sgabeblack@google.comsc_fxnum_fast_subref::operator = (const sc_fxnum_fast_subref &a) 191412853Sgabeblack@google.com{ 191512853Sgabeblack@google.com if (&a != this) { 191612853Sgabeblack@google.com m_bv = static_cast<sc_bv_base>(a); 191712853Sgabeblack@google.com set(); 191812853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) 191912853Sgabeblack@google.com } 192012853Sgabeblack@google.com return *this; 192112853Sgabeblack@google.com} 192212853Sgabeblack@google.com 192312853Sgabeblack@google.com#define DEFN_ASN_OP_T(tp) \ 192412853Sgabeblack@google.cominline sc_fxnum_fast_subref & \ 192512853Sgabeblack@google.comsc_fxnum_fast_subref::operator = (tp a) \ 192612853Sgabeblack@google.com{ \ 192712853Sgabeblack@google.com m_bv = a; \ 192812853Sgabeblack@google.com set(); \ 192912853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) \ 193012853Sgabeblack@google.com return *this; \ 193112853Sgabeblack@google.com} 193212853Sgabeblack@google.com 193312853Sgabeblack@google.comDEFN_ASN_OP_T(const sc_bv_base &) 193412853Sgabeblack@google.comDEFN_ASN_OP_T(const sc_lv_base &) 193512853Sgabeblack@google.comDEFN_ASN_OP_T(const char *) 193612853Sgabeblack@google.comDEFN_ASN_OP_T(const bool *) 193712853Sgabeblack@google.comDEFN_ASN_OP_T(const sc_signed &) 193812853Sgabeblack@google.comDEFN_ASN_OP_T(const sc_unsigned &) 193912853Sgabeblack@google.comDEFN_ASN_OP_T(const sc_int_base &) 194012853Sgabeblack@google.comDEFN_ASN_OP_T(const sc_uint_base &) 194112853Sgabeblack@google.comDEFN_ASN_OP_T(int64) 194212853Sgabeblack@google.comDEFN_ASN_OP_T(uint64) 194312853Sgabeblack@google.comDEFN_ASN_OP_T(int) 194412853Sgabeblack@google.comDEFN_ASN_OP_T(unsigned int) 194512853Sgabeblack@google.comDEFN_ASN_OP_T(long) 194612853Sgabeblack@google.comDEFN_ASN_OP_T(unsigned long) 194712853Sgabeblack@google.comDEFN_ASN_OP_T(char) 194812853Sgabeblack@google.com 194912853Sgabeblack@google.com#undef DEFN_ASN_OP_T 195012853Sgabeblack@google.com 195112853Sgabeblack@google.com 195212853Sgabeblack@google.com#define DEFN_ASN_OP_T(op, tp) \ 195312853Sgabeblack@google.cominline sc_fxnum_fast_subref & \ 195412853Sgabeblack@google.comsc_fxnum_fast_subref::operator op ## = (tp a) \ 195512853Sgabeblack@google.com{ \ 195612853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(m_num) \ 195712853Sgabeblack@google.com get(); \ 195812853Sgabeblack@google.com m_bv = m_bv op a; \ 195912853Sgabeblack@google.com set(); \ 196012853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) \ 196112853Sgabeblack@google.com return *this; \ 196212853Sgabeblack@google.com} 196312853Sgabeblack@google.com 196412853Sgabeblack@google.com#define DEFN_ASN_OP(op) \ 196512853Sgabeblack@google.cominline sc_fxnum_fast_subref & \ 196612853Sgabeblack@google.comsc_fxnum_fast_subref::operator op ## = (const sc_fxnum_subref &a) \ 196712853Sgabeblack@google.com{ \ 196812853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(m_num) \ 196912853Sgabeblack@google.com get(); \ 197012853Sgabeblack@google.com m_bv = m_bv op static_cast<sc_bv_base>(a); \ 197112853Sgabeblack@google.com set(); \ 197212853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) \ 197312853Sgabeblack@google.com return *this; \ 197412853Sgabeblack@google.com} \ 197512853Sgabeblack@google.com \ 197612853Sgabeblack@google.cominline sc_fxnum_fast_subref & \ 197712853Sgabeblack@google.comsc_fxnum_fast_subref::operator op ## = (const sc_fxnum_fast_subref &a) \ 197812853Sgabeblack@google.com{ \ 197912853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(m_num) \ 198012853Sgabeblack@google.com get(); \ 198112853Sgabeblack@google.com m_bv = m_bv op static_cast<sc_bv_base>(a); \ 198212853Sgabeblack@google.com set(); \ 198312853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(m_num) \ 198412853Sgabeblack@google.com return *this; \ 198512853Sgabeblack@google.com} \ 198612853Sgabeblack@google.com \ 198712853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_bv_base &) \ 198812853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_lv_base &) 198912853Sgabeblack@google.com 199012853Sgabeblack@google.comDEFN_ASN_OP(&) 199112853Sgabeblack@google.comDEFN_ASN_OP(|) 199212853Sgabeblack@google.comDEFN_ASN_OP(^) 199312853Sgabeblack@google.com 199412853Sgabeblack@google.com#undef DEFN_ASN_OP_T 199512853Sgabeblack@google.com#undef DEFN_ASN_OP 199612853Sgabeblack@google.com 199712853Sgabeblack@google.com 199812853Sgabeblack@google.com// relational operators 199912853Sgabeblack@google.com 200012853Sgabeblack@google.com#define DEFN_REL_OP_T(op, tp) \ 200112853Sgabeblack@google.cominline bool \ 200212853Sgabeblack@google.comoperator op (const sc_fxnum_fast_subref &a, tp b) \ 200312853Sgabeblack@google.com{ \ 200412853Sgabeblack@google.com return (static_cast<sc_bv_base>(a) op b); \ 200512853Sgabeblack@google.com} \ 200612853Sgabeblack@google.com \ 200712853Sgabeblack@google.cominline bool \ 200812853Sgabeblack@google.comoperator op (tp a, const sc_fxnum_fast_subref &b) \ 200912853Sgabeblack@google.com{ \ 201012853Sgabeblack@google.com return (static_cast<sc_bv_base>(b) op a); \ 201112853Sgabeblack@google.com} 201212853Sgabeblack@google.com 201312853Sgabeblack@google.com#define DEFN_REL_OP(op) \ 201412853Sgabeblack@google.cominline bool \ 201512853Sgabeblack@google.comoperator op (const sc_fxnum_fast_subref &a, const sc_fxnum_fast_subref &b) \ 201612853Sgabeblack@google.com{ \ 201712853Sgabeblack@google.com return (static_cast<sc_bv_base>(a) op static_cast<sc_bv_base>(b)); \ 201812853Sgabeblack@google.com} \ 201912853Sgabeblack@google.com \ 202012853Sgabeblack@google.cominline bool \ 202112853Sgabeblack@google.comoperator op (const sc_fxnum_fast_subref &a, const sc_fxnum_subref &b) \ 202212853Sgabeblack@google.com{ \ 202312853Sgabeblack@google.com return (static_cast<sc_bv_base>(a) op static_cast<sc_bv_base>(b)); \ 202412853Sgabeblack@google.com} \ 202512853Sgabeblack@google.com \ 202612853Sgabeblack@google.comDEFN_REL_OP_T(op, const sc_bv_base &) \ 202712853Sgabeblack@google.comDEFN_REL_OP_T(op, const sc_lv_base &) \ 202812853Sgabeblack@google.comDEFN_REL_OP_T(op, const char *) \ 202912853Sgabeblack@google.comDEFN_REL_OP_T(op, const bool *) \ 203012853Sgabeblack@google.comDEFN_REL_OP_T(op, const sc_signed &) \ 203112853Sgabeblack@google.comDEFN_REL_OP_T(op, const sc_unsigned &) \ 203212853Sgabeblack@google.comDEFN_REL_OP_T(op, int) \ 203312853Sgabeblack@google.comDEFN_REL_OP_T(op, unsigned int) \ 203412853Sgabeblack@google.comDEFN_REL_OP_T(op, long) \ 203512853Sgabeblack@google.comDEFN_REL_OP_T(op, unsigned long) 203612853Sgabeblack@google.com 203712853Sgabeblack@google.comDEFN_REL_OP(==) 203812853Sgabeblack@google.comDEFN_REL_OP(!=) 203912853Sgabeblack@google.com 204012853Sgabeblack@google.com#undef DEFN_REL_OP_T 204112853Sgabeblack@google.com#undef DEFN_REL_OP 204212853Sgabeblack@google.com 204312853Sgabeblack@google.com// reduce functions 204412853Sgabeblack@google.com#define DEFN_RED_FNC(fnc) \ 204512853Sgabeblack@google.cominline bool \ 204612853Sgabeblack@google.comsc_fxnum_fast_subref::fnc() const \ 204712853Sgabeblack@google.com{ \ 204812853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(m_num) \ 204912853Sgabeblack@google.com get(); \ 205012853Sgabeblack@google.com return static_cast<bool>(m_bv.fnc()); \ 205112853Sgabeblack@google.com} 205212853Sgabeblack@google.com 205312853Sgabeblack@google.comDEFN_RED_FNC(and_reduce) 205412853Sgabeblack@google.comDEFN_RED_FNC(nand_reduce) 205512853Sgabeblack@google.comDEFN_RED_FNC(or_reduce) 205612853Sgabeblack@google.comDEFN_RED_FNC(nor_reduce) 205712853Sgabeblack@google.comDEFN_RED_FNC(xor_reduce) 205812853Sgabeblack@google.comDEFN_RED_FNC(xnor_reduce) 205912853Sgabeblack@google.com 206012853Sgabeblack@google.com#undef DEFN_RED_FNC 206112853Sgabeblack@google.com 206212853Sgabeblack@google.com// query parameter 206312853Sgabeblack@google.cominline int 206412853Sgabeblack@google.comsc_fxnum_fast_subref::length() const 206512853Sgabeblack@google.com{ 206612853Sgabeblack@google.com return m_bv.length(); 206712853Sgabeblack@google.com} 206812853Sgabeblack@google.com 206912853Sgabeblack@google.com// explicit conversions 207012853Sgabeblack@google.cominline int 207112853Sgabeblack@google.comsc_fxnum_fast_subref::to_int() const 207212853Sgabeblack@google.com{ 207312853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(m_num) 207412853Sgabeblack@google.com get(); 207512853Sgabeblack@google.com return m_bv.to_int(); 207612853Sgabeblack@google.com} 207712853Sgabeblack@google.com 207812853Sgabeblack@google.cominline int64 207912853Sgabeblack@google.comsc_fxnum_fast_subref::to_int64() const 208012853Sgabeblack@google.com{ 208112853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(m_num) 208212853Sgabeblack@google.com get(); 208312853Sgabeblack@google.com return m_bv.to_int64(); 208412853Sgabeblack@google.com} 208512853Sgabeblack@google.com 208612853Sgabeblack@google.cominline unsigned int 208712853Sgabeblack@google.comsc_fxnum_fast_subref::to_uint() const 208812853Sgabeblack@google.com{ 208912853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(m_num) 209012853Sgabeblack@google.com get(); 209112853Sgabeblack@google.com return m_bv.to_uint(); 209212853Sgabeblack@google.com} 209312853Sgabeblack@google.com 209412853Sgabeblack@google.cominline uint64 209512853Sgabeblack@google.comsc_fxnum_fast_subref::to_uint64() const 209612853Sgabeblack@google.com{ 209712853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(m_num) 209812853Sgabeblack@google.com get(); 209912853Sgabeblack@google.com return m_bv.to_uint64(); 210012853Sgabeblack@google.com} 210112853Sgabeblack@google.com 210212853Sgabeblack@google.cominline long 210312853Sgabeblack@google.comsc_fxnum_fast_subref::to_long() const 210412853Sgabeblack@google.com{ 210512853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(m_num) 210612853Sgabeblack@google.com get(); 210712853Sgabeblack@google.com return m_bv.to_long(); 210812853Sgabeblack@google.com} 210912853Sgabeblack@google.com 211012853Sgabeblack@google.cominline unsigned long 211112853Sgabeblack@google.comsc_fxnum_fast_subref::to_ulong() const 211212853Sgabeblack@google.com{ 211312853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(m_num) 211412853Sgabeblack@google.com get(); 211512853Sgabeblack@google.com return m_bv.to_ulong(); 211612853Sgabeblack@google.com} 211712853Sgabeblack@google.com 211812853Sgabeblack@google.cominline const std::string 211912853Sgabeblack@google.comsc_fxnum_fast_subref::to_string() const 212012853Sgabeblack@google.com{ 212112853Sgabeblack@google.com get(); 212212853Sgabeblack@google.com return m_bv.to_string(); 212312853Sgabeblack@google.com} 212412853Sgabeblack@google.com 212512853Sgabeblack@google.cominline const std::string 212612853Sgabeblack@google.comsc_fxnum_fast_subref::to_string(sc_numrep numrep) const 212712853Sgabeblack@google.com{ 212812853Sgabeblack@google.com get(); 212912853Sgabeblack@google.com return m_bv.to_string(numrep); 213012853Sgabeblack@google.com} 213112853Sgabeblack@google.com 213212853Sgabeblack@google.cominline const std::string 213312853Sgabeblack@google.comsc_fxnum_fast_subref::to_string(sc_numrep numrep, bool w_prefix) const 213412853Sgabeblack@google.com{ 213512853Sgabeblack@google.com get(); 213612853Sgabeblack@google.com return m_bv.to_string(numrep, w_prefix); 213712853Sgabeblack@google.com} 213812853Sgabeblack@google.com 213912853Sgabeblack@google.com 214012853Sgabeblack@google.com// implicit conversion 214112853Sgabeblack@google.cominline sc_fxnum_fast_subref::operator sc_bv_base () const 214212853Sgabeblack@google.com{ 214312853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(m_num) 214412853Sgabeblack@google.com get(); 214512853Sgabeblack@google.com return m_bv; 214612853Sgabeblack@google.com} 214712853Sgabeblack@google.com 214812853Sgabeblack@google.cominline ::std::ostream & 214912853Sgabeblack@google.comoperator << (::std::ostream &os, const sc_fxnum_fast_subref &a) 215012853Sgabeblack@google.com{ 215112853Sgabeblack@google.com a.print(os); 215212853Sgabeblack@google.com return os; 215312853Sgabeblack@google.com} 215412853Sgabeblack@google.com 215512853Sgabeblack@google.cominline ::std::istream & 215612853Sgabeblack@google.comoperator >> (::std::istream &is, sc_fxnum_fast_subref &a) 215712853Sgabeblack@google.com{ 215812853Sgabeblack@google.com a.scan(is); 215912853Sgabeblack@google.com return is; 216012853Sgabeblack@google.com} 216112853Sgabeblack@google.com 216212853Sgabeblack@google.com 216312853Sgabeblack@google.com// ---------------------------------------------------------------------------- 216412853Sgabeblack@google.com// CLASS : sc_fxnum 216512853Sgabeblack@google.com// 216612853Sgabeblack@google.com// Base class for the fixed-point types; arbitrary precision. 216712853Sgabeblack@google.com// ---------------------------------------------------------------------------- 216812853Sgabeblack@google.com 216912853Sgabeblack@google.cominline sc_fxnum_observer * 217012853Sgabeblack@google.comsc_fxnum::observer() const 217112853Sgabeblack@google.com{ 217212853Sgabeblack@google.com return m_observer; 217312853Sgabeblack@google.com} 217412853Sgabeblack@google.com 217512853Sgabeblack@google.cominline void 217612853Sgabeblack@google.comsc_fxnum::cast() 217712853Sgabeblack@google.com{ 217813325Sgabeblack@google.com SC_ERROR_IF_(!m_rep->is_normal(), sc_core::SC_ID_INVALID_FX_VALUE_); 217912853Sgabeblack@google.com 218012853Sgabeblack@google.com if (m_params.cast_switch() == SC_ON) 218112853Sgabeblack@google.com m_rep->cast(m_params, m_q_flag, m_o_flag); 218212853Sgabeblack@google.com} 218312853Sgabeblack@google.com 218412853Sgabeblack@google.com// constructors 218512853Sgabeblack@google.cominline sc_fxnum::sc_fxnum(const sc_fxtype_params &type_params_, 218612853Sgabeblack@google.com sc_enc enc_, const sc_fxcast_switch &cast_sw, 218712853Sgabeblack@google.com sc_fxnum_observer *observer_) : 218812853Sgabeblack@google.com m_rep(new scfx_rep), m_params(type_params_, enc_, cast_sw), 218912853Sgabeblack@google.com m_q_flag(false), m_o_flag(false), m_observer(observer_) 219012853Sgabeblack@google.com{ 219112853Sgabeblack@google.com SC_FXNUM_OBSERVER_DEFAULT_ 219212853Sgabeblack@google.com SC_FXNUM_OBSERVER_CONSTRUCT_(*this) 219312853Sgabeblack@google.com} 219412853Sgabeblack@google.com 219512853Sgabeblack@google.com#define DEFN_CTOR_T(tp, arg) \ 219612853Sgabeblack@google.cominline sc_fxnum::sc_fxnum(tp a, const sc_fxtype_params &type_params_, \ 219712853Sgabeblack@google.com sc_enc enc_, const sc_fxcast_switch &cast_sw, \ 219812853Sgabeblack@google.com sc_fxnum_observer *observer_) : \ 219912853Sgabeblack@google.com m_rep(new scfx_rep(arg)), m_params(type_params_, enc_, cast_sw), \ 220012853Sgabeblack@google.com m_q_flag(false), m_o_flag(false), m_observer(observer_) \ 220112853Sgabeblack@google.com{ \ 220212853Sgabeblack@google.com SC_FXNUM_OBSERVER_DEFAULT_ \ 220312853Sgabeblack@google.com cast(); \ 220412853Sgabeblack@google.com SC_FXNUM_OBSERVER_CONSTRUCT_(*this) \ 220512853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(*this) \ 220612853Sgabeblack@google.com} 220712853Sgabeblack@google.com 220812853Sgabeblack@google.com#define DEFN_CTOR_T_A(tp) DEFN_CTOR_T(tp, a) 220912853Sgabeblack@google.com#define DEFN_CTOR_T_B(tp) DEFN_CTOR_T(tp, *a.m_rep) 221012853Sgabeblack@google.com#define DEFN_CTOR_T_C(tp) DEFN_CTOR_T(tp, a.to_double()) 221112853Sgabeblack@google.com#define DEFN_CTOR_T_D(tp) DEFN_CTOR_T(tp, a.value()) 221212853Sgabeblack@google.com 221312853Sgabeblack@google.comDEFN_CTOR_T_A(int) 221412853Sgabeblack@google.comDEFN_CTOR_T_A(unsigned int) 221512853Sgabeblack@google.comDEFN_CTOR_T_A(long) 221612853Sgabeblack@google.comDEFN_CTOR_T_A(unsigned long) 221712853Sgabeblack@google.comDEFN_CTOR_T_A(float) 221812853Sgabeblack@google.comDEFN_CTOR_T_A(double) 221912853Sgabeblack@google.comDEFN_CTOR_T_A(const char *) 222012853Sgabeblack@google.comDEFN_CTOR_T_B(const sc_fxval &) 222112853Sgabeblack@google.comDEFN_CTOR_T_C(const sc_fxval_fast &) 222212853Sgabeblack@google.comDEFN_CTOR_T_B(const sc_fxnum &) 222312853Sgabeblack@google.comDEFN_CTOR_T_C(const sc_fxnum_fast &) 222412853Sgabeblack@google.com#ifndef SC_FX_EXCLUDE_OTHER 222512853Sgabeblack@google.comDEFN_CTOR_T_A(int64) 222612853Sgabeblack@google.comDEFN_CTOR_T_A(uint64) 222712853Sgabeblack@google.comDEFN_CTOR_T_D(const sc_int_base &) 222812853Sgabeblack@google.comDEFN_CTOR_T_D(const sc_uint_base &) 222912853Sgabeblack@google.comDEFN_CTOR_T_A(const sc_signed &) 223012853Sgabeblack@google.comDEFN_CTOR_T_A(const sc_unsigned &) 223112853Sgabeblack@google.com#endif 223212853Sgabeblack@google.com 223312853Sgabeblack@google.com#undef DEFN_CTOR_T 223412853Sgabeblack@google.com#undef DEFN_CTOR_T_A 223512853Sgabeblack@google.com#undef DEFN_CTOR_T_B 223612853Sgabeblack@google.com#undef DEFN_CTOR_T_C 223712853Sgabeblack@google.com#undef DEFN_CTOR_T_D 223812853Sgabeblack@google.com 223912853Sgabeblack@google.cominline sc_fxnum::~sc_fxnum() 224012853Sgabeblack@google.com{ 224112853Sgabeblack@google.com SC_FXNUM_OBSERVER_DESTRUCT_(*this) 224212853Sgabeblack@google.com delete m_rep; 224312853Sgabeblack@google.com} 224412853Sgabeblack@google.com 224512853Sgabeblack@google.com// internal use only; 224612853Sgabeblack@google.cominline const scfx_rep * 224712853Sgabeblack@google.comsc_fxnum::get_rep() const 224812853Sgabeblack@google.com{ 224912853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(*this) 225012853Sgabeblack@google.com return m_rep; 225112853Sgabeblack@google.com} 225212853Sgabeblack@google.com 225312853Sgabeblack@google.com// unary operators 225412853Sgabeblack@google.cominline const sc_fxval 225512853Sgabeblack@google.comsc_fxnum::operator - () const 225612853Sgabeblack@google.com{ 225712853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(*this) 225812853Sgabeblack@google.com return sc_fxval(sc_dt::neg_scfx_rep(*m_rep)); 225912853Sgabeblack@google.com} 226012853Sgabeblack@google.com 226112853Sgabeblack@google.cominline const sc_fxval 226212853Sgabeblack@google.comsc_fxnum::operator + () const 226312853Sgabeblack@google.com{ 226412853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(*this) 226512853Sgabeblack@google.com return sc_fxval(new scfx_rep(*m_rep)); 226612853Sgabeblack@google.com} 226712853Sgabeblack@google.com 226812853Sgabeblack@google.com// unary functions 226912853Sgabeblack@google.cominline void 227012853Sgabeblack@google.comneg(sc_fxval &c, const sc_fxnum &a) 227112853Sgabeblack@google.com{ 227212853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(a) 227312853Sgabeblack@google.com c.set_rep(sc_dt::neg_scfx_rep(*a.m_rep)); 227412853Sgabeblack@google.com} 227512853Sgabeblack@google.com 227612853Sgabeblack@google.cominline void 227712853Sgabeblack@google.comneg(sc_fxnum &c, const sc_fxnum &a) 227812853Sgabeblack@google.com{ 227912853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(a) 228012853Sgabeblack@google.com delete c.m_rep; 228112853Sgabeblack@google.com c.m_rep = sc_dt::neg_scfx_rep(*a.m_rep); 228212853Sgabeblack@google.com c.cast(); 228312853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(c) 228412853Sgabeblack@google.com} 228512853Sgabeblack@google.com 228612853Sgabeblack@google.com// binary operators 228712853Sgabeblack@google.com#define DEFN_BIN_OP_T(op, fnc, tp) \ 228812853Sgabeblack@google.cominline const sc_fxval \ 228912853Sgabeblack@google.comoperator op (const sc_fxnum &a, tp b) \ 229012853Sgabeblack@google.com{ \ 229112853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(a) \ 229212853Sgabeblack@google.com sc_fxval tmp(b); \ 229312853Sgabeblack@google.com return sc_fxval(sc_dt::fnc ## _scfx_rep(*a.m_rep, *tmp.get_rep())); \ 229412853Sgabeblack@google.com} \ 229512853Sgabeblack@google.com \ 229612853Sgabeblack@google.cominline const sc_fxval \ 229712853Sgabeblack@google.comoperator op (tp a, const sc_fxnum &b) \ 229812853Sgabeblack@google.com{ \ 229912853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(b) \ 230012853Sgabeblack@google.com sc_fxval tmp(a); \ 230112853Sgabeblack@google.com return sc_fxval(sc_dt::fnc ## _scfx_rep(*tmp.get_rep(), *b.m_rep)); \ 230212853Sgabeblack@google.com} 230312853Sgabeblack@google.com 230412853Sgabeblack@google.com#ifndef SC_FX_EXCLUDE_OTHER 230512853Sgabeblack@google.com#define DEFN_BIN_OP_OTHER(op, fnc) \ 230612853Sgabeblack@google.comDEFN_BIN_OP_T(op, fnc, int64) \ 230712853Sgabeblack@google.comDEFN_BIN_OP_T(op, fnc, uint64) \ 230812853Sgabeblack@google.comDEFN_BIN_OP_T(op, fnc, const sc_int_base &) \ 230912853Sgabeblack@google.comDEFN_BIN_OP_T(op, fnc, const sc_uint_base &) \ 231012853Sgabeblack@google.comDEFN_BIN_OP_T(op, fnc, const sc_signed &) \ 231112853Sgabeblack@google.comDEFN_BIN_OP_T(op, fnc, const sc_unsigned &) 231212853Sgabeblack@google.com#else 231312853Sgabeblack@google.com#define DEFN_BIN_OP_OTHER(op, fnc) 231412853Sgabeblack@google.com#endif 231512853Sgabeblack@google.com 231612853Sgabeblack@google.com#define DEFN_BIN_OP(op, fnc) \ 231712853Sgabeblack@google.cominline const sc_fxval \ 231812853Sgabeblack@google.comoperator op (const sc_fxnum &a, const sc_fxnum &b) \ 231912853Sgabeblack@google.com{ \ 232012853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(a) \ 232112853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(b) \ 232212853Sgabeblack@google.com return sc_fxval(sc_dt::fnc ## _scfx_rep(*a.m_rep, *b.m_rep)); \ 232312853Sgabeblack@google.com} \ 232412853Sgabeblack@google.com \ 232512853Sgabeblack@google.cominline const sc_fxval \ 232612853Sgabeblack@google.comoperator op (const sc_fxnum &a, const sc_fxval &b) \ 232712853Sgabeblack@google.com{ \ 232812853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(a) \ 232912853Sgabeblack@google.com return sc_fxval(sc_dt::fnc ## _scfx_rep(*a.m_rep, *b.get_rep())); \ 233012853Sgabeblack@google.com} \ 233112853Sgabeblack@google.com \ 233212853Sgabeblack@google.cominline const sc_fxval \ 233312853Sgabeblack@google.comoperator op (const sc_fxval &a, const sc_fxnum &b) \ 233412853Sgabeblack@google.com{ \ 233512853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(b) \ 233612853Sgabeblack@google.com return sc_fxval(sc_dt::fnc ## _scfx_rep(*a.get_rep(), *b.m_rep)); \ 233712853Sgabeblack@google.com} \ 233812853Sgabeblack@google.com \ 233912853Sgabeblack@google.comDEFN_BIN_OP_T(op, fnc, int) \ 234012853Sgabeblack@google.comDEFN_BIN_OP_T(op, fnc, unsigned int) \ 234112853Sgabeblack@google.comDEFN_BIN_OP_T(op, fnc, long) \ 234212853Sgabeblack@google.comDEFN_BIN_OP_T(op, fnc, unsigned long) \ 234312853Sgabeblack@google.comDEFN_BIN_OP_T(op, fnc, float) \ 234412853Sgabeblack@google.comDEFN_BIN_OP_T(op, fnc, double) \ 234512853Sgabeblack@google.comDEFN_BIN_OP_T(op, fnc, const char *) \ 234612853Sgabeblack@google.comDEFN_BIN_OP_T(op, fnc, const sc_fxval_fast &) \ 234712853Sgabeblack@google.comDEFN_BIN_OP_T(op, fnc, const sc_fxnum_fast &) \ 234812853Sgabeblack@google.comDEFN_BIN_OP_OTHER(op, fnc) 234912853Sgabeblack@google.com 235012853Sgabeblack@google.comDEFN_BIN_OP(*, mult) 235112853Sgabeblack@google.comDEFN_BIN_OP(+, add) 235212853Sgabeblack@google.comDEFN_BIN_OP(-, sub) 235312853Sgabeblack@google.com// don't use macros 235412853Sgabeblack@google.com//DEFN_BIN_OP(/, div) 235512853Sgabeblack@google.cominline const sc_fxval 235612853Sgabeblack@google.comoperator / (const sc_fxnum &a, const sc_fxnum &b) 235712853Sgabeblack@google.com{ 235812853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(a) 235912853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(b) 236012853Sgabeblack@google.com return sc_fxval(sc_dt::div_scfx_rep(*a.m_rep, *b.m_rep)); 236112853Sgabeblack@google.com} 236212853Sgabeblack@google.com 236312853Sgabeblack@google.cominline const sc_fxval 236412853Sgabeblack@google.comoperator / (const sc_fxnum &a, const sc_fxval &b) 236512853Sgabeblack@google.com{ 236612853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(a) 236712853Sgabeblack@google.com return sc_fxval(sc_dt::div_scfx_rep(*a.m_rep, *b.get_rep())); 236812853Sgabeblack@google.com} 236912853Sgabeblack@google.com 237012853Sgabeblack@google.cominline const sc_fxval 237112853Sgabeblack@google.comoperator / (const sc_fxval &a, const sc_fxnum &b) 237212853Sgabeblack@google.com{ 237312853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(b) 237412853Sgabeblack@google.com return sc_fxval(sc_dt::div_scfx_rep(*a.get_rep(), *b.m_rep)); 237512853Sgabeblack@google.com} 237612853Sgabeblack@google.com 237712853Sgabeblack@google.comDEFN_BIN_OP_T(/, div, int) 237812853Sgabeblack@google.comDEFN_BIN_OP_T(/, div, unsigned int) 237912853Sgabeblack@google.comDEFN_BIN_OP_T(/, div, long) 238012853Sgabeblack@google.comDEFN_BIN_OP_T(/, div, unsigned long) 238112853Sgabeblack@google.comDEFN_BIN_OP_T(/, div, float) 238212853Sgabeblack@google.comDEFN_BIN_OP_T(/, div, double) 238312853Sgabeblack@google.comDEFN_BIN_OP_T(/, div, const char *) 238412853Sgabeblack@google.comDEFN_BIN_OP_T(/, div, const sc_fxval_fast &) 238512853Sgabeblack@google.comDEFN_BIN_OP_T(/, div, const sc_fxnum_fast &) 238612853Sgabeblack@google.com//DEFN_BIN_OP_OTHER(/, div) 238712853Sgabeblack@google.com 238812853Sgabeblack@google.comDEFN_BIN_OP_T(/, div, int64) 238912853Sgabeblack@google.comDEFN_BIN_OP_T(/, div, uint64) 239012853Sgabeblack@google.comDEFN_BIN_OP_T(/, div, const sc_int_base &) 239112853Sgabeblack@google.comDEFN_BIN_OP_T(/, div, const sc_uint_base &) 239212853Sgabeblack@google.comDEFN_BIN_OP_T(/, div, const sc_signed &) 239312853Sgabeblack@google.comDEFN_BIN_OP_T(/, div, const sc_unsigned &) 239412853Sgabeblack@google.com 239512853Sgabeblack@google.com#undef DEFN_BIN_OP_T 239612853Sgabeblack@google.com#undef DEFN_BIN_OP_OTHER 239712853Sgabeblack@google.com#undef DEFN_BIN_OP 239812853Sgabeblack@google.com 239912853Sgabeblack@google.cominline const sc_fxval 240012853Sgabeblack@google.comoperator << (const sc_fxnum &a, int b) 240112853Sgabeblack@google.com{ 240212853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(a) 240312853Sgabeblack@google.com return sc_fxval(sc_dt::lsh_scfx_rep(*a.m_rep, b)); 240412853Sgabeblack@google.com} 240512853Sgabeblack@google.com 240612853Sgabeblack@google.cominline const sc_fxval 240712853Sgabeblack@google.comoperator >> (const sc_fxnum &a, int b) 240812853Sgabeblack@google.com{ 240912853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(a) 241012853Sgabeblack@google.com return sc_fxval(sc_dt::rsh_scfx_rep(*a.m_rep, b)); 241112853Sgabeblack@google.com} 241212853Sgabeblack@google.com 241312853Sgabeblack@google.com// binary functions 241412853Sgabeblack@google.com#define DEFN_BIN_FNC_T(fnc, tp) \ 241512853Sgabeblack@google.cominline void \ 241612853Sgabeblack@google.comfnc (sc_fxval &c, const sc_fxnum &a, tp b) \ 241712853Sgabeblack@google.com{ \ 241812853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(a) \ 241912853Sgabeblack@google.com sc_fxval tmp(b); \ 242012853Sgabeblack@google.com c.set_rep(sc_dt::fnc ## _scfx_rep(*a.m_rep, *tmp.get_rep())); \ 242112853Sgabeblack@google.com} \ 242212853Sgabeblack@google.com \ 242312853Sgabeblack@google.cominline void \ 242412853Sgabeblack@google.comfnc (sc_fxval &c, tp a, const sc_fxnum &b) \ 242512853Sgabeblack@google.com{ \ 242612853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(b) \ 242712853Sgabeblack@google.com sc_fxval tmp(a); \ 242812853Sgabeblack@google.com c.set_rep(sc_dt::fnc ## _scfx_rep(*tmp.get_rep(), *b.m_rep)); \ 242912853Sgabeblack@google.com} \ 243012853Sgabeblack@google.com \ 243112853Sgabeblack@google.cominline void \ 243212853Sgabeblack@google.comfnc (sc_fxnum &c, const sc_fxnum &a, tp b) \ 243312853Sgabeblack@google.com{ \ 243412853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(a) \ 243512853Sgabeblack@google.com sc_fxval tmp(b); \ 243612853Sgabeblack@google.com delete c.m_rep; \ 243712853Sgabeblack@google.com c.m_rep = sc_dt::fnc ## _scfx_rep(*a.m_rep, *tmp.get_rep()); \ 243812853Sgabeblack@google.com c.cast(); \ 243912853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(c) \ 244012853Sgabeblack@google.com} \ 244112853Sgabeblack@google.com \ 244212853Sgabeblack@google.cominline void \ 244312853Sgabeblack@google.comfnc (sc_fxnum &c, tp a, const sc_fxnum &b) \ 244412853Sgabeblack@google.com{ \ 244512853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(b) \ 244612853Sgabeblack@google.com sc_fxval tmp(a); \ 244712853Sgabeblack@google.com delete c.m_rep; \ 244812853Sgabeblack@google.com c.m_rep = sc_dt::fnc ## _scfx_rep(*tmp.get_rep(), *b.m_rep); \ 244912853Sgabeblack@google.com c.cast(); \ 245012853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(c) \ 245112853Sgabeblack@google.com} 245212853Sgabeblack@google.com 245312853Sgabeblack@google.com#define DEFN_BIN_FNC_OTHER(fnc) \ 245412853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, int64) \ 245512853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, uint64) \ 245612853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, const sc_int_base &) \ 245712853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, const sc_uint_base &) \ 245812853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, const sc_signed &) \ 245912853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, const sc_unsigned &) 246012853Sgabeblack@google.com 246112853Sgabeblack@google.com#define DEFN_BIN_FNC(fnc) \ 246212853Sgabeblack@google.cominline void \ 246312853Sgabeblack@google.comfnc (sc_fxval &c, const sc_fxnum &a, const sc_fxnum &b) \ 246412853Sgabeblack@google.com{ \ 246512853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(a) \ 246612853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(b) \ 246712853Sgabeblack@google.com c.set_rep(sc_dt::fnc ## _scfx_rep(*a.m_rep, *b.m_rep)); \ 246812853Sgabeblack@google.com} \ 246912853Sgabeblack@google.com \ 247012853Sgabeblack@google.cominline void \ 247112853Sgabeblack@google.comfnc (sc_fxnum &c, const sc_fxnum &a, const sc_fxnum &b) \ 247212853Sgabeblack@google.com{ \ 247312853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(a) \ 247412853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(b) \ 247512853Sgabeblack@google.com delete c.m_rep; \ 247612853Sgabeblack@google.com c.m_rep = sc_dt::fnc ## _scfx_rep(*a.m_rep, *b.m_rep); \ 247712853Sgabeblack@google.com c.cast(); \ 247812853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(c) \ 247912853Sgabeblack@google.com} \ 248012853Sgabeblack@google.com \ 248112853Sgabeblack@google.cominline void \ 248212853Sgabeblack@google.comfnc (sc_fxval &c, const sc_fxnum &a, const sc_fxval &b) \ 248312853Sgabeblack@google.com{ \ 248412853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(a) \ 248512853Sgabeblack@google.com c.set_rep(sc_dt::fnc ## _scfx_rep(*a.m_rep, *b.get_rep())); \ 248612853Sgabeblack@google.com} \ 248712853Sgabeblack@google.com \ 248812853Sgabeblack@google.cominline void \ 248912853Sgabeblack@google.comfnc (sc_fxval &c, const sc_fxval &a, const sc_fxnum &b) \ 249012853Sgabeblack@google.com{ \ 249112853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(b) \ 249212853Sgabeblack@google.com c.set_rep(sc_dt::fnc ## _scfx_rep(*a.get_rep(), *b.m_rep)); \ 249312853Sgabeblack@google.com} \ 249412853Sgabeblack@google.com \ 249512853Sgabeblack@google.cominline void \ 249612853Sgabeblack@google.comfnc (sc_fxnum &c, const sc_fxnum &a, const sc_fxval &b) \ 249712853Sgabeblack@google.com{ \ 249812853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(a) \ 249912853Sgabeblack@google.com delete c.m_rep; \ 250012853Sgabeblack@google.com c.m_rep = sc_dt::fnc ## _scfx_rep(*a.m_rep, *b.get_rep()); \ 250112853Sgabeblack@google.com c.cast(); \ 250212853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(c) \ 250312853Sgabeblack@google.com} \ 250412853Sgabeblack@google.com \ 250512853Sgabeblack@google.cominline void \ 250612853Sgabeblack@google.comfnc (sc_fxnum &c, const sc_fxval &a, const sc_fxnum &b) \ 250712853Sgabeblack@google.com{ \ 250812853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(b) \ 250912853Sgabeblack@google.com delete c.m_rep; \ 251012853Sgabeblack@google.com c.m_rep = sc_dt::fnc ## _scfx_rep(*a.get_rep(), *b.m_rep); \ 251112853Sgabeblack@google.com c.cast(); \ 251212853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(c) \ 251312853Sgabeblack@google.com} \ 251412853Sgabeblack@google.com \ 251512853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, int) \ 251612853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, unsigned int) \ 251712853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, long) \ 251812853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, unsigned long) \ 251912853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, float) \ 252012853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, double) \ 252112853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, const char *) \ 252212853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, const sc_fxval_fast &) \ 252312853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, const sc_fxnum_fast &) \ 252412853Sgabeblack@google.comDEFN_BIN_FNC_OTHER(fnc) 252512853Sgabeblack@google.com 252612853Sgabeblack@google.comDEFN_BIN_FNC(mult) 252712853Sgabeblack@google.comDEFN_BIN_FNC(div) 252812853Sgabeblack@google.comDEFN_BIN_FNC(add) 252912853Sgabeblack@google.comDEFN_BIN_FNC(sub) 253012853Sgabeblack@google.com 253112853Sgabeblack@google.com#undef DEFN_BIN_FNC_T 253212853Sgabeblack@google.com#undef DEFN_BIN_FNC_OTHER 253312853Sgabeblack@google.com#undef DEFN_BIN_FNC 253412853Sgabeblack@google.com 253512853Sgabeblack@google.cominline void 253612853Sgabeblack@google.comlshift(sc_fxval &c, const sc_fxnum &a, int b) 253712853Sgabeblack@google.com{ 253812853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(a) 253912853Sgabeblack@google.com c.set_rep(sc_dt::lsh_scfx_rep(*a.m_rep, b)); 254012853Sgabeblack@google.com} 254112853Sgabeblack@google.com 254212853Sgabeblack@google.cominline void 254312853Sgabeblack@google.comrshift(sc_fxval &c, const sc_fxnum &a, int b) 254412853Sgabeblack@google.com{ 254512853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(a) 254612853Sgabeblack@google.com c.set_rep(sc_dt::rsh_scfx_rep(*a.m_rep, b)); 254712853Sgabeblack@google.com} 254812853Sgabeblack@google.com 254912853Sgabeblack@google.cominline void 255012853Sgabeblack@google.comlshift(sc_fxnum &c, const sc_fxnum &a, int b) 255112853Sgabeblack@google.com{ 255212853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(a) 255312853Sgabeblack@google.com delete c.m_rep; 255412853Sgabeblack@google.com c.m_rep = sc_dt::lsh_scfx_rep(*a.m_rep, b); 255512853Sgabeblack@google.com c.cast(); 255612853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(c) 255712853Sgabeblack@google.com} 255812853Sgabeblack@google.com 255912853Sgabeblack@google.cominline void 256012853Sgabeblack@google.comrshift(sc_fxnum &c, const sc_fxnum &a, int b) 256112853Sgabeblack@google.com{ 256212853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(a) 256312853Sgabeblack@google.com delete c.m_rep; 256412853Sgabeblack@google.com c.m_rep = sc_dt::rsh_scfx_rep(*a.m_rep, b); 256512853Sgabeblack@google.com c.cast(); 256612853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(c) 256712853Sgabeblack@google.com} 256812853Sgabeblack@google.com 256912853Sgabeblack@google.com// relational (including equality) operators 257012853Sgabeblack@google.com#define DEFN_REL_OP_T(op, ret, tp) \ 257112853Sgabeblack@google.cominline bool \ 257212853Sgabeblack@google.comoperator op (const sc_fxnum &a, tp b) \ 257312853Sgabeblack@google.com{ \ 257412853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(a) \ 257512853Sgabeblack@google.com sc_fxval tmp(b); \ 257612853Sgabeblack@google.com int result = sc_dt::cmp_scfx_rep(*a.m_rep, *tmp.get_rep()); \ 257712853Sgabeblack@google.com return (ret); \ 257812853Sgabeblack@google.com} \ 257912853Sgabeblack@google.com \ 258012853Sgabeblack@google.cominline bool \ 258112853Sgabeblack@google.comoperator op (tp a, const sc_fxnum &b) \ 258212853Sgabeblack@google.com{ \ 258312853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(b) \ 258412853Sgabeblack@google.com sc_fxval tmp(a); \ 258512853Sgabeblack@google.com int result = sc_dt::cmp_scfx_rep(*tmp.get_rep(), *b.m_rep); \ 258612853Sgabeblack@google.com return (ret); \ 258712853Sgabeblack@google.com} 258812853Sgabeblack@google.com 258912853Sgabeblack@google.com#define DEFN_REL_OP_OTHER(op, ret) \ 259012853Sgabeblack@google.comDEFN_REL_OP_T(op, ret, int64) \ 259112853Sgabeblack@google.comDEFN_REL_OP_T(op, ret, uint64) \ 259212853Sgabeblack@google.comDEFN_REL_OP_T(op, ret, const sc_int_base &) \ 259312853Sgabeblack@google.comDEFN_REL_OP_T(op, ret, const sc_uint_base &) \ 259412853Sgabeblack@google.comDEFN_REL_OP_T(op, ret, const sc_signed &) \ 259512853Sgabeblack@google.comDEFN_REL_OP_T(op, ret, const sc_unsigned &) 259612853Sgabeblack@google.com 259712853Sgabeblack@google.com#define DEFN_REL_OP(op, ret) \ 259812853Sgabeblack@google.cominline bool \ 259912853Sgabeblack@google.comoperator op (const sc_fxnum &a, const sc_fxnum &b) \ 260012853Sgabeblack@google.com{ \ 260112853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(a) \ 260212853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(b) \ 260312853Sgabeblack@google.com int result = sc_dt::cmp_scfx_rep(*a.m_rep, *b.m_rep); \ 260412853Sgabeblack@google.com return (ret); \ 260512853Sgabeblack@google.com} \ 260612853Sgabeblack@google.com \ 260712853Sgabeblack@google.cominline bool \ 260812853Sgabeblack@google.comoperator op (const sc_fxnum &a, const sc_fxval &b) \ 260912853Sgabeblack@google.com{ \ 261012853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(a) \ 261112853Sgabeblack@google.com int result = sc_dt::cmp_scfx_rep(*a.m_rep, *b.get_rep()); \ 261212853Sgabeblack@google.com return (ret); \ 261312853Sgabeblack@google.com} \ 261412853Sgabeblack@google.com \ 261512853Sgabeblack@google.cominline bool \ 261612853Sgabeblack@google.comoperator op (const sc_fxval &a, const sc_fxnum &b) \ 261712853Sgabeblack@google.com{ \ 261812853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(b) \ 261912853Sgabeblack@google.com int result = sc_dt::cmp_scfx_rep(*a.get_rep(), *b.m_rep); \ 262012853Sgabeblack@google.com return (ret); \ 262112853Sgabeblack@google.com} \ 262212853Sgabeblack@google.com \ 262312853Sgabeblack@google.comDEFN_REL_OP_T(op, ret, int) \ 262412853Sgabeblack@google.comDEFN_REL_OP_T(op, ret, unsigned int) \ 262512853Sgabeblack@google.comDEFN_REL_OP_T(op, ret, long) \ 262612853Sgabeblack@google.comDEFN_REL_OP_T(op, ret, unsigned long) \ 262712853Sgabeblack@google.comDEFN_REL_OP_T(op, ret, float) \ 262812853Sgabeblack@google.comDEFN_REL_OP_T(op, ret, double) \ 262912853Sgabeblack@google.comDEFN_REL_OP_T(op, ret, const char *) \ 263012853Sgabeblack@google.comDEFN_REL_OP_T(op, ret, const sc_fxval_fast &) \ 263112853Sgabeblack@google.comDEFN_REL_OP_T(op, ret, const sc_fxnum_fast &) \ 263212853Sgabeblack@google.comDEFN_REL_OP_OTHER(op, ret) 263312853Sgabeblack@google.com 263412853Sgabeblack@google.comDEFN_REL_OP(<, result < 0) 263512853Sgabeblack@google.comDEFN_REL_OP(<=, result <= 0) 263612853Sgabeblack@google.comDEFN_REL_OP(>, result > 0 && result != 2) 263712853Sgabeblack@google.comDEFN_REL_OP(>=, result >= 0 && result != 2) 263812853Sgabeblack@google.comDEFN_REL_OP(==, result == 0) 263912853Sgabeblack@google.comDEFN_REL_OP(!=, result != 0) 264012853Sgabeblack@google.com 264112853Sgabeblack@google.com#undef DEFN_REL_OP_T 264212853Sgabeblack@google.com#undef DEFN_REL_OP_OTHER 264312853Sgabeblack@google.com#undef DEFN_REL_OP 264412853Sgabeblack@google.com 264512853Sgabeblack@google.com// assignment operators 264612853Sgabeblack@google.cominline sc_fxnum & 264712853Sgabeblack@google.comsc_fxnum::operator = (const sc_fxnum &a) 264812853Sgabeblack@google.com{ 264912853Sgabeblack@google.com if (&a != this) { 265012853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(a) 265112853Sgabeblack@google.com *m_rep = *a.m_rep; 265212853Sgabeblack@google.com cast(); 265312853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(*this) 265412853Sgabeblack@google.com } 265512853Sgabeblack@google.com return *this; 265612853Sgabeblack@google.com} 265712853Sgabeblack@google.com 265812853Sgabeblack@google.cominline sc_fxnum & 265912853Sgabeblack@google.comsc_fxnum::operator = (const sc_fxval &a) 266012853Sgabeblack@google.com{ 266112853Sgabeblack@google.com *m_rep = *a.get_rep(); 266212853Sgabeblack@google.com cast(); 266312853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(*this) 266412853Sgabeblack@google.com return *this; 266512853Sgabeblack@google.com} 266612853Sgabeblack@google.com 266712853Sgabeblack@google.com#define DEFN_ASN_OP_T(tp) \ 266812853Sgabeblack@google.cominline sc_fxnum & \ 266912853Sgabeblack@google.comsc_fxnum::operator = (tp a) \ 267012853Sgabeblack@google.com{ \ 267112853Sgabeblack@google.com sc_fxval tmp(a); \ 267212853Sgabeblack@google.com *m_rep = *tmp.get_rep(); \ 267312853Sgabeblack@google.com cast(); \ 267412853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(*this) \ 267512853Sgabeblack@google.com return *this; \ 267612853Sgabeblack@google.com} 267712853Sgabeblack@google.com 267812853Sgabeblack@google.comDEFN_ASN_OP_T(int) 267912853Sgabeblack@google.comDEFN_ASN_OP_T(unsigned int) 268012853Sgabeblack@google.comDEFN_ASN_OP_T(long) 268112853Sgabeblack@google.comDEFN_ASN_OP_T(unsigned long) 268212853Sgabeblack@google.comDEFN_ASN_OP_T(float) 268312853Sgabeblack@google.comDEFN_ASN_OP_T(double) 268412853Sgabeblack@google.comDEFN_ASN_OP_T(const char *) 268512853Sgabeblack@google.comDEFN_ASN_OP_T(const sc_fxval_fast &) 268612853Sgabeblack@google.comDEFN_ASN_OP_T(const sc_fxnum_fast &) 268712853Sgabeblack@google.com 268812853Sgabeblack@google.comDEFN_ASN_OP_T(int64) 268912853Sgabeblack@google.comDEFN_ASN_OP_T(uint64) 269012853Sgabeblack@google.comDEFN_ASN_OP_T(const sc_int_base &) 269112853Sgabeblack@google.comDEFN_ASN_OP_T(const sc_uint_base &) 269212853Sgabeblack@google.comDEFN_ASN_OP_T(const sc_signed &) 269312853Sgabeblack@google.comDEFN_ASN_OP_T(const sc_unsigned &) 269412853Sgabeblack@google.com 269512853Sgabeblack@google.com#undef DEFN_ASN_OP_T 269612853Sgabeblack@google.com 269712853Sgabeblack@google.com 269812853Sgabeblack@google.com#define DEFN_ASN_OP_T(op, fnc, tp) \ 269912853Sgabeblack@google.cominline sc_fxnum & \ 270012853Sgabeblack@google.comsc_fxnum::operator op (tp b) \ 270112853Sgabeblack@google.com{ \ 270212853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(*this) \ 270312853Sgabeblack@google.com sc_fxval tmp(b); \ 270412853Sgabeblack@google.com scfx_rep *new_rep = sc_dt::fnc ## _scfx_rep(*m_rep, *tmp.get_rep()); \ 270512853Sgabeblack@google.com delete m_rep; \ 270612853Sgabeblack@google.com m_rep = new_rep; \ 270712853Sgabeblack@google.com cast(); \ 270812853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(*this) \ 270912853Sgabeblack@google.com return *this; \ 271012853Sgabeblack@google.com} 271112853Sgabeblack@google.com 271212853Sgabeblack@google.com#define DEFN_ASN_OP_OTHER(op, fnc) \ 271312853Sgabeblack@google.comDEFN_ASN_OP_T(op, fnc, int64) \ 271412853Sgabeblack@google.comDEFN_ASN_OP_T(op, fnc, uint64) \ 271512853Sgabeblack@google.comDEFN_ASN_OP_T(op, fnc, const sc_int_base &) \ 271612853Sgabeblack@google.comDEFN_ASN_OP_T(op, fnc, const sc_uint_base &) \ 271712853Sgabeblack@google.comDEFN_ASN_OP_T(op, fnc, const sc_signed &) \ 271812853Sgabeblack@google.comDEFN_ASN_OP_T(op, fnc, const sc_unsigned &) 271912853Sgabeblack@google.com 272012853Sgabeblack@google.com#define DEFN_ASN_OP(op, fnc) \ 272112853Sgabeblack@google.cominline sc_fxnum & \ 272212853Sgabeblack@google.comsc_fxnum::operator op (const sc_fxnum &b) \ 272312853Sgabeblack@google.com{ \ 272412853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(*this) \ 272512853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(b) \ 272612853Sgabeblack@google.com scfx_rep *new_rep = sc_dt::fnc ## _scfx_rep(*m_rep, *b.m_rep); \ 272712853Sgabeblack@google.com delete m_rep; \ 272812853Sgabeblack@google.com m_rep = new_rep; \ 272912853Sgabeblack@google.com cast(); \ 273012853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(*this) \ 273112853Sgabeblack@google.com return *this; \ 273212853Sgabeblack@google.com} \ 273312853Sgabeblack@google.com \ 273412853Sgabeblack@google.cominline sc_fxnum & \ 273512853Sgabeblack@google.comsc_fxnum::operator op (const sc_fxval &b) \ 273612853Sgabeblack@google.com{ \ 273712853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(*this) \ 273812853Sgabeblack@google.com scfx_rep *new_rep = sc_dt::fnc ## _scfx_rep(*m_rep, *b.get_rep()); \ 273912853Sgabeblack@google.com delete m_rep; \ 274012853Sgabeblack@google.com m_rep = new_rep; \ 274112853Sgabeblack@google.com cast(); \ 274212853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(*this) \ 274312853Sgabeblack@google.com return *this; \ 274412853Sgabeblack@google.com} \ 274512853Sgabeblack@google.com \ 274612853Sgabeblack@google.comDEFN_ASN_OP_T(op, fnc, int) \ 274712853Sgabeblack@google.comDEFN_ASN_OP_T(op, fnc, unsigned int) \ 274812853Sgabeblack@google.comDEFN_ASN_OP_T(op, fnc, long) \ 274912853Sgabeblack@google.comDEFN_ASN_OP_T(op, fnc, unsigned long) \ 275012853Sgabeblack@google.comDEFN_ASN_OP_T(op, fnc, float) \ 275112853Sgabeblack@google.comDEFN_ASN_OP_T(op, fnc, double) \ 275212853Sgabeblack@google.comDEFN_ASN_OP_T(op, fnc, const char *) \ 275312853Sgabeblack@google.comDEFN_ASN_OP_T(op, fnc, const sc_fxval_fast &) \ 275412853Sgabeblack@google.comDEFN_ASN_OP_T(op, fnc, const sc_fxnum_fast &) \ 275512853Sgabeblack@google.comDEFN_ASN_OP_OTHER(op, fnc) 275612853Sgabeblack@google.com 275712853Sgabeblack@google.comDEFN_ASN_OP(*=, mult) 275812853Sgabeblack@google.comDEFN_ASN_OP(/=, div) 275912853Sgabeblack@google.comDEFN_ASN_OP(+=, add) 276012853Sgabeblack@google.comDEFN_ASN_OP(-=, sub) 276112853Sgabeblack@google.com 276212853Sgabeblack@google.com#undef DEFN_ASN_OP_T 276312853Sgabeblack@google.com#undef DEFN_ASN_OP_OTHER 276412853Sgabeblack@google.com#undef DEFN_ASN_OP 276512853Sgabeblack@google.com 276612853Sgabeblack@google.com 276712853Sgabeblack@google.cominline sc_fxnum & 276812853Sgabeblack@google.comsc_fxnum::operator <<= (int b) 276912853Sgabeblack@google.com{ 277012853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(*this) 277112853Sgabeblack@google.com m_rep->lshift(b); 277212853Sgabeblack@google.com cast(); 277312853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(*this) 277412853Sgabeblack@google.com return *this; 277512853Sgabeblack@google.com} 277612853Sgabeblack@google.com 277712853Sgabeblack@google.cominline sc_fxnum & 277812853Sgabeblack@google.comsc_fxnum::operator >>= (int b) 277912853Sgabeblack@google.com{ 278012853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(*this) 278112853Sgabeblack@google.com m_rep->rshift(b); 278212853Sgabeblack@google.com cast(); 278312853Sgabeblack@google.com SC_FXNUM_OBSERVER_WRITE_(*this) 278412853Sgabeblack@google.com return *this; 278512853Sgabeblack@google.com} 278612853Sgabeblack@google.com 278712853Sgabeblack@google.com// auto-increment and auto-decrement 278812853Sgabeblack@google.cominline const sc_fxval 278912853Sgabeblack@google.comsc_fxnum::operator ++ (int) 279012853Sgabeblack@google.com{ 279112853Sgabeblack@google.com sc_fxval c(*this); 279212853Sgabeblack@google.com (*this) += 1; 279312853Sgabeblack@google.com return c; 279412853Sgabeblack@google.com} 279512853Sgabeblack@google.com 279612853Sgabeblack@google.cominline const sc_fxval 279712853Sgabeblack@google.comsc_fxnum::operator -- (int) 279812853Sgabeblack@google.com{ 279912853Sgabeblack@google.com sc_fxval c(*this); 280012853Sgabeblack@google.com (*this) -= 1; 280112853Sgabeblack@google.com return c; 280212853Sgabeblack@google.com} 280312853Sgabeblack@google.com 280412853Sgabeblack@google.cominline sc_fxnum & 280512853Sgabeblack@google.comsc_fxnum::operator ++ () 280612853Sgabeblack@google.com{ 280712853Sgabeblack@google.com (*this) += 1; 280812853Sgabeblack@google.com return *this; 280912853Sgabeblack@google.com} 281012853Sgabeblack@google.com 281112853Sgabeblack@google.cominline sc_fxnum & 281212853Sgabeblack@google.comsc_fxnum::operator -- () 281312853Sgabeblack@google.com{ 281412853Sgabeblack@google.com (*this) -= 1; 281512853Sgabeblack@google.com return *this; 281612853Sgabeblack@google.com} 281712853Sgabeblack@google.com 281812853Sgabeblack@google.com// bit selection 281912853Sgabeblack@google.cominline const sc_fxnum_bitref 282012853Sgabeblack@google.comsc_fxnum::operator [] (int i) const 282112853Sgabeblack@google.com{ 282213325Sgabeblack@google.com SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_); 282312853Sgabeblack@google.com return sc_fxnum_bitref(const_cast<sc_fxnum &>(*this), 282412853Sgabeblack@google.com i - m_params.fwl()); 282512853Sgabeblack@google.com} 282612853Sgabeblack@google.com 282712853Sgabeblack@google.cominline sc_fxnum_bitref 282812853Sgabeblack@google.comsc_fxnum::operator [] (int i) 282912853Sgabeblack@google.com{ 283013325Sgabeblack@google.com SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_); 283112853Sgabeblack@google.com return sc_fxnum_bitref(*this, i - m_params.fwl()); 283212853Sgabeblack@google.com} 283312853Sgabeblack@google.com 283412853Sgabeblack@google.cominline const sc_fxnum_bitref 283512853Sgabeblack@google.comsc_fxnum::bit(int i) const 283612853Sgabeblack@google.com{ 283713325Sgabeblack@google.com SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_); 283812853Sgabeblack@google.com return sc_fxnum_bitref(const_cast<sc_fxnum &>(*this), 283912853Sgabeblack@google.com i - m_params.fwl()); 284012853Sgabeblack@google.com} 284112853Sgabeblack@google.com 284212853Sgabeblack@google.cominline sc_fxnum_bitref 284312853Sgabeblack@google.comsc_fxnum::bit(int i) 284412853Sgabeblack@google.com{ 284513325Sgabeblack@google.com SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_); 284612853Sgabeblack@google.com return sc_fxnum_bitref(*this, i - m_params.fwl()); 284712853Sgabeblack@google.com} 284812853Sgabeblack@google.com 284912853Sgabeblack@google.com// part selection 285012853Sgabeblack@google.com 285112853Sgabeblack@google.cominline const sc_fxnum_subref 285212853Sgabeblack@google.comsc_fxnum::operator () (int i, int j) const 285312853Sgabeblack@google.com{ 285413325Sgabeblack@google.com SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_); 285513325Sgabeblack@google.com SC_ERROR_IF_(j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_); 285612853Sgabeblack@google.com 285712853Sgabeblack@google.com return sc_fxnum_subref(const_cast<sc_fxnum &>(*this), 285812853Sgabeblack@google.com i - m_params.fwl(), j - m_params.fwl()); 285912853Sgabeblack@google.com} 286012853Sgabeblack@google.com 286112853Sgabeblack@google.cominline sc_fxnum_subref 286212853Sgabeblack@google.comsc_fxnum::operator () (int i, int j) 286312853Sgabeblack@google.com{ 286413325Sgabeblack@google.com SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_); 286513325Sgabeblack@google.com SC_ERROR_IF_(j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_); 286612853Sgabeblack@google.com 286712853Sgabeblack@google.com return sc_fxnum_subref(*this, i - m_params.fwl(), j - m_params.fwl()); 286812853Sgabeblack@google.com} 286912853Sgabeblack@google.com 287012853Sgabeblack@google.cominline const sc_fxnum_subref 287112853Sgabeblack@google.comsc_fxnum::range(int i, int j) const 287212853Sgabeblack@google.com{ 287313325Sgabeblack@google.com SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_); 287413325Sgabeblack@google.com SC_ERROR_IF_(j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_); 287512853Sgabeblack@google.com 287612853Sgabeblack@google.com return sc_fxnum_subref(const_cast<sc_fxnum &>(*this), 287712853Sgabeblack@google.com i - m_params.fwl(), j - m_params.fwl()); 287812853Sgabeblack@google.com} 287912853Sgabeblack@google.com 288012853Sgabeblack@google.cominline sc_fxnum_subref 288112853Sgabeblack@google.comsc_fxnum::range(int i, int j) 288212853Sgabeblack@google.com{ 288313325Sgabeblack@google.com SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_); 288413325Sgabeblack@google.com SC_ERROR_IF_(j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_); 288512853Sgabeblack@google.com 288612853Sgabeblack@google.com return sc_fxnum_subref(*this, i - m_params.fwl(), j - m_params.fwl()); 288712853Sgabeblack@google.com} 288812853Sgabeblack@google.com 288912853Sgabeblack@google.com 289012853Sgabeblack@google.cominline const sc_fxnum_subref 289112853Sgabeblack@google.comsc_fxnum::operator () () const 289212853Sgabeblack@google.com{ 289312853Sgabeblack@google.com return this->operator () (m_params.wl() - 1, 0); 289412853Sgabeblack@google.com} 289512853Sgabeblack@google.com 289612853Sgabeblack@google.cominline sc_fxnum_subref 289712853Sgabeblack@google.comsc_fxnum::operator () () 289812853Sgabeblack@google.com{ 289912853Sgabeblack@google.com return this->operator () (m_params.wl() - 1, 0); 290012853Sgabeblack@google.com} 290112853Sgabeblack@google.com 290212853Sgabeblack@google.cominline const sc_fxnum_subref 290312853Sgabeblack@google.comsc_fxnum::range() const 290412853Sgabeblack@google.com{ 290512853Sgabeblack@google.com return this->range(m_params.wl() - 1, 0); 290612853Sgabeblack@google.com} 290712853Sgabeblack@google.com 290812853Sgabeblack@google.cominline sc_fxnum_subref 290912853Sgabeblack@google.comsc_fxnum::range() 291012853Sgabeblack@google.com{ 291112853Sgabeblack@google.com return this->range(m_params.wl() - 1, 0); 291212853Sgabeblack@google.com} 291312853Sgabeblack@google.com 291412853Sgabeblack@google.com// implicit conversion 291512853Sgabeblack@google.cominline sc_fxnum::operator double() const 291612853Sgabeblack@google.com{ 291712853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(*this) 291812853Sgabeblack@google.com return m_rep->to_double(); 291912853Sgabeblack@google.com} 292012853Sgabeblack@google.com 292112853Sgabeblack@google.com// explicit conversion to primitive types 292212853Sgabeblack@google.cominline short 292312853Sgabeblack@google.comsc_fxnum::to_short() const 292412853Sgabeblack@google.com{ 292512853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(*this) 292612853Sgabeblack@google.com return static_cast<short>(m_rep->to_uint64()); 292712853Sgabeblack@google.com} 292812853Sgabeblack@google.com 292912853Sgabeblack@google.cominline unsigned short 293012853Sgabeblack@google.comsc_fxnum::to_ushort() const 293112853Sgabeblack@google.com{ 293212853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(*this) 293312853Sgabeblack@google.com return static_cast<unsigned short>(m_rep->to_uint64()); 293412853Sgabeblack@google.com} 293512853Sgabeblack@google.com 293612853Sgabeblack@google.cominline int 293712853Sgabeblack@google.comsc_fxnum::to_int() const 293812853Sgabeblack@google.com{ 293912853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(*this) 294012853Sgabeblack@google.com return static_cast<int>(m_rep->to_uint64()); 294112853Sgabeblack@google.com} 294212853Sgabeblack@google.com 294312853Sgabeblack@google.cominline int64 294412853Sgabeblack@google.comsc_fxnum::to_int64() const 294512853Sgabeblack@google.com{ 294612853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(*this) 294712853Sgabeblack@google.com return static_cast<int64>(m_rep->to_uint64()); 294812853Sgabeblack@google.com} 294912853Sgabeblack@google.com 295012853Sgabeblack@google.cominline unsigned int 295112853Sgabeblack@google.comsc_fxnum::to_uint() const 295212853Sgabeblack@google.com{ 295312853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(*this) 295412853Sgabeblack@google.com return static_cast<unsigned int>(m_rep->to_uint64()); 295512853Sgabeblack@google.com} 295612853Sgabeblack@google.com 295712853Sgabeblack@google.cominline uint64 295812853Sgabeblack@google.comsc_fxnum::to_uint64() const 295912853Sgabeblack@google.com{ 296012853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(*this) 296112853Sgabeblack@google.com return m_rep->to_uint64(); 296212853Sgabeblack@google.com} 296312853Sgabeblack@google.com 296412853Sgabeblack@google.cominline long 296512853Sgabeblack@google.comsc_fxnum::to_long() const 296612853Sgabeblack@google.com{ 296712853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(*this) 296812853Sgabeblack@google.com return static_cast<long>(m_rep->to_uint64()); 296912853Sgabeblack@google.com} 297012853Sgabeblack@google.com 297112853Sgabeblack@google.cominline unsigned long 297212853Sgabeblack@google.comsc_fxnum::to_ulong() const 297312853Sgabeblack@google.com{ 297412853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(*this) 297512853Sgabeblack@google.com return static_cast<unsigned long>(m_rep->to_uint64()); 297612853Sgabeblack@google.com} 297712853Sgabeblack@google.com 297812853Sgabeblack@google.cominline float 297912853Sgabeblack@google.comsc_fxnum::to_float() const 298012853Sgabeblack@google.com{ 298112853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(*this) 298212853Sgabeblack@google.com return static_cast<float>(m_rep->to_double()); 298312853Sgabeblack@google.com} 298412853Sgabeblack@google.com 298512853Sgabeblack@google.cominline double 298612853Sgabeblack@google.comsc_fxnum::to_double() const 298712853Sgabeblack@google.com{ 298812853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(*this) 298912853Sgabeblack@google.com return m_rep->to_double(); 299012853Sgabeblack@google.com} 299112853Sgabeblack@google.com 299212853Sgabeblack@google.com// query value 299312853Sgabeblack@google.cominline bool 299412853Sgabeblack@google.comsc_fxnum::is_neg() const 299512853Sgabeblack@google.com{ 299612853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(*this) 299712853Sgabeblack@google.com return m_rep->is_neg(); 299812853Sgabeblack@google.com} 299912853Sgabeblack@google.com 300012853Sgabeblack@google.cominline bool 300112853Sgabeblack@google.comsc_fxnum::is_zero() const 300212853Sgabeblack@google.com{ 300312853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(*this) 300412853Sgabeblack@google.com return m_rep->is_zero(); 300512853Sgabeblack@google.com} 300612853Sgabeblack@google.com 300712853Sgabeblack@google.com// internal use only; 300812853Sgabeblack@google.cominline bool 300912853Sgabeblack@google.comsc_fxnum::is_normal() const 301012853Sgabeblack@google.com{ 301112853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(*this) 301212853Sgabeblack@google.com return m_rep->is_normal(); 301312853Sgabeblack@google.com} 301412853Sgabeblack@google.com 301512853Sgabeblack@google.cominline bool 301612853Sgabeblack@google.comsc_fxnum::quantization_flag() const 301712853Sgabeblack@google.com{ 301812853Sgabeblack@google.com return m_q_flag; 301912853Sgabeblack@google.com} 302012853Sgabeblack@google.com 302112853Sgabeblack@google.cominline bool 302212853Sgabeblack@google.comsc_fxnum::overflow_flag() const 302312853Sgabeblack@google.com{ 302412853Sgabeblack@google.com return m_o_flag; 302512853Sgabeblack@google.com} 302612853Sgabeblack@google.com 302712853Sgabeblack@google.com 302812853Sgabeblack@google.cominline const sc_fxval 302912853Sgabeblack@google.comsc_fxnum::value() const 303012853Sgabeblack@google.com{ 303112853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(*this) 303212853Sgabeblack@google.com return sc_fxval(new scfx_rep(*m_rep)); 303312853Sgabeblack@google.com} 303412853Sgabeblack@google.com 303512853Sgabeblack@google.com// query parameters 303612853Sgabeblack@google.cominline int 303712853Sgabeblack@google.comsc_fxnum::wl() const 303812853Sgabeblack@google.com{ 303912853Sgabeblack@google.com return m_params.wl(); 304012853Sgabeblack@google.com} 304112853Sgabeblack@google.com 304212853Sgabeblack@google.cominline int 304312853Sgabeblack@google.comsc_fxnum::iwl() const 304412853Sgabeblack@google.com{ 304512853Sgabeblack@google.com return m_params.iwl(); 304612853Sgabeblack@google.com} 304712853Sgabeblack@google.com 304812853Sgabeblack@google.cominline sc_q_mode 304912853Sgabeblack@google.comsc_fxnum::q_mode() const 305012853Sgabeblack@google.com{ 305112853Sgabeblack@google.com return m_params.q_mode(); 305212853Sgabeblack@google.com} 305312853Sgabeblack@google.com 305412853Sgabeblack@google.cominline sc_o_mode 305512853Sgabeblack@google.comsc_fxnum::o_mode() const 305612853Sgabeblack@google.com{ 305712853Sgabeblack@google.com return m_params.o_mode(); 305812853Sgabeblack@google.com} 305912853Sgabeblack@google.com 306012853Sgabeblack@google.cominline int 306112853Sgabeblack@google.comsc_fxnum::n_bits() const 306212853Sgabeblack@google.com{ 306312853Sgabeblack@google.com return m_params.n_bits(); 306412853Sgabeblack@google.com} 306512853Sgabeblack@google.com 306612853Sgabeblack@google.cominline const sc_fxtype_params & 306712853Sgabeblack@google.comsc_fxnum::type_params() const 306812853Sgabeblack@google.com{ 306912853Sgabeblack@google.com return m_params.type_params(); 307012853Sgabeblack@google.com} 307112853Sgabeblack@google.com 307212853Sgabeblack@google.cominline const sc_fxcast_switch & 307312853Sgabeblack@google.comsc_fxnum::cast_switch() const 307412853Sgabeblack@google.com{ 307512853Sgabeblack@google.com return m_params.cast_switch(); 307612853Sgabeblack@google.com} 307712853Sgabeblack@google.com 307812853Sgabeblack@google.com// internal use only; 307912853Sgabeblack@google.cominline void 308012853Sgabeblack@google.comsc_fxnum::observer_read() const 308112853Sgabeblack@google.com{ 308212853Sgabeblack@google.com SC_FXNUM_OBSERVER_READ_(*this); 308312853Sgabeblack@google.com} 308412853Sgabeblack@google.com 308512853Sgabeblack@google.com// internal use only; 308612853Sgabeblack@google.cominline bool 308712853Sgabeblack@google.comsc_fxnum::get_bit(int i) const 308812853Sgabeblack@google.com{ 308912853Sgabeblack@google.com return m_rep->get_bit(i); 309012853Sgabeblack@google.com} 309112853Sgabeblack@google.com 309212853Sgabeblack@google.com// protected methods and friend functions 309312853Sgabeblack@google.cominline bool 309412853Sgabeblack@google.comsc_fxnum::set_bit(int i, bool high) 309512853Sgabeblack@google.com{ 309612853Sgabeblack@google.com if (high) 309712853Sgabeblack@google.com return m_rep->set(i, m_params); 309812853Sgabeblack@google.com else 309912853Sgabeblack@google.com return m_rep->clear(i, m_params); 310012853Sgabeblack@google.com} 310112853Sgabeblack@google.com 310212853Sgabeblack@google.cominline bool 310312853Sgabeblack@google.comsc_fxnum::get_slice(int i, int j, sc_bv_base &bv) const 310412853Sgabeblack@google.com{ 310512853Sgabeblack@google.com return m_rep->get_slice(i, j, m_params, bv); 310612853Sgabeblack@google.com} 310712853Sgabeblack@google.com 310812853Sgabeblack@google.cominline bool 310912853Sgabeblack@google.comsc_fxnum::set_slice(int i, int j, const sc_bv_base &bv) 311012853Sgabeblack@google.com{ 311112853Sgabeblack@google.com return m_rep->set_slice(i, j, m_params, bv); 311212853Sgabeblack@google.com} 311312853Sgabeblack@google.com 311412853Sgabeblack@google.cominline ::std::ostream & 311512853Sgabeblack@google.comoperator << (::std::ostream &os, const sc_fxnum &a) 311612853Sgabeblack@google.com{ 311712853Sgabeblack@google.com a.print(os); 311812853Sgabeblack@google.com return os; 311912853Sgabeblack@google.com} 312012853Sgabeblack@google.com 312112853Sgabeblack@google.cominline ::std::istream & 312212853Sgabeblack@google.comoperator >> (::std::istream &is, sc_fxnum &a) 312312853Sgabeblack@google.com{ 312412853Sgabeblack@google.com a.scan(is); 312512853Sgabeblack@google.com return is; 312612853Sgabeblack@google.com} 312712853Sgabeblack@google.com 312812853Sgabeblack@google.com 312912853Sgabeblack@google.com// ---------------------------------------------------------------------------- 313012853Sgabeblack@google.com// CLASS : sc_fxnum_fast 313112853Sgabeblack@google.com// 313212853Sgabeblack@google.com// Base class for the fixed-point types; limited precision. 313312853Sgabeblack@google.com// ---------------------------------------------------------------------------- 313412853Sgabeblack@google.com 313512853Sgabeblack@google.cominline sc_fxnum_fast_observer * 313612853Sgabeblack@google.comsc_fxnum_fast::observer() const 313712853Sgabeblack@google.com{ 313812853Sgabeblack@google.com return m_observer; 313912853Sgabeblack@google.com} 314012853Sgabeblack@google.com 314112853Sgabeblack@google.com 314212853Sgabeblack@google.com// constructors 314312853Sgabeblack@google.cominline sc_fxnum_fast::sc_fxnum_fast(const sc_fxtype_params &type_params_, 314412853Sgabeblack@google.com sc_enc enc_, 314512853Sgabeblack@google.com const sc_fxcast_switch &cast_sw, 314612853Sgabeblack@google.com sc_fxnum_fast_observer *observer_) : 314712853Sgabeblack@google.com m_val(0.0), m_params(type_params_, enc_, cast_sw), m_q_flag(false), 314812853Sgabeblack@google.com m_o_flag(false), m_observer(observer_) 314912853Sgabeblack@google.com{ 315012853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_DEFAULT_ 315112853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_CONSTRUCT_(*this) 315212853Sgabeblack@google.com} 315312853Sgabeblack@google.com 315412853Sgabeblack@google.cominline sc_fxnum_fast::sc_fxnum_fast(const sc_fxnum_fast &a, 315512853Sgabeblack@google.com const sc_fxtype_params &type_params_, 315612853Sgabeblack@google.com sc_enc enc_, 315712853Sgabeblack@google.com const sc_fxcast_switch &cast_sw, 315812853Sgabeblack@google.com sc_fxnum_fast_observer *observer_) : 315912853Sgabeblack@google.com m_val(a.m_val), m_params(type_params_, enc_, cast_sw), m_q_flag(false), 316012853Sgabeblack@google.com m_o_flag(false), m_observer(observer_) 316112853Sgabeblack@google.com{ 316212853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_DEFAULT_ 316312853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(a) 316412853Sgabeblack@google.com cast(); 316512853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_CONSTRUCT_(*this) 316612853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(*this) 316712853Sgabeblack@google.com} 316812853Sgabeblack@google.com 316912853Sgabeblack@google.com#define DEFN_CTOR_T(tp, arg) \ 317012853Sgabeblack@google.cominline sc_fxnum_fast::sc_fxnum_fast( \ 317112853Sgabeblack@google.com tp a, const sc_fxtype_params &type_params_, sc_enc enc_, \ 317212853Sgabeblack@google.com const sc_fxcast_switch &cast_sw, \ 317312853Sgabeblack@google.com sc_fxnum_fast_observer *observer_) : \ 317412853Sgabeblack@google.com m_val(arg), m_params(type_params_, enc_, cast_sw), m_q_flag(false), \ 317512853Sgabeblack@google.com m_o_flag(false), m_observer(observer_) \ 317612853Sgabeblack@google.com{ \ 317712853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_DEFAULT_ \ 317812853Sgabeblack@google.com cast(); \ 317912853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_CONSTRUCT_(*this) \ 318012853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(*this) \ 318112853Sgabeblack@google.com} 318212853Sgabeblack@google.com 318312853Sgabeblack@google.com#define DEFN_CTOR_T_A(tp) DEFN_CTOR_T(tp, static_cast<double>(a)) 318412853Sgabeblack@google.com#define DEFN_CTOR_T_B(tp) DEFN_CTOR_T(tp, sc_fxval_fast::from_string(a)) 318512853Sgabeblack@google.com#define DEFN_CTOR_T_C(tp) DEFN_CTOR_T(tp, a.to_double()) 318612853Sgabeblack@google.com 318712853Sgabeblack@google.comDEFN_CTOR_T_A(int) 318812853Sgabeblack@google.comDEFN_CTOR_T_A(unsigned int) 318912853Sgabeblack@google.comDEFN_CTOR_T_A(long) 319012853Sgabeblack@google.comDEFN_CTOR_T_A(unsigned long) 319112853Sgabeblack@google.comDEFN_CTOR_T_A(float) 319212853Sgabeblack@google.comDEFN_CTOR_T_A(double) 319312853Sgabeblack@google.comDEFN_CTOR_T_B(const char *) 319412853Sgabeblack@google.comDEFN_CTOR_T_C(const sc_fxval &) 319512853Sgabeblack@google.comDEFN_CTOR_T_C(const sc_fxval_fast &) 319612853Sgabeblack@google.comDEFN_CTOR_T_C(const sc_fxnum &) 319712853Sgabeblack@google.com 319812853Sgabeblack@google.comDEFN_CTOR_T_A(int64) 319912853Sgabeblack@google.comDEFN_CTOR_T_A(uint64) 320012853Sgabeblack@google.comDEFN_CTOR_T_C(const sc_int_base &) 320112853Sgabeblack@google.comDEFN_CTOR_T_C(const sc_uint_base &) 320212853Sgabeblack@google.comDEFN_CTOR_T_C(const sc_signed &) 320312853Sgabeblack@google.comDEFN_CTOR_T_C(const sc_unsigned &) 320412853Sgabeblack@google.com 320512853Sgabeblack@google.com#undef DEFN_CTOR_T 320612853Sgabeblack@google.com#undef DEFN_CTOR_T_A 320712853Sgabeblack@google.com#undef DEFN_CTOR_T_B 320812853Sgabeblack@google.com#undef DEFN_CTOR_T_C 320912853Sgabeblack@google.com#undef DEFN_CTOR_T_D 321012853Sgabeblack@google.com#undef DEFN_CTOR_T_E 321112853Sgabeblack@google.com 321212853Sgabeblack@google.cominline sc_fxnum_fast::~sc_fxnum_fast() 321312853Sgabeblack@google.com{ 321412853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_DESTRUCT_(*this) 321512853Sgabeblack@google.com} 321612853Sgabeblack@google.com 321712853Sgabeblack@google.com// internal use only; 321812853Sgabeblack@google.cominline double 321912853Sgabeblack@google.comsc_fxnum_fast::get_val() const 322012853Sgabeblack@google.com{ 322112853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(*this) 322212853Sgabeblack@google.com return m_val; 322312853Sgabeblack@google.com} 322412853Sgabeblack@google.com 322512853Sgabeblack@google.com// unary operators 322612853Sgabeblack@google.cominline const sc_fxval_fast 322712853Sgabeblack@google.comsc_fxnum_fast::operator - () const 322812853Sgabeblack@google.com{ 322912853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(*this) 323012853Sgabeblack@google.com return sc_fxval_fast(- m_val); 323112853Sgabeblack@google.com} 323212853Sgabeblack@google.com 323312853Sgabeblack@google.cominline const sc_fxval_fast 323412853Sgabeblack@google.comsc_fxnum_fast::operator + () const 323512853Sgabeblack@google.com{ 323612853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(*this) 323712853Sgabeblack@google.com return sc_fxval_fast(m_val); 323812853Sgabeblack@google.com} 323912853Sgabeblack@google.com 324012853Sgabeblack@google.com// unary functions 324112853Sgabeblack@google.cominline void 324212853Sgabeblack@google.comneg(sc_fxval_fast &c, const sc_fxnum_fast &a) 324312853Sgabeblack@google.com{ 324412853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(a) 324512853Sgabeblack@google.com c.set_val(- a.m_val); 324612853Sgabeblack@google.com} 324712853Sgabeblack@google.com 324812853Sgabeblack@google.cominline void 324912853Sgabeblack@google.comneg(sc_fxnum_fast &c, const sc_fxnum_fast &a) 325012853Sgabeblack@google.com{ 325112853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(a) 325212853Sgabeblack@google.com c.m_val = - a.m_val; 325312853Sgabeblack@google.com c.cast(); 325412853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(c) 325512853Sgabeblack@google.com} 325612853Sgabeblack@google.com 325712853Sgabeblack@google.com// binary operators 325812853Sgabeblack@google.com#define DEFN_BIN_OP_T(op, tp) \ 325912853Sgabeblack@google.cominline const sc_fxval_fast \ 326012853Sgabeblack@google.comoperator op (const sc_fxnum_fast &a, tp b) \ 326112853Sgabeblack@google.com{ \ 326212853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(a) \ 326312853Sgabeblack@google.com sc_fxval_fast tmp(b); \ 326412853Sgabeblack@google.com return sc_fxval_fast(a.m_val op tmp.get_val()); \ 326512853Sgabeblack@google.com} \ 326612853Sgabeblack@google.com \ 326712853Sgabeblack@google.cominline const sc_fxval_fast \ 326812853Sgabeblack@google.comoperator op (tp a, const sc_fxnum_fast &b) \ 326912853Sgabeblack@google.com{ \ 327012853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(b) \ 327112853Sgabeblack@google.com sc_fxval_fast tmp(a); \ 327212853Sgabeblack@google.com return sc_fxval_fast(tmp.get_val() op b.m_val); \ 327312853Sgabeblack@google.com} 327412853Sgabeblack@google.com 327512853Sgabeblack@google.com#define DEFN_BIN_OP_OTHER(op) \ 327612853Sgabeblack@google.comDEFN_BIN_OP_T(op, int64) \ 327712853Sgabeblack@google.comDEFN_BIN_OP_T(op, uint64) \ 327812853Sgabeblack@google.comDEFN_BIN_OP_T(op, const sc_int_base &) \ 327912853Sgabeblack@google.comDEFN_BIN_OP_T(op, const sc_uint_base &) \ 328012853Sgabeblack@google.comDEFN_BIN_OP_T(op, const sc_signed &) \ 328112853Sgabeblack@google.comDEFN_BIN_OP_T(op, const sc_unsigned &) 328212853Sgabeblack@google.com 328312853Sgabeblack@google.com#define DEFN_BIN_OP(op, dummy) \ 328412853Sgabeblack@google.cominline const sc_fxval_fast \ 328512853Sgabeblack@google.comoperator op (const sc_fxnum_fast &a, const sc_fxnum_fast &b) \ 328612853Sgabeblack@google.com{ \ 328712853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(a) \ 328812853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(b) \ 328912853Sgabeblack@google.com return sc_fxval_fast(a.m_val op b.m_val); \ 329012853Sgabeblack@google.com} \ 329112853Sgabeblack@google.com \ 329212853Sgabeblack@google.cominline const sc_fxval_fast \ 329312853Sgabeblack@google.comoperator op (const sc_fxnum_fast &a, const sc_fxval_fast &b) \ 329412853Sgabeblack@google.com{ \ 329512853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(a) \ 329612853Sgabeblack@google.com return sc_fxval_fast(a.m_val op b.get_val()); \ 329712853Sgabeblack@google.com} \ 329812853Sgabeblack@google.com \ 329912853Sgabeblack@google.cominline const sc_fxval_fast \ 330012853Sgabeblack@google.comoperator op (const sc_fxval_fast &a, const sc_fxnum_fast &b) \ 330112853Sgabeblack@google.com{ \ 330212853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(b) \ 330312853Sgabeblack@google.com return sc_fxval_fast(a.get_val() op b.m_val); \ 330412853Sgabeblack@google.com} \ 330512853Sgabeblack@google.com \ 330612853Sgabeblack@google.comDEFN_BIN_OP_T(op, int) \ 330712853Sgabeblack@google.comDEFN_BIN_OP_T(op, unsigned int) \ 330812853Sgabeblack@google.comDEFN_BIN_OP_T(op, long) \ 330912853Sgabeblack@google.comDEFN_BIN_OP_T(op, unsigned long) \ 331012853Sgabeblack@google.comDEFN_BIN_OP_T(op, float) \ 331112853Sgabeblack@google.comDEFN_BIN_OP_T(op, double) \ 331212853Sgabeblack@google.comDEFN_BIN_OP_T(op, const char *) \ 331312853Sgabeblack@google.comDEFN_BIN_OP_OTHER(op) 331412853Sgabeblack@google.com 331512853Sgabeblack@google.comDEFN_BIN_OP(*, mult) 331612853Sgabeblack@google.comDEFN_BIN_OP(+, add) 331712853Sgabeblack@google.comDEFN_BIN_OP(-, sub) 331812853Sgabeblack@google.com//DEFN_BIN_OP(/, div) 331912853Sgabeblack@google.cominline const sc_fxval_fast 332012853Sgabeblack@google.comoperator / (const sc_fxnum_fast &a, const sc_fxnum_fast &b) 332112853Sgabeblack@google.com{ 332212853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(a) 332312853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(b) 332412853Sgabeblack@google.com return sc_fxval_fast(a.m_val / b.m_val); 332512853Sgabeblack@google.com} 332612853Sgabeblack@google.com 332712853Sgabeblack@google.cominline const sc_fxval_fast 332812853Sgabeblack@google.comoperator / (const sc_fxnum_fast &a, const sc_fxval_fast &b) 332912853Sgabeblack@google.com{ 333012853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(a) 333112853Sgabeblack@google.com return sc_fxval_fast(a.m_val / b.get_val()); 333212853Sgabeblack@google.com} 333312853Sgabeblack@google.com 333412853Sgabeblack@google.cominline const sc_fxval_fast 333512853Sgabeblack@google.comoperator / (const sc_fxval_fast &a, const sc_fxnum_fast &b) 333612853Sgabeblack@google.com{ 333712853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(b) 333812853Sgabeblack@google.com return sc_fxval_fast(a.get_val() / b.m_val); 333912853Sgabeblack@google.com} 334012853Sgabeblack@google.com 334112853Sgabeblack@google.comDEFN_BIN_OP_T(/, int) 334212853Sgabeblack@google.comDEFN_BIN_OP_T(/, unsigned int) 334312853Sgabeblack@google.comDEFN_BIN_OP_T(/, long) 334412853Sgabeblack@google.comDEFN_BIN_OP_T(/, unsigned long) 334512853Sgabeblack@google.comDEFN_BIN_OP_T(/, float) 334612853Sgabeblack@google.comDEFN_BIN_OP_T(/, double) 334712853Sgabeblack@google.comDEFN_BIN_OP_T(/, const char *) 334812853Sgabeblack@google.com//DEFN_BIN_OP_OTHER(/) 334912853Sgabeblack@google.com 335012853Sgabeblack@google.comDEFN_BIN_OP_T(/, int64) 335112853Sgabeblack@google.comDEFN_BIN_OP_T(/, uint64) 335212853Sgabeblack@google.comDEFN_BIN_OP_T(/, const sc_int_base &) 335312853Sgabeblack@google.comDEFN_BIN_OP_T(/, const sc_uint_base &) 335412853Sgabeblack@google.comDEFN_BIN_OP_T(/, const sc_signed &) 335512853Sgabeblack@google.comDEFN_BIN_OP_T(/, const sc_unsigned &) 335612853Sgabeblack@google.com 335712853Sgabeblack@google.com#undef DEFN_BIN_OP_T 335812853Sgabeblack@google.com#undef DEFN_BIN_OP_OTHER 335912853Sgabeblack@google.com#undef DEFN_BIN_OP 336012853Sgabeblack@google.com 336112853Sgabeblack@google.cominline const sc_fxval_fast 336212853Sgabeblack@google.comoperator << (const sc_fxnum_fast &a, int b) 336312853Sgabeblack@google.com{ 336412853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(a) 336512853Sgabeblack@google.com return sc_fxval_fast(a.m_val *scfx_pow2(b)); 336612853Sgabeblack@google.com} 336712853Sgabeblack@google.com 336812853Sgabeblack@google.cominline const sc_fxval_fast 336912853Sgabeblack@google.comoperator >> (const sc_fxnum_fast &a, int b) 337012853Sgabeblack@google.com{ 337112853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(a) 337212853Sgabeblack@google.com return sc_fxval_fast(a.m_val *scfx_pow2(-b)); 337312853Sgabeblack@google.com} 337412853Sgabeblack@google.com 337512853Sgabeblack@google.com// binary functions 337612853Sgabeblack@google.com#define DEFN_BIN_FNC_T(fnc, op, tp) \ 337712853Sgabeblack@google.cominline void \ 337812853Sgabeblack@google.comfnc (sc_fxval_fast &c, const sc_fxnum_fast &a, tp b) \ 337912853Sgabeblack@google.com{ \ 338012853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(a) \ 338112853Sgabeblack@google.com sc_fxval_fast tmp(b); \ 338212853Sgabeblack@google.com c.set_val(a.m_val op tmp.get_val()); \ 338312853Sgabeblack@google.com} \ 338412853Sgabeblack@google.com \ 338512853Sgabeblack@google.cominline void \ 338612853Sgabeblack@google.comfnc (sc_fxval_fast &c, tp a, const sc_fxnum_fast &b) \ 338712853Sgabeblack@google.com{ \ 338812853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(b) \ 338912853Sgabeblack@google.com sc_fxval_fast tmp(a); \ 339012853Sgabeblack@google.com c.set_val(tmp.get_val() op b.m_val); \ 339112853Sgabeblack@google.com} \ 339212853Sgabeblack@google.com \ 339312853Sgabeblack@google.cominline void \ 339412853Sgabeblack@google.comfnc (sc_fxnum_fast &c, const sc_fxnum_fast &a, tp b) \ 339512853Sgabeblack@google.com{ \ 339612853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(a) \ 339712853Sgabeblack@google.com sc_fxval_fast tmp(b); \ 339812853Sgabeblack@google.com c.m_val = a.m_val op tmp.get_val(); \ 339912853Sgabeblack@google.com c.cast(); \ 340012853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(c) \ 340112853Sgabeblack@google.com} \ 340212853Sgabeblack@google.com \ 340312853Sgabeblack@google.cominline void \ 340412853Sgabeblack@google.comfnc (sc_fxnum_fast &c, tp a, const sc_fxnum_fast &b) \ 340512853Sgabeblack@google.com{ \ 340612853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(b) \ 340712853Sgabeblack@google.com sc_fxval_fast tmp(a); \ 340812853Sgabeblack@google.com c.m_val = tmp.get_val() op b.m_val; \ 340912853Sgabeblack@google.com c.cast(); \ 341012853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(c) \ 341112853Sgabeblack@google.com} 341212853Sgabeblack@google.com 341312853Sgabeblack@google.com#define DEFN_BIN_FNC_OTHER(fnc, op) \ 341412853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, op, int64) \ 341512853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, op, uint64) \ 341612853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, op, const sc_int_base &) \ 341712853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, op, const sc_uint_base &) \ 341812853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, op, const sc_signed &) \ 341912853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, op, const sc_unsigned &) 342012853Sgabeblack@google.com 342112853Sgabeblack@google.com#define DEFN_BIN_FNC(fnc, op) \ 342212853Sgabeblack@google.cominline void \ 342312853Sgabeblack@google.comfnc (sc_fxval_fast &c, const sc_fxnum_fast &a, const sc_fxnum_fast &b) \ 342412853Sgabeblack@google.com{ \ 342512853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(a) \ 342612853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(b) \ 342712853Sgabeblack@google.com c.set_val(a.m_val op b.m_val); \ 342812853Sgabeblack@google.com} \ 342912853Sgabeblack@google.com \ 343012853Sgabeblack@google.cominline void \ 343112853Sgabeblack@google.comfnc (sc_fxnum_fast &c, const sc_fxnum_fast &a, const sc_fxnum_fast &b) \ 343212853Sgabeblack@google.com{ \ 343312853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(a) \ 343412853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(b) \ 343512853Sgabeblack@google.com c.m_val = a.m_val op b.m_val; \ 343612853Sgabeblack@google.com c.cast(); \ 343712853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(c) \ 343812853Sgabeblack@google.com} \ 343912853Sgabeblack@google.com \ 344012853Sgabeblack@google.cominline void \ 344112853Sgabeblack@google.comfnc (sc_fxval_fast &c, const sc_fxnum_fast &a, const sc_fxval_fast &b) \ 344212853Sgabeblack@google.com{ \ 344312853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(a) \ 344412853Sgabeblack@google.com c.set_val(a.m_val op b.get_val()); \ 344512853Sgabeblack@google.com} \ 344612853Sgabeblack@google.com \ 344712853Sgabeblack@google.cominline void \ 344812853Sgabeblack@google.comfnc (sc_fxval_fast &c, const sc_fxval_fast &a, const sc_fxnum_fast &b) \ 344912853Sgabeblack@google.com{ \ 345012853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(b) \ 345112853Sgabeblack@google.com c.set_val(a.get_val() op b.m_val); \ 345212853Sgabeblack@google.com} \ 345312853Sgabeblack@google.com \ 345412853Sgabeblack@google.cominline void \ 345512853Sgabeblack@google.comfnc (sc_fxnum_fast &c, const sc_fxnum_fast &a, const sc_fxval_fast &b) \ 345612853Sgabeblack@google.com{ \ 345712853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(a) \ 345812853Sgabeblack@google.com c.m_val = a.m_val op b.get_val(); \ 345912853Sgabeblack@google.com c.cast(); \ 346012853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(c) \ 346112853Sgabeblack@google.com} \ 346212853Sgabeblack@google.com \ 346312853Sgabeblack@google.cominline void \ 346412853Sgabeblack@google.comfnc (sc_fxnum_fast &c, const sc_fxval_fast &a, const sc_fxnum_fast &b) \ 346512853Sgabeblack@google.com{ \ 346612853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(b) \ 346712853Sgabeblack@google.com c.m_val = a.get_val() op b.m_val; \ 346812853Sgabeblack@google.com c.cast(); \ 346912853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(c) \ 347012853Sgabeblack@google.com} \ 347112853Sgabeblack@google.com \ 347212853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, op, int) \ 347312853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, op, unsigned int) \ 347412853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, op, long) \ 347512853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, op, unsigned long) \ 347612853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, op, float) \ 347712853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, op, double) \ 347812853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, op, const char *) \ 347912853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, op, const sc_fxval &) \ 348012853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, op, const sc_fxnum &) \ 348112853Sgabeblack@google.comDEFN_BIN_FNC_OTHER(fnc, op) 348212853Sgabeblack@google.com 348312853Sgabeblack@google.comDEFN_BIN_FNC(mult, *) 348412853Sgabeblack@google.comDEFN_BIN_FNC(div, /) 348512853Sgabeblack@google.comDEFN_BIN_FNC(add, +) 348612853Sgabeblack@google.comDEFN_BIN_FNC(sub, -) 348712853Sgabeblack@google.com 348812853Sgabeblack@google.com#undef DEFN_BIN_FNC_T 348912853Sgabeblack@google.com#undef DEFN_BIN_FNC_OTHER 349012853Sgabeblack@google.com#undef DEFN_BIN_FNC 349112853Sgabeblack@google.com 349212853Sgabeblack@google.cominline void 349312853Sgabeblack@google.comlshift(sc_fxval_fast &c, const sc_fxnum_fast &a, int b) 349412853Sgabeblack@google.com{ 349512853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(a) 349612853Sgabeblack@google.com c.set_val(a.m_val * scfx_pow2(b)); 349712853Sgabeblack@google.com} 349812853Sgabeblack@google.com 349912853Sgabeblack@google.cominline void 350012853Sgabeblack@google.comrshift(sc_fxval_fast &c, const sc_fxnum_fast &a, int b) 350112853Sgabeblack@google.com{ 350212853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(a) 350312853Sgabeblack@google.com c.set_val(a.m_val * scfx_pow2(-b)); 350412853Sgabeblack@google.com} 350512853Sgabeblack@google.com 350612853Sgabeblack@google.cominline void 350712853Sgabeblack@google.comlshift(sc_fxnum_fast &c, const sc_fxnum_fast &a, int b) 350812853Sgabeblack@google.com{ 350912853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(a) 351012853Sgabeblack@google.com c.m_val = a.m_val * scfx_pow2(b); 351112853Sgabeblack@google.com c.cast(); 351212853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(c) 351312853Sgabeblack@google.com} 351412853Sgabeblack@google.com 351512853Sgabeblack@google.cominline void 351612853Sgabeblack@google.comrshift(sc_fxnum_fast &c, const sc_fxnum_fast &a, int b) 351712853Sgabeblack@google.com{ 351812853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(a) 351912853Sgabeblack@google.com c.m_val = a.m_val * scfx_pow2(-b); 352012853Sgabeblack@google.com c.cast(); 352112853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(c) 352212853Sgabeblack@google.com} 352312853Sgabeblack@google.com 352412853Sgabeblack@google.com// relational (including equality) operators 352512853Sgabeblack@google.com#define DEFN_REL_OP_T(op, tp) \ 352612853Sgabeblack@google.cominline bool \ 352712853Sgabeblack@google.comoperator op (const sc_fxnum_fast &a, tp b) \ 352812853Sgabeblack@google.com{ \ 352912853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(a) \ 353012853Sgabeblack@google.com sc_fxval_fast tmp(b); \ 353112853Sgabeblack@google.com return (a.m_val op tmp.get_val()); \ 353212853Sgabeblack@google.com} \ 353312853Sgabeblack@google.com \ 353412853Sgabeblack@google.cominline bool \ 353512853Sgabeblack@google.comoperator op (tp a, const sc_fxnum_fast &b) \ 353612853Sgabeblack@google.com{ \ 353712853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(b) \ 353812853Sgabeblack@google.com sc_fxval_fast tmp(a); \ 353912853Sgabeblack@google.com return (tmp.get_val() op b.m_val); \ 354012853Sgabeblack@google.com} 354112853Sgabeblack@google.com 354212853Sgabeblack@google.com#define DEFN_REL_OP_OTHER(op) \ 354312853Sgabeblack@google.comDEFN_REL_OP_T(op, int64) \ 354412853Sgabeblack@google.comDEFN_REL_OP_T(op, uint64) \ 354512853Sgabeblack@google.comDEFN_REL_OP_T(op, const sc_int_base &) \ 354612853Sgabeblack@google.comDEFN_REL_OP_T(op, const sc_uint_base &) \ 354712853Sgabeblack@google.comDEFN_REL_OP_T(op, const sc_signed &) \ 354812853Sgabeblack@google.comDEFN_REL_OP_T(op, const sc_unsigned &) 354912853Sgabeblack@google.com 355012853Sgabeblack@google.com#define DEFN_REL_OP(op) \ 355112853Sgabeblack@google.cominline bool \ 355212853Sgabeblack@google.comoperator op (const sc_fxnum_fast &a, const sc_fxnum_fast &b) \ 355312853Sgabeblack@google.com{ \ 355412853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(a) \ 355512853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(b) \ 355612853Sgabeblack@google.com return (a.m_val op b.m_val); \ 355712853Sgabeblack@google.com} \ 355812853Sgabeblack@google.com \ 355912853Sgabeblack@google.cominline bool \ 356012853Sgabeblack@google.comoperator op (const sc_fxnum_fast &a, const sc_fxval_fast &b) \ 356112853Sgabeblack@google.com{ \ 356212853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(a) \ 356312853Sgabeblack@google.com return (a.m_val op b.get_val()); \ 356412853Sgabeblack@google.com} \ 356512853Sgabeblack@google.com \ 356612853Sgabeblack@google.cominline bool \ 356712853Sgabeblack@google.comoperator op (const sc_fxval_fast &a, const sc_fxnum_fast &b) \ 356812853Sgabeblack@google.com{ \ 356912853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(b) \ 357012853Sgabeblack@google.com return (a.get_val() op b.m_val); \ 357112853Sgabeblack@google.com} \ 357212853Sgabeblack@google.com \ 357312853Sgabeblack@google.comDEFN_REL_OP_T(op, int) \ 357412853Sgabeblack@google.comDEFN_REL_OP_T(op, unsigned int) \ 357512853Sgabeblack@google.comDEFN_REL_OP_T(op, long) \ 357612853Sgabeblack@google.comDEFN_REL_OP_T(op, unsigned long) \ 357712853Sgabeblack@google.comDEFN_REL_OP_T(op, float) \ 357812853Sgabeblack@google.comDEFN_REL_OP_T(op, double) \ 357912853Sgabeblack@google.comDEFN_REL_OP_T(op, const char *) \ 358012853Sgabeblack@google.comDEFN_REL_OP_OTHER(op) 358112853Sgabeblack@google.com 358212853Sgabeblack@google.comDEFN_REL_OP(<) 358312853Sgabeblack@google.comDEFN_REL_OP(<=) 358412853Sgabeblack@google.comDEFN_REL_OP(>) 358512853Sgabeblack@google.comDEFN_REL_OP(>=) 358612853Sgabeblack@google.comDEFN_REL_OP(==) 358712853Sgabeblack@google.comDEFN_REL_OP(!=) 358812853Sgabeblack@google.com 358912853Sgabeblack@google.com#undef DEFN_REL_OP_T 359012853Sgabeblack@google.com#undef DEFN_REL_OP_OTHER 359112853Sgabeblack@google.com#undef DEFN_REL_OP 359212853Sgabeblack@google.com 359312853Sgabeblack@google.com// assignment operators 359412853Sgabeblack@google.com 359512853Sgabeblack@google.cominline sc_fxnum_fast & 359612853Sgabeblack@google.comsc_fxnum_fast::operator = (const sc_fxnum_fast &a) 359712853Sgabeblack@google.com{ 359812853Sgabeblack@google.com if (&a != this) { 359912853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(a) 360012853Sgabeblack@google.com m_val = a.m_val; 360112853Sgabeblack@google.com cast(); 360212853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(*this) 360312853Sgabeblack@google.com } 360412853Sgabeblack@google.com return *this; 360512853Sgabeblack@google.com} 360612853Sgabeblack@google.com 360712853Sgabeblack@google.cominline sc_fxnum_fast & 360812853Sgabeblack@google.comsc_fxnum_fast::operator = (const sc_fxval_fast &a) 360912853Sgabeblack@google.com{ 361012853Sgabeblack@google.com m_val = a.get_val(); 361112853Sgabeblack@google.com cast(); 361212853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(*this) 361312853Sgabeblack@google.com return *this; 361412853Sgabeblack@google.com} 361512853Sgabeblack@google.com 361612853Sgabeblack@google.com#define DEFN_ASN_OP_T(tp) \ 361712853Sgabeblack@google.cominline sc_fxnum_fast & \ 361812853Sgabeblack@google.comsc_fxnum_fast::operator = (tp a) \ 361912853Sgabeblack@google.com{ \ 362012853Sgabeblack@google.com sc_fxval_fast tmp(a); \ 362112853Sgabeblack@google.com m_val = tmp.get_val(); \ 362212853Sgabeblack@google.com cast(); \ 362312853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(*this) \ 362412853Sgabeblack@google.com return *this; \ 362512853Sgabeblack@google.com} 362612853Sgabeblack@google.com 362712853Sgabeblack@google.comDEFN_ASN_OP_T(int) 362812853Sgabeblack@google.comDEFN_ASN_OP_T(unsigned int) 362912853Sgabeblack@google.comDEFN_ASN_OP_T(long) 363012853Sgabeblack@google.comDEFN_ASN_OP_T(unsigned long) 363112853Sgabeblack@google.comDEFN_ASN_OP_T(float) 363212853Sgabeblack@google.comDEFN_ASN_OP_T(double) 363312853Sgabeblack@google.comDEFN_ASN_OP_T(const char *) 363412853Sgabeblack@google.comDEFN_ASN_OP_T(const sc_fxval &) 363512853Sgabeblack@google.comDEFN_ASN_OP_T(const sc_fxnum &) 363612853Sgabeblack@google.com 363712853Sgabeblack@google.comDEFN_ASN_OP_T(int64) 363812853Sgabeblack@google.comDEFN_ASN_OP_T(uint64) 363912853Sgabeblack@google.comDEFN_ASN_OP_T(const sc_int_base &) 364012853Sgabeblack@google.comDEFN_ASN_OP_T(const sc_uint_base &) 364112853Sgabeblack@google.comDEFN_ASN_OP_T(const sc_signed &) 364212853Sgabeblack@google.comDEFN_ASN_OP_T(const sc_unsigned &) 364312853Sgabeblack@google.com 364412853Sgabeblack@google.com#undef DEFN_ASN_OP_T 364512853Sgabeblack@google.com 364612853Sgabeblack@google.com#define DEFN_ASN_OP_T(op, tp) \ 364712853Sgabeblack@google.cominline sc_fxnum_fast & \ 364812853Sgabeblack@google.comsc_fxnum_fast::operator op (tp b) \ 364912853Sgabeblack@google.com{ \ 365012853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(*this) \ 365112853Sgabeblack@google.com sc_fxval_fast tmp(b); \ 365212853Sgabeblack@google.com m_val op tmp.get_val(); \ 365312853Sgabeblack@google.com cast(); \ 365412853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(*this) \ 365512853Sgabeblack@google.com return *this; \ 365612853Sgabeblack@google.com} 365712853Sgabeblack@google.com 365812853Sgabeblack@google.com#define DEFN_ASN_OP_OTHER(op) \ 365912853Sgabeblack@google.comDEFN_ASN_OP_T(op, int64) \ 366012853Sgabeblack@google.comDEFN_ASN_OP_T(op, uint64) \ 366112853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_int_base &) \ 366212853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_uint_base &) \ 366312853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_signed &) \ 366412853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_unsigned &) 366512853Sgabeblack@google.com 366612853Sgabeblack@google.com#define DEFN_ASN_OP(op) \ 366712853Sgabeblack@google.cominline sc_fxnum_fast & \ 366812853Sgabeblack@google.comsc_fxnum_fast::operator op (const sc_fxnum_fast &b) \ 366912853Sgabeblack@google.com{ \ 367012853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(*this) \ 367112853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(b) \ 367212853Sgabeblack@google.com m_val op b.m_val; \ 367312853Sgabeblack@google.com cast(); \ 367412853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(*this) \ 367512853Sgabeblack@google.com return *this; \ 367612853Sgabeblack@google.com} \ 367712853Sgabeblack@google.com \ 367812853Sgabeblack@google.cominline sc_fxnum_fast & \ 367912853Sgabeblack@google.comsc_fxnum_fast::operator op (const sc_fxval_fast &b) \ 368012853Sgabeblack@google.com{ \ 368112853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(*this) \ 368212853Sgabeblack@google.com m_val op b.get_val(); \ 368312853Sgabeblack@google.com cast(); \ 368412853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(*this) \ 368512853Sgabeblack@google.com return *this; \ 368612853Sgabeblack@google.com} \ 368712853Sgabeblack@google.com \ 368812853Sgabeblack@google.comDEFN_ASN_OP_T(op, int) \ 368912853Sgabeblack@google.comDEFN_ASN_OP_T(op, unsigned int) \ 369012853Sgabeblack@google.comDEFN_ASN_OP_T(op, long) \ 369112853Sgabeblack@google.comDEFN_ASN_OP_T(op, unsigned long) \ 369212853Sgabeblack@google.comDEFN_ASN_OP_T(op, float) \ 369312853Sgabeblack@google.comDEFN_ASN_OP_T(op, double) \ 369412853Sgabeblack@google.comDEFN_ASN_OP_T(op, const char *) \ 369512853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_fxval &) \ 369612853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_fxnum &) \ 369712853Sgabeblack@google.comDEFN_ASN_OP_OTHER(op) 369812853Sgabeblack@google.com 369912853Sgabeblack@google.comDEFN_ASN_OP(*=) 370012853Sgabeblack@google.comDEFN_ASN_OP(/=) 370112853Sgabeblack@google.comDEFN_ASN_OP(+=) 370212853Sgabeblack@google.comDEFN_ASN_OP(-=) 370312853Sgabeblack@google.com 370412853Sgabeblack@google.com#undef DEFN_ASN_OP_T 370512853Sgabeblack@google.com#undef DEFN_ASN_OP_OTHER 370612853Sgabeblack@google.com#undef DEFN_ASN_OP 370712853Sgabeblack@google.com 370812853Sgabeblack@google.cominline sc_fxnum_fast & 370912853Sgabeblack@google.comsc_fxnum_fast::operator <<= (int b) 371012853Sgabeblack@google.com{ 371112853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(*this) 371212853Sgabeblack@google.com m_val *= scfx_pow2(b); 371312853Sgabeblack@google.com cast(); 371412853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(*this) 371512853Sgabeblack@google.com return *this; 371612853Sgabeblack@google.com} 371712853Sgabeblack@google.com 371812853Sgabeblack@google.cominline sc_fxnum_fast & 371912853Sgabeblack@google.comsc_fxnum_fast::operator >>= (int b) 372012853Sgabeblack@google.com{ 372112853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(*this) 372212853Sgabeblack@google.com m_val *= scfx_pow2(-b); 372312853Sgabeblack@google.com cast(); 372412853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(*this) 372512853Sgabeblack@google.com return *this; 372612853Sgabeblack@google.com} 372712853Sgabeblack@google.com 372812853Sgabeblack@google.com// auto-increment and auto-decrement 372912853Sgabeblack@google.cominline const sc_fxval_fast 373012853Sgabeblack@google.comsc_fxnum_fast::operator ++ (int) 373112853Sgabeblack@google.com{ 373212853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(*this) 373312853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(*this) 373412853Sgabeblack@google.com double c = m_val; 373512853Sgabeblack@google.com m_val = m_val + 1; 373612853Sgabeblack@google.com cast(); 373712853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(*this) 373812853Sgabeblack@google.com return sc_fxval_fast(c); 373912853Sgabeblack@google.com} 374012853Sgabeblack@google.com 374112853Sgabeblack@google.cominline const sc_fxval_fast 374212853Sgabeblack@google.comsc_fxnum_fast::operator -- (int) 374312853Sgabeblack@google.com{ 374412853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(*this) 374512853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(*this) 374612853Sgabeblack@google.com double c = m_val; 374712853Sgabeblack@google.com m_val = m_val - 1; 374812853Sgabeblack@google.com cast(); 374912853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(*this) 375012853Sgabeblack@google.com return sc_fxval_fast(c); 375112853Sgabeblack@google.com} 375212853Sgabeblack@google.com 375312853Sgabeblack@google.cominline sc_fxnum_fast & 375412853Sgabeblack@google.comsc_fxnum_fast::operator ++ () 375512853Sgabeblack@google.com{ 375612853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(*this) 375712853Sgabeblack@google.com m_val = m_val + 1; 375812853Sgabeblack@google.com cast(); 375912853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(*this) 376012853Sgabeblack@google.com return *this; 376112853Sgabeblack@google.com} 376212853Sgabeblack@google.com 376312853Sgabeblack@google.cominline sc_fxnum_fast & 376412853Sgabeblack@google.comsc_fxnum_fast::operator -- () 376512853Sgabeblack@google.com{ 376612853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(*this) 376712853Sgabeblack@google.com m_val = m_val - 1; 376812853Sgabeblack@google.com cast(); 376912853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_WRITE_(*this) 377012853Sgabeblack@google.com return *this; 377112853Sgabeblack@google.com} 377212853Sgabeblack@google.com 377312853Sgabeblack@google.com// bit selection 377412853Sgabeblack@google.cominline const sc_fxnum_fast_bitref 377512853Sgabeblack@google.comsc_fxnum_fast::operator [] (int i) const 377612853Sgabeblack@google.com{ 377713325Sgabeblack@google.com SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_); 377812853Sgabeblack@google.com return sc_fxnum_fast_bitref(const_cast<sc_fxnum_fast &>(*this), 377912853Sgabeblack@google.com i - m_params.fwl()); 378012853Sgabeblack@google.com} 378112853Sgabeblack@google.com 378212853Sgabeblack@google.cominline sc_fxnum_fast_bitref 378312853Sgabeblack@google.comsc_fxnum_fast::operator [] (int i) 378412853Sgabeblack@google.com{ 378513325Sgabeblack@google.com SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_); 378612853Sgabeblack@google.com return sc_fxnum_fast_bitref(*this, i - m_params.fwl()); 378712853Sgabeblack@google.com} 378812853Sgabeblack@google.com 378912853Sgabeblack@google.cominline const sc_fxnum_fast_bitref 379012853Sgabeblack@google.comsc_fxnum_fast::bit(int i) const 379112853Sgabeblack@google.com{ 379213325Sgabeblack@google.com SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_); 379312853Sgabeblack@google.com return sc_fxnum_fast_bitref(const_cast<sc_fxnum_fast &>(*this), 379412853Sgabeblack@google.com i - m_params.fwl()); 379512853Sgabeblack@google.com} 379612853Sgabeblack@google.com 379712853Sgabeblack@google.cominline sc_fxnum_fast_bitref 379812853Sgabeblack@google.comsc_fxnum_fast::bit(int i) 379912853Sgabeblack@google.com{ 380013325Sgabeblack@google.com SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_); 380112853Sgabeblack@google.com return sc_fxnum_fast_bitref(*this, i - m_params.fwl()); 380212853Sgabeblack@google.com} 380312853Sgabeblack@google.com 380412853Sgabeblack@google.com// part selection 380512853Sgabeblack@google.cominline const sc_fxnum_fast_subref 380612853Sgabeblack@google.comsc_fxnum_fast::operator () (int i, int j) const 380712853Sgabeblack@google.com{ 380813325Sgabeblack@google.com SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_); 380913325Sgabeblack@google.com SC_ERROR_IF_(j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_); 381012853Sgabeblack@google.com 381112853Sgabeblack@google.com return sc_fxnum_fast_subref(const_cast<sc_fxnum_fast &>(*this), 381212853Sgabeblack@google.com i - m_params.fwl(), j - m_params.fwl()); 381312853Sgabeblack@google.com} 381412853Sgabeblack@google.com 381512853Sgabeblack@google.cominline sc_fxnum_fast_subref 381612853Sgabeblack@google.comsc_fxnum_fast::operator () (int i, int j) 381712853Sgabeblack@google.com{ 381813325Sgabeblack@google.com SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_); 381913325Sgabeblack@google.com SC_ERROR_IF_(j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_); 382012853Sgabeblack@google.com 382112853Sgabeblack@google.com return sc_fxnum_fast_subref(*this, i - m_params.fwl(), j - m_params.fwl()); 382212853Sgabeblack@google.com} 382312853Sgabeblack@google.com 382412853Sgabeblack@google.cominline const sc_fxnum_fast_subref 382512853Sgabeblack@google.comsc_fxnum_fast::range(int i, int j) const 382612853Sgabeblack@google.com{ 382713325Sgabeblack@google.com SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_); 382813325Sgabeblack@google.com SC_ERROR_IF_(j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_); 382912853Sgabeblack@google.com 383012853Sgabeblack@google.com return sc_fxnum_fast_subref(const_cast<sc_fxnum_fast &>(*this), 383112853Sgabeblack@google.com i - m_params.fwl(), j - m_params.fwl()); 383212853Sgabeblack@google.com} 383312853Sgabeblack@google.com 383412853Sgabeblack@google.cominline sc_fxnum_fast_subref 383512853Sgabeblack@google.comsc_fxnum_fast::range(int i, int j) 383612853Sgabeblack@google.com{ 383713325Sgabeblack@google.com SC_ERROR_IF_(i < 0 || i >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_); 383813325Sgabeblack@google.com SC_ERROR_IF_(j < 0 || j >= m_params.wl(), sc_core::SC_ID_OUT_OF_RANGE_); 383912853Sgabeblack@google.com 384012853Sgabeblack@google.com return sc_fxnum_fast_subref(*this, i - m_params.fwl(), j - m_params.fwl()); 384112853Sgabeblack@google.com} 384212853Sgabeblack@google.com 384312853Sgabeblack@google.cominline const sc_fxnum_fast_subref 384412853Sgabeblack@google.comsc_fxnum_fast::operator () () const 384512853Sgabeblack@google.com{ 384612853Sgabeblack@google.com return this->operator () (m_params.wl() - 1, 0); 384712853Sgabeblack@google.com} 384812853Sgabeblack@google.com 384912853Sgabeblack@google.cominline sc_fxnum_fast_subref 385012853Sgabeblack@google.comsc_fxnum_fast::operator () () 385112853Sgabeblack@google.com{ 385212853Sgabeblack@google.com return this->operator () (m_params.wl() - 1, 0); 385312853Sgabeblack@google.com} 385412853Sgabeblack@google.com 385512853Sgabeblack@google.cominline const sc_fxnum_fast_subref 385612853Sgabeblack@google.comsc_fxnum_fast::range() const 385712853Sgabeblack@google.com{ 385812853Sgabeblack@google.com return this->range(m_params.wl() - 1, 0); 385912853Sgabeblack@google.com} 386012853Sgabeblack@google.com 386112853Sgabeblack@google.cominline sc_fxnum_fast_subref 386212853Sgabeblack@google.comsc_fxnum_fast::range() 386312853Sgabeblack@google.com{ 386412853Sgabeblack@google.com return this->range(m_params.wl() - 1, 0); 386512853Sgabeblack@google.com} 386612853Sgabeblack@google.com 386712853Sgabeblack@google.com// implicit conversion 386812853Sgabeblack@google.cominline sc_fxnum_fast::operator double() const 386912853Sgabeblack@google.com{ 387012853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(*this) 387112853Sgabeblack@google.com return m_val; 387212853Sgabeblack@google.com} 387312853Sgabeblack@google.com 387412853Sgabeblack@google.com// explicit conversion to primitive types 387512853Sgabeblack@google.cominline short 387612853Sgabeblack@google.comsc_fxnum_fast::to_short() const 387712853Sgabeblack@google.com{ 387812853Sgabeblack@google.com // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64 387912853Sgabeblack@google.com return static_cast<short>(to_uint64()); 388012853Sgabeblack@google.com} 388112853Sgabeblack@google.com 388212853Sgabeblack@google.cominline unsigned short 388312853Sgabeblack@google.comsc_fxnum_fast::to_ushort() const 388412853Sgabeblack@google.com{ 388512853Sgabeblack@google.com // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64 388612853Sgabeblack@google.com return static_cast<unsigned short>(to_uint64()); 388712853Sgabeblack@google.com} 388812853Sgabeblack@google.com 388912853Sgabeblack@google.cominline int 389012853Sgabeblack@google.comsc_fxnum_fast::to_int() const 389112853Sgabeblack@google.com{ 389212853Sgabeblack@google.com // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64 389312853Sgabeblack@google.com return static_cast<int>(to_uint64()); 389412853Sgabeblack@google.com} 389512853Sgabeblack@google.com 389612853Sgabeblack@google.cominline int64 389712853Sgabeblack@google.comsc_fxnum_fast::to_int64() const 389812853Sgabeblack@google.com{ 389912853Sgabeblack@google.com // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64 390012853Sgabeblack@google.com return static_cast<int64>(to_uint64()); 390112853Sgabeblack@google.com} 390212853Sgabeblack@google.com 390312853Sgabeblack@google.cominline unsigned int 390412853Sgabeblack@google.comsc_fxnum_fast::to_uint() const 390512853Sgabeblack@google.com{ 390612853Sgabeblack@google.com // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64 390712853Sgabeblack@google.com return static_cast<unsigned int>(to_uint64()); 390812853Sgabeblack@google.com} 390912853Sgabeblack@google.com 391012853Sgabeblack@google.cominline uint64 391112853Sgabeblack@google.comsc_fxnum_fast::to_uint64() const 391212853Sgabeblack@google.com{ 391312853Sgabeblack@google.com // SC_FXNUM_FAST_OBSERVER_READ_ in is_normal 391412853Sgabeblack@google.com if (!is_normal()) { 391512853Sgabeblack@google.com return 0; 391612853Sgabeblack@google.com } 391712853Sgabeblack@google.com 391812853Sgabeblack@google.com int exponent; 391912853Sgabeblack@google.com double mantissa_dbl = frexp(m_val, &exponent); 392012853Sgabeblack@google.com 392112853Sgabeblack@google.com uint64 mantissa = static_cast<uint64>(fabs(mantissa_dbl) * 392212853Sgabeblack@google.com (UINT64_ONE << 53)); 392312853Sgabeblack@google.com exponent -= 53; 392412853Sgabeblack@google.com 392512853Sgabeblack@google.com if (!(-64 < exponent && exponent < 64)) { 392612853Sgabeblack@google.com return 0; 392712853Sgabeblack@google.com } 392812853Sgabeblack@google.com 392912853Sgabeblack@google.com mantissa = exponent >= 0 ? mantissa << exponent : mantissa >> -exponent; 393012853Sgabeblack@google.com return mantissa_dbl >= 0 ? mantissa : -mantissa; 393112853Sgabeblack@google.com} 393212853Sgabeblack@google.com 393312853Sgabeblack@google.cominline long 393412853Sgabeblack@google.comsc_fxnum_fast::to_long() const 393512853Sgabeblack@google.com{ 393612853Sgabeblack@google.com // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64 393712853Sgabeblack@google.com return static_cast<long>(to_uint64()); 393812853Sgabeblack@google.com} 393912853Sgabeblack@google.com 394012853Sgabeblack@google.cominline unsigned long 394112853Sgabeblack@google.comsc_fxnum_fast::to_ulong() const 394212853Sgabeblack@google.com{ 394312853Sgabeblack@google.com // SC_FXNUM_FAST_OBSERVER_READ_ in to_uint64 394412853Sgabeblack@google.com return static_cast<unsigned long>(to_uint64()); 394512853Sgabeblack@google.com} 394612853Sgabeblack@google.com 394712853Sgabeblack@google.cominline float 394812853Sgabeblack@google.comsc_fxnum_fast::to_float() const 394912853Sgabeblack@google.com{ 395012853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(*this) 395112853Sgabeblack@google.com return static_cast<float>(m_val); 395212853Sgabeblack@google.com} 395312853Sgabeblack@google.com 395412853Sgabeblack@google.cominline double 395512853Sgabeblack@google.comsc_fxnum_fast::to_double() const 395612853Sgabeblack@google.com{ 395712853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(*this) 395812853Sgabeblack@google.com return m_val; 395912853Sgabeblack@google.com} 396012853Sgabeblack@google.com 396112853Sgabeblack@google.com// query value 396212853Sgabeblack@google.cominline bool 396312853Sgabeblack@google.comsc_fxnum_fast::is_neg() const 396412853Sgabeblack@google.com{ 396512853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(*this) 396612853Sgabeblack@google.com scfx_ieee_double id(m_val); 396712853Sgabeblack@google.com return (id.negative() != 0); 396812853Sgabeblack@google.com} 396912853Sgabeblack@google.com 397012853Sgabeblack@google.cominline bool 397112853Sgabeblack@google.comsc_fxnum_fast::is_zero() const 397212853Sgabeblack@google.com{ 397312853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(*this) 397412853Sgabeblack@google.com scfx_ieee_double id(m_val); 397512853Sgabeblack@google.com return id.is_zero(); 397612853Sgabeblack@google.com} 397712853Sgabeblack@google.com 397812853Sgabeblack@google.com// internal use only; 397912853Sgabeblack@google.cominline bool 398012853Sgabeblack@google.comsc_fxnum_fast::is_normal() const 398112853Sgabeblack@google.com{ 398212853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(*this) 398312853Sgabeblack@google.com scfx_ieee_double id(m_val); 398412853Sgabeblack@google.com return (id.is_normal() || id.is_subnormal() || id.is_zero()); 398512853Sgabeblack@google.com} 398612853Sgabeblack@google.com 398712853Sgabeblack@google.cominline bool 398812853Sgabeblack@google.comsc_fxnum_fast::quantization_flag() const 398912853Sgabeblack@google.com{ 399012853Sgabeblack@google.com return m_q_flag; 399112853Sgabeblack@google.com} 399212853Sgabeblack@google.com 399312853Sgabeblack@google.cominline bool 399412853Sgabeblack@google.comsc_fxnum_fast::overflow_flag() const 399512853Sgabeblack@google.com{ 399612853Sgabeblack@google.com return m_o_flag; 399712853Sgabeblack@google.com} 399812853Sgabeblack@google.com 399912853Sgabeblack@google.cominline const sc_fxval_fast 400012853Sgabeblack@google.comsc_fxnum_fast::value() const 400112853Sgabeblack@google.com{ 400212853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(*this) 400312853Sgabeblack@google.com return sc_fxval_fast(m_val); 400412853Sgabeblack@google.com} 400512853Sgabeblack@google.com 400612853Sgabeblack@google.com// query parameters 400712853Sgabeblack@google.cominline int 400812853Sgabeblack@google.comsc_fxnum_fast::wl() const 400912853Sgabeblack@google.com{ 401012853Sgabeblack@google.com return m_params.wl(); 401112853Sgabeblack@google.com} 401212853Sgabeblack@google.com 401312853Sgabeblack@google.cominline int 401412853Sgabeblack@google.comsc_fxnum_fast::iwl() const 401512853Sgabeblack@google.com{ 401612853Sgabeblack@google.com return m_params.iwl(); 401712853Sgabeblack@google.com} 401812853Sgabeblack@google.com 401912853Sgabeblack@google.cominline sc_q_mode 402012853Sgabeblack@google.comsc_fxnum_fast::q_mode() const 402112853Sgabeblack@google.com{ 402212853Sgabeblack@google.com return m_params.q_mode(); 402312853Sgabeblack@google.com} 402412853Sgabeblack@google.com 402512853Sgabeblack@google.cominline sc_o_mode 402612853Sgabeblack@google.comsc_fxnum_fast::o_mode() const 402712853Sgabeblack@google.com{ 402812853Sgabeblack@google.com return m_params.o_mode(); 402912853Sgabeblack@google.com} 403012853Sgabeblack@google.com 403112853Sgabeblack@google.cominline int 403212853Sgabeblack@google.comsc_fxnum_fast::n_bits() const 403312853Sgabeblack@google.com{ 403412853Sgabeblack@google.com return m_params.n_bits(); 403512853Sgabeblack@google.com} 403612853Sgabeblack@google.com 403712853Sgabeblack@google.cominline const sc_fxtype_params & 403812853Sgabeblack@google.comsc_fxnum_fast::type_params() const 403912853Sgabeblack@google.com{ 404012853Sgabeblack@google.com return m_params.type_params(); 404112853Sgabeblack@google.com} 404212853Sgabeblack@google.com 404312853Sgabeblack@google.cominline const sc_fxcast_switch & 404412853Sgabeblack@google.comsc_fxnum_fast::cast_switch() const 404512853Sgabeblack@google.com{ 404612853Sgabeblack@google.com return m_params.cast_switch(); 404712853Sgabeblack@google.com} 404812853Sgabeblack@google.com 404912853Sgabeblack@google.com// internal use only; 405012853Sgabeblack@google.cominline void 405112853Sgabeblack@google.comsc_fxnum_fast::observer_read() const 405212853Sgabeblack@google.com{ 405312853Sgabeblack@google.com SC_FXNUM_FAST_OBSERVER_READ_(*this); 405412853Sgabeblack@google.com} 405512853Sgabeblack@google.com 405612853Sgabeblack@google.cominline ::std::ostream & 405712853Sgabeblack@google.comoperator << (::std::ostream &os, const sc_fxnum_fast &a) 405812853Sgabeblack@google.com{ 405912853Sgabeblack@google.com a.print(os); 406012853Sgabeblack@google.com return os; 406112853Sgabeblack@google.com} 406212853Sgabeblack@google.com 406312853Sgabeblack@google.cominline ::std::istream & 406412853Sgabeblack@google.comoperator >> (::std::istream &is, sc_fxnum_fast &a) 406512853Sgabeblack@google.com{ 406612853Sgabeblack@google.com a.scan(is); 406712853Sgabeblack@google.com return is; 406812853Sgabeblack@google.com} 406912853Sgabeblack@google.com 407012853Sgabeblack@google.com 407112853Sgabeblack@google.com// ---------------------------------------------------------------------------- 407212853Sgabeblack@google.com// CLASS : sc_fxval 407312853Sgabeblack@google.com// 407412853Sgabeblack@google.com// Fixed-point value type; arbitrary precision. 407512853Sgabeblack@google.com// ---------------------------------------------------------------------------- 407612853Sgabeblack@google.com 407712853Sgabeblack@google.com// public constructors 407812853Sgabeblack@google.cominline sc_fxval::sc_fxval(const sc_fxnum &a, sc_fxval_observer *observer_) : 407912853Sgabeblack@google.com m_rep(new scfx_rep(*a.get_rep())), m_observer(observer_) 408012853Sgabeblack@google.com{ 408112853Sgabeblack@google.com SC_FXVAL_OBSERVER_DEFAULT_ 408212853Sgabeblack@google.com SC_FXVAL_OBSERVER_CONSTRUCT_(*this) 408312853Sgabeblack@google.com SC_FXVAL_OBSERVER_WRITE_(*this) 408412853Sgabeblack@google.com} 408512853Sgabeblack@google.com 408612853Sgabeblack@google.cominline sc_fxval::sc_fxval(const sc_fxnum_fast &a, 408712853Sgabeblack@google.com sc_fxval_observer *observer_) : 408812853Sgabeblack@google.com m_rep(new scfx_rep(a.to_double())), m_observer(observer_) 408912853Sgabeblack@google.com{ 409012853Sgabeblack@google.com SC_FXVAL_OBSERVER_DEFAULT_ 409112853Sgabeblack@google.com SC_FXVAL_OBSERVER_CONSTRUCT_(*this) 409212853Sgabeblack@google.com SC_FXVAL_OBSERVER_WRITE_(*this) 409312853Sgabeblack@google.com} 409412853Sgabeblack@google.com 409512853Sgabeblack@google.com// binary operators 409612853Sgabeblack@google.com#define DEFN_BIN_OP_T(op, fnc, tp) \ 409712853Sgabeblack@google.cominline const sc_fxval \ 409812853Sgabeblack@google.comoperator op (const sc_fxval &a, tp b) \ 409912853Sgabeblack@google.com{ \ 410012853Sgabeblack@google.com SC_FXVAL_OBSERVER_READ_(a) \ 410112853Sgabeblack@google.com sc_fxval tmp(b); \ 410212853Sgabeblack@google.com return sc_fxval(sc_dt::fnc ## _scfx_rep(*a.m_rep, *tmp.m_rep)); \ 410312853Sgabeblack@google.com} \ 410412853Sgabeblack@google.com \ 410512853Sgabeblack@google.cominline const sc_fxval \ 410612853Sgabeblack@google.comoperator op (tp a, const sc_fxval &b) \ 410712853Sgabeblack@google.com{ \ 410812853Sgabeblack@google.com SC_FXVAL_OBSERVER_READ_(b) \ 410912853Sgabeblack@google.com sc_fxval tmp(a); \ 411012853Sgabeblack@google.com return sc_fxval(sc_dt::fnc ## _scfx_rep(*tmp.m_rep, *b.m_rep)); \ 411112853Sgabeblack@google.com} 411212853Sgabeblack@google.com 411312853Sgabeblack@google.com#define DEFN_BIN_OP(op, fnc) \ 411412853Sgabeblack@google.comDEFN_BIN_OP_T(op, fnc, const sc_fxnum_fast &) 411512853Sgabeblack@google.com 411612853Sgabeblack@google.comDEFN_BIN_OP(*, mult) 411712853Sgabeblack@google.comDEFN_BIN_OP(+, add) 411812853Sgabeblack@google.comDEFN_BIN_OP(-, sub) 411912853Sgabeblack@google.com//DEFN_BIN_OP(/, div) 412012853Sgabeblack@google.comDEFN_BIN_OP_T(/, div, const sc_fxnum_fast &) 412112853Sgabeblack@google.com 412212853Sgabeblack@google.com#undef DEFN_BIN_OP_T 412312853Sgabeblack@google.com#undef DEFN_BIN_OP 412412853Sgabeblack@google.com 412512853Sgabeblack@google.com 412612853Sgabeblack@google.com// binary functions 412712853Sgabeblack@google.com#define DEFN_BIN_FNC_T(fnc, tp) \ 412812853Sgabeblack@google.cominline void \ 412912853Sgabeblack@google.comfnc (sc_fxval &c, const sc_fxval &a, tp b) \ 413012853Sgabeblack@google.com{ \ 413112853Sgabeblack@google.com SC_FXVAL_OBSERVER_READ_(a) \ 413212853Sgabeblack@google.com sc_fxval tmp(b); \ 413312853Sgabeblack@google.com delete c.m_rep; \ 413412853Sgabeblack@google.com c.m_rep = sc_dt::fnc ## _scfx_rep(*a.m_rep, *tmp.m_rep); \ 413512853Sgabeblack@google.com SC_FXVAL_OBSERVER_WRITE_(c) \ 413612853Sgabeblack@google.com} \ 413712853Sgabeblack@google.com \ 413812853Sgabeblack@google.cominline void \ 413912853Sgabeblack@google.comfnc (sc_fxval &c, tp a, const sc_fxval &b) \ 414012853Sgabeblack@google.com{ \ 414112853Sgabeblack@google.com SC_FXVAL_OBSERVER_READ_(b) \ 414212853Sgabeblack@google.com sc_fxval tmp(a); \ 414312853Sgabeblack@google.com delete c.m_rep; \ 414412853Sgabeblack@google.com c.m_rep = sc_dt::fnc ## _scfx_rep(*tmp.m_rep, *b.m_rep); \ 414512853Sgabeblack@google.com SC_FXVAL_OBSERVER_WRITE_(c) \ 414612853Sgabeblack@google.com} 414712853Sgabeblack@google.com 414812853Sgabeblack@google.com#define DEFN_BIN_FNC(fnc) \ 414912853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, const sc_fxnum_fast &) 415012853Sgabeblack@google.com 415112853Sgabeblack@google.comDEFN_BIN_FNC(mult) 415212853Sgabeblack@google.comDEFN_BIN_FNC(div) 415312853Sgabeblack@google.comDEFN_BIN_FNC(add) 415412853Sgabeblack@google.comDEFN_BIN_FNC(sub) 415512853Sgabeblack@google.com 415612853Sgabeblack@google.com#undef DEFN_BIN_FNC_T 415712853Sgabeblack@google.com#undef DEFN_BIN_FNC 415812853Sgabeblack@google.com 415912853Sgabeblack@google.com 416012853Sgabeblack@google.com// relational (including equality) operators 416112853Sgabeblack@google.com#define DEFN_REL_OP_T(op, ret, tp) \ 416212853Sgabeblack@google.cominline bool \ 416312853Sgabeblack@google.comoperator op (const sc_fxval &a, tp b) \ 416412853Sgabeblack@google.com{ \ 416512853Sgabeblack@google.com SC_FXVAL_OBSERVER_READ_(a) \ 416612853Sgabeblack@google.com sc_fxval tmp(b); \ 416712853Sgabeblack@google.com int result = sc_dt::cmp_scfx_rep(*a.m_rep, *tmp.m_rep); \ 416812853Sgabeblack@google.com return (ret); \ 416912853Sgabeblack@google.com} \ 417012853Sgabeblack@google.com \ 417112853Sgabeblack@google.cominline bool \ 417212853Sgabeblack@google.comoperator op (tp a, const sc_fxval &b) \ 417312853Sgabeblack@google.com{ \ 417412853Sgabeblack@google.com SC_FXVAL_OBSERVER_READ_(b) \ 417512853Sgabeblack@google.com sc_fxval tmp(a); \ 417612853Sgabeblack@google.com int result = sc_dt::cmp_scfx_rep(*tmp.m_rep, *b.m_rep); \ 417712853Sgabeblack@google.com return (ret); \ 417812853Sgabeblack@google.com} 417912853Sgabeblack@google.com 418012853Sgabeblack@google.com#define DEFN_REL_OP(op, ret) \ 418112853Sgabeblack@google.comDEFN_REL_OP_T(op, ret, const sc_fxnum_fast &) 418212853Sgabeblack@google.com 418312853Sgabeblack@google.comDEFN_REL_OP(<, result < 0) 418412853Sgabeblack@google.comDEFN_REL_OP(<=, result <= 0) 418512853Sgabeblack@google.comDEFN_REL_OP(>, result > 0 && result != 2) 418612853Sgabeblack@google.comDEFN_REL_OP(>=, result >= 0 && result != 2) 418712853Sgabeblack@google.comDEFN_REL_OP(==, result == 0) 418812853Sgabeblack@google.comDEFN_REL_OP(!=, result != 0) 418912853Sgabeblack@google.com 419012853Sgabeblack@google.com#undef DEFN_REL_OP_T 419112853Sgabeblack@google.com#undef DEFN_REL_OP 419212853Sgabeblack@google.com 419312853Sgabeblack@google.com// assignment operators 419412853Sgabeblack@google.cominline sc_fxval & 419512853Sgabeblack@google.comsc_fxval::operator = (const sc_fxnum &a) 419612853Sgabeblack@google.com{ 419712853Sgabeblack@google.com *m_rep = *a.get_rep(); 419812853Sgabeblack@google.com SC_FXVAL_OBSERVER_WRITE_(*this) 419912853Sgabeblack@google.com return *this; 420012853Sgabeblack@google.com} 420112853Sgabeblack@google.com 420212853Sgabeblack@google.com#define DEFN_ASN_OP_T(tp) \ 420312853Sgabeblack@google.cominline sc_fxval & \ 420412853Sgabeblack@google.comsc_fxval::operator = (tp b) \ 420512853Sgabeblack@google.com{ \ 420612853Sgabeblack@google.com sc_fxval tmp(b); \ 420712853Sgabeblack@google.com *m_rep = *tmp.m_rep; \ 420812853Sgabeblack@google.com SC_FXVAL_OBSERVER_WRITE_(*this) \ 420912853Sgabeblack@google.com return *this; \ 421012853Sgabeblack@google.com} 421112853Sgabeblack@google.com 421212853Sgabeblack@google.comDEFN_ASN_OP_T(const sc_fxnum_fast &) 421312853Sgabeblack@google.com 421412853Sgabeblack@google.com#undef DEFN_ASN_OP_T 421512853Sgabeblack@google.com 421612853Sgabeblack@google.com#define DEFN_ASN_OP_T(op, fnc, tp) \ 421712853Sgabeblack@google.cominline sc_fxval & \ 421812853Sgabeblack@google.comsc_fxval::operator op (tp b) \ 421912853Sgabeblack@google.com{ \ 422012853Sgabeblack@google.com SC_FXVAL_OBSERVER_READ_(*this) \ 422112853Sgabeblack@google.com sc_fxval tmp(b); \ 422212853Sgabeblack@google.com scfx_rep *new_rep = sc_dt::fnc ## _scfx_rep(*m_rep, *tmp.m_rep); \ 422312853Sgabeblack@google.com delete m_rep; \ 422412853Sgabeblack@google.com m_rep = new_rep; \ 422512853Sgabeblack@google.com SC_FXVAL_OBSERVER_WRITE_(*this) \ 422612853Sgabeblack@google.com return *this; \ 422712853Sgabeblack@google.com} 422812853Sgabeblack@google.com 422912853Sgabeblack@google.com#define DEFN_ASN_OP(op, fnc) \ 423012853Sgabeblack@google.cominline sc_fxval & \ 423112853Sgabeblack@google.comsc_fxval::operator op (const sc_fxnum &b) \ 423212853Sgabeblack@google.com{ \ 423312853Sgabeblack@google.com SC_FXVAL_OBSERVER_READ_(*this) \ 423412853Sgabeblack@google.com scfx_rep *new_rep = sc_dt::fnc ## _scfx_rep(*m_rep, *b.get_rep()); \ 423512853Sgabeblack@google.com delete m_rep; \ 423612853Sgabeblack@google.com m_rep = new_rep; \ 423712853Sgabeblack@google.com SC_FXVAL_OBSERVER_WRITE_(*this) \ 423812853Sgabeblack@google.com return *this; \ 423912853Sgabeblack@google.com} \ 424012853Sgabeblack@google.com \ 424112853Sgabeblack@google.comDEFN_ASN_OP_T(op, fnc, const sc_fxnum_fast &) 424212853Sgabeblack@google.com 424312853Sgabeblack@google.comDEFN_ASN_OP(*=, mult) 424412853Sgabeblack@google.comDEFN_ASN_OP(/=, div) 424512853Sgabeblack@google.comDEFN_ASN_OP(+=, add) 424612853Sgabeblack@google.comDEFN_ASN_OP(-=, sub) 424712853Sgabeblack@google.com 424812853Sgabeblack@google.com#undef DEFN_ASN_OP_T 424912853Sgabeblack@google.com#undef DEFN_ASN_OP 425012853Sgabeblack@google.com 425112853Sgabeblack@google.com 425212853Sgabeblack@google.com// ---------------------------------------------------------------------------- 425312853Sgabeblack@google.com// CLASS : sc_fxval_fast 425412853Sgabeblack@google.com// 425512853Sgabeblack@google.com// Fixed-point value types; limited precision. 425612853Sgabeblack@google.com// ---------------------------------------------------------------------------- 425712853Sgabeblack@google.com 425812853Sgabeblack@google.com// public constructors 425912853Sgabeblack@google.com 426012853Sgabeblack@google.cominline 426112853Sgabeblack@google.comsc_fxval_fast::sc_fxval_fast(const sc_fxnum &a, 426212853Sgabeblack@google.com sc_fxval_fast_observer *observer_) : 426312853Sgabeblack@google.com m_val(a.to_double()), m_observer(observer_) 426412853Sgabeblack@google.com{ 426512853Sgabeblack@google.com SC_FXVAL_FAST_OBSERVER_DEFAULT_ 426612853Sgabeblack@google.com SC_FXVAL_FAST_OBSERVER_CONSTRUCT_(*this) 426712853Sgabeblack@google.com SC_FXVAL_FAST_OBSERVER_WRITE_(*this) 426812853Sgabeblack@google.com} 426912853Sgabeblack@google.com 427012853Sgabeblack@google.cominline sc_fxval_fast::sc_fxval_fast(const sc_fxnum_fast &a, 427112853Sgabeblack@google.com sc_fxval_fast_observer *observer_) : 427212853Sgabeblack@google.com m_val(a.get_val()), m_observer(observer_) 427312853Sgabeblack@google.com{ 427412853Sgabeblack@google.com SC_FXVAL_FAST_OBSERVER_DEFAULT_ 427512853Sgabeblack@google.com SC_FXVAL_FAST_OBSERVER_CONSTRUCT_(*this) 427612853Sgabeblack@google.com SC_FXVAL_FAST_OBSERVER_WRITE_(*this) 427712853Sgabeblack@google.com} 427812853Sgabeblack@google.com 427912853Sgabeblack@google.com 428012853Sgabeblack@google.com// binary functions 428112853Sgabeblack@google.com#define DEFN_BIN_FNC_T(fnc, op, tp) \ 428212853Sgabeblack@google.cominline void \ 428312853Sgabeblack@google.comfnc (sc_fxval_fast &c, const sc_fxval_fast &a, tp b) \ 428412853Sgabeblack@google.com{ \ 428512853Sgabeblack@google.com SC_FXVAL_FAST_OBSERVER_READ_(a) \ 428612853Sgabeblack@google.com sc_fxval_fast tmp(b); \ 428712853Sgabeblack@google.com c.m_val = a.m_val op tmp.m_val; \ 428812853Sgabeblack@google.com SC_FXVAL_FAST_OBSERVER_WRITE_(c) \ 428912853Sgabeblack@google.com} \ 429012853Sgabeblack@google.com \ 429112853Sgabeblack@google.cominline void \ 429212853Sgabeblack@google.comfnc (sc_fxval_fast &c, tp a, const sc_fxval_fast &b) \ 429312853Sgabeblack@google.com{ \ 429412853Sgabeblack@google.com SC_FXVAL_FAST_OBSERVER_READ_(b) \ 429512853Sgabeblack@google.com sc_fxval_fast tmp(a); \ 429612853Sgabeblack@google.com c.m_val = tmp.m_val op b.m_val; \ 429712853Sgabeblack@google.com SC_FXVAL_FAST_OBSERVER_WRITE_(c) \ 429812853Sgabeblack@google.com} 429912853Sgabeblack@google.com 430012853Sgabeblack@google.com#define DEFN_BIN_FNC(fnc, op) \ 430112853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, op, const sc_fxval &) \ 430212853Sgabeblack@google.comDEFN_BIN_FNC_T(fnc, op, const sc_fxnum &) 430312853Sgabeblack@google.com 430412853Sgabeblack@google.comDEFN_BIN_FNC(mult, *) 430512853Sgabeblack@google.comDEFN_BIN_FNC(div, /) 430612853Sgabeblack@google.comDEFN_BIN_FNC(add, +) 430712853Sgabeblack@google.comDEFN_BIN_FNC(sub, -) 430812853Sgabeblack@google.com 430912853Sgabeblack@google.com#undef DEFN_BIN_FNC_T 431012853Sgabeblack@google.com#undef DEFN_BIN_FNC 431112853Sgabeblack@google.com 431212853Sgabeblack@google.com 431312853Sgabeblack@google.com// assignment operators 431412853Sgabeblack@google.cominline sc_fxval_fast & 431512853Sgabeblack@google.comsc_fxval_fast::operator = (const sc_fxnum_fast &a) 431612853Sgabeblack@google.com{ 431712853Sgabeblack@google.com m_val = a.get_val(); 431812853Sgabeblack@google.com SC_FXVAL_FAST_OBSERVER_WRITE_(*this) 431912853Sgabeblack@google.com return *this; 432012853Sgabeblack@google.com} 432112853Sgabeblack@google.com 432212853Sgabeblack@google.com#define DEFN_ASN_OP_T(tp) \ 432312853Sgabeblack@google.cominline sc_fxval_fast & \ 432412853Sgabeblack@google.comsc_fxval_fast::operator = (tp a) \ 432512853Sgabeblack@google.com{ \ 432612853Sgabeblack@google.com sc_fxval_fast tmp(a); \ 432712853Sgabeblack@google.com m_val = tmp.m_val; \ 432812853Sgabeblack@google.com SC_FXVAL_FAST_OBSERVER_WRITE_(*this) \ 432912853Sgabeblack@google.com return *this; \ 433012853Sgabeblack@google.com} 433112853Sgabeblack@google.com 433212853Sgabeblack@google.comDEFN_ASN_OP_T(const sc_fxnum &) 433312853Sgabeblack@google.com 433412853Sgabeblack@google.com#undef DEFN_ASN_OP_T 433512853Sgabeblack@google.com 433612853Sgabeblack@google.com#define DEFN_ASN_OP_T(op, tp) \ 433712853Sgabeblack@google.cominline sc_fxval_fast & \ 433812853Sgabeblack@google.comsc_fxval_fast::operator op (tp b) \ 433912853Sgabeblack@google.com{ \ 434012853Sgabeblack@google.com SC_FXVAL_FAST_OBSERVER_READ_(*this) \ 434112853Sgabeblack@google.com sc_fxval_fast tmp(b); \ 434212853Sgabeblack@google.com m_val op tmp.m_val; \ 434312853Sgabeblack@google.com SC_FXVAL_FAST_OBSERVER_WRITE_(*this) \ 434412853Sgabeblack@google.com return *this; \ 434512853Sgabeblack@google.com} 434612853Sgabeblack@google.com 434712853Sgabeblack@google.com#define DEFN_ASN_OP(op) \ 434812853Sgabeblack@google.cominline sc_fxval_fast & \ 434912853Sgabeblack@google.comsc_fxval_fast::operator op (const sc_fxnum_fast &b) \ 435012853Sgabeblack@google.com{ \ 435112853Sgabeblack@google.com SC_FXVAL_FAST_OBSERVER_READ_(*this) \ 435212853Sgabeblack@google.com m_val op b.get_val(); \ 435312853Sgabeblack@google.com SC_FXVAL_FAST_OBSERVER_WRITE_(*this) \ 435412853Sgabeblack@google.com return *this; \ 435512853Sgabeblack@google.com} \ 435612853Sgabeblack@google.com \ 435712853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_fxnum &) 435812853Sgabeblack@google.com 435912853Sgabeblack@google.comDEFN_ASN_OP(*=) 436012853Sgabeblack@google.comDEFN_ASN_OP(/=) 436112853Sgabeblack@google.comDEFN_ASN_OP(+=) 436212853Sgabeblack@google.comDEFN_ASN_OP(-=) 436312853Sgabeblack@google.com 436412853Sgabeblack@google.com#undef DEFN_ASN_OP_T 436512853Sgabeblack@google.com#undef DEFN_ASN_OP 436612853Sgabeblack@google.com 436712853Sgabeblack@google.com} // namespace sc_dt 436812853Sgabeblack@google.com 436912853Sgabeblack@google.com#endif // __SYSTEMC_EXT_DT_FX_SC_FXNUM_HH__ 4370