Deleted Added
sdiff udiff text old ( 12837:413a7b490b1b ) new ( 12853:e23d6f09069a )
full compact
1/*****************************************************************************
2
3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4 more contributor license agreements. See the NOTICE file distributed
5 with this work for additional information regarding copyright ownership.
6 Accellera licenses this file to you under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with the
8 License. You may obtain a copy of the License at

--- 4 unchanged lines hidden (view full) ---

13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15 implied. See the License for the specific language governing
16 permissions and limitations under the License.
17
18 *****************************************************************************/
19
20/*****************************************************************************
21 sc_nbdefs.h -- Top level header file for arbitrary precision signed/unsigned
22 arithmetic. This file defines all the constants needed.
23 *****************************************************************************/
24
25#ifndef __SYSTEMC_DT_SC_NBDEFS_H__
26#define __SYSTEMC_DT_SC_NBDEFS_H__
27
28#include <stdint.h>
29
30#include <climits>
31
32namespace sc_dt
33{
34
35// ----------------------------------------------------------------------------

--- 36 unchanged lines hidden (view full) ---

72#define BYTE_RADIX 256
73#define BYTE_MASK 255
74
75// LOG2_BITS_PER_BYTE = log2(BITS_PER_BYTE), assuming that
76// BITS_PER_BYTE is a power of 2.
77#define LOG2_BITS_PER_BYTE 3
78
79// Attributes of the unsigned long. These definitions are used mainly in
80// the functions that are aware of the internal representation of digits,
81// e.g., get/set_packed_rep().
82#define BYTES_PER_DIGIT_TYPE 4
83#define BITS_PER_DIGIT_TYPE 32
84
85// Attributes of a digit, i.e., unsigned long less the overflow bits.
86#define BYTES_PER_DIGIT 4
87#define BITS_PER_DIGIT 30
88#define DIGIT_RADIX (1ul << BITS_PER_DIGIT)
89#define DIGIT_MASK (DIGIT_RADIX - 1)

--- 25 unchanged lines hidden (view full) ---

115
116// Support for "digit" vectors used to hold the values of sc_signed,
117// sc_unsigned, sc_bv_base, and sc_lv_base data types. This type is also used
118// in the concatenation support. An sc_digit is currently an unsigned 32-bit
119// quantity. The typedef used is an unsigned int, rather than an unsigned long,
120// since the unsigned long data type varies in size between 32-bit and 64-bit
121// machines.
122
123typedef unsigned int sc_digit; // 32-bit unsigned integer
124
125// Support for the long long type. This type is not in the standard
126// but is usually supported by compilers.
127typedef int64_t int64;
128typedef uint64_t uint64;
129
130static const uint64 UINT64_ZERO = 0ULL;
131static const uint64 UINT64_ONE = 1ULL;
132static const uint64 UINT64_32ONES = 0x00000000ffffffffULL;
133
134// Bits per ...
135// will be deleted in the future. Use numeric_limits instead
136#define BITS_PER_CHAR 8
137#define BITS_PER_INT (sizeof(int) * BITS_PER_CHAR)
138#define BITS_PER_LONG (sizeof(long) * BITS_PER_CHAR)
139#define BITS_PER_INT64 (sizeof(::sc_dt::int64) * BITS_PER_CHAR)
140#define BITS_PER_UINT (sizeof(unsigned int) * BITS_PER_CHAR)
141#define BITS_PER_ULONG (sizeof(unsigned long) * BITS_PER_CHAR)
142#define BITS_PER_UINT64 (sizeof(::sc_dt::uint64) * BITS_PER_CHAR)
143
144// Digits per ...
145#define DIGITS_PER_CHAR 1
146#define DIGITS_PER_INT ((BITS_PER_INT+29)/30)
147#define DIGITS_PER_LONG ((BITS_PER_LONG+29)/30)
148#define DIGITS_PER_INT64 ((BITS_PER_INT64+29)/30)
149#define DIGITS_PER_UINT ((BITS_PER_UINT+29)/30)
150#define DIGITS_PER_ULONG ((BITS_PER_ULONG+29)/30)
151#define DIGITS_PER_UINT64 ((BITS_PER_UINT64+29)/30)
152
153// Above, BITS_PER_X is mainly used for sc_signed, and BITS_PER_UX is
154// mainly used for sc_unsigned.
155
156static const small_type NB_DEFAULT_BASE = SC_DEC;
157
158// For sc_int code:
159
160typedef int64 int_type;
161typedef uint64 uint_type;
162#define SC_INTWIDTH 64
163static const uint64 UINT_ZERO = UINT64_ZERO;
164static const uint64 UINT_ONE = UINT64_ONE;
165
166} // namespace sc_dt
167
168#endif