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