SystemC 3.0.0
Accellera SystemC proof-of-concept library
sc_biguint.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_biguint.h -- Template version of sc_unsigned. This class
23 enables compile-time bit widths for sc_unsigned 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_biguint.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_BIGUINT_H
55#define SC_BIGUINT_H
56
57
60
61namespace sc_dt
62{
63
64// classes defined in this module
65template <int W> class sc_biguint;
66
67// classes referenced by this module
68template <int W> class sc_bigint;
69
70// forward class declarations
71class sc_bv_base;
72class sc_lv_base;
73class sc_fxval;
74class sc_fxval_fast;
75class sc_fxnum;
76class sc_fxnum_fast;
77
78
79// ----------------------------------------------------------------------------
80// CLASS TEMPLATE : sc_biguint<W>
81//
82// Arbitrary size unsigned integer type.
83// ----------------------------------------------------------------------------
84
85template< int W >
87#if !defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_NO_BASE_CLASS)
88 : public sc_unsigned
89#endif // SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_NO_BASE_CLASS
90{
91public: // anonymous compile-type information about this type.
92 enum {
93 ACTUAL_WIDTH = W+1, // actual width.
94 DIGITS_N = SC_DIGIT_COUNT(W+1), // number of digits in digit vector.
95 HOB = SC_BIT_INDEX(W), // bit index of high order bit.
96 HOD = SC_DIGIT_INDEX(W), // digit index of high order bit.
97 SIGNED = 0, // this type is unsigned.
98 WIDTH = W // width as an enum.
99 };
100 typedef int HOD_TYPE; // type of high order sc_digit.
101
102public:
103
104 // constructors
105
107 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
109 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
110 : sc_unsigned( W, false )
111 #endif
112 { *this = 0; }
113
114 sc_biguint(int, int)
115 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
117 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
118 : sc_unsigned( W, false )
119 #endif
120 { }
121
122 sc_biguint( bool flag )
123 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
125 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
126 : sc_unsigned( W, false )
127 #endif
128 { *this = (int)flag; }
129
131 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
133 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
134 : sc_unsigned( W, false )
135 #endif
136 { *this = v; }
137
138 template<int WO>
140 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
142 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
143 : sc_unsigned( W, false )
144 #endif
145 { *this = v; }
146
147 template<int WO>
149 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
151 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
152 : sc_unsigned( W, false )
153 #endif
154 { *this = v; }
155
157 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
159 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
160 : sc_unsigned( W, false )
161 #endif
162 { *this = v; }
163
165 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
167 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
168 : sc_unsigned( W, false )
169 #endif
170 { *this = v; }
171
172 template< class T >
174 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
176 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
177 : sc_unsigned( W, false )
178 #endif
179 { a->to_sc_unsigned(*this); }
180
182 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
184 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
185 : sc_unsigned( W, false )
186 #endif
187 { *this = v; }
188
190 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
192 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
193 : sc_unsigned( W, false )
194 #endif
195 { *this = v; }
196
197 sc_biguint( const char* v )
198 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
200 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
201 : sc_unsigned( W, false )
202 #endif
203 { *this = v; }
204
206 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
208 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
209 : sc_unsigned( W, false )
210 #endif
211 { *this = v; }
212
214 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
216 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
217 : sc_unsigned( W, false )
218 #endif
219 { *this = v; }
220
221 sc_biguint( long v )
222 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
224 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
225 : sc_unsigned( W, false )
226 #endif
227 { *this = v; }
228
229 sc_biguint( unsigned long v )
230 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
232 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
233 : sc_unsigned( W, false )
234 #endif
235 { *this = v; }
236
237 sc_biguint( int v )
238 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
240 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
241 : sc_unsigned( W, false )
242 #endif
243 { *this = v; }
244
245 sc_biguint( unsigned int v )
246 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
248 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
249 : sc_unsigned( W, false )
250 #endif
251 { *this = v; }
252
253 sc_biguint( double v )
254 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
256 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
257 : sc_unsigned( W, false )
258 #endif
259 { *this = v; }
260
262 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
264 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
265 : sc_unsigned( W, false )
266 #endif
267 { *this = v; }
268
270 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
272 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
273 : sc_unsigned( W, false )
274 #endif
275 { *this = v; }
276
277#ifdef SC_INCLUDE_FX
278
279 explicit sc_biguint( const sc_fxval& v )
280 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
282 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
283 : sc_unsigned( W, false )
284 #endif
285 { *this = v; }
286
287 explicit sc_biguint( const sc_fxval_fast& v )
288 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
290 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
291 : sc_unsigned( W, false )
292 #endif
293 { *this = v; }
294
295 explicit sc_biguint( const sc_fxnum& v )
296 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
298 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
299 : sc_unsigned( W, false )
300 #endif
301 { *this = v; }
302
303 explicit sc_biguint( const sc_fxnum_fast& v )
304 #if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
306 #elif defined(SC_BIGINT_CONFIG_BASE_CLASS_HAS_STORAGE)
307 : sc_unsigned( W, false )
308 #endif
309 { *this = v; }
310
311#endif
312
313
314 // destructor
315
317 {}
318
319 // unary operators:
320
321 inline const sc_bigint<W+1> operator - ();
322 inline const sc_bigint<W+1> operator ~ ();
323
324
325 // assignment operators
326
327 const sc_biguint<W>& operator = ( const sc_biguint<W>& v );
328
329 template<int WO>
330 const sc_biguint<W>& operator = ( const sc_biguint<WO>& v );
331
332 template<int WO>
333 const sc_biguint<W>& operator = ( const sc_bigint<WO>& v );
334
335 const sc_biguint<W>& operator = ( const sc_unsigned& v );
336
338 { sc_unsigned_proxy() = ( v ); return *this; }
339
340 template< class T >
342 { a->to_sc_unsigned(*this); return *this; }
343
344 const sc_biguint<W>& operator = ( const sc_signed& v );
345
347 { sc_unsigned_proxy() = ( v ); return *this; }
348
349 const sc_biguint<W>& operator = ( const char* v )
350 { sc_unsigned_proxy() = ( v ); return *this; }
351
352 const sc_biguint<W>& operator = ( int64 v ) ;
353
354 const sc_biguint<W>& operator = ( uint64 v ) ;
355
356 const sc_biguint<W>& operator = ( long v ) ;
357
358 const sc_biguint<W>& operator = ( unsigned long v ) ;
359
360 const sc_biguint<W>& operator = ( int v ) ;
361
362 const sc_biguint<W>& operator = ( unsigned int v ) ;
363
364 const sc_biguint<W>& operator = ( double v )
365 { sc_unsigned_proxy() = ( v ); return *this; }
366
367
369 { sc_unsigned_proxy() = ( v ); return *this; }
370
372 { sc_unsigned_proxy() = ( v ); return *this; }
373
374 const sc_biguint<W>& operator = ( const sc_int_base& v ) ;
375
376 const sc_biguint<W>& operator = ( const sc_uint_base& v ) ;
377
378#ifdef SC_INCLUDE_FX
379
380 const sc_biguint<W>& operator = ( const sc_fxval& v )
381 { sc_unsigned_proxy() = ( v ); return *this; }
382
383 const sc_biguint<W>& operator = ( const sc_fxval_fast& v )
384 { sc_unsigned_proxy() = ( v ); return *this; }
385
386 const sc_biguint<W>& operator = ( const sc_fxnum& v )
387 { sc_unsigned_proxy() = ( v ); return *this; }
388
389 const sc_biguint<W>& operator = ( const sc_fxnum_fast& v )
390 { sc_unsigned_proxy() = ( v ); return *this; }
391
392#endif
393
394// +----------------------------------------------------------------------------
395// |"sc_bigint<W>::to_XXXX"
396// |
397// | These functions return an object instance's value as the requested
398// | native C++ type.
399// |
400// | Notes:
401// | (1) These are set up for BITS_PER_DIGIT == 32.
402// | Result:
403// | Native C++ type containing the object instance's value.
404// +----------------------------------------------------------------------------
405inline
406double
408{
409 return sc_unsigned_proxy().to_double();
410}
411
412inline
413int
414to_int() const
415{
416 int result;
417
418 result = (int)digit[0];
419 return result;
420}
421
422inline
423unsigned int
424to_uint() const
425{
426 unsigned int result;
427
428 result = (unsigned int)digit[0];
429 if ( W < 32 ) { result &= ~((~0u)<<W); }
430 return result;
431}
432
433inline
434int64
435to_int64() const
436{
437 int64 result;
438
439 if ( W < 33 ) {
440 result = to_int();
441 }
442 else {
443 result = ( (int64)digit[1] << BITS_PER_DIGIT ) | digit[0];
444 }
445 return result;
446}
447
448inline
449uint64
451{
452 uint64 result;
453
454 if ( W < 33 ) {
455 result = to_uint();
456 }
457 else {
458 result = ( (uint64)digit[1] << BITS_PER_DIGIT ) | digit[0];
459 if ( W < 64 ) { result &= ~(~UINT64_ZERO << W); }
460 }
461 return result;
462}
463
464inline
465long
466to_long() const
467{
468 long result = ( sizeof(long) < 5 ) ? to_int() : to_int64();
469 return result;
470}
471
472
473inline
474unsigned long
475to_ulong() const
476{
477 unsigned long result = ( sizeof(unsigned long) < 5 ) ? to_uint() : to_uint64();
478 return result;
479}
480
481// SELF-REFERENCING OPERATORS:
482
483inline const sc_biguint<W>& operator += (const sc_signed& v);
484inline const sc_biguint<W>& operator += (const sc_unsigned& v);
485inline const sc_biguint<W>& operator += (int64 v);
486inline const sc_biguint<W>& operator += (uint64 v);
487inline const sc_biguint<W>& operator += (long v);
488inline const sc_biguint<W>& operator += (unsigned long v);
489inline const sc_biguint<W>& operator += (int v);
490inline const sc_biguint<W>& operator += (unsigned int v);
491inline const sc_biguint<W>& operator += (const sc_int_base& v);
492inline const sc_biguint<W>& operator += (const sc_uint_base& v);
493
494inline const sc_biguint<W>& operator -= (const sc_signed& v);
495inline const sc_biguint<W>& operator -= (const sc_unsigned& v);
496inline const sc_biguint<W>& operator -= (int64 v);
497inline const sc_biguint<W>& operator -= (uint64 v);
498inline const sc_biguint<W>& operator -= (long v);
499inline const sc_biguint<W>& operator -= (unsigned long v);
500inline const sc_biguint<W>& operator -= (int v);
501inline const sc_biguint<W>& operator -= (unsigned int v);
502inline const sc_biguint<W>& operator -= (const sc_int_base& v);
503inline const sc_biguint<W>& operator -= (const sc_uint_base& v);
504
505inline const sc_biguint<W>& operator *= (const sc_signed& v);
506inline const sc_biguint<W>& operator *= (const sc_unsigned& v);
507inline const sc_biguint<W>& operator *= (int64 v);
508inline const sc_biguint<W>& operator *= (uint64 v);
509inline const sc_biguint<W>& operator *= (long v);
510inline const sc_biguint<W>& operator *= (unsigned long v);
511inline const sc_biguint<W>& operator *= (int v);
512inline const sc_biguint<W>& operator *= (unsigned int v);
513inline const sc_biguint<W>& operator *= (const sc_int_base& v);
514inline const sc_biguint<W>& operator *= (const sc_uint_base& v);
515
516inline const sc_biguint<W>& operator /= (const sc_signed& v);
517inline const sc_biguint<W>& operator /= (const sc_unsigned& v);
518inline const sc_biguint<W>& operator /= (int64 v);
519inline const sc_biguint<W>& operator /= (uint64 v);
520inline const sc_biguint<W>& operator /= (long v);
521inline const sc_biguint<W>& operator /= (unsigned long v);
522inline const sc_biguint<W>& operator /= (int v);
523inline const sc_biguint<W>& operator /= (unsigned int v);
524inline const sc_biguint<W>& operator /= (const sc_int_base& v);
525inline const sc_biguint<W>& operator /= (const sc_uint_base& v);
526
527inline const sc_biguint<W>& operator %= (const sc_signed& v);
528inline const sc_biguint<W>& operator %= (const sc_unsigned& v);
529inline const sc_biguint<W>& operator %= (int64 v);
530inline const sc_biguint<W>& operator %= (uint64 v);
531inline const sc_biguint<W>& operator %= (long v);
532inline const sc_biguint<W>& operator %= (unsigned long v);
533inline const sc_biguint<W>& operator %= (int v);
534inline const sc_biguint<W>& operator %= (unsigned int v);
535inline const sc_biguint<W>& operator %= (const sc_int_base& v);
536inline const sc_biguint<W>& operator %= (const sc_uint_base& v);
537
538inline const sc_biguint<W>& operator &= (const sc_signed& v);
539inline const sc_biguint<W>& operator &= (const sc_unsigned& v);
540inline const sc_biguint<W>& operator &= (int64 v);
541inline const sc_biguint<W>& operator &= (uint64 v);
542inline const sc_biguint<W>& operator &= (long v);
543inline const sc_biguint<W>& operator &= (unsigned long v);
544inline const sc_biguint<W>& operator &= (int v);
545inline const sc_biguint<W>& operator &= (unsigned int v);
546inline const sc_biguint<W>& operator &= (const sc_int_base& v);
547inline const sc_biguint<W>& operator &= (const sc_uint_base& v);
548
549inline const sc_biguint<W>& operator |= (const sc_signed& v);
550inline const sc_biguint<W>& operator |= (const sc_unsigned& v);
551inline const sc_biguint<W>& operator |= (int64 v);
552inline const sc_biguint<W>& operator |= (uint64 v);
553inline const sc_biguint<W>& operator |= (long v);
554inline const sc_biguint<W>& operator |= (unsigned long v);
555inline const sc_biguint<W>& operator |= (int v);
556inline const sc_biguint<W>& operator |= (unsigned int v);
557inline const sc_biguint<W>& operator |= (const sc_int_base& v);
558inline const sc_biguint<W>& operator |= (const sc_uint_base& v);
559
560inline const sc_biguint<W>& operator ^= (const sc_signed& v);
561inline const sc_biguint<W>& operator ^= (const sc_unsigned& v);
562inline const sc_biguint<W>& operator ^= (int64 v);
563inline const sc_biguint<W>& operator ^= (uint64 v);
564inline const sc_biguint<W>& operator ^= (long v);
565inline const sc_biguint<W>& operator ^= (unsigned long v);
566inline const sc_biguint<W>& operator ^= (int v);
567inline const sc_biguint<W>& operator ^= (unsigned int v);
568inline const sc_biguint<W>& operator ^= (const sc_int_base& v);
569inline const sc_biguint<W>& operator ^= (const sc_uint_base& v);
570
571// Left shift operators:
572
573const sc_unsigned operator<<(int v) const;
574const sc_unsigned operator<<(const sc_signed& v) const { return operator << (v.to_int()); }
575const sc_unsigned operator<<(const sc_unsigned& v) const { return operator << (v.to_int()); }
576
577const sc_biguint<W>& operator<<=(int v);
578const sc_biguint<W>& operator<<=(const sc_unsigned& v) { return operator <<=( v.to_int() ); }
579const sc_biguint<W>& operator<<=(const sc_signed& v) { return operator <<=( v.to_int() ); }
580
581// Right shift operators:
582
583const sc_unsigned operator>>(int v) const;
584const sc_unsigned operator>>(const sc_signed& v) const { return operator >> (v.to_int()); }
585const sc_unsigned operator>>(const sc_unsigned& v) const { return operator >> (v.to_int()); }
586
587const sc_biguint<W>& operator>>=(int v);
588const sc_biguint<W>& operator>>=(const sc_unsigned& v) { return operator >>=( v.to_int() ); }
589const sc_biguint<W>& operator>>=(const sc_signed& v) { return operator >>=( v.to_int() ); }
590
591// Range operators:
592
593sc_unsigned_bitref& bit( int i ) { return sc_unsigned_proxy().bit(i); }
594const sc_unsigned_bitref_r& bit( int i ) const { return sc_unsigned_proxy().bit(i); }
595sc_unsigned_bitref& operator [] ( int i ) { return bit(i); }
596const sc_unsigned_bitref_r& operator [] ( int i ) const { return bit(i); }
597
598sc_unsigned_subref& range( int i, int j ) { return sc_unsigned_proxy().range(i,j); }
599const sc_unsigned_subref_r& range( int i, int j ) const { return sc_unsigned_proxy().range(i,j); }
600sc_unsigned_subref& operator () ( int i, int j ) { return range(i,j); }
601const sc_unsigned_subref_r& operator () ( int i, int j ) const { return range(i,j); }
602
603// reduce methods
604
605inline bool and_reduce() const;
606inline bool nand_reduce() const;
607inline bool or_reduce() const;
608inline bool nor_reduce() const;
609inline bool xor_reduce() const ;
610inline bool xnor_reduce() const;
611
612// Increment operators:
613
614inline sc_biguint<W>& operator ++ () // prefix
615{
616 *this = *this + 1;
617 return *this;
618}
619
620inline sc_biguint<W> operator ++ (int) // postfix
621{
622 sc_biguint<W> result(*this);
623 *this = *this + 1;
624 return result;
625}
626
627// Decrement operators:
628
629inline sc_biguint<W>& operator -- () // prefix
630{
631 *this = *this - 1;
632 return *this;
633}
634
635inline sc_biguint<W> operator -- (int) // postfix
636{
637 sc_biguint<W> result(*this);
638 *this = *this - 1;
639 return result;
640}
641
642public:
643#if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_STORAGE)
644 // If the number of digits is sufficient to fit in sc_signed::base_vec then just allocate
645 // a single word here to save storage. Otherwise we allocate enough storage to accomodate
646 // our value.
648#elif defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_NO_BASE_CLASS)
649 sc_digit digit[DIV_CEIL(W+1)];
650#endif // SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_NO_BASE_CLASS
651
652public:
654 {
655 digit[HOD] &= ~(~0U << SC_BIT_INDEX(W));
656 }
657
658#if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_NO_BASE_CLASS)
660 {
661 sc_dt::sc_unsigned& result = sc_unsigned::allocate_temporary(W,(sc_digit*)digit);
662 return result;
663 }
664
665 inline const sc_unsigned& sc_unsigned_proxy() const
666 {
667 const sc_dt::sc_unsigned& result = sc_unsigned::allocate_temporary(W,(sc_digit*)digit);
668 return result;
669 }
670
671 inline operator sc_dt::sc_unsigned& ()
672 {
673 return sc_unsigned_proxy();
674 }
675
676 inline operator const sc_dt::sc_unsigned& () const
677 {
678 return sc_unsigned_proxy();
679 }
680#else
681
683 {
684 return *this;
685 }
686
687 inline const sc_unsigned& sc_unsigned_proxy() const
688 {
689 return *this;
690 }
691
692#endif // SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_NO_BASE_CLASS
693
694 // explicit conversion to character string:
695
696 const std::string to_string( sc_numrep numrep = SC_DEC ) const {
697 return sc_unsigned_proxy().to_string( numrep );
698 }
699
700 const std::string to_string( sc_numrep numrep, bool w_prefix ) const {
701 return sc_unsigned_proxy().to_string( numrep, w_prefix );
702 }
703
704#if defined(SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_NO_BASE_CLASS)
705public: // "mirror" for sc_value_base concatenation support:
706 int concat_length(bool xzp) const { return W; }
707#endif // SC_BIGINT_CONFIG_TEMPLATE_CLASS_HAS_NO_BASE_CLASS
708
709public: // field and template value accesses:
710
711 inline int get_actual_length() const { return W+1; }
712 inline const sc_digit* get_digits() const { return digit; }
713 inline sc_digit* get_digits() { return digit; }
714 inline int get_digits_n() const { return DIV_CEIL(W+1); }
715 inline int get_hod() const { return SC_DIGIT_INDEX(W); }
716 inline sc_digit* get_raw() { return digit; }
717 inline sc_digit* get_raw() const { return (sc_digit*)digit; }
718
719 inline int length() const { return W; }
720
721};
722
723} // namespace sc_dt
724
725
726#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
bool nand_reduce() const
sc_biguint(const sc_generic_base< T > &a)
Definition: sc_biguint.h:173
sc_unsigned_bitref & bit(int i)
Definition: sc_biguint.h:593
sc_biguint(const sc_bigint< WO > &v)
Definition: sc_biguint.h:148
const sc_biguint< W > & operator-=(const sc_signed &v)
const sc_unsigned operator<<(const sc_unsigned &v) const
Definition: sc_biguint.h:575
const sc_unsigned_subref_r & range(int i, int j) const
Definition: sc_biguint.h:599
int get_actual_length() const
Definition: sc_biguint.h:711
int to_int() const
Definition: sc_biguint.h:414
const sc_unsigned operator>>(int v) const
const std::string to_string(sc_numrep numrep=SC_DEC) const
Definition: sc_biguint.h:696
uint64 to_uint64() const
Definition: sc_biguint.h:450
int64 to_int64() const
Definition: sc_biguint.h:435
sc_biguint(const char *v)
Definition: sc_biguint.h:197
const sc_unsigned_bitref_r & bit(int i) const
Definition: sc_biguint.h:594
sc_unsigned_subref & operator()(int i, int j)
Definition: sc_biguint.h:600
sc_biguint(const sc_signed &v)
Definition: sc_biguint.h:181
sc_biguint(int64 v)
Definition: sc_biguint.h:205
unsigned long to_ulong() const
Definition: sc_biguint.h:475
const sc_biguint< W > & operator%=(const sc_signed &v)
const sc_biguint< W > & operator|=(const sc_signed &v)
const sc_biguint< W > & operator>>=(int v)
int get_digits_n() const
Definition: sc_biguint.h:714
unsigned int to_uint() const
Definition: sc_biguint.h:424
sc_digit * get_raw() const
Definition: sc_biguint.h:717
sc_biguint(double v)
Definition: sc_biguint.h:253
sc_unsigned_bitref & operator[](int i)
Definition: sc_biguint.h:595
bool xnor_reduce() const
sc_biguint(uint64 v)
Definition: sc_biguint.h:213
sc_biguint(const sc_unsigned_subref &v)
Definition: sc_biguint.h:164
sc_biguint(unsigned long v)
Definition: sc_biguint.h:229
const sc_biguint< W > & operator&=(const sc_signed &v)
const sc_digit * get_digits() const
Definition: sc_biguint.h:712
sc_biguint(unsigned int v)
Definition: sc_biguint.h:245
const sc_biguint< W > & operator=(const sc_biguint< W > &v)
sc_biguint< W > & operator++()
Definition: sc_biguint.h:614
sc_digit * get_raw()
Definition: sc_biguint.h:716
const sc_biguint< W > & operator/=(const sc_signed &v)
sc_biguint(const sc_biguint< WO > &v)
Definition: sc_biguint.h:139
const sc_biguint< W > & operator<<=(const sc_signed &v)
Definition: sc_biguint.h:579
const sc_biguint< W > & operator<<=(int v)
const sc_bigint< W+1 > operator-()
sc_unsigned_subref & range(int i, int j)
Definition: sc_biguint.h:598
sc_digit compile_time_digits[DIV_CEIL(W+1)>SC_BASE_VEC_DIGITS?DIV_CEIL(W+1):1]
Definition: sc_biguint.h:647
const sc_biguint< W > & operator>>=(const sc_unsigned &v)
Definition: sc_biguint.h:588
sc_biguint(const sc_unsigned &v)
Definition: sc_biguint.h:156
long to_long() const
Definition: sc_biguint.h:466
sc_biguint(const sc_lv_base &v)
Definition: sc_biguint.h:269
sc_biguint(const sc_signed_subref &v)
Definition: sc_biguint.h:189
sc_biguint(long v)
Definition: sc_biguint.h:221
const sc_biguint< W > & operator+=(const sc_signed &v)
const sc_unsigned operator<<(int v) const
const sc_unsigned operator<<(const sc_signed &v) const
Definition: sc_biguint.h:574
double to_double() const
Definition: sc_biguint.h:407
const sc_unsigned & sc_unsigned_proxy() const
Definition: sc_biguint.h:687
sc_unsigned & sc_unsigned_proxy()
Definition: sc_biguint.h:682
int get_hod() const
Definition: sc_biguint.h:715
sc_biguint(const sc_bv_base &v)
Definition: sc_biguint.h:261
const sc_biguint< W > & operator>>=(const sc_signed &v)
Definition: sc_biguint.h:589
const sc_biguint< W > & operator<<=(const sc_unsigned &v)
Definition: sc_biguint.h:578
sc_biguint(const sc_biguint< W > &v)
Definition: sc_biguint.h:130
sc_biguint(int, int)
Definition: sc_biguint.h:114
sc_digit * get_digits()
Definition: sc_biguint.h:713
const sc_biguint< W > & operator*=(const sc_signed &v)
const sc_bigint< W+1 > operator~()
sc_biguint(bool flag)
Definition: sc_biguint.h:122
sc_biguint< W > & operator--()
Definition: sc_biguint.h:629
const sc_unsigned operator>>(const sc_signed &v) const
Definition: sc_biguint.h:584
const sc_biguint< W > & operator^=(const sc_signed &v)
const std::string to_string(sc_numrep numrep, bool w_prefix) const
Definition: sc_biguint.h:700
int length() const
Definition: sc_biguint.h:719
const sc_unsigned operator>>(const sc_unsigned &v) const
Definition: sc_biguint.h:585
int to_int() const
Definition: sc_signed.h:1497
double to_double() const
virtual int concat_length(bool *xz_present_p) const
Definition: sc_unsigned.h:635
const std::string to_string(sc_numrep numrep=SC_DEC) const
sc_unsigned_subref & range(int i, int j)
Definition: sc_unsigned.h:732
sc_unsigned_bitref & bit(int i)
Definition: sc_unsigned.h:686
int to_int() const
Definition: sc_unsigned.h:1582
sc_unsigned(int nb=sc_length_param().len())
Definition: sc_unsigned.h:1670