112853Sgabeblack@google.com/*****************************************************************************
212853Sgabeblack@google.com
312853Sgabeblack@google.com  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
412853Sgabeblack@google.com  more contributor license agreements.  See the NOTICE file distributed
512853Sgabeblack@google.com  with this work for additional information regarding copyright ownership.
612853Sgabeblack@google.com  Accellera licenses this file to you under the Apache License, Version 2.0
712853Sgabeblack@google.com  (the "License"); you may not use this file except in compliance with the
812853Sgabeblack@google.com  License.  You may obtain a copy of the License at
912853Sgabeblack@google.com
1012853Sgabeblack@google.com    http://www.apache.org/licenses/LICENSE-2.0
1112853Sgabeblack@google.com
1212853Sgabeblack@google.com  Unless required by applicable law or agreed to in writing, software
1312853Sgabeblack@google.com  distributed under the License is distributed on an "AS IS" BASIS,
1412853Sgabeblack@google.com  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
1512853Sgabeblack@google.com  implied.  See the License for the specific language governing
1612853Sgabeblack@google.com  permissions and limitations under the License.
1712853Sgabeblack@google.com
1812853Sgabeblack@google.com *****************************************************************************/
1912853Sgabeblack@google.com
2012853Sgabeblack@google.com/*****************************************************************************
2112853Sgabeblack@google.com
2212853Sgabeblack@google.com  sc_signed.h -- Arbitrary precision signed arithmetic.
2312853Sgabeblack@google.com
2412853Sgabeblack@google.com    This file includes the definitions of sc_signed_bitref,
2512853Sgabeblack@google.com    sc_signed_subref, and sc_signed classes. The first two classes are
2612853Sgabeblack@google.com    proxy classes to reference one bit and a range of bits of a
2712853Sgabeblack@google.com    sc_signed number, respectively.
2812853Sgabeblack@google.com
2912853Sgabeblack@google.com    An sc_signed number has the sign-magnitude representation
3012853Sgabeblack@google.com    internally. However, its interface guarantees a 2's-complement
3112853Sgabeblack@google.com    representation. The sign-magnitude representation is chosen
3212853Sgabeblack@google.com    because of its efficiency: The sc_signed and sc_unsigned types are
3312853Sgabeblack@google.com    optimized for arithmetic rather than bitwise operations. For
3412853Sgabeblack@google.com    arithmetic operations, the sign-magnitude representation performs
3512853Sgabeblack@google.com    better.
3612853Sgabeblack@google.com
3712853Sgabeblack@google.com    The implementations of sc_signed and sc_unsigned classes are
3812853Sgabeblack@google.com    almost identical: Most of the member and friend functions are
3912853Sgabeblack@google.com    defined in sc_nbcommon.cpp and sc_nbfriends.cpp so that they can
4012853Sgabeblack@google.com    be shared by both of these classes. These functions are chosed by
4112853Sgabeblack@google.com    defining a few macros before including them such as IF_SC_SIGNED
4212853Sgabeblack@google.com    and CLASS_TYPE. Our implementation choices are mostly dictated by
4312853Sgabeblack@google.com    performance considerations in that we tried to provide the most
4412853Sgabeblack@google.com    efficient sc_signed and sc_unsigned types without compromising
4512853Sgabeblack@google.com    their interface.
4612853Sgabeblack@google.com
4712853Sgabeblack@google.com    For the behavior of operators, we have two semantics: the old and
4812853Sgabeblack@google.com    new. The most important difference between these two semantics is
4912853Sgabeblack@google.com    that the old semantics is closer to C/C++ semantics in that the
5012853Sgabeblack@google.com    result type of a binary operator on unsigned and signed arguments
5112853Sgabeblack@google.com    is unsigned; the new semantics, on the other hand, requires the
5212853Sgabeblack@google.com    result type be signed. The new semantics is required by the VSIA
5312853Sgabeblack@google.com    C/C++ data types standard. We have implemented the new semantics.
5412853Sgabeblack@google.com
5512853Sgabeblack@google.com  Original Author: Ali Dasdan, Synopsys, Inc.
5612853Sgabeblack@google.com
5712853Sgabeblack@google.com *****************************************************************************/
5812853Sgabeblack@google.com
5912853Sgabeblack@google.com/*****************************************************************************
6012853Sgabeblack@google.com
6112853Sgabeblack@google.com  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
6212853Sgabeblack@google.com  changes you are making here.
6312853Sgabeblack@google.com
6412853Sgabeblack@google.com      Name, Affiliation, Date:
6512853Sgabeblack@google.com  Description of Modification:
6612853Sgabeblack@google.com
6712853Sgabeblack@google.com *****************************************************************************/
6812853Sgabeblack@google.com
6912853Sgabeblack@google.com// $Log: sc_signed.h,v $
7012853Sgabeblack@google.com// Revision 1.3  2011/08/24 22:05:46  acg
7112853Sgabeblack@google.com//  Torsten Maehne: initialization changes to remove warnings.
7212853Sgabeblack@google.com//
7312853Sgabeblack@google.com// Revision 1.2  2011/02/18 20:19:15  acg
7412853Sgabeblack@google.com//  Andy Goodrich: updating Copyright notice.
7512853Sgabeblack@google.com//
7612853Sgabeblack@google.com// Revision 1.1.1.1  2006/12/15 20:20:05  acg
7712853Sgabeblack@google.com// SystemC 2.3
7812853Sgabeblack@google.com//
7912853Sgabeblack@google.com// Revision 1.5  2006/05/08 17:50:01  acg
8012853Sgabeblack@google.com//   Andy Goodrich: Added David Long's declarations for friend operators,
8112853Sgabeblack@google.com//   functions, and methods, to keep the Microsoft compiler happy.
8212853Sgabeblack@google.com//
8312853Sgabeblack@google.com// Revision 1.4  2006/03/13 20:25:27  acg
8412853Sgabeblack@google.com//  Andy Goodrich: Addition of function declarations, e.g., xor_signed_friend()
8512853Sgabeblack@google.com//  to keep gcc 4.x happy.
8612853Sgabeblack@google.com//
8712853Sgabeblack@google.com// Revision 1.3  2006/01/13 18:49:32  acg
8812853Sgabeblack@google.com// Added $Log command so that CVS check in comments are reproduced in the
8912853Sgabeblack@google.com// source.
9012853Sgabeblack@google.com//
9112853Sgabeblack@google.com
9212853Sgabeblack@google.com#ifndef __SYSTEMC_EXT_DT_INT_SC_SIGNED_HH__
9312853Sgabeblack@google.com#define __SYSTEMC_EXT_DT_INT_SC_SIGNED_HH__
9412853Sgabeblack@google.com
9512853Sgabeblack@google.com#include <iostream>
9612853Sgabeblack@google.com
9712853Sgabeblack@google.com#include "../misc/sc_value_base.hh"
9812853Sgabeblack@google.com#include "../sc_temporary.hh"
9912853Sgabeblack@google.com#include "sc_length_param.hh"
10012853Sgabeblack@google.com#include "sc_nbdefs.hh"
10112853Sgabeblack@google.com#include "sc_nbexterns.hh"
10212853Sgabeblack@google.com#include "sc_nbutils.hh"
10312853Sgabeblack@google.com#include "sc_unsigned.hh"
10412853Sgabeblack@google.com
10512853Sgabeblack@google.comnamespace sc_dt
10612853Sgabeblack@google.com{
10712853Sgabeblack@google.com
10812853Sgabeblack@google.com// classes defined in this module
10912853Sgabeblack@google.comclass sc_signed_bitref_r;
11012853Sgabeblack@google.comclass sc_signed_bitref;
11112853Sgabeblack@google.comclass sc_signed_subref_r;
11212853Sgabeblack@google.comclass sc_signed_subref;
11312853Sgabeblack@google.comclass sc_concatref;
11412853Sgabeblack@google.comclass sc_signed;
11512853Sgabeblack@google.com
11612853Sgabeblack@google.com// forward class declarations
11712853Sgabeblack@google.comclass sc_bv_base;
11812853Sgabeblack@google.comclass sc_lv_base;
11912853Sgabeblack@google.comclass sc_int_base;
12012853Sgabeblack@google.comclass sc_uint_base;
12112853Sgabeblack@google.comclass sc_int_subref_r;
12212853Sgabeblack@google.comclass sc_uint_subref_r;
12312853Sgabeblack@google.comclass sc_signed;
12412853Sgabeblack@google.comclass sc_unsigned;
12512853Sgabeblack@google.comclass sc_unsigned_subref_r;
12612853Sgabeblack@google.comclass sc_fxval;
12712853Sgabeblack@google.comclass sc_fxval_fast;
12812853Sgabeblack@google.comclass sc_fxnum;
12912853Sgabeblack@google.comclass sc_fxnum_fast;
13012853Sgabeblack@google.com
13112853Sgabeblack@google.com} // namespace sc_dt
13212853Sgabeblack@google.com
13312853Sgabeblack@google.com// extern template instantiations
13412853Sgabeblack@google.comnamespace sc_core
13512853Sgabeblack@google.com{
13612853Sgabeblack@google.com
13712853Sgabeblack@google.comextern template class sc_vpool<sc_dt::sc_signed_bitref>;
13812853Sgabeblack@google.comextern template class sc_vpool<sc_dt::sc_signed_subref>;
13912853Sgabeblack@google.com
14012853Sgabeblack@google.com} // namespace sc_core
14112853Sgabeblack@google.com
14212853Sgabeblack@google.comnamespace sc_dt
14312853Sgabeblack@google.com{
14412853Sgabeblack@google.com
14512853Sgabeblack@google.com// Helper function declarations
14612853Sgabeblack@google.comsc_signed add_signed_friend(
14712853Sgabeblack@google.com        small_type us, int unb, int und, const sc_digit *ud,
14812853Sgabeblack@google.com        small_type vs, int vnb, int vnd, const sc_digit *vd);
14912853Sgabeblack@google.com
15012853Sgabeblack@google.comsc_signed sub_signed_friend(
15112853Sgabeblack@google.com        small_type us, int unb, int und, const sc_digit *ud,
15212853Sgabeblack@google.com        small_type vs, int vnb, int vnd, const sc_digit *vd);
15312853Sgabeblack@google.com
15412853Sgabeblack@google.comsc_signed mul_signed_friend(
15512853Sgabeblack@google.com        small_type s, int unb, int und, const sc_digit *ud,
15612853Sgabeblack@google.com        int vnb, int vnd, const sc_digit *vd);
15712853Sgabeblack@google.com
15812853Sgabeblack@google.comsc_signed div_signed_friend(
15912853Sgabeblack@google.com        small_type s, int unb, int und, const sc_digit *ud,
16012853Sgabeblack@google.com        int vnb, int vnd, const sc_digit *vd);
16112853Sgabeblack@google.com
16212853Sgabeblack@google.comsc_signed mod_signed_friend(
16312853Sgabeblack@google.com        small_type us, int unb, int und, const sc_digit *ud,
16412853Sgabeblack@google.com        int vnb, int vnd, const sc_digit *vd);
16512853Sgabeblack@google.com
16612853Sgabeblack@google.comsc_signed and_signed_friend(
16712853Sgabeblack@google.com        small_type us, int unb, int und, const sc_digit *ud,
16812853Sgabeblack@google.com        small_type vs, int vnb, int vnd, const sc_digit *vd);
16912853Sgabeblack@google.com
17012853Sgabeblack@google.comsc_signed or_signed_friend(
17112853Sgabeblack@google.com        small_type us, int unb, int und, const sc_digit *ud,
17212853Sgabeblack@google.com        small_type vs, int vnb, int vnd, const sc_digit *vd);
17312853Sgabeblack@google.com
17412853Sgabeblack@google.comsc_signed xor_signed_friend(
17512853Sgabeblack@google.com        small_type us, int unb, int und, const sc_digit *ud,
17612853Sgabeblack@google.com        small_type vs, int vnb, int vnd, const sc_digit *vd);
17712853Sgabeblack@google.com
17812853Sgabeblack@google.com/*
17912853Sgabeblack@google.com * friend operator declarations
18012853Sgabeblack@google.com */
18112853Sgabeblack@google.com
18212853Sgabeblack@google.com// ARITHMETIC OPERATORS:
18312853Sgabeblack@google.com
18412853Sgabeblack@google.com// ADDition operators:
18512853Sgabeblack@google.comsc_signed operator + (const sc_unsigned &u, const sc_signed &v);
18612853Sgabeblack@google.comsc_signed operator + (const sc_signed &u, const sc_unsigned &v);
18712853Sgabeblack@google.com
18812853Sgabeblack@google.comsc_signed operator + (const sc_unsigned &u, int64 v);
18912853Sgabeblack@google.comsc_signed operator + (const sc_unsigned &u, long v);
19012853Sgabeblack@google.cominline sc_signed operator + (const sc_unsigned &u, int v);
19112853Sgabeblack@google.com
19212853Sgabeblack@google.comsc_signed operator + (int64 u, const sc_unsigned &v);
19312853Sgabeblack@google.comsc_signed operator + (long u, const sc_unsigned &v);
19412853Sgabeblack@google.cominline sc_signed operator + (int u, const sc_unsigned &v);
19512853Sgabeblack@google.com
19612853Sgabeblack@google.comsc_signed operator + (const sc_signed &u, const sc_signed &v);
19712853Sgabeblack@google.comsc_signed operator + (const sc_signed &u, int64 v);
19812853Sgabeblack@google.comsc_signed operator + (const sc_signed &u, uint64 v);
19912853Sgabeblack@google.comsc_signed operator + (const sc_signed &u, long v);
20012853Sgabeblack@google.comsc_signed operator + (const sc_signed &u, unsigned long v);
20112853Sgabeblack@google.cominline sc_signed operator + (const sc_signed &u, int v);
20212853Sgabeblack@google.cominline sc_signed operator + (const sc_signed &u, unsigned int v);
20312853Sgabeblack@google.com
20412853Sgabeblack@google.comsc_signed operator + (int64 u, const sc_signed &v);
20512853Sgabeblack@google.comsc_signed operator + (uint64 u, const sc_signed &v);
20612853Sgabeblack@google.comsc_signed operator + (long u, const sc_signed &v);
20712853Sgabeblack@google.comsc_signed operator + (unsigned long u, const sc_signed &v);
20812853Sgabeblack@google.cominline sc_signed operator + (int u, const sc_signed &v);
20912853Sgabeblack@google.cominline sc_signed operator + (unsigned int u, const sc_signed &v);
21012853Sgabeblack@google.com
21112853Sgabeblack@google.comsc_signed operator + (const sc_unsigned &u, const sc_int_base &v);
21212853Sgabeblack@google.comsc_signed operator + (const sc_int_base &u, const sc_unsigned &v);
21312853Sgabeblack@google.comsc_signed operator + (const sc_signed &u, const sc_int_base &v);
21412853Sgabeblack@google.comsc_signed operator + (const sc_signed &u, const sc_uint_base &v);
21512853Sgabeblack@google.comsc_signed operator + (const sc_int_base &u, const sc_signed &v);
21612853Sgabeblack@google.comsc_signed operator + (const sc_uint_base &u, const sc_signed &v);
21712853Sgabeblack@google.com
21812853Sgabeblack@google.com
21912853Sgabeblack@google.com// SUBtraction operators:
22012853Sgabeblack@google.comsc_signed operator - (const sc_unsigned &u, const sc_signed &v);
22112853Sgabeblack@google.comsc_signed operator - (const sc_signed &u, const sc_unsigned &v);
22212853Sgabeblack@google.com
22312853Sgabeblack@google.comsc_signed operator - (const sc_unsigned &u, const sc_unsigned &v);
22412853Sgabeblack@google.comsc_signed operator - (const sc_unsigned &u, int64 v);
22512853Sgabeblack@google.comsc_signed operator - (const sc_unsigned &u, uint64 v);
22612853Sgabeblack@google.comsc_signed operator - (const sc_unsigned &u, long v);
22712853Sgabeblack@google.comsc_signed operator - (const sc_unsigned &u, unsigned long v);
22812853Sgabeblack@google.cominline sc_signed operator - (const sc_unsigned &u, int v);
22912853Sgabeblack@google.cominline sc_signed operator - (const sc_unsigned &u, unsigned int v);
23012853Sgabeblack@google.com
23112853Sgabeblack@google.comsc_signed operator - (int64 u, const sc_unsigned &v);
23212853Sgabeblack@google.comsc_signed operator - (uint64 u, const sc_unsigned &v);
23312853Sgabeblack@google.comsc_signed operator - (long u, const sc_unsigned &v);
23412853Sgabeblack@google.comsc_signed operator - (unsigned long u, const sc_unsigned &v);
23512853Sgabeblack@google.cominline sc_signed operator - (int u, const sc_unsigned &v);
23612853Sgabeblack@google.cominline sc_signed operator - (unsigned int u, const sc_unsigned &v);
23712853Sgabeblack@google.com
23812853Sgabeblack@google.comsc_signed operator - (const sc_signed &u, const sc_signed &v);
23912853Sgabeblack@google.comsc_signed operator - (const sc_signed &u, int64 v);
24012853Sgabeblack@google.comsc_signed operator - (const sc_signed &u, uint64 v);
24112853Sgabeblack@google.comsc_signed operator - (const sc_signed &u, long v);
24212853Sgabeblack@google.comsc_signed operator - (const sc_signed &u, unsigned long v);
24312853Sgabeblack@google.cominline sc_signed operator - (const sc_signed &u, int v);
24412853Sgabeblack@google.cominline sc_signed operator - (const sc_signed &u, unsigned int v);
24512853Sgabeblack@google.com
24612853Sgabeblack@google.comsc_signed operator - (int64 u, const sc_signed &v);
24712853Sgabeblack@google.comsc_signed operator - (uint64 u, const sc_signed &v);
24812853Sgabeblack@google.comsc_signed operator - (long u, const sc_signed &v);
24912853Sgabeblack@google.comsc_signed operator - (unsigned long u, const sc_signed &v);
25012853Sgabeblack@google.cominline sc_signed operator - (int u, const sc_signed &v);
25112853Sgabeblack@google.cominline sc_signed operator - (unsigned int u, const sc_signed &v);
25212853Sgabeblack@google.com
25312853Sgabeblack@google.com
25412853Sgabeblack@google.comsc_signed operator - (const sc_unsigned &u, const sc_int_base &v);
25512853Sgabeblack@google.comsc_signed operator - (const sc_unsigned &u, const sc_uint_base &v);
25612853Sgabeblack@google.comsc_signed operator - (const sc_int_base &u, const sc_unsigned &v);
25712853Sgabeblack@google.comsc_signed operator - (const sc_uint_base &u, const sc_unsigned &v);
25812853Sgabeblack@google.comsc_signed operator - (const sc_signed &u, const sc_int_base &v);
25912853Sgabeblack@google.comsc_signed operator - (const sc_signed &u, const sc_uint_base &v);
26012853Sgabeblack@google.comsc_signed operator - (const sc_int_base &u, const sc_signed &v);
26112853Sgabeblack@google.comsc_signed operator - (const sc_uint_base &u, const sc_signed &v);
26212853Sgabeblack@google.com
26312853Sgabeblack@google.com
26412853Sgabeblack@google.com// MULtiplication operators:
26512853Sgabeblack@google.comsc_signed operator * (const sc_unsigned &u, const sc_signed &v);
26612853Sgabeblack@google.comsc_signed operator * (const sc_signed &u, const sc_unsigned &v);
26712853Sgabeblack@google.com
26812853Sgabeblack@google.comsc_signed operator * (const sc_unsigned &u, int64 v);
26912853Sgabeblack@google.comsc_signed operator * (const sc_unsigned &u, long v);
27012853Sgabeblack@google.cominline sc_signed operator * (const sc_unsigned &u, int v);
27112853Sgabeblack@google.com
27212853Sgabeblack@google.comsc_signed operator * (int64 u, const sc_unsigned &v);
27312853Sgabeblack@google.comsc_signed operator * (long u, const sc_unsigned &v);
27412853Sgabeblack@google.cominline sc_signed operator * (int u, const sc_unsigned &v);
27512853Sgabeblack@google.com
27612853Sgabeblack@google.comsc_signed operator * (const sc_signed &u, const sc_signed &v);
27712853Sgabeblack@google.comsc_signed operator * (const sc_signed &u, int64 v);
27812853Sgabeblack@google.comsc_signed operator * (const sc_signed &u, uint64 v);
27912853Sgabeblack@google.comsc_signed operator * (const sc_signed &u, long v);
28012853Sgabeblack@google.comsc_signed operator * (const sc_signed &u, unsigned long v);
28112853Sgabeblack@google.cominline sc_signed operator * (const sc_signed &u, int v);
28212853Sgabeblack@google.cominline sc_signed operator * (const sc_signed &u, unsigned int v);
28312853Sgabeblack@google.com
28412853Sgabeblack@google.comsc_signed operator * (int64 u, const sc_signed &v);
28512853Sgabeblack@google.comsc_signed operator * (uint64 u, const sc_signed &v);
28612853Sgabeblack@google.comsc_signed operator * (long u, const sc_signed &v);
28712853Sgabeblack@google.comsc_signed operator * (unsigned long u, const sc_signed &v);
28812853Sgabeblack@google.cominline sc_signed operator * (int u, const sc_signed &v);
28912853Sgabeblack@google.cominline sc_signed operator * (unsigned int u, const sc_signed &v);
29012853Sgabeblack@google.com
29112853Sgabeblack@google.comsc_signed operator * (const sc_unsigned &u, const sc_int_base &v);
29212853Sgabeblack@google.comsc_signed operator * (const sc_int_base &u, const sc_unsigned &v);
29312853Sgabeblack@google.comsc_signed operator * (const sc_signed &u, const sc_int_base &v);
29412853Sgabeblack@google.comsc_signed operator * (const sc_signed &u, const sc_uint_base &v);
29512853Sgabeblack@google.comsc_signed operator * (const sc_int_base &u, const sc_signed &v);
29612853Sgabeblack@google.comsc_signed operator * (const sc_uint_base &u, const sc_signed &v);
29712853Sgabeblack@google.com
29812853Sgabeblack@google.com
29912853Sgabeblack@google.com// DIVision operators:
30012853Sgabeblack@google.comsc_signed operator / (const sc_unsigned &u, const sc_signed &v);
30112853Sgabeblack@google.comsc_signed operator / (const sc_signed &u, const sc_unsigned &v);
30212853Sgabeblack@google.com
30312853Sgabeblack@google.comsc_signed operator / (const sc_unsigned &u, int64 v);
30412853Sgabeblack@google.comsc_signed operator / (const sc_unsigned &u, long v);
30512853Sgabeblack@google.cominline sc_signed operator / (const sc_unsigned &u, int v);
30612853Sgabeblack@google.com
30712853Sgabeblack@google.comsc_signed operator / (int64 u, const sc_unsigned &v);
30812853Sgabeblack@google.comsc_signed operator / (long u, const sc_unsigned &v);
30912853Sgabeblack@google.cominline sc_signed operator / (int u, const sc_unsigned &v);
31012853Sgabeblack@google.com
31112853Sgabeblack@google.comsc_signed operator / (const sc_signed &u, const sc_signed &v);
31212853Sgabeblack@google.comsc_signed operator / (const sc_signed &u, int64 v);
31312853Sgabeblack@google.comsc_signed operator / (const sc_signed &u, uint64 v);
31412853Sgabeblack@google.comsc_signed operator / (const sc_signed &u, long v);
31512853Sgabeblack@google.comsc_signed operator / (const sc_signed &u, unsigned long v);
31612853Sgabeblack@google.cominline sc_signed operator / (const sc_signed &u, int v);
31712853Sgabeblack@google.cominline sc_signed operator / (const sc_signed &u, unsigned int v);
31812853Sgabeblack@google.com
31912853Sgabeblack@google.comsc_signed operator / (int64 u, const sc_signed &v);
32012853Sgabeblack@google.comsc_signed operator / (uint64 u, const sc_signed &v);
32112853Sgabeblack@google.comsc_signed operator / (long u, const sc_signed &v);
32212853Sgabeblack@google.comsc_signed operator / (unsigned long u, const sc_signed &v);
32312853Sgabeblack@google.cominline sc_signed operator / (int u, const sc_signed &v);
32412853Sgabeblack@google.cominline sc_signed operator / (unsigned int u, const sc_signed &v);
32512853Sgabeblack@google.com
32612853Sgabeblack@google.comsc_signed operator / (const sc_unsigned &u, const sc_int_base &v);
32712853Sgabeblack@google.comsc_signed operator / (const sc_int_base &u, const sc_unsigned &v);
32812853Sgabeblack@google.comsc_signed operator / (const sc_signed &u, const sc_int_base &v);
32912853Sgabeblack@google.comsc_signed operator / (const sc_signed &u, const sc_uint_base &v);
33012853Sgabeblack@google.comsc_signed operator / (const sc_int_base &u, const sc_signed &v);
33112853Sgabeblack@google.comsc_signed operator / (const sc_uint_base &u, const sc_signed &v);
33212853Sgabeblack@google.com
33312853Sgabeblack@google.com
33412853Sgabeblack@google.com// MODulo operators:
33512853Sgabeblack@google.comsc_signed operator % (const sc_unsigned &u, const sc_signed &v);
33612853Sgabeblack@google.comsc_signed operator % (const sc_signed &u, const sc_unsigned &v);
33712853Sgabeblack@google.com
33812853Sgabeblack@google.comsc_signed operator % (const sc_unsigned &u, int64 v);
33912853Sgabeblack@google.comsc_signed operator % (const sc_unsigned &u, long v);
34012853Sgabeblack@google.cominline sc_signed operator % (const sc_unsigned &u, int v);
34112853Sgabeblack@google.com
34212853Sgabeblack@google.comsc_signed operator % (int64 u, const sc_unsigned &v);
34312853Sgabeblack@google.comsc_signed operator % (long u, const sc_unsigned &v);
34412853Sgabeblack@google.cominline sc_signed operator % (int u, const sc_unsigned &v);
34512853Sgabeblack@google.com
34612853Sgabeblack@google.comsc_signed operator % (const sc_signed &u, const sc_signed &v);
34712853Sgabeblack@google.comsc_signed operator % (const sc_signed &u, int64 v);
34812853Sgabeblack@google.comsc_signed operator % (const sc_signed &u, uint64 v);
34912853Sgabeblack@google.comsc_signed operator % (const sc_signed &u, long v);
35012853Sgabeblack@google.comsc_signed operator % (const sc_signed &u, unsigned long v);
35112853Sgabeblack@google.cominline sc_signed operator % (const sc_signed &u, int v);
35212853Sgabeblack@google.cominline sc_signed operator % (const sc_signed &u, unsigned int v);
35312853Sgabeblack@google.com
35412853Sgabeblack@google.comsc_signed operator % (int64 u, const sc_signed &v);
35512853Sgabeblack@google.comsc_signed operator % (uint64 u, const sc_signed &v);
35612853Sgabeblack@google.comsc_signed operator % (long u, const sc_signed &v);
35712853Sgabeblack@google.comsc_signed operator % (unsigned long u, const sc_signed &v);
35812853Sgabeblack@google.cominline sc_signed operator % (int u, const sc_signed &v);
35912853Sgabeblack@google.cominline sc_signed operator % (unsigned int u, const sc_signed &v);
36012853Sgabeblack@google.com
36112853Sgabeblack@google.comsc_signed operator % (const sc_unsigned &u, const sc_int_base &v);
36212853Sgabeblack@google.comsc_signed operator % (const sc_int_base &u, const sc_unsigned &v);
36312853Sgabeblack@google.comsc_signed operator % (const sc_signed &u, const sc_int_base &v);
36412853Sgabeblack@google.comsc_signed operator % (const sc_signed &u, const sc_uint_base &v);
36512853Sgabeblack@google.comsc_signed operator % (const sc_int_base &u, const sc_signed &v);
36612853Sgabeblack@google.comsc_signed operator % (const sc_uint_base &u, const sc_signed &v);
36712853Sgabeblack@google.com
36812853Sgabeblack@google.com
36912853Sgabeblack@google.com// BITWISE OPERATORS:
37012853Sgabeblack@google.com
37112853Sgabeblack@google.com// Bitwise AND operators:
37212853Sgabeblack@google.comsc_signed operator & (const sc_unsigned &u, const sc_signed &v);
37312853Sgabeblack@google.comsc_signed operator & (const sc_signed &u, const sc_unsigned &v);
37412853Sgabeblack@google.com
37512853Sgabeblack@google.comsc_signed operator & (const sc_unsigned &u, int64 v);
37612853Sgabeblack@google.comsc_signed operator & (const sc_unsigned &u, long v);
37712853Sgabeblack@google.cominline sc_signed operator & (const sc_unsigned &u, int v);
37812853Sgabeblack@google.com
37912853Sgabeblack@google.comsc_signed operator & (int64 u, const sc_unsigned &v);
38012853Sgabeblack@google.comsc_signed operator & (long u, const sc_unsigned &v);
38112853Sgabeblack@google.cominline sc_signed operator & (int u, const sc_unsigned &v);
38212853Sgabeblack@google.com
38312853Sgabeblack@google.comsc_signed operator & (const sc_signed &u, const sc_signed &v);
38412853Sgabeblack@google.comsc_signed operator & (const sc_signed &u, int64 v);
38512853Sgabeblack@google.comsc_signed operator & (const sc_signed &u, uint64 v);
38612853Sgabeblack@google.comsc_signed operator & (const sc_signed &u, long v);
38712853Sgabeblack@google.comsc_signed operator & (const sc_signed &u, unsigned long v);
38812853Sgabeblack@google.cominline sc_signed operator & (const sc_signed &u, int v);
38912853Sgabeblack@google.cominline sc_signed operator & (const sc_signed &u, unsigned int v);
39012853Sgabeblack@google.com
39112853Sgabeblack@google.comsc_signed operator & (int64 u, const sc_signed &v);
39212853Sgabeblack@google.comsc_signed operator & (uint64 u, const sc_signed &v);
39312853Sgabeblack@google.comsc_signed operator & (long u, const sc_signed &v);
39412853Sgabeblack@google.comsc_signed operator & (unsigned long u, const sc_signed &v);
39512853Sgabeblack@google.cominline sc_signed operator & (int u, const sc_signed &v);
39612853Sgabeblack@google.cominline sc_signed operator & (unsigned int u, const sc_signed &v);
39712853Sgabeblack@google.com
39812853Sgabeblack@google.comsc_signed operator & (const sc_unsigned &u, const sc_int_base &v);
39912853Sgabeblack@google.comsc_signed operator & (const sc_int_base &u, const sc_unsigned &v);
40012853Sgabeblack@google.comsc_signed operator & (const sc_signed &u, const sc_int_base &v);
40112853Sgabeblack@google.comsc_signed operator & (const sc_signed &u, const sc_uint_base &v);
40212853Sgabeblack@google.comsc_signed operator & (const sc_int_base &u, const sc_signed &v);
40312853Sgabeblack@google.comsc_signed operator & (const sc_uint_base &u, const sc_signed &v);
40412853Sgabeblack@google.com
40512853Sgabeblack@google.com
40612853Sgabeblack@google.com// Bitwise OR operators:
40712853Sgabeblack@google.comsc_signed operator | (const sc_unsigned &u, const sc_signed &v);
40812853Sgabeblack@google.comsc_signed operator | (const sc_signed &u, const sc_unsigned &v);
40912853Sgabeblack@google.com
41012853Sgabeblack@google.comsc_signed operator | (const sc_unsigned &u, int64 v);
41112853Sgabeblack@google.comsc_signed operator | (const sc_unsigned &u, long v);
41212853Sgabeblack@google.cominline sc_signed operator | (const sc_unsigned &u, int v);
41312853Sgabeblack@google.com
41412853Sgabeblack@google.comsc_signed operator | (int64 u, const sc_unsigned &v);
41512853Sgabeblack@google.comsc_signed operator | (long u, const sc_unsigned &v);
41612853Sgabeblack@google.cominline sc_signed operator | (int u, const sc_unsigned &v);
41712853Sgabeblack@google.com
41812853Sgabeblack@google.comsc_signed operator | (const sc_signed &u, const sc_signed &v);
41912853Sgabeblack@google.comsc_signed operator | (const sc_signed &u, int64 v);
42012853Sgabeblack@google.comsc_signed operator | (const sc_signed &u, uint64 v);
42112853Sgabeblack@google.comsc_signed operator | (const sc_signed &u, long v);
42212853Sgabeblack@google.comsc_signed operator | (const sc_signed &u, unsigned long v);
42312853Sgabeblack@google.cominline sc_signed operator | (const sc_signed &u, int v);
42412853Sgabeblack@google.cominline sc_signed operator | (const sc_signed &u, unsigned int v);
42512853Sgabeblack@google.com
42612853Sgabeblack@google.comsc_signed operator | (int64 u, const sc_signed &v);
42712853Sgabeblack@google.comsc_signed operator | (uint64 u, const sc_signed &v);
42812853Sgabeblack@google.comsc_signed operator | (long u, const sc_signed &v);
42912853Sgabeblack@google.comsc_signed operator | (unsigned long u, const sc_signed &v);
43012853Sgabeblack@google.cominline sc_signed operator | (int u, const sc_signed &v);
43112853Sgabeblack@google.cominline sc_signed operator | (unsigned int u, const sc_signed &v);
43212853Sgabeblack@google.com
43312853Sgabeblack@google.comsc_signed operator | (const sc_unsigned &u, const sc_int_base &v);
43412853Sgabeblack@google.comsc_signed operator | (const sc_int_base &u, const sc_unsigned &v);
43512853Sgabeblack@google.comsc_signed operator | (const sc_signed &u, const sc_int_base &v);
43612853Sgabeblack@google.comsc_signed operator | (const sc_signed &u, const sc_uint_base &v);
43712853Sgabeblack@google.comsc_signed operator | (const sc_int_base &u, const sc_signed &v);
43812853Sgabeblack@google.comsc_signed operator | (const sc_uint_base &u, const sc_signed &v);
43912853Sgabeblack@google.com
44012853Sgabeblack@google.com
44112853Sgabeblack@google.com// Bitwise XOR operators:
44212853Sgabeblack@google.comsc_signed operator ^ (const sc_unsigned &u, const sc_signed &v);
44312853Sgabeblack@google.comsc_signed operator ^ (const sc_signed &u, const sc_unsigned &v);
44412853Sgabeblack@google.com
44512853Sgabeblack@google.comsc_signed operator ^ (const sc_unsigned &u, int64 v);
44612853Sgabeblack@google.comsc_signed operator ^ (const sc_unsigned &u, long v);
44712853Sgabeblack@google.cominline sc_signed operator ^ (const sc_unsigned &u, int v);
44812853Sgabeblack@google.com
44912853Sgabeblack@google.comsc_signed operator ^ (int64 u, const sc_unsigned &v);
45012853Sgabeblack@google.comsc_signed operator ^ (long u, const sc_unsigned &v);
45112853Sgabeblack@google.cominline sc_signed operator ^ (int u, const sc_unsigned &v);
45212853Sgabeblack@google.com
45312853Sgabeblack@google.comsc_signed operator ^ (const sc_signed &u, const sc_signed &v);
45412853Sgabeblack@google.comsc_signed operator ^ (const sc_signed &u, int64 v);
45512853Sgabeblack@google.comsc_signed operator ^ (const sc_signed &u, uint64 v);
45612853Sgabeblack@google.comsc_signed operator ^ (const sc_signed &u, long v);
45712853Sgabeblack@google.comsc_signed operator ^ (const sc_signed &u, unsigned long v);
45812853Sgabeblack@google.cominline sc_signed operator ^ (const sc_signed &u, int v);
45912853Sgabeblack@google.cominline sc_signed operator ^ (const sc_signed &u, unsigned int v);
46012853Sgabeblack@google.com
46112853Sgabeblack@google.comsc_signed operator ^ (int64 u, const sc_signed &v);
46212853Sgabeblack@google.comsc_signed operator ^ (uint64 u, const sc_signed &v);
46312853Sgabeblack@google.comsc_signed operator ^ (long u, const sc_signed &v);
46412853Sgabeblack@google.comsc_signed operator ^ (unsigned long u, const sc_signed &v);
46512853Sgabeblack@google.cominline sc_signed operator ^ (int u, const sc_signed &v);
46612853Sgabeblack@google.cominline sc_signed operator ^ (unsigned int u, const sc_signed &v);
46712853Sgabeblack@google.com
46812853Sgabeblack@google.comsc_signed operator ^ (const sc_unsigned &u, const sc_int_base &v);
46912853Sgabeblack@google.comsc_signed operator ^ (const sc_int_base &u, const sc_unsigned &v);
47012853Sgabeblack@google.comsc_signed operator ^ (const sc_signed &u, const sc_int_base &v);
47112853Sgabeblack@google.comsc_signed operator ^ (const sc_signed &u, const sc_uint_base &v);
47212853Sgabeblack@google.comsc_signed operator ^ (const sc_int_base &u, const sc_signed &v);
47312853Sgabeblack@google.comsc_signed operator ^ (const sc_uint_base &u, const sc_signed &v);
47412853Sgabeblack@google.com
47512853Sgabeblack@google.com
47612853Sgabeblack@google.com// SHIFT OPERATORS:
47712853Sgabeblack@google.com// LEFT SHIFT operators:
47812853Sgabeblack@google.comsc_unsigned operator << (const sc_unsigned &u, const sc_signed &v);
47912853Sgabeblack@google.comsc_signed operator << (const sc_signed &u, const sc_unsigned &v);
48012853Sgabeblack@google.com
48112853Sgabeblack@google.comsc_signed operator << (const sc_signed &u, const sc_signed &v);
48212853Sgabeblack@google.comsc_signed operator << (const sc_signed &u, int64 v);
48312853Sgabeblack@google.comsc_signed operator << (const sc_signed &u, uint64 v);
48412853Sgabeblack@google.comsc_signed operator << (const sc_signed &u, long v);
48512853Sgabeblack@google.comsc_signed operator << (const sc_signed &u, unsigned long v);
48612853Sgabeblack@google.cominline sc_signed operator << (const sc_signed &u, int v);
48712853Sgabeblack@google.cominline sc_signed operator << (const sc_signed &u, unsigned int v);
48812853Sgabeblack@google.com
48912853Sgabeblack@google.comsc_signed operator << (const sc_signed &u, const sc_int_base &v);
49012853Sgabeblack@google.comsc_signed operator << (const sc_signed &u, const sc_uint_base &v);
49112853Sgabeblack@google.com
49212853Sgabeblack@google.com
49312853Sgabeblack@google.com// RIGHT SHIFT operators:
49412853Sgabeblack@google.comsc_unsigned operator >> (const sc_unsigned &u, const sc_signed &v);
49512853Sgabeblack@google.comsc_signed operator >> (const sc_signed &u, const sc_unsigned &v);
49612853Sgabeblack@google.com
49712853Sgabeblack@google.comsc_signed operator >> (const sc_signed &u, const sc_signed &v);
49812853Sgabeblack@google.comsc_signed operator >> (const sc_signed &u, int64 v);
49912853Sgabeblack@google.comsc_signed operator >> (const sc_signed &u, uint64 v);
50012853Sgabeblack@google.comsc_signed operator >> (const sc_signed &u, long v);
50112853Sgabeblack@google.comsc_signed operator >> (const sc_signed &u, unsigned long v);
50212853Sgabeblack@google.cominline sc_signed operator >> (const sc_signed &u, int v);
50312853Sgabeblack@google.cominline sc_signed operator >> (const sc_signed &u, unsigned int v);
50412853Sgabeblack@google.com
50512853Sgabeblack@google.comsc_signed operator >> (const sc_signed &u, const sc_int_base &v);
50612853Sgabeblack@google.comsc_signed operator >> (const sc_signed &u, const sc_uint_base &v);
50712853Sgabeblack@google.com
50812853Sgabeblack@google.com
50912853Sgabeblack@google.com// Unary arithmetic operators
51012853Sgabeblack@google.comsc_signed operator + (const sc_signed &u);
51112853Sgabeblack@google.comsc_signed operator - (const sc_signed &u);
51212853Sgabeblack@google.comsc_signed operator - (const sc_unsigned &u);
51312853Sgabeblack@google.com
51412853Sgabeblack@google.com
51512853Sgabeblack@google.com// LOGICAL OPERATORS:
51612853Sgabeblack@google.com
51712853Sgabeblack@google.com// Logical EQUAL operators:
51812853Sgabeblack@google.combool operator == (const sc_unsigned &u, const sc_signed &v);
51912853Sgabeblack@google.combool operator == (const sc_signed &u, const sc_unsigned &v);
52012853Sgabeblack@google.com
52112853Sgabeblack@google.combool operator == (const sc_signed &u, const sc_signed &v);
52212853Sgabeblack@google.combool operator == (const sc_signed &u, int64 v);
52312853Sgabeblack@google.combool operator == (const sc_signed &u, uint64 v);
52412853Sgabeblack@google.combool operator == (const sc_signed &u, long v);
52512853Sgabeblack@google.combool operator == (const sc_signed &u, unsigned long v);
52612853Sgabeblack@google.cominline bool operator == (const sc_signed &u, int v);
52712853Sgabeblack@google.cominline bool operator == (const sc_signed &u, unsigned int v);
52812853Sgabeblack@google.com
52912853Sgabeblack@google.combool operator == (int64 u, const sc_signed &v);
53012853Sgabeblack@google.combool operator == (uint64 u, const sc_signed &v);
53112853Sgabeblack@google.combool operator == (long u, const sc_signed &v);
53212853Sgabeblack@google.combool operator == (unsigned long u, const sc_signed &v);
53312853Sgabeblack@google.cominline bool operator == (int u, const sc_signed &v);
53412853Sgabeblack@google.cominline bool operator == (unsigned int u, const sc_signed &v);
53512853Sgabeblack@google.com
53612853Sgabeblack@google.combool operator == (const sc_signed &u, const sc_int_base &v);
53712853Sgabeblack@google.combool operator == (const sc_signed &u, const sc_uint_base &v);
53812853Sgabeblack@google.combool operator == (const sc_int_base &u, const sc_signed &v);
53912853Sgabeblack@google.combool operator == (const sc_uint_base &u, const sc_signed &v);
54012853Sgabeblack@google.com
54112853Sgabeblack@google.com// Logical NOT_EQUAL operators:
54212853Sgabeblack@google.combool operator != (const sc_unsigned &u, const sc_signed &v);
54312853Sgabeblack@google.combool operator != (const sc_signed &u, const sc_unsigned &v);
54412853Sgabeblack@google.com
54512853Sgabeblack@google.combool operator != (const sc_signed &u, const sc_signed &v);
54612853Sgabeblack@google.combool operator != (const sc_signed &u, int64 v);
54712853Sgabeblack@google.combool operator != (const sc_signed &u, uint64 v);
54812853Sgabeblack@google.combool operator != (const sc_signed &u, long v);
54912853Sgabeblack@google.combool operator != (const sc_signed &u, unsigned long v);
55012853Sgabeblack@google.cominline bool operator != (const sc_signed &u, int v);
55112853Sgabeblack@google.cominline bool operator != (const sc_signed &u, unsigned int v);
55212853Sgabeblack@google.com
55312853Sgabeblack@google.combool operator != (int64 u, const sc_signed &v);
55412853Sgabeblack@google.combool operator != (uint64 u, const sc_signed &v);
55512853Sgabeblack@google.combool operator != (long u, const sc_signed &v);
55612853Sgabeblack@google.combool operator != (unsigned long u, const sc_signed &v);
55712853Sgabeblack@google.cominline bool operator != (int u, const sc_signed &v);
55812853Sgabeblack@google.cominline bool operator != (unsigned int u, const sc_signed &v);
55912853Sgabeblack@google.com
56012853Sgabeblack@google.combool operator != (const sc_signed &u, const sc_int_base &v);
56112853Sgabeblack@google.combool operator != (const sc_signed &u, const sc_uint_base &v);
56212853Sgabeblack@google.combool operator != (const sc_int_base &u, const sc_signed &v);
56312853Sgabeblack@google.combool operator != (const sc_uint_base &u, const sc_signed &v);
56412853Sgabeblack@google.com
56512853Sgabeblack@google.com// Logical LESS_THAN operators:
56612853Sgabeblack@google.combool operator < (const sc_unsigned &u, const sc_signed &v);
56712853Sgabeblack@google.combool operator < (const sc_signed &u, const sc_unsigned &v);
56812853Sgabeblack@google.com
56912853Sgabeblack@google.combool operator < (const sc_signed &u, const sc_signed &v);
57012853Sgabeblack@google.combool operator < (const sc_signed &u, int64 v);
57112853Sgabeblack@google.combool operator < (const sc_signed &u, uint64 v);
57212853Sgabeblack@google.combool operator < (const sc_signed &u, long v);
57312853Sgabeblack@google.combool operator < (const sc_signed &u, unsigned long v);
57412853Sgabeblack@google.cominline bool operator < (const sc_signed &u, int v);
57512853Sgabeblack@google.cominline bool operator < (const sc_signed &u, unsigned int v);
57612853Sgabeblack@google.com
57712853Sgabeblack@google.combool operator < (int64 u, const sc_signed &v);
57812853Sgabeblack@google.combool operator < (uint64 u, const sc_signed &v);
57912853Sgabeblack@google.combool operator < (long u, const sc_signed &v);
58012853Sgabeblack@google.combool operator < (unsigned long u, const sc_signed &v);
58112853Sgabeblack@google.cominline bool operator < (int u, const sc_signed &v);
58212853Sgabeblack@google.cominline bool operator < (unsigned int u, const sc_signed &v);
58312853Sgabeblack@google.com
58412853Sgabeblack@google.combool operator < (const sc_signed &u, const sc_int_base &v);
58512853Sgabeblack@google.combool operator < (const sc_signed &u, const sc_uint_base &v);
58612853Sgabeblack@google.combool operator < (const sc_int_base &u, const sc_signed &v);
58712853Sgabeblack@google.combool operator < (const sc_uint_base &u, const sc_signed &v);
58812853Sgabeblack@google.com
58912853Sgabeblack@google.com// Logical LESS_THAN_AND_EQUAL operators:
59012853Sgabeblack@google.combool operator <= (const sc_unsigned &u, const sc_signed &v);
59112853Sgabeblack@google.combool operator <= (const sc_signed &u, const sc_unsigned &v);
59212853Sgabeblack@google.com
59312853Sgabeblack@google.combool operator <= (const sc_signed &u, const sc_signed &v);
59412853Sgabeblack@google.combool operator <= (const sc_signed &u, int64 v);
59512853Sgabeblack@google.combool operator <= (const sc_signed &u, uint64 v);
59612853Sgabeblack@google.combool operator <= (const sc_signed &u, long v);
59712853Sgabeblack@google.combool operator <= (const sc_signed &u, unsigned long v);
59812853Sgabeblack@google.cominline bool operator <= (const sc_signed &u, int v);
59912853Sgabeblack@google.cominline bool operator <= (const sc_signed &u, unsigned int v);
60012853Sgabeblack@google.com
60112853Sgabeblack@google.combool operator <= (int64 u, const sc_signed &v);
60212853Sgabeblack@google.combool operator <= (uint64 u, const sc_signed &v);
60312853Sgabeblack@google.combool operator <= (long u, const sc_signed &v);
60412853Sgabeblack@google.combool operator <= (unsigned long u, const sc_signed &v);
60512853Sgabeblack@google.cominline bool operator <= (int u, const sc_signed &v);
60612853Sgabeblack@google.cominline bool operator <= (unsigned int u, const sc_signed &v);
60712853Sgabeblack@google.com
60812853Sgabeblack@google.combool operator <= (const sc_signed &u, const sc_int_base &v);
60912853Sgabeblack@google.combool operator <= (const sc_signed &u, const sc_uint_base &v);
61012853Sgabeblack@google.combool operator <= (const sc_int_base &u, const sc_signed &v);
61112853Sgabeblack@google.combool operator <= (const sc_uint_base &u, const sc_signed &v);
61212853Sgabeblack@google.com
61312853Sgabeblack@google.com// Logical GREATER_THAN operators:
61412853Sgabeblack@google.combool operator > (const sc_unsigned &u, const sc_signed &v);
61512853Sgabeblack@google.combool operator > (const sc_signed &u, const sc_unsigned &v);
61612853Sgabeblack@google.com
61712853Sgabeblack@google.combool operator > (const sc_signed &u, const sc_signed &v);
61812853Sgabeblack@google.combool operator > (const sc_signed &u, int64 v);
61912853Sgabeblack@google.combool operator > (const sc_signed &u, uint64 v);
62012853Sgabeblack@google.combool operator > (const sc_signed &u, long v);
62112853Sgabeblack@google.combool operator > (const sc_signed &u, unsigned long v);
62212853Sgabeblack@google.cominline bool operator > (const sc_signed &u, int v);
62312853Sgabeblack@google.cominline bool operator > (const sc_signed &u, unsigned int v);
62412853Sgabeblack@google.com
62512853Sgabeblack@google.combool operator > (int64 u, const sc_signed &v);
62612853Sgabeblack@google.combool operator > (uint64 u, const sc_signed &v);
62712853Sgabeblack@google.combool operator > (long u, const sc_signed &v);
62812853Sgabeblack@google.combool operator > (unsigned long u, const sc_signed &v);
62912853Sgabeblack@google.cominline bool operator > (int u, const sc_signed &v);
63012853Sgabeblack@google.cominline bool operator > (unsigned int u, const sc_signed &v);
63112853Sgabeblack@google.com
63212853Sgabeblack@google.combool operator > (const sc_signed &u, const sc_int_base &v);
63312853Sgabeblack@google.combool operator > (const sc_signed &u, const sc_uint_base &v);
63412853Sgabeblack@google.combool operator > (const sc_int_base &u, const sc_signed &v);
63512853Sgabeblack@google.combool operator > (const sc_uint_base &u, const sc_signed &v);
63612853Sgabeblack@google.com
63712853Sgabeblack@google.com// Logical GREATER_THAN_AND_EQUAL operators:
63812853Sgabeblack@google.combool operator >= (const sc_unsigned &u, const sc_signed &v);
63912853Sgabeblack@google.combool operator >= (const sc_signed &u, const sc_unsigned &v);
64012853Sgabeblack@google.com
64112853Sgabeblack@google.combool operator >= (const sc_signed &u, const sc_signed &v);
64212853Sgabeblack@google.combool operator >= (const sc_signed &u, int64 v);
64312853Sgabeblack@google.combool operator >= (const sc_signed &u, uint64 v);
64412853Sgabeblack@google.combool operator >= (const sc_signed &u, long v);
64512853Sgabeblack@google.combool operator >= (const sc_signed &u, unsigned long v);
64612853Sgabeblack@google.cominline bool operator >= (const sc_signed &u, int v);
64712853Sgabeblack@google.cominline bool operator >= (const sc_signed &u, unsigned int v);
64812853Sgabeblack@google.com
64912853Sgabeblack@google.combool operator >= (int64 u, const sc_signed &v);
65012853Sgabeblack@google.combool operator >= (uint64 u, const sc_signed &v);
65112853Sgabeblack@google.combool operator >= (long u, const sc_signed &v);
65212853Sgabeblack@google.combool operator >= (unsigned long u, const sc_signed &v);
65312853Sgabeblack@google.cominline bool operator >= (int u, const sc_signed &v);
65412853Sgabeblack@google.cominline bool operator >= (unsigned int u, const sc_signed &v);
65512853Sgabeblack@google.com
65612853Sgabeblack@google.combool operator >= (const sc_signed &u, const sc_int_base &v);
65712853Sgabeblack@google.combool operator >= (const sc_signed &u, const sc_uint_base &v);
65812853Sgabeblack@google.combool operator >= (const sc_int_base &u, const sc_signed &v);
65912853Sgabeblack@google.combool operator >= (const sc_uint_base &u, const sc_signed &v);
66012853Sgabeblack@google.com
66112853Sgabeblack@google.com  // Bitwise NOT operator (unary).
66212853Sgabeblack@google.comsc_signed operator ~ (const sc_signed &u);
66312853Sgabeblack@google.com
66412853Sgabeblack@google.com// ----------------------------------------------------------------------------
66512853Sgabeblack@google.com//  CLASS : sc_signed_bitref_r
66612853Sgabeblack@google.com//
66712853Sgabeblack@google.com//  Proxy class for sc_signed bit selection (r-value only).
66812853Sgabeblack@google.com// ----------------------------------------------------------------------------
66912853Sgabeblack@google.com
67012853Sgabeblack@google.comclass sc_signed_bitref_r : public sc_value_base
67112853Sgabeblack@google.com{
67212853Sgabeblack@google.com    friend class sc_signed;
67312853Sgabeblack@google.com  protected:
67412853Sgabeblack@google.com    // constructor
67512853Sgabeblack@google.com    sc_signed_bitref_r() : sc_value_base(), m_index(0), m_obj_p(0) {}
67612853Sgabeblack@google.com
67712853Sgabeblack@google.com    void
67812853Sgabeblack@google.com    initialize(const sc_signed* obj_p, int index_)
67912853Sgabeblack@google.com    {
68012853Sgabeblack@google.com        m_index = index_;
68112853Sgabeblack@google.com        m_obj_p = const_cast<sc_signed*>(obj_p);
68212853Sgabeblack@google.com    }
68312853Sgabeblack@google.com
68412853Sgabeblack@google.com  public:
68512853Sgabeblack@google.com    // destructor
68612853Sgabeblack@google.com    virtual ~sc_signed_bitref_r() {}
68712853Sgabeblack@google.com
68812853Sgabeblack@google.com    // copy constructor
68912853Sgabeblack@google.com    sc_signed_bitref_r(const sc_signed_bitref_r &a) :
69012853Sgabeblack@google.com            sc_value_base(a), m_index(a.m_index), m_obj_p(a.m_obj_p)
69112853Sgabeblack@google.com    {}
69212853Sgabeblack@google.com
69312853Sgabeblack@google.com    // capacity
69412853Sgabeblack@google.com    int length() const { return 1; }
69512853Sgabeblack@google.com
69612853Sgabeblack@google.com
69712853Sgabeblack@google.com    // implicit conversion to bool
69812853Sgabeblack@google.com    operator uint64 () const;
69912853Sgabeblack@google.com    bool operator ! () const;
70012853Sgabeblack@google.com    bool operator ~ () const;
70112853Sgabeblack@google.com
70212853Sgabeblack@google.com
70312853Sgabeblack@google.com    // explicit conversions
70412853Sgabeblack@google.com    bool value() const { return operator uint64(); }
70512853Sgabeblack@google.com
70612853Sgabeblack@google.com    bool to_bool() const { return operator uint64(); }
70712853Sgabeblack@google.com
70812853Sgabeblack@google.com    // concatenation support
70912853Sgabeblack@google.com    virtual int
71012853Sgabeblack@google.com    concat_length(bool* xz_present_p) const
71112853Sgabeblack@google.com    {
71212853Sgabeblack@google.com        if (xz_present_p)
71312853Sgabeblack@google.com            *xz_present_p = false;
71412853Sgabeblack@google.com        return 1;
71512853Sgabeblack@google.com    }
71612853Sgabeblack@google.com
71712853Sgabeblack@google.com    virtual uint64
71812853Sgabeblack@google.com    concat_get_uint64() const
71912853Sgabeblack@google.com    {
72012853Sgabeblack@google.com        return (uint64)operator uint64();
72112853Sgabeblack@google.com    }
72212853Sgabeblack@google.com    virtual bool
72312853Sgabeblack@google.com    concat_get_ctrl(sc_digit *dst_p, int low_i) const
72412853Sgabeblack@google.com    {
72512853Sgabeblack@google.com        int bit_mask = 1 << (low_i % BITS_PER_DIGIT);
72612853Sgabeblack@google.com        int word_i = low_i / BITS_PER_DIGIT;
72712853Sgabeblack@google.com        dst_p[word_i] &= ~bit_mask;
72812853Sgabeblack@google.com        return false;
72912853Sgabeblack@google.com    }
73012853Sgabeblack@google.com
73112853Sgabeblack@google.com    virtual bool
73212853Sgabeblack@google.com    concat_get_data( sc_digit* dst_p, int low_i ) const
73312853Sgabeblack@google.com    {
73412853Sgabeblack@google.com        int bit_mask = 1 << (low_i % BITS_PER_DIGIT);
73512853Sgabeblack@google.com        bool result; // True if non-zero.
73612853Sgabeblack@google.com        int word_i = low_i / BITS_PER_DIGIT;
73712853Sgabeblack@google.com        if (operator uint64()) {
73812853Sgabeblack@google.com            dst_p[word_i] |= bit_mask;
73912853Sgabeblack@google.com            result = true;
74012853Sgabeblack@google.com        } else {
74112853Sgabeblack@google.com            dst_p[word_i] &= ~bit_mask;
74212853Sgabeblack@google.com            result = false;
74312853Sgabeblack@google.com        }
74412853Sgabeblack@google.com        return result;
74512853Sgabeblack@google.com    }
74612853Sgabeblack@google.com
74712853Sgabeblack@google.com    // other methods
74812853Sgabeblack@google.com    void print(::std::ostream &os=::std::cout) const { os << to_bool(); }
74912853Sgabeblack@google.com
75012853Sgabeblack@google.com  protected:
75112853Sgabeblack@google.com    int m_index; // Bit to be selected.
75212853Sgabeblack@google.com    sc_signed *m_obj_p; // Target of this bit selection.
75312853Sgabeblack@google.com
75412853Sgabeblack@google.com  private:
75512853Sgabeblack@google.com    // Disabled
75612853Sgabeblack@google.com    const sc_signed_bitref_r &operator = (const sc_signed_bitref_r &);
75712853Sgabeblack@google.com};
75812853Sgabeblack@google.com
75912853Sgabeblack@google.com
76012853Sgabeblack@google.cominline ::std::ostream &operator << (
76112853Sgabeblack@google.com        ::std::ostream &, const sc_signed_bitref_r &);
76212853Sgabeblack@google.com
76312853Sgabeblack@google.com
76412853Sgabeblack@google.com// ----------------------------------------------------------------------------
76512853Sgabeblack@google.com//  CLASS : sc_signed_bitref
76612853Sgabeblack@google.com//
76712853Sgabeblack@google.com//  Proxy class for sc_signed bit selection (r-value and l-value).
76812853Sgabeblack@google.com// ----------------------------------------------------------------------------
76912853Sgabeblack@google.com
77012853Sgabeblack@google.comclass sc_signed_bitref : public sc_signed_bitref_r
77112853Sgabeblack@google.com{
77212853Sgabeblack@google.com    friend class sc_signed;
77312853Sgabeblack@google.com    friend class sc_core::sc_vpool<sc_signed_bitref>;
77412853Sgabeblack@google.com
77512853Sgabeblack@google.com  protected:
77612853Sgabeblack@google.com    // constructor
77712853Sgabeblack@google.com    sc_signed_bitref() : sc_signed_bitref_r() {}
77812853Sgabeblack@google.com
77912853Sgabeblack@google.com  public:
78012853Sgabeblack@google.com    // copy constructor
78112853Sgabeblack@google.com    sc_signed_bitref(const sc_signed_bitref &a) : sc_signed_bitref_r(a) {}
78212853Sgabeblack@google.com
78312853Sgabeblack@google.com    // assignment operators
78412853Sgabeblack@google.com    const sc_signed_bitref &operator = (const sc_signed_bitref_r &);
78512853Sgabeblack@google.com    const sc_signed_bitref &operator = (const sc_signed_bitref &);
78612853Sgabeblack@google.com    const sc_signed_bitref &operator = (bool);
78712853Sgabeblack@google.com
78812853Sgabeblack@google.com    const sc_signed_bitref &operator &= (bool);
78912853Sgabeblack@google.com    const sc_signed_bitref &operator |= (bool);
79012853Sgabeblack@google.com    const sc_signed_bitref &operator ^= (bool);
79112853Sgabeblack@google.com
79212853Sgabeblack@google.com    // concatenation methods
79312853Sgabeblack@google.com    virtual void concat_set(int64 src, int low_i);
79412853Sgabeblack@google.com    virtual void concat_set(const sc_signed &src, int low_i);
79512853Sgabeblack@google.com    virtual void concat_set(const sc_unsigned &src, int low_i);
79612853Sgabeblack@google.com    virtual void concat_set(uint64 src, int low_i);
79712853Sgabeblack@google.com
79812853Sgabeblack@google.com    // other methods
79912853Sgabeblack@google.com    void scan(::std::istream &is=::std::cin);
80012853Sgabeblack@google.com
80112853Sgabeblack@google.com  protected:
80212853Sgabeblack@google.com    static sc_core::sc_vpool<sc_signed_bitref> m_pool;
80312853Sgabeblack@google.com};
80412853Sgabeblack@google.com
80512853Sgabeblack@google.cominline ::std::istream &operator >> (::std::istream &, sc_signed_bitref &);
80612853Sgabeblack@google.com
80712853Sgabeblack@google.com
80812853Sgabeblack@google.com// ----------------------------------------------------------------------------
80912853Sgabeblack@google.com//  CLASS : sc_signed_subref_r
81012853Sgabeblack@google.com//
81112853Sgabeblack@google.com//  Proxy class for sc_signed part selection (r-value only).
81212853Sgabeblack@google.com// ----------------------------------------------------------------------------
81312853Sgabeblack@google.com
81412853Sgabeblack@google.comclass sc_signed_subref_r : public sc_value_base
81512853Sgabeblack@google.com{
81612853Sgabeblack@google.com    friend class sc_signed;
81712853Sgabeblack@google.com    friend class sc_signed_signal;
81812853Sgabeblack@google.com    friend class sc_unsigned;
81912853Sgabeblack@google.com
82012853Sgabeblack@google.com  protected:
82112853Sgabeblack@google.com    // constructor
82212853Sgabeblack@google.com    sc_signed_subref_r() : sc_value_base(), m_left(0), m_obj_p(0), m_right(0)
82312853Sgabeblack@google.com    {}
82412853Sgabeblack@google.com
82512853Sgabeblack@google.com    void
82612853Sgabeblack@google.com    initialize(const sc_signed *obj_p, int left_, int right_)
82712853Sgabeblack@google.com    {
82812853Sgabeblack@google.com        m_obj_p = (const_cast<sc_signed*>(obj_p));
82912853Sgabeblack@google.com        m_left = left_;
83012853Sgabeblack@google.com        m_right = right_;
83112853Sgabeblack@google.com    }
83212853Sgabeblack@google.com
83312853Sgabeblack@google.com  public:
83412853Sgabeblack@google.com    // destructor
83512853Sgabeblack@google.com    virtual ~sc_signed_subref_r() {}
83612853Sgabeblack@google.com
83712853Sgabeblack@google.com    // copy constructor
83812853Sgabeblack@google.com    sc_signed_subref_r(const sc_signed_subref_r &a) :
83912853Sgabeblack@google.com            sc_value_base(a), m_left(a.m_left), m_obj_p(a.m_obj_p),
84012853Sgabeblack@google.com            m_right(a.m_right)
84112853Sgabeblack@google.com    {}
84212853Sgabeblack@google.com
84312853Sgabeblack@google.com    // capacity
84412853Sgabeblack@google.com    int
84512853Sgabeblack@google.com    length() const
84612853Sgabeblack@google.com    {
84712853Sgabeblack@google.com        return m_left >= m_right ? (m_left-m_right + 1) : (m_right-m_left + 1);
84812853Sgabeblack@google.com    }
84912853Sgabeblack@google.com
85012853Sgabeblack@google.com    // implicit conversion to sc_unsigned
85112853Sgabeblack@google.com    operator sc_unsigned () const;
85212853Sgabeblack@google.com
85312853Sgabeblack@google.com    // explicit conversions
85412853Sgabeblack@google.com    int to_int() const;
85512853Sgabeblack@google.com    unsigned int to_uint() const;
85612853Sgabeblack@google.com    long to_long() const;
85712853Sgabeblack@google.com    unsigned long to_ulong() const;
85812853Sgabeblack@google.com    int64 to_int64() const;
85912853Sgabeblack@google.com    uint64 to_uint64() const;
86012853Sgabeblack@google.com    double to_double() const;
86112853Sgabeblack@google.com
86212853Sgabeblack@google.com    // explicit conversion to character string
86312853Sgabeblack@google.com    const std::string to_string(sc_numrep numrep=SC_DEC) const;
86412853Sgabeblack@google.com    const std::string to_string(sc_numrep numrep, bool w_prefix) const;
86512853Sgabeblack@google.com
86612853Sgabeblack@google.com    // concatenation support
86712853Sgabeblack@google.com    virtual int
86812853Sgabeblack@google.com    concat_length(bool* xz_present_p) const
86912853Sgabeblack@google.com    {
87012853Sgabeblack@google.com        if (xz_present_p)
87112853Sgabeblack@google.com            *xz_present_p = false;
87212853Sgabeblack@google.com        return m_left - m_right + 1;
87312853Sgabeblack@google.com    }
87412853Sgabeblack@google.com    virtual uint64 concat_get_uint64() const;
87512853Sgabeblack@google.com    virtual bool concat_get_ctrl(sc_digit *dst_p, int low_i) const;
87612853Sgabeblack@google.com    virtual bool concat_get_data(sc_digit *dst_p, int low_i) const;
87712853Sgabeblack@google.com
87812853Sgabeblack@google.com    // reduce methods
87912853Sgabeblack@google.com    bool and_reduce() const;
88012853Sgabeblack@google.com    bool nand_reduce() const;
88112853Sgabeblack@google.com    bool or_reduce() const;
88212853Sgabeblack@google.com    bool nor_reduce() const;
88312853Sgabeblack@google.com    bool xor_reduce() const ;
88412853Sgabeblack@google.com    bool xnor_reduce() const;
88512853Sgabeblack@google.com
88612853Sgabeblack@google.com    // other methods
88712853Sgabeblack@google.com    void
88812853Sgabeblack@google.com    print(::std::ostream &os=::std::cout) const
88912853Sgabeblack@google.com    {
89012853Sgabeblack@google.com        os << to_string(sc_io_base(os, SC_DEC), sc_io_show_base(os));
89112853Sgabeblack@google.com    }
89212853Sgabeblack@google.com
89312853Sgabeblack@google.com  protected:
89412853Sgabeblack@google.com    int m_left; // Left-most bit in this part selection.
89512853Sgabeblack@google.com    sc_signed *m_obj_p; // Target of this part selection.
89612853Sgabeblack@google.com    int m_right; // Right-most bit in this part selection.
89712853Sgabeblack@google.com
89812853Sgabeblack@google.com  private:
89912853Sgabeblack@google.com    const sc_signed_subref_r &operator = (const sc_signed_subref_r &);
90012853Sgabeblack@google.com};
90112853Sgabeblack@google.com
90212853Sgabeblack@google.cominline ::std::ostream &operator << (
90312853Sgabeblack@google.com        ::std::ostream &, const sc_signed_subref_r &);
90412853Sgabeblack@google.com
90512853Sgabeblack@google.com
90612853Sgabeblack@google.com// ----------------------------------------------------------------------------
90712853Sgabeblack@google.com//  CLASS : sc_signed_subref
90812853Sgabeblack@google.com//
90912853Sgabeblack@google.com//  Proxy class for sc_signed part selection (r-value and l-value).
91012853Sgabeblack@google.com// ----------------------------------------------------------------------------
91112853Sgabeblack@google.com
91212853Sgabeblack@google.comclass sc_signed_subref : public sc_signed_subref_r
91312853Sgabeblack@google.com{
91412853Sgabeblack@google.com    friend class sc_signed;
91512853Sgabeblack@google.com    friend class sc_core::sc_vpool<sc_signed_subref>;
91612853Sgabeblack@google.com
91712853Sgabeblack@google.com    // constructor
91812853Sgabeblack@google.com    sc_signed_subref() : sc_signed_subref_r() {}
91912853Sgabeblack@google.com
92012853Sgabeblack@google.com  public:
92112853Sgabeblack@google.com    // copy constructor
92212853Sgabeblack@google.com    sc_signed_subref(const sc_signed_subref &a) : sc_signed_subref_r(a) {}
92312853Sgabeblack@google.com
92412853Sgabeblack@google.com    // assignment operators
92512853Sgabeblack@google.com    const sc_signed_subref &operator = (const sc_signed_subref_r &a);
92612853Sgabeblack@google.com    const sc_signed_subref &operator = (const sc_signed_subref &a);
92712853Sgabeblack@google.com    const sc_signed_subref &operator = (const sc_signed &a);
92812853Sgabeblack@google.com
92912853Sgabeblack@google.com    const sc_signed_subref &operator = (const sc_unsigned_subref_r &a);
93012853Sgabeblack@google.com    const sc_signed_subref &operator = (const sc_unsigned &a);
93112853Sgabeblack@google.com
93212853Sgabeblack@google.com    template< class T >
93312853Sgabeblack@google.com    const sc_signed_subref &
93412853Sgabeblack@google.com    operator = (const sc_generic_base<T> &a)
93512853Sgabeblack@google.com    {
93612853Sgabeblack@google.com        sc_unsigned temp(length());
93712853Sgabeblack@google.com        a->to_sc_unsigned(temp);
93812853Sgabeblack@google.com        return operator = (temp);
93912853Sgabeblack@google.com    }
94012853Sgabeblack@google.com
94112853Sgabeblack@google.com    const sc_signed_subref &operator = (const char *a);
94212853Sgabeblack@google.com    const sc_signed_subref &operator = (unsigned long a);
94312853Sgabeblack@google.com    const sc_signed_subref &operator = (long a);
94412853Sgabeblack@google.com    const sc_signed_subref &
94512853Sgabeblack@google.com    operator = (unsigned int a)
94612853Sgabeblack@google.com    {
94712853Sgabeblack@google.com        return operator = ((unsigned long)a);
94812853Sgabeblack@google.com    }
94912853Sgabeblack@google.com
95012853Sgabeblack@google.com    const sc_signed_subref &
95112853Sgabeblack@google.com    operator = (int a)
95212853Sgabeblack@google.com    {
95312853Sgabeblack@google.com        return operator = ((long)a);
95412853Sgabeblack@google.com    }
95512853Sgabeblack@google.com
95612853Sgabeblack@google.com    const sc_signed_subref &operator = (uint64 a);
95712853Sgabeblack@google.com    const sc_signed_subref &operator = (int64 a);
95812853Sgabeblack@google.com    const sc_signed_subref &operator = (double a);
95912853Sgabeblack@google.com    const sc_signed_subref &operator = (const sc_int_base &a);
96012853Sgabeblack@google.com    const sc_signed_subref &operator = (const sc_uint_base &a);
96112853Sgabeblack@google.com
96212853Sgabeblack@google.com    // concatenation methods
96312853Sgabeblack@google.com    virtual void concat_set(int64 src, int low_i);
96412853Sgabeblack@google.com    virtual void concat_set(const sc_signed &src, int low_i);
96512853Sgabeblack@google.com    virtual void concat_set(const sc_unsigned &src, int low_i);
96612853Sgabeblack@google.com    virtual void concat_set(uint64 src, int low_i);
96712853Sgabeblack@google.com
96812853Sgabeblack@google.com    // other methods
96912853Sgabeblack@google.com    void scan(::std::istream &is=::std::cin);
97012853Sgabeblack@google.com
97112853Sgabeblack@google.com  protected:
97212853Sgabeblack@google.com    static sc_core::sc_vpool<sc_signed_subref> m_pool;
97312853Sgabeblack@google.com};
97412853Sgabeblack@google.com
97512853Sgabeblack@google.cominline ::std::istream &operator >> (::std::istream &, sc_signed_subref &);
97612853Sgabeblack@google.com
97712853Sgabeblack@google.com
97812853Sgabeblack@google.com// ----------------------------------------------------------------------------
97912853Sgabeblack@google.com//  CLASS : sc_signed
98012853Sgabeblack@google.com//
98112853Sgabeblack@google.com//  Arbitrary precision signed number.
98212853Sgabeblack@google.com// ----------------------------------------------------------------------------
98312853Sgabeblack@google.com
98412853Sgabeblack@google.comclass sc_signed : public sc_value_base
98512853Sgabeblack@google.com{
98612853Sgabeblack@google.com    friend class sc_concatref;
98712853Sgabeblack@google.com    friend class sc_signed_bitref_r;
98812853Sgabeblack@google.com    friend class sc_signed_bitref;
98912853Sgabeblack@google.com    friend class sc_signed_subref_r;
99012853Sgabeblack@google.com    friend class sc_signed_subref;
99112853Sgabeblack@google.com    friend class sc_unsigned;
99212853Sgabeblack@google.com    friend class sc_unsigned_subref;
99312853Sgabeblack@google.com
99412853Sgabeblack@google.com    // Needed for types using sc_signed.
99512853Sgabeblack@google.com    typedef bool elemtype;
99612853Sgabeblack@google.com
99712853Sgabeblack@google.com    void invalid_init(const char *type_name, int nb) const;
99812853Sgabeblack@google.com
99912853Sgabeblack@google.com  public:
100012853Sgabeblack@google.com    // constructors
100112853Sgabeblack@google.com    explicit sc_signed(int nb=sc_length_param().len());
100212853Sgabeblack@google.com    sc_signed(const sc_signed &v);
100312853Sgabeblack@google.com    sc_signed(const sc_unsigned &v);
100412853Sgabeblack@google.com    template<class T>
100512853Sgabeblack@google.com    explicit sc_signed(const sc_generic_base<T> &v);
100612853Sgabeblack@google.com    explicit sc_signed(const sc_bv_base &v);
100712853Sgabeblack@google.com    explicit sc_signed(const sc_lv_base &v);
100812853Sgabeblack@google.com    explicit sc_signed(const sc_int_subref_r &v);
100912853Sgabeblack@google.com    explicit sc_signed(const sc_uint_subref_r &v);
101012853Sgabeblack@google.com    explicit sc_signed(const sc_signed_subref_r &v);
101112853Sgabeblack@google.com    explicit sc_signed(const sc_unsigned_subref_r &v);
101212853Sgabeblack@google.com
101312853Sgabeblack@google.com    // assignment operators
101412853Sgabeblack@google.com    const sc_signed &operator = (const sc_signed &v);
101512853Sgabeblack@google.com    const sc_signed &operator = (const sc_signed_subref_r &a);
101612853Sgabeblack@google.com
101712853Sgabeblack@google.com    template< class T >
101812853Sgabeblack@google.com    const sc_signed &
101912853Sgabeblack@google.com    operator = (const sc_generic_base<T> &a)
102012853Sgabeblack@google.com    {
102112853Sgabeblack@google.com        a->to_sc_signed(*this);
102212853Sgabeblack@google.com        return *this;
102312853Sgabeblack@google.com    }
102412853Sgabeblack@google.com
102512853Sgabeblack@google.com    const sc_signed &operator = (const sc_unsigned &v);
102612853Sgabeblack@google.com    const sc_signed &operator = (const sc_unsigned_subref_r &a);
102712853Sgabeblack@google.com
102812853Sgabeblack@google.com    const sc_signed &operator = (const char *v);
102912853Sgabeblack@google.com    const sc_signed &operator = (int64 v);
103012853Sgabeblack@google.com    const sc_signed &operator = (uint64 v);
103112853Sgabeblack@google.com    const sc_signed &operator = (long v);
103212853Sgabeblack@google.com    const sc_signed &operator = (unsigned long v);
103312853Sgabeblack@google.com
103412853Sgabeblack@google.com    const sc_signed &operator = (int v) { return operator=((long)v); }
103512853Sgabeblack@google.com
103612853Sgabeblack@google.com    const sc_signed &
103712853Sgabeblack@google.com    operator = (unsigned int v)
103812853Sgabeblack@google.com    {
103912853Sgabeblack@google.com        return operator=((unsigned long)v);
104012853Sgabeblack@google.com    }
104112853Sgabeblack@google.com
104212853Sgabeblack@google.com    const sc_signed &operator = (double v);
104312853Sgabeblack@google.com    const sc_signed &operator = (const sc_int_base & v);
104412853Sgabeblack@google.com    const sc_signed &operator = (const sc_uint_base & v);
104512853Sgabeblack@google.com
104612853Sgabeblack@google.com    const sc_signed &operator = (const sc_bv_base &);
104712853Sgabeblack@google.com    const sc_signed &operator = (const sc_lv_base &);
104812853Sgabeblack@google.com
104912853Sgabeblack@google.com    const sc_signed &operator = (const sc_fxval &);
105012853Sgabeblack@google.com    const sc_signed &operator = (const sc_fxval_fast &);
105112853Sgabeblack@google.com    const sc_signed &operator = (const sc_fxnum &);
105212853Sgabeblack@google.com    const sc_signed &operator = (const sc_fxnum_fast &);
105312853Sgabeblack@google.com
105412853Sgabeblack@google.com    // destructor
105512853Sgabeblack@google.com    virtual ~sc_signed()
105612853Sgabeblack@google.com    {
105712853Sgabeblack@google.com#ifndef SC_MAX_NBITS
105812853Sgabeblack@google.com        delete [] digit;
105912853Sgabeblack@google.com#endif
106012853Sgabeblack@google.com    }
106112853Sgabeblack@google.com
106212853Sgabeblack@google.com    // Concatenation support:
106312853Sgabeblack@google.com    sc_digit* get_raw() const { return digit; }
106412853Sgabeblack@google.com    virtual int
106512853Sgabeblack@google.com    concat_length(bool* xz_present_p) const
106612853Sgabeblack@google.com    {
106712853Sgabeblack@google.com        if (xz_present_p)
106812853Sgabeblack@google.com            *xz_present_p = false;
106912853Sgabeblack@google.com        return nbits;
107012853Sgabeblack@google.com    }
107112853Sgabeblack@google.com    virtual bool concat_get_ctrl(sc_digit *dst_p, int low_i) const;
107212853Sgabeblack@google.com    virtual bool concat_get_data(sc_digit *dst_p, int low_i) const;
107312853Sgabeblack@google.com    virtual uint64 concat_get_uint64() const;
107412853Sgabeblack@google.com    virtual void concat_set(int64 src, int low_i);
107512853Sgabeblack@google.com    virtual void concat_set(const sc_signed &src, int low_i);
107612853Sgabeblack@google.com    virtual void concat_set(const sc_unsigned &src, int low_i);
107712853Sgabeblack@google.com    virtual void concat_set(uint64 src, int low_i);
107812853Sgabeblack@google.com
107912853Sgabeblack@google.com    // Increment operators.
108012853Sgabeblack@google.com    sc_signed &operator ++ ();
108112853Sgabeblack@google.com    const sc_signed operator ++ (int);
108212853Sgabeblack@google.com
108312853Sgabeblack@google.com    // Decrement operators.
108412853Sgabeblack@google.com    sc_signed &operator -- ();
108512853Sgabeblack@google.com    const sc_signed operator -- (int);
108612853Sgabeblack@google.com
108712853Sgabeblack@google.com    // bit selection
108812853Sgabeblack@google.com    inline void
108912853Sgabeblack@google.com    check_index(int i) const
109012853Sgabeblack@google.com    {
109112853Sgabeblack@google.com        if (i < 0 || i >= nbits)
109212853Sgabeblack@google.com            invalid_index(i);
109312853Sgabeblack@google.com    }
109412853Sgabeblack@google.com
109512853Sgabeblack@google.com    void invalid_index(int i) const;
109612853Sgabeblack@google.com
109712853Sgabeblack@google.com    sc_signed_bitref &
109812853Sgabeblack@google.com    operator [] (int i)
109912853Sgabeblack@google.com    {
110012853Sgabeblack@google.com        check_index(i);
110112853Sgabeblack@google.com        sc_signed_bitref *result_p = sc_signed_bitref::m_pool.allocate();
110212853Sgabeblack@google.com        result_p->initialize(this, i);
110312853Sgabeblack@google.com        return *result_p;
110412853Sgabeblack@google.com    }
110512853Sgabeblack@google.com
110612853Sgabeblack@google.com    const sc_signed_bitref_r &
110712853Sgabeblack@google.com    operator [] (int i) const
110812853Sgabeblack@google.com    {
110912853Sgabeblack@google.com        check_index(i);
111012853Sgabeblack@google.com        sc_signed_bitref *result_p = sc_signed_bitref::m_pool.allocate();
111112853Sgabeblack@google.com        result_p->initialize(this, i);
111212853Sgabeblack@google.com        return *result_p;
111312853Sgabeblack@google.com    }
111412853Sgabeblack@google.com
111512853Sgabeblack@google.com    sc_signed_bitref &
111612853Sgabeblack@google.com    bit(int i)
111712853Sgabeblack@google.com    {
111812853Sgabeblack@google.com        check_index(i);
111912853Sgabeblack@google.com        sc_signed_bitref *result_p = sc_signed_bitref::m_pool.allocate();
112012853Sgabeblack@google.com        result_p->initialize(this, i);
112112853Sgabeblack@google.com        return *result_p;
112212853Sgabeblack@google.com    }
112312853Sgabeblack@google.com
112412853Sgabeblack@google.com    const sc_signed_bitref_r &
112512853Sgabeblack@google.com    bit(int i) const
112612853Sgabeblack@google.com    {
112712853Sgabeblack@google.com        check_index(i);
112812853Sgabeblack@google.com        sc_signed_bitref *result_p = sc_signed_bitref::m_pool.allocate();
112912853Sgabeblack@google.com        result_p->initialize(this, i);
113012853Sgabeblack@google.com        return *result_p;
113112853Sgabeblack@google.com    }
113212853Sgabeblack@google.com
113312853Sgabeblack@google.com
113412853Sgabeblack@google.com    // part selection
113512853Sgabeblack@google.com
113612853Sgabeblack@google.com    // Subref operators. Help access the range of bits from the ith to
113712853Sgabeblack@google.com    // jth. These indices have arbitrary precedence with respect to each
113812853Sgabeblack@google.com    // other, i.e., we can have i <= j or i > j. Note the equivalence
113912853Sgabeblack@google.com    // between range(i, j) and operator(i, j). Also note that
114012853Sgabeblack@google.com    // operator(i, i) returns a signed number that corresponds to the
114112853Sgabeblack@google.com    // bit operator[i], so these two forms are not the same.
114212853Sgabeblack@google.com
114312853Sgabeblack@google.com    inline void
114412853Sgabeblack@google.com    check_range(int l, int r) const
114512853Sgabeblack@google.com    {
114612853Sgabeblack@google.com        if (l < r)
114712853Sgabeblack@google.com        {
114812853Sgabeblack@google.com            if (l < 0 || r >= nbits)
114912853Sgabeblack@google.com                invalid_range(l, r);
115012853Sgabeblack@google.com        } else {
115112853Sgabeblack@google.com            if (r < 0 || l >= nbits)
115212853Sgabeblack@google.com                invalid_range(l, r);
115312853Sgabeblack@google.com        }
115412853Sgabeblack@google.com    }
115512853Sgabeblack@google.com
115612853Sgabeblack@google.com    void invalid_range(int l, int r) const;
115712853Sgabeblack@google.com
115812853Sgabeblack@google.com    sc_signed_subref &
115912853Sgabeblack@google.com    range(int i, int j)
116012853Sgabeblack@google.com    {
116112853Sgabeblack@google.com        check_range(i, j);
116212853Sgabeblack@google.com        sc_signed_subref *result_p = sc_signed_subref::m_pool.allocate();
116312853Sgabeblack@google.com        result_p->initialize(this, i, j);
116412853Sgabeblack@google.com        return *result_p;
116512853Sgabeblack@google.com    }
116612853Sgabeblack@google.com
116712853Sgabeblack@google.com    const sc_signed_subref_r &
116812853Sgabeblack@google.com    range(int i, int j) const
116912853Sgabeblack@google.com    {
117012853Sgabeblack@google.com        check_range(i, j);
117112853Sgabeblack@google.com        sc_signed_subref *result_p = sc_signed_subref::m_pool.allocate();
117212853Sgabeblack@google.com        result_p->initialize(this, i, j);
117312853Sgabeblack@google.com        return *result_p;
117412853Sgabeblack@google.com    }
117512853Sgabeblack@google.com
117612853Sgabeblack@google.com    sc_signed_subref &
117712853Sgabeblack@google.com    operator () (int i, int j)
117812853Sgabeblack@google.com    {
117912853Sgabeblack@google.com        check_range(i, j);
118012853Sgabeblack@google.com        sc_signed_subref *result_p = sc_signed_subref::m_pool.allocate();
118112853Sgabeblack@google.com        result_p->initialize(this, i, j);
118212853Sgabeblack@google.com        return *result_p;
118312853Sgabeblack@google.com    }
118412853Sgabeblack@google.com
118512853Sgabeblack@google.com    const sc_signed_subref_r &
118612853Sgabeblack@google.com    operator () (int i, int j) const
118712853Sgabeblack@google.com    {
118812853Sgabeblack@google.com        check_range(i, j);
118912853Sgabeblack@google.com        sc_signed_subref *result_p = sc_signed_subref::m_pool.allocate();
119012853Sgabeblack@google.com        result_p->initialize(this, i, j);
119112853Sgabeblack@google.com        return *result_p;
119212853Sgabeblack@google.com    }
119312853Sgabeblack@google.com
119412853Sgabeblack@google.com
119512853Sgabeblack@google.com    // explicit conversions
119612853Sgabeblack@google.com    int to_int() const;
119712853Sgabeblack@google.com    unsigned int to_uint() const;
119812853Sgabeblack@google.com    long to_long() const;
119912853Sgabeblack@google.com    unsigned long to_ulong() const;
120012853Sgabeblack@google.com    int64 to_int64() const;
120112853Sgabeblack@google.com    uint64 to_uint64() const;
120212853Sgabeblack@google.com    double to_double() const;
120312853Sgabeblack@google.com
120412853Sgabeblack@google.com
120512853Sgabeblack@google.com    // explicit conversion to character string
120612853Sgabeblack@google.com    const std::string to_string(sc_numrep numrep=SC_DEC) const;
120712853Sgabeblack@google.com    const std::string to_string(sc_numrep numrep, bool w_prefix) const;
120812853Sgabeblack@google.com
120912853Sgabeblack@google.com
121012853Sgabeblack@google.com    // Print functions. dump prints the internals of the class.
121112853Sgabeblack@google.com    void
121212853Sgabeblack@google.com    print(::std::ostream &os=::std::cout) const
121312853Sgabeblack@google.com    {
121412853Sgabeblack@google.com        os << to_string(sc_io_base(os, SC_DEC), sc_io_show_base(os));
121512853Sgabeblack@google.com    }
121612853Sgabeblack@google.com
121712853Sgabeblack@google.com    void scan(::std::istream &is=::std::cin);
121812853Sgabeblack@google.com
121912853Sgabeblack@google.com    void dump(::std::ostream &os=::std::cout) const;
122012853Sgabeblack@google.com
122112853Sgabeblack@google.com    // Functions to find various properties.
122212853Sgabeblack@google.com    int length() const { return nbits; } // Bit width.
122312853Sgabeblack@google.com    bool iszero() const; // Is the number zero?
122412853Sgabeblack@google.com    bool sign() const; // Sign.
122512853Sgabeblack@google.com
122612853Sgabeblack@google.com   // reduce methods
122712853Sgabeblack@google.com    bool and_reduce() const;
122812853Sgabeblack@google.com    bool nand_reduce() const { return !and_reduce(); }
122912853Sgabeblack@google.com    bool or_reduce() const;
123012853Sgabeblack@google.com    bool nor_reduce() const { return !or_reduce(); }
123112853Sgabeblack@google.com    bool xor_reduce() const;
123212853Sgabeblack@google.com    bool xnor_reduce() const { return !xor_reduce(); }
123312853Sgabeblack@google.com
123412853Sgabeblack@google.com    // Functions to access individual bits.
123512853Sgabeblack@google.com    bool test(int i) const; // Is the ith bit 0 or 1?
123612853Sgabeblack@google.com    void set(int i); // Set the ith bit to 1.
123712853Sgabeblack@google.com    void clear(int i); // Set the ith bit to 0.
123812853Sgabeblack@google.com    void
123912853Sgabeblack@google.com    set(int i, bool v) // Set the ith bit to v.
124012853Sgabeblack@google.com    {
124112853Sgabeblack@google.com        if (v)
124212853Sgabeblack@google.com            set(i);
124312853Sgabeblack@google.com        else
124412853Sgabeblack@google.com            clear(i);
124512853Sgabeblack@google.com    }
124612853Sgabeblack@google.com    void
124712853Sgabeblack@google.com    invert(int i) // Negate the ith bit.
124812853Sgabeblack@google.com    {
124912853Sgabeblack@google.com        if (test(i))
125012853Sgabeblack@google.com            clear(i);
125112853Sgabeblack@google.com        else set(i);
125212853Sgabeblack@google.com    }
125312853Sgabeblack@google.com
125412853Sgabeblack@google.com    // Make the number equal to its mirror image.
125512853Sgabeblack@google.com    void reverse();
125612853Sgabeblack@google.com
125712853Sgabeblack@google.com    // Get/set a packed bit representation of the number.
125812853Sgabeblack@google.com    void get_packed_rep(sc_digit *buf) const;
125912853Sgabeblack@google.com    void set_packed_rep(sc_digit *buf);
126012853Sgabeblack@google.com
126112853Sgabeblack@google.com    /*
126212853Sgabeblack@google.com        The comparison of the old and new semantics are as follows:
126312853Sgabeblack@google.com
126412853Sgabeblack@google.com        Let s = sc_signed,
126512853Sgabeblack@google.com            u = sc_unsigned,
126612853Sgabeblack@google.com            un = { uint64, unsigned long, unsigned int },
126712853Sgabeblack@google.com            sn = { int64, long, int, char* }, and
126812853Sgabeblack@google.com            OP = { +, -, *, /, % }.
126912853Sgabeblack@google.com
127012853Sgabeblack@google.com        Old semantics:                     New semantics:
127112853Sgabeblack@google.com          u OP u -> u                        u OP u -> u
127212853Sgabeblack@google.com          s OP u -> u                        s OP u -> s
127312853Sgabeblack@google.com          u OP s -> u                        u OP s -> s
127412853Sgabeblack@google.com          s OP s -> s                        s OP s -> s
127512853Sgabeblack@google.com
127612853Sgabeblack@google.com          u OP un = un OP u -> u             u OP un = un OP u -> u
127712853Sgabeblack@google.com          u OP sn = sn OP u -> u             u OP sn = sn OP u -> s
127812853Sgabeblack@google.com
127912853Sgabeblack@google.com          s OP un = un OP s -> s             s OP un = un OP s -> s
128012853Sgabeblack@google.com          s OP sn = sn OP s -> s             s OP sn = sn OP s -> s
128112853Sgabeblack@google.com
128212853Sgabeblack@google.com        In the new semantics, the result is u if both operands are u; the
128312853Sgabeblack@google.com        result is s otherwise. The only exception is subtraction. The result
128412853Sgabeblack@google.com        of a subtraction is always s.
128512853Sgabeblack@google.com
128612853Sgabeblack@google.com        The old semantics is like C/C++ semantics on integer types; the
128712853Sgabeblack@google.com        new semantics is due to the VSIA C/C++ data types standard.
128812853Sgabeblack@google.com    */
128912853Sgabeblack@google.com
129012853Sgabeblack@google.com    // ARITHMETIC OPERATORS:
129112853Sgabeblack@google.com
129212853Sgabeblack@google.com    // ADDition operators:
129312853Sgabeblack@google.com    friend sc_signed operator + (const sc_unsigned &u, const sc_signed &v);
129412853Sgabeblack@google.com    friend sc_signed operator + (const sc_signed &u, const sc_unsigned &v);
129512853Sgabeblack@google.com
129612853Sgabeblack@google.com    friend sc_signed operator + (const sc_unsigned &u, int64 v);
129712853Sgabeblack@google.com    friend sc_signed operator + (const sc_unsigned &u, long v);
129812853Sgabeblack@google.com    friend sc_signed
129912853Sgabeblack@google.com    operator + (const sc_unsigned &u, int v)
130012853Sgabeblack@google.com    {
130112853Sgabeblack@google.com        return operator + (u, (long)v);
130212853Sgabeblack@google.com    }
130312853Sgabeblack@google.com
130412853Sgabeblack@google.com    friend sc_signed operator + (int64 u, const sc_unsigned &v);
130512853Sgabeblack@google.com    friend sc_signed operator + (long u, const sc_unsigned &v);
130612853Sgabeblack@google.com    friend sc_signed
130712853Sgabeblack@google.com    operator + (int u, const sc_unsigned &v)
130812853Sgabeblack@google.com    {
130912853Sgabeblack@google.com        return operator + ((long)u, v);
131012853Sgabeblack@google.com    }
131112853Sgabeblack@google.com
131212853Sgabeblack@google.com    friend sc_signed operator + (const sc_signed &u, const sc_signed &v);
131312853Sgabeblack@google.com    friend sc_signed operator + (const sc_signed &u, int64 v);
131412853Sgabeblack@google.com    friend sc_signed operator + (const sc_signed &u, uint64 v);
131512853Sgabeblack@google.com    friend sc_signed operator + (const sc_signed &u, long v);
131612853Sgabeblack@google.com    friend sc_signed operator + (const sc_signed &u, unsigned long v);
131712853Sgabeblack@google.com    friend sc_signed
131812853Sgabeblack@google.com    operator + (const sc_signed &u, int v)
131912853Sgabeblack@google.com    {
132012853Sgabeblack@google.com        return operator + (u, (long)v);
132112853Sgabeblack@google.com    }
132212853Sgabeblack@google.com    friend sc_signed
132312853Sgabeblack@google.com    operator + (const sc_signed &u, unsigned int v)
132412853Sgabeblack@google.com    {
132512853Sgabeblack@google.com        return operator + (u, (unsigned long)v);
132612853Sgabeblack@google.com    }
132712853Sgabeblack@google.com
132812853Sgabeblack@google.com    friend sc_signed operator + (int64 u, const sc_signed &v);
132912853Sgabeblack@google.com    friend sc_signed operator + (uint64 u, const sc_signed &v);
133012853Sgabeblack@google.com    friend sc_signed operator + (long u, const sc_signed &v);
133112853Sgabeblack@google.com    friend sc_signed operator + (unsigned long u, const sc_signed &v);
133212853Sgabeblack@google.com    friend sc_signed
133312853Sgabeblack@google.com    operator + (int u, const sc_signed &v)
133412853Sgabeblack@google.com    {
133512853Sgabeblack@google.com        return operator + ((long)u, v);
133612853Sgabeblack@google.com    }
133712853Sgabeblack@google.com    friend sc_signed
133812853Sgabeblack@google.com    operator + (unsigned int u, const sc_signed &v)
133912853Sgabeblack@google.com    {
134012853Sgabeblack@google.com        return operator + ((unsigned long)u, v);
134112853Sgabeblack@google.com    }
134212853Sgabeblack@google.com
134312853Sgabeblack@google.com    const sc_signed &operator += (const sc_signed &v);
134412853Sgabeblack@google.com    const sc_signed &operator += (const sc_unsigned &v);
134512853Sgabeblack@google.com    const sc_signed &operator += (int64 v);
134612853Sgabeblack@google.com    const sc_signed &operator += (uint64 v);
134712853Sgabeblack@google.com    const sc_signed &operator += (long v);
134812853Sgabeblack@google.com    const sc_signed &operator += (unsigned long v);
134912853Sgabeblack@google.com    const sc_signed &
135012853Sgabeblack@google.com    operator += (int v)
135112853Sgabeblack@google.com    {
135212853Sgabeblack@google.com        return operator += ((long)v);
135312853Sgabeblack@google.com    }
135412853Sgabeblack@google.com    const sc_signed &
135512853Sgabeblack@google.com    operator += (unsigned int v)
135612853Sgabeblack@google.com    {
135712853Sgabeblack@google.com        return operator += ((unsigned long)v);
135812853Sgabeblack@google.com    }
135912853Sgabeblack@google.com
136012853Sgabeblack@google.com    friend sc_signed operator + (const sc_unsigned &u, const sc_int_base &v);
136112853Sgabeblack@google.com    friend sc_signed operator + (const sc_int_base &u, const sc_unsigned &v);
136212853Sgabeblack@google.com    friend sc_signed operator + (const sc_signed &u, const sc_int_base &v);
136312853Sgabeblack@google.com    friend sc_signed operator + (const sc_signed &u, const sc_uint_base &v);
136412853Sgabeblack@google.com    friend sc_signed operator + (const sc_int_base &u, const sc_signed &v);
136512853Sgabeblack@google.com    friend sc_signed operator + (const sc_uint_base &u, const sc_signed &v);
136612853Sgabeblack@google.com    const sc_signed & operator += (const sc_int_base &v);
136712853Sgabeblack@google.com    const sc_signed & operator += (const sc_uint_base &v);
136812853Sgabeblack@google.com
136912853Sgabeblack@google.com    // SUBtraction operators:
137012853Sgabeblack@google.com    friend sc_signed operator - (const sc_unsigned &u, const sc_signed &v);
137112853Sgabeblack@google.com    friend sc_signed operator - (const sc_signed &u, const sc_unsigned &v);
137212853Sgabeblack@google.com
137312853Sgabeblack@google.com    friend sc_signed operator - (const sc_unsigned &u, const sc_unsigned &v);
137412853Sgabeblack@google.com    friend sc_signed operator - (const sc_unsigned &u, int64 v);
137512853Sgabeblack@google.com    friend sc_signed operator - (const sc_unsigned &u, uint64 v);
137612853Sgabeblack@google.com    friend sc_signed operator - (const sc_unsigned &u, long v);
137712853Sgabeblack@google.com    friend sc_signed operator - (const sc_unsigned &u, unsigned long v);
137812853Sgabeblack@google.com    friend sc_signed
137912853Sgabeblack@google.com    operator - (const sc_unsigned &u, int v)
138012853Sgabeblack@google.com    {
138112853Sgabeblack@google.com        return operator - (u, (long)v);
138212853Sgabeblack@google.com    }
138312853Sgabeblack@google.com    friend sc_signed
138412853Sgabeblack@google.com    operator - (const sc_unsigned &u, unsigned int v)
138512853Sgabeblack@google.com    {
138612853Sgabeblack@google.com        return operator - (u, (unsigned long)v);
138712853Sgabeblack@google.com    }
138812853Sgabeblack@google.com
138912853Sgabeblack@google.com    friend sc_signed operator - (int64 u, const sc_unsigned &v);
139012853Sgabeblack@google.com    friend sc_signed operator - (uint64 u, const sc_unsigned &v);
139112853Sgabeblack@google.com    friend sc_signed operator - (long u, const sc_unsigned &v);
139212853Sgabeblack@google.com    friend sc_signed operator - (unsigned long u, const sc_unsigned &v);
139312853Sgabeblack@google.com    friend sc_signed
139412853Sgabeblack@google.com    operator - (int u, const sc_unsigned &v)
139512853Sgabeblack@google.com    {
139612853Sgabeblack@google.com        return operator - ((long)u, v);
139712853Sgabeblack@google.com    }
139812853Sgabeblack@google.com    friend sc_signed
139912853Sgabeblack@google.com    operator - (unsigned int u, const sc_unsigned &v)
140012853Sgabeblack@google.com    {
140112853Sgabeblack@google.com        return operator - ((unsigned long)u, v);
140212853Sgabeblack@google.com    }
140312853Sgabeblack@google.com
140412853Sgabeblack@google.com    friend sc_signed operator - (const sc_signed &u, const sc_signed &v);
140512853Sgabeblack@google.com    friend sc_signed operator - (const sc_signed &u, int64 v);
140612853Sgabeblack@google.com    friend sc_signed operator - (const sc_signed &u, uint64 v);
140712853Sgabeblack@google.com    friend sc_signed operator - (const sc_signed &u, long v);
140812853Sgabeblack@google.com    friend sc_signed operator - (const sc_signed &u, unsigned long v);
140912853Sgabeblack@google.com    friend sc_signed
141012853Sgabeblack@google.com    operator - (const sc_signed &u, int v)
141112853Sgabeblack@google.com    {
141212853Sgabeblack@google.com        return operator - (u, (long) v);
141312853Sgabeblack@google.com    }
141412853Sgabeblack@google.com    friend sc_signed
141512853Sgabeblack@google.com    operator - (const sc_signed &u, unsigned int v)
141612853Sgabeblack@google.com    {
141712853Sgabeblack@google.com        return operator - (u, (unsigned long)v);
141812853Sgabeblack@google.com    }
141912853Sgabeblack@google.com
142012853Sgabeblack@google.com    friend sc_signed operator - (int64 u, const sc_signed &v);
142112853Sgabeblack@google.com    friend sc_signed operator - (uint64 u, const sc_signed &v);
142212853Sgabeblack@google.com    friend sc_signed operator - (long u, const sc_signed &v);
142312853Sgabeblack@google.com    friend sc_signed operator - (unsigned long u, const sc_signed &v);
142412853Sgabeblack@google.com    friend sc_signed
142512853Sgabeblack@google.com    operator - (int u, const sc_signed &v)
142612853Sgabeblack@google.com    {
142712853Sgabeblack@google.com        return operator - ((long)u, v);
142812853Sgabeblack@google.com    }
142912853Sgabeblack@google.com    friend sc_signed
143012853Sgabeblack@google.com    operator - (unsigned int u, const sc_signed &v)
143112853Sgabeblack@google.com    {
143212853Sgabeblack@google.com        return operator - ((unsigned long)u, v);
143312853Sgabeblack@google.com    }
143412853Sgabeblack@google.com
143512853Sgabeblack@google.com    const sc_signed &operator -= (const sc_signed &v);
143612853Sgabeblack@google.com    const sc_signed &operator -= (const sc_unsigned &v);
143712853Sgabeblack@google.com    const sc_signed &operator -= (int64 v);
143812853Sgabeblack@google.com    const sc_signed &operator -= (uint64 v);
143912853Sgabeblack@google.com    const sc_signed &operator -= (long v);
144012853Sgabeblack@google.com    const sc_signed &operator -= (unsigned long v);
144112853Sgabeblack@google.com    const sc_signed &
144212853Sgabeblack@google.com    operator -= (int v)
144312853Sgabeblack@google.com    {
144412853Sgabeblack@google.com        return operator -= ((long)v);
144512853Sgabeblack@google.com    }
144612853Sgabeblack@google.com    const sc_signed &
144712853Sgabeblack@google.com    operator -= (unsigned int v)
144812853Sgabeblack@google.com    {
144912853Sgabeblack@google.com        return operator -= ((unsigned long)v);
145012853Sgabeblack@google.com    }
145112853Sgabeblack@google.com
145212853Sgabeblack@google.com    friend sc_signed operator - (const sc_unsigned &u, const sc_int_base &v);
145312853Sgabeblack@google.com    friend sc_signed operator - (const sc_unsigned &u, const sc_uint_base &v);
145412853Sgabeblack@google.com    friend sc_signed operator - (const sc_int_base &u, const sc_unsigned &v);
145512853Sgabeblack@google.com    friend sc_signed operator - (const sc_uint_base &u, const sc_unsigned &v);
145612853Sgabeblack@google.com    friend sc_signed operator - (const sc_signed &u, const sc_int_base &v);
145712853Sgabeblack@google.com    friend sc_signed operator - (const sc_signed &u, const sc_uint_base &v);
145812853Sgabeblack@google.com    friend sc_signed operator - (const sc_int_base &u, const sc_signed &v);
145912853Sgabeblack@google.com    friend sc_signed operator - (const sc_uint_base &u, const sc_signed &v);
146012853Sgabeblack@google.com    const sc_signed &operator -= (const sc_int_base &v);
146112853Sgabeblack@google.com    const sc_signed &operator -= (const sc_uint_base &v);
146212853Sgabeblack@google.com
146312853Sgabeblack@google.com    // MULtiplication operators:
146412853Sgabeblack@google.com    friend sc_signed operator * (const sc_unsigned &u, const sc_signed &v);
146512853Sgabeblack@google.com    friend sc_signed operator * (const sc_signed &u, const sc_unsigned &v);
146612853Sgabeblack@google.com
146712853Sgabeblack@google.com    friend sc_signed operator * (const sc_unsigned &u, int64 v);
146812853Sgabeblack@google.com    friend sc_signed operator * (const sc_unsigned &u, long v);
146912853Sgabeblack@google.com    friend sc_signed
147012853Sgabeblack@google.com    operator * (const sc_unsigned &u, int v)
147112853Sgabeblack@google.com    {
147212853Sgabeblack@google.com        return operator * (u, (long)v);
147312853Sgabeblack@google.com    }
147412853Sgabeblack@google.com
147512853Sgabeblack@google.com    friend sc_signed operator * (int64 u, const sc_unsigned &v);
147612853Sgabeblack@google.com    friend sc_signed operator * (long u, const sc_unsigned &v);
147712853Sgabeblack@google.com    friend sc_signed
147812853Sgabeblack@google.com    operator * (int u, const sc_unsigned &v)
147912853Sgabeblack@google.com    {
148012853Sgabeblack@google.com        return operator * ((long)u, v);
148112853Sgabeblack@google.com    }
148212853Sgabeblack@google.com
148312853Sgabeblack@google.com    friend sc_signed operator * (const sc_signed &u, const sc_signed &v);
148412853Sgabeblack@google.com    friend sc_signed operator * (const sc_signed &u, int64 v);
148512853Sgabeblack@google.com    friend sc_signed operator * (const sc_signed &u, uint64 v);
148612853Sgabeblack@google.com    friend sc_signed operator * (const sc_signed &u, long v);
148712853Sgabeblack@google.com    friend sc_signed operator * (const sc_signed &u, unsigned long v);
148812853Sgabeblack@google.com    friend sc_signed
148912853Sgabeblack@google.com    operator * (const sc_signed &u, int v)
149012853Sgabeblack@google.com    {
149112853Sgabeblack@google.com        return operator * (u, (long)v);
149212853Sgabeblack@google.com    }
149312853Sgabeblack@google.com    friend sc_signed
149412853Sgabeblack@google.com    operator * (const sc_signed &u, unsigned int v)
149512853Sgabeblack@google.com    {
149612853Sgabeblack@google.com        return operator * (u, (unsigned long)v);
149712853Sgabeblack@google.com    }
149812853Sgabeblack@google.com
149912853Sgabeblack@google.com    friend sc_signed operator * (int64 u, const sc_signed &v);
150012853Sgabeblack@google.com    friend sc_signed operator * (uint64 u, const sc_signed &v);
150112853Sgabeblack@google.com    friend sc_signed operator * (long u, const sc_signed &v);
150212853Sgabeblack@google.com    friend sc_signed operator * (unsigned long u, const sc_signed &v);
150312853Sgabeblack@google.com    friend sc_signed
150412853Sgabeblack@google.com    operator * (int u, const sc_signed &v)
150512853Sgabeblack@google.com    {
150612853Sgabeblack@google.com        return operator * ((long)u, v);
150712853Sgabeblack@google.com    }
150812853Sgabeblack@google.com    friend sc_signed
150912853Sgabeblack@google.com    operator * (unsigned int u, const sc_signed &v)
151012853Sgabeblack@google.com    {
151112853Sgabeblack@google.com        return operator * ((unsigned long)u, v);
151212853Sgabeblack@google.com    }
151312853Sgabeblack@google.com
151412853Sgabeblack@google.com    const sc_signed &operator *= (const sc_signed &v);
151512853Sgabeblack@google.com    const sc_signed &operator *= (const sc_unsigned &v);
151612853Sgabeblack@google.com    const sc_signed &operator *= (int64 v);
151712853Sgabeblack@google.com    const sc_signed &operator *= (uint64 v);
151812853Sgabeblack@google.com    const sc_signed &operator *= (long v);
151912853Sgabeblack@google.com    const sc_signed &operator *= (unsigned long v);
152012853Sgabeblack@google.com    const sc_signed &
152112853Sgabeblack@google.com    operator *= (int v)
152212853Sgabeblack@google.com    {
152312853Sgabeblack@google.com        return operator *= ((long)v);
152412853Sgabeblack@google.com    }
152512853Sgabeblack@google.com    const sc_signed &
152612853Sgabeblack@google.com    operator *= (unsigned int v)
152712853Sgabeblack@google.com    {
152812853Sgabeblack@google.com        return operator *= ((unsigned long)v);
152912853Sgabeblack@google.com    }
153012853Sgabeblack@google.com
153112853Sgabeblack@google.com    friend sc_signed operator * (const sc_unsigned &u, const sc_int_base &v);
153212853Sgabeblack@google.com    friend sc_signed operator * (const sc_int_base &u, const sc_unsigned &v);
153312853Sgabeblack@google.com    friend sc_signed operator * (const sc_signed &u, const sc_int_base &v);
153412853Sgabeblack@google.com    friend sc_signed operator * (const sc_signed &u, const sc_uint_base &v);
153512853Sgabeblack@google.com    friend sc_signed operator * (const sc_int_base &u, const sc_signed &v);
153612853Sgabeblack@google.com    friend sc_signed operator * (const sc_uint_base &u, const sc_signed &v);
153712853Sgabeblack@google.com    const sc_signed &operator *= (const sc_int_base &v);
153812853Sgabeblack@google.com    const sc_signed &operator *= (const sc_uint_base &v);
153912853Sgabeblack@google.com
154012853Sgabeblack@google.com    // DIVision operators:
154112853Sgabeblack@google.com    friend sc_signed operator / (const sc_unsigned &u, const sc_signed &v);
154212853Sgabeblack@google.com    friend sc_signed operator / (const sc_signed &u, const sc_unsigned &v);
154312853Sgabeblack@google.com
154412853Sgabeblack@google.com    friend sc_signed operator / (const sc_unsigned &u, int64 v);
154512853Sgabeblack@google.com    friend sc_signed operator / (const sc_unsigned &u, long v);
154612853Sgabeblack@google.com    friend sc_signed
154712853Sgabeblack@google.com    operator / (const sc_unsigned &u, int v)
154812853Sgabeblack@google.com    {
154912853Sgabeblack@google.com        return operator / (u, (long)v);
155012853Sgabeblack@google.com    }
155112853Sgabeblack@google.com
155212853Sgabeblack@google.com    friend sc_signed operator / (int64 u, const sc_unsigned &v);
155312853Sgabeblack@google.com    friend sc_signed operator / (long u, const sc_unsigned &v);
155412853Sgabeblack@google.com    friend sc_signed
155512853Sgabeblack@google.com    operator / (int u, const sc_unsigned &v)
155612853Sgabeblack@google.com    {
155712853Sgabeblack@google.com        return operator / ((long)u, v);
155812853Sgabeblack@google.com    }
155912853Sgabeblack@google.com
156012853Sgabeblack@google.com    friend sc_signed operator / (const sc_signed &u, const sc_signed &v);
156112853Sgabeblack@google.com    friend sc_signed operator / (const sc_signed &u, int64 v);
156212853Sgabeblack@google.com    friend sc_signed operator / (const sc_signed &u, uint64 v);
156312853Sgabeblack@google.com    friend sc_signed operator / (const sc_signed &u, long v);
156412853Sgabeblack@google.com    friend sc_signed operator / (const sc_signed &u, unsigned long v);
156512853Sgabeblack@google.com    friend sc_signed
156612853Sgabeblack@google.com    operator / (const sc_signed &u, int v)
156712853Sgabeblack@google.com    {
156812853Sgabeblack@google.com        return operator / (u, (long)v);
156912853Sgabeblack@google.com    }
157012853Sgabeblack@google.com    friend sc_signed
157112853Sgabeblack@google.com    operator / (const sc_signed &u, unsigned int v)
157212853Sgabeblack@google.com    {
157312853Sgabeblack@google.com        return operator / (u, (unsigned long)v);
157412853Sgabeblack@google.com    }
157512853Sgabeblack@google.com
157612853Sgabeblack@google.com    friend sc_signed operator / (int64 u, const sc_signed &v);
157712853Sgabeblack@google.com    friend sc_signed operator / (uint64 u, const sc_signed &v);
157812853Sgabeblack@google.com    friend sc_signed operator / (long u, const sc_signed &v);
157912853Sgabeblack@google.com    friend sc_signed operator / (unsigned long u, const sc_signed &v);
158012853Sgabeblack@google.com    friend sc_signed
158112853Sgabeblack@google.com    operator / (int u, const sc_signed &v)
158212853Sgabeblack@google.com    {
158312853Sgabeblack@google.com        return operator / ((long)u, v);
158412853Sgabeblack@google.com    }
158512853Sgabeblack@google.com    friend sc_signed
158612853Sgabeblack@google.com    operator / (unsigned int u, const sc_signed &v)
158712853Sgabeblack@google.com    {
158812853Sgabeblack@google.com        return operator / ((unsigned long)u, v);
158912853Sgabeblack@google.com    }
159012853Sgabeblack@google.com
159112853Sgabeblack@google.com    const sc_signed &operator /= (const sc_signed &v);
159212853Sgabeblack@google.com    const sc_signed &operator /= (const sc_unsigned &v);
159312853Sgabeblack@google.com    const sc_signed &operator /= (int64 v);
159412853Sgabeblack@google.com    const sc_signed &operator /= (uint64 v);
159512853Sgabeblack@google.com    const sc_signed &operator /= (long v);
159612853Sgabeblack@google.com    const sc_signed &operator /= (unsigned long v);
159712853Sgabeblack@google.com    const sc_signed &
159812853Sgabeblack@google.com    operator /= (int v)
159912853Sgabeblack@google.com    {
160012853Sgabeblack@google.com        return operator /= ((long)v);
160112853Sgabeblack@google.com    }
160212853Sgabeblack@google.com    const sc_signed &
160312853Sgabeblack@google.com    operator /= (unsigned int v)
160412853Sgabeblack@google.com    {
160512853Sgabeblack@google.com        return operator /= ((unsigned long)v);
160612853Sgabeblack@google.com    }
160712853Sgabeblack@google.com
160812853Sgabeblack@google.com    friend sc_signed operator / (const sc_unsigned &u, const sc_int_base &v);
160912853Sgabeblack@google.com    friend sc_signed operator / (const sc_int_base &u, const sc_unsigned &v);
161012853Sgabeblack@google.com    friend sc_signed operator / (const sc_signed &u, const sc_int_base &v);
161112853Sgabeblack@google.com    friend sc_signed operator / (const sc_signed &u, const sc_uint_base &v);
161212853Sgabeblack@google.com    friend sc_signed operator / (const sc_int_base &u, const sc_signed &v);
161312853Sgabeblack@google.com    friend sc_signed operator / (const sc_uint_base &u, const sc_signed &v);
161412853Sgabeblack@google.com    const sc_signed &operator /= (const sc_int_base &v);
161512853Sgabeblack@google.com    const sc_signed &operator /= (const sc_uint_base &v);
161612853Sgabeblack@google.com
161712853Sgabeblack@google.com    // MODulo operators:
161812853Sgabeblack@google.com    friend sc_signed operator % (const sc_unsigned &u, const sc_signed &v);
161912853Sgabeblack@google.com    friend sc_signed operator % (const sc_signed &u, const sc_unsigned &v);
162012853Sgabeblack@google.com
162112853Sgabeblack@google.com    friend sc_signed operator % (const sc_unsigned &u, int64 v);
162212853Sgabeblack@google.com    friend sc_signed operator % (const sc_unsigned &u, long v);
162312853Sgabeblack@google.com    friend sc_signed
162412853Sgabeblack@google.com    operator % (const sc_unsigned &u, int v)
162512853Sgabeblack@google.com    {
162612853Sgabeblack@google.com        return operator % (u, (long)v);
162712853Sgabeblack@google.com    }
162812853Sgabeblack@google.com
162912853Sgabeblack@google.com    friend sc_signed operator % (int64 u, const sc_unsigned &v);
163012853Sgabeblack@google.com    friend sc_signed operator % (long u, const sc_unsigned &v);
163112853Sgabeblack@google.com    friend sc_signed
163212853Sgabeblack@google.com    operator % (int u, const sc_unsigned &v)
163312853Sgabeblack@google.com    {
163412853Sgabeblack@google.com        return operator % ((long)u, v);
163512853Sgabeblack@google.com    }
163612853Sgabeblack@google.com
163712853Sgabeblack@google.com    friend sc_signed operator % (const sc_signed &u, const sc_signed &v);
163812853Sgabeblack@google.com    friend sc_signed operator % (const sc_signed &u, int64 v);
163912853Sgabeblack@google.com    friend sc_signed operator % (const sc_signed &u, uint64 v);
164012853Sgabeblack@google.com    friend sc_signed operator % (const sc_signed &u, long v);
164112853Sgabeblack@google.com    friend sc_signed operator % (const sc_signed &u, unsigned long v);
164212853Sgabeblack@google.com    friend sc_signed
164312853Sgabeblack@google.com    operator % (const sc_signed &u, int v)
164412853Sgabeblack@google.com    {
164512853Sgabeblack@google.com        return operator % (u, (long)v);
164612853Sgabeblack@google.com    }
164712853Sgabeblack@google.com    friend sc_signed
164812853Sgabeblack@google.com    operator % (const sc_signed &u, unsigned int v)
164912853Sgabeblack@google.com    {
165012853Sgabeblack@google.com        return operator % (u, (unsigned long)v);
165112853Sgabeblack@google.com    }
165212853Sgabeblack@google.com
165312853Sgabeblack@google.com    friend sc_signed operator % (int64 u, const sc_signed &v);
165412853Sgabeblack@google.com    friend sc_signed operator % (uint64 u, const sc_signed &v);
165512853Sgabeblack@google.com    friend sc_signed operator % (long u, const sc_signed &v);
165612853Sgabeblack@google.com    friend sc_signed operator % (unsigned long u, const sc_signed &v);
165712853Sgabeblack@google.com    friend sc_signed
165812853Sgabeblack@google.com    operator % (int u, const sc_signed &v)
165912853Sgabeblack@google.com    {
166012853Sgabeblack@google.com        return operator % ((long)u, v);
166112853Sgabeblack@google.com    }
166212853Sgabeblack@google.com    friend sc_signed
166312853Sgabeblack@google.com    operator % (unsigned int u, const sc_signed &v)
166412853Sgabeblack@google.com    {
166512853Sgabeblack@google.com        return operator % ((unsigned long) u, v);
166612853Sgabeblack@google.com    }
166712853Sgabeblack@google.com
166812853Sgabeblack@google.com    const sc_signed &operator %= (const sc_signed &v);
166912853Sgabeblack@google.com    const sc_signed &operator %= (const sc_unsigned &v);
167012853Sgabeblack@google.com    const sc_signed &operator %= (int64 v);
167112853Sgabeblack@google.com    const sc_signed &operator %= (uint64 v);
167212853Sgabeblack@google.com    const sc_signed &operator %= (long v);
167312853Sgabeblack@google.com    const sc_signed &operator %= (unsigned long v);
167412853Sgabeblack@google.com    const sc_signed &
167512853Sgabeblack@google.com    operator %= (int v)
167612853Sgabeblack@google.com    {
167712853Sgabeblack@google.com        return operator %= ((long)v);
167812853Sgabeblack@google.com    }
167912853Sgabeblack@google.com    const sc_signed &
168012853Sgabeblack@google.com    operator %= (unsigned int v)
168112853Sgabeblack@google.com    {
168212853Sgabeblack@google.com        return operator %= ((unsigned long)v);
168312853Sgabeblack@google.com    }
168412853Sgabeblack@google.com
168512853Sgabeblack@google.com    friend sc_signed operator % (const sc_unsigned &u, const sc_int_base &v);
168612853Sgabeblack@google.com    friend sc_signed operator % (const sc_int_base &u, const sc_unsigned &v);
168712853Sgabeblack@google.com    friend sc_signed operator % (const sc_signed &u, const sc_int_base &v);
168812853Sgabeblack@google.com    friend sc_signed operator % (const sc_signed &u, const sc_uint_base &v);
168912853Sgabeblack@google.com    friend sc_signed operator % (const sc_int_base &u, const sc_signed &v);
169012853Sgabeblack@google.com    friend sc_signed operator % (const sc_uint_base &u, const sc_signed &v);
169112853Sgabeblack@google.com    const sc_signed &operator %= (const sc_int_base &v);
169212853Sgabeblack@google.com    const sc_signed &operator %= (const sc_uint_base &v);
169312853Sgabeblack@google.com
169412853Sgabeblack@google.com    // BITWISE OPERATORS:
169512853Sgabeblack@google.com
169612853Sgabeblack@google.com    // Bitwise AND operators:
169712853Sgabeblack@google.com    friend sc_signed operator & (const sc_unsigned &u, const sc_signed &v);
169812853Sgabeblack@google.com    friend sc_signed operator & (const sc_signed &u, const sc_unsigned &v);
169912853Sgabeblack@google.com
170012853Sgabeblack@google.com    friend sc_signed operator & (const sc_unsigned &u, int64 v);
170112853Sgabeblack@google.com    friend sc_signed operator & (const sc_unsigned &u, long v);
170212853Sgabeblack@google.com    friend sc_signed
170312853Sgabeblack@google.com    operator  &(const sc_unsigned &u, int v)
170412853Sgabeblack@google.com    {
170512853Sgabeblack@google.com        return operator & (u, (long)v);
170612853Sgabeblack@google.com    }
170712853Sgabeblack@google.com
170812853Sgabeblack@google.com    friend sc_signed operator & (int64 u, const sc_unsigned &v);
170912853Sgabeblack@google.com    friend sc_signed operator & (long u, const sc_unsigned &v);
171012853Sgabeblack@google.com    friend sc_signed
171112853Sgabeblack@google.com    operator & (int u, const sc_unsigned &v)
171212853Sgabeblack@google.com    {
171312853Sgabeblack@google.com        return operator & ((long) u, v);
171412853Sgabeblack@google.com    }
171512853Sgabeblack@google.com
171612853Sgabeblack@google.com    friend sc_signed operator & (const sc_signed &u, const sc_signed &v);
171712853Sgabeblack@google.com    friend sc_signed operator & (const sc_signed &u, int64 v);
171812853Sgabeblack@google.com    friend sc_signed operator & (const sc_signed &u, uint64 v);
171912853Sgabeblack@google.com    friend sc_signed operator & (const sc_signed &u, long v);
172012853Sgabeblack@google.com    friend sc_signed operator & (const sc_signed &u, unsigned long v);
172112853Sgabeblack@google.com    friend sc_signed
172212853Sgabeblack@google.com    operator & (const sc_signed &u, int v)
172312853Sgabeblack@google.com    {
172412853Sgabeblack@google.com        return operator & (u, (long)v);
172512853Sgabeblack@google.com    }
172612853Sgabeblack@google.com    friend sc_signed
172712853Sgabeblack@google.com    operator & (const sc_signed &u, unsigned int v)
172812853Sgabeblack@google.com    {
172912853Sgabeblack@google.com        return operator & (u, (unsigned long)v);
173012853Sgabeblack@google.com    }
173112853Sgabeblack@google.com
173212853Sgabeblack@google.com    friend sc_signed operator & (int64 u, const sc_signed &v);
173312853Sgabeblack@google.com    friend sc_signed operator & (uint64 u, const sc_signed &v);
173412853Sgabeblack@google.com    friend sc_signed operator & (long u, const sc_signed &v);
173512853Sgabeblack@google.com    friend sc_signed operator & (unsigned long u, const sc_signed &v);
173612853Sgabeblack@google.com    friend sc_signed operator & (int u, const sc_signed &v)
173712853Sgabeblack@google.com    { return operator&((long) u, v); }
173812853Sgabeblack@google.com    friend sc_signed operator & (unsigned int u, const sc_signed &v)
173912853Sgabeblack@google.com    { return operator&((unsigned long) u, v); }
174012853Sgabeblack@google.com
174112853Sgabeblack@google.com    const sc_signed &operator &= (const sc_signed &v);
174212853Sgabeblack@google.com    const sc_signed &operator &= (const sc_unsigned &v);
174312853Sgabeblack@google.com    const sc_signed &operator &= (int64 v);
174412853Sgabeblack@google.com    const sc_signed &operator &= (uint64 v);
174512853Sgabeblack@google.com    const sc_signed &operator &= (long v);
174612853Sgabeblack@google.com    const sc_signed &operator &= (unsigned long v);
174712853Sgabeblack@google.com    const sc_signed &
174812853Sgabeblack@google.com    operator &= (int v)
174912853Sgabeblack@google.com    {
175012853Sgabeblack@google.com        return operator &= ((long) v);
175112853Sgabeblack@google.com    }
175212853Sgabeblack@google.com    const sc_signed &
175312853Sgabeblack@google.com    operator &= (unsigned int v)
175412853Sgabeblack@google.com    {
175512853Sgabeblack@google.com        return operator &= ((unsigned long) v);
175612853Sgabeblack@google.com    }
175712853Sgabeblack@google.com
175812853Sgabeblack@google.com    friend sc_signed operator & (const sc_unsigned &u, const sc_int_base &v);
175912853Sgabeblack@google.com    friend sc_signed operator & (const sc_int_base &u, const sc_unsigned &v);
176012853Sgabeblack@google.com    friend sc_signed operator & (const sc_signed &u, const sc_int_base &v);
176112853Sgabeblack@google.com    friend sc_signed operator & (const sc_signed &u, const sc_uint_base &v);
176212853Sgabeblack@google.com    friend sc_signed operator & (const sc_int_base &u, const sc_signed &v);
176312853Sgabeblack@google.com    friend sc_signed operator & (const sc_uint_base &u, const sc_signed &v);
176412853Sgabeblack@google.com    const sc_signed &operator &= (const sc_int_base &v);
176512853Sgabeblack@google.com    const sc_signed &operator &= (const sc_uint_base &v);
176612853Sgabeblack@google.com
176712853Sgabeblack@google.com    // Bitwise OR operators:
176812853Sgabeblack@google.com    friend sc_signed operator | (const sc_unsigned &u, const sc_signed &v);
176912853Sgabeblack@google.com    friend sc_signed operator | (const sc_signed &u, const sc_unsigned &v);
177012853Sgabeblack@google.com
177112853Sgabeblack@google.com    friend sc_signed operator | (const sc_unsigned &u, int64 v);
177212853Sgabeblack@google.com    friend sc_signed operator | (const sc_unsigned &u, long v);
177312853Sgabeblack@google.com    friend sc_signed
177412853Sgabeblack@google.com    operator | (const sc_unsigned &u, int v)
177512853Sgabeblack@google.com    {
177612853Sgabeblack@google.com        return operator | (u, (long)v);
177712853Sgabeblack@google.com    }
177812853Sgabeblack@google.com
177912853Sgabeblack@google.com    friend sc_signed operator | (int64 u, const sc_unsigned &v);
178012853Sgabeblack@google.com    friend sc_signed operator | (long u, const sc_unsigned &v);
178112853Sgabeblack@google.com    friend sc_signed
178212853Sgabeblack@google.com    operator | (int u, const sc_unsigned &v)
178312853Sgabeblack@google.com    {
178412853Sgabeblack@google.com        return operator | ((long)u, v);
178512853Sgabeblack@google.com    }
178612853Sgabeblack@google.com
178712853Sgabeblack@google.com    friend sc_signed operator | (const sc_signed &u, const sc_signed &v);
178812853Sgabeblack@google.com    friend sc_signed operator | (const sc_signed &u, int64 v);
178912853Sgabeblack@google.com    friend sc_signed operator | (const sc_signed &u, uint64 v);
179012853Sgabeblack@google.com    friend sc_signed operator | (const sc_signed &u, long v);
179112853Sgabeblack@google.com    friend sc_signed operator | (const sc_signed &u, unsigned long v);
179212853Sgabeblack@google.com    friend sc_signed
179312853Sgabeblack@google.com    operator | (const sc_signed &u, int v)
179412853Sgabeblack@google.com    {
179512853Sgabeblack@google.com        return operator | (u, (long)v);
179612853Sgabeblack@google.com    }
179712853Sgabeblack@google.com    friend sc_signed
179812853Sgabeblack@google.com    operator | (const sc_signed &u, unsigned int v)
179912853Sgabeblack@google.com    {
180012853Sgabeblack@google.com        return operator | (u, (unsigned long)v);
180112853Sgabeblack@google.com    }
180212853Sgabeblack@google.com
180312853Sgabeblack@google.com    friend sc_signed operator | (int64 u, const sc_signed &v);
180412853Sgabeblack@google.com    friend sc_signed operator | (uint64 u, const sc_signed &v);
180512853Sgabeblack@google.com    friend sc_signed operator | (long u, const sc_signed &v);
180612853Sgabeblack@google.com    friend sc_signed operator | (unsigned long u, const sc_signed &v);
180712853Sgabeblack@google.com    friend sc_signed
180812853Sgabeblack@google.com    operator | (int u, const sc_signed &v)
180912853Sgabeblack@google.com    {
181012853Sgabeblack@google.com        return operator | ((long) u, v);
181112853Sgabeblack@google.com    }
181212853Sgabeblack@google.com    friend sc_signed
181312853Sgabeblack@google.com    operator | (unsigned int u, const sc_signed &v)
181412853Sgabeblack@google.com    {
181512853Sgabeblack@google.com        return operator | ((unsigned long)u, v);
181612853Sgabeblack@google.com    }
181712853Sgabeblack@google.com
181812853Sgabeblack@google.com    const sc_signed &operator |= (const sc_signed &v);
181912853Sgabeblack@google.com    const sc_signed &operator |= (const sc_unsigned &v);
182012853Sgabeblack@google.com    const sc_signed &operator |= (int64 v);
182112853Sgabeblack@google.com    const sc_signed &operator |= (uint64 v);
182212853Sgabeblack@google.com    const sc_signed &operator |= (long v);
182312853Sgabeblack@google.com    const sc_signed &operator |= (unsigned long v);
182412853Sgabeblack@google.com    const sc_signed &
182512853Sgabeblack@google.com    operator |= (int v)
182612853Sgabeblack@google.com    {
182712853Sgabeblack@google.com        return operator |= ((long)v);
182812853Sgabeblack@google.com    }
182912853Sgabeblack@google.com    const sc_signed &
183012853Sgabeblack@google.com    operator |= (unsigned int v)
183112853Sgabeblack@google.com    {
183212853Sgabeblack@google.com        return operator |= ((unsigned long)v);
183312853Sgabeblack@google.com    }
183412853Sgabeblack@google.com
183512853Sgabeblack@google.com    friend sc_signed operator | (const sc_unsigned &u, const sc_int_base &v);
183612853Sgabeblack@google.com    friend sc_signed operator | (const sc_int_base &u, const sc_unsigned &v);
183712853Sgabeblack@google.com    friend sc_signed operator | (const sc_signed &u, const sc_int_base &v);
183812853Sgabeblack@google.com    friend sc_signed operator | (const sc_signed &u, const sc_uint_base &v);
183912853Sgabeblack@google.com    friend sc_signed operator | (const sc_int_base &u, const sc_signed &v);
184012853Sgabeblack@google.com    friend sc_signed operator | (const sc_uint_base &u, const sc_signed &v);
184112853Sgabeblack@google.com    const sc_signed &operator |= (const sc_int_base &v);
184212853Sgabeblack@google.com    const sc_signed &operator |= (const sc_uint_base &v);
184312853Sgabeblack@google.com
184412853Sgabeblack@google.com    // Bitwise XOR operators:
184512853Sgabeblack@google.com    friend sc_signed operator ^ (const sc_unsigned &u, const sc_signed &v);
184612853Sgabeblack@google.com    friend sc_signed operator ^ (const sc_signed &u, const sc_unsigned &v);
184712853Sgabeblack@google.com
184812853Sgabeblack@google.com    friend sc_signed operator ^ (const sc_unsigned &u, int64 v);
184912853Sgabeblack@google.com    friend sc_signed operator ^ (const sc_unsigned &u, long v);
185012853Sgabeblack@google.com    friend sc_signed
185112853Sgabeblack@google.com    operator ^ (const sc_unsigned &u, int v)
185212853Sgabeblack@google.com    {
185312853Sgabeblack@google.com        return operator ^ (u, (long)v);
185412853Sgabeblack@google.com    }
185512853Sgabeblack@google.com
185612853Sgabeblack@google.com    friend sc_signed operator ^ (int64 u, const sc_unsigned &v);
185712853Sgabeblack@google.com    friend sc_signed operator ^ (long u, const sc_unsigned &v);
185812853Sgabeblack@google.com    friend sc_signed
185912853Sgabeblack@google.com    operator ^ (int u, const sc_unsigned &v)
186012853Sgabeblack@google.com    {
186112853Sgabeblack@google.com        return operator ^ ((long)u, v);
186212853Sgabeblack@google.com    }
186312853Sgabeblack@google.com
186412853Sgabeblack@google.com    friend sc_signed operator ^ (const sc_signed &u, const sc_signed &v);
186512853Sgabeblack@google.com    friend sc_signed operator ^ (const sc_signed &u, int64 v);
186612853Sgabeblack@google.com    friend sc_signed operator ^ (const sc_signed &u, uint64 v);
186712853Sgabeblack@google.com    friend sc_signed operator ^ (const sc_signed &u, long v);
186812853Sgabeblack@google.com    friend sc_signed operator ^ (const sc_signed &u, unsigned long v);
186912853Sgabeblack@google.com    friend sc_signed
187012853Sgabeblack@google.com    operator ^ (const sc_signed &u, int v)
187112853Sgabeblack@google.com    {
187212853Sgabeblack@google.com        return operator ^ (u, (long)v);
187312853Sgabeblack@google.com    }
187412853Sgabeblack@google.com    friend sc_signed
187512853Sgabeblack@google.com    operator ^ (const sc_signed &u, unsigned int v)
187612853Sgabeblack@google.com    {
187712853Sgabeblack@google.com        return operator ^ (u, (unsigned long)v);
187812853Sgabeblack@google.com    }
187912853Sgabeblack@google.com
188012853Sgabeblack@google.com    friend sc_signed operator ^ (int64 u, const sc_signed &v);
188112853Sgabeblack@google.com    friend sc_signed operator ^ (uint64 u, const sc_signed &v);
188212853Sgabeblack@google.com    friend sc_signed operator ^ (long u, const sc_signed &v);
188312853Sgabeblack@google.com    friend sc_signed operator ^ (unsigned long u, const sc_signed &v);
188412853Sgabeblack@google.com    friend sc_signed
188512853Sgabeblack@google.com    operator ^ (int u, const sc_signed &v)
188612853Sgabeblack@google.com    {
188712853Sgabeblack@google.com        return operator ^ ((long)u, v);
188812853Sgabeblack@google.com    }
188912853Sgabeblack@google.com    friend sc_signed
189012853Sgabeblack@google.com    operator ^ (unsigned int u, const sc_signed &v)
189112853Sgabeblack@google.com    {
189212853Sgabeblack@google.com        return operator ^ ((unsigned long)u, v);
189312853Sgabeblack@google.com    }
189412853Sgabeblack@google.com
189512853Sgabeblack@google.com    const sc_signed &operator ^= (const sc_signed &v);
189612853Sgabeblack@google.com    const sc_signed &operator ^= (const sc_unsigned &v);
189712853Sgabeblack@google.com    const sc_signed &operator ^= (int64 v);
189812853Sgabeblack@google.com    const sc_signed &operator ^= (uint64 v);
189912853Sgabeblack@google.com    const sc_signed &operator ^= (long v);
190012853Sgabeblack@google.com    const sc_signed &operator ^= (unsigned long v);
190112853Sgabeblack@google.com    const sc_signed &
190212853Sgabeblack@google.com    operator ^= (int v)
190312853Sgabeblack@google.com    {
190412853Sgabeblack@google.com        return operator ^= ((long)v);
190512853Sgabeblack@google.com    }
190612853Sgabeblack@google.com    const sc_signed &
190712853Sgabeblack@google.com    operator ^= (unsigned int v)
190812853Sgabeblack@google.com    {
190912853Sgabeblack@google.com        return operator ^= ((unsigned long)v);
191012853Sgabeblack@google.com    }
191112853Sgabeblack@google.com
191212853Sgabeblack@google.com    friend sc_signed operator ^ (const sc_unsigned &u, const sc_int_base &v);
191312853Sgabeblack@google.com    friend sc_signed operator ^ (const sc_int_base &u, const sc_unsigned &v);
191412853Sgabeblack@google.com    friend sc_signed operator ^ (const sc_signed &u, const sc_int_base &v);
191512853Sgabeblack@google.com    friend sc_signed operator ^ (const sc_signed &u, const sc_uint_base &v);
191612853Sgabeblack@google.com    friend sc_signed operator ^ (const sc_int_base &u, const sc_signed &v);
191712853Sgabeblack@google.com    friend sc_signed operator ^ (const sc_uint_base &u, const sc_signed &v);
191812853Sgabeblack@google.com    const sc_signed &operator ^= (const sc_int_base &v);
191912853Sgabeblack@google.com    const sc_signed &operator ^= (const sc_uint_base &v);
192012853Sgabeblack@google.com
192112853Sgabeblack@google.com    // SHIFT OPERATORS:
192212853Sgabeblack@google.com
192312853Sgabeblack@google.com    // LEFT SHIFT operators:
192412853Sgabeblack@google.com    friend sc_unsigned operator << (const sc_unsigned &u, const sc_signed &v);
192512853Sgabeblack@google.com    friend sc_signed operator << (const sc_signed &u, const sc_unsigned &v);
192612853Sgabeblack@google.com
192712853Sgabeblack@google.com    friend sc_signed operator << (const sc_signed &u, const sc_signed &v);
192812853Sgabeblack@google.com    friend sc_signed operator << (const sc_signed &u, int64 v);
192912853Sgabeblack@google.com    friend sc_signed operator << (const sc_signed &u, uint64 v);
193012853Sgabeblack@google.com    friend sc_signed operator << (const sc_signed &u, long v);
193112853Sgabeblack@google.com    friend sc_signed operator << (const sc_signed &u, unsigned long v);
193212853Sgabeblack@google.com    friend sc_signed
193312853Sgabeblack@google.com    operator << (const sc_signed &u, int v)
193412853Sgabeblack@google.com    {
193512853Sgabeblack@google.com        return operator << (u, (long)v);
193612853Sgabeblack@google.com    }
193712853Sgabeblack@google.com    friend sc_signed
193812853Sgabeblack@google.com    operator << (const sc_signed &u, unsigned int v)
193912853Sgabeblack@google.com    {
194012853Sgabeblack@google.com        return operator << (u, (unsigned long)v);
194112853Sgabeblack@google.com    }
194212853Sgabeblack@google.com
194312853Sgabeblack@google.com    const sc_signed &operator <<= (const sc_signed &v);
194412853Sgabeblack@google.com    const sc_signed &operator <<= (const sc_unsigned &v);
194512853Sgabeblack@google.com    const sc_signed &operator <<= (int64 v);
194612853Sgabeblack@google.com    const sc_signed &operator <<= (uint64 v);
194712853Sgabeblack@google.com    const sc_signed &operator <<= (long v);
194812853Sgabeblack@google.com    const sc_signed &operator <<= (unsigned long v);
194912853Sgabeblack@google.com    const sc_signed &
195012853Sgabeblack@google.com    operator <<= (int v)
195112853Sgabeblack@google.com    {
195212853Sgabeblack@google.com        return operator <<= ((long)v);
195312853Sgabeblack@google.com    }
195412853Sgabeblack@google.com    const sc_signed &
195512853Sgabeblack@google.com    operator <<= (unsigned int v)
195612853Sgabeblack@google.com    {
195712853Sgabeblack@google.com        return operator <<= ((unsigned long)v);
195812853Sgabeblack@google.com    }
195912853Sgabeblack@google.com
196012853Sgabeblack@google.com    friend sc_signed operator << (const sc_signed &u, const sc_int_base &v);
196112853Sgabeblack@google.com    friend sc_signed operator << (const sc_signed &u, const sc_uint_base &v);
196212853Sgabeblack@google.com    const sc_signed &operator <<= (const sc_int_base &v);
196312853Sgabeblack@google.com    const sc_signed &operator <<= (const sc_uint_base &v);
196412853Sgabeblack@google.com
196512853Sgabeblack@google.com    // RIGHT SHIFT operators:
196612853Sgabeblack@google.com    friend sc_unsigned operator >> (const sc_unsigned &u, const sc_signed &v);
196712853Sgabeblack@google.com    friend sc_signed operator >> (const sc_signed &u, const sc_unsigned &v);
196812853Sgabeblack@google.com
196912853Sgabeblack@google.com    friend sc_signed operator >> (const sc_signed &u, const sc_signed &v);
197012853Sgabeblack@google.com    friend sc_signed operator >> (const sc_signed &u, int64 v);
197112853Sgabeblack@google.com    friend sc_signed operator >> (const sc_signed &u, uint64 v);
197212853Sgabeblack@google.com    friend sc_signed operator >> (const sc_signed &u, long v);
197312853Sgabeblack@google.com    friend sc_signed operator >> (const sc_signed &u, unsigned long v);
197412853Sgabeblack@google.com    friend sc_signed
197512853Sgabeblack@google.com    operator >> (const sc_signed &u, int v)
197612853Sgabeblack@google.com    {
197712853Sgabeblack@google.com        return operator >> (u, (long)v);
197812853Sgabeblack@google.com    }
197912853Sgabeblack@google.com    friend sc_signed
198012853Sgabeblack@google.com    operator >> (const sc_signed &u, unsigned int v)
198112853Sgabeblack@google.com    {
198212853Sgabeblack@google.com        return operator >> (u, (unsigned long) v);
198312853Sgabeblack@google.com    }
198412853Sgabeblack@google.com
198512853Sgabeblack@google.com    const sc_signed &operator >>= (const sc_signed &v);
198612853Sgabeblack@google.com    const sc_signed &operator >>= (const sc_unsigned &v);
198712853Sgabeblack@google.com    const sc_signed &operator >>= (int64 v);
198812853Sgabeblack@google.com    const sc_signed &operator >>= (uint64 v);
198912853Sgabeblack@google.com    const sc_signed &operator >>= (long v);
199012853Sgabeblack@google.com    const sc_signed &operator >>= (unsigned long v);
199112853Sgabeblack@google.com    const sc_signed &
199212853Sgabeblack@google.com    operator >>= (int v)
199312853Sgabeblack@google.com    {
199412853Sgabeblack@google.com        return operator >>= ((long)v);
199512853Sgabeblack@google.com    }
199612853Sgabeblack@google.com    const sc_signed &
199712853Sgabeblack@google.com    operator >>= (unsigned int v)
199812853Sgabeblack@google.com    {
199912853Sgabeblack@google.com        return operator >>= ((unsigned long)v);
200012853Sgabeblack@google.com    }
200112853Sgabeblack@google.com
200212853Sgabeblack@google.com    friend sc_signed operator >> (const sc_signed &u, const sc_int_base &v);
200312853Sgabeblack@google.com    friend sc_signed operator >> (const sc_signed &u, const sc_uint_base &v);
200412853Sgabeblack@google.com    const sc_signed &operator >>= (const sc_int_base &v);
200512853Sgabeblack@google.com    const sc_signed &operator >>= (const sc_uint_base &v);
200612853Sgabeblack@google.com
200712853Sgabeblack@google.com    // Unary arithmetic operators
200812853Sgabeblack@google.com    friend sc_signed operator + (const sc_signed &u);
200912853Sgabeblack@google.com    friend sc_signed operator - (const sc_signed &u);
201012853Sgabeblack@google.com    friend sc_signed operator - (const sc_unsigned &u);
201112853Sgabeblack@google.com
201212853Sgabeblack@google.com    // LOGICAL OPERATORS:
201312853Sgabeblack@google.com
201412853Sgabeblack@google.com    // Logical EQUAL operators:
201512853Sgabeblack@google.com    friend bool operator == (const sc_unsigned &u, const sc_signed &v);
201612853Sgabeblack@google.com    friend bool operator == (const sc_signed &u, const sc_unsigned &v);
201712853Sgabeblack@google.com
201812853Sgabeblack@google.com    friend bool operator == (const sc_signed &u, const sc_signed &v);
201912853Sgabeblack@google.com    friend bool operator == (const sc_signed &u, int64 v);
202012853Sgabeblack@google.com    friend bool operator == (const sc_signed &u, uint64 v);
202112853Sgabeblack@google.com    friend bool operator == (const sc_signed &u, long v);
202212853Sgabeblack@google.com    friend bool operator == (const sc_signed &u, unsigned long v);
202312853Sgabeblack@google.com    friend bool
202412853Sgabeblack@google.com    operator == (const sc_signed &u, int v)
202512853Sgabeblack@google.com    {
202612853Sgabeblack@google.com        return operator == (u, (long)v);
202712853Sgabeblack@google.com    }
202812853Sgabeblack@google.com    friend bool
202912853Sgabeblack@google.com    operator == (const sc_signed &u, unsigned int v)
203012853Sgabeblack@google.com    {
203112853Sgabeblack@google.com        return operator == (u, (unsigned long)v);
203212853Sgabeblack@google.com    }
203312853Sgabeblack@google.com
203412853Sgabeblack@google.com    friend bool operator == (int64 u, const sc_signed &v);
203512853Sgabeblack@google.com    friend bool operator == (uint64 u, const sc_signed &v);
203612853Sgabeblack@google.com    friend bool operator == (long u, const sc_signed &v);
203712853Sgabeblack@google.com    friend bool operator == (unsigned long u, const sc_signed &v);
203812853Sgabeblack@google.com    friend bool
203912853Sgabeblack@google.com    operator == (int u, const sc_signed &v)
204012853Sgabeblack@google.com    {
204112853Sgabeblack@google.com        return operator == ((long)u, v);
204212853Sgabeblack@google.com    }
204312853Sgabeblack@google.com    friend bool
204412853Sgabeblack@google.com    operator == (unsigned int u, const sc_signed &v)
204512853Sgabeblack@google.com    {
204612853Sgabeblack@google.com        return operator == ((unsigned long)u, v);
204712853Sgabeblack@google.com    }
204812853Sgabeblack@google.com
204912853Sgabeblack@google.com    friend bool operator == (const sc_signed &u, const sc_int_base &v);
205012853Sgabeblack@google.com    friend bool operator == (const sc_signed &u, const sc_uint_base &v);
205112853Sgabeblack@google.com    friend bool operator == (const sc_int_base &u, const sc_signed &v);
205212853Sgabeblack@google.com    friend bool operator == (const sc_uint_base &u, const sc_signed &v);
205312853Sgabeblack@google.com
205412853Sgabeblack@google.com    // Logical NOT_EQUAL operators:
205512853Sgabeblack@google.com    friend bool operator != (const sc_unsigned &u, const sc_signed &v);
205612853Sgabeblack@google.com    friend bool operator != (const sc_signed &u, const sc_unsigned &v);
205712853Sgabeblack@google.com
205812853Sgabeblack@google.com    friend bool operator != (const sc_signed &u, const sc_signed &v);
205912853Sgabeblack@google.com    friend bool operator != (const sc_signed &u, int64 v);
206012853Sgabeblack@google.com    friend bool operator != (const sc_signed &u, uint64 v);
206112853Sgabeblack@google.com    friend bool operator != (const sc_signed &u, long v);
206212853Sgabeblack@google.com    friend bool operator != (const sc_signed &u, unsigned long v);
206312853Sgabeblack@google.com    friend bool
206412853Sgabeblack@google.com    operator != (const sc_signed &u, int v)
206512853Sgabeblack@google.com    {
206612853Sgabeblack@google.com        return operator != (u, (long)v);
206712853Sgabeblack@google.com    }
206812853Sgabeblack@google.com    friend bool
206912853Sgabeblack@google.com    operator != (const sc_signed &u, unsigned int v)
207012853Sgabeblack@google.com    {
207112853Sgabeblack@google.com        return operator != (u, (unsigned long)v);
207212853Sgabeblack@google.com    }
207312853Sgabeblack@google.com
207412853Sgabeblack@google.com    friend bool operator != (int64 u, const sc_signed &v);
207512853Sgabeblack@google.com    friend bool operator != (uint64 u, const sc_signed &v);
207612853Sgabeblack@google.com    friend bool operator != (long u, const sc_signed &v);
207712853Sgabeblack@google.com    friend bool operator != (unsigned long u, const sc_signed &v);
207812853Sgabeblack@google.com    friend bool
207912853Sgabeblack@google.com    operator != (int u, const sc_signed &v)
208012853Sgabeblack@google.com    {
208112853Sgabeblack@google.com        return operator != ((long)u, v);
208212853Sgabeblack@google.com    }
208312853Sgabeblack@google.com    friend bool
208412853Sgabeblack@google.com    operator != (unsigned int u, const sc_signed &v)
208512853Sgabeblack@google.com    {
208612853Sgabeblack@google.com        return operator != ((unsigned long)u, v);
208712853Sgabeblack@google.com    }
208812853Sgabeblack@google.com
208912853Sgabeblack@google.com    friend bool operator != (const sc_signed &u, const sc_int_base &v);
209012853Sgabeblack@google.com    friend bool operator != (const sc_signed &u, const sc_uint_base &v);
209112853Sgabeblack@google.com    friend bool operator != (const sc_int_base &u, const sc_signed &v);
209212853Sgabeblack@google.com    friend bool operator != (const sc_uint_base &u, const sc_signed &v);
209312853Sgabeblack@google.com
209412853Sgabeblack@google.com    // Logical LESS_THAN operators:
209512853Sgabeblack@google.com    friend bool operator < (const sc_unsigned &u, const sc_signed &v);
209612853Sgabeblack@google.com    friend bool operator < (const sc_signed &u, const sc_unsigned &v);
209712853Sgabeblack@google.com
209812853Sgabeblack@google.com    friend bool operator < (const sc_signed &u, const sc_signed &v);
209912853Sgabeblack@google.com    friend bool operator < (const sc_signed &u, int64 v);
210012853Sgabeblack@google.com    friend bool operator < (const sc_signed &u, uint64 v);
210112853Sgabeblack@google.com    friend bool operator < (const sc_signed &u, long v);
210212853Sgabeblack@google.com    friend bool operator < (const sc_signed &u, unsigned long v);
210312853Sgabeblack@google.com    friend bool operator < (const sc_signed &u, int v)
210412853Sgabeblack@google.com    { return operator<(u, (long) v); }
210512853Sgabeblack@google.com    friend bool operator < (const sc_signed &u, unsigned int v)
210612853Sgabeblack@google.com    { return operator<(u, (unsigned long) v); }
210712853Sgabeblack@google.com
210812853Sgabeblack@google.com    friend bool operator < (int64 u, const sc_signed &v);
210912853Sgabeblack@google.com    friend bool operator < (uint64 u, const sc_signed &v);
211012853Sgabeblack@google.com    friend bool operator < (long u, const sc_signed &v);
211112853Sgabeblack@google.com    friend bool operator < (unsigned long u, const sc_signed &v);
211212853Sgabeblack@google.com    friend bool
211312853Sgabeblack@google.com    operator < (int u, const sc_signed &v)
211412853Sgabeblack@google.com    {
211512853Sgabeblack@google.com        return operator < ((long)u, v);
211612853Sgabeblack@google.com    }
211712853Sgabeblack@google.com    friend bool
211812853Sgabeblack@google.com    operator < (unsigned int u, const sc_signed &v)
211912853Sgabeblack@google.com    {
212012853Sgabeblack@google.com        return operator < ((unsigned long)u, v);
212112853Sgabeblack@google.com    }
212212853Sgabeblack@google.com
212312853Sgabeblack@google.com    friend bool operator < (const sc_signed &u, const sc_int_base &v);
212412853Sgabeblack@google.com    friend bool operator < (const sc_signed &u, const sc_uint_base &v);
212512853Sgabeblack@google.com    friend bool operator < (const sc_int_base &u, const sc_signed &v);
212612853Sgabeblack@google.com    friend bool operator < (const sc_uint_base &u, const sc_signed &v);
212712853Sgabeblack@google.com
212812853Sgabeblack@google.com    // Logical LESS_THAN_AND_EQUAL operators:
212912853Sgabeblack@google.com    friend bool operator <= (const sc_unsigned &u, const sc_signed &v);
213012853Sgabeblack@google.com    friend bool operator <= (const sc_signed &u, const sc_unsigned &v);
213112853Sgabeblack@google.com
213212853Sgabeblack@google.com    friend bool operator <= (const sc_signed &u, const sc_signed &v);
213312853Sgabeblack@google.com    friend bool operator <= (const sc_signed &u, int64 v);
213412853Sgabeblack@google.com    friend bool operator <= (const sc_signed &u, uint64 v);
213512853Sgabeblack@google.com    friend bool operator <= (const sc_signed &u, long v);
213612853Sgabeblack@google.com    friend bool operator <= (const sc_signed &u, unsigned long v);
213712853Sgabeblack@google.com    friend bool
213812853Sgabeblack@google.com    operator <= (const sc_signed &u, int v)
213912853Sgabeblack@google.com    {
214012853Sgabeblack@google.com        return operator <= (u, (long)v);
214112853Sgabeblack@google.com    }
214212853Sgabeblack@google.com    friend bool
214312853Sgabeblack@google.com    operator <= (const sc_signed &u, unsigned int v)
214412853Sgabeblack@google.com    {
214512853Sgabeblack@google.com        return operator <= (u, (unsigned long)v);
214612853Sgabeblack@google.com    }
214712853Sgabeblack@google.com
214812853Sgabeblack@google.com    friend bool operator <= (int64 u, const sc_signed &v);
214912853Sgabeblack@google.com    friend bool operator <= (uint64 u, const sc_signed &v);
215012853Sgabeblack@google.com    friend bool operator <= (long u, const sc_signed &v);
215112853Sgabeblack@google.com    friend bool operator <= (unsigned long u, const sc_signed &v);
215212853Sgabeblack@google.com    friend bool
215312853Sgabeblack@google.com    operator <= (int u, const sc_signed &v)
215412853Sgabeblack@google.com    {
215512853Sgabeblack@google.com        return operator <= ((long)u, v);
215612853Sgabeblack@google.com    }
215712853Sgabeblack@google.com    friend bool
215812853Sgabeblack@google.com    operator <= (unsigned int u, const sc_signed &v)
215912853Sgabeblack@google.com    {
216012853Sgabeblack@google.com        return operator <= ((unsigned long)u, v);
216112853Sgabeblack@google.com    }
216212853Sgabeblack@google.com
216312853Sgabeblack@google.com    friend bool operator <= (const sc_signed &u, const sc_int_base &v);
216412853Sgabeblack@google.com    friend bool operator <= (const sc_signed &u, const sc_uint_base &v);
216512853Sgabeblack@google.com    friend bool operator <= (const sc_int_base &u, const sc_signed &v);
216612853Sgabeblack@google.com    friend bool operator <= (const sc_uint_base &u, const sc_signed &v);
216712853Sgabeblack@google.com
216812853Sgabeblack@google.com    // Logical GREATER_THAN operators:
216912853Sgabeblack@google.com    friend bool operator > (const sc_unsigned &u, const sc_signed &v);
217012853Sgabeblack@google.com    friend bool operator > (const sc_signed &u, const sc_unsigned &v);
217112853Sgabeblack@google.com
217212853Sgabeblack@google.com    friend bool operator > (const sc_signed &u, const sc_signed &v);
217312853Sgabeblack@google.com    friend bool operator > (const sc_signed &u, int64 v);
217412853Sgabeblack@google.com    friend bool operator > (const sc_signed &u, uint64 v);
217512853Sgabeblack@google.com    friend bool operator > (const sc_signed &u, long v);
217612853Sgabeblack@google.com    friend bool operator > (const sc_signed &u, unsigned long v);
217712853Sgabeblack@google.com    friend bool
217812853Sgabeblack@google.com    operator > (const sc_signed &u, int v)
217912853Sgabeblack@google.com    {
218012853Sgabeblack@google.com        return operator > (u, (long)v);
218112853Sgabeblack@google.com    }
218212853Sgabeblack@google.com    friend bool
218312853Sgabeblack@google.com    operator > (const sc_signed &u, unsigned int v)
218412853Sgabeblack@google.com    {
218512853Sgabeblack@google.com        return operator > (u, (unsigned long)v);
218612853Sgabeblack@google.com    }
218712853Sgabeblack@google.com
218812853Sgabeblack@google.com    friend bool operator > (int64 u, const sc_signed &v);
218912853Sgabeblack@google.com    friend bool operator > (uint64 u, const sc_signed &v);
219012853Sgabeblack@google.com    friend bool operator > (long u, const sc_signed &v);
219112853Sgabeblack@google.com    friend bool operator > (unsigned long u, const sc_signed &v);
219212853Sgabeblack@google.com    friend bool
219312853Sgabeblack@google.com    operator > (int u, const sc_signed &v)
219412853Sgabeblack@google.com    {
219512853Sgabeblack@google.com        return operator > ((long)u, v);
219612853Sgabeblack@google.com    }
219712853Sgabeblack@google.com    friend bool
219812853Sgabeblack@google.com    operator > (unsigned int u, const sc_signed &v)
219912853Sgabeblack@google.com    {
220012853Sgabeblack@google.com        return operator > ((unsigned long)u, v);
220112853Sgabeblack@google.com    }
220212853Sgabeblack@google.com
220312853Sgabeblack@google.com    friend bool operator > (const sc_signed &u, const sc_int_base &v);
220412853Sgabeblack@google.com    friend bool operator > (const sc_signed &u, const sc_uint_base &v);
220512853Sgabeblack@google.com    friend bool operator > (const sc_int_base &u, const sc_signed &v);
220612853Sgabeblack@google.com    friend bool operator > (const sc_uint_base &u, const sc_signed &v);
220712853Sgabeblack@google.com
220812853Sgabeblack@google.com    // Logical GREATER_THAN_AND_EQUAL operators:
220912853Sgabeblack@google.com    friend bool operator >= (const sc_unsigned &u, const sc_signed &v);
221012853Sgabeblack@google.com    friend bool operator >= (const sc_signed &u, const sc_unsigned &v);
221112853Sgabeblack@google.com
221212853Sgabeblack@google.com    friend bool operator >= (const sc_signed &u, const sc_signed &v);
221312853Sgabeblack@google.com    friend bool operator >= (const sc_signed &u, int64 v);
221412853Sgabeblack@google.com    friend bool operator >= (const sc_signed &u, uint64 v);
221512853Sgabeblack@google.com    friend bool operator >= (const sc_signed &u, long v);
221612853Sgabeblack@google.com    friend bool operator >= (const sc_signed &u, unsigned long v);
221712853Sgabeblack@google.com    friend bool
221812853Sgabeblack@google.com    operator >= (const sc_signed &u, int v)
221912853Sgabeblack@google.com    {
222012853Sgabeblack@google.com        return operator >= (u, (long)v);
222112853Sgabeblack@google.com    }
222212853Sgabeblack@google.com    friend bool
222312853Sgabeblack@google.com    operator >= (const sc_signed &u, unsigned int v)
222412853Sgabeblack@google.com    {
222512853Sgabeblack@google.com        return operator >= (u, (unsigned long)v);
222612853Sgabeblack@google.com    }
222712853Sgabeblack@google.com
222812853Sgabeblack@google.com    friend bool operator >= (int64 u, const sc_signed &v);
222912853Sgabeblack@google.com    friend bool operator >= (uint64 u, const sc_signed &v);
223012853Sgabeblack@google.com    friend bool operator >= (long u, const sc_signed &v);
223112853Sgabeblack@google.com    friend bool operator >= (unsigned long u, const sc_signed &v);
223212853Sgabeblack@google.com    friend bool
223312853Sgabeblack@google.com    operator >= (int u, const sc_signed &v)
223412853Sgabeblack@google.com    {
223512853Sgabeblack@google.com        return operator >= ((long)u, v);
223612853Sgabeblack@google.com    }
223712853Sgabeblack@google.com    friend bool
223812853Sgabeblack@google.com    operator >= (unsigned int u, const sc_signed &v)
223912853Sgabeblack@google.com    {
224012853Sgabeblack@google.com        return operator >= ((unsigned long)u, v);
224112853Sgabeblack@google.com    }
224212853Sgabeblack@google.com
224312853Sgabeblack@google.com    friend bool operator >= (const sc_signed &u, const sc_int_base &v);
224412853Sgabeblack@google.com    friend bool operator >= (const sc_signed &u, const sc_uint_base &v);
224512853Sgabeblack@google.com    friend bool operator >= (const sc_int_base &u, const sc_signed &v);
224612853Sgabeblack@google.com    friend bool operator >= (const sc_uint_base &u, const sc_signed &v);
224712853Sgabeblack@google.com
224812853Sgabeblack@google.com    // Bitwise NOT operator (unary).
224912853Sgabeblack@google.com    friend sc_signed operator ~ (const sc_signed &u);
225012853Sgabeblack@google.com
225112853Sgabeblack@google.com    // Helper functions.
225212853Sgabeblack@google.com    friend sc_signed add_signed_friend(
225312853Sgabeblack@google.com            small_type us, int unb, int und, const sc_digit *ud,
225412853Sgabeblack@google.com            small_type vs, int vnb, int vnd, const sc_digit *vd);
225512853Sgabeblack@google.com
225612853Sgabeblack@google.com    friend sc_signed sub_signed_friend(
225712853Sgabeblack@google.com            small_type us, int unb, int und, const sc_digit *ud,
225812853Sgabeblack@google.com            small_type vs, int vnb, int vnd, const sc_digit *vd);
225912853Sgabeblack@google.com
226012853Sgabeblack@google.com    friend sc_signed mul_signed_friend(
226112853Sgabeblack@google.com            small_type s, int unb, int und, const sc_digit *ud,
226212853Sgabeblack@google.com            int vnb, int vnd, const sc_digit *vd);
226312853Sgabeblack@google.com
226412853Sgabeblack@google.com    friend sc_signed div_signed_friend(
226512853Sgabeblack@google.com            small_type s, int unb, int und, const sc_digit *ud,
226612853Sgabeblack@google.com            int vnb, int vnd, const sc_digit *vd);
226712853Sgabeblack@google.com
226812853Sgabeblack@google.com    friend sc_signed mod_signed_friend(
226912853Sgabeblack@google.com            small_type us, int unb, int und, const sc_digit *ud,
227012853Sgabeblack@google.com            int vnb, int vnd, const sc_digit *vd);
227112853Sgabeblack@google.com
227212853Sgabeblack@google.com    friend sc_signed and_signed_friend(
227312853Sgabeblack@google.com            small_type us, int unb, int und, const sc_digit *ud,
227412853Sgabeblack@google.com            small_type vs, int vnb, int vnd, const sc_digit *vd);
227512853Sgabeblack@google.com
227612853Sgabeblack@google.com    friend sc_signed or_signed_friend(
227712853Sgabeblack@google.com            small_type us, int unb, int und, const sc_digit *ud,
227812853Sgabeblack@google.com            small_type vs, int vnb, int vnd, const sc_digit *vd);
227912853Sgabeblack@google.com
228012853Sgabeblack@google.com    friend sc_signed xor_signed_friend(
228112853Sgabeblack@google.com            small_type us, int unb, int und, const sc_digit *ud,
228212853Sgabeblack@google.com            small_type vs, int vnb, int vnd, const sc_digit *vd);
228312853Sgabeblack@google.com
228412853Sgabeblack@google.com  private:
228512853Sgabeblack@google.com
228612853Sgabeblack@google.com    small_type sgn; // Shortened as s.
228712853Sgabeblack@google.com    int nbits; // Shortened as nb.
228812853Sgabeblack@google.com    int ndigits; // Shortened as nd.
228912853Sgabeblack@google.com
229012853Sgabeblack@google.com#ifdef SC_MAX_NBITS
229112853Sgabeblack@google.com    sc_digit digit[DIV_CEIL(SC_MAX_NBITS)]; // Shortened as d.
229212853Sgabeblack@google.com#else
229312853Sgabeblack@google.com    sc_digit *digit; // Shortened as d.
229412853Sgabeblack@google.com#endif
229512853Sgabeblack@google.com
229612853Sgabeblack@google.com    /*
229712853Sgabeblack@google.com     * Private constructors:
229812853Sgabeblack@google.com     */
229912853Sgabeblack@google.com
230012853Sgabeblack@google.com    // Create a copy of v with sign s.
230112853Sgabeblack@google.com    sc_signed(const sc_signed &v, small_type s);
230212853Sgabeblack@google.com    sc_signed(const sc_unsigned &v, small_type s);
230312853Sgabeblack@google.com
230412853Sgabeblack@google.com    // Create a signed number with the given attributes.
230512853Sgabeblack@google.com    sc_signed(small_type s, int nb, int nd, sc_digit *d, bool alloc=true);
230612853Sgabeblack@google.com
230712853Sgabeblack@google.com    // Create an unsigned number using the bits u[l..r].
230812853Sgabeblack@google.com    sc_signed(const sc_signed *u, int l, int r);
230912853Sgabeblack@google.com    sc_signed(const sc_unsigned *u, int l, int r);
231012853Sgabeblack@google.com
231112853Sgabeblack@google.com    // Private member functions. The called functions are inline functions.
231212853Sgabeblack@google.com    small_type default_sign() const { return SC_NOSIGN; }
231312853Sgabeblack@google.com    int num_bits(int nb) const { return nb; }
231412853Sgabeblack@google.com
231512853Sgabeblack@google.com    bool check_if_outside(int bit_num) const;
231612853Sgabeblack@google.com
231712853Sgabeblack@google.com    void
231812853Sgabeblack@google.com    copy_digits(int nb, int nd, const sc_digit *d)
231912853Sgabeblack@google.com    {
232012853Sgabeblack@google.com        copy_digits_signed(sgn, nbits, ndigits, digit, nb, nd, d);
232112853Sgabeblack@google.com    }
232212853Sgabeblack@google.com
232312853Sgabeblack@google.com    void makezero() { sgn = make_zero(ndigits, digit); }
232412853Sgabeblack@google.com
232512853Sgabeblack@google.com    // Conversion functions between 2's complement (2C) and
232612853Sgabeblack@google.com    // sign-magnitude (SM):
232712853Sgabeblack@google.com    void
232812853Sgabeblack@google.com    convert_2C_to_SM()
232912853Sgabeblack@google.com    {
233012853Sgabeblack@google.com        sgn = convert_signed_2C_to_SM(nbits, ndigits, digit);
233112853Sgabeblack@google.com    }
233212853Sgabeblack@google.com
233312853Sgabeblack@google.com    void
233412853Sgabeblack@google.com    convert_SM_to_2C_to_SM()
233512853Sgabeblack@google.com    {
233612853Sgabeblack@google.com        sgn = convert_signed_SM_to_2C_to_SM(sgn, nbits, ndigits, digit);
233712853Sgabeblack@google.com    }
233812853Sgabeblack@google.com
233912853Sgabeblack@google.com    void
234012853Sgabeblack@google.com    convert_SM_to_2C()
234112853Sgabeblack@google.com    {
234212853Sgabeblack@google.com        convert_signed_SM_to_2C(sgn, ndigits, digit);
234312853Sgabeblack@google.com    }
234412853Sgabeblack@google.com};
234512853Sgabeblack@google.com
234612853Sgabeblack@google.cominline ::std::ostream &operator << (::std::ostream &, const sc_signed &);
234712853Sgabeblack@google.com
234812853Sgabeblack@google.cominline ::std::istream &operator >> (::std::istream &, sc_signed &);
234912853Sgabeblack@google.com
235012853Sgabeblack@google.cominline ::std::ostream &
235112853Sgabeblack@google.comoperator << (::std::ostream &os, const sc_signed_bitref_r &a)
235212853Sgabeblack@google.com{
235312853Sgabeblack@google.com    a.print(os);
235412853Sgabeblack@google.com    return os;
235512853Sgabeblack@google.com}
235612853Sgabeblack@google.com
235712853Sgabeblack@google.com
235812853Sgabeblack@google.cominline ::std::istream &
235912853Sgabeblack@google.comoperator >> (::std::istream &is, sc_signed_bitref &a)
236012853Sgabeblack@google.com{
236112853Sgabeblack@google.com    a.scan(is);
236212853Sgabeblack@google.com    return is;
236312853Sgabeblack@google.com}
236412853Sgabeblack@google.com
236512853Sgabeblack@google.com
236612853Sgabeblack@google.com// ----------------------------------------------------------------------------
236712853Sgabeblack@google.com//  CLASS : sc_signed_subref_r
236812853Sgabeblack@google.com//
236912853Sgabeblack@google.com//  Proxy class for sc_signed part selection (r-value only).
237012853Sgabeblack@google.com// ----------------------------------------------------------------------------
237112853Sgabeblack@google.com
237212853Sgabeblack@google.com
237312853Sgabeblack@google.com// reduce methods
237412853Sgabeblack@google.com
237512853Sgabeblack@google.cominline bool
237612853Sgabeblack@google.comsc_signed_subref_r::and_reduce() const
237712853Sgabeblack@google.com{
237812853Sgabeblack@google.com    const sc_signed *target_p = m_obj_p;
237912853Sgabeblack@google.com    for (int i = m_right; i <= m_left; i++)
238012853Sgabeblack@google.com        if (!target_p->test(i))
238112853Sgabeblack@google.com        return false;
238212853Sgabeblack@google.com    return true;
238312853Sgabeblack@google.com}
238412853Sgabeblack@google.com
238512853Sgabeblack@google.cominline bool
238612853Sgabeblack@google.comsc_signed_subref_r::nand_reduce() const
238712853Sgabeblack@google.com{
238812853Sgabeblack@google.com    return !and_reduce();
238912853Sgabeblack@google.com}
239012853Sgabeblack@google.com
239112853Sgabeblack@google.cominline bool
239212853Sgabeblack@google.comsc_signed_subref_r::or_reduce() const
239312853Sgabeblack@google.com{
239412853Sgabeblack@google.com    const sc_signed *target_p = m_obj_p;
239512853Sgabeblack@google.com    for (int i = m_right; i <= m_left; i++)
239612853Sgabeblack@google.com        if (target_p->test(i))
239712853Sgabeblack@google.com            return true;
239812853Sgabeblack@google.com    return false;
239912853Sgabeblack@google.com}
240012853Sgabeblack@google.com
240112853Sgabeblack@google.cominline bool
240212853Sgabeblack@google.comsc_signed_subref_r::nor_reduce() const
240312853Sgabeblack@google.com{
240412853Sgabeblack@google.com    return !or_reduce();
240512853Sgabeblack@google.com}
240612853Sgabeblack@google.com
240712853Sgabeblack@google.cominline bool
240812853Sgabeblack@google.comsc_signed_subref_r::xor_reduce() const
240912853Sgabeblack@google.com{
241012853Sgabeblack@google.com    int odd;
241112853Sgabeblack@google.com    const sc_signed *target_p = m_obj_p;
241212853Sgabeblack@google.com    odd = 0;
241312853Sgabeblack@google.com    for (int i = m_right; i <= m_left; i++)
241412853Sgabeblack@google.com        if (target_p->test(i)) odd = ~odd;
241512853Sgabeblack@google.com   return odd ? true : false;
241612853Sgabeblack@google.com}
241712853Sgabeblack@google.com
241812853Sgabeblack@google.cominline bool
241912853Sgabeblack@google.comsc_signed_subref_r::xnor_reduce() const
242012853Sgabeblack@google.com{
242112853Sgabeblack@google.com    return !xor_reduce();
242212853Sgabeblack@google.com}
242312853Sgabeblack@google.com
242412853Sgabeblack@google.cominline ::std::ostream &
242512853Sgabeblack@google.comoperator << (::std::ostream &os, const sc_signed_subref_r &a)
242612853Sgabeblack@google.com{
242712853Sgabeblack@google.com    a.print(os);
242812853Sgabeblack@google.com    return os;
242912853Sgabeblack@google.com}
243012853Sgabeblack@google.com
243112853Sgabeblack@google.com
243212853Sgabeblack@google.com// ----------------------------------------------------------------------------
243312853Sgabeblack@google.com//  CLASS : sc_signed_subref
243412853Sgabeblack@google.com//
243512853Sgabeblack@google.com//  Proxy class for sc_signed part selection (r-value and l-value).
243612853Sgabeblack@google.com// ----------------------------------------------------------------------------
243712853Sgabeblack@google.com
243812853Sgabeblack@google.com// assignment operators
243912853Sgabeblack@google.com
244012853Sgabeblack@google.cominline const sc_signed_subref &
244112853Sgabeblack@google.comsc_signed_subref::operator = (const char *a)
244212853Sgabeblack@google.com{
244312853Sgabeblack@google.com    sc_signed aa(length());
244412853Sgabeblack@google.com    return (*this = aa = a);
244512853Sgabeblack@google.com}
244612853Sgabeblack@google.com
244712853Sgabeblack@google.com
244812853Sgabeblack@google.com
244912853Sgabeblack@google.com
245012853Sgabeblack@google.cominline ::std::istream &
245112853Sgabeblack@google.comoperator >> (::std::istream &is, sc_signed_subref &a)
245212853Sgabeblack@google.com{
245312853Sgabeblack@google.com    a.scan(is);
245412853Sgabeblack@google.com    return is;
245512853Sgabeblack@google.com}
245612853Sgabeblack@google.com
245712853Sgabeblack@google.com
245812853Sgabeblack@google.com
245912853Sgabeblack@google.com// ----------------------------------------------------------------------------
246012853Sgabeblack@google.com//  CLASS : sc_signed
246112853Sgabeblack@google.com//
246212853Sgabeblack@google.com//  Arbitrary precision signed number.
246312853Sgabeblack@google.com// ----------------------------------------------------------------------------
246412853Sgabeblack@google.com
246512853Sgabeblack@google.comtemplate<class T>
246612853Sgabeblack@google.comsc_signed::sc_signed(const sc_generic_base<T> &v)
246712853Sgabeblack@google.com{
246812853Sgabeblack@google.com    int nb = v->length();
246912853Sgabeblack@google.com    sgn = default_sign();
247012853Sgabeblack@google.com    if (nb > 0) {
247112853Sgabeblack@google.com        nbits = num_bits(nb);
247212853Sgabeblack@google.com    } else {
247312853Sgabeblack@google.com        invalid_init("sc_generic_base<T>", nb);
247412853Sgabeblack@google.com        sc_core::sc_abort(); // can't recover from here
247512853Sgabeblack@google.com    }
247612853Sgabeblack@google.com    ndigits = DIV_CEIL(nbits);
247712853Sgabeblack@google.com#   ifdef SC_MAX_NBITS
247812853Sgabeblack@google.com        test_bound(nb);
247912853Sgabeblack@google.com#    else
248012853Sgabeblack@google.com        digit = new sc_digit[ndigits];
248112853Sgabeblack@google.com#    endif
248212853Sgabeblack@google.com    makezero();
248312853Sgabeblack@google.com    v->to_sc_signed(*this);
248412853Sgabeblack@google.com}
248512853Sgabeblack@google.com
248612853Sgabeblack@google.com
248712853Sgabeblack@google.com
248812853Sgabeblack@google.cominline ::std::ostream &
248912853Sgabeblack@google.comoperator << (::std::ostream &os, const sc_signed &a)
249012853Sgabeblack@google.com{
249112853Sgabeblack@google.com    a.print(os);
249212853Sgabeblack@google.com    return os;
249312853Sgabeblack@google.com}
249412853Sgabeblack@google.com
249512853Sgabeblack@google.cominline ::std::istream &
249612853Sgabeblack@google.comoperator >> (::std::istream &is, sc_signed &a)
249712853Sgabeblack@google.com{
249812853Sgabeblack@google.com    a.scan(is);
249912853Sgabeblack@google.com    return is;
250012853Sgabeblack@google.com}
250112853Sgabeblack@google.com
250212853Sgabeblack@google.com} // namespace sc_dt
250312853Sgabeblack@google.com
250412853Sgabeblack@google.com#endif // __SYSTEMC_EXT_DT_INT_SC_SIGNED_HH__
2505