SystemC  2.3.2
Accellera SystemC proof-of-concept library
sc_uint.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_uint.h -- An unsigned integer whose length is less than 64 bits.
23 */
38 /*****************************************************************************
39 
40  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
41  changes you are making here.
42 
43  Name, Affiliation, Date: Ali Dasdan, Synopsys, Inc.
44  Description of Modification: - Resolved ambiguity with sc_(un)signed.
45  - Merged the code for 64- and 32-bit versions
46  via the constants in sc_nbdefs.h.
47  - Eliminated redundant file inclusions.
48 
49  Name, Affiliation, Date:
50  Description of Modification:
51 
52  *****************************************************************************/
53 
54 // $Log: sc_uint.h,v $
55 // Revision 1.2 2011/02/18 20:19:15 acg
56 // Andy Goodrich: updating Copyright notice.
57 //
58 // Revision 1.1.1.1 2006/12/15 20:20:05 acg
59 // SystemC 2.3
60 //
61 // Revision 1.3 2006/01/13 18:49:32 acg
62 // Added $Log command so that CVS check in comments are reproduced in the
63 // source.
64 //
65 
66 #ifndef SC_UINT_H
67 #define SC_UINT_H
68 
69 
71 
72 
73 namespace sc_dt
74 {
75 
76 // classes defined in this module
77 template <int W> class sc_uint;
78 
79 
91 template <int W>
92 class sc_uint
93  : public sc_uint_base
94 {
95 public:
96 
97  // constructors
98 
100  : sc_uint_base( W )
101  {}
102 
104  : sc_uint_base( v, W )
105  {}
106 
107  sc_uint( const sc_uint<W>& a )
108  : sc_uint_base( a )
109  {}
110 
111  sc_uint( const sc_uint_base& a )
112  : sc_uint_base( W )
113  { sc_uint_base::operator = ( a ); }
114 
116  : sc_uint_base( W )
117  { sc_uint_base::operator = ( a ); }
118 
119  template< class T >
121  : sc_uint_base( W )
122  { sc_uint_base::operator = ( a ); }
123 
124  sc_uint( const sc_signed& a )
125  : sc_uint_base( W )
126  { sc_uint_base::operator = ( a ); }
127 
128  sc_uint( const sc_unsigned& a )
129  : sc_uint_base( W )
130  { sc_uint_base::operator = ( a ); }
131 
132 #ifdef SC_INCLUDE_FX
133 
134  explicit sc_uint( const sc_fxval& a )
135  : sc_uint_base( W )
136  { sc_uint_base::operator = ( a ); }
137 
138  explicit sc_uint( const sc_fxval_fast& a )
139  : sc_uint_base( W )
140  { sc_uint_base::operator = ( a ); }
141 
142  explicit sc_uint( const sc_fxnum& a )
143  : sc_uint_base( W )
144  { sc_uint_base::operator = ( a ); }
145 
146  explicit sc_uint( const sc_fxnum_fast& a )
147  : sc_uint_base( W )
148  { sc_uint_base::operator = ( a ); }
149 
150 #endif
151 
152  sc_uint( const sc_bv_base& a )
153  : sc_uint_base( W )
154  { sc_uint_base::operator = ( a ); }
155 
156  sc_uint( const sc_lv_base& a )
157  : sc_uint_base( W )
158  { sc_uint_base::operator = ( a ); }
159 
160  sc_uint( const char* a )
161  : sc_uint_base( W )
162  { sc_uint_base::operator = ( a ); }
163 
164  sc_uint( unsigned long a )
165  : sc_uint_base( W )
166  { sc_uint_base::operator = ( a ); }
167 
168  sc_uint( long a )
169  : sc_uint_base( W )
170  { sc_uint_base::operator = ( a ); }
171 
172  sc_uint( unsigned int a )
173  : sc_uint_base( W )
174  { sc_uint_base::operator = ( a ); }
175 
176  sc_uint( int a )
177  : sc_uint_base( W )
178  { sc_uint_base::operator = ( a ); }
179 
181  : sc_uint_base( W )
182  { sc_uint_base::operator = ( a ); }
183 
184  sc_uint( double a )
185  : sc_uint_base( W )
186  { sc_uint_base::operator = ( a ); }
187 
188 
189  // assignment operators
190 
192  { sc_uint_base::operator = ( v ); return *this; }
193 
195  { sc_uint_base::operator = ( a ); return *this; }
196 
198  { sc_uint_base::operator = ( a ); return *this; }
199 
201  { m_val = a.m_val; return *this; }
202 
203  template<class T>
205  { sc_uint_base::operator = ( a ); return *this; }
206 
208  { sc_uint_base::operator = ( a ); return *this; }
209 
211  { sc_uint_base::operator = ( a ); return *this; }
212 
213 #ifdef SC_INCLUDE_FX
214 
215  sc_uint<W>& operator = ( const sc_fxval& a )
216  { sc_uint_base::operator = ( a ); return *this; }
217 
219  { sc_uint_base::operator = ( a ); return *this; }
220 
221  sc_uint<W>& operator = ( const sc_fxnum& a )
222  { sc_uint_base::operator = ( a ); return *this; }
223 
225  { sc_uint_base::operator = ( a ); return *this; }
226 
227 #endif
228 
230  { sc_uint_base::operator = ( a ); return *this; }
231 
233  { sc_uint_base::operator = ( a ); return *this; }
234 
235  sc_uint<W>& operator = ( const char* a )
236  { sc_uint_base::operator = ( a ); return *this; }
237 
238  sc_uint<W>& operator = ( unsigned long a )
239  { sc_uint_base::operator = ( a ); return *this; }
240 
242  { sc_uint_base::operator = ( a ); return *this; }
243 
244  sc_uint<W>& operator = ( unsigned int a )
245  { sc_uint_base::operator = ( a ); return *this; }
246 
248  { sc_uint_base::operator = ( a ); return *this; }
249 
251  { sc_uint_base::operator = ( a ); return *this; }
252 
253  sc_uint<W>& operator = ( double a )
254  { sc_uint_base::operator = ( a ); return *this; }
255 
256 
257  // arithmetic assignment operators
258 
260  { sc_uint_base::operator += ( v ); return *this; }
261 
263  { sc_uint_base::operator -= ( v ); return *this; }
264 
266  { sc_uint_base::operator *= ( v ); return *this; }
267 
269  { sc_uint_base::operator /= ( v ); return *this; }
270 
272  { sc_uint_base::operator %= ( v ); return *this; }
273 
274 
275  // bitwise assignment operators
276 
278  { sc_uint_base::operator &= ( v ); return *this; }
279 
281  { sc_uint_base::operator |= ( v ); return *this; }
282 
284  { sc_uint_base::operator ^= ( v ); return *this; }
285 
286 
288  { sc_uint_base::operator <<= ( v ); return *this; }
289 
291  { sc_uint_base::operator >>= ( v ); return *this; }
292 
293 
294  // prefix and postfix increment and decrement operators
295 
297  { sc_uint_base::operator ++ (); return *this; }
298 
299  const sc_uint<W> operator ++ ( int ) // postfix
300  { return sc_uint<W>( sc_uint_base::operator ++ ( 0 ) ); }
301 
303  { sc_uint_base::operator -- (); return *this; }
304 
305  const sc_uint<W> operator -- ( int ) // postfix
306  { return sc_uint<W>( sc_uint_base::operator -- ( 0 ) ); }
307 };
308 
309 } // namespace sc_dt
310 
311 
312 #endif
313 
314 // Taf!
Base class for the fixed-point types; limited precision.
Definition: sc_fxnum.h:991
sc_uint_base & operator-=(uint_type v)
Definition: sc_uint_base.h:662
sc_uint< W > & operator&=(uint_type v)
Definition: sc_uint.h:277
sc_uint(int a)
Definition: sc_uint.h:176
sc_uint_base & operator*=(uint_type v)
Definition: sc_uint_base.h:665
sc_uint(const sc_uint< W > &a)
Definition: sc_uint.h:107
Proxy class for sc_uint part selection (r-value only).
Definition: sc_uint_base.h:317
Fixed-point value types; limited precision.
Definition: sc_fxval.h:439
sc_uint_base & operator>>=(uint_type v)
Definition: sc_uint_base.h:690
sc_uint_base & operator&=(uint_type v)
Definition: sc_uint_base.h:677
sc_uint< W > & operator-=(uint_type v)
Definition: sc_uint.h:262
sc_uint< W > & operator/=(uint_type v)
Definition: sc_uint.h:268
sc_uint(int64 a)
Definition: sc_uint.h:180
sc_uint(const sc_signed &a)
Definition: sc_uint.h:124
int64_t int64
Definition: sc_nbdefs.h:188
Base class for sc_uint.
Definition: sc_uint_base.h:534
sc_uint(const sc_unsigned &a)
Definition: sc_uint.h:128
Arbitrary precision signed number.
Definition: sc_signed.h:1099
sc_uint_base & operator=(uint_type v)
Definition: sc_uint_base.h:610
sc_uint< W > & operator<<=(uint_type v)
Definition: sc_uint.h:287
sc_uint(long a)
Definition: sc_uint.h:168
sc_uint(unsigned int a)
Definition: sc_uint.h:172
sc_uint_base & operator--()
Definition: sc_uint_base.h:702
Arbitrary precision unsigned number.
Definition: sc_unsigned.h:1001
sc_uint< W > & operator--()
Definition: sc_uint.h:302
Base class for the fixed-point types; arbitrary precision.
Definition: sc_fxnum.h:564
sc_uint_base & operator%=(uint_type v)
Definition: sc_uint_base.h:671
Template class sc_uint<W> is the interface that the user sees.
Definition: sc_uint.h:77
sc_uint_base & operator<<=(uint_type v)
Definition: sc_uint_base.h:687
Fixed-point value type; arbitrary precision.
Definition: sc_fxval.h:95
sc_uint< W > & operator|=(uint_type v)
Definition: sc_uint.h:280
An unsigned integer whose length is less than 64 bits.
sc_uint(const sc_lv_base &a)
Definition: sc_uint.h:156
Arbitrary size logic vector base class.
Definition: sc_lv_base.h:91
sc_uint(double a)
Definition: sc_uint.h:184
sc_uint(const sc_uint_subref_r &a)
Definition: sc_uint.h:115
sc_uint_base & operator++()
Definition: sc_uint_base.h:696
sc_uint< W > & operator=(uint_type v)
Definition: sc_uint.h:191
sc_uint(const char *a)
Definition: sc_uint.h:160
sc_uint(const sc_uint_base &a)
Definition: sc_uint.h:111
sc_uint< W > & operator%=(uint_type v)
Definition: sc_uint.h:271
Proxy class for user-defined value classes and other classes that.
sc_uint< W > & operator*=(uint_type v)
Definition: sc_uint.h:265
sc_uint< W > & operator^=(uint_type v)
Definition: sc_uint.h:283
uint64 uint_type
Definition: sc_nbdefs.h:234
sc_uint_base & operator+=(uint_type v)
Definition: sc_uint_base.h:659
sc_uint_base(int w=sc_length_param().len())
Definition: sc_uint_base.h:571
sc_uint_base & operator/=(uint_type v)
Definition: sc_uint_base.h:668
sc_uint< W > & operator>>=(uint_type v)
Definition: sc_uint.h:290
sc_uint(const sc_bv_base &a)
Definition: sc_uint.h:152
sc_uint< W > & operator+=(uint_type v)
Definition: sc_uint.h:259
sc_uint_base & operator|=(uint_type v)
Definition: sc_uint_base.h:680
sc_uint_base & operator^=(uint_type v)
Definition: sc_uint_base.h:683
sc_uint(uint_type v)
Definition: sc_uint.h:103
sc_uint(unsigned long a)
Definition: sc_uint.h:164
sc_uint(const sc_generic_base< T > &a)
Definition: sc_uint.h:120
Arbitrary size bit vector base class.
Definition: sc_bv_base.h:80
sc_uint< W > & operator++()
Definition: sc_uint.h:296