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