sc_bigint.hh revision 12853:e23d6f09069a
17506Stjones1@inf.ed.ac.uk/***************************************************************************** 27506Stjones1@inf.ed.ac.uk 37506Stjones1@inf.ed.ac.uk Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 47506Stjones1@inf.ed.ac.uk more contributor license agreements. See the NOTICE file distributed 57506Stjones1@inf.ed.ac.uk with this work for additional information regarding copyright ownership. 67506Stjones1@inf.ed.ac.uk Accellera licenses this file to you under the Apache License, Version 2.0 77506Stjones1@inf.ed.ac.uk (the "License"); you may not use this file except in compliance with the 87506Stjones1@inf.ed.ac.uk License. You may obtain a copy of the License at 97506Stjones1@inf.ed.ac.uk 107506Stjones1@inf.ed.ac.uk http://www.apache.org/licenses/LICENSE-2.0 117506Stjones1@inf.ed.ac.uk 127506Stjones1@inf.ed.ac.uk Unless required by applicable law or agreed to in writing, software 137506Stjones1@inf.ed.ac.uk distributed under the License is distributed on an "AS IS" BASIS, 147506Stjones1@inf.ed.ac.uk WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 157506Stjones1@inf.ed.ac.uk implied. See the License for the specific language governing 167506Stjones1@inf.ed.ac.uk permissions and limitations under the License. 177506Stjones1@inf.ed.ac.uk 187506Stjones1@inf.ed.ac.uk *****************************************************************************/ 197506Stjones1@inf.ed.ac.uk 207506Stjones1@inf.ed.ac.uk/***************************************************************************** 217506Stjones1@inf.ed.ac.uk 227506Stjones1@inf.ed.ac.uk sc_bigint.h -- Template version of sc_signed. This class enables 237506Stjones1@inf.ed.ac.uk compile-time bit widths for sc_signed numbers. 247506Stjones1@inf.ed.ac.uk 257506Stjones1@inf.ed.ac.uk Original Author: Ali Dasdan, Synopsys, Inc. 267506Stjones1@inf.ed.ac.uk 277506Stjones1@inf.ed.ac.uk *****************************************************************************/ 287506Stjones1@inf.ed.ac.uk 297506Stjones1@inf.ed.ac.uk/***************************************************************************** 307506Stjones1@inf.ed.ac.uk 317506Stjones1@inf.ed.ac.uk MODIFICATION LOG - modifiers, enter your name, affiliation, date and 327506Stjones1@inf.ed.ac.uk changes you are making here. 337506Stjones1@inf.ed.ac.uk 347506Stjones1@inf.ed.ac.uk Name, Affiliation, Date: Gene Bushayev, Synopsys, Inc. 357506Stjones1@inf.ed.ac.uk Description of Modification: - Interface between sc_bigint and sc_bv/sc_lv. 3611793Sbrandon.potter@amd.com 3712334Sgabeblack@google.com Name, Affiliation, Date: 387506Stjones1@inf.ed.ac.uk Description of Modification: 397506Stjones1@inf.ed.ac.uk 407506Stjones1@inf.ed.ac.uk *****************************************************************************/ 417506Stjones1@inf.ed.ac.uk 427506Stjones1@inf.ed.ac.uk// $Log: sc_bigint.h,v $ 437506Stjones1@inf.ed.ac.uk// Revision 1.2 2011/02/18 20:19:14 acg 447506Stjones1@inf.ed.ac.uk// Andy Goodrich: updating Copyright notice. 457506Stjones1@inf.ed.ac.uk// 467506Stjones1@inf.ed.ac.uk// Revision 1.1.1.1 2006/12/15 20:20:05 acg 477506Stjones1@inf.ed.ac.uk// SystemC 2.3 487506Stjones1@inf.ed.ac.uk// 497506Stjones1@inf.ed.ac.uk// Revision 1.3 2006/01/13 18:49:31 acg 5013611Sgabeblack@google.com// Added $Log command so that CVS check in comments are reproduced in the 517506Stjones1@inf.ed.ac.uk// source. 529920Syasuko.eckert@amd.com// 539920Syasuko.eckert@amd.com 549920Syasuko.eckert@amd.com#ifndef __SYSTEMC_EXT_DT_INT_SC_BIGINT_HH__ 557506Stjones1@inf.ed.ac.uk#define __SYSTEMC_EXT_DT_INT_SC_BIGINT_HH__ 567506Stjones1@inf.ed.ac.uk 577506Stjones1@inf.ed.ac.uk#include "sc_signed.hh" 587506Stjones1@inf.ed.ac.uk#include "sc_unsigned.hh" 597720Sgblack@eecs.umich.edu 607506Stjones1@inf.ed.ac.uknamespace sc_dt 617506Stjones1@inf.ed.ac.uk{ 628787Sgblack@eecs.umich.edu 638787Sgblack@eecs.umich.edu// classes defined in this module 648787Sgblack@eecs.umich.edutemplate <int W> 658787Sgblack@eecs.umich.educlass sc_bigint; 668787Sgblack@eecs.umich.edu 678787Sgblack@eecs.umich.edu// forward class declarations 688787Sgblack@eecs.umich.educlass sc_bv_base; 697693SAli.Saidi@ARM.comclass sc_lv_base; 707693SAli.Saidi@ARM.comclass sc_fxval; 717693SAli.Saidi@ARM.comclass sc_fxval_fast; 727693SAli.Saidi@ARM.comclass sc_fxnum; 737693SAli.Saidi@ARM.comclass sc_fxnum_fast; 747693SAli.Saidi@ARM.com 758791Sgblack@eecs.umich.edu 768791Sgblack@eecs.umich.edu// ---------------------------------------------------------------------------- 778791Sgblack@eecs.umich.edu// CLASS TEMPLATE : sc_bigint<W> 788791Sgblack@eecs.umich.edu// 798791Sgblack@eecs.umich.edu// Arbitrary size signed integer type. 808791Sgblack@eecs.umich.edu// ---------------------------------------------------------------------------- 817693SAli.Saidi@ARM.com 827811Ssteve.reinhardt@amd.com#ifdef SC_MAX_NBITS 83template<int W=SC_MAX_NBITS> 84#else 85template<int W> 86#endif 87class sc_bigint : public sc_signed 88{ 89 public: 90 // constructors 91 sc_bigint() : sc_signed(W) {} 92 sc_bigint(const sc_bigint<W> &v) : sc_signed(W) { *this = v; } 93 sc_bigint(const sc_signed &v) : sc_signed(W) { *this = v; } 94 sc_bigint(const sc_signed_subref &v) : sc_signed(W) { *this = v; } 95 96 template< class T > 97 sc_bigint(const sc_generic_base<T> &a) : sc_signed(W) 98 { 99 a->to_sc_signed(*this); 100 } 101 102 sc_bigint(const sc_unsigned &v) : sc_signed(W) { *this = v; } 103 sc_bigint(const sc_unsigned_subref &v) : sc_signed(W) { *this = v; } 104 sc_bigint(const char *v) : sc_signed(W) { *this = v; } 105 sc_bigint(int64 v) : sc_signed(W) { *this = v; } 106 sc_bigint(uint64 v) : sc_signed(W) { *this = v; } 107 sc_bigint(long v) : sc_signed(W) { *this = v; } 108 sc_bigint(unsigned long v) : sc_signed(W) { *this = v; } 109 sc_bigint(int v) : sc_signed(W) { *this = v; } 110 sc_bigint(unsigned int v) : sc_signed(W) { *this = v; } 111 sc_bigint(double v) : sc_signed(W) { *this = v; } 112 sc_bigint(const sc_bv_base &v) : sc_signed(W) { *this = v; } 113 sc_bigint(const sc_lv_base &v) : sc_signed(W) { *this = v; } 114 115 explicit sc_bigint(const sc_fxval &v) : sc_signed(W) { *this = v; } 116 explicit sc_bigint(const sc_fxval_fast &v) : sc_signed(W) { *this = v; } 117 explicit sc_bigint(const sc_fxnum &v) : sc_signed(W) { *this = v; } 118 explicit sc_bigint(const sc_fxnum_fast &v) : sc_signed(W) { *this = v; } 119 120#ifndef SC_MAX_NBITS 121 // destructor 122 ~sc_bigint() {} 123#endif 124 125 // assignment operators 126 sc_bigint<W> & 127 operator = (const sc_bigint<W> &v) 128 { 129 sc_signed::operator = (v); 130 return *this; 131 } 132 133 sc_bigint<W> & 134 operator = (const sc_signed &v) 135 { 136 sc_signed::operator = (v); 137 return *this; 138 } 139 140 sc_bigint<W> & 141 operator = (const sc_signed_subref &v) 142 { 143 sc_signed::operator = (v); 144 return *this; 145 } 146 147 template< class T > 148 sc_bigint<W> & 149 operator = (const sc_generic_base<T> &a) 150 { 151 a->to_sc_signed(*this); 152 return *this; 153 } 154 155 sc_bigint<W> & 156 operator = (const sc_unsigned &v) 157 { 158 sc_signed::operator = (v); 159 return *this; 160 } 161 162 sc_bigint<W> & 163 operator = (const sc_unsigned_subref &v) 164 { 165 sc_signed::operator = (v); 166 return *this; 167 } 168 169 sc_bigint<W> & 170 operator = (const char *v) 171 { 172 sc_signed::operator = (v); 173 return *this; 174 } 175 176 sc_bigint<W> & 177 operator = (int64 v) 178 { 179 sc_signed::operator = (v); 180 return *this; 181 } 182 183 sc_bigint<W> & 184 operator = (uint64 v) 185 { 186 sc_signed::operator = (v); 187 return *this; 188 } 189 190 sc_bigint<W> & 191 operator = (long v) 192 { 193 sc_signed::operator = (v); 194 return *this; 195 } 196 197 sc_bigint<W> & 198 operator = (unsigned long v) 199 { 200 sc_signed::operator = (v); 201 return *this; 202 } 203 204 sc_bigint<W> & 205 operator = (int v) 206 { 207 sc_signed::operator = (v); 208 return *this; 209 } 210 211 sc_bigint<W> & 212 operator = (unsigned int v) 213 { 214 sc_signed::operator = (v); 215 return *this; 216 } 217 218 sc_bigint<W> &operator = (double v) 219 { 220 sc_signed::operator = (v); 221 return *this; 222 } 223 224 225 sc_bigint<W> & 226 operator = (const sc_bv_base &v) 227 { 228 sc_signed::operator = (v); 229 return *this; 230 } 231 232 sc_bigint<W> & 233 operator = (const sc_lv_base &v) 234 { 235 sc_signed::operator = (v); 236 return *this; 237 } 238 239 sc_bigint<W> & 240 operator = (const sc_int_base &v) 241 { 242 sc_signed::operator = (v); 243 return *this; 244 } 245 246 sc_bigint<W> & 247 operator = (const sc_uint_base &v) 248 { 249 sc_signed::operator = (v); 250 return *this; 251 } 252 253 sc_bigint<W> & 254 operator = (const sc_fxval &v) 255 { 256 sc_signed::operator = (v); 257 return *this; 258 } 259 260 sc_bigint<W> & 261 operator = (const sc_fxval_fast& v) 262 { 263 sc_signed::operator = (v); 264 return *this; 265 } 266 267 sc_bigint<W> & 268 operator = (const sc_fxnum &v) 269 { 270 sc_signed::operator = (v); 271 return *this; 272 } 273 274 sc_bigint<W> & 275 operator = (const sc_fxnum_fast &v) 276 { 277 sc_signed::operator = (v); 278 return *this; 279 } 280}; 281 282} // namespace sc_dt 283 284#endif // __SYSTEMC_EXT_DT_INT_SC_BIGINT_HH__ 285