SystemC 3.0.0
Accellera SystemC proof-of-concept library
sc_bigint.h
Go to the documentation of this file.
1/*****************************************************************************
2
3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4 more contributor license agreements. See the NOTICE file distributed
5 with this work for additional information regarding copyright ownership.
6 Accellera licenses this file to you under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with the
8 License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15 implied. See the License for the specific language governing
16 permissions and limitations under the License.
17
18 *****************************************************************************/
19
20/*****************************************************************************
21
22 sc_bigint.h -- Template version of arbitrary length integer. This class
23 enables compile-time bit widths for sc_signed numbers.
24
25 Original Author: Ali Dasdan, Synopsys, Inc.
26
27 *****************************************************************************/
28
29/*****************************************************************************
30
31 MODIFICATION LOG - modifiers, enter your name, affiliation, date and
32 changes you are making here.
33
34 Name, Affiliation, Date: Gene Bushayev, Synopsys, Inc.
35 Description of Modification: - Interface between sc_bigint and sc_bv/sc_lv.
36
37 Name, Affiliation, Date:
38 Description of Modification:
39
40 *****************************************************************************/
41
42// $Log: sc_bigint.h,v $
43// Revision 1.2 2011/02/18 20:19:14 acg
44// Andy Goodrich: updating Copyright notice.
45//
46// Revision 1.1.1.1 2006/12/15 20:20:05 acg
47// SystemC 2.3
48//
49// Revision 1.3 2006/01/13 18:49:31 acg
50// Added $Log command so that CVS check in comments are reproduced in the
51// source.
52//
53
54#ifndef SC_BIGINT_H
55#define SC_BIGINT_H
56
57
60
61namespace sc_dt
62{
63
64// classes defined in this module
65template <int W> class sc_bigint;
66
67// forward class declarations
68class sc_bv_base;
69class sc_lv_base;
70class sc_fxval;
71class sc_fxval_fast;
72class sc_fxnum;
73class sc_fxnum_fast;
74template <int W> class sc_biguint;
75
76
77// ----------------------------------------------------------------------------
78// CLASS TEMPLATE : sc_bigint<W>
79//
80// Arbitrary size signed integer type.
81// ----------------------------------------------------------------------------
82
83template< int W >
85#if !defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_NO_BASE_CLASS)
86 : public sc_signed
87#endif
88{
89public: // anonymous compile-type information about this type.
90 enum {
91 ACTUAL_WIDTH = W, // actual width.
92 DIGITS_N = SC_DIGIT_COUNT(W), // number of digits in digit vector.
93 HOB = SC_BIT_INDEX(W-1), // bit index of high order bit.
94 HOD = SC_DIGIT_INDEX(W-1), // digit index of high order bit.
95 SIGNED = 1, // this type is signed.
96 WIDTH = W // width as an enum.
97 };
98 typedef int HOD_TYPE; // type of high order sc_digit.
99
100public:
101
102 // constructors
103
105 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
107 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
108 : sc_signed( W, false )
109 #endif
110 { *this = 0; }
111
112 sc_bigint(int, int)
113 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
115 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
116 : sc_signed( W, false )
117 #endif
118 { }
119
120 inline sc_bigint( const sc_bigint<W>& v )
121 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
123 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
124 : sc_signed( W, false )
125 #endif
126 { *this = v; }
127
128 template<int WO>
129 inline sc_bigint( const sc_bigint<WO>& v )
130 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
132 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
133 : sc_signed( W, false )
134 #endif
135 { *this = v; }
136
137 template<int WO>
138 inline sc_bigint( const sc_biguint<WO>& v )
139 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
141 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
142 : sc_signed( W, false )
143 #endif
144 { *this = v; }
145
146 sc_bigint( const sc_signed& v )
147 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
149 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
150 : sc_signed( W, false )
151 #endif
152 { *this = v; }
153
155 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
157 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
158 : sc_signed( W, false )
159 #endif
160 { *this = v; }
161
162 template< class T >
164 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
166 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
167 : sc_signed( W, false )
168 #endif
169 { a->to_sc_signed(*this); }
170
172 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
174 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
175 : sc_signed( W, false )
176 #endif
177 { *this = v; }
178
180 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
182 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
183 : sc_signed( W, false )
184 #endif
185 { *this = v; }
186
187 sc_bigint( const char* v )
188 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
190 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
191 : sc_signed( W, false )
192 #endif
193 { *this = v; }
194
196 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
198 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
199 : sc_signed( W, false )
200 #endif
201 { *this = v; }
202
204 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
206 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
207 : sc_signed( W, false )
208 #endif
209 { *this = v; }
210
211 sc_bigint( long v )
212 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
214 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
215 : sc_signed( W, false )
216 #endif
217 { *this = v; }
218
219 sc_bigint( unsigned long v )
220 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
222 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
223 : sc_signed( W, false )
224 #endif
225 { *this = v; }
226
227 sc_bigint( int v )
228 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
230 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
231 : sc_signed( W, false )
232 #endif
233 { *this = v; }
234
235 sc_bigint( unsigned int v )
236 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
238 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
239 : sc_signed( W, false )
240 #endif
241 { *this = v; }
242
243 sc_bigint( double v )
244 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
246 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
247 : sc_signed( W, false )
248 #endif
249 { *this = v; }
250
252 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
254 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
255 : sc_signed( W, false )
256 #endif
257 { *this = v; }
258
260 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
262 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
263 : sc_signed( W, false )
264 #endif
265 { *this = v; }
266
267#ifdef SC_INCLUDE_FX
268
269 explicit sc_bigint( const sc_fxval& v )
270 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
272 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
273 : sc_signed( W, false )
274 #endif
275 { *this = v; }
276
277 explicit sc_bigint( const sc_fxval_fast& v )
278 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
280 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
281 : sc_signed( W, false )
282 #endif
283 { *this = v; }
284
285 explicit sc_bigint( const sc_fxnum& v )
286 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
288 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
289 : sc_signed( W, false )
290 #endif
291 { *this = v; }
292
293 explicit sc_bigint( const sc_fxnum_fast& v )
294 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
296 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
297 : sc_signed( W, false )
298 #endif
299 { *this = v; }
300
301#endif
302
303
304
305 // destructor
306
308 {}
309
310 // unary operators:
311
312 inline const sc_bigint<W> operator - ();
313 inline const sc_bigint<W> operator ~ ();
314
315 // assignment operators
316
317 inline const sc_bigint<W>& operator = ( const sc_bigint<W>& other );
318
319 template<int WO>
320 inline const sc_bigint<W>& operator = ( const sc_bigint<WO>& other );
321
322 template<int WO>
323 inline const sc_bigint<W>& operator = ( const sc_biguint<WO>& other );
324
325 inline const sc_bigint<W>& operator = ( const sc_signed& v );
326
327 inline const sc_bigint<W>& operator = ( const sc_unsigned& v );
328
330 {
332 return * this;
333 }
334
335 template< class T >
337 { a->to_sc_signed(sc_signed_proxy()); return *this;}
338
339 inline const sc_bigint<W>& operator = ( const sc_unsigned_subref_r& v );
340
341 inline const sc_bigint<W>& operator = ( const char* v )
342 { sc_signed_proxy() = v; return *this; }
343
344 inline const sc_bigint<W>& operator = ( int64 v );
345
346 inline const sc_bigint<W>& operator = ( uint64 v );
347
348 inline const sc_bigint<W>& operator = ( long v );
349
350 inline const sc_bigint<W>& operator = ( unsigned long v );
351
352 inline const sc_bigint<W>& operator = ( int v );
353
354 inline const sc_bigint<W>& operator = ( unsigned int v );
355
356 inline const sc_bigint<W>& operator = ( double v )
357 { sc_signed_proxy() = v; return *this; }
358
359
361 { sc_signed_proxy() = v; return *this; }
362
364 { sc_signed_proxy() = v; return *this; }
365
366 inline const sc_bigint<W>& operator = ( const sc_int_base& v );
367
368 inline const sc_bigint<W>& operator = ( const sc_uint_base& v );
369
370#ifdef SC_INCLUDE_FX
371
372 const sc_bigint<W>& operator = ( const sc_fxval& v )
373 { sc_signed_proxy() = v; return *this; }
374
375 const sc_bigint<W>& operator = ( const sc_fxval_fast& v )
376 { sc_signed_proxy() = v; return *this; }
377
378 const sc_bigint<W>& operator = ( const sc_fxnum& v )
379 { sc_signed_proxy() = v; return *this; }
380
381 const sc_bigint<W>& operator = ( const sc_fxnum_fast& v )
382 { sc_signed_proxy() = v; return *this; }
383
384#endif
385
386// +----------------------------------------------------------------------------
387// |"sc_bigint<W>::to_XXXX"
388// |
389// | These functions return an object instance's value as the requested
390// | native C++ type.
391// |
392// | Notes:
393// | (1) These are set up for BITS_PER_DIGIT == 32.
394// | Result:
395// | Native C++ type containing the object instance's value.
396// +----------------------------------------------------------------------------
397inline
398double
400{
401 return sc_signed_proxy().to_double();
402}
403
404inline
405int
406to_int() const
407{
408 int result;
409
410 result = (int)digit[0];
411 return result;
412}
413
414inline
415unsigned int
416to_uint() const
417{
418 unsigned int result;
419
420 result = (unsigned int)digit[0];
421 return result;
422}
423
424inline
425int64
426to_int64() const
427{
428 int64 result;
429
430 if ( W < 33 ) {
431 result = to_int();
432 }
433 else {
434 result = ( (uint64)digit[1] << BITS_PER_DIGIT ) | digit[0];
435 }
436 return result;
437}
438
439inline
440uint64
442{
443 uint64 result;
444
445 if ( W < 33 ) {
446 result = to_int();
447 }
448 else {
449 result = to_int64(); // @@@@#### ( (uint64)digit[1] << BITS_PER_DIGIT ) | digit[0];
450 }
451 return result;
452}
453
454inline
455long
456to_long() const
457{
458 long result = ( sizeof(long) < 5 ) ? to_int() : to_int64();
459 return result;
460}
461
462
463inline
464unsigned long
465to_ulong() const
466{
467 unsigned long result = ( sizeof(unsigned long) < 5 ) ? to_uint() : to_uint64();
468 return result;
469}
470
471// SELF-REFERENCING OPERATORS:
472
473inline sc_bigint<W>& operator += (const sc_signed& v);
474inline sc_bigint<W>& operator += (const sc_unsigned& v);
477inline sc_bigint<W>& operator += (long v);
478inline sc_bigint<W>& operator += (unsigned long v);
479inline sc_bigint<W>& operator += (int v);
480inline sc_bigint<W>& operator += (unsigned int v);
481inline sc_bigint<W>& operator += (const sc_int_base& v);
482inline sc_bigint<W>& operator += (const sc_uint_base& v);
483
484inline sc_bigint<W>& operator -= (const sc_signed& v);
485inline sc_bigint<W>& operator -= (const sc_unsigned& v);
488inline sc_bigint<W>& operator -= (long v);
489inline sc_bigint<W>& operator -= (unsigned long v);
490inline sc_bigint<W>& operator -= (int v);
491inline sc_bigint<W>& operator -= (unsigned int v);
492inline sc_bigint<W>& operator -= (const sc_int_base& v);
493inline sc_bigint<W>& operator -= (const sc_uint_base& v);
494
495inline sc_bigint<W>& operator *= (const sc_signed& v);
496inline sc_bigint<W>& operator *= (const sc_unsigned& v);
499inline sc_bigint<W>& operator *= (long v);
500inline sc_bigint<W>& operator *= (unsigned long v);
501inline sc_bigint<W>& operator *= (int v);
502inline sc_bigint<W>& operator *= (unsigned int v);
503inline sc_bigint<W>& operator *= (const sc_int_base& v);
504inline sc_bigint<W>& operator *= (const sc_uint_base& v);
505
506inline sc_bigint<W>& operator /= (const sc_signed& v);
507inline sc_bigint<W>& operator /= (const sc_unsigned& v);
510inline sc_bigint<W>& operator /= (long v);
511inline sc_bigint<W>& operator /= (unsigned long v);
512inline sc_bigint<W>& operator /= (int v);
513inline sc_bigint<W>& operator /= (unsigned int v);
514inline sc_bigint<W>& operator /= (const sc_int_base& v);
515inline sc_bigint<W>& operator /= (const sc_uint_base& v);
516
517inline sc_bigint<W>& operator %= (const sc_signed& v);
518inline sc_bigint<W>& operator %= (const sc_unsigned& v);
521inline sc_bigint<W>& operator %= (long v);
522inline sc_bigint<W>& operator %= (unsigned long v);
523inline sc_bigint<W>& operator %= (int v);
524inline sc_bigint<W>& operator %= (unsigned int v);
525inline sc_bigint<W>& operator %= (const sc_int_base& v);
526inline sc_bigint<W>& operator %= (const sc_uint_base& v);
527
528inline sc_bigint<W>& operator &= (const sc_signed& v);
529inline sc_bigint<W>& operator &= (const sc_unsigned& v);
532inline sc_bigint<W>& operator &= (long v);
533inline sc_bigint<W>& operator &= (unsigned long v);
534inline sc_bigint<W>& operator &= (int v);
535inline sc_bigint<W>& operator &= (unsigned int v);
536inline sc_bigint<W>& operator &= (const sc_int_base& v);
537inline sc_bigint<W>& operator &= (const sc_uint_base& v);
538
539inline sc_bigint<W>& operator |= (const sc_signed& v);
540inline sc_bigint<W>& operator |= (const sc_unsigned& v);
543inline sc_bigint<W>& operator |= (long v);
544inline sc_bigint<W>& operator |= (unsigned long v);
545inline sc_bigint<W>& operator |= (int v);
546inline sc_bigint<W>& operator |= (unsigned int v);
547inline sc_bigint<W>& operator |= (const sc_int_base& v);
548inline sc_bigint<W>& operator |= (const sc_uint_base& v);
549
550inline sc_bigint<W>& operator ^= (const sc_signed& v);
551inline sc_bigint<W>& operator ^= (const sc_unsigned& v);
554inline sc_bigint<W>& operator ^= (long v);
555inline sc_bigint<W>& operator ^= (unsigned long v);
556inline sc_bigint<W>& operator ^= (int v);
557inline sc_bigint<W>& operator ^= (unsigned int v);
558inline sc_bigint<W>& operator ^= (const sc_int_base& v);
559inline sc_bigint<W>& operator ^= (const sc_uint_base& v);
560
561// Range operators:
562
563sc_signed_bitref& bit( int i ) { return sc_signed_proxy().bit(i); }
564const sc_signed_bitref_r& bit( int i ) const { return sc_signed_proxy().bit(i); }
565sc_signed_bitref& operator [] ( int i ) { return bit(i); }
566const sc_signed_bitref_r& operator [] ( int i ) const { return bit(i); }
567
568sc_signed_subref& range( int i, int j ) { return sc_signed_proxy().range(i,j); }
569const sc_signed_subref_r& range( int i, int j ) const { return sc_signed_proxy().range(i,j); }
570sc_signed_subref& operator () ( int i, int j ) { return range(i,j); }
571const sc_signed_subref_r& operator () ( int i, int j ) const { return range(i,j); }
572
573// reduce methods
574
575inline bool and_reduce() const;
576inline bool nand_reduce() const;
577inline bool or_reduce() const;
578inline bool nor_reduce() const;
579inline bool xor_reduce() const ;
580inline bool xnor_reduce() const;
581
582// left shift operators
583
584const sc_signed operator<<(int v) const;
585const sc_signed operator<<(const sc_signed& v) const { return operator << (v.to_int()); }
586const sc_signed operator<<(const sc_unsigned& v) const { return operator << (v.to_int()); }
587
588const sc_bigint<W>& operator<<=(int v);
589const sc_bigint<W>& operator<<=(const sc_unsigned& v) { return operator<<=( v.to_int() ); }
590const sc_bigint<W>& operator<<=(const sc_signed& v) { return operator<<= ( v.to_int() ); }
591
592// right shift operators
593
594const sc_signed operator>>(int v) const;
595const sc_signed operator>>(const sc_signed& v) const { return operator >> (v.to_int()); }
596const sc_signed operator>>(const sc_unsigned& v) const { return operator>>(v.to_int()); }
597
598const sc_bigint<W>& operator>>=(int v);
599const sc_bigint<W>& operator>>=(const sc_unsigned& v) { return operator>>= (v.to_int() ); }
600const sc_bigint<W>& operator>>=(const sc_signed& v) { return operator>>=( v.to_int() ); }
601
602// Increment operators:
603
604inline sc_bigint<W>& operator ++ () // prefix
605{
606 *this = *this + 1;
607 return *this;
608}
609
610inline sc_bigint<W> operator ++ (int) // postfix
611{
612 sc_bigint<W> result(*this);
613 *this = *this + 1;
614 return result;
615}
616
617// Decrement operators:
618
619inline sc_bigint<W>& operator -- () // prefix
620{
621 *this = *this - 1;
622 return *this;
623}
624
625inline sc_bigint<W> operator -- (int) // postfix
626{
627 sc_bigint<W> result(*this);
628 *this = *this - 1;
629 return result;
630}
631
632#if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
633protected:
634 // If the number of digits is sufficient to fit in sc_signed::base_vec then just allocate
635 // a single word here to save storage. Otherwise we allocate enough storage to accomodate
636 // our value.
638#elif defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_NO_BASE_CLASS)
639public:
641#endif
642
643public:
644 inline void adjust_hod()
645 {
646 const int shift = (BITS_PER_DIGIT-1)-SC_BIT_INDEX(W-1);
647 unsigned long long tmp = (std::make_signed<sc_digit>::type) (digit[HOD] << shift);
648 digit[HOD] = (sc_digit)(tmp >> shift) ;
649 }
650
651public:
652#if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_NO_BASE_CLASS)
653 inline sc_signed& sc_signed_proxy()
654 {
655 sc_dt::sc_signed& result = sc_signed::allocate_temporary(W,(sc_digit*)digit);
656 return result;
657 }
658
659 inline const sc_signed& sc_signed_proxy() const
660 {
661 const sc_dt::sc_signed& result = sc_signed::allocate_temporary(W,(sc_digit*)digit);
662 return result;
663 }
664
665 inline operator sc_dt::sc_signed& ()
666 {
667 return sc_signed_proxy();
668 }
669
670 inline operator const sc_dt::sc_signed& () const
671 {
672 return sc_signed_proxy();
673 }
674#else
675
677 {
678 return *this;
679 }
680
681 inline const sc_signed& sc_signed_proxy() const
682 {
683 return *this;
684 }
685
686
687#endif // SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_NO_BASE_CLASS
688
689public: // explicit conversion to character string:
690
691 const std::string to_string( sc_numrep numrep = SC_DEC ) const {
692 return sc_signed_proxy().to_string( numrep );
693 }
694
695 const std::string to_string( sc_numrep numrep, bool w_prefix ) const {
696 return sc_signed_proxy().to_string( numrep, w_prefix );
697 }
698
699#if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_NO_BASE_CLASS)
700public: // "mirror" for sc_value_base concatenation support:
701 int concat_length(bool xzp) const { return W; }
702#endif // SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_NO_BASE_CLASS
703
704public: // field and template value accesses:
705 inline int get_actual_length() const { return W; }
706 inline const sc_digit* get_digits() const { return digit; }
707 inline sc_digit* get_digits() { return digit; }
708 inline int get_digits_n() const { return DIV_CEIL(W); }
709 inline int get_hod() const { return SC_DIGIT_INDEX(W-1); }
710 inline sc_digit* get_raw() { return digit; }
711
712 inline int length() const { return W; }
713
714};
715
716} // namespace sc_dt
717
718#endif
#define SC_DIGIT_INDEX(BIT_INDEX)
Definition: sc_nbdefs.h:186
#define DIV_CEIL(x)
Definition: sc_nbdefs.h:212
#define SC_BIT_INDEX(BIT)
Definition: sc_nbdefs.h:185
#define SC_DIGIT_COUNT(BIT_WIDTH)
Definition: sc_nbdefs.h:188
#define BITS_PER_DIGIT
Definition: sc_nbdefs.h:164
#define SC_BASE_VEC_DIGITS
Definition: sc_nbdefs.h:127
sc_numrep
Definition: sc_string.h:56
@ SC_DEC
Definition: sc_string.h:60
unsigned long long uint64
Definition: sc_nbdefs.h:216
unsigned int sc_digit
Definition: sc_nbdefs.h:161
long long int64
Definition: sc_nbdefs.h:215
const sc_bigint< W > & operator>>=(int v)
unsigned int to_uint() const
Definition: sc_bigint.h:416
double to_double() const
Definition: sc_bigint.h:399
const sc_signed operator<<(const sc_unsigned &v) const
Definition: sc_bigint.h:586
const sc_signed & sc_signed_proxy() const
Definition: sc_bigint.h:681
const sc_bigint< W > & operator<<=(const sc_signed &v)
Definition: sc_bigint.h:590
const sc_signed operator>>(int v) const
sc_digit * get_digits()
Definition: sc_bigint.h:707
sc_bigint(const sc_signed_subref &v)
Definition: sc_bigint.h:154
sc_bigint(const sc_bv_base &v)
Definition: sc_bigint.h:251
sc_bigint(const sc_bigint< WO > &v)
Definition: sc_bigint.h:129
bool or_reduce() const
sc_signed_bitref & operator[](int i)
Definition: sc_bigint.h:565
int to_int() const
Definition: sc_bigint.h:406
sc_bigint< W > & operator*=(const sc_signed &v)
const sc_bigint< W > & operator=(const sc_signed_subref_r &v)
Definition: sc_bigint.h:329
bool nor_reduce() const
sc_digit * get_raw()
Definition: sc_bigint.h:710
uint64 to_uint64() const
Definition: sc_bigint.h:441
sc_bigint< W > & operator|=(const sc_signed &v)
sc_bigint(unsigned long v)
Definition: sc_bigint.h:219
const sc_bigint< W > & operator>>=(const sc_unsigned &v)
Definition: sc_bigint.h:599
const sc_digit * get_digits() const
Definition: sc_bigint.h:706
const std::string to_string(sc_numrep numrep, bool w_prefix) const
Definition: sc_bigint.h:695
bool xnor_reduce() const
bool nand_reduce() const
sc_bigint< W > & operator+=(const sc_signed &v)
sc_bigint(uint64 v)
Definition: sc_bigint.h:203
sc_bigint(double v)
Definition: sc_bigint.h:243
const sc_signed operator>>(const sc_signed &v) const
Definition: sc_bigint.h:595
const sc_signed_bitref_r & bit(int i) const
Definition: sc_bigint.h:564
sc_signed_subref & range(int i, int j)
Definition: sc_bigint.h:568
const sc_bigint< W > operator-()
sc_digit compile_time_digits[DIV_CEIL(W)>SC_BASE_VEC_DIGITS?DIV_CEIL(W):1]
Definition: sc_bigint.h:637
const sc_signed_subref_r & range(int i, int j) const
Definition: sc_bigint.h:569
bool xor_reduce() const
sc_bigint< W > & operator++()
Definition: sc_bigint.h:604
const sc_signed operator<<(const sc_signed &v) const
Definition: sc_bigint.h:585
void adjust_hod()
Definition: sc_bigint.h:644
sc_bigint(const sc_lv_base &v)
Definition: sc_bigint.h:259
int get_hod() const
Definition: sc_bigint.h:709
bool and_reduce() const
sc_signed_subref & operator()(int i, int j)
Definition: sc_bigint.h:570
const sc_signed operator>>(const sc_unsigned &v) const
Definition: sc_bigint.h:596
sc_bigint(const sc_unsigned &v)
Definition: sc_bigint.h:171
sc_bigint(const sc_signed &v)
Definition: sc_bigint.h:146
const sc_bigint< W > & operator<<=(int v)
sc_bigint< W > & operator%=(const sc_signed &v)
sc_bigint(const sc_generic_base< T > &a)
Definition: sc_bigint.h:163
sc_bigint(unsigned int v)
Definition: sc_bigint.h:235
unsigned long to_ulong() const
Definition: sc_bigint.h:465
int64 to_int64() const
Definition: sc_bigint.h:426
int length() const
Definition: sc_bigint.h:712
const sc_bigint< W > operator~()
const sc_bigint< W > & operator>>=(const sc_signed &v)
Definition: sc_bigint.h:600
sc_bigint< W > & operator/=(const sc_signed &v)
sc_signed & sc_signed_proxy()
Definition: sc_bigint.h:676
const std::string to_string(sc_numrep numrep=SC_DEC) const
Definition: sc_bigint.h:691
const sc_bigint< W > & operator=(const sc_bigint< W > &other)
int get_actual_length() const
Definition: sc_bigint.h:705
sc_bigint< W > & operator&=(const sc_signed &v)
sc_bigint< W > & operator--()
Definition: sc_bigint.h:619
sc_bigint< W > & operator-=(const sc_signed &v)
sc_bigint(const sc_bigint< W > &v)
Definition: sc_bigint.h:120
int get_digits_n() const
Definition: sc_bigint.h:708
sc_bigint(int64 v)
Definition: sc_bigint.h:195
sc_bigint(long v)
Definition: sc_bigint.h:211
sc_bigint(int, int)
Definition: sc_bigint.h:112
sc_signed_bitref & bit(int i)
Definition: sc_bigint.h:563
sc_bigint(const char *v)
Definition: sc_bigint.h:187
sc_bigint< W > & operator^=(const sc_signed &v)
sc_bigint(int v)
Definition: sc_bigint.h:227
sc_bigint(const sc_biguint< WO > &v)
Definition: sc_bigint.h:138
sc_bigint(const sc_unsigned_subref &v)
Definition: sc_bigint.h:179
const sc_bigint< W > & operator<<=(const sc_unsigned &v)
Definition: sc_bigint.h:589
long to_long() const
Definition: sc_bigint.h:456
const sc_signed operator<<(int v) const
double to_double() const
sc_signed_subref & range(int i, int j)
Definition: sc_signed.h:737
sc_digit * digit
Definition: sc_signed.h:1152
int to_int() const
Definition: sc_signed.h:1497
virtual int concat_length(bool *xz_present_p) const
Definition: sc_signed.h:640
friend class sc_unsigned
Definition: sc_signed.h:558
const std::string to_string(sc_numrep numrep=SC_DEC) const
sc_signed(int nb=sc_length_param().len())
Definition: sc_signed.h:1626
sc_signed_bitref & bit(int i)
Definition: sc_signed.h:691
int to_int() const
Definition: sc_unsigned.h:1582