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