77 const int BYTE_COUNT =
80 #if HOST_BIGENDIAN == 1
83 memcpy(
rawData_, &value, BYTE_COUNT);
123 if (
static_cast<size_t>(BYTE_COUNT) >
sizeof(
DoubleWord)) {
140 const size_t BYTE_COUNT =
sizeof(
SIntWord);
142 #if HOST_BIGENDIAN == 1
145 memcpy(
rawData_, &source, BYTE_COUNT);
159 const size_t BYTE_COUNT =
sizeof(
UIntWord);
161 #if HOST_BIGENDIAN == 1
164 memcpy(
rawData_, &source, BYTE_COUNT);
178 const size_t BYTE_COUNT =
sizeof(
SLongWord);
180 #if HOST_BIGENDIAN == 1
183 memcpy(
rawData_, &source, BYTE_COUNT);
197 const size_t BYTE_COUNT =
sizeof(
ULongWord);
199 #if HOST_BIGENDIAN == 1
202 memcpy(
rawData_, &source, BYTE_COUNT);
217 const size_t BYTE_COUNT =
sizeof(uint16_t);
222 #if HOST_BIGENDIAN == 1
225 memcpy(
rawData_, &data, BYTE_COUNT);
239 const size_t BYTE_COUNT =
sizeof(
FloatWord);
243 #if HOST_BIGENDIAN == 1
246 memcpy(
rawData_, &source, BYTE_COUNT);
264 #if HOST_BIGENDIAN == 1
267 memcpy(
rawData_, &source, BYTE_COUNT);
284 const size_t DST_BYTE_COUNT =
286 const size_t SRC_BYTE_COUNT =
290 if (SRC_BYTE_COUNT < DST_BYTE_COUNT) {
291 memset(
rawData_+SRC_BYTE_COUNT, 0, DST_BYTE_COUNT-SRC_BYTE_COUNT);
294 const Byte msbBitMask =
static_cast<Byte>((1 << bitsInMSB) - 1);
295 rawData_[DST_BYTE_COUNT-1] &= msbBitMask;
309 const size_t BYTE_COUNT =
897 const size_t BYTE_COUNT =
sizeof(int);
900 Byte bytes[BYTE_COUNT];
906 #if HOST_BIGENDIAN == 1
909 memcpy(cast.bytes,
rawData_, BYTE_COUNT);
921 const size_t BYTE_COUNT =
sizeof(
unsigned int);
924 Byte bytes[BYTE_COUNT];
930 #if HOST_BIGENDIAN == 1
933 memcpy(cast.bytes,
rawData_, BYTE_COUNT);
946 const size_t BYTE_COUNT =
sizeof(
SIntWord);
949 Byte bytes[BYTE_COUNT];
955 #if HOST_BIGENDIAN == 1
958 memcpy(cast.bytes,
rawData_, BYTE_COUNT);
974 const size_t BYTE_COUNT =
sizeof(
UIntWord);
977 Byte bytes[BYTE_COUNT];
983 #if HOST_BIGENDIAN == 1
986 memcpy(cast.bytes,
rawData_, BYTE_COUNT);
988 return cast.value &
mask_;
999 const size_t BYTE_COUNT =
sizeof(
SLongWord);
1002 Byte bytes[BYTE_COUNT];
1008 #if HOST_BIGENDIAN == 1
1011 memcpy(cast.bytes,
rawData_, BYTE_COUNT);
1029 const size_t BYTE_COUNT =
sizeof(
ULongWord);
1032 Byte bytes[BYTE_COUNT];
1038 #if HOST_BIGENDIAN == 1
1041 memcpy(cast.bytes,
rawData_, BYTE_COUNT);
1043 return cast.value &
mask_;
1054 const size_t BYTE_COUNT =
sizeof(
DoubleWord);
1057 Byte bytes[BYTE_COUNT];
1063 #if HOST_BIGENDIAN == 1
1066 memcpy(cast.bytes,
rawData_, BYTE_COUNT);
1077 const size_t BYTE_COUNT =
sizeof(
FloatWord);
1080 Byte bytes[BYTE_COUNT];
1086 #if HOST_BIGENDIAN == 1
1089 memcpy(cast.bytes,
rawData_, BYTE_COUNT);
1100 const size_t BYTE_COUNT =
sizeof(uint16_t);
1103 Byte bytes[BYTE_COUNT];
1109 #if HOST_BIGENDIAN == 1
1112 memcpy(cast.bytes,
rawData_, BYTE_COUNT);
1128 if (remainBits > 0) {
1130 static_cast<unsigned int>(
rawData_[BYTE_COUNT]),
1134 for (
int i = BYTE_COUNT - 1; i >= 0; --i) {
1136 static_cast<unsigned int>(
rawData_[i]), 8);
1151 size_t hexNumbers = (
bitWidth_ + 3) / 4;
1153 if (noHexIdentifier) {
1162 const size_t BYTE_COUNT =
1164 const unsigned MSB_MASK = ~(0xfffffffffffffffful << (8-(BYTE_COUNT*8-
bitWidth_)));
1169 for (
int i = BYTE_COUNT - 1; i >= 0; --i) {
1170 unsigned int value =
static_cast<unsigned int>(
rawData_[i]);
1171 if (i ==
static_cast<int>(BYTE_COUNT - 1)) {
1178 hexStr = hexStr.substr(hexStr.size() - hexNumbers);
1180 if (!noHexIdentifier) hexStr.insert(0,
"0x");
1185 template <
typename T>
1188 const size_t BYTE_COUNT =
sizeof(T);
1189 const size_t OFFSET = elementIndex * BYTE_COUNT;
1195 Byte bytes[
sizeof(T)];
1201 #if HOST_BIGENDIAN == 1
1204 memcpy(cast.bytes,
rawData_ + OFFSET, BYTE_COUNT);
1220 return vectorElement<Word>(elementIndex);
1250 return vectorElement<HalfWord>(elementIndex);
1257 return HalfFloatWord(vectorElement<HalfWord>(elementIndex));
1262 return vectorElement<FloatWord>(elementIndex);
1267 return vectorElement<DoubleWord>(elementIndex);
1275 const size_t BYTE_COUNT =
sizeof(
Byte);
1276 const size_t OFFSET = elementIndex * BYTE_COUNT;
1297 if (data & (1 << LEFT_SHIFTS)) {
1314 assert(elementWidth != 0);
1315 assert(elementWidth <= 32);
1317 if (elementWidth == 1) {
1320 const size_t BYTE_COUNT = elementWidth >= 8u ?
1322 const size_t OFFSET = elementIndex * BYTE_COUNT;
1323 const Word BITMASK =
1324 elementWidth < 32 ? ~(~Word(0) << elementWidth) : ~(Word(0));
1327 #if HOST_BIGENDIAN == 1
1330 memcpy(&tmp,
rawData_ + OFFSET, BYTE_COUNT);
1337 template <
typename T>
1340 const size_t BYTE_COUNT =
sizeof(T);
1341 const size_t OFFSET = elementIndex * BYTE_COUNT;
1346 #if HOST_BIGENDIAN == 1
1349 memcpy(
rawData_ + OFFSET, &data, BYTE_COUNT);
1407 byte =
byte & (~(1 << LEFT_SHIFTS));
1409 byte =
byte | (1 << LEFT_SHIFTS);
1423 assert(elementWidth != 0);
1424 if (elementWidth == 1) {
1427 const size_t BYTE_COUNT =
1428 elementWidth >= 8u ?
1430 const size_t OFFSET = elementIndex * BYTE_COUNT;
1435 Word BITMASK = ~Word(0);
1436 if (elementWidth <
sizeof(Word)*8) {
1437 BITMASK = ~(~Word(0) << elementWidth);
1440 Word tmp_data = data & BITMASK;
1441 #if HOST_BIGENDIAN == 1
1444 memcpy(
rawData_ + OFFSET, &tmp_data, BYTE_COUNT);
1465 const size_t VALUE_BITWIDTH =
hexValue.size() * 4;
1471 size_t paddingBytes = 0;
1475 __FILE__, __LINE__,
__func__,
"Too wide value.");
1476 }
else if (VALUE_BITWIDTH == 0) {
1478 __FILE__, __LINE__,
__func__,
"Input value is empty.");
1479 }
else if (VALUE_BITWIDTH > (
size_t)
bitWidth_) {
1482 paddingBytes = (VALUE_BITWIDTH -
bitWidth_) / 8;
1483 for (
size_t i = 0; i < paddingBytes; ++i)
1484 rawData_[VALUE_BITWIDTH / 8 + i] = 0;
1492 int byteWidth = VALUE_BITWIDTH / 8;
1493 if (VALUE_BITWIDTH % 8 != 0) ++byteWidth;
1536 if (bitWidth <= 0) {
1545 static_cast<int>(
rawData_[FIRST_BYTE-1]),
1548 if (BYTE_COUNT > FIRST_BYTE) {
1550 memset(
rawData_+FIRST_BYTE, 0, BYTE_COUNT-FIRST_BYTE);
1552 memset(
rawData_+FIRST_BYTE, -1, BYTE_COUNT-FIRST_BYTE);
1572 if (bitWidth <= 0) {
1581 static_cast<int>(
rawData_[FIRST_BYTE-1]),
1584 if (BYTE_COUNT > FIRST_BYTE) {
1585 memset(
rawData_+FIRST_BYTE, 0, BYTE_COUNT-FIRST_BYTE);
1598 result +=
" data=0x";
1603 unsigned int value =
1604 static_cast<unsigned int>(
rawData_[i]);
1622 const Byte* from,
size_t byteCount,
Byte* to)
const {
1625 for (
size_t i = 0; i < byteCount; ++i) {
1626 to[byteCount - 1 - i] = from[i];