00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef SC_NBDEFS_H
00038 #define SC_NBDEFS_H
00039
00040
00041 #include "sysc/kernel/sc_cmnhdr.h"
00042
00043 #include <climits>
00044
00045 #include "sysc/utils/sc_iostream.h"
00046 #include "sysc/kernel/sc_constants.h"
00047 #include "sysc/utils/sc_string.h"
00048
00049
00050 #if defined( __SUNPRO_CC ) || defined( _MSC_VER ) || 1
00051 #define SC_DT_MIXED_COMMA_OPERATORS
00052 #endif
00053
00054
00055 namespace sc_dt
00056 {
00057
00058
00059 #define SC_NEG -1 // Negative number
00060 #define SC_ZERO 0 // Zero
00061 #define SC_POS 1 // Positive number
00062 #define SC_NOSIGN 2 // Uninitialized sc_signed number
00063
00064 typedef unsigned char uchar;
00065
00066
00067
00068 typedef int small_type;
00069
00070
00071 #define BITS_PER_BYTE 8
00072 #define BYTE_RADIX 256
00073 #define BYTE_MASK 255
00074
00075
00076
00077 #define LOG2_BITS_PER_BYTE 3
00078
00079
00080
00081
00082 #define BYTES_PER_DIGIT_TYPE 4
00083 #define BITS_PER_DIGIT_TYPE 32
00084
00085
00086 #define BYTES_PER_DIGIT 4
00087 #define BITS_PER_DIGIT 30
00088 #define DIGIT_RADIX (1ul << BITS_PER_DIGIT)
00089 #define DIGIT_MASK (DIGIT_RADIX - 1)
00090
00091
00092
00093
00094
00095 #define BITS_PER_HALF_DIGIT (BITS_PER_DIGIT / 2)
00096 #define HALF_DIGIT_RADIX (1ul << BITS_PER_HALF_DIGIT)
00097 #define HALF_DIGIT_MASK (HALF_DIGIT_RADIX - 1)
00098
00099
00100 #define DIV_CEIL2(x, y) (((x) - 1) / (y) + 1)
00101
00102
00103
00104 #define DIV_CEIL(x) DIV_CEIL2(x, BITS_PER_DIGIT)
00105
00106 #ifdef SC_MAX_NBITS
00107 extern const int MAX_NDIGITS;
00108
00109
00110
00111
00112
00113
00114 #endif
00115
00116
00117
00118 #ifndef WIN32
00119 typedef long long int64;
00120 typedef unsigned long long uint64;
00121 extern const uint64 UINT64_ZERO;
00122 extern const uint64 UINT64_ONE;
00123 extern const uint64 UINT64_32ONES;
00124 #else
00125 typedef __int64 int64;
00126 typedef unsigned __int64 uint64;
00127 extern const uint64 UINT64_ZERO;
00128 extern const uint64 UINT64_ONE;
00129 extern const uint64 UINT64_32ONES;
00130 #endif
00131
00132
00133
00134
00135 #define BITS_PER_CHAR 8
00136 #define BITS_PER_INT 32
00137 #define BITS_PER_LONG 32
00138 #define BITS_PER_INT64 64
00139 #define BITS_PER_UINT 32
00140 #define BITS_PER_ULONG 32
00141 #define BITS_PER_UINT64 64
00142
00143
00144 #define DIGITS_PER_CHAR 1
00145 #define DIGITS_PER_INT 2
00146 #define DIGITS_PER_LONG 2
00147 #define DIGITS_PER_INT64 3
00148 #define DIGITS_PER_UINT 2
00149 #define DIGITS_PER_ULONG 2
00150 #define DIGITS_PER_UINT64 3
00151
00152
00153
00154
00155 #if defined( WIN32 ) || defined( __SUNPRO_CC ) || defined( __HP_aCC )
00156 typedef unsigned long fmtflags;
00157 #else
00158 typedef ::std::ios::fmtflags fmtflags;
00159 #endif
00160
00161 extern const small_type NB_DEFAULT_BASE ;
00162
00163
00164 #define LLWIDTH BITS_PER_INT64
00165 #define INTWIDTH BITS_PER_INT
00166
00167 #ifndef _32BIT_
00168
00169 typedef int64 int_type;
00170 typedef uint64 uint_type;
00171 #define SC_INTWIDTH 64
00172 extern const uint64 UINT_ZERO;
00173 extern const uint64 UINT_ONE;
00174
00175 #else
00176
00177 typedef int int_type;
00178 typedef unsigned int uint_type;
00179 #define SC_INTWIDTH 32
00180 extern const unsigned int UINT_ZERO;
00181 extern const unsigned int UINT_ONE;
00182
00183 #endif
00184
00185
00186 #if defined(_MSC_VER) && ( _MSC_VER < 1300 )
00187
00188 ::std::ostream& operator << ( ::std::ostream&, int64 );
00189 ::std::ostream& operator << ( ::std::ostream&, uint64 );
00190 #endif
00191
00192 }
00193
00194
00195 #if defined(_MSC_VER) && ( _MSC_VER < 1300 )
00196
00197 inline
00198 ::std::ostream&
00199 operator << ( ::std::ostream& os, sc_dt::int64 a )
00200 {
00201 sc_dt::operator << ( os, a );
00202 return os;
00203 }
00204
00205 inline
00206 ::std::ostream&
00207 operator << ( ::std::ostream& os, sc_dt::uint64 a )
00208 {
00209 sc_dt::operator << ( os, a );
00210 return os;
00211 }
00212
00213 #endif
00214
00215
00216 #endif