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_fixed.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_fixed.h,v $ 3912853Sgabeblack@google.com// Revision 1.2 2011/01/19 18:57:40 acg 4012853Sgabeblack@google.com// Andy Goodrich: changes for IEEE_1666_2011. 4112853Sgabeblack@google.com// 4212853Sgabeblack@google.com// Revision 1.1.1.1 2006/12/15 20:20:04 acg 4312853Sgabeblack@google.com// SystemC 2.3 4412853Sgabeblack@google.com// 4512853Sgabeblack@google.com// Revision 1.3 2006/01/13 18:53:57 acg 4612853Sgabeblack@google.com// Andy Goodrich: added $Log command so that CVS comments are reproduced in 4712853Sgabeblack@google.com// the source. 4812853Sgabeblack@google.com// 4912853Sgabeblack@google.com 5012853Sgabeblack@google.com#ifndef __SYSTEMC_EXT_DT_FX_SC_FIXED_HH__ 5112853Sgabeblack@google.com#define __SYSTEMC_EXT_DT_FX_SC_FIXED_HH__ 5212853Sgabeblack@google.com 5312853Sgabeblack@google.com#include "sc_fix.hh" 5412853Sgabeblack@google.com 5512853Sgabeblack@google.comnamespace sc_dt 5612853Sgabeblack@google.com{ 5712853Sgabeblack@google.com 5812853Sgabeblack@google.com// classes defined in this module 5912853Sgabeblack@google.comtemplate <int W, int I, sc_q_mode Q, sc_o_mode O, int N> 6012853Sgabeblack@google.comclass sc_fixed; 6112853Sgabeblack@google.comtemplate <int W, int I, sc_q_mode Q, sc_o_mode O, int N> 6212853Sgabeblack@google.comclass sc_fixed_fast; 6312853Sgabeblack@google.com 6412853Sgabeblack@google.com// ---------------------------------------------------------------------------- 6512853Sgabeblack@google.com// TEMPLATE CLASS : sc_fixed 6612853Sgabeblack@google.com// 6712853Sgabeblack@google.com// "Constrained" signed fixed-point class; arbitrary precision. 6812853Sgabeblack@google.com// ---------------------------------------------------------------------------- 6912853Sgabeblack@google.com 7012853Sgabeblack@google.comtemplate <int W, int I, 7112853Sgabeblack@google.com sc_q_mode Q=SC_DEFAULT_Q_MODE_, 7212853Sgabeblack@google.com sc_o_mode O=SC_DEFAULT_O_MODE_, int N=SC_DEFAULT_N_BITS_> 7312853Sgabeblack@google.comclass sc_fixed : public sc_fix 7412853Sgabeblack@google.com{ 7512853Sgabeblack@google.com public: 7612853Sgabeblack@google.com // constructors 7712853Sgabeblack@google.com explicit sc_fixed(sc_fxnum_observer * =0); 7812853Sgabeblack@google.com explicit sc_fixed(const sc_fxcast_switch &, sc_fxnum_observer * =0); 7912853Sgabeblack@google.com 8012853Sgabeblack@google.com#define DECL_CTORS_T_A(tp) \ 8112853Sgabeblack@google.com sc_fixed(tp, sc_fxnum_observer * =0); \ 8212853Sgabeblack@google.com sc_fixed(tp, const sc_fxcast_switch &, sc_fxnum_observer * =0); 8312853Sgabeblack@google.com 8412853Sgabeblack@google.com#define DECL_CTORS_T_B(tp) \ 8512853Sgabeblack@google.com explicit sc_fixed(tp, sc_fxnum_observer * =0); \ 8612853Sgabeblack@google.com sc_fixed(tp, const sc_fxcast_switch &, sc_fxnum_observer * =0); 8712853Sgabeblack@google.com 8812853Sgabeblack@google.com DECL_CTORS_T_A(int) 8912853Sgabeblack@google.com DECL_CTORS_T_A(unsigned int) 9012853Sgabeblack@google.com DECL_CTORS_T_A(long) 9112853Sgabeblack@google.com DECL_CTORS_T_A(unsigned long) 9212853Sgabeblack@google.com DECL_CTORS_T_A(float) 9312853Sgabeblack@google.com DECL_CTORS_T_A(double) 9412853Sgabeblack@google.com DECL_CTORS_T_A(const char *) 9512853Sgabeblack@google.com DECL_CTORS_T_A(const sc_fxval &) 9612853Sgabeblack@google.com DECL_CTORS_T_A(const sc_fxval_fast &) 9712853Sgabeblack@google.com DECL_CTORS_T_A(const sc_fxnum &) 9812853Sgabeblack@google.com DECL_CTORS_T_A(const sc_fxnum_fast &) 9912853Sgabeblack@google.com 10012853Sgabeblack@google.com DECL_CTORS_T_B(int64) 10112853Sgabeblack@google.com DECL_CTORS_T_B(uint64) 10212853Sgabeblack@google.com DECL_CTORS_T_B(const sc_int_base&) 10312853Sgabeblack@google.com DECL_CTORS_T_B(const sc_uint_base&) 10412853Sgabeblack@google.com DECL_CTORS_T_B(const sc_signed&) 10512853Sgabeblack@google.com DECL_CTORS_T_B(const sc_unsigned&) 10612853Sgabeblack@google.com 10712853Sgabeblack@google.com#undef DECL_CTORS_T_A 10812853Sgabeblack@google.com#undef DECL_CTORS_T_B 10912853Sgabeblack@google.com 11012853Sgabeblack@google.com // copy constructor 11112853Sgabeblack@google.com sc_fixed(const sc_fixed<W, I, Q, O, N> &); 11212853Sgabeblack@google.com 11312853Sgabeblack@google.com // assignment operators 11412853Sgabeblack@google.com sc_fixed &operator = (const sc_fixed<W, I, Q, O, N> &); 11512853Sgabeblack@google.com 11612853Sgabeblack@google.com#define DECL_ASN_OP_T(op, tp) sc_fixed &operator op (tp); 11712853Sgabeblack@google.com 11812853Sgabeblack@google.com#define DECL_ASN_OP_OTHER(op) \ 11912853Sgabeblack@google.com DECL_ASN_OP_T(op, int64) \ 12012853Sgabeblack@google.com DECL_ASN_OP_T(op, uint64) \ 12112853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_int_base&) \ 12212853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_uint_base&) \ 12312853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_signed&) \ 12412853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_unsigned&) 12512853Sgabeblack@google.com 12612853Sgabeblack@google.com#define DECL_ASN_OP(op) \ 12712853Sgabeblack@google.com DECL_ASN_OP_T(op, int) \ 12812853Sgabeblack@google.com DECL_ASN_OP_T(op, unsigned int) \ 12912853Sgabeblack@google.com DECL_ASN_OP_T(op, long) \ 13012853Sgabeblack@google.com DECL_ASN_OP_T(op, unsigned long) \ 13112853Sgabeblack@google.com DECL_ASN_OP_T(op, float) \ 13212853Sgabeblack@google.com DECL_ASN_OP_T(op, double) \ 13312853Sgabeblack@google.com DECL_ASN_OP_T(op, const char *) \ 13412853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_fxval &) \ 13512853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_fxval_fast &) \ 13612853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_fxnum &) \ 13712853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_fxnum_fast &) \ 13812853Sgabeblack@google.com DECL_ASN_OP_OTHER(op) 13912853Sgabeblack@google.com 14012853Sgabeblack@google.com DECL_ASN_OP(=) 14112853Sgabeblack@google.com 14212853Sgabeblack@google.com DECL_ASN_OP(*=) 14312853Sgabeblack@google.com DECL_ASN_OP(/=) 14412853Sgabeblack@google.com DECL_ASN_OP(+=) 14512853Sgabeblack@google.com DECL_ASN_OP(-=) 14612853Sgabeblack@google.com 14712853Sgabeblack@google.com DECL_ASN_OP_T(<<=, int) 14812853Sgabeblack@google.com DECL_ASN_OP_T(>>=, int) 14912853Sgabeblack@google.com 15012853Sgabeblack@google.com DECL_ASN_OP_T(&=, const sc_fix &) 15112853Sgabeblack@google.com DECL_ASN_OP_T(&=, const sc_fix_fast &) 15212853Sgabeblack@google.com DECL_ASN_OP_T(|=, const sc_fix &) 15312853Sgabeblack@google.com DECL_ASN_OP_T(|=, const sc_fix_fast &) 15412853Sgabeblack@google.com DECL_ASN_OP_T(^=, const sc_fix &) 15512853Sgabeblack@google.com DECL_ASN_OP_T(^=, const sc_fix_fast &) 15612853Sgabeblack@google.com 15712853Sgabeblack@google.com#undef DECL_ASN_OP_T 15812853Sgabeblack@google.com#undef DECL_ASN_OP_OTHER 15912853Sgabeblack@google.com#undef DECL_ASN_OP 16012853Sgabeblack@google.com 16112853Sgabeblack@google.com // auto-increment and auto-decrement 16212853Sgabeblack@google.com const sc_fxval operator ++ (int); 16312853Sgabeblack@google.com const sc_fxval operator -- (int); 16412853Sgabeblack@google.com 16512853Sgabeblack@google.com sc_fixed & operator ++ (); 16612853Sgabeblack@google.com sc_fixed & operator -- (); 16712853Sgabeblack@google.com}; 16812853Sgabeblack@google.com 16912853Sgabeblack@google.com 17012853Sgabeblack@google.com// ---------------------------------------------------------------------------- 17112853Sgabeblack@google.com// TEMPLATE CLASS : sc_fixed_fast 17212853Sgabeblack@google.com// 17312853Sgabeblack@google.com// "Constrained" signed fixed-point class; limited precision. 17412853Sgabeblack@google.com// ---------------------------------------------------------------------------- 17512853Sgabeblack@google.com 17612853Sgabeblack@google.comtemplate <int W, int I, 17712853Sgabeblack@google.com sc_q_mode Q=SC_DEFAULT_Q_MODE_, 17812853Sgabeblack@google.com sc_o_mode O=SC_DEFAULT_O_MODE_, int N=SC_DEFAULT_N_BITS_> 17912853Sgabeblack@google.comclass sc_fixed_fast : public sc_fix_fast 18012853Sgabeblack@google.com{ 18112853Sgabeblack@google.com public: 18212853Sgabeblack@google.com // constructors 18312853Sgabeblack@google.com explicit sc_fixed_fast(sc_fxnum_fast_observer * =0); 18412853Sgabeblack@google.com explicit sc_fixed_fast(const sc_fxcast_switch &, 18512853Sgabeblack@google.com sc_fxnum_fast_observer * =0); 18612853Sgabeblack@google.com 18712853Sgabeblack@google.com#define DECL_CTORS_T_A(tp) \ 18812853Sgabeblack@google.com sc_fixed_fast(tp, sc_fxnum_fast_observer * =0); \ 18912853Sgabeblack@google.com sc_fixed_fast(tp, const sc_fxcast_switch &, \ 19012853Sgabeblack@google.com sc_fxnum_fast_observer * =0); 19112853Sgabeblack@google.com 19212853Sgabeblack@google.com#define DECL_CTORS_T_B(tp) \ 19312853Sgabeblack@google.com explicit sc_fixed_fast(tp, sc_fxnum_fast_observer * =0); \ 19412853Sgabeblack@google.com sc_fixed_fast(tp, const sc_fxcast_switch &, \ 19512853Sgabeblack@google.com sc_fxnum_fast_observer * =0); 19612853Sgabeblack@google.com 19712853Sgabeblack@google.com DECL_CTORS_T_A(int) 19812853Sgabeblack@google.com DECL_CTORS_T_A(unsigned int) 19912853Sgabeblack@google.com DECL_CTORS_T_A(long) 20012853Sgabeblack@google.com DECL_CTORS_T_A(unsigned long) 20112853Sgabeblack@google.com DECL_CTORS_T_A(float) 20212853Sgabeblack@google.com DECL_CTORS_T_A(double) 20312853Sgabeblack@google.com DECL_CTORS_T_A(const char *) 20412853Sgabeblack@google.com DECL_CTORS_T_A(const sc_fxval &) 20512853Sgabeblack@google.com DECL_CTORS_T_A(const sc_fxval_fast &) 20612853Sgabeblack@google.com DECL_CTORS_T_A(const sc_fxnum &) 20712853Sgabeblack@google.com DECL_CTORS_T_A(const sc_fxnum_fast &) 20812853Sgabeblack@google.com 20912853Sgabeblack@google.com DECL_CTORS_T_B(int64) 21012853Sgabeblack@google.com DECL_CTORS_T_B(uint64) 21112853Sgabeblack@google.com DECL_CTORS_T_B(const sc_int_base &) 21212853Sgabeblack@google.com DECL_CTORS_T_B(const sc_uint_base &) 21312853Sgabeblack@google.com DECL_CTORS_T_B(const sc_signed &) 21412853Sgabeblack@google.com DECL_CTORS_T_B(const sc_unsigned &) 21512853Sgabeblack@google.com 21612853Sgabeblack@google.com#undef DECL_CTORS_T_A 21712853Sgabeblack@google.com#undef DECL_CTORS_T_B 21812853Sgabeblack@google.com 21912853Sgabeblack@google.com // copy constructor 22012853Sgabeblack@google.com sc_fixed_fast(const sc_fixed_fast<W, I, Q, O, N> &); 22112853Sgabeblack@google.com 22212853Sgabeblack@google.com // assignment operators 22312853Sgabeblack@google.com sc_fixed_fast &operator = (const sc_fixed_fast<W, I, Q, O, N> &); 22412853Sgabeblack@google.com 22512853Sgabeblack@google.com#define DECL_ASN_OP_T(op, tp) sc_fixed_fast &operator op (tp); 22612853Sgabeblack@google.com 22712853Sgabeblack@google.com#define DECL_ASN_OP_OTHER(op) \ 22812853Sgabeblack@google.com DECL_ASN_OP_T(op, int64) \ 22912853Sgabeblack@google.com DECL_ASN_OP_T(op, uint64) \ 23012853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_int_base &) \ 23112853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_uint_base &) \ 23212853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_signed &) \ 23312853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_unsigned &) 23412853Sgabeblack@google.com 23512853Sgabeblack@google.com#define DECL_ASN_OP(op) \ 23612853Sgabeblack@google.com DECL_ASN_OP_T(op, int) \ 23712853Sgabeblack@google.com DECL_ASN_OP_T(op, unsigned int) \ 23812853Sgabeblack@google.com DECL_ASN_OP_T(op, long) \ 23912853Sgabeblack@google.com DECL_ASN_OP_T(op, unsigned long) \ 24012853Sgabeblack@google.com DECL_ASN_OP_T(op, float) \ 24112853Sgabeblack@google.com DECL_ASN_OP_T(op, double) \ 24212853Sgabeblack@google.com DECL_ASN_OP_T(op, const char *) \ 24312853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_fxval &) \ 24412853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_fxval_fast &) \ 24512853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_fxnum &) \ 24612853Sgabeblack@google.com DECL_ASN_OP_T(op, const sc_fxnum_fast &) \ 24712853Sgabeblack@google.com DECL_ASN_OP_OTHER(op) 24812853Sgabeblack@google.com 24912853Sgabeblack@google.com DECL_ASN_OP(=) 25012853Sgabeblack@google.com 25112853Sgabeblack@google.com DECL_ASN_OP(*=) 25212853Sgabeblack@google.com DECL_ASN_OP(/=) 25312853Sgabeblack@google.com DECL_ASN_OP(+=) 25412853Sgabeblack@google.com DECL_ASN_OP(-=) 25512853Sgabeblack@google.com 25612853Sgabeblack@google.com DECL_ASN_OP_T(<<=, int) 25712853Sgabeblack@google.com DECL_ASN_OP_T(>>=, int) 25812853Sgabeblack@google.com 25912853Sgabeblack@google.com DECL_ASN_OP_T(&=, const sc_fix &) 26012853Sgabeblack@google.com DECL_ASN_OP_T(&=, const sc_fix_fast &) 26112853Sgabeblack@google.com DECL_ASN_OP_T(|=, const sc_fix &) 26212853Sgabeblack@google.com DECL_ASN_OP_T(|=, const sc_fix_fast &) 26312853Sgabeblack@google.com DECL_ASN_OP_T(^=, const sc_fix &) 26412853Sgabeblack@google.com DECL_ASN_OP_T(^=, const sc_fix_fast &) 26512853Sgabeblack@google.com 26612853Sgabeblack@google.com#undef DECL_ASN_OP_T 26712853Sgabeblack@google.com#undef DECL_ASN_OP_OTHER 26812853Sgabeblack@google.com#undef DECL_ASN_OP 26912853Sgabeblack@google.com 27012853Sgabeblack@google.com // auto-increment and auto-decrement 27112853Sgabeblack@google.com const sc_fxval_fast operator ++ (int); 27212853Sgabeblack@google.com const sc_fxval_fast operator -- (int); 27312853Sgabeblack@google.com 27412853Sgabeblack@google.com sc_fixed_fast& operator ++ (); 27512853Sgabeblack@google.com sc_fixed_fast& operator -- (); 27612853Sgabeblack@google.com}; 27712853Sgabeblack@google.com 27812853Sgabeblack@google.com 27912853Sgabeblack@google.com// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 28012853Sgabeblack@google.com 28112853Sgabeblack@google.com// ---------------------------------------------------------------------------- 28212853Sgabeblack@google.com// TEMPLATE CLASS : sc_fixed 28312853Sgabeblack@google.com// 28412853Sgabeblack@google.com// "Constrained" signed fixed-point class; arbitrary precision. 28512853Sgabeblack@google.com// ---------------------------------------------------------------------------- 28612853Sgabeblack@google.com 28712853Sgabeblack@google.comtemplate <int W, int I, sc_q_mode Q, sc_o_mode O, int N> 28812853Sgabeblack@google.cominline sc_fixed<W, I, Q, O, N>::sc_fixed(sc_fxnum_observer *observer_) : 28912853Sgabeblack@google.com sc_fix(W, I, Q, O, N, observer_) 29012853Sgabeblack@google.com{} 29112853Sgabeblack@google.com 29212853Sgabeblack@google.comtemplate <int W, int I, sc_q_mode Q, sc_o_mode O, int N> 29312853Sgabeblack@google.cominline sc_fixed<W, I, Q, O, N>::sc_fixed( 29412853Sgabeblack@google.com const sc_fxcast_switch &cast_sw, sc_fxnum_observer *observer_) : 29512853Sgabeblack@google.com sc_fix(W, I, Q, O, N, cast_sw, observer_) 29612853Sgabeblack@google.com{} 29712853Sgabeblack@google.com 29812853Sgabeblack@google.com#define DEFN_CTORS_T(tp) \ 29912853Sgabeblack@google.comtemplate <int W, int I, sc_q_mode Q, sc_o_mode O, int N> \ 30012853Sgabeblack@google.cominline sc_fixed<W, I, Q, O, N>::sc_fixed( \ 30112853Sgabeblack@google.com tp a, sc_fxnum_observer* observer_) : \ 30212853Sgabeblack@google.com sc_fix(a, W, I, Q, O, N, observer_) \ 30312853Sgabeblack@google.com{} \ 30412853Sgabeblack@google.com \ 30512853Sgabeblack@google.comtemplate <int W, int I, sc_q_mode Q, sc_o_mode O, int N> \ 30612853Sgabeblack@google.cominline sc_fixed<W, I, Q, O, N>::sc_fixed( \ 30712853Sgabeblack@google.com tp a, const sc_fxcast_switch &cast_sw, \ 30812853Sgabeblack@google.com sc_fxnum_observer *observer_) : \ 30912853Sgabeblack@google.com sc_fix(a, W, I, Q, O, N, cast_sw, observer_) \ 31012853Sgabeblack@google.com{} 31112853Sgabeblack@google.com 31212853Sgabeblack@google.comDEFN_CTORS_T(int) 31312853Sgabeblack@google.comDEFN_CTORS_T(unsigned int) 31412853Sgabeblack@google.comDEFN_CTORS_T(long) 31512853Sgabeblack@google.comDEFN_CTORS_T(unsigned long) 31612853Sgabeblack@google.comDEFN_CTORS_T(float) 31712853Sgabeblack@google.comDEFN_CTORS_T(double) 31812853Sgabeblack@google.comDEFN_CTORS_T(const char *) 31912853Sgabeblack@google.comDEFN_CTORS_T(const sc_fxval &) 32012853Sgabeblack@google.comDEFN_CTORS_T(const sc_fxval_fast &) 32112853Sgabeblack@google.comDEFN_CTORS_T(const sc_fxnum &) 32212853Sgabeblack@google.comDEFN_CTORS_T(const sc_fxnum_fast &) 32312853Sgabeblack@google.com 32412853Sgabeblack@google.comDEFN_CTORS_T(int64) 32512853Sgabeblack@google.comDEFN_CTORS_T(uint64) 32612853Sgabeblack@google.comDEFN_CTORS_T(const sc_int_base &) 32712853Sgabeblack@google.comDEFN_CTORS_T(const sc_uint_base &) 32812853Sgabeblack@google.comDEFN_CTORS_T(const sc_signed &) 32912853Sgabeblack@google.comDEFN_CTORS_T(const sc_unsigned &) 33012853Sgabeblack@google.com 33112853Sgabeblack@google.com#undef DEFN_CTORS_T 33212853Sgabeblack@google.com 33312853Sgabeblack@google.com// copy constructor 33412853Sgabeblack@google.comtemplate <int W, int I, sc_q_mode Q, sc_o_mode O, int N> 33512853Sgabeblack@google.cominline sc_fixed<W, I, Q, O, N>::sc_fixed(const sc_fixed<W, I, Q, O, N> &a) : 33612853Sgabeblack@google.com sc_fix(a, W, I, Q, O, N) 33712853Sgabeblack@google.com{} 33812853Sgabeblack@google.com 33912853Sgabeblack@google.com// assignment operators 34012853Sgabeblack@google.comtemplate <int W, int I, sc_q_mode Q, sc_o_mode O, int N> 34112853Sgabeblack@google.cominline sc_fixed<W, I, Q, O, N> & 34212853Sgabeblack@google.comsc_fixed<W, I, Q, O, N>::operator = (const sc_fixed<W, I, Q, O, N> &a) 34312853Sgabeblack@google.com{ 34412853Sgabeblack@google.com sc_fix::operator = (a); 34512853Sgabeblack@google.com return *this; 34612853Sgabeblack@google.com} 34712853Sgabeblack@google.com 34812853Sgabeblack@google.com#define DEFN_ASN_OP_T(op, tp) \ 34912853Sgabeblack@google.comtemplate <int W, int I, sc_q_mode Q, sc_o_mode O, int N> \ 35012853Sgabeblack@google.cominline sc_fixed<W, I, Q, O, N> & \ 35112853Sgabeblack@google.comsc_fixed<W, I, Q, O, N>::operator op (tp a) \ 35212853Sgabeblack@google.com{ \ 35312853Sgabeblack@google.com sc_fix::operator op (a); \ 35412853Sgabeblack@google.com return *this; \ 35512853Sgabeblack@google.com} 35612853Sgabeblack@google.com 35712853Sgabeblack@google.com#define DEFN_ASN_OP_OTHER(op) \ 35812853Sgabeblack@google.comDEFN_ASN_OP_T(op, int64) \ 35912853Sgabeblack@google.comDEFN_ASN_OP_T(op, uint64) \ 36012853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_int_base &) \ 36112853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_uint_base &) \ 36212853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_signed &) \ 36312853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_unsigned &) 36412853Sgabeblack@google.com 36512853Sgabeblack@google.com#define DEFN_ASN_OP(op) \ 36612853Sgabeblack@google.comDEFN_ASN_OP_T(op, int) \ 36712853Sgabeblack@google.comDEFN_ASN_OP_T(op, unsigned int) \ 36812853Sgabeblack@google.comDEFN_ASN_OP_T(op, long) \ 36912853Sgabeblack@google.comDEFN_ASN_OP_T(op, unsigned long) \ 37012853Sgabeblack@google.comDEFN_ASN_OP_T(op, float) \ 37112853Sgabeblack@google.comDEFN_ASN_OP_T(op, double) \ 37212853Sgabeblack@google.comDEFN_ASN_OP_T(op, const char *) \ 37312853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_fxval &) \ 37412853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_fxval_fast &) \ 37512853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_fxnum &) \ 37612853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_fxnum_fast &) \ 37712853Sgabeblack@google.comDEFN_ASN_OP_OTHER(op) 37812853Sgabeblack@google.com 37912853Sgabeblack@google.comDEFN_ASN_OP(=) 38012853Sgabeblack@google.com 38112853Sgabeblack@google.comDEFN_ASN_OP(*=) 38212853Sgabeblack@google.comDEFN_ASN_OP(/=) 38312853Sgabeblack@google.comDEFN_ASN_OP(+=) 38412853Sgabeblack@google.comDEFN_ASN_OP(-=) 38512853Sgabeblack@google.com 38612853Sgabeblack@google.comDEFN_ASN_OP_T(<<=, int) 38712853Sgabeblack@google.comDEFN_ASN_OP_T(>>=, int) 38812853Sgabeblack@google.com 38912853Sgabeblack@google.comDEFN_ASN_OP_T(&=, const sc_fix &) 39012853Sgabeblack@google.comDEFN_ASN_OP_T(&=, const sc_fix_fast &) 39112853Sgabeblack@google.comDEFN_ASN_OP_T(|=, const sc_fix &) 39212853Sgabeblack@google.comDEFN_ASN_OP_T(|=, const sc_fix_fast &) 39312853Sgabeblack@google.comDEFN_ASN_OP_T(^=, const sc_fix &) 39412853Sgabeblack@google.comDEFN_ASN_OP_T(^=, const sc_fix_fast &) 39512853Sgabeblack@google.com 39612853Sgabeblack@google.com#undef DEFN_ASN_OP_T 39712853Sgabeblack@google.com#undef DEFN_ASN_OP_OTHER 39812853Sgabeblack@google.com#undef DEFN_ASN_OP 39912853Sgabeblack@google.com 40012853Sgabeblack@google.com// auto-increment and auto-decrement 40112853Sgabeblack@google.comtemplate <int W, int I, sc_q_mode Q, sc_o_mode O, int N> 40212853Sgabeblack@google.cominline const sc_fxval 40312853Sgabeblack@google.comsc_fixed<W, I, Q, O, N>::operator ++ (int) 40412853Sgabeblack@google.com{ 40512853Sgabeblack@google.com return sc_fxval(sc_fix::operator ++ (0)); 40612853Sgabeblack@google.com} 40712853Sgabeblack@google.com 40812853Sgabeblack@google.comtemplate <int W, int I, sc_q_mode Q, sc_o_mode O, int N> 40912853Sgabeblack@google.cominline const sc_fxval 41012853Sgabeblack@google.comsc_fixed<W, I, Q, O, N>::operator -- (int) 41112853Sgabeblack@google.com{ 41212853Sgabeblack@google.com return sc_fxval(sc_fix::operator -- (0)); 41312853Sgabeblack@google.com} 41412853Sgabeblack@google.com 41512853Sgabeblack@google.comtemplate <int W, int I, sc_q_mode Q, sc_o_mode O, int N> 41612853Sgabeblack@google.cominline sc_fixed<W, I, Q, O, N> & 41712853Sgabeblack@google.comsc_fixed<W, I, Q, O, N>::operator ++ () 41812853Sgabeblack@google.com{ 41912853Sgabeblack@google.com sc_fix::operator ++ (); 42012853Sgabeblack@google.com return *this; 42112853Sgabeblack@google.com} 42212853Sgabeblack@google.com 42312853Sgabeblack@google.comtemplate <int W, int I, sc_q_mode Q, sc_o_mode O, int N> 42412853Sgabeblack@google.cominline sc_fixed<W, I, Q, O, N> & 42512853Sgabeblack@google.comsc_fixed<W, I, Q, O, N>::operator -- () 42612853Sgabeblack@google.com{ 42712853Sgabeblack@google.com sc_fix::operator -- (); 42812853Sgabeblack@google.com return *this; 42912853Sgabeblack@google.com} 43012853Sgabeblack@google.com 43112853Sgabeblack@google.com 43212853Sgabeblack@google.com// ---------------------------------------------------------------------------- 43312853Sgabeblack@google.com// TEMPLATE CLASS : sc_fixed_fast 43412853Sgabeblack@google.com// 43512853Sgabeblack@google.com// "Constrained" signed fixed-point class; limited precision. 43612853Sgabeblack@google.com// ---------------------------------------------------------------------------- 43712853Sgabeblack@google.com 43812853Sgabeblack@google.comtemplate <int W, int I, sc_q_mode Q, sc_o_mode O, int N> 43912853Sgabeblack@google.cominline sc_fixed_fast<W, I, Q, O, N>::sc_fixed_fast( 44012853Sgabeblack@google.com sc_fxnum_fast_observer *observer_) : 44112853Sgabeblack@google.com sc_fix_fast(W, I, Q, O, N, observer_) 44212853Sgabeblack@google.com{} 44312853Sgabeblack@google.com 44412853Sgabeblack@google.comtemplate <int W, int I, sc_q_mode Q, sc_o_mode O, int N> 44512853Sgabeblack@google.cominline sc_fixed_fast<W, I, Q, O, N>::sc_fixed_fast( 44612853Sgabeblack@google.com const sc_fxcast_switch &cast_sw, sc_fxnum_fast_observer *observer_) : 44712853Sgabeblack@google.com sc_fix_fast(W, I, Q, O, N, cast_sw, observer_) 44812853Sgabeblack@google.com{} 44912853Sgabeblack@google.com 45012853Sgabeblack@google.com#define DEFN_CTORS_T(tp) \ 45112853Sgabeblack@google.comtemplate <int W, int I, sc_q_mode Q, sc_o_mode O, int N> \ 45212853Sgabeblack@google.cominline sc_fixed_fast<W, I, Q, O, N>::sc_fixed_fast( \ 45312853Sgabeblack@google.com tp a, sc_fxnum_fast_observer *observer_) : \ 45412853Sgabeblack@google.com sc_fix_fast(a, W, I, Q, O, N, observer_) \ 45512853Sgabeblack@google.com{} \ 45612853Sgabeblack@google.com \ 45712853Sgabeblack@google.comtemplate <int W, int I, sc_q_mode Q, sc_o_mode O, int N> \ 45812853Sgabeblack@google.cominline sc_fixed_fast<W, I, Q, O, N>::sc_fixed_fast( \ 45912853Sgabeblack@google.com tp a, const sc_fxcast_switch &cast_sw, \ 46012853Sgabeblack@google.com sc_fxnum_fast_observer *observer_) : \ 46112853Sgabeblack@google.com sc_fix_fast(a, W, I, Q, O, N, cast_sw, observer_) \ 46212853Sgabeblack@google.com{} 46312853Sgabeblack@google.com 46412853Sgabeblack@google.comDEFN_CTORS_T(int) 46512853Sgabeblack@google.comDEFN_CTORS_T(unsigned int) 46612853Sgabeblack@google.comDEFN_CTORS_T(long) 46712853Sgabeblack@google.comDEFN_CTORS_T(unsigned long) 46812853Sgabeblack@google.comDEFN_CTORS_T(float) 46912853Sgabeblack@google.comDEFN_CTORS_T(double) 47012853Sgabeblack@google.comDEFN_CTORS_T(const char *) 47112853Sgabeblack@google.comDEFN_CTORS_T(const sc_fxval &) 47212853Sgabeblack@google.comDEFN_CTORS_T(const sc_fxval_fast &) 47312853Sgabeblack@google.comDEFN_CTORS_T(const sc_fxnum &) 47412853Sgabeblack@google.comDEFN_CTORS_T(const sc_fxnum_fast &) 47512853Sgabeblack@google.com 47612853Sgabeblack@google.comDEFN_CTORS_T(int64) 47712853Sgabeblack@google.comDEFN_CTORS_T(uint64) 47812853Sgabeblack@google.comDEFN_CTORS_T(const sc_int_base &) 47912853Sgabeblack@google.comDEFN_CTORS_T(const sc_uint_base &) 48012853Sgabeblack@google.comDEFN_CTORS_T(const sc_signed &) 48112853Sgabeblack@google.comDEFN_CTORS_T(const sc_unsigned &) 48212853Sgabeblack@google.com 48312853Sgabeblack@google.com#undef DEFN_CTORS_T 48412853Sgabeblack@google.com 48512853Sgabeblack@google.com// copy constructor 48612853Sgabeblack@google.comtemplate <int W, int I, sc_q_mode Q, sc_o_mode O, int N> 48712853Sgabeblack@google.cominline sc_fixed_fast<W, I, Q, O, N>::sc_fixed_fast( 48812853Sgabeblack@google.com const sc_fixed_fast<W, I, Q, O, N> &a) : sc_fix_fast(a, W, I, Q, O, N) 48912853Sgabeblack@google.com{} 49012853Sgabeblack@google.com 49112853Sgabeblack@google.com// assignment operators 49212853Sgabeblack@google.comtemplate <int W, int I, sc_q_mode Q, sc_o_mode O, int N> 49312853Sgabeblack@google.cominline sc_fixed_fast<W, I, Q, O, N> & 49412853Sgabeblack@google.comsc_fixed_fast<W, I, Q, O, N>::operator = ( 49512853Sgabeblack@google.com const sc_fixed_fast<W, I, Q, O, N> &a) 49612853Sgabeblack@google.com{ 49712853Sgabeblack@google.com sc_fix_fast::operator = (a); 49812853Sgabeblack@google.com return *this; 49912853Sgabeblack@google.com} 50012853Sgabeblack@google.com 50112853Sgabeblack@google.com#define DEFN_ASN_OP_T(op, tp) \ 50212853Sgabeblack@google.comtemplate <int W, int I, sc_q_mode Q, sc_o_mode O, int N> \ 50312853Sgabeblack@google.cominline sc_fixed_fast<W, I, Q, O, N> & \ 50412853Sgabeblack@google.comsc_fixed_fast<W, I, Q, O, N>::operator op (tp a) \ 50512853Sgabeblack@google.com{ \ 50612853Sgabeblack@google.com sc_fix_fast::operator op (a); \ 50712853Sgabeblack@google.com return *this; \ 50812853Sgabeblack@google.com} 50912853Sgabeblack@google.com 51012853Sgabeblack@google.com#define DEFN_ASN_OP_OTHER(op) \ 51112853Sgabeblack@google.comDEFN_ASN_OP_T(op, int64) \ 51212853Sgabeblack@google.comDEFN_ASN_OP_T(op, uint64) \ 51312853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_int_base &) \ 51412853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_uint_base &) \ 51512853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_signed &) \ 51612853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_unsigned &) 51712853Sgabeblack@google.com 51812853Sgabeblack@google.com#define DEFN_ASN_OP(op) \ 51912853Sgabeblack@google.comDEFN_ASN_OP_T(op, int) \ 52012853Sgabeblack@google.comDEFN_ASN_OP_T(op, unsigned int) \ 52112853Sgabeblack@google.comDEFN_ASN_OP_T(op, long) \ 52212853Sgabeblack@google.comDEFN_ASN_OP_T(op, unsigned long) \ 52312853Sgabeblack@google.comDEFN_ASN_OP_T(op, float) \ 52412853Sgabeblack@google.comDEFN_ASN_OP_T(op, double) \ 52512853Sgabeblack@google.comDEFN_ASN_OP_T(op, const char *) \ 52612853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_fxval &) \ 52712853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_fxval_fast &) \ 52812853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_fxnum &) \ 52912853Sgabeblack@google.comDEFN_ASN_OP_T(op, const sc_fxnum_fast &) \ 53012853Sgabeblack@google.comDEFN_ASN_OP_OTHER(op) 53112853Sgabeblack@google.com 53212853Sgabeblack@google.comDEFN_ASN_OP(=) 53312853Sgabeblack@google.com 53412853Sgabeblack@google.comDEFN_ASN_OP(*=) 53512853Sgabeblack@google.comDEFN_ASN_OP(/=) 53612853Sgabeblack@google.comDEFN_ASN_OP(+=) 53712853Sgabeblack@google.comDEFN_ASN_OP(-=) 53812853Sgabeblack@google.com 53912853Sgabeblack@google.comDEFN_ASN_OP_T(<<=, int) 54012853Sgabeblack@google.comDEFN_ASN_OP_T(>>=, int) 54112853Sgabeblack@google.com 54212853Sgabeblack@google.comDEFN_ASN_OP_T(&=, const sc_fix &) 54312853Sgabeblack@google.comDEFN_ASN_OP_T(&=, const sc_fix_fast &) 54412853Sgabeblack@google.comDEFN_ASN_OP_T(|=, const sc_fix &) 54512853Sgabeblack@google.comDEFN_ASN_OP_T(|=, const sc_fix_fast &) 54612853Sgabeblack@google.comDEFN_ASN_OP_T(^=, const sc_fix &) 54712853Sgabeblack@google.comDEFN_ASN_OP_T(^=, const sc_fix_fast &) 54812853Sgabeblack@google.com 54912853Sgabeblack@google.com#undef DEFN_ASN_OP_T 55012853Sgabeblack@google.com#undef DEFN_ASN_OP_OTHER 55112853Sgabeblack@google.com#undef DEFN_ASN_OP 55212853Sgabeblack@google.com 55312853Sgabeblack@google.com// auto-increment and auto-decrement 55412853Sgabeblack@google.comtemplate <int W, int I, sc_q_mode Q, sc_o_mode O, int N> 55512853Sgabeblack@google.cominline const sc_fxval_fast 55612853Sgabeblack@google.comsc_fixed_fast<W, I, Q, O, N>::operator ++ (int) 55712853Sgabeblack@google.com{ 55812853Sgabeblack@google.com return sc_fxval_fast(sc_fix_fast::operator ++ (0)); 55912853Sgabeblack@google.com} 56012853Sgabeblack@google.com 56112853Sgabeblack@google.comtemplate <int W, int I, sc_q_mode Q, sc_o_mode O, int N> 56212853Sgabeblack@google.cominline const sc_fxval_fast 56312853Sgabeblack@google.comsc_fixed_fast<W, I, Q, O, N>::operator -- (int) 56412853Sgabeblack@google.com{ 56512853Sgabeblack@google.com return sc_fxval_fast(sc_fix_fast::operator -- (0)); 56612853Sgabeblack@google.com} 56712853Sgabeblack@google.com 56812853Sgabeblack@google.comtemplate <int W, int I, sc_q_mode Q, sc_o_mode O, int N> 56912853Sgabeblack@google.cominline sc_fixed_fast<W, I, Q, O, N> & 57012853Sgabeblack@google.comsc_fixed_fast<W, I, Q, O, N>::operator ++ () 57112853Sgabeblack@google.com{ 57212853Sgabeblack@google.com sc_fix_fast::operator ++ (); 57312853Sgabeblack@google.com return *this; 57412853Sgabeblack@google.com} 57512853Sgabeblack@google.com 57612853Sgabeblack@google.comtemplate <int W, int I, sc_q_mode Q, sc_o_mode O, int N> 57712853Sgabeblack@google.cominline sc_fixed_fast<W, I, Q, O, N> & 57812853Sgabeblack@google.comsc_fixed_fast<W, I, Q, O, N>::operator -- () 57912853Sgabeblack@google.com{ 58012853Sgabeblack@google.com sc_fix_fast::operator -- (); 58112853Sgabeblack@google.com return *this; 58212853Sgabeblack@google.com} 58312853Sgabeblack@google.com 58412853Sgabeblack@google.com} // namespace sc_dt 58512853Sgabeblack@google.com 58612853Sgabeblack@google.com#endif // __SYSTEMC_EXT_DT_FX_SC_FIXED_HH__ 587