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
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 #ifndef SC_NBDEFS_H
00062 #define SC_NBDEFS_H
00063
00064
00065 #include "sysc/kernel/sc_cmnhdr.h"
00066
00067 #include <climits>
00068
00069 #if defined(__sun) || defined(__sun__)
00070 # include <inttypes.h>
00071 #elif !defined(WIN32) && !defined(_WIN32)
00072 # include <stdint.h>
00073 #endif
00074
00075 #include "sysc/utils/sc_iostream.h"
00076 #include "sysc/kernel/sc_constants.h"
00077
00078
00079 #define SC_DT_MIXED_COMMA_OPERATORS
00080
00081
00082 namespace sc_dt
00083 {
00084
00085
00086
00087
00088
00089
00090
00091 enum sc_numrep
00092 {
00093 SC_NOBASE = 0,
00094 SC_BIN = 2,
00095 SC_OCT = 8,
00096 SC_DEC = 10,
00097 SC_HEX = 16,
00098 SC_BIN_US,
00099 SC_BIN_SM,
00100 SC_OCT_US,
00101 SC_OCT_SM,
00102 SC_HEX_US,
00103 SC_HEX_SM,
00104 SC_CSD
00105 };
00106
00107
00108
00109 #define SC_NEG -1 // Negative number
00110 #define SC_ZERO 0 // Zero
00111 #define SC_POS 1 // Positive number
00112 #define SC_NOSIGN 2 // Uninitialized sc_signed number
00113
00114 typedef unsigned char uchar;
00115
00116
00117
00118 typedef int small_type;
00119
00120
00121 #define BITS_PER_BYTE 8
00122 #define BYTE_RADIX 256
00123 #define BYTE_MASK 255
00124
00125
00126
00127 #define LOG2_BITS_PER_BYTE 3
00128
00129
00130
00131
00132 #define BYTES_PER_DIGIT_TYPE 4
00133 #define BITS_PER_DIGIT_TYPE 32
00134
00135
00136 #define BYTES_PER_DIGIT 4
00137 #define BITS_PER_DIGIT 30
00138 #define DIGIT_RADIX (1ul << BITS_PER_DIGIT)
00139 #define DIGIT_MASK (DIGIT_RADIX - 1)
00140
00141
00142
00143
00144
00145 #define BITS_PER_HALF_DIGIT (BITS_PER_DIGIT / 2)
00146 #define HALF_DIGIT_RADIX (1ul << BITS_PER_HALF_DIGIT)
00147 #define HALF_DIGIT_MASK (HALF_DIGIT_RADIX - 1)
00148
00149
00150 #define DIV_CEIL2(x, y) (((x) - 1) / (y) + 1)
00151
00152
00153
00154 #define DIV_CEIL(x) DIV_CEIL2(x, BITS_PER_DIGIT)
00155
00156 #ifdef SC_MAX_NBITS
00157 extern const int MAX_NDIGITS;
00158
00159
00160
00161
00162
00163
00164 #endif
00165
00166
00167
00168
00169
00170
00171
00172
00173 typedef unsigned int sc_digit;
00174
00175
00176
00177 #ifndef _WIN32
00178 # if defined(__x86_64__)
00179 typedef long long int64;
00180 typedef unsigned long long uint64;
00181 # else
00182 typedef int64_t int64;
00183 typedef uint64_t uint64;
00184 # endif
00185 extern const uint64 UINT64_ZERO;
00186 extern const uint64 UINT64_ONE;
00187 extern const uint64 UINT64_32ONES;
00188 #else
00189 typedef __int64 int64;
00190 typedef unsigned __int64 uint64;
00191 extern const uint64 UINT64_ZERO;
00192 extern const uint64 UINT64_ONE;
00193 extern const uint64 UINT64_32ONES;
00194 #endif
00195
00196
00197
00198
00199 #define BITS_PER_CHAR 8
00200 #define BITS_PER_INT (sizeof(int) * BITS_PER_CHAR)
00201 #define BITS_PER_LONG (sizeof(long) * BITS_PER_CHAR)
00202 #define BITS_PER_INT64 (sizeof(::sc_dt::int64) * BITS_PER_CHAR)
00203 #define BITS_PER_UINT (sizeof(unsigned int) * BITS_PER_CHAR)
00204 #define BITS_PER_ULONG (sizeof(unsigned long) * BITS_PER_CHAR)
00205 #define BITS_PER_UINT64 (sizeof(::sc_dt::uint64) * BITS_PER_CHAR)
00206
00207
00208 #define DIGITS_PER_CHAR 1
00209 #define DIGITS_PER_INT ((BITS_PER_INT+29)/30)
00210 #define DIGITS_PER_LONG ((BITS_PER_LONG+29)/30)
00211 #define DIGITS_PER_INT64 ((BITS_PER_INT64+29)/30)
00212 #define DIGITS_PER_UINT ((BITS_PER_UINT+29)/30)
00213 #define DIGITS_PER_ULONG ((BITS_PER_ULONG+29)/30)
00214 #define DIGITS_PER_UINT64 ((BITS_PER_UINT64+29)/30)
00215
00216
00217
00218
00219 #if defined( _WIN32 ) || defined( __HP_aCC )
00220 typedef unsigned long fmtflags;
00221 #else
00222 typedef ::std::ios::fmtflags fmtflags;
00223 #endif
00224
00225 extern const small_type NB_DEFAULT_BASE ;
00226
00227
00228 #define LLWIDTH BITS_PER_INT64
00229 #define INTWIDTH BITS_PER_INT
00230
00231 #ifndef _32BIT_
00232
00233 typedef int64 int_type;
00234 typedef uint64 uint_type;
00235 #define SC_INTWIDTH 64
00236 extern const uint64 UINT_ZERO;
00237 extern const uint64 UINT_ONE;
00238
00239 #else
00240
00241 typedef int int_type;
00242 typedef unsigned int uint_type;
00243 #define SC_INTWIDTH 32
00244 extern const unsigned int UINT_ZERO;
00245 extern const unsigned int UINT_ONE;
00246
00247 #endif
00248
00249
00250 #if defined(_MSC_VER) && ( _MSC_VER < 1300 )
00251
00252 ::std::ostream& operator << ( ::std::ostream&, int64 );
00253 ::std::ostream& operator << ( ::std::ostream&, uint64 );
00254 #endif
00255
00256 }
00257
00258
00259 #if defined(_MSC_VER) && ( _MSC_VER < 1300 )
00260
00261 inline
00262 ::std::ostream&
00263 operator << ( ::std::ostream& os, sc_dt::int64 a )
00264 {
00265 sc_dt::operator << ( os, a );
00266 return os;
00267 }
00268
00269 inline
00270 ::std::ostream&
00271 operator << ( ::std::ostream& os, sc_dt::uint64 a )
00272 {
00273 sc_dt::operator << ( os, a );
00274 return os;
00275 }
00276
00277 #endif
00278
00279
00280 #endif