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
58#include "sysc/datatypes/int/sc_signed.h"
59#include "sysc/datatypes/int/sc_unsigned.h"
60
61namespace sc_dt
62{
63
64// classes defined in this module
65template <int W> class sc_biguint;
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;
74
75
76// ----------------------------------------------------------------------------
77//  CLASS TEMPLATE : sc_biguint<W>
78//
79//  Arbitrary size unsigned integer type.
80// ----------------------------------------------------------------------------
81
82#ifdef SC_MAX_NBITS
83template< int W = SC_MAX_NBITS >
84#else
85template< int W >
86#endif
87class sc_biguint
88    : public sc_unsigned
89{
90public:
91
92    // constructors
93
94    sc_biguint()
95	: sc_unsigned( W )
96	{}
97
98    sc_biguint( const sc_biguint<W>& v )
99	: sc_unsigned( W )
100	{ *this = v; }
101
102    sc_biguint( const sc_unsigned& v )
103	: sc_unsigned( W )
104	{ *this = v; }
105
106    sc_biguint( const sc_unsigned_subref& v )
107	: sc_unsigned( W )
108	{ *this = v; }
109
110    template< class T >
111    sc_biguint( const sc_generic_base<T>& a )
112	: sc_unsigned( W )
113	{ a->to_sc_unsigned(*this); }
114
115    sc_biguint( const sc_signed& v )
116	: sc_unsigned( W )
117	{ *this = v; }
118
119    sc_biguint( const sc_signed_subref& v )
120	: sc_unsigned( W )
121	{ *this = v; }
122
123    sc_biguint( const char* v )
124	: sc_unsigned( W )
125	{ *this = v; }
126
127    sc_biguint( int64 v )
128	: sc_unsigned( W )
129	{ *this = v; }
130
131    sc_biguint( uint64 v )
132	: sc_unsigned( W )
133	{ *this = v; }
134
135    sc_biguint( long v )
136	: sc_unsigned( W )
137	{ *this = v; }
138
139    sc_biguint( unsigned long v )
140	: sc_unsigned( W )
141	{ *this = v; }
142
143    sc_biguint( int v )
144	: sc_unsigned( W )
145	{ *this = v; }
146
147    sc_biguint( unsigned int v )
148	: sc_unsigned( W )
149	{ *this = v; }
150
151    sc_biguint( double v )
152	: sc_unsigned( W )
153	{ *this = v; }
154
155    sc_biguint( const sc_bv_base& v )
156	: sc_unsigned( W )
157	{ *this = v; }
158
159    sc_biguint( const sc_lv_base& v )
160	: sc_unsigned( W )
161	{ *this = v; }
162
163#ifdef SC_INCLUDE_FX
164
165    explicit sc_biguint( const sc_fxval& v )
166	: sc_unsigned( W )
167	{ *this = v; }
168
169    explicit sc_biguint( const sc_fxval_fast& v )
170	: sc_unsigned( W )
171	{ *this = v; }
172
173    explicit sc_biguint( const sc_fxnum& v )
174	: sc_unsigned( W )
175	{ *this = v; }
176
177    explicit sc_biguint( const sc_fxnum_fast& v )
178	: sc_unsigned( W )
179	{ *this = v; }
180
181#endif
182
183
184#ifndef SC_MAX_NBITS
185
186    // destructor
187
188    ~sc_biguint()
189	{}
190
191#endif
192
193
194    // assignment operators
195
196    sc_biguint<W>& operator = ( const sc_biguint<W>& v )
197	{ sc_unsigned::operator = ( v ); return *this; }
198
199    sc_biguint<W>& operator = ( const sc_unsigned& v )
200	{ sc_unsigned::operator = ( v ); return *this; }
201
202    sc_biguint<W>& operator = ( const sc_unsigned_subref& v )
203	{ sc_unsigned::operator = ( v ); return *this; }
204
205    template< class T >
206    sc_biguint<W>& operator = ( const sc_generic_base<T>& a )
207	{ a->to_sc_unsigned(*this); return *this; }
208
209    sc_biguint<W>& operator = ( const sc_signed& v )
210	{ sc_unsigned::operator = ( v ); return *this; }
211
212    sc_biguint<W>& operator = ( const sc_signed_subref& v )
213	{ sc_unsigned::operator = ( v ); return *this; }
214
215    sc_biguint<W>& operator = ( const char* v )
216	{ sc_unsigned::operator = ( v ); return *this; }
217
218    sc_biguint<W>& operator = ( int64 v )
219	{ sc_unsigned::operator = ( v ); return *this; }
220
221    sc_biguint<W>& operator = ( uint64 v )
222	{ sc_unsigned::operator = ( v ); return *this; }
223
224    sc_biguint<W>& operator = ( long v )
225	{ sc_unsigned::operator = ( v ); return *this; }
226
227    sc_biguint<W>& operator = ( unsigned long v )
228	{ sc_unsigned::operator = ( v ); return *this; }
229
230    sc_biguint<W>& operator = ( int v )
231	{ sc_unsigned::operator = ( v ); return *this; }
232
233    sc_biguint<W>& operator = ( unsigned int v )
234	{ sc_unsigned::operator = ( v ); return *this; }
235
236    sc_biguint<W>& operator = ( double v )
237	{ sc_unsigned::operator = ( v ); return *this; }
238
239
240    sc_biguint<W>& operator = ( const sc_bv_base& v )
241	{ sc_unsigned::operator = ( v ); return *this; }
242
243    sc_biguint<W>& operator = ( const sc_lv_base& v )
244	{ sc_unsigned::operator = ( v ); return *this; }
245
246    sc_biguint<W>& operator = ( const sc_int_base& v )
247	{ sc_unsigned::operator = ( v ); return *this; }
248
249    sc_biguint<W>& operator = ( const sc_uint_base& v )
250	{ sc_unsigned::operator = ( v ); return *this; }
251
252#ifdef SC_INCLUDE_FX
253
254    sc_biguint<W>& operator = ( const sc_fxval& v )
255	{ sc_unsigned::operator = ( v ); return *this; }
256
257    sc_biguint<W>& operator = ( const sc_fxval_fast& v )
258	{ sc_unsigned::operator = ( v ); return *this; }
259
260    sc_biguint<W>& operator = ( const sc_fxnum& v )
261	{ sc_unsigned::operator = ( v ); return *this; }
262
263    sc_biguint<W>& operator = ( const sc_fxnum_fast& v )
264	{ sc_unsigned::operator = ( v ); return *this; }
265
266#endif
267};
268
269} // namespace sc_dt
270
271
272#endif
273