SystemC  2.3.1
Accellera SystemC proof-of-concept library
sc_signed.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  The following code is derived, directly or indirectly, from the SystemC
4  source code Copyright (c) 1996-2014 by all Contributors.
5  All Rights reserved.
6 
7  The contents of this file are subject to the restrictions and limitations
8  set forth in the SystemC Open Source License (the "License");
9  You may not use this file except in compliance with such restrictions and
10  limitations. You may obtain instructions on how to receive a copy of the
11  License at http://www.accellera.org/. Software distributed by Contributors
12  under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
13  ANY KIND, either express or implied. See the License for the specific
14  language governing rights and limitations under the License.
15 
16  *****************************************************************************/
17 
18 /*****************************************************************************
19 
20  sc_signed.h -- Arbitrary precision signed arithmetic.
21 
22  This file includes the definitions of sc_signed_bitref,
23  sc_signed_subref, and sc_signed classes. The first two classes are
24  proxy classes to reference one bit and a range of bits of a
25  sc_signed number, respectively.
26 
27  An sc_signed number has the sign-magnitude representation
28  internally. However, its interface guarantees a 2's-complement
29  representation. The sign-magnitude representation is chosen
30  because of its efficiency: The sc_signed and sc_unsigned types are
31  optimized for arithmetic rather than bitwise operations. For
32  arithmetic operations, the sign-magnitude representation performs
33  better.
34 
35  The implementations of sc_signed and sc_unsigned classes are
36  almost identical: Most of the member and friend functions are
37  defined in sc_nbcommon.cpp and sc_nbfriends.cpp so that they can
38  be shared by both of these classes. These functions are chosed by
39  defining a few macros before including them such as IF_SC_SIGNED
40  and CLASS_TYPE. Our implementation choices are mostly dictated by
41  performance considerations in that we tried to provide the most
42  efficient sc_signed and sc_unsigned types without compromising
43  their interface.
44 
45  For the behavior of operators, we have two semantics: the old and
46  new. The most important difference between these two semantics is
47  that the old semantics is closer to C/C++ semantics in that the
48  result type of a binary operator on unsigned and signed arguments
49  is unsigned; the new semantics, on the other hand, requires the
50  result type be signed. The new semantics is required by the VSIA
51  C/C++ data types standard. We have implemented the new semantics.
52 
53  Original Author: Ali Dasdan, Synopsys, Inc.
54 
55  *****************************************************************************/
56 
57 /*****************************************************************************
58 
59  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
60  changes you are making here.
61 
62  Name, Affiliation, Date:
63  Description of Modification:
64 
65  *****************************************************************************/
66 
67 // $Log: sc_signed.h,v $
68 // Revision 1.3 2011/08/24 22:05:46 acg
69 // Torsten Maehne: initialization changes to remove warnings.
70 //
71 // Revision 1.2 2011/02/18 20:19:15 acg
72 // Andy Goodrich: updating Copyright notice.
73 //
74 // Revision 1.1.1.1 2006/12/15 20:20:05 acg
75 // SystemC 2.3
76 //
77 // Revision 1.5 2006/05/08 17:50:01 acg
78 // Andy Goodrich: Added David Long's declarations for friend operators,
79 // functions, and methods, to keep the Microsoft compiler happy.
80 //
81 // Revision 1.4 2006/03/13 20:25:27 acg
82 // Andy Goodrich: Addition of function declarations, e.g., xor_signed_friend()
83 // to keep gcc 4.x happy.
84 //
85 // Revision 1.3 2006/01/13 18:49:32 acg
86 // Added $Log command so that CVS check in comments are reproduced in the
87 // source.
88 //
89 
90 #ifndef SC_SIGNED_H
91 #define SC_SIGNED_H
92 
93 
94 #include "sysc/kernel/sc_object.h"
96 #include "sysc/utils/sc_iostream.h"
103 
104 
105 namespace sc_dt
106 {
107 
108 // classes defined in this module
109 class sc_signed_bitref_r;
110 class sc_signed_bitref;
111 class sc_signed_subref_r;
112 class sc_signed_subref;
113 class sc_concatref;
114 class sc_signed;
115 
116 // forward class declarations
117 class sc_bv_base;
118 class sc_lv_base;
119 class sc_int_base;
120 class sc_uint_base;
121 class sc_int_subref_r;
122 class sc_uint_subref_r;
123 class sc_signed;
124 class sc_unsigned;
125 class sc_unsigned_subref_r;
126 class sc_fxval;
127 class sc_fxval_fast;
128 class sc_fxnum;
129 class sc_fxnum_fast;
130 
131 
132 // Helper function declarations
133 sc_signed add_signed_friend(small_type us,
134  int unb,
135  int und,
136  const sc_digit *ud,
137  small_type vs,
138  int vnb,
139  int vnd,
140  const sc_digit *vd);
141 
142 sc_signed sub_signed_friend(small_type us,
143  int unb,
144  int und,
145  const sc_digit *ud,
146  small_type vs,
147  int vnb,
148  int vnd,
149  const sc_digit *vd);
150 
151 sc_signed mul_signed_friend(small_type s,
152  int unb,
153  int und,
154  const sc_digit *ud,
155  int vnb,
156  int vnd,
157  const sc_digit *vd);
158 
159 sc_signed div_signed_friend(small_type s,
160  int unb,
161  int und,
162  const sc_digit *ud,
163  int vnb,
164  int vnd,
165  const sc_digit *vd);
166 
167 sc_signed mod_signed_friend(small_type us,
168  int unb,
169  int und,
170  const sc_digit *ud,
171  int vnb,
172  int vnd,
173  const sc_digit *vd);
174 
175 sc_signed and_signed_friend(small_type us,
176  int unb,
177  int und,
178  const sc_digit *ud,
179  small_type vs,
180  int vnb,
181  int vnd,
182  const sc_digit *vd);
183 
184 sc_signed or_signed_friend(small_type us,
185  int unb,
186  int und,
187  const sc_digit *ud,
188  small_type vs,
189  int vnb,
190  int vnd,
191  const sc_digit *vd);
192 
193 sc_signed xor_signed_friend(small_type us,
194  int unb,
195  int und,
196  const sc_digit *ud,
197  small_type vs,
198  int vnb,
199  int vnd,
200  const sc_digit *vd);
201 
202 
203 // friend operator declarations
204  // ARITHMETIC OPERATORS:
205 
206  // ADDition operators:
207 
208  sc_signed operator + (const sc_unsigned& u, const sc_signed& v);
209  sc_signed operator + (const sc_signed& u, const sc_unsigned& v);
210 
211  sc_signed operator + (const sc_unsigned& u, int64 v);
212  sc_signed operator + (const sc_unsigned& u, long v);
213  inline sc_signed operator + (const sc_unsigned& u, int v);
214 
215  sc_signed operator + (int64 u, const sc_unsigned& v);
216  sc_signed operator + (long u, const sc_unsigned& v);
217  inline sc_signed operator + (int u, const sc_unsigned& v);
218 
219  sc_signed operator + (const sc_signed& u, const sc_signed& v);
220  sc_signed operator + (const sc_signed& u, int64 v);
221  sc_signed operator + (const sc_signed& u, uint64 v);
222  sc_signed operator + (const sc_signed& u, long v);
223  sc_signed operator + (const sc_signed& u, unsigned long v);
224  inline sc_signed operator + (const sc_signed& u, int v);
225  inline sc_signed operator + (const sc_signed& u, unsigned int v);
226 
227  sc_signed operator + (int64 u, const sc_signed& v);
228  sc_signed operator + (uint64 u, const sc_signed& v);
229  sc_signed operator + (long u, const sc_signed& v);
230  sc_signed operator + (unsigned long u, const sc_signed& v);
231  inline sc_signed operator + (int u, const sc_signed& v);
232  inline sc_signed operator + (unsigned int u, const sc_signed& v);
233 
234  sc_signed operator + (const sc_unsigned& u, const sc_int_base& v);
235  sc_signed operator + (const sc_int_base& u, const sc_unsigned& v);
236  sc_signed operator + (const sc_signed& u, const sc_int_base& v);
237  sc_signed operator + (const sc_signed& u, const sc_uint_base& v);
238  sc_signed operator + (const sc_int_base& u, const sc_signed& v);
239  sc_signed operator + (const sc_uint_base& u, const sc_signed& v);
240 
241 
242 
243  // SUBtraction operators:
244 
245  sc_signed operator - (const sc_unsigned& u, const sc_signed& v);
246  sc_signed operator - (const sc_signed& u, const sc_unsigned& v);
247 
248  sc_signed operator - (const sc_unsigned& u, const sc_unsigned& v);
249  sc_signed operator - (const sc_unsigned& u, int64 v);
250  sc_signed operator - (const sc_unsigned& u, uint64 v);
251  sc_signed operator - (const sc_unsigned& u, long v);
252  sc_signed operator - (const sc_unsigned& u, unsigned long v);
253  inline sc_signed operator - (const sc_unsigned& u, int v);
254  inline sc_signed operator - (const sc_unsigned& u, unsigned int v);
255 
256  sc_signed operator - (int64 u, const sc_unsigned& v);
257  sc_signed operator - (uint64 u, const sc_unsigned& v);
258  sc_signed operator - (long u, const sc_unsigned& v);
259  sc_signed operator - (unsigned long u, const sc_unsigned& v);
260  inline sc_signed operator - (int u, const sc_unsigned& v);
261  inline sc_signed operator - (unsigned int u, const sc_unsigned& v);
262 
263  sc_signed operator - (const sc_signed& u, const sc_signed& v);
264  sc_signed operator - (const sc_signed& u, int64 v);
265  sc_signed operator - (const sc_signed& u, uint64 v);
266  sc_signed operator - (const sc_signed& u, long v);
267  sc_signed operator - (const sc_signed& u, unsigned long v);
268  inline sc_signed operator - (const sc_signed& u, int v);
269  inline sc_signed operator - (const sc_signed& u, unsigned int v);
270 
271  sc_signed operator - (int64 u, const sc_signed& v);
272  sc_signed operator - (uint64 u, const sc_signed& v);
273  sc_signed operator - (long u, const sc_signed& v);
274  sc_signed operator - (unsigned long u, const sc_signed& v);
275  inline sc_signed operator - (int u, const sc_signed& v);
276  inline sc_signed operator - (unsigned int u, const sc_signed& v);
277 
278 
279  sc_signed operator - (const sc_unsigned& u, const sc_int_base& v);
280  sc_signed operator - (const sc_unsigned& u, const sc_uint_base& v);
281  sc_signed operator - (const sc_int_base& u, const sc_unsigned& v);
282  sc_signed operator - (const sc_uint_base& u, const sc_unsigned& v);
283  sc_signed operator - (const sc_signed& u, const sc_int_base& v);
284  sc_signed operator - (const sc_signed& u, const sc_uint_base& v);
285  sc_signed operator - (const sc_int_base& u, const sc_signed& v);
286  sc_signed operator - (const sc_uint_base& u, const sc_signed& v);
287 
288 
289 
290  // MULtiplication operators:
291 
292  sc_signed operator * (const sc_unsigned& u, const sc_signed& v);
293  sc_signed operator * (const sc_signed& u, const sc_unsigned& v);
294 
295  sc_signed operator * (const sc_unsigned& u, int64 v);
296  sc_signed operator * (const sc_unsigned& u, long v);
297  inline sc_signed operator * (const sc_unsigned& u, int v);
298 
299  sc_signed operator * (int64 u, const sc_unsigned& v);
300  sc_signed operator * (long u, const sc_unsigned& v);
301  inline sc_signed operator * (int u, const sc_unsigned& v);
302 
303  sc_signed operator * (const sc_signed& u, const sc_signed& v);
304  sc_signed operator * (const sc_signed& u, int64 v);
305  sc_signed operator * (const sc_signed& u, uint64 v);
306  sc_signed operator * (const sc_signed& u, long v);
307  sc_signed operator * (const sc_signed& u, unsigned long v);
308  inline sc_signed operator * (const sc_signed& u, int v);
309  inline sc_signed operator * (const sc_signed& u, unsigned int v);
310 
311  sc_signed operator * (int64 u, const sc_signed& v);
312  sc_signed operator * (uint64 u, const sc_signed& v);
313  sc_signed operator * (long u, const sc_signed& v);
314  sc_signed operator * (unsigned long u, const sc_signed& v);
315  inline sc_signed operator * (int u, const sc_signed& v);
316  inline sc_signed operator * (unsigned int u, const sc_signed& v);
317 
318  sc_signed operator * (const sc_unsigned& u, const sc_int_base& v);
319  sc_signed operator * (const sc_int_base& u, const sc_unsigned& v);
320  sc_signed operator * (const sc_signed& u, const sc_int_base& v);
321  sc_signed operator * (const sc_signed& u, const sc_uint_base& v);
322  sc_signed operator * (const sc_int_base& u, const sc_signed& v);
323  sc_signed operator * (const sc_uint_base& u, const sc_signed& v);
324 
325 
326 
327  // DIVision operators:
328 
329  sc_signed operator / (const sc_unsigned& u, const sc_signed& v);
330  sc_signed operator / (const sc_signed& u, const sc_unsigned& v);
331 
332  sc_signed operator / (const sc_unsigned& u, int64 v);
333  sc_signed operator / (const sc_unsigned& u, long v);
334  inline sc_signed operator / (const sc_unsigned& u, int v);
335 
336  sc_signed operator / (int64 u, const sc_unsigned& v);
337  sc_signed operator / (long u, const sc_unsigned& v);
338  inline sc_signed operator / (int u, const sc_unsigned& v);
339 
340  sc_signed operator / (const sc_signed& u, const sc_signed& v);
341  sc_signed operator / (const sc_signed& u, int64 v);
342  sc_signed operator / (const sc_signed& u, uint64 v);
343  sc_signed operator / (const sc_signed& u, long v);
344  sc_signed operator / (const sc_signed& u, unsigned long v);
345  inline sc_signed operator / (const sc_signed& u, int v);
346  inline sc_signed operator / (const sc_signed& u, unsigned int v);
347 
348  sc_signed operator / (int64 u, const sc_signed& v);
349  sc_signed operator / (uint64 u, const sc_signed& v);
350  sc_signed operator / (long u, const sc_signed& v);
351  sc_signed operator / (unsigned long u, const sc_signed& v);
352  inline sc_signed operator / (int u, const sc_signed& v);
353  inline sc_signed operator / (unsigned int u, const sc_signed& v);
354 
355  sc_signed operator / (const sc_unsigned& u, const sc_int_base& v);
356  sc_signed operator / (const sc_int_base& u, const sc_unsigned& v);
357  sc_signed operator / (const sc_signed& u, const sc_int_base& v);
358  sc_signed operator / (const sc_signed& u, const sc_uint_base& v);
359  sc_signed operator / (const sc_int_base& u, const sc_signed& v);
360  sc_signed operator / (const sc_uint_base& u, const sc_signed& v);
361 
362 
363 
364  // MODulo operators:
365 
366  sc_signed operator % (const sc_unsigned& u, const sc_signed& v);
367  sc_signed operator % (const sc_signed& u, const sc_unsigned& v);
368 
369  sc_signed operator % (const sc_unsigned& u, int64 v);
370  sc_signed operator % (const sc_unsigned& u, long v);
371  inline sc_signed operator % (const sc_unsigned& u, int v);
372 
373  sc_signed operator % (int64 u, const sc_unsigned& v);
374  sc_signed operator % (long u, const sc_unsigned& v);
375  inline sc_signed operator % (int u, const sc_unsigned& v);
376 
377  sc_signed operator % (const sc_signed& u, const sc_signed& v);
378  sc_signed operator % (const sc_signed& u, int64 v);
379  sc_signed operator % (const sc_signed& u, uint64 v);
380  sc_signed operator % (const sc_signed& u, long v);
381  sc_signed operator % (const sc_signed& u, unsigned long v);
382  inline sc_signed operator % (const sc_signed& u, int v);
383  inline sc_signed operator % (const sc_signed& u, unsigned int v);
384 
385  sc_signed operator % (int64 u, const sc_signed& v);
386  sc_signed operator % (uint64 u, const sc_signed& v);
387  sc_signed operator % (long u, const sc_signed& v);
388  sc_signed operator % (unsigned long u, const sc_signed& v);
389  inline sc_signed operator % (int u, const sc_signed& v);
390  inline sc_signed operator % (unsigned int u, const sc_signed& v);
391 
392  sc_signed operator % (const sc_unsigned& u, const sc_int_base& v);
393  sc_signed operator % (const sc_int_base& u, const sc_unsigned& v);
394  sc_signed operator % (const sc_signed& u, const sc_int_base& v);
395  sc_signed operator % (const sc_signed& u, const sc_uint_base& v);
396  sc_signed operator % (const sc_int_base& u, const sc_signed& v);
397  sc_signed operator % (const sc_uint_base& u, const sc_signed& v);
398 
399 
400 
401  // BITWISE OPERATORS:
402 
403  // Bitwise AND operators:
404 
405  sc_signed operator & (const sc_unsigned& u, const sc_signed& v);
406  sc_signed operator & (const sc_signed& u, const sc_unsigned& v);
407 
408  sc_signed operator & (const sc_unsigned& u, int64 v);
409  sc_signed operator & (const sc_unsigned& u, long v);
410  inline sc_signed operator & (const sc_unsigned& u, int v);
411 
412  sc_signed operator & (int64 u, const sc_unsigned& v);
413  sc_signed operator & (long u, const sc_unsigned& v);
414  inline sc_signed operator & (int u, const sc_unsigned& v);
415 
416  sc_signed operator & (const sc_signed& u, const sc_signed& v);
417  sc_signed operator & (const sc_signed& u, int64 v);
418  sc_signed operator & (const sc_signed& u, uint64 v);
419  sc_signed operator & (const sc_signed& u, long v);
420  sc_signed operator & (const sc_signed& u, unsigned long v);
421  inline sc_signed operator & (const sc_signed& u, int v);
422  inline sc_signed operator & (const sc_signed& u, unsigned int v);
423 
424  sc_signed operator & (int64 u, const sc_signed& v);
425  sc_signed operator & (uint64 u, const sc_signed& v);
426  sc_signed operator & (long u, const sc_signed& v);
427  sc_signed operator & (unsigned long u, const sc_signed& v);
428  inline sc_signed operator & (int u, const sc_signed& v);
429  inline sc_signed operator & (unsigned int u, const sc_signed& v);
430 
431  sc_signed operator & (const sc_unsigned& u, const sc_int_base& v);
432  sc_signed operator & (const sc_int_base& u, const sc_unsigned& v);
433  sc_signed operator & (const sc_signed& u, const sc_int_base& v);
434  sc_signed operator & (const sc_signed& u, const sc_uint_base& v);
435  sc_signed operator & (const sc_int_base& u, const sc_signed& v);
436  sc_signed operator & (const sc_uint_base& u, const sc_signed& v);
437 
438 
439 
440  // Bitwise OR operators:
441 
442  sc_signed operator | (const sc_unsigned& u, const sc_signed& v);
443  sc_signed operator | (const sc_signed& u, const sc_unsigned& v);
444 
445  sc_signed operator | (const sc_unsigned& u, int64 v);
446  sc_signed operator | (const sc_unsigned& u, long v);
447  inline sc_signed operator | (const sc_unsigned& u, int v);
448 
449  sc_signed operator | (int64 u, const sc_unsigned& v);
450  sc_signed operator | (long u, const sc_unsigned& v);
451  inline sc_signed operator | (int u, const sc_unsigned& v);
452 
453  sc_signed operator | (const sc_signed& u, const sc_signed& v);
454  sc_signed operator | (const sc_signed& u, int64 v);
455  sc_signed operator | (const sc_signed& u, uint64 v);
456  sc_signed operator | (const sc_signed& u, long v);
457  sc_signed operator | (const sc_signed& u, unsigned long v);
458  inline sc_signed operator | (const sc_signed& u, int v);
459  inline sc_signed operator | (const sc_signed& u, unsigned int v);
460 
461  sc_signed operator | (int64 u, const sc_signed& v);
462  sc_signed operator | (uint64 u, const sc_signed& v);
463  sc_signed operator | (long u, const sc_signed& v);
464  sc_signed operator | (unsigned long u, const sc_signed& v);
465  inline sc_signed operator | (int u, const sc_signed& v);
466  inline sc_signed operator | (unsigned int u, const sc_signed& v);
467 
468  sc_signed operator | (const sc_unsigned& u, const sc_int_base& v);
469  sc_signed operator | (const sc_int_base& u, const sc_unsigned& v);
470  sc_signed operator | (const sc_signed& u, const sc_int_base& v);
471  sc_signed operator | (const sc_signed& u, const sc_uint_base& v);
472  sc_signed operator | (const sc_int_base& u, const sc_signed& v);
473  sc_signed operator | (const sc_uint_base& u, const sc_signed& v);
474 
475 
476 
477  // Bitwise XOR operators:
478 
479  sc_signed operator ^ (const sc_unsigned& u, const sc_signed& v);
480  sc_signed operator ^ (const sc_signed& u, const sc_unsigned& v);
481 
482  sc_signed operator ^ (const sc_unsigned& u, int64 v);
483  sc_signed operator ^ (const sc_unsigned& u, long v);
484  inline sc_signed operator ^ (const sc_unsigned& u, int v);
485 
486  sc_signed operator ^ (int64 u, const sc_unsigned& v);
487  sc_signed operator ^ (long u, const sc_unsigned& v);
488  inline sc_signed operator ^ (int u, const sc_unsigned& v);
489 
490  sc_signed operator ^ (const sc_signed& u, const sc_signed& v);
491  sc_signed operator ^ (const sc_signed& u, int64 v);
492  sc_signed operator ^ (const sc_signed& u, uint64 v);
493  sc_signed operator ^ (const sc_signed& u, long v);
494  sc_signed operator ^ (const sc_signed& u, unsigned long v);
495  inline sc_signed operator ^ (const sc_signed& u, int v);
496  inline sc_signed operator ^ (const sc_signed& u, unsigned int v);
497 
498  sc_signed operator ^ (int64 u, const sc_signed& v);
499  sc_signed operator ^ (uint64 u, const sc_signed& v);
500  sc_signed operator ^ (long u, const sc_signed& v);
501  sc_signed operator ^ (unsigned long u, const sc_signed& v);
502  inline sc_signed operator ^ (int u, const sc_signed& v);
503  inline sc_signed operator ^ (unsigned int u, const sc_signed& v);
504 
505  sc_signed operator ^ (const sc_unsigned& u, const sc_int_base& v);
506  sc_signed operator ^ (const sc_int_base& u, const sc_unsigned& v);
507  sc_signed operator ^ (const sc_signed& u, const sc_int_base& v);
508  sc_signed operator ^ (const sc_signed& u, const sc_uint_base& v);
509  sc_signed operator ^ (const sc_int_base& u, const sc_signed& v);
510  sc_signed operator ^ (const sc_uint_base& u, const sc_signed& v);
511 
512 
513 
514  // SHIFT OPERATORS:
515 
516  // LEFT SHIFT operators:
517 
518  sc_unsigned operator << (const sc_unsigned& u, const sc_signed& v);
519  sc_signed operator << (const sc_signed& u, const sc_unsigned& v);
520 
521  sc_signed operator << (const sc_signed& u, const sc_signed& v);
522  sc_signed operator << (const sc_signed& u, int64 v);
523  sc_signed operator << (const sc_signed& u, uint64 v);
524  sc_signed operator << (const sc_signed& u, long v);
525  sc_signed operator << (const sc_signed& u, unsigned long v);
526  inline sc_signed operator << (const sc_signed& u, int v);
527  inline sc_signed operator << (const sc_signed& u, unsigned int v);
528 
529  sc_signed operator << (const sc_signed& u, const sc_int_base& v);
530  sc_signed operator << (const sc_signed& u, const sc_uint_base& v);
531 
532 
533 
534  // RIGHT SHIFT operators:
535 
536  sc_unsigned operator >> (const sc_unsigned& u, const sc_signed& v);
537  sc_signed operator >> (const sc_signed& u, const sc_unsigned& v);
538 
539  sc_signed operator >> (const sc_signed& u, const sc_signed& v);
540  sc_signed operator >> (const sc_signed& u, int64 v);
541  sc_signed operator >> (const sc_signed& u, uint64 v);
542  sc_signed operator >> (const sc_signed& u, long v);
543  sc_signed operator >> (const sc_signed& u, unsigned long v);
544  inline sc_signed operator >> (const sc_signed& u, int v);
545  inline sc_signed operator >> (const sc_signed& u, unsigned int v);
546 
547  sc_signed operator >> (const sc_signed& u, const sc_int_base& v);
548  sc_signed operator >> (const sc_signed& u, const sc_uint_base& v);
549 
550 
551 
552  // Unary arithmetic operators
553  sc_signed operator + (const sc_signed& u);
554  sc_signed operator - (const sc_signed& u);
555  sc_signed operator - (const sc_unsigned& u);
556 
557  // LOGICAL OPERATORS:
558 
559  // Logical EQUAL operators:
560 
561  bool operator == (const sc_unsigned& u, const sc_signed& v);
562  bool operator == (const sc_signed& u, const sc_unsigned& v);
563 
564  bool operator == (const sc_signed& u, const sc_signed& v);
565  bool operator == (const sc_signed& u, int64 v);
566  bool operator == (const sc_signed& u, uint64 v);
567  bool operator == (const sc_signed& u, long v);
568  bool operator == (const sc_signed& u, unsigned long v);
569  inline bool operator == (const sc_signed& u, int v);
570  inline bool operator == (const sc_signed& u, unsigned int v);
571 
572  bool operator == (int64 u, const sc_signed& v);
573  bool operator == (uint64 u, const sc_signed& v);
574  bool operator == (long u, const sc_signed& v);
575  bool operator == (unsigned long u, const sc_signed& v);
576  inline bool operator == (int u, const sc_signed& v);
577  inline bool operator == (unsigned int u, const sc_signed& v);
578 
579  bool operator == (const sc_signed& u, const sc_int_base& v);
580  bool operator == (const sc_signed& u, const sc_uint_base& v);
581  bool operator == (const sc_int_base& u, const sc_signed& v);
582  bool operator == (const sc_uint_base& u, const sc_signed& v);
583 
584  // Logical NOT_EQUAL operators:
585 
586  bool operator != (const sc_unsigned& u, const sc_signed& v);
587  bool operator != (const sc_signed& u, const sc_unsigned& v);
588 
589  bool operator != (const sc_signed& u, const sc_signed& v);
590  bool operator != (const sc_signed& u, int64 v);
591  bool operator != (const sc_signed& u, uint64 v);
592  bool operator != (const sc_signed& u, long v);
593  bool operator != (const sc_signed& u, unsigned long v);
594  inline bool operator != (const sc_signed& u, int v);
595  inline bool operator != (const sc_signed& u, unsigned int v);
596 
597  bool operator != (int64 u, const sc_signed& v);
598  bool operator != (uint64 u, const sc_signed& v);
599  bool operator != (long u, const sc_signed& v);
600  bool operator != (unsigned long u, const sc_signed& v);
601  inline bool operator != (int u, const sc_signed& v);
602  inline bool operator != (unsigned int u, const sc_signed& v);
603 
604  bool operator != (const sc_signed& u, const sc_int_base& v);
605  bool operator != (const sc_signed& u, const sc_uint_base& v);
606  bool operator != (const sc_int_base& u, const sc_signed& v);
607  bool operator != (const sc_uint_base& u, const sc_signed& v);
608 
609  // Logical LESS_THAN operators:
610 
611  bool operator < (const sc_unsigned& u, const sc_signed& v);
612  bool operator < (const sc_signed& u, const sc_unsigned& v);
613 
614  bool operator < (const sc_signed& u, const sc_signed& v);
615  bool operator < (const sc_signed& u, int64 v);
616  bool operator < (const sc_signed& u, uint64 v);
617  bool operator < (const sc_signed& u, long v);
618  bool operator < (const sc_signed& u, unsigned long v);
619  inline bool operator < (const sc_signed& u, int v);
620  inline bool operator < (const sc_signed& u, unsigned int v);
621 
622  bool operator < (int64 u, const sc_signed& v);
623  bool operator < (uint64 u, const sc_signed& v);
624  bool operator < (long u, const sc_signed& v);
625  bool operator < (unsigned long u, const sc_signed& v);
626  inline bool operator < (int u, const sc_signed& v);
627  inline bool operator < (unsigned int u, const sc_signed& v);
628 
629  bool operator < (const sc_signed& u, const sc_int_base& v);
630  bool operator < (const sc_signed& u, const sc_uint_base& v);
631  bool operator < (const sc_int_base& u, const sc_signed& v);
632  bool operator < (const sc_uint_base& u, const sc_signed& v);
633 
634  // Logical LESS_THAN_AND_EQUAL operators:
635 
636  bool operator <= (const sc_unsigned& u, const sc_signed& v);
637  bool operator <= (const sc_signed& u, const sc_unsigned& v);
638 
639  bool operator <= (const sc_signed& u, const sc_signed& v);
640  bool operator <= (const sc_signed& u, int64 v);
641  bool operator <= (const sc_signed& u, uint64 v);
642  bool operator <= (const sc_signed& u, long v);
643  bool operator <= (const sc_signed& u, unsigned long v);
644  inline bool operator <= (const sc_signed& u, int v);
645  inline bool operator <= (const sc_signed& u, unsigned int v);
646 
647  bool operator <= (int64 u, const sc_signed& v);
648  bool operator <= (uint64 u, const sc_signed& v);
649  bool operator <= (long u, const sc_signed& v);
650  bool operator <= (unsigned long u, const sc_signed& v);
651  inline bool operator <= (int u, const sc_signed& v);
652  inline bool operator <= (unsigned int u, const sc_signed& v);
653 
654  bool operator <= (const sc_signed& u, const sc_int_base& v);
655  bool operator <= (const sc_signed& u, const sc_uint_base& v);
656  bool operator <= (const sc_int_base& u, const sc_signed& v);
657  bool operator <= (const sc_uint_base& u, const sc_signed& v);
658 
659  // Logical GREATER_THAN operators:
660 
661  bool operator > (const sc_unsigned& u, const sc_signed& v);
662  bool operator > (const sc_signed& u, const sc_unsigned& v);
663 
664  bool operator > (const sc_signed& u, const sc_signed& v);
665  bool operator > (const sc_signed& u, int64 v);
666  bool operator > (const sc_signed& u, uint64 v);
667  bool operator > (const sc_signed& u, long v);
668  bool operator > (const sc_signed& u, unsigned long v);
669  inline bool operator > (const sc_signed& u, int v);
670  inline bool operator > (const sc_signed& u, unsigned int v);
671 
672  bool operator > (int64 u, const sc_signed& v);
673  bool operator > (uint64 u, const sc_signed& v);
674  bool operator > (long u, const sc_signed& v);
675  bool operator > (unsigned long u, const sc_signed& v);
676  inline bool operator > (int u, const sc_signed& v);
677  inline bool operator > (unsigned int u, const sc_signed& v);
678 
679  bool operator > (const sc_signed& u, const sc_int_base& v);
680  bool operator > (const sc_signed& u, const sc_uint_base& v);
681  bool operator > (const sc_int_base& u, const sc_signed& v);
682  bool operator > (const sc_uint_base& u, const sc_signed& v);
683 
684  // Logical GREATER_THAN_AND_EQUAL operators:
685 
686  bool operator >= (const sc_unsigned& u, const sc_signed& v);
687  bool operator >= (const sc_signed& u, const sc_unsigned& v);
688 
689  bool operator >= (const sc_signed& u, const sc_signed& v);
690  bool operator >= (const sc_signed& u, int64 v);
691  bool operator >= (const sc_signed& u, uint64 v);
692  bool operator >= (const sc_signed& u, long v);
693  bool operator >= (const sc_signed& u, unsigned long v);
694  inline bool operator >= (const sc_signed& u, int v);
695  inline bool operator >= (const sc_signed& u, unsigned int v);
696 
697  bool operator >= (int64 u, const sc_signed& v);
698  bool operator >= (uint64 u, const sc_signed& v);
699  bool operator >= (long u, const sc_signed& v);
700  bool operator >= (unsigned long u, const sc_signed& v);
701  inline bool operator >= (int u, const sc_signed& v);
702  inline bool operator >= (unsigned int u, const sc_signed& v);
703 
704  bool operator >= (const sc_signed& u, const sc_int_base& v);
705  bool operator >= (const sc_signed& u, const sc_uint_base& v);
706  bool operator >= (const sc_int_base& u, const sc_signed& v);
707  bool operator >= (const sc_uint_base& u, const sc_signed& v);
708 
709  // Bitwise NOT operator (unary).
710  sc_signed operator ~ (const sc_signed& u);
711 
712 // ----------------------------------------------------------------------------
713 // CLASS : sc_signed_bitref_r
714 //
715 // Proxy class for sc_signed bit selection (r-value only).
716 // ----------------------------------------------------------------------------
717 
719 {
720  friend class sc_signed;
721 
722 protected:
723 
724  // constructor
725 
727  {}
728 
729  void initialize( const sc_signed* obj_p, int index_ )
730  {
731  m_index = index_;
732  m_obj_p = ( CCAST<sc_signed*>( obj_p ) );
733  }
734 
735 public:
736 
737  // destructor
738 
740  {}
741 
742  // copy constructor
743 
745  : sc_value_base(a), m_index( a.m_index ), m_obj_p( a.m_obj_p )
746  {}
747 
748  // capacity
749 
750  int length() const
751  { return 1; }
752 
753 
754  // implicit conversion to bool
755 
756  operator uint64 () const;
757  bool operator ! () const;
758  bool operator ~ () const;
759 
760 
761  // explicit conversions
762 
763  bool value() const
764  { return operator uint64(); }
765 
766  bool to_bool() const
767  { return operator uint64(); }
768 
769  // concatenation support
770 
771  virtual int concat_length(bool* xz_present_p) const
772  { if ( xz_present_p ) *xz_present_p = false; return 1; }
773  virtual uint64 concat_get_uint64() const
774  { return (uint64)operator uint64(); }
775  virtual bool concat_get_ctrl( sc_digit* dst_p, int low_i ) const
776  {
777  int bit_mask = 1 << (low_i % BITS_PER_DIGIT);
778  int word_i = low_i / BITS_PER_DIGIT;
779  dst_p[word_i] &= ~bit_mask;
780  return false;
781  }
782  virtual bool concat_get_data( sc_digit* dst_p, int low_i ) const
783  {
784  int bit_mask = 1 << (low_i % BITS_PER_DIGIT);
785  bool result; // True if non-zero.
786  int word_i = low_i / BITS_PER_DIGIT;
787  if ( operator uint64() )
788  {
789  dst_p[word_i] |= bit_mask;
790  result = true;
791  }
792  else
793  {
794  dst_p[word_i] &= ~bit_mask;
795  result = false;
796  }
797  return result;
798  }
799 
800 
801  // other methods
802 
803  void print( ::std::ostream& os = ::std::cout ) const
804  { os << to_bool(); }
805 
806 protected:
807 
808  int m_index; // Bit to be selected.
809  sc_signed* m_obj_p; // Target of this bit selection.
810 
811 private:
812 
813  // disabled
814  const sc_signed_bitref_r& operator = ( const sc_signed_bitref_r& );
815 };
816 
817 
818 
819 inline
820 ::std::ostream&
821 operator << ( ::std::ostream&, const sc_signed_bitref_r& );
822 
823 
824 // ----------------------------------------------------------------------------
825 // CLASS : sc_signed_bitref
826 //
827 // Proxy class for sc_signed bit selection (r-value and l-value).
828 // ----------------------------------------------------------------------------
829 
831  : public sc_signed_bitref_r
832 {
833  friend class sc_signed;
835 
836 
837  // constructor
838 
839 protected:
840 
842  {}
843 
844 public:
845 
846  // copy constructor
847 
849  : sc_signed_bitref_r( a )
850  {}
851 
852  // assignment operators
853 
856  const sc_signed_bitref& operator = ( bool );
857 
858  const sc_signed_bitref& operator &= ( bool );
859  const sc_signed_bitref& operator |= ( bool );
860  const sc_signed_bitref& operator ^= ( bool );
861 
862  // concatenation methods
863 
864  virtual void concat_set(int64 src, int low_i);
865  virtual void concat_set(const sc_signed& src, int low_i);
866  virtual void concat_set(const sc_unsigned& src, int low_i);
867  virtual void concat_set(uint64 src, int low_i);
868 
869 
870  // other methods
871 
872  void scan( ::std::istream& is = ::std::cin );
873 
874 protected:
876 };
877 
878 
879 
880 inline
881 ::std::istream&
882 operator >> ( ::std::istream&, sc_signed_bitref& );
883 
884 
885 // ----------------------------------------------------------------------------
886 // CLASS : sc_signed_subref_r
887 //
888 // Proxy class for sc_signed part selection (r-value only).
889 // ----------------------------------------------------------------------------
890 
892 {
893  friend class sc_signed;
894  friend class sc_signed_signal;
895  friend class sc_unsigned;
896 
897 protected:
898 
899  // constructor
900 
902  {}
903 
904  void initialize( const sc_signed* obj_p, int left_, int right_ )
905  {
906  m_obj_p = ( CCAST<sc_signed*>( obj_p ));
907  m_left = left_;
908  m_right = right_;
909  }
910 
911 
912 public:
913 
914  // destructor
915 
917  {}
918 
919  // copy constructor
920 
922  : sc_value_base(a), m_left( a.m_left ), m_obj_p( a.m_obj_p ),
923  m_right( a.m_right )
924  {}
925 
926 
927  // capacity
928 
929  int length() const
930  { return m_left >= m_right ? (m_left-m_right+1) : (m_right-m_left+1 ); }
931 
932 
933  // implicit conversion to sc_unsigned
934 
935  operator sc_unsigned () const;
936 
937 
938  // explicit conversions
939 
940  int to_int() const;
941  unsigned int to_uint() const;
942  long to_long() const;
943  unsigned long to_ulong() const;
944  int64 to_int64() const;
945  uint64 to_uint64() const;
946  double to_double() const;
947 
948 
949  // explicit conversion to character string
950 
951  const std::string to_string( sc_numrep numrep = SC_DEC ) const;
952  const std::string to_string( sc_numrep numrep, bool w_prefix ) const;
953 
954  // concatenation support
955 
956  virtual int concat_length(bool* xz_present_p) const
957  {
958  if ( xz_present_p ) *xz_present_p = false;
959  return m_left - m_right + 1;
960  }
961  virtual uint64 concat_get_uint64() const;
962  virtual bool concat_get_ctrl( sc_digit* dst_p, int low_i ) const;
963  virtual bool concat_get_data( sc_digit* dst_p, int low_i ) const;
964 
965  // reduce methods
966 
967  bool and_reduce() const;
968  bool nand_reduce() const;
969  bool or_reduce() const;
970  bool nor_reduce() const;
971  bool xor_reduce() const ;
972  bool xnor_reduce() const;
973 
974 
975  // other methods
976 
977  void print( ::std::ostream& os = ::std::cout ) const
978  { os << to_string(sc_io_base(os,SC_DEC),sc_io_show_base(os)); }
979 
980 protected:
981 
982  int m_left; // Left-most bit in this part selection.
983  sc_signed* m_obj_p; // Target of this part selection.
984  int m_right; // Right-most bit in this part selection.
985 
986 private:
987  const sc_signed_subref_r& operator = ( const sc_signed_subref_r& );
988 
989 };
990 
991 
992 
993 inline
994 ::std::ostream&
995 operator << ( ::std::ostream&, const sc_signed_subref_r& );
996 
997 
998 // ----------------------------------------------------------------------------
999 // CLASS : sc_signed_subref
1000 //
1001 // Proxy class for sc_signed part selection (r-value and l-value).
1002 // ----------------------------------------------------------------------------
1003 
1005  : public sc_signed_subref_r
1006 {
1007  friend class sc_signed;
1009 
1010 
1011  // constructor
1012 
1014  {}
1015 
1016 public:
1017 
1018  // copy constructor
1019 
1021  : sc_signed_subref_r( a )
1022  {}
1023 
1024 
1025  // assignment operators
1026 
1027  const sc_signed_subref& operator = ( const sc_signed_subref_r& a );
1028  const sc_signed_subref& operator = ( const sc_signed_subref& a );
1029  const sc_signed_subref& operator = ( const sc_signed& a );
1030 
1032  const sc_signed_subref& operator = ( const sc_unsigned& a );
1033 
1034  template< class T >
1036  {
1037  sc_unsigned temp( length() );
1038  a->to_sc_unsigned(temp);
1039  return operator = (temp);
1040  }
1041 
1042  const sc_signed_subref& operator = ( const char* a );
1043  const sc_signed_subref& operator = ( unsigned long a );
1044  const sc_signed_subref& operator = ( long a );
1045  const sc_signed_subref& operator = ( unsigned int a )
1046  { return operator = ( (unsigned long) a ); }
1047 
1049  { return operator = ( (long) a ); }
1050 
1051  const sc_signed_subref& operator = ( uint64 a );
1052  const sc_signed_subref& operator = ( int64 a );
1053  const sc_signed_subref& operator = ( double a );
1054  const sc_signed_subref& operator = ( const sc_int_base& a );
1055  const sc_signed_subref& operator = ( const sc_uint_base& a );
1056 
1057  // concatenation methods
1058 
1059  virtual void concat_set(int64 src, int low_i);
1060  virtual void concat_set(const sc_signed& src, int low_i);
1061  virtual void concat_set(const sc_unsigned& src, int low_i);
1062  virtual void concat_set(uint64 src, int low_i);
1063 
1064  // other methods
1065 
1066  void scan( ::std::istream& is = ::std::cin );
1067 
1068 protected:
1070 };
1071 
1072 
1073 
1074 inline
1075 ::std::istream&
1076 operator >> ( ::std::istream&, sc_signed_subref& );
1077 
1078 
1079 // ----------------------------------------------------------------------------
1080 // CLASS : sc_signed
1081 //
1082 // Arbitrary precision signed number.
1083 // ----------------------------------------------------------------------------
1084 
1085 class sc_signed : public sc_value_base
1086 {
1087  friend class sc_concatref;
1088  friend class sc_signed_bitref_r;
1089  friend class sc_signed_bitref;
1090  friend class sc_signed_subref_r;
1091  friend class sc_signed_subref;
1092  friend class sc_unsigned;
1093  friend class sc_unsigned_subref;
1094 
1095  // Needed for types using sc_signed.
1096  typedef bool elemtype;
1097 
1098 public:
1099 
1100  // constructors
1101 
1102  explicit sc_signed( int nb = sc_length_param().len() );
1103  sc_signed( const sc_signed& v );
1104  sc_signed( const sc_unsigned& v );
1105  template<class T>
1106  explicit sc_signed( const sc_generic_base<T>& v );
1107  explicit sc_signed( const sc_bv_base& v );
1108  explicit sc_signed( const sc_lv_base& v );
1109  explicit sc_signed( const sc_int_subref_r& v );
1110  explicit sc_signed( const sc_uint_subref_r& v );
1111  explicit sc_signed( const sc_signed_subref_r& v );
1112  explicit sc_signed( const sc_unsigned_subref_r& v );
1113 
1114  // assignment operators
1115 
1116  const sc_signed& operator = (const sc_signed& v);
1117  const sc_signed& operator = (const sc_signed_subref_r& a );
1118 
1119  template< class T >
1121  { a->to_sc_signed(*this); return *this; }
1122 
1123  const sc_signed& operator = (const sc_unsigned& v);
1124  const sc_signed& operator = (const sc_unsigned_subref_r& a );
1125 
1126  const sc_signed& operator = (const char* v);
1127  const sc_signed& operator = (int64 v);
1128  const sc_signed& operator = (uint64 v);
1129  const sc_signed& operator = (long v);
1130  const sc_signed& operator = (unsigned long v);
1131 
1132  const sc_signed& operator = (int v)
1133  { return operator=((long) v); }
1134 
1135  const sc_signed& operator = (unsigned int v)
1136  { return operator=((unsigned long) v); }
1137 
1138  const sc_signed& operator = (double v);
1139  const sc_signed& operator = (const sc_int_base& v);
1140  const sc_signed& operator = (const sc_uint_base& v);
1141 
1142  const sc_signed& operator = ( const sc_bv_base& );
1143  const sc_signed& operator = ( const sc_lv_base& );
1144 
1145 #ifdef SC_INCLUDE_FX
1146  const sc_signed& operator = ( const sc_fxval& );
1147  const sc_signed& operator = ( const sc_fxval_fast& );
1148  const sc_signed& operator = ( const sc_fxnum& );
1149  const sc_signed& operator = ( const sc_fxnum_fast& );
1150 #endif
1151 
1152 
1153  // destructor
1154 
1155  virtual ~sc_signed()
1156  {
1157 #ifndef SC_MAX_NBITS
1158  delete [] digit;
1159 #endif
1160  }
1161 
1162  // Concatenation support:
1163 
1165  { return digit; }
1166  virtual int concat_length(bool* xz_present_p) const
1167  { if ( xz_present_p ) *xz_present_p = false; return nbits; }
1168  virtual bool concat_get_ctrl( sc_digit* dst_p, int low_i ) const;
1169  virtual bool concat_get_data( sc_digit* dst_p, int low_i ) const;
1170  virtual uint64 concat_get_uint64() const;
1171  virtual void concat_set(int64 src, int low_i);
1172  virtual void concat_set(const sc_signed& src, int low_i);
1173  virtual void concat_set(const sc_unsigned& src, int low_i);
1174  virtual void concat_set(uint64 src, int low_i);
1175 
1176 
1177 
1178  // Increment operators.
1180  const sc_signed operator ++ (int);
1181 
1182  // Decrement operators.
1184  const sc_signed operator -- (int);
1185 
1186 
1187  // bit selection
1188 
1189  inline void check_index( int i ) const
1190  { if ( i < 0 || i >= nbits ) invalid_index(i); }
1191 
1192  void invalid_index( int i ) const;
1193 
1195  {
1196  check_index(i);
1197  sc_signed_bitref* result_p =
1198  sc_signed_bitref::m_pool.allocate();
1199  result_p->initialize( this, i );
1200  return *result_p;
1201  }
1202 
1203  const sc_signed_bitref_r& operator [] ( int i ) const
1204  {
1205  check_index(i);
1206  sc_signed_bitref* result_p =
1207  sc_signed_bitref::m_pool.allocate();
1208  result_p->initialize( this, i );
1209  return *result_p;
1210  }
1211 
1213  {
1214  check_index(i);
1215  sc_signed_bitref* result_p =
1216  sc_signed_bitref::m_pool.allocate();
1217  result_p->initialize( this, i );
1218  return *result_p;
1219  }
1220 
1221  const sc_signed_bitref_r& bit( int i ) const
1222  {
1223  check_index(i);
1224  sc_signed_bitref* result_p =
1225  sc_signed_bitref::m_pool.allocate();
1226  result_p->initialize( this, i );
1227  return *result_p;
1228  }
1229 
1230 
1231  // part selection
1232 
1233  // Subref operators. Help access the range of bits from the ith to
1234  // jth. These indices have arbitrary precedence with respect to each
1235  // other, i.e., we can have i <= j or i > j. Note the equivalence
1236  // between range(i, j) and operator(i, j). Also note that
1237  // operator(i, i) returns a signed number that corresponds to the
1238  // bit operator[i], so these two forms are not the same.
1239 
1240  inline void check_range( int l, int r ) const
1241  {
1242  if ( l < r )
1243  {
1244  if ( l < 0 || r >= nbits ) invalid_range(l,r);
1245  }
1246  else
1247  {
1248  if ( r < 0 || l >= nbits ) invalid_range(l,r);
1249  }
1250  }
1251 
1252  void invalid_range( int l, int r ) const;
1253 
1254  sc_signed_subref& range( int i, int j )
1255  {
1256  check_range( i, j );
1257  sc_signed_subref* result_p =
1258  sc_signed_subref::m_pool.allocate();
1259  result_p->initialize( this, i, j );
1260  return *result_p;
1261  }
1262 
1263  const sc_signed_subref_r& range( int i, int j ) const
1264  {
1265  check_range( i, j );
1266  sc_signed_subref* result_p =
1267  sc_signed_subref::m_pool.allocate();
1268  result_p->initialize( this, i, j );
1269  return *result_p;
1270  }
1271 
1273  {
1274  check_range( i, j );
1275  sc_signed_subref* result_p =
1276  sc_signed_subref::m_pool.allocate();
1277  result_p->initialize( this, i, j );
1278  return *result_p;
1279  }
1280 
1281  const sc_signed_subref_r& operator () ( int i, int j ) const
1282  {
1283  check_range( i, j );
1284  sc_signed_subref* result_p =
1285  sc_signed_subref::m_pool.allocate();
1286  result_p->initialize( this, i, j );
1287  return *result_p;
1288  }
1289 
1290 
1291  // explicit conversions
1292 
1293  int to_int() const;
1294  unsigned int to_uint() const;
1295  long to_long() const;
1296  unsigned long to_ulong() const;
1297  int64 to_int64() const;
1298  uint64 to_uint64() const;
1299  double to_double() const;
1300 
1301 #ifdef SC_DT_DEPRECATED
1302  int to_signed() const
1303  { return to_int(); }
1304 
1305  unsigned int to_unsigned() const
1306  { return to_uint(); }
1307 #endif
1308 
1309  // explicit conversion to character string
1310 
1311  const std::string to_string( sc_numrep numrep = SC_DEC ) const;
1312  const std::string to_string( sc_numrep numrep, bool w_prefix ) const;
1313 
1314 
1315  // Print functions. dump prints the internals of the class.
1316 
1317  void print( ::std::ostream& os = ::std::cout ) const
1318  { os << to_string(sc_io_base(os,SC_DEC),sc_io_show_base(os)); }
1319 
1320  void scan( ::std::istream& is = ::std::cin );
1321 
1322  void dump( ::std::ostream& os = ::std::cout ) const;
1323 
1324 
1325  // Functions to find various properties.
1326  int length() const { return nbits; } // Bit width.
1327  bool iszero() const; // Is the number zero?
1328  bool sign() const; // Sign.
1329 
1330  // reduce methods
1331 
1332  bool and_reduce() const;
1333 
1334  bool nand_reduce() const
1335  { return ( ! and_reduce() ); }
1336 
1337  bool or_reduce() const;
1338 
1339  bool nor_reduce() const
1340  { return ( ! or_reduce() ); }
1341 
1342  bool xor_reduce() const;
1343 
1344  bool xnor_reduce() const
1345  { return ( ! xor_reduce() ); }
1346 
1347  // Functions to access individual bits.
1348  bool test(int i) const; // Is the ith bit 0 or 1?
1349  void set(int i); // Set the ith bit to 1.
1350  void clear(int i); // Set the ith bit to 0.
1351  void set(int i, bool v) // Set the ith bit to v.
1352  { if (v) set(i); else clear(i); }
1353  void invert(int i) // Negate the ith bit.
1354  { if (test(i)) clear(i); else set(i); }
1355 
1356  // Make the number equal to its mirror image.
1357  void reverse();
1358 
1359  // Get/set a packed bit representation of the number.
1360  void get_packed_rep(sc_digit *buf) const;
1361  void set_packed_rep(sc_digit *buf);
1362 
1363  /*
1364  The comparison of the old and new semantics are as follows:
1365 
1366  Let s = sc_signed,
1367  u = sc_unsigned,
1368  un = { uint64, unsigned long, unsigned int },
1369  sn = { int64, long, int, char* }, and
1370  OP = { +, -, *, /, % }.
1371 
1372  Old semantics: New semantics:
1373  u OP u -> u u OP u -> u
1374  s OP u -> u s OP u -> s
1375  u OP s -> u u OP s -> s
1376  s OP s -> s s OP s -> s
1377 
1378  u OP un = un OP u -> u u OP un = un OP u -> u
1379  u OP sn = sn OP u -> u u OP sn = sn OP u -> s
1380 
1381  s OP un = un OP s -> s s OP un = un OP s -> s
1382  s OP sn = sn OP s -> s s OP sn = sn OP s -> s
1383 
1384  In the new semantics, the result is u if both operands are u; the
1385  result is s otherwise. The only exception is subtraction. The result
1386  of a subtraction is always s.
1387 
1388  The old semantics is like C/C++ semantics on integer types; the
1389  new semantics is due to the VSIA C/C++ data types standard.
1390  */
1391 
1392  // ARITHMETIC OPERATORS:
1393 
1394  // ADDition operators:
1395 
1396  friend sc_signed operator + (const sc_unsigned& u, const sc_signed& v);
1397  friend sc_signed operator + (const sc_signed& u, const sc_unsigned& v);
1398 
1399  friend sc_signed operator + (const sc_unsigned& u, int64 v);
1400  friend sc_signed operator + (const sc_unsigned& u, long v);
1401  friend sc_signed operator + (const sc_unsigned& u, int v)
1402  { return operator+(u, (long) v); }
1403 
1404  friend sc_signed operator + (int64 u, const sc_unsigned& v);
1405  friend sc_signed operator + (long u, const sc_unsigned& v);
1406  friend sc_signed operator + (int u, const sc_unsigned& v)
1407  { return operator+((long) u, v); }
1408 
1409  friend sc_signed operator + (const sc_signed& u, const sc_signed& v);
1410  friend sc_signed operator + (const sc_signed& u, int64 v);
1411  friend sc_signed operator + (const sc_signed& u, uint64 v);
1412  friend sc_signed operator + (const sc_signed& u, long v);
1413  friend sc_signed operator + (const sc_signed& u, unsigned long v);
1414  friend sc_signed operator + (const sc_signed& u, int v)
1415  { return operator+(u, (long) v); }
1416  friend sc_signed operator + (const sc_signed& u, unsigned int v)
1417  { return operator+(u, (unsigned long) v); }
1418 
1419  friend sc_signed operator + (int64 u, const sc_signed& v);
1420  friend sc_signed operator + (uint64 u, const sc_signed& v);
1421  friend sc_signed operator + (long u, const sc_signed& v);
1422  friend sc_signed operator + (unsigned long u, const sc_signed& v);
1423  friend sc_signed operator + (int u, const sc_signed& v)
1424  { return operator+((long) u, v); }
1425  friend sc_signed operator + (unsigned int u, const sc_signed& v)
1426  { return operator+((unsigned long) u, v); }
1427 
1428  const sc_signed& operator += (const sc_signed& v);
1429  const sc_signed& operator += (const sc_unsigned& v);
1430  const sc_signed& operator += (int64 v);
1431  const sc_signed& operator += (uint64 v);
1432  const sc_signed& operator += (long v);
1433  const sc_signed& operator += (unsigned long v);
1434  const sc_signed& operator += (int v)
1435  { return operator+=((long) v); }
1436  const sc_signed& operator += (unsigned int v)
1437  { return operator+=((unsigned long) v); }
1438 
1439  friend sc_signed operator + (const sc_unsigned& u, const sc_int_base& v);
1440  friend sc_signed operator + (const sc_int_base& u, const sc_unsigned& v);
1441  friend sc_signed operator + (const sc_signed& u, const sc_int_base& v);
1442  friend sc_signed operator + (const sc_signed& u, const sc_uint_base& v);
1443  friend sc_signed operator + (const sc_int_base& u, const sc_signed& v);
1444  friend sc_signed operator + (const sc_uint_base& u, const sc_signed& v);
1445  const sc_signed& operator += (const sc_int_base& v);
1446  const sc_signed& operator += (const sc_uint_base& v);
1447 
1448  // SUBtraction operators:
1449 
1450  friend sc_signed operator - (const sc_unsigned& u, const sc_signed& v);
1451  friend sc_signed operator - (const sc_signed& u, const sc_unsigned& v);
1452 
1453  friend sc_signed operator - (const sc_unsigned& u, const sc_unsigned& v);
1454  friend sc_signed operator - (const sc_unsigned& u, int64 v);
1455  friend sc_signed operator - (const sc_unsigned& u, uint64 v);
1456  friend sc_signed operator - (const sc_unsigned& u, long v);
1457  friend sc_signed operator - (const sc_unsigned& u, unsigned long v);
1458  friend sc_signed operator - (const sc_unsigned& u, int v)
1459  { return operator-(u, (long) v); }
1460  friend sc_signed operator - (const sc_unsigned& u, unsigned int v)
1461  { return operator-(u, (unsigned long) v); }
1462 
1463  friend sc_signed operator - (int64 u, const sc_unsigned& v);
1464  friend sc_signed operator - (uint64 u, const sc_unsigned& v);
1465  friend sc_signed operator - (long u, const sc_unsigned& v);
1466  friend sc_signed operator - (unsigned long u, const sc_unsigned& v);
1467  friend sc_signed operator - (int u, const sc_unsigned& v)
1468  { return operator-((long) u, v); }
1469  friend sc_signed operator - (unsigned int u, const sc_unsigned& v)
1470  { return operator-((unsigned long) u, v); }
1471 
1472  friend sc_signed operator - (const sc_signed& u, const sc_signed& v);
1473  friend sc_signed operator - (const sc_signed& u, int64 v);
1474  friend sc_signed operator - (const sc_signed& u, uint64 v);
1475  friend sc_signed operator - (const sc_signed& u, long v);
1476  friend sc_signed operator - (const sc_signed& u, unsigned long v);
1477  friend sc_signed operator - (const sc_signed& u, int v)
1478  { return operator-(u, (long) v); }
1479  friend sc_signed operator - (const sc_signed& u, unsigned int v)
1480  { return operator-(u, (unsigned long) v); }
1481 
1482  friend sc_signed operator - (int64 u, const sc_signed& v);
1483  friend sc_signed operator - (uint64 u, const sc_signed& v);
1484  friend sc_signed operator - (long u, const sc_signed& v);
1485  friend sc_signed operator - (unsigned long u, const sc_signed& v);
1486  friend sc_signed operator - (int u, const sc_signed& v)
1487  { return operator-((long) u, v); }
1488  friend sc_signed operator - (unsigned int u, const sc_signed& v)
1489  { return operator-((unsigned long) u, v); }
1490 
1491  const sc_signed& operator -= (const sc_signed& v);
1492  const sc_signed& operator -= (const sc_unsigned& v);
1493  const sc_signed& operator -= (int64 v);
1494  const sc_signed& operator -= (uint64 v);
1495  const sc_signed& operator -= (long v);
1496  const sc_signed& operator -= (unsigned long v);
1497  const sc_signed& operator -= (int v)
1498  { return operator -= ((long) v); }
1499  const sc_signed& operator -= (unsigned int v)
1500  { return operator -= ((unsigned long) v); }
1501 
1502  friend sc_signed operator - (const sc_unsigned& u, const sc_int_base& v);
1503  friend sc_signed operator - (const sc_unsigned& u, const sc_uint_base& v);
1504  friend sc_signed operator - (const sc_int_base& u, const sc_unsigned& v);
1505  friend sc_signed operator - (const sc_uint_base& u, const sc_unsigned& v);
1506  friend sc_signed operator - (const sc_signed& u, const sc_int_base& v);
1507  friend sc_signed operator - (const sc_signed& u, const sc_uint_base& v);
1508  friend sc_signed operator - (const sc_int_base& u, const sc_signed& v);
1509  friend sc_signed operator - (const sc_uint_base& u, const sc_signed& v);
1510  const sc_signed& operator -= (const sc_int_base& v);
1511  const sc_signed& operator -= (const sc_uint_base& v);
1512 
1513  // MULtiplication operators:
1514 
1515  friend sc_signed operator * (const sc_unsigned& u, const sc_signed& v);
1516  friend sc_signed operator * (const sc_signed& u, const sc_unsigned& v);
1517 
1518  friend sc_signed operator * (const sc_unsigned& u, int64 v);
1519  friend sc_signed operator * (const sc_unsigned& u, long v);
1520  friend sc_signed operator * (const sc_unsigned& u, int v)
1521  { return operator*(u, (long) v); }
1522 
1523  friend sc_signed operator * (int64 u, const sc_unsigned& v);
1524  friend sc_signed operator * (long u, const sc_unsigned& v);
1525  friend sc_signed operator * (int u, const sc_unsigned& v)
1526  { return operator*((long) u, v); }
1527 
1528  friend sc_signed operator * (const sc_signed& u, const sc_signed& v);
1529  friend sc_signed operator * (const sc_signed& u, int64 v);
1530  friend sc_signed operator * (const sc_signed& u, uint64 v);
1531  friend sc_signed operator * (const sc_signed& u, long v);
1532  friend sc_signed operator * (const sc_signed& u, unsigned long v);
1533  friend sc_signed operator * (const sc_signed& u, int v)
1534  { return operator*(u, (long) v); }
1535  friend sc_signed operator * (const sc_signed& u, unsigned int v)
1536  { return operator*(u, (unsigned long) v); }
1537 
1538  friend sc_signed operator * (int64 u, const sc_signed& v);
1539  friend sc_signed operator * (uint64 u, const sc_signed& v);
1540  friend sc_signed operator * (long u, const sc_signed& v);
1541  friend sc_signed operator * (unsigned long u, const sc_signed& v);
1542  friend sc_signed operator * (int u, const sc_signed& v)
1543  { return operator*((long) u, v); }
1544  friend sc_signed operator * (unsigned int u, const sc_signed& v)
1545  { return operator*((unsigned long) u, v); }
1546 
1547  const sc_signed& operator *= (const sc_signed& v);
1548  const sc_signed& operator *= (const sc_unsigned& v);
1549  const sc_signed& operator *= (int64 v);
1550  const sc_signed& operator *= (uint64 v);
1551  const sc_signed& operator *= (long v);
1552  const sc_signed& operator *= (unsigned long v);
1553  const sc_signed& operator *= (int v)
1554  { return operator*=((long) v); }
1555  const sc_signed& operator *= (unsigned int v)
1556  { return operator*=((unsigned long) v); }
1557 
1558  friend sc_signed operator * (const sc_unsigned& u, const sc_int_base& v);
1559  friend sc_signed operator * (const sc_int_base& u, const sc_unsigned& v);
1560  friend sc_signed operator * (const sc_signed& u, const sc_int_base& v);
1561  friend sc_signed operator * (const sc_signed& u, const sc_uint_base& v);
1562  friend sc_signed operator * (const sc_int_base& u, const sc_signed& v);
1563  friend sc_signed operator * (const sc_uint_base& u, const sc_signed& v);
1564  const sc_signed& operator *= (const sc_int_base& v);
1565  const sc_signed& operator *= (const sc_uint_base& v);
1566 
1567  // DIVision operators:
1568 
1569  friend sc_signed operator / (const sc_unsigned& u, const sc_signed& v);
1570  friend sc_signed operator / (const sc_signed& u, const sc_unsigned& v);
1571 
1572  friend sc_signed operator / (const sc_unsigned& u, int64 v);
1573  friend sc_signed operator / (const sc_unsigned& u, long v);
1574  friend sc_signed operator / (const sc_unsigned& u, int v)
1575  { return operator/(u, (long) v); }
1576 
1577  friend sc_signed operator / (int64 u, const sc_unsigned& v);
1578  friend sc_signed operator / (long u, const sc_unsigned& v);
1579  friend sc_signed operator / (int u, const sc_unsigned& v)
1580  { return operator/((long) u, v); }
1581 
1582  friend sc_signed operator / (const sc_signed& u, const sc_signed& v);
1583  friend sc_signed operator / (const sc_signed& u, int64 v);
1584  friend sc_signed operator / (const sc_signed& u, uint64 v);
1585  friend sc_signed operator / (const sc_signed& u, long v);
1586  friend sc_signed operator / (const sc_signed& u, unsigned long v);
1587  friend sc_signed operator / (const sc_signed& u, int v)
1588  { return operator/(u, (long) v); }
1589  friend sc_signed operator / (const sc_signed& u, unsigned int v)
1590  { return operator/(u, (unsigned long) v); }
1591 
1592  friend sc_signed operator / (int64 u, const sc_signed& v);
1593  friend sc_signed operator / (uint64 u, const sc_signed& v);
1594  friend sc_signed operator / (long u, const sc_signed& v);
1595  friend sc_signed operator / (unsigned long u, const sc_signed& v);
1596  friend sc_signed operator / (int u, const sc_signed& v)
1597  { return operator/((long) u, v); }
1598  friend sc_signed operator / (unsigned int u, const sc_signed& v)
1599  { return operator/((unsigned long) u, v); }
1600 
1601  const sc_signed& operator /= (const sc_signed& v);
1602  const sc_signed& operator /= (const sc_unsigned& v);
1603  const sc_signed& operator /= (int64 v);
1604  const sc_signed& operator /= (uint64 v);
1605  const sc_signed& operator /= (long v);
1606  const sc_signed& operator /= (unsigned long v);
1607  const sc_signed& operator /= (int v)
1608  { return operator/=((long) v); }
1609  const sc_signed& operator /= (unsigned int v)
1610  { return operator/=((unsigned long) v); }
1611 
1612  friend sc_signed operator / (const sc_unsigned& u, const sc_int_base& v);
1613  friend sc_signed operator / (const sc_int_base& u, const sc_unsigned& v);
1614  friend sc_signed operator / (const sc_signed& u, const sc_int_base& v);
1615  friend sc_signed operator / (const sc_signed& u, const sc_uint_base& v);
1616  friend sc_signed operator / (const sc_int_base& u, const sc_signed& v);
1617  friend sc_signed operator / (const sc_uint_base& u, const sc_signed& v);
1618  const sc_signed& operator /= (const sc_int_base& v);
1619  const sc_signed& operator /= (const sc_uint_base& v);
1620 
1621  // MODulo operators:
1622 
1623  friend sc_signed operator % (const sc_unsigned& u, const sc_signed& v);
1624  friend sc_signed operator % (const sc_signed& u, const sc_unsigned& v);
1625 
1626  friend sc_signed operator % (const sc_unsigned& u, int64 v);
1627  friend sc_signed operator % (const sc_unsigned& u, long v);
1628  friend sc_signed operator % (const sc_unsigned& u, int v)
1629  { return operator%(u, (long) v); }
1630 
1631  friend sc_signed operator % (int64 u, const sc_unsigned& v);
1632  friend sc_signed operator % (long u, const sc_unsigned& v);
1633  friend sc_signed operator % (int u, const sc_unsigned& v)
1634  { return operator%((long) u, v); }
1635 
1636  friend sc_signed operator % (const sc_signed& u, const sc_signed& v);
1637  friend sc_signed operator % (const sc_signed& u, int64 v);
1638  friend sc_signed operator % (const sc_signed& u, uint64 v);
1639  friend sc_signed operator % (const sc_signed& u, long v);
1640  friend sc_signed operator % (const sc_signed& u, unsigned long v);
1641  friend sc_signed operator % (const sc_signed& u, int v)
1642  { return operator%(u, (long) v); }
1643  friend sc_signed operator % (const sc_signed& u, unsigned int v)
1644  { return operator%(u, (unsigned long) v); }
1645 
1646  friend sc_signed operator % (int64 u, const sc_signed& v);
1647  friend sc_signed operator % (uint64 u, const sc_signed& v);
1648  friend sc_signed operator % (long u, const sc_signed& v);
1649  friend sc_signed operator % (unsigned long u, const sc_signed& v);
1650  friend sc_signed operator % (int u, const sc_signed& v)
1651  { return operator%((long) u, v); }
1652  friend sc_signed operator % (unsigned int u, const sc_signed& v)
1653  { return operator%((unsigned long) u, v); }
1654 
1655  const sc_signed& operator %= (const sc_signed& v);
1656  const sc_signed& operator %= (const sc_unsigned& v);
1657  const sc_signed& operator %= (int64 v);
1658  const sc_signed& operator %= (uint64 v);
1659  const sc_signed& operator %= (long v);
1660  const sc_signed& operator %= (unsigned long v);
1661  const sc_signed& operator %= (int v)
1662  { return operator%=((long) v); }
1663  const sc_signed& operator %= (unsigned int v)
1664  { return operator%=((unsigned long) v); }
1665 
1666  friend sc_signed operator % (const sc_unsigned& u, const sc_int_base& v);
1667  friend sc_signed operator % (const sc_int_base& u, const sc_unsigned& v);
1668  friend sc_signed operator % (const sc_signed& u, const sc_int_base& v);
1669  friend sc_signed operator % (const sc_signed& u, const sc_uint_base& v);
1670  friend sc_signed operator % (const sc_int_base& u, const sc_signed& v);
1671  friend sc_signed operator % (const sc_uint_base& u, const sc_signed& v);
1672  const sc_signed& operator %= (const sc_int_base& v);
1673  const sc_signed& operator %= (const sc_uint_base& v);
1674 
1675  // BITWISE OPERATORS:
1676 
1677  // Bitwise AND operators:
1678 
1679  friend sc_signed operator & (const sc_unsigned& u, const sc_signed& v);
1680  friend sc_signed operator & (const sc_signed& u, const sc_unsigned& v);
1681 
1682  friend sc_signed operator & (const sc_unsigned& u, int64 v);
1683  friend sc_signed operator & (const sc_unsigned& u, long v);
1684  friend sc_signed operator & (const sc_unsigned& u, int v)
1685  { return operator&(u, (long) v); }
1686 
1687  friend sc_signed operator & (int64 u, const sc_unsigned& v);
1688  friend sc_signed operator & (long u, const sc_unsigned& v);
1689  friend sc_signed operator & (int u, const sc_unsigned& v)
1690  { return operator&((long) u, v); }
1691 
1692  friend sc_signed operator & (const sc_signed& u, const sc_signed& v);
1693  friend sc_signed operator & (const sc_signed& u, int64 v);
1694  friend sc_signed operator & (const sc_signed& u, uint64 v);
1695  friend sc_signed operator & (const sc_signed& u, long v);
1696  friend sc_signed operator & (const sc_signed& u, unsigned long v);
1697  friend sc_signed operator & (const sc_signed& u, int v)
1698  { return operator&(u, (long) v); }
1699  friend sc_signed operator & (const sc_signed& u, unsigned int v)
1700  { return operator&(u, (unsigned long) v); }
1701 
1702  friend sc_signed operator & (int64 u, const sc_signed& v);
1703  friend sc_signed operator & (uint64 u, const sc_signed& v);
1704  friend sc_signed operator & (long u, const sc_signed& v);
1705  friend sc_signed operator & (unsigned long u, const sc_signed& v);
1706  friend sc_signed operator & (int u, const sc_signed& v)
1707  { return operator&((long) u, v); }
1708  friend sc_signed operator & (unsigned int u, const sc_signed& v)
1709  { return operator&((unsigned long) u, v); }
1710 
1711  const sc_signed& operator &= (const sc_signed& v);
1712  const sc_signed& operator &= (const sc_unsigned& v);
1713  const sc_signed& operator &= (int64 v);
1714  const sc_signed& operator &= (uint64 v);
1715  const sc_signed& operator &= (long v);
1716  const sc_signed& operator &= (unsigned long v);
1717  const sc_signed& operator &= (int v)
1718  { return operator&=((long) v); }
1719  const sc_signed& operator &= (unsigned int v)
1720  { return operator&=((unsigned long) v); }
1721 
1722  friend sc_signed operator & (const sc_unsigned& u, const sc_int_base& v);
1723  friend sc_signed operator & (const sc_int_base& u, const sc_unsigned& v);
1724  friend sc_signed operator & (const sc_signed& u, const sc_int_base& v);
1725  friend sc_signed operator & (const sc_signed& u, const sc_uint_base& v);
1726  friend sc_signed operator & (const sc_int_base& u, const sc_signed& v);
1727  friend sc_signed operator & (const sc_uint_base& u, const sc_signed& v);
1728  const sc_signed& operator &= (const sc_int_base& v);
1729  const sc_signed& operator &= (const sc_uint_base& v);
1730 
1731  // Bitwise OR operators:
1732 
1733  friend sc_signed operator | (const sc_unsigned& u, const sc_signed& v);
1734  friend sc_signed operator | (const sc_signed& u, const sc_unsigned& v);
1735 
1736  friend sc_signed operator | (const sc_unsigned& u, int64 v);
1737  friend sc_signed operator | (const sc_unsigned& u, long v);
1738  friend sc_signed operator | (const sc_unsigned& u, int v)
1739  { return operator|(u, (long) v); }
1740 
1741  friend sc_signed operator | (int64 u, const sc_unsigned& v);
1742  friend sc_signed operator | (long u, const sc_unsigned& v);
1743  friend sc_signed operator | (int u, const sc_unsigned& v)
1744  { return operator|((long) u, v); }
1745 
1746  friend sc_signed operator | (const sc_signed& u, const sc_signed& v);
1747  friend sc_signed operator | (const sc_signed& u, int64 v);
1748  friend sc_signed operator | (const sc_signed& u, uint64 v);
1749  friend sc_signed operator | (const sc_signed& u, long v);
1750  friend sc_signed operator | (const sc_signed& u, unsigned long v);
1751  friend sc_signed operator | (const sc_signed& u, int v)
1752  { return operator|(u, (long) v); }
1753  friend sc_signed operator | (const sc_signed& u, unsigned int v)
1754  { return operator|(u, (unsigned long) v); }
1755 
1756  friend sc_signed operator | (int64 u, const sc_signed& v);
1757  friend sc_signed operator | (uint64 u, const sc_signed& v);
1758  friend sc_signed operator | (long u, const sc_signed& v);
1759  friend sc_signed operator | (unsigned long u, const sc_signed& v);
1760  friend sc_signed operator | (int u, const sc_signed& v)
1761  { return operator|((long) u, v); }
1762  friend sc_signed operator | (unsigned int u, const sc_signed& v)
1763  { return operator|((unsigned long) u, v); }
1764 
1765  const sc_signed& operator |= (const sc_signed& v);
1766  const sc_signed& operator |= (const sc_unsigned& v);
1767  const sc_signed& operator |= (int64 v);
1768  const sc_signed& operator |= (uint64 v);
1769  const sc_signed& operator |= (long v);
1770  const sc_signed& operator |= (unsigned long v);
1771  const sc_signed& operator |= (int v)
1772  { return operator|=((long) v); }
1773  const sc_signed& operator |= (unsigned int v)
1774  { return operator|=((unsigned long) v); }
1775 
1776  friend sc_signed operator | (const sc_unsigned& u, const sc_int_base& v);
1777  friend sc_signed operator | (const sc_int_base& u, const sc_unsigned& v);
1778  friend sc_signed operator | (const sc_signed& u, const sc_int_base& v);
1779  friend sc_signed operator | (const sc_signed& u, const sc_uint_base& v);
1780  friend sc_signed operator | (const sc_int_base& u, const sc_signed& v);
1781  friend sc_signed operator | (const sc_uint_base& u, const sc_signed& v);
1782  const sc_signed& operator |= (const sc_int_base& v);
1783  const sc_signed& operator |= (const sc_uint_base& v);
1784 
1785  // Bitwise XOR operators:
1786 
1787  friend sc_signed operator ^ (const sc_unsigned& u, const sc_signed& v);
1788  friend sc_signed operator ^ (const sc_signed& u, const sc_unsigned& v);
1789 
1790  friend sc_signed operator ^ (const sc_unsigned& u, int64 v);
1791  friend sc_signed operator ^ (const sc_unsigned& u, long v);
1792  friend sc_signed operator ^ (const sc_unsigned& u, int v)
1793  { return operator^(u, (long) v); }
1794 
1795  friend sc_signed operator ^ (int64 u, const sc_unsigned& v);
1796  friend sc_signed operator ^ (long u, const sc_unsigned& v);
1797  friend sc_signed operator ^ (int u, const sc_unsigned& v)
1798  { return operator^((long) u, v); }
1799 
1800  friend sc_signed operator ^ (const sc_signed& u, const sc_signed& v);
1801  friend sc_signed operator ^ (const sc_signed& u, int64 v);
1802  friend sc_signed operator ^ (const sc_signed& u, uint64 v);
1803  friend sc_signed operator ^ (const sc_signed& u, long v);
1804  friend sc_signed operator ^ (const sc_signed& u, unsigned long v);
1805  friend sc_signed operator ^ (const sc_signed& u, int v)
1806  { return operator^(u, (long) v); }
1807  friend sc_signed operator ^ (const sc_signed& u, unsigned int v)
1808  { return operator^(u, (unsigned long) v); }
1809 
1810  friend sc_signed operator ^ (int64 u, const sc_signed& v);
1811  friend sc_signed operator ^ (uint64 u, const sc_signed& v);
1812  friend sc_signed operator ^ (long u, const sc_signed& v);
1813  friend sc_signed operator ^ (unsigned long u, const sc_signed& v);
1814  friend sc_signed operator ^ (int u, const sc_signed& v)
1815  { return operator^((long) u, v); }
1816  friend sc_signed operator ^ (unsigned int u, const sc_signed& v)
1817  { return operator^((unsigned long) u, v); }
1818 
1819  const sc_signed& operator ^= (const sc_signed& v);
1820  const sc_signed& operator ^= (const sc_unsigned& v);
1821  const sc_signed& operator ^= (int64 v);
1822  const sc_signed& operator ^= (uint64 v);
1823  const sc_signed& operator ^= (long v);
1824  const sc_signed& operator ^= (unsigned long v);
1825  const sc_signed& operator ^= (int v)
1826  { return operator^=((long) v); }
1827  const sc_signed& operator ^= (unsigned int v)
1828  { return operator^=((unsigned long) v); }
1829 
1830  friend sc_signed operator ^ (const sc_unsigned& u, const sc_int_base& v);
1831  friend sc_signed operator ^ (const sc_int_base& u, const sc_unsigned& v);
1832  friend sc_signed operator ^ (const sc_signed& u, const sc_int_base& v);
1833  friend sc_signed operator ^ (const sc_signed& u, const sc_uint_base& v);
1834  friend sc_signed operator ^ (const sc_int_base& u, const sc_signed& v);
1835  friend sc_signed operator ^ (const sc_uint_base& u, const sc_signed& v);
1836  const sc_signed& operator ^= (const sc_int_base& v);
1837  const sc_signed& operator ^= (const sc_uint_base& v);
1838 
1839  // SHIFT OPERATORS:
1840 
1841  // LEFT SHIFT operators:
1842 
1843  friend sc_unsigned operator << (const sc_unsigned& u, const sc_signed& v);
1844  friend sc_signed operator << (const sc_signed& u, const sc_unsigned& v);
1845 
1846  friend sc_signed operator << (const sc_signed& u, const sc_signed& v);
1847  friend sc_signed operator << (const sc_signed& u, int64 v);
1848  friend sc_signed operator << (const sc_signed& u, uint64 v);
1849  friend sc_signed operator << (const sc_signed& u, long v);
1850  friend sc_signed operator << (const sc_signed& u, unsigned long v);
1851  friend sc_signed operator << (const sc_signed& u, int v)
1852  { return operator<<(u, (long) v); }
1853  friend sc_signed operator << (const sc_signed& u, unsigned int v)
1854  { return operator<<(u, (unsigned long) v); }
1855 
1856  const sc_signed& operator <<= (const sc_signed& v);
1857  const sc_signed& operator <<= (const sc_unsigned& v);
1858  const sc_signed& operator <<= (int64 v);
1859  const sc_signed& operator <<= (uint64 v);
1860  const sc_signed& operator <<= (long v);
1861  const sc_signed& operator <<= (unsigned long v);
1862  const sc_signed& operator <<= (int v)
1863  { return operator<<=((long) v); }
1864  const sc_signed& operator <<= (unsigned int v)
1865  { return operator<<=((unsigned long) v); }
1866 
1867  friend sc_signed operator << (const sc_signed& u, const sc_int_base& v);
1868  friend sc_signed operator << (const sc_signed& u, const sc_uint_base& v);
1869  const sc_signed& operator <<= (const sc_int_base& v);
1870  const sc_signed& operator <<= (const sc_uint_base& v);
1871 
1872  // RIGHT SHIFT operators:
1873 
1874  friend sc_unsigned operator >> (const sc_unsigned& u, const sc_signed& v);
1875  friend sc_signed operator >> (const sc_signed& u, const sc_unsigned& v);
1876 
1877  friend sc_signed operator >> (const sc_signed& u, const sc_signed& v);
1878  friend sc_signed operator >> (const sc_signed& u, int64 v);
1879  friend sc_signed operator >> (const sc_signed& u, uint64 v);
1880  friend sc_signed operator >> (const sc_signed& u, long v);
1881  friend sc_signed operator >> (const sc_signed& u, unsigned long v);
1882  friend sc_signed operator >> (const sc_signed& u, int v)
1883  { return operator>>(u, (long) v); }
1884  friend sc_signed operator >> (const sc_signed& u, unsigned int v)
1885  { return operator>>(u, (unsigned long) v); }
1886 
1887  const sc_signed& operator >>= (const sc_signed& v);
1888  const sc_signed& operator >>= (const sc_unsigned& v);
1889  const sc_signed& operator >>= (int64 v);
1890  const sc_signed& operator >>= (uint64 v);
1891  const sc_signed& operator >>= (long v);
1892  const sc_signed& operator >>= (unsigned long v);
1893  const sc_signed& operator >>= (int v)
1894  { return operator>>=((long) v); }
1895  const sc_signed& operator >>= (unsigned int v)
1896  { return operator>>=((unsigned long) v); }
1897 
1898  friend sc_signed operator >> (const sc_signed& u, const sc_int_base& v);
1899  friend sc_signed operator >> (const sc_signed& u, const sc_uint_base& v);
1900  const sc_signed& operator >>= (const sc_int_base& v);
1901  const sc_signed& operator >>= (const sc_uint_base& v);
1902 
1903  // Unary arithmetic operators
1904  friend sc_signed operator + (const sc_signed& u);
1905  friend sc_signed operator - (const sc_signed& u);
1906  friend sc_signed operator - (const sc_unsigned& u);
1907 
1908  // LOGICAL OPERATORS:
1909 
1910  // Logical EQUAL operators:
1911 
1912  friend bool operator == (const sc_unsigned& u, const sc_signed& v);
1913  friend bool operator == (const sc_signed& u, const sc_unsigned& v);
1914 
1915  friend bool operator == (const sc_signed& u, const sc_signed& v);
1916  friend bool operator == (const sc_signed& u, int64 v);
1917  friend bool operator == (const sc_signed& u, uint64 v);
1918  friend bool operator == (const sc_signed& u, long v);
1919  friend bool operator == (const sc_signed& u, unsigned long v);
1920  friend bool operator == (const sc_signed& u, int v)
1921  { return operator==(u, (long) v); }
1922  friend bool operator == (const sc_signed& u, unsigned int v)
1923  { return operator==(u, (unsigned long) v); }
1924 
1925  friend bool operator == (int64 u, const sc_signed& v);
1926  friend bool operator == (uint64 u, const sc_signed& v);
1927  friend bool operator == (long u, const sc_signed& v);
1928  friend bool operator == (unsigned long u, const sc_signed& v);
1929  friend bool operator == (int u, const sc_signed& v)
1930  { return operator==((long) u, v); }
1931  friend bool operator == (unsigned int u, const sc_signed& v)
1932  { return operator==((unsigned long) u, v); }
1933 
1934  friend bool operator == (const sc_signed& u, const sc_int_base& v);
1935  friend bool operator == (const sc_signed& u, const sc_uint_base& v);
1936  friend bool operator == (const sc_int_base& u, const sc_signed& v);
1937  friend bool operator == (const sc_uint_base& u, const sc_signed& v);
1938 
1939  // Logical NOT_EQUAL operators:
1940 
1941  friend bool operator != (const sc_unsigned& u, const sc_signed& v);
1942  friend bool operator != (const sc_signed& u, const sc_unsigned& v);
1943 
1944  friend bool operator != (const sc_signed& u, const sc_signed& v);
1945  friend bool operator != (const sc_signed& u, int64 v);
1946  friend bool operator != (const sc_signed& u, uint64 v);
1947  friend bool operator != (const sc_signed& u, long v);
1948  friend bool operator != (const sc_signed& u, unsigned long v);
1949  friend bool operator != (const sc_signed& u, int v)
1950  { return operator!=(u, (long) v); }
1951  friend bool operator != (const sc_signed& u, unsigned int v)
1952  { return operator!=(u, (unsigned long) v); }
1953 
1954  friend bool operator != (int64 u, const sc_signed& v);
1955  friend bool operator != (uint64 u, const sc_signed& v);
1956  friend bool operator != (long u, const sc_signed& v);
1957  friend bool operator != (unsigned long u, const sc_signed& v);
1958  friend bool operator != (int u, const sc_signed& v)
1959  { return operator!=((long) u, v); }
1960  friend bool operator != (unsigned int u, const sc_signed& v)
1961  { return operator!=((unsigned long) u, v); }
1962 
1963  friend bool operator != (const sc_signed& u, const sc_int_base& v);
1964  friend bool operator != (const sc_signed& u, const sc_uint_base& v);
1965  friend bool operator != (const sc_int_base& u, const sc_signed& v);
1966  friend bool operator != (const sc_uint_base& u, const sc_signed& v);
1967 
1968  // Logical LESS_THAN operators:
1969 
1970  friend bool operator < (const sc_unsigned& u, const sc_signed& v);
1971  friend bool operator < (const sc_signed& u, const sc_unsigned& v);
1972 
1973  friend bool operator < (const sc_signed& u, const sc_signed& v);
1974  friend bool operator < (const sc_signed& u, int64 v);
1975  friend bool operator < (const sc_signed& u, uint64 v);
1976  friend bool operator < (const sc_signed& u, long v);
1977  friend bool operator < (const sc_signed& u, unsigned long v);
1978  friend bool operator < (const sc_signed& u, int v)
1979  { return operator<(u, (long) v); }
1980  friend bool operator < (const sc_signed& u, unsigned int v)
1981  { return operator<(u, (unsigned long) v); }
1982 
1983  friend bool operator < (int64 u, const sc_signed& v);
1984  friend bool operator < (uint64 u, const sc_signed& v);
1985  friend bool operator < (long u, const sc_signed& v);
1986  friend bool operator < (unsigned long u, const sc_signed& v);
1987  friend bool operator < (int u, const sc_signed& v)
1988  { return operator<((long) u, v); }
1989  friend bool operator < (unsigned int u, const sc_signed& v)
1990  { return operator<((unsigned long) u, v); }
1991 
1992  friend bool operator < (const sc_signed& u, const sc_int_base& v);
1993  friend bool operator < (const sc_signed& u, const sc_uint_base& v);
1994  friend bool operator < (const sc_int_base& u, const sc_signed& v);
1995  friend bool operator < (const sc_uint_base& u, const sc_signed& v);
1996 
1997  // Logical LESS_THAN_AND_EQUAL operators:
1998 
1999  friend bool operator <= (const sc_unsigned& u, const sc_signed& v);
2000  friend bool operator <= (const sc_signed& u, const sc_unsigned& v);
2001 
2002  friend bool operator <= (const sc_signed& u, const sc_signed& v);
2003  friend bool operator <= (const sc_signed& u, int64 v);
2004  friend bool operator <= (const sc_signed& u, uint64 v);
2005  friend bool operator <= (const sc_signed& u, long v);
2006  friend bool operator <= (const sc_signed& u, unsigned long v);
2007  friend bool operator <= (const sc_signed& u, int v)
2008  { return operator<=(u, (long) v); }
2009  friend bool operator <= (const sc_signed& u, unsigned int v)
2010  { return operator<=(u, (unsigned long) v); }
2011 
2012  friend bool operator <= (int64 u, const sc_signed& v);
2013  friend bool operator <= (uint64 u, const sc_signed& v);
2014  friend bool operator <= (long u, const sc_signed& v);
2015  friend bool operator <= (unsigned long u, const sc_signed& v);
2016  friend bool operator <= (int u, const sc_signed& v)
2017  { return operator<=((long) u, v); }
2018  friend bool operator <= (unsigned int u, const sc_signed& v)
2019  { return operator<=((unsigned long) u, v); }
2020 
2021  friend bool operator <= (const sc_signed& u, const sc_int_base& v);
2022  friend bool operator <= (const sc_signed& u, const sc_uint_base& v);
2023  friend bool operator <= (const sc_int_base& u, const sc_signed& v);
2024  friend bool operator <= (const sc_uint_base& u, const sc_signed& v);
2025 
2026  // Logical GREATER_THAN operators:
2027 
2028  friend bool operator > (const sc_unsigned& u, const sc_signed& v);
2029  friend bool operator > (const sc_signed& u, const sc_unsigned& v);
2030 
2031  friend bool operator > (const sc_signed& u, const sc_signed& v);
2032  friend bool operator > (const sc_signed& u, int64 v);
2033  friend bool operator > (const sc_signed& u, uint64 v);
2034  friend bool operator > (const sc_signed& u, long v);
2035  friend bool operator > (const sc_signed& u, unsigned long v);
2036  friend bool operator > (const sc_signed& u, int v)
2037  { return operator>(u, (long) v); }
2038  friend bool operator > (const sc_signed& u, unsigned int v)
2039  { return operator>(u, (unsigned long) v); }
2040 
2041  friend bool operator > (int64 u, const sc_signed& v);
2042  friend bool operator > (uint64 u, const sc_signed& v);
2043  friend bool operator > (long u, const sc_signed& v);
2044  friend bool operator > (unsigned long u, const sc_signed& v);
2045  friend bool operator > (int u, const sc_signed& v)
2046  { return operator>((long) u, v); }
2047  friend bool operator > (unsigned int u, const sc_signed& v)
2048  { return operator>((unsigned long) u, v); }
2049 
2050  friend bool operator > (const sc_signed& u, const sc_int_base& v);
2051  friend bool operator > (const sc_signed& u, const sc_uint_base& v);
2052  friend bool operator > (const sc_int_base& u, const sc_signed& v);
2053  friend bool operator > (const sc_uint_base& u, const sc_signed& v);
2054 
2055  // Logical GREATER_THAN_AND_EQUAL operators:
2056 
2057  friend bool operator >= (const sc_unsigned& u, const sc_signed& v);
2058  friend bool operator >= (const sc_signed& u, const sc_unsigned& v);
2059 
2060  friend bool operator >= (const sc_signed& u, const sc_signed& v);
2061  friend bool operator >= (const sc_signed& u, int64 v);
2062  friend bool operator >= (const sc_signed& u, uint64 v);
2063  friend bool operator >= (const sc_signed& u, long v);
2064  friend bool operator >= (const sc_signed& u, unsigned long v);
2065  friend bool operator >= (const sc_signed& u, int v)
2066  { return operator>=(u, (long) v); }
2067  friend bool operator >= (const sc_signed& u, unsigned int v)
2068  { return operator>=(u, (unsigned long) v); }
2069 
2070  friend bool operator >= (int64 u, const sc_signed& v);
2071  friend bool operator >= (uint64 u, const sc_signed& v);
2072  friend bool operator >= (long u, const sc_signed& v);
2073  friend bool operator >= (unsigned long u, const sc_signed& v);
2074  friend bool operator >= (int u, const sc_signed& v)
2075  { return operator>=((long) u, v); }
2076  friend bool operator >= (unsigned int u, const sc_signed& v)
2077  { return operator>=((unsigned long) u, v); }
2078 
2079  friend bool operator >= (const sc_signed& u, const sc_int_base& v);
2080  friend bool operator >= (const sc_signed& u, const sc_uint_base& v);
2081  friend bool operator >= (const sc_int_base& u, const sc_signed& v);
2082  friend bool operator >= (const sc_uint_base& u, const sc_signed& v);
2083 
2084  // Bitwise NOT operator (unary).
2085  friend sc_signed operator ~ (const sc_signed& u);
2086 
2087  // Helper functions.
2089  int unb,
2090  int und,
2091  const sc_digit *ud,
2092  small_type vs,
2093  int vnb,
2094  int vnd,
2095  const sc_digit *vd);
2096 
2098  int unb,
2099  int und,
2100  const sc_digit *ud,
2101  small_type vs,
2102  int vnb,
2103  int vnd,
2104  const sc_digit *vd);
2105 
2107  int unb,
2108  int und,
2109  const sc_digit *ud,
2110  int vnb,
2111  int vnd,
2112  const sc_digit *vd);
2113 
2115  int unb,
2116  int und,
2117  const sc_digit *ud,
2118  int vnb,
2119  int vnd,
2120  const sc_digit *vd);
2121 
2123  int unb,
2124  int und,
2125  const sc_digit *ud,
2126  int vnb,
2127  int vnd,
2128  const sc_digit *vd);
2129 
2131  int unb,
2132  int und,
2133  const sc_digit *ud,
2134  small_type vs,
2135  int vnb,
2136  int vnd,
2137  const sc_digit *vd);
2138 
2140  int unb,
2141  int und,
2142  const sc_digit *ud,
2143  small_type vs,
2144  int vnb,
2145  int vnd,
2146  const sc_digit *vd);
2147 
2149  int unb,
2150  int und,
2151  const sc_digit *ud,
2152  small_type vs,
2153  int vnb,
2154  int vnd,
2155  const sc_digit *vd);
2156 
2157 private:
2158 
2159  small_type sgn; // Shortened as s.
2160  int nbits; // Shortened as nb.
2161  int ndigits; // Shortened as nd.
2162 
2163 #ifdef SC_MAX_NBITS
2164  sc_digit digit[DIV_CEIL(SC_MAX_NBITS)]; // Shortened as d.
2165 #else
2166  sc_digit *digit; // Shortened as d.
2167 #endif
2168 
2169  // Private constructors:
2170 
2171  // Create a copy of v with sign s.
2172  sc_signed(const sc_signed& v, small_type s);
2173  sc_signed(const sc_unsigned& v, small_type s);
2174 
2175  // Create a signed number with the given attributes.
2176  sc_signed(small_type s, int nb, int nd,
2177  sc_digit *d, bool alloc = true);
2178 
2179  // Create an unsigned number using the bits u[l..r].
2180  sc_signed(const sc_signed* u, int l, int r);
2181  sc_signed(const sc_unsigned* u, int l, int r);
2182 
2183  // Private member functions. The called functions are inline functions.
2184 
2185  small_type default_sign() const
2186  { return SC_NOSIGN; }
2187 
2188  int num_bits(int nb) const { return nb; }
2189 
2190  bool check_if_outside(int bit_num) const;
2191 
2192  void copy_digits(int nb, int nd, const sc_digit *d)
2193  { copy_digits_signed(sgn, nbits, ndigits, digit, nb, nd, d); }
2194 
2195  void makezero()
2196  { sgn = make_zero(ndigits, digit); }
2197 
2198  // Conversion functions between 2's complement (2C) and
2199  // sign-magnitude (SM):
2200  void convert_2C_to_SM()
2201  { sgn = convert_signed_2C_to_SM(nbits, ndigits, digit); }
2202 
2203  void convert_SM_to_2C_to_SM()
2204  { sgn = convert_signed_SM_to_2C_to_SM(sgn, nbits, ndigits, digit); }
2205 
2206  void convert_SM_to_2C()
2207  { convert_signed_SM_to_2C(sgn, ndigits, digit); }
2208 
2209 };
2210 
2211 
2212 
2213 inline
2214 ::std::ostream&
2215 operator << ( ::std::ostream&, const sc_signed& );
2216 
2217 inline
2218 ::std::istream&
2219 operator >> ( ::std::istream&, sc_signed& );
2220 
2221 
2222 
2223 inline
2224 ::std::ostream&
2225 operator << ( ::std::ostream& os, const sc_signed_bitref_r& a )
2226 {
2227  a.print( os );
2228  return os;
2229 }
2230 
2231 
2232 inline
2233 ::std::istream&
2234 operator >> ( ::std::istream& is, sc_signed_bitref& a )
2235 {
2236  a.scan( is );
2237  return is;
2238 }
2239 
2240 
2241 // ----------------------------------------------------------------------------
2242 // CLASS : sc_signed_subref_r
2243 //
2244 // Proxy class for sc_signed part selection (r-value only).
2245 // ----------------------------------------------------------------------------
2246 
2247 
2248 // reduce methods
2249 
2251 {
2252  const sc_signed* target_p = m_obj_p;
2253  for ( int i = m_right; i <= m_left; i++ )
2254  if ( !target_p->test(i) ) return false;
2255  return true;
2256 }
2257 
2259 {
2260  return !and_reduce();
2261 }
2262 
2264 {
2265  const sc_signed* target_p = m_obj_p;
2266  for ( int i = m_right; i <= m_left; i++ )
2267  if ( target_p->test(i) ) return true;
2268  return false;
2269 }
2270 
2272 {
2273  return !or_reduce();
2274 }
2275 
2277 {
2278  int odd;
2279  const sc_signed* target_p = m_obj_p;
2280  odd = 0;
2281  for ( int i = m_right; i <= m_left; i++ )
2282  if ( target_p->test(i) ) odd = ~odd;
2283  return odd ? true : false;
2284 }
2285 
2287 {
2288  return !xor_reduce();
2289 }
2290 
2291 inline
2292 ::std::ostream&
2293 operator << ( ::std::ostream& os, const sc_signed_subref_r& a )
2294 {
2295  a.print( os );
2296  return os;
2297 }
2298 
2299 
2300 // ----------------------------------------------------------------------------
2301 // CLASS : sc_signed_subref
2302 //
2303 // Proxy class for sc_signed part selection (r-value and l-value).
2304 // ----------------------------------------------------------------------------
2305 
2306 // assignment operators
2307 
2308 inline
2309 const sc_signed_subref&
2311 {
2312  sc_signed aa( length() );
2313  return ( *this = aa = a );
2314 }
2315 
2316 
2317 
2318 
2319 inline
2320 ::std::istream&
2321 operator >> ( ::std::istream& is, sc_signed_subref& a )
2322 {
2323  a.scan( is );
2324  return is;
2325 }
2326 
2327 
2328 
2329 // ----------------------------------------------------------------------------
2330 // CLASS : sc_signed
2331 //
2332 // Arbitrary precision signed number.
2333 // ----------------------------------------------------------------------------
2334 
2335 template<class T>
2337 {
2338  int nb = v->length();
2339  sgn = default_sign();
2340  if( nb > 0 ) {
2341  nbits = num_bits( nb );
2342  } else {
2343  char msg[BUFSIZ];
2344  std::sprintf( msg,
2345  "sc_unsigned( sc_generic_base<T> ) : nb = %d is not valid", nb);
2346  SC_REPORT_ERROR( sc_core::SC_ID_INIT_FAILED_, msg );
2347  }
2348  ndigits = DIV_CEIL(nbits);
2349 # ifdef SC_MAX_NBITS
2350  test_bound(nb);
2351 # else
2352  digit = new sc_digit[ndigits];
2353 # endif
2354  makezero();
2355  v->to_sc_signed(*this);
2356 }
2357 
2358 
2359 
2360 inline
2361 ::std::ostream&
2362 operator << ( ::std::ostream& os, const sc_signed& a )
2363 {
2364  a.print( os );
2365  return os;
2366 }
2367 
2368 inline
2369 ::std::istream&
2370 operator >> ( ::std::istream& is, sc_signed& a )
2371 {
2372  a.scan( is );
2373  return is;
2374 }
2375 
2376 
2377 } // namespace sc_dt
2378 
2379 
2380 #endif
bool operator>(const sc_int_base &a, const sc_int_base &b)
Definition: sc_int_base.h:727
const sc_signed_subref_r & range(int i, int j) const
Definition: sc_signed.h:1263
void set(int i)
void convert_signed_SM_to_2C(small_type s, int nd, sc_digit *d)
Definition: sc_nbutils.h:882
friend sc_unsigned operator<<(const sc_unsigned &u, const sc_signed &v)
sc_signed & operator++()
sc_signed_bitref & operator[](int i)
Definition: sc_signed.h:1194
const sc_bit operator~(const sc_bit &a)
Definition: sc_bit.h:310
bool sc_io_show_base(systemc_ostream &)
Definition: sc_nbutils.h:112
friend class sc_signed_signal
Definition: sc_signed.h:894
const sc_bit operator|(const sc_bit &a, const sc_bit &b)
Definition: sc_bit.h:332
#define SC_NOSIGN
Definition: sc_nbdefs.h:112
void convert_SM_to_2C(small_type s, int nd, sc_digit *d)
Definition: sc_nbutils.h:798
friend sc_signed mod_signed_friend(small_type us, int unb, int und, const sc_digit *ud, int vnb, int vnd, const sc_digit *vd)
void check_index(int i) const
Definition: sc_signed.h:1189
sc_signed operator+(const sc_unsigned &u, const sc_signed &v)
sc_numrep sc_io_base(systemc_ostream &, sc_numrep)
Definition: sc_nbutils.h:107
const sc_fxval operator/(const sc_fxnum &a, const sc_fxnum &b)
Definition: sc_fxnum.h:2782
void print(::std::ostream &os=::std::cout) const
Definition: sc_signed.h:977
sc_numrep
Definition: sc_nbdefs.h:91
unsigned int sc_digit
Definition: sc_nbdefs.h:173
sc_signed_subref(const sc_signed_subref &a)
Definition: sc_signed.h:1020
friend bool operator>=(const sc_unsigned &u, const sc_signed &v)
const sc_signed & operator+=(const sc_signed &v)
long to_long() const
const sc_signed & operator|=(const sc_signed &v)
const sc_signed & operator-=(const sc_signed &v)
friend sc_signed sub_signed_friend(small_type us, int unb, int und, const sc_digit *ud, small_type vs, int vnb, int vnd, const sc_digit *vd)
static sc_core::sc_vpool< sc_signed_subref > m_pool
Definition: sc_signed.h:1069
uint64_t uint64
Definition: sc_nbdefs.h:183
virtual void concat_set(int64 src, int low_i)
const sc_signed_bitref & operator|=(bool)
friend class sc_unsigned
Definition: sc_signed.h:895
uint64 to_uint64() const
bool operator<(const sc_int_base &a, const sc_int_base &b)
Definition: sc_int_base.h:721
const sc_signed_bitref & operator^=(bool)
sc_signed and_signed_friend(small_type us, int unb, int und, const sc_digit *ud, small_type vs, int vnb, int vnd, const sc_digit *vd)
void set_packed_rep(sc_digit *buf)
bool and_reduce() const
sc_digit * get_raw() const
Definition: sc_signed.h:1164
inline::std::istream & operator>>(::std::istream &is, sc_bit &a)
Definition: sc_bit.h:394
#define BITS_PER_DIGIT
Definition: sc_nbdefs.h:137
friend sc_signed operator^(const sc_unsigned &u, const sc_signed &v)
virtual uint64 concat_get_uint64() const
Definition: sc_signed.h:773
sc_signed_bitref(const sc_signed_bitref &a)
Definition: sc_signed.h:848
uint64 to_uint64() const
bool or_reduce() const
const sc_signed & operator>>=(const sc_signed &v)
sc_signed_subref & range(int i, int j)
Definition: sc_signed.h:1254
bool operator>=(const sc_int_base &a, const sc_int_base &b)
Definition: sc_int_base.h:730
friend bool operator!=(const sc_unsigned &u, const sc_signed &v)
virtual ~sc_signed()
Definition: sc_signed.h:1155
const std::string to_string(sc_numrep numrep=SC_DEC) const
const std::string to_string(sc_numrep numrep=SC_DEC) const
virtual bool concat_get_data(sc_digit *dst_p, int low_i) const
Definition: sc_signed.h:782
void invert(int i)
Definition: sc_signed.h:1353
int64_t int64
Definition: sc_nbdefs.h:182
virtual bool concat_get_data(sc_digit *dst_p, int low_i) const
friend sc_signed add_signed_friend(small_type us, int unb, int und, const sc_digit *ud, small_type vs, int vnb, int vnd, const sc_digit *vd)
void clear(int i)
void check_range(int l, int r) const
Definition: sc_signed.h:1240
const sc_bit operator&(const sc_bit &a, const sc_bit &b)
Definition: sc_bit.h:329
friend sc_signed and_signed_friend(small_type us, int unb, int und, const sc_digit *ud, small_type vs, int vnb, int vnd, const sc_digit *vd)
sc_signed_subref & operator()(int i, int j)
Definition: sc_signed.h:1272
friend sc_signed operator/(const sc_unsigned &u, const sc_signed &v)
void set(int i, bool v)
Definition: sc_signed.h:1351
virtual int concat_length(bool *xz_present_p) const
Definition: sc_signed.h:771
void get_packed_rep(sc_digit *buf) const
friend class sc_unsigned
Definition: sc_signed.h:1092
virtual ~sc_signed_bitref_r()
Definition: sc_signed.h:739
friend sc_signed div_signed_friend(small_type s, int unb, int und, const sc_digit *ud, int vnb, int vnd, const sc_digit *vd)
bool nor_reduce() const
Definition: sc_signed.h:1339
double to_double() const
int small_type
Definition: sc_nbdefs.h:118
void scan(::std::istream &is=::std::cin)
friend sc_signed mul_signed_friend(small_type s, int unb, int und, const sc_digit *ud, int vnb, int vnd, const sc_digit *vd)
friend sc_signed operator%(const sc_unsigned &u, const sc_signed &v)
const sc_signed & operator&=(const sc_signed &v)
const sc_signed & operator/=(const sc_signed &v)
bool xnor_reduce() const
Definition: sc_signed.h:1344
sc_signed_subref_r(const sc_signed_subref_r &a)
Definition: sc_signed.h:921
const sc_bit operator^(const sc_bit &a, const sc_bit &b)
Definition: sc_bit.h:335
sc_signed div_signed_friend(small_type s, int unb, int und, const sc_digit *ud, int vnb, int vnd, const sc_digit *vd)
int64 to_int64() const
bool xor_reduce() const
unsigned long to_ulong() const
friend sc_unsigned operator>>(const sc_unsigned &u, const sc_signed &v)
double to_double() const
const sc_signed & operator<<=(const sc_signed &v)
int length() const
Definition: sc_signed.h:1326
bool test(int i) const
bool sign() const
void initialize(const sc_signed *obj_p, int index_)
Definition: sc_signed.h:729
const sc_signed_bitref & operator&=(bool)
sc_signed mod_signed_friend(small_type us, int unb, int und, const sc_digit *ud, int vnb, int vnd, const sc_digit *vd)
sc_signed_bitref_r(const sc_signed_bitref_r &a)
Definition: sc_signed.h:744
bool xor_reduce() const
Definition: sc_signed.h:2276
friend sc_signed or_signed_friend(small_type us, int unb, int und, const sc_digit *ud, small_type vs, int vnb, int vnd, const sc_digit *vd)
friend sc_signed operator|(const sc_unsigned &u, const sc_signed &v)
void print(::std::ostream &os=::std::cout) const
Definition: sc_signed.h:803
sc_signed sub_signed_friend(small_type us, int unb, int und, const sc_digit *ud, small_type vs, int vnb, int vnd, const sc_digit *vd)
void scan(::std::istream &is=::std::cin)
#define DIV_CEIL(x)
Definition: sc_nbdefs.h:154
friend bool operator>(const sc_unsigned &u, const sc_signed &v)
friend sc_signed operator+(const sc_unsigned &u, const sc_signed &v)
friend bool operator<=(const sc_unsigned &u, const sc_signed &v)
void copy_digits_signed(small_type &us, int unb, int und, sc_digit *ud, int vnb, int vnd, const sc_digit *vd)
Definition: sc_nbutils.h:954
small_type convert_signed_SM_to_2C_to_SM(small_type s, int nb, int nd, sc_digit *d)
Definition: sc_nbutils.h:863
int to_int() const
unsigned int to_uint() const
sc_signed add_signed_friend(small_type us, int unb, int und, const sc_digit *ud, small_type vs, int vnb, int vnd, const sc_digit *vd)
const sc_signed_subref & operator=(const sc_signed_subref_r &a)
sc_signed xor_signed_friend(small_type us, int unb, int und, const sc_digit *ud, small_type vs, int vnb, int vnd, const sc_digit *vd)
small_type make_zero(int nd, sc_digit *d)
Definition: sc_nbutils.h:754
virtual int concat_length(bool *xz_present_p) const
Definition: sc_signed.h:1166
bool operator!=(const sc_bit &a, const sc_bit &b)
Definition: sc_bit.h:286
const sc_signed & operator^=(const sc_signed &v)
friend sc_signed operator*(const sc_unsigned &u, const sc_signed &v)
sc_signed(int nb=sc_length_param().len())
bool xnor_reduce() const
Definition: sc_signed.h:2286
virtual bool concat_get_ctrl(sc_digit *dst_p, int low_i) const
bool nor_reduce() const
Definition: sc_signed.h:2271
bool nand_reduce() const
Definition: sc_signed.h:1334
friend sc_signed operator&(const sc_unsigned &u, const sc_signed &v)
virtual uint64 concat_get_uint64() const
friend bool operator<(const sc_unsigned &u, const sc_signed &v)
sc_signed operator%(const sc_unsigned &u, const sc_signed &v)
void dump(::std::ostream &os=::std::cout) const
void scan(::std::istream &is=::std::cin)
virtual uint64 concat_get_uint64() const
friend bool operator==(const sc_unsigned &u, const sc_signed &v)
sc_signed & operator--()
const sc_signed & operator=(const sc_signed &v)
bool and_reduce() const
Definition: sc_signed.h:2250
const sc_signed_bitref & operator=(const sc_signed_bitref_r &)
const sc_signed_bitref_r & bit(int i) const
Definition: sc_signed.h:1221
sc_signed or_signed_friend(small_type us, int unb, int und, const sc_digit *ud, small_type vs, int vnb, int vnd, const sc_digit *vd)
virtual bool concat_get_ctrl(sc_digit *dst_p, int low_i) const
Definition: sc_signed.h:775
unsigned long to_ulong() const
bool operator<=(const sc_int_base &a, const sc_int_base &b)
Definition: sc_int_base.h:724
void print(::std::ostream &os=::std::cout) const
Definition: sc_signed.h:1317
virtual int concat_length(bool *xz_present_p) const
Definition: sc_signed.h:956
#define SC_REPORT_ERROR(msg_type, msg)
Definition: sc_report.h:213
friend sc_signed operator~(const sc_signed &u)
void invalid_index(int i) const
const sc_signed & operator%=(const sc_signed &v)
virtual void concat_set(int64 src, int low_i)
bool operator==(const sc_bit &a, const sc_bit &b)
Definition: sc_bit.h:283
bool to_bool() const
Definition: sc_signed.h:766
sc_signed_bitref & bit(int i)
Definition: sc_signed.h:1212
bool nand_reduce() const
Definition: sc_signed.h:2258
virtual void concat_set(int64 src, int low_i)
void invalid_range(int l, int r) const
unsigned int to_uint() const
virtual bool concat_get_ctrl(sc_digit *dst_p, int low_i) const
small_type convert_signed_2C_to_SM(int nb, int nd, sc_digit *d)
Definition: sc_nbutils.h:827
friend sc_signed operator-(const sc_unsigned &u, const sc_signed &v)
friend sc_signed xor_signed_friend(small_type us, int unb, int und, const sc_digit *ud, small_type vs, int vnb, int vnd, const sc_digit *vd)
sc_signed mul_signed_friend(small_type s, int unb, int und, const sc_digit *ud, int vnb, int vnd, const sc_digit *vd)
virtual bool concat_get_data(sc_digit *dst_p, int low_i) const
sc_signed operator*(const sc_unsigned &u, const sc_signed &v)
bool iszero() const
sc_signed operator-(const sc_unsigned &u, const sc_signed &v)
void initialize(const sc_signed *obj_p, int left_, int right_)
Definition: sc_signed.h:904
bool or_reduce() const
Definition: sc_signed.h:2263
inline::std::ostream & operator<<(::std::ostream &os, const sc_bit &a)
Definition: sc_bit.h:386
virtual ~sc_signed_subref_r()
Definition: sc_signed.h:916
static sc_core::sc_vpool< sc_signed_bitref > m_pool
Definition: sc_signed.h:875
const sc_signed & operator*=(const sc_signed &v)