sc_nbdefs.hh (12837:413a7b490b1b) sc_nbdefs.hh (12853:e23d6f09069a)
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/*****************************************************************************
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
21 sc_nbdefs.h -- Top level header file for arbitrary precision signed/unsigned
22 arithmetic. This file defines all the constants needed.
22 sc_nbdefs.h -- Top level header file for arbitrary precision signed/unsigned
23 arithmetic. This file defines all the constants needed.
24
25 Original Author: Ali Dasdan, Synopsys, Inc.
26
23 *****************************************************************************/
24
27 *****************************************************************************/
28
25#ifndef __SYSTEMC_DT_SC_NBDEFS_H__
26#define __SYSTEMC_DT_SC_NBDEFS_H__
29/*****************************************************************************
27
30
31 MODIFICATION LOG - modifiers, enter your name, affiliation, date and
32 changes you are making here.
33
34 Name, Affiliation, Date: Torsten Maehne, Berner Fachhochschule,
35 2016-09-24
36 Description of Modification: Move constant definitions to the header so that
37 that their value is known at compile time.
38
39 *****************************************************************************/
40
41// $Log: sc_nbdefs.h,v $
42// Revision 1.7 2011/02/18 20:19:15 acg
43// Andy Goodrich: updating Copyright notice.
44//
45// Revision 1.6 2011/02/18 20:09:34 acg
46// Philipp A. Hartmann: added alternative #define for Windows to guard.
47//
48// Revision 1.5 2011/01/20 16:52:20 acg
49// Andy Goodrich: changes for IEEE 1666 2011.
50//
51// Revision 1.4 2010/02/08 18:35:55 acg
52// Andy Goodrich: Philipp Hartmann's changes for Solaris and Linux 64.
53//
54// Revision 1.2 2009/05/22 16:06:29 acg
55// Andy Goodrich: process control updates.
56//
57// Revision 1.1.1.1 2006/12/15 20:20:05 acg
58// SystemC 2.3
59//
60// Revision 1.3 2006/01/13 18:49:32 acg
61// Added $Log command so that CVS check in comments are reproduced in the
62// source.
63//
64
65#ifndef __SYSTEMC_EXT_DT_INT_SC_NBDEFS_HH__
66#define __SYSTEMC_EXT_DT_INT_SC_NBDEFS_HH__
67
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
68#include <stdint.h>
69
70#include <climits>
71
72namespace sc_dt
73{
74
75// ----------------------------------------------------------------------------

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

112#define BYTE_RADIX 256
113#define BYTE_MASK 255
114
115// LOG2_BITS_PER_BYTE = log2(BITS_PER_BYTE), assuming that
116// BITS_PER_BYTE is a power of 2.
117#define LOG2_BITS_PER_BYTE 3
118
119// 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().
120// the functions that are aware of the internal representation of
121// digits, 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
122#define BYTES_PER_DIGIT_TYPE 4
123#define BITS_PER_DIGIT_TYPE 32
124
125// Attributes of a digit, i.e., unsigned long less the overflow bits.
126#define BYTES_PER_DIGIT 4
127#define BITS_PER_DIGIT 30
128#define DIGIT_RADIX (1ul << BITS_PER_DIGIT)
129#define DIGIT_MASK (DIGIT_RADIX - 1)

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

155
156// Support for "digit" vectors used to hold the values of sc_signed,
157// sc_unsigned, sc_bv_base, and sc_lv_base data types. This type is also used
158// in the concatenation support. An sc_digit is currently an unsigned 32-bit
159// quantity. The typedef used is an unsigned int, rather than an unsigned long,
160// since the unsigned long data type varies in size between 32-bit and 64-bit
161// machines.
162
123typedef unsigned int sc_digit; // 32-bit unsigned integer
163typedef 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.
164
165// Support for the long long type. This type is not in the standard
166// but is usually supported by compilers.
167#if defined(__x86_64__) || defined(__aarch64__)
168typedef long long int64;
169typedef unsigned long long uint64;
170#else
127typedef int64_t int64;
128typedef uint64_t uint64;
171typedef int64_t int64;
172typedef uint64_t uint64;
173#endif
129
174
130static const uint64 UINT64_ZERO = 0ULL;
131static const uint64 UINT64_ONE = 1ULL;
175static const uint64 UINT64_ZERO = 0ULL;
176static const uint64 UINT64_ONE = 1ULL;
132static const uint64 UINT64_32ONES = 0x00000000ffffffffULL;
133
177static const uint64 UINT64_32ONES = 0x00000000ffffffffULL;
178
179
134// Bits per ...
135// will be deleted in the future. Use numeric_limits instead
180// Bits per ...
181// 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)
182#define BITS_PER_CHAR 8
183#define BITS_PER_INT (sizeof(int) * BITS_PER_CHAR)
184#define BITS_PER_LONG (sizeof(long) * BITS_PER_CHAR)
185#define BITS_PER_INT64 (sizeof(::sc_dt::int64) * BITS_PER_CHAR)
186#define BITS_PER_UINT (sizeof(unsigned int) * BITS_PER_CHAR)
187#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 ...
188#define BITS_PER_UINT64 (sizeof(::sc_dt::uint64) * BITS_PER_CHAR)
189
190// 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)
191#define DIGITS_PER_CHAR 1
192#define DIGITS_PER_INT ((BITS_PER_INT + 29) / 30)
193#define DIGITS_PER_LONG ((BITS_PER_LONG + 29) / 30)
194#define DIGITS_PER_INT64 ((BITS_PER_INT64 + 29) / 30)
195#define DIGITS_PER_UINT ((BITS_PER_UINT + 29) / 30)
196#define DIGITS_PER_ULONG ((BITS_PER_ULONG + 29) / 30)
197#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
198
199// Above, BITS_PER_X is mainly used for sc_signed, and BITS_PER_UX is
200// mainly used for sc_unsigned.
201
202static const small_type NB_DEFAULT_BASE = SC_DEC;
203
204// For sc_int code:
205
206typedef int64 int_type;
207typedef uint64 uint_type;
208#define SC_INTWIDTH 64
209static const uint64 UINT_ZERO = UINT64_ZERO;
210static const uint64 UINT_ONE = UINT64_ONE;
211
212} // namespace sc_dt
213
168#endif
214#endif // __SYSTEMC_EXT_DT_INT_SC_NBDEFS_HH__