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