gem5  v20.1.0.0
sc_int.hh
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_int.h -- A signed integer whose length is less than 64 bits.
23 
24  Unlike arbitrary precision, arithmetic and bitwise operations
25  are performed using the native types (hence capped at 64 bits).
26  The sc_int integer is useful when the user does not need
27  arbitrary precision and the performance is superior to
28  sc_bigint/sc_biguint.
29 
30  Original Author: Amit Rao, Synopsys, Inc.
31 
32  *****************************************************************************/
33 
34 /*****************************************************************************
35 
36  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
37  changes you are making here.
38 
39  Name, Affiliation, Date: Ali Dasdan, Synopsys, Inc.
40  Description of Modification: - Resolved ambiguity with sc_(un)signed.
41  - Merged the code for 64- and 32-bit versions
42  via the constants in sc_nbdefs.h.
43  - Eliminated redundant file inclusions.
44 
45  Name, Affiliation, Date:
46  Description of Modification:
47 
48  *****************************************************************************/
49 
50 // $Log: sc_int.h,v $
51 // Revision 1.2 2011/02/18 20:19:14 acg
52 // Andy Goodrich: updating Copyright notice.
53 //
54 // Revision 1.1.1.1 2006/12/15 20:20:05 acg
55 // SystemC 2.3
56 //
57 // Revision 1.3 2006/01/13 18:49:31 acg
58 // Added $Log command so that CVS check in comments are reproduced in the
59 // source.
60 //
61 
62 #ifndef __SYSTEMC_EXT_DT_INT_SC_INT_HH__
63 #define __SYSTEMC_EXT_DT_INT_SC_INT_HH__
64 
65 #include "sc_int_base.hh"
66 
67 namespace sc_dt
68 {
69 
70 // classes defined in this module
71 template <int W>
72 class sc_int;
73 
74 
75 // ----------------------------------------------------------------------------
76 // CLASS TEMPLATE : sc_int<W>
77 //
78 // Template class sc_int<W> is the interface that the user sees. It is
79 // derived from sc_int_base and most of its methods are just wrappers
80 // that call the corresponding method in the parent class. Note that
81 // the length of sc_int datatype is specified as a template parameter.
82 // ----------------------------------------------------------------------------
83 
84 template <int W>
85 class sc_int : public sc_int_base
86 {
87  public:
88  // constructors
89  sc_int() : sc_int_base(W) {}
90  sc_int(int_type v) : sc_int_base(v, W) {}
91  sc_int(const sc_int<W> &a) : sc_int_base(a) {}
92 
93  sc_int(const sc_int_base &a) : sc_int_base(W)
94  {
96  }
97  sc_int(const sc_int_subref_r &a) : sc_int_base(W)
98  {
100  }
101  template< class T >
102  sc_int(const sc_generic_base<T> &a) : sc_int_base(W)
103  {
104  sc_int_base::operator = (a->to_int64());
105  }
106  sc_int(const sc_signed &a) : sc_int_base(W)
107  {
109  }
110  sc_int(const sc_unsigned &a) : sc_int_base(W)
111  {
113  }
114  explicit sc_int(const sc_fxval &a) : sc_int_base(W)
115  {
117  }
118  explicit sc_int(const sc_fxval_fast &a) : sc_int_base(W)
119  {
121  }
122  explicit sc_int(const sc_fxnum &a) : sc_int_base(W)
123  {
125  }
126  explicit sc_int(const sc_fxnum_fast &a) : sc_int_base(W)
127  {
129  }
130  sc_int(const sc_bv_base &a) : sc_int_base(W)
131  {
133  }
135  {
137  }
138  sc_int(const char *a) : sc_int_base(W)
139  {
141  }
142  sc_int(unsigned long a) : sc_int_base(W)
143  {
145  }
146  sc_int(long a) : sc_int_base(W)
147  {
149  }
150  sc_int(unsigned int a) : sc_int_base(W)
151  {
153  }
154  sc_int(int a) : sc_int_base(W)
155  {
157  }
158  sc_int(uint64 a) : sc_int_base(W)
159  {
161  }
162  sc_int(double a) : sc_int_base(W)
163  {
165  }
166 
167  // assignment operators
168  sc_int<W> &
170  {
172  return *this;
173  }
174  sc_int<W> &
175  operator = (const sc_int_base &a)
176  {
178  return *this;
179  }
180  sc_int<W> &
182  {
184  return *this;
185  }
186  sc_int<W> &
187  operator = (const sc_int<W> &a)
188  {
189  m_val = a.m_val;
190  return *this;
191  }
192  template< class T >
195  {
196  sc_int_base::operator = (a->to_int64());
197  return *this;
198  }
199  sc_int<W> &
200  operator = (const sc_signed &a)
201  {
203  return *this;
204  }
206  operator = (const sc_unsigned &a)
207  {
209  return *this;
210  }
211  sc_int<W> &
213  {
215  return *this;
216  }
217  sc_int<W> &
219  {
221  return *this;
222  }
223  sc_int<W> &
225  {
227  return *this;
228  }
230  {
232  return *this;
233  }
234  sc_int<W> &
235  operator = (const sc_bv_base &a)
236  {
238  return *this;
239  }
240  sc_int<W> &
241  operator = (const sc_lv_base &a)
242  {
244  return *this;
245  }
246  sc_int<W> &
247  operator = (const char *a)
248  {
250  return *this;
251  }
252  sc_int<W> &
253  operator = (unsigned long a)
254  {
256  return *this;
257  }
258  sc_int<W> &
259  operator = (long a)
260  {
262  return *this;
263  }
264  sc_int<W> &
265  operator = (unsigned int a)
266  {
268  return *this;
269  }
270  sc_int<W> &
271  operator = (int a)
272  {
274  return *this;
275  }
276  sc_int<W> &
278  {
280  return *this;
281  }
282  sc_int<W> &
283  operator = (double a)
284  {
286  return *this;
287  }
288 
289  // arithmetic assignment operators
292  {
294  return *this;
295  }
298  {
300  return *this;
301  }
304  {
306  return *this;
307  }
310  {
312  return *this;
313  }
316  {
318  return *this;
319  }
320 
321  // bitwise assignment operators
322  sc_int<W> &
324  {
326  return *this;
327  }
328  sc_int<W> &
330  {
332  return *this;
333  }
336  {
338  return *this;
339  }
342  {
344  return *this;
345  }
348  {
350  return *this;
351  }
352 
353  // prefix and postfix increment and decrement operators
354  sc_int<W> &
355  operator ++ () // prefix
356  {
358  return *this;
359  }
360  const sc_int<W>
361  operator ++ (int) // postfix
362  {
363  return sc_int<W>(sc_int_base::operator ++ (0));
364  }
365  sc_int<W> &
366  operator -- () // prefix
367  {
369  return *this;
370  }
371  const sc_int<W>
372  operator -- (int) // postfix
373  {
374  return sc_int<W>(sc_int_base::operator -- (0));
375  }
376 };
377 
378 } // namespace sc_dt
379 
380 
381 #endif // __SYSTEMC_EXT_DT_INT_SC_INT_HH__
sc_dt::sc_int_base::operator^=
sc_int_base & operator^=(int_type v)
Definition: sc_int_base.hh:743
sc_dt::sc_int_base::operator++
sc_int_base & operator++()
Definition: sc_int_base.hh:770
sc_dt::sc_int::operator&=
sc_int< W > & operator&=(int_type v)
Definition: sc_int.hh:366
sc_dt
Definition: sc_bit.cc:67
sc_dt::sc_int::operator--
sc_int< W > & operator--()
Definition: sc_int.hh:409
sc_dt::int_type
int64 int_type
Definition: sc_nbdefs.hh:240
sc_dt::sc_int::operator=
sc_int< W > & operator=(int_type v)
Definition: sc_int.hh:212
sc_int_base.hh
sc_dt::sc_int_base::operator+=
sc_int_base & operator+=(int_type v)
Definition: sc_int_base.hh:685
sc_dt::sc_fxnum_fast
Definition: sc_fxnum.hh:844
sc_dt::sc_int::operator++
sc_int< W > & operator++()
Definition: sc_int.hh:398
sc_dt::sc_fxval
Definition: sc_fxval.hh:86
sc_dt::sc_bv_base
Definition: sc_bv_base.hh:105
sc_dt::sc_int_base
Definition: sc_int_base.hh:494
sc_dt::sc_signed
Definition: sc_signed.hh:984
sc_dt::sc_int::operator<<=
sc_int< W > & operator<<=(int_type v)
Definition: sc_int.hh:384
sc_dt::sc_int::operator>>=
sc_int< W > & operator>>=(int_type v)
Definition: sc_int.hh:390
sc_dt::sc_int_base::operator>>=
sc_int_base & operator>>=(int_type v)
Definition: sc_int_base.hh:760
sc_dt::sc_int::operator/=
sc_int< W > & operator/=(int_type v)
Definition: sc_int.hh:352
ArmISA::a
Bitfield< 8 > a
Definition: miscregs_types.hh:62
sc_dt::sc_int::sc_int
sc_int(const sc_int< W > &a)
Definition: sc_int.hh:134
sc_dt::uint64
uint64_t uint64
Definition: sc_nbdefs.hh:206
sc_dt::sc_int_base::operator<<=
sc_int_base & operator<<=(int_type v)
Definition: sc_int_base.hh:752
sc_dt::sc_int::operator-=
sc_int< W > & operator-=(int_type v)
Definition: sc_int.hh:340
sc_dt::sc_fxnum
Definition: sc_fxnum.hh:483
sc_dt::sc_int::operator|=
sc_int< W > & operator|=(int_type v)
Definition: sc_int.hh:372
sc_dt::sc_int_base::operator-=
sc_int_base & operator-=(int_type v)
Definition: sc_int_base.hh:693
sc_dt::sc_int_base::operator=
sc_int_base & operator=(int_type v)
Definition: sc_int_base.hh:590
sc_dt::sc_int_base::operator*=
sc_int_base & operator*=(int_type v)
Definition: sc_int_base.hh:701
sc_dt::sc_generic_base
Definition: sc_value_base.hh:145
sc_dt::sc_int_base::operator%=
sc_int_base & operator%=(int_type v)
Definition: sc_int_base.hh:717
sc_dt::sc_int::operator*=
sc_int< W > & operator*=(int_type v)
Definition: sc_int.hh:346
sc_dt::sc_lv_base
Definition: sc_lv_base.hh:118
sc_fxval
#define sc_fxval
Definition: fx_precision_double.h:65
sc_dt::sc_int_base::operator|=
sc_int_base & operator|=(int_type v)
Definition: sc_int_base.hh:735
sc_dt::sc_int::sc_int
sc_int()
Definition: sc_int.hh:132
sc_dt::sc_fxval_fast
Definition: sc_fxval.hh:376
sc_dt::sc_int
Definition: sc_int.hh:115
sc_dt::sc_int_base::operator--
sc_int_base & operator--()
Definition: sc_int_base.hh:787
sc_dt::sc_unsigned
Definition: sc_unsigned.hh:890
sc_dt::sc_int::operator^=
sc_int< W > & operator^=(int_type v)
Definition: sc_int.hh:378
sc_dt::sc_int::operator+=
sc_int< W > & operator+=(int_type v)
Definition: sc_int.hh:334
sc_dt::sc_int::operator%=
sc_int< W > & operator%=(int_type v)
Definition: sc_int.hh:358
sc_dt::sc_int_base::operator/=
sc_int_base & operator/=(int_type v)
Definition: sc_int_base.hh:709
ArmISA::v
Bitfield< 28 > v
Definition: miscregs_types.hh:51
sc_dt::sc_int_base::operator&=
sc_int_base & operator&=(int_type v)
Definition: sc_int_base.hh:727
sc_dt::sc_int_subref_r
Definition: sc_int_base.hh:288

Generated on Wed Sep 30 2020 14:02:16 for gem5 by doxygen 1.8.17