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

Generated on Tue Jun 18 2024 16:24:06 for gem5 by doxygen 1.11.0