sc_biguint.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_biguint.h -- Template version of sc_unsigned. This class 2312853Sgabeblack@google.com enables compile-time bit widths for sc_unsigned numbers. 2412853Sgabeblack@google.com 2512853Sgabeblack@google.com Original Author: Ali Dasdan, Synopsys, Inc. 2612853Sgabeblack@google.com 2712853Sgabeblack@google.com *****************************************************************************/ 2812853Sgabeblack@google.com 2912853Sgabeblack@google.com/***************************************************************************** 3012853Sgabeblack@google.com 3112853Sgabeblack@google.com MODIFICATION LOG - modifiers, enter your name, affiliation, date and 3212853Sgabeblack@google.com changes you are making here. 3312853Sgabeblack@google.com 3412853Sgabeblack@google.com Name, Affiliation, Date: Gene Bushayev, Synopsys, Inc. 3512853Sgabeblack@google.com Description of Modification: - Interface between sc_bigint and sc_bv/sc_lv. 3612853Sgabeblack@google.com 3712853Sgabeblack@google.com Name, Affiliation, Date: 3812853Sgabeblack@google.com Description of Modification: 3912853Sgabeblack@google.com 4012853Sgabeblack@google.com *****************************************************************************/ 4112853Sgabeblack@google.com 4212853Sgabeblack@google.com// $Log: sc_biguint.h,v $ 4312853Sgabeblack@google.com// Revision 1.2 2011/02/18 20:19:14 acg 4412853Sgabeblack@google.com// Andy Goodrich: updating Copyright notice. 4512853Sgabeblack@google.com// 4612853Sgabeblack@google.com// Revision 1.1.1.1 2006/12/15 20:20:05 acg 4712853Sgabeblack@google.com// SystemC 2.3 4812853Sgabeblack@google.com// 4912853Sgabeblack@google.com// Revision 1.3 2006/01/13 18:49:31 acg 5012853Sgabeblack@google.com// Added $Log command so that CVS check in comments are reproduced in the 5112853Sgabeblack@google.com// source. 5212853Sgabeblack@google.com// 5312853Sgabeblack@google.com 5412853Sgabeblack@google.com#ifndef __SYSTEMC_EXT_DT_INT_SC_BIGUINT_HH__ 5512853Sgabeblack@google.com#define __SYSTEMC_EXT_DT_INT_SC_BIGUINT_HH__ 5612853Sgabeblack@google.com 5712853Sgabeblack@google.com#include "sc_signed.hh" 5812853Sgabeblack@google.com#include "sc_unsigned.hh" 5912853Sgabeblack@google.com 6012853Sgabeblack@google.comnamespace sc_dt 6112853Sgabeblack@google.com{ 6212853Sgabeblack@google.com 6312853Sgabeblack@google.com// classes defined in this module 6412853Sgabeblack@google.comtemplate <int W> 6512853Sgabeblack@google.comclass sc_biguint; 6612853Sgabeblack@google.com 6712853Sgabeblack@google.com// forward class declarations 6812853Sgabeblack@google.comclass sc_bv_base; 6912853Sgabeblack@google.comclass sc_lv_base; 7012853Sgabeblack@google.comclass sc_fxval; 7112853Sgabeblack@google.comclass sc_fxval_fast; 7212853Sgabeblack@google.comclass sc_fxnum; 7312853Sgabeblack@google.comclass sc_fxnum_fast; 7412853Sgabeblack@google.com 7512853Sgabeblack@google.com 7612853Sgabeblack@google.com// ---------------------------------------------------------------------------- 7712853Sgabeblack@google.com// CLASS TEMPLATE : sc_biguint<W> 7812853Sgabeblack@google.com// 7912853Sgabeblack@google.com// Arbitrary size unsigned integer type. 8012853Sgabeblack@google.com// ---------------------------------------------------------------------------- 8112853Sgabeblack@google.com 8212853Sgabeblack@google.com#ifdef SC_MAX_NBITS 8312853Sgabeblack@google.comtemplate<int W=SC_MAX_NBITS> 8412853Sgabeblack@google.com#else 8512853Sgabeblack@google.comtemplate<int W> 8612853Sgabeblack@google.com#endif 8712853Sgabeblack@google.comclass sc_biguint : public sc_unsigned 8812853Sgabeblack@google.com{ 8912853Sgabeblack@google.com public: 9012853Sgabeblack@google.com // constructors 9112853Sgabeblack@google.com sc_biguint() : sc_unsigned(W) {} 9212853Sgabeblack@google.com sc_biguint(const sc_biguint<W> &v) : sc_unsigned(W) { *this = v; } 9312853Sgabeblack@google.com sc_biguint(const sc_unsigned &v) : sc_unsigned(W) { *this = v; } 9412853Sgabeblack@google.com sc_biguint(const sc_unsigned_subref &v) : sc_unsigned(W) { *this = v; } 9512853Sgabeblack@google.com 9612853Sgabeblack@google.com template<class T> 9712853Sgabeblack@google.com sc_biguint(const sc_generic_base<T> &a) : sc_unsigned(W) 9812853Sgabeblack@google.com { 9912853Sgabeblack@google.com a->to_sc_unsigned(*this); 10012853Sgabeblack@google.com } 10112853Sgabeblack@google.com 10212853Sgabeblack@google.com sc_biguint(const sc_signed &v) : sc_unsigned(W) { *this = v; } 10312853Sgabeblack@google.com sc_biguint(const sc_signed_subref &v) : sc_unsigned(W) { *this = v; } 10412853Sgabeblack@google.com sc_biguint(const char* v) : sc_unsigned(W) { *this = v; } 10512853Sgabeblack@google.com sc_biguint(int64 v) : sc_unsigned(W) { *this = v; } 10612853Sgabeblack@google.com sc_biguint(uint64 v) : sc_unsigned(W) { *this = v; } 10712853Sgabeblack@google.com sc_biguint(long v) : sc_unsigned(W) { *this = v; } 10812853Sgabeblack@google.com sc_biguint(unsigned long v) : sc_unsigned(W) { *this = v; } 10912853Sgabeblack@google.com sc_biguint(int v) : sc_unsigned(W) { *this = v; } 11012853Sgabeblack@google.com sc_biguint(unsigned int v) : sc_unsigned(W) { *this = v; } 11112853Sgabeblack@google.com sc_biguint(double v) : sc_unsigned(W) { *this = v; } 11212853Sgabeblack@google.com sc_biguint(const sc_bv_base &v) : sc_unsigned(W) { *this = v; } 11312853Sgabeblack@google.com sc_biguint(const sc_lv_base &v) : sc_unsigned(W) { *this = v; } 11412853Sgabeblack@google.com 11512853Sgabeblack@google.com explicit sc_biguint(const sc_fxval &v) : sc_unsigned(W) { *this = v; } 11612853Sgabeblack@google.com explicit sc_biguint(const sc_fxval_fast &v) : sc_unsigned(W) { *this = v; } 11712853Sgabeblack@google.com explicit sc_biguint(const sc_fxnum &v) : sc_unsigned(W) { *this = v; } 11812853Sgabeblack@google.com explicit sc_biguint(const sc_fxnum_fast &v) : sc_unsigned(W) { *this = v; } 11912853Sgabeblack@google.com 12012853Sgabeblack@google.com#ifndef SC_MAX_NBITS 12112853Sgabeblack@google.com // destructor 12212853Sgabeblack@google.com ~sc_biguint() {} 12312853Sgabeblack@google.com#endif 12412853Sgabeblack@google.com 12512853Sgabeblack@google.com // assignment operators 12612853Sgabeblack@google.com sc_biguint<W> & 12712853Sgabeblack@google.com operator = (const sc_biguint<W> &v) 12812853Sgabeblack@google.com { 12912853Sgabeblack@google.com sc_unsigned::operator = (v); 13012853Sgabeblack@google.com return *this; 13112853Sgabeblack@google.com } 13212853Sgabeblack@google.com 13312853Sgabeblack@google.com sc_biguint<W> & 13412853Sgabeblack@google.com operator = (const sc_unsigned &v) 13512853Sgabeblack@google.com { 13612853Sgabeblack@google.com sc_unsigned::operator = (v); 13712853Sgabeblack@google.com return *this; 13812853Sgabeblack@google.com } 13912853Sgabeblack@google.com 14012853Sgabeblack@google.com sc_biguint<W> & 14112853Sgabeblack@google.com operator = (const sc_unsigned_subref &v) 14212853Sgabeblack@google.com { 14312853Sgabeblack@google.com sc_unsigned::operator = (v); 14412853Sgabeblack@google.com return *this; 14512853Sgabeblack@google.com } 14612853Sgabeblack@google.com 14712853Sgabeblack@google.com template< class T > 14812853Sgabeblack@google.com sc_biguint<W> & 14912853Sgabeblack@google.com operator = (const sc_generic_base<T> &a) 15012853Sgabeblack@google.com { a->to_sc_unsigned(*this); 15112853Sgabeblack@google.com return *this; 15212853Sgabeblack@google.com } 15312853Sgabeblack@google.com 15412853Sgabeblack@google.com sc_biguint<W> & 15512853Sgabeblack@google.com operator = (const sc_signed &v) 15612853Sgabeblack@google.com { 15712853Sgabeblack@google.com sc_unsigned::operator = (v); 15812853Sgabeblack@google.com return *this; 15912853Sgabeblack@google.com } 16012853Sgabeblack@google.com 16112853Sgabeblack@google.com sc_biguint<W> & 16212853Sgabeblack@google.com operator = (const sc_signed_subref &v) 16312853Sgabeblack@google.com { 16412853Sgabeblack@google.com sc_unsigned::operator = (v); 16512853Sgabeblack@google.com return *this; 16612853Sgabeblack@google.com } 16712853Sgabeblack@google.com 16812853Sgabeblack@google.com sc_biguint<W> & 16912853Sgabeblack@google.com operator = (const char* v) 17012853Sgabeblack@google.com { 17112853Sgabeblack@google.com sc_unsigned::operator = (v); 17212853Sgabeblack@google.com return *this; 17312853Sgabeblack@google.com } 17412853Sgabeblack@google.com 17512853Sgabeblack@google.com sc_biguint<W> & 17612853Sgabeblack@google.com operator = (int64 v) 17712853Sgabeblack@google.com { 17812853Sgabeblack@google.com sc_unsigned::operator = (v); 17912853Sgabeblack@google.com return *this; 18012853Sgabeblack@google.com } 18112853Sgabeblack@google.com 18212853Sgabeblack@google.com sc_biguint<W> & 18312853Sgabeblack@google.com operator = (uint64 v) 18412853Sgabeblack@google.com { 18512853Sgabeblack@google.com sc_unsigned::operator = (v); 18612853Sgabeblack@google.com return *this; 18712853Sgabeblack@google.com } 18812853Sgabeblack@google.com 18912853Sgabeblack@google.com sc_biguint<W> & 19012853Sgabeblack@google.com operator = (long v) 19112853Sgabeblack@google.com { 19212853Sgabeblack@google.com sc_unsigned::operator = (v); 19312853Sgabeblack@google.com return *this; 19412853Sgabeblack@google.com } 19512853Sgabeblack@google.com 19612853Sgabeblack@google.com sc_biguint<W> & 19712853Sgabeblack@google.com operator = (unsigned long v) 19812853Sgabeblack@google.com { 19912853Sgabeblack@google.com sc_unsigned::operator = (v); 20012853Sgabeblack@google.com return *this; 20112853Sgabeblack@google.com } 20212853Sgabeblack@google.com 20312853Sgabeblack@google.com sc_biguint<W> & 20412853Sgabeblack@google.com operator = (int v) 20512853Sgabeblack@google.com { 20612853Sgabeblack@google.com sc_unsigned::operator = (v); 20712853Sgabeblack@google.com return *this; 20812853Sgabeblack@google.com } 20912853Sgabeblack@google.com 21012853Sgabeblack@google.com sc_biguint<W> & 21112853Sgabeblack@google.com operator = (unsigned int v) 21212853Sgabeblack@google.com { 21312853Sgabeblack@google.com sc_unsigned::operator = (v); 21412853Sgabeblack@google.com return *this; 21512853Sgabeblack@google.com } 21612853Sgabeblack@google.com 21712853Sgabeblack@google.com sc_biguint<W> & 21812853Sgabeblack@google.com operator = (double v) 21912853Sgabeblack@google.com { 22012853Sgabeblack@google.com sc_unsigned::operator = (v); 22112853Sgabeblack@google.com return *this; 22212853Sgabeblack@google.com } 22312853Sgabeblack@google.com 22412853Sgabeblack@google.com 22512853Sgabeblack@google.com sc_biguint<W> & 22612853Sgabeblack@google.com operator = (const sc_bv_base &v) 22712853Sgabeblack@google.com { 22812853Sgabeblack@google.com sc_unsigned::operator = (v); 22912853Sgabeblack@google.com return *this; 23012853Sgabeblack@google.com } 23112853Sgabeblack@google.com 23212853Sgabeblack@google.com sc_biguint<W> & 23312853Sgabeblack@google.com operator = (const sc_lv_base &v) 23412853Sgabeblack@google.com { 23512853Sgabeblack@google.com sc_unsigned::operator = (v); 23612853Sgabeblack@google.com return *this; 23712853Sgabeblack@google.com } 23812853Sgabeblack@google.com 23912853Sgabeblack@google.com sc_biguint<W> & 24012853Sgabeblack@google.com operator = (const sc_int_base &v) 24112853Sgabeblack@google.com { 24212853Sgabeblack@google.com sc_unsigned::operator = (v); 24312853Sgabeblack@google.com return *this; 24412853Sgabeblack@google.com } 24512853Sgabeblack@google.com 24612853Sgabeblack@google.com sc_biguint<W> & 24712853Sgabeblack@google.com operator = (const sc_uint_base &v) 24812853Sgabeblack@google.com { 24912853Sgabeblack@google.com sc_unsigned::operator = (v); 25012853Sgabeblack@google.com return *this; 25112853Sgabeblack@google.com } 25212853Sgabeblack@google.com 25312853Sgabeblack@google.com sc_biguint<W> & 25412853Sgabeblack@google.com operator = (const sc_fxval &v) 25512853Sgabeblack@google.com { 25612853Sgabeblack@google.com sc_unsigned::operator = (v); 25712853Sgabeblack@google.com return *this; 25812853Sgabeblack@google.com } 25912853Sgabeblack@google.com 26012853Sgabeblack@google.com sc_biguint<W> & 26112853Sgabeblack@google.com operator = (const sc_fxval_fast &v) 26212853Sgabeblack@google.com { 26312853Sgabeblack@google.com sc_unsigned::operator = (v); 26412853Sgabeblack@google.com return *this; 26512853Sgabeblack@google.com } 26612853Sgabeblack@google.com 26712853Sgabeblack@google.com sc_biguint<W> & 26812853Sgabeblack@google.com operator = (const sc_fxnum &v) 26912853Sgabeblack@google.com { 27012853Sgabeblack@google.com sc_unsigned::operator = (v); 27112853Sgabeblack@google.com return *this; 27212853Sgabeblack@google.com } 27312853Sgabeblack@google.com 27412853Sgabeblack@google.com sc_biguint<W> & 27512853Sgabeblack@google.com operator = (const sc_fxnum_fast &v) 27612853Sgabeblack@google.com { 27712853Sgabeblack@google.com sc_unsigned::operator = (v); 27812853Sgabeblack@google.com return *this; 27912853Sgabeblack@google.com } 28012853Sgabeblack@google.com}; 28112853Sgabeblack@google.com 28212853Sgabeblack@google.com} // namespace sc_dt 28312853Sgabeblack@google.com 28412853Sgabeblack@google.com#endif // __SYSTEMC_EXT_DT_INT_SC_BIGUINT_HH__ 285