[gem5-dev] Change in gem5/gem5[master]: systemc: Add the sc_nbdefs.hh header from Accellera.
Gabe Black has submitted this change and it was merged. ( https://gem5-review.googlesource.com/10826 ) Change subject: systemc: Add the sc_nbdefs.hh header from Accellera. .. systemc: Add the sc_nbdefs.hh header from Accellera. This header defines the uint64 type alias needed for the sc_time class. Change-Id: I7793dbfb98001796c8c8fe24f69fe7868249ff85 Reviewed-on: https://gem5-review.googlesource.com/10826 Reviewed-by: Jason Lowe-Power Maintainer: Gabe Black --- A src/systemc/dt/int/sc_nbdefs.hh 1 file changed, 168 insertions(+), 0 deletions(-) Approvals: Jason Lowe-Power: Looks good to me, approved Gabe Black: Looks good to me, approved diff --git a/src/systemc/dt/int/sc_nbdefs.hh b/src/systemc/dt/int/sc_nbdefs.hh new file mode 100644 index 000..48d735a --- /dev/null +++ b/src/systemc/dt/int/sc_nbdefs.hh @@ -0,0 +1,168 @@ +/* + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + */ + +/* + sc_nbdefs.h -- Top level header file for arbitrary precision signed/unsigned + arithmetic. This file defines all the constants needed. + */ + +#ifndef __SYSTEMC_DT_SC_NBDEFS_H__ +#define __SYSTEMC_DT_SC_NBDEFS_H__ + +#include + +#include + +namespace sc_dt +{ + +// +// ENUM : sc_numrep +// +// Enumeration of number representations for character string conversion. +// + +enum sc_numrep +{ +SC_NOBASE = 0, +SC_BIN = 2, +SC_OCT = 8, +SC_DEC = 10, +SC_HEX = 16, +SC_BIN_US, +SC_BIN_SM, +SC_OCT_US, +SC_OCT_SM, +SC_HEX_US, +SC_HEX_SM, +SC_CSD +}; + + +// Sign of a number: +#define SC_NEG -1 // Negative number +#define SC_ZERO 0 // Zero +#define SC_POS 1 // Positive number +#define SC_NOSIGN 2 // Uninitialized sc_signed number + +typedef unsigned char uchar; + +// A small_type number is at least a char. Defining an int is probably +// better for alignment. +typedef int small_type; + +// Attributes of a byte. +#define BITS_PER_BYTE 8 +#define BYTE_RADIX 256 +#define BYTE_MASK 255 + +// LOG2_BITS_PER_BYTE = log2(BITS_PER_BYTE), assuming that +// BITS_PER_BYTE is a power of 2. +#define LOG2_BITS_PER_BYTE 3 + +// Attributes of the unsigned long. These definitions are used mainly in +// the functions that are aware of the internal representation of digits, +// e.g., get/set_packed_rep(). +#define BYTES_PER_DIGIT_TYPE 4 +#define BITS_PER_DIGIT_TYPE 32 + +// Attributes of a digit, i.e., unsigned long less the overflow bits. +#define BYTES_PER_DIGIT 4 +#define BITS_PER_DIGIT 30 +#define DIGIT_RADIX (1ul << BITS_PER_DIGIT) +#define DIGIT_MASK (DIGIT_RADIX - 1) +// Make sure that BYTES_PER_DIGIT = ceil(BITS_PER_DIGIT / BITS_PER_BYTE). + +// Similar attributes for the half of a digit. Note that +// HALF_DIGIT_RADIX is equal to the square root of DIGIT_RADIX. These +// definitions are used mainly in the multiplication routines. +#define BITS_PER_HALF_DIGIT (BITS_PER_DIGIT / 2) +#define HALF_DIGIT_RADIX (1ul << BITS_PER_HALF_DIGIT) +#define HALF_DIGIT_MASK (HALF_DIGIT_RADIX - 1) + +// DIV_CEIL2(x, y) = ceil(x / y). x and y are positive numbers. +#define DIV_CEIL2(x, y) (((x) - 1) / (y) + 1) + +// DIV_CEIL(x) = ceil(x / BITS_PER_DIGIT) = the number of digits to +// store x bits. x is a positive number. +#define DIV_CEIL(x) DIV_CEIL2(x, BITS_PER_DIGIT) + +#ifdef SC_MAX_NBITS +static const int MAX_NDIGITS = DIV_CEIL(SC_MAX_NBITS) + 2; +// Consider a number with x bits another with y bits. The maximum +// number of bits happens when we multiply them. The result will have +// (x + y) bits. Assume that x + y <= SC_MAX_NBITS. Then, DIV_CEIL(x) + +// DIV_CEIL(y) <= DIV_CEIL(SC_MAX_NBITS) + 2. This is the reason for +2 +// above. With this change, MAX_NDIGITS must be enough to hold the
[gem5-dev] Change in gem5/gem5[master]: systemc: Add the sc_nbdefs.hh header from Accellera.
Hello Jason Lowe-Power, Matthias Jung, Andreas Sandberg, I'd like you to reexamine a change. Please visit https://gem5-review.googlesource.com/10826 to look at the new patch set (#4). Change subject: systemc: Add the sc_nbdefs.hh header from Accellera. .. systemc: Add the sc_nbdefs.hh header from Accellera. This header defines the uint64 type alias needed for the sc_time class. Change-Id: I7793dbfb98001796c8c8fe24f69fe7868249ff85 --- A src/systemc/dt/int/sc_nbdefs.hh 1 file changed, 168 insertions(+), 0 deletions(-) -- To view, visit https://gem5-review.googlesource.com/10826 To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings Gerrit-Project: public/gem5 Gerrit-Branch: master Gerrit-Change-Id: I7793dbfb98001796c8c8fe24f69fe7868249ff85 Gerrit-Change-Number: 10826 Gerrit-PatchSet: 4 Gerrit-Owner: Gabe Black Gerrit-Reviewer: Andreas Sandberg Gerrit-Reviewer: Gabe Black Gerrit-Reviewer: Jason Lowe-Power Gerrit-Reviewer: Matthias Jung Gerrit-MessageType: newpatchset ___ gem5-dev mailing list gem5-dev@gem5.org http://m5sim.org/mailman/listinfo/gem5-dev
[gem5-dev] Change in gem5/gem5[master]: systemc: Add the sc_nbdefs.hh header from Accellera.
Hello Jason Lowe-Power, Matthias Jung, Andreas Sandberg, I'd like you to reexamine a change. Please visit https://gem5-review.googlesource.com/10826 to look at the new patch set (#2). Change subject: systemc: Add the sc_nbdefs.hh header from Accellera. .. systemc: Add the sc_nbdefs.hh header from Accellera. This header defines the uint64 type alias needed for the sc_time class. Change-Id: I7793dbfb98001796c8c8fe24f69fe7868249ff85 --- A src/systemc/dt/int/sc_nbdefs.hh 1 file changed, 168 insertions(+), 0 deletions(-) -- To view, visit https://gem5-review.googlesource.com/10826 To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings Gerrit-Project: public/gem5 Gerrit-Branch: master Gerrit-Change-Id: I7793dbfb98001796c8c8fe24f69fe7868249ff85 Gerrit-Change-Number: 10826 Gerrit-PatchSet: 2 Gerrit-Owner: Gabe Black Gerrit-Reviewer: Andreas Sandberg Gerrit-Reviewer: Gabe Black Gerrit-Reviewer: Jason Lowe-Power Gerrit-Reviewer: Matthias Jung Gerrit-MessageType: newpatchset ___ gem5-dev mailing list gem5-dev@gem5.org http://m5sim.org/mailman/listinfo/gem5-dev
[gem5-dev] Change in gem5/gem5[master]: systemc: Add the sc_nbdefs.hh header from Accellera.
Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/10826 Change subject: systemc: Add the sc_nbdefs.hh header from Accellera. .. systemc: Add the sc_nbdefs.hh header from Accellera. This header defines the uint64 type alias needed for the sc_time class. Change-Id: I7793dbfb98001796c8c8fe24f69fe7868249ff85 --- A src/systemc/dt/int/sc_nbdefs.hh 1 file changed, 168 insertions(+), 0 deletions(-) diff --git a/src/systemc/dt/int/sc_nbdefs.hh b/src/systemc/dt/int/sc_nbdefs.hh new file mode 100644 index 000..48d735a --- /dev/null +++ b/src/systemc/dt/int/sc_nbdefs.hh @@ -0,0 +1,168 @@ +/* + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + */ + +/* + sc_nbdefs.h -- Top level header file for arbitrary precision signed/unsigned + arithmetic. This file defines all the constants needed. + */ + +#ifndef __SYSTEMC_DT_SC_NBDEFS_H__ +#define __SYSTEMC_DT_SC_NBDEFS_H__ + +#include + +#include + +namespace sc_dt +{ + +// +// ENUM : sc_numrep +// +// Enumeration of number representations for character string conversion. +// + +enum sc_numrep +{ +SC_NOBASE = 0, +SC_BIN = 2, +SC_OCT = 8, +SC_DEC = 10, +SC_HEX = 16, +SC_BIN_US, +SC_BIN_SM, +SC_OCT_US, +SC_OCT_SM, +SC_HEX_US, +SC_HEX_SM, +SC_CSD +}; + + +// Sign of a number: +#define SC_NEG -1 // Negative number +#define SC_ZERO 0 // Zero +#define SC_POS 1 // Positive number +#define SC_NOSIGN 2 // Uninitialized sc_signed number + +typedef unsigned char uchar; + +// A small_type number is at least a char. Defining an int is probably +// better for alignment. +typedef int small_type; + +// Attributes of a byte. +#define BITS_PER_BYTE 8 +#define BYTE_RADIX 256 +#define BYTE_MASK 255 + +// LOG2_BITS_PER_BYTE = log2(BITS_PER_BYTE), assuming that +// BITS_PER_BYTE is a power of 2. +#define LOG2_BITS_PER_BYTE 3 + +// Attributes of the unsigned long. These definitions are used mainly in +// the functions that are aware of the internal representation of digits, +// e.g., get/set_packed_rep(). +#define BYTES_PER_DIGIT_TYPE 4 +#define BITS_PER_DIGIT_TYPE 32 + +// Attributes of a digit, i.e., unsigned long less the overflow bits. +#define BYTES_PER_DIGIT 4 +#define BITS_PER_DIGIT 30 +#define DIGIT_RADIX (1ul << BITS_PER_DIGIT) +#define DIGIT_MASK (DIGIT_RADIX - 1) +// Make sure that BYTES_PER_DIGIT = ceil(BITS_PER_DIGIT / BITS_PER_BYTE). + +// Similar attributes for the half of a digit. Note that +// HALF_DIGIT_RADIX is equal to the square root of DIGIT_RADIX. These +// definitions are used mainly in the multiplication routines. +#define BITS_PER_HALF_DIGIT (BITS_PER_DIGIT / 2) +#define HALF_DIGIT_RADIX (1ul << BITS_PER_HALF_DIGIT) +#define HALF_DIGIT_MASK (HALF_DIGIT_RADIX - 1) + +// DIV_CEIL2(x, y) = ceil(x / y). x and y are positive numbers. +#define DIV_CEIL2(x, y) (((x) - 1) / (y) + 1) + +// DIV_CEIL(x) = ceil(x / BITS_PER_DIGIT) = the number of digits to +// store x bits. x is a positive number. +#define DIV_CEIL(x) DIV_CEIL2(x, BITS_PER_DIGIT) + +#ifdef SC_MAX_NBITS +static const int MAX_NDIGITS = DIV_CEIL(SC_MAX_NBITS) + 2; +// Consider a number with x bits another with y bits. The maximum +// number of bits happens when we multiply them. The result will have +// (x + y) bits. Assume that x + y <= SC_MAX_NBITS. Then, DIV_CEIL(x) + +// DIV_CEIL(y) <= DIV_CEIL(SC_MAX_NBITS) + 2. This is the reason for +2 +// above. With this change, MAX_NDIGITS must be enough to hold the +// result of any operation. +#endif + +// Support for "digit" vectors used to hold the values of sc_signed, +// sc_unsigned, sc_bv_base, and sc_lv_base data types. This type is also used +// in the concatenation