00001 /***************************************************************************** 00002 00003 The following code is derived, directly or indirectly, from the SystemC 00004 source code Copyright (c) 1996-2006 by all Contributors. 00005 All Rights reserved. 00006 00007 The contents of this file are subject to the restrictions and limitations 00008 set forth in the SystemC Open Source License Version 2.4 (the "License"); 00009 You may not use this file except in compliance with such restrictions and 00010 limitations. You may obtain instructions on how to receive a copy of the 00011 License at http://www.systemc.org/. Software distributed by Contributors 00012 under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF 00013 ANY KIND, either express or implied. See the License for the specific 00014 language governing rights and limitations under the License. 00015 00016 *****************************************************************************/ 00017 00018 /***************************************************************************** 00019 00020 sc_nbdefs.h -- Top level header file for arbitrary precision signed/unsigned 00021 arithmetic. This file defines all the constants needed. 00022 00023 Original Author: Ali Dasdan, Synopsys, Inc. 00024 00025 *****************************************************************************/ 00026 00027 /***************************************************************************** 00028 00029 MODIFICATION LOG - modifiers, enter your name, affiliation, date and 00030 changes you are making here. 00031 00032 Name, Affiliation, Date: 00033 Description of Modification: 00034 00035 *****************************************************************************/ 00036 00037 00038 // $Log: sc_nbdefs.cpp,v $ 00039 // Revision 1.1.1.1 2006/12/15 20:31:36 acg 00040 // SystemC 2.2 00041 // 00042 // Revision 1.3 2006/01/13 18:49:32 acg 00043 // Added $Log command so that CVS check in comments are reproduced in the 00044 // source. 00045 // 00046 00047 #include "sysc/datatypes/int/sc_nbdefs.h" 00048 00049 00050 namespace sc_dt 00051 { 00052 00053 #ifdef SC_MAX_NBITS 00054 const int MAX_NDIGITS = DIV_CEIL(SC_MAX_NBITS) + 2; 00055 // Consider a number with x bits another with y bits. The maximum 00056 // number of bits happens when we multiply them. The result will have 00057 // (x + y) bits. Assume that x + y <= SC_MAX_NBITS. Then, DIV_CEIL(x) + 00058 // DIV_CEIL(y) <= DIV_CEIL(SC_MAX_NBITS) + 2. This is the reason for +2 00059 // above. With this change, MAX_NDIGITS must be enough to hold the 00060 // result of any operation. 00061 #endif 00062 00063 // Support for the long long type. This type is not in the standard 00064 // but is usually supported by compilers. 00065 #ifndef WIN32 00066 const uint64 UINT64_ZERO = 0ULL; 00067 const uint64 UINT64_ONE = 1ULL; 00068 const uint64 UINT64_32ONES = 0x00000000ffffffffULL; 00069 #else 00070 const uint64 UINT64_ZERO = 0i64; 00071 const uint64 UINT64_ONE = 1i64; 00072 const uint64 UINT64_32ONES = 0x00000000ffffffffi64; 00073 #endif 00074 00075 const small_type NB_DEFAULT_BASE = SC_DEC; 00076 00077 #ifndef _32BIT_ 00078 const uint64 UINT_ZERO = UINT64_ZERO; 00079 const uint64 UINT_ONE = UINT64_ONE; 00080 #else 00081 const unsigned int UINT_ZERO = 0U; 00082 const unsigned int UINT_ONE = 1U; 00083 #endif 00084 00085 } // namespace sc_dt