vpi_get_value_array: fix vpiRawTwoStateVal's WDATA return.

WDATA only worked if the bit length was a multiple of 32.

Signed-off-by: Diego Roux <diegoroux04@protonmail.com>
This commit is contained in:
Diego Roux 2024-09-30 14:29:00 -06:00
parent a062ccac6a
commit 74fe41143b
No known key found for this signature in database
GPG Key ID: D7D0B7E32653DAD2

View File

@ -2993,8 +2993,7 @@ void vl_get_value_array(vpiHandle object, p_vpi_arrayvalue arrayvalue_p,
case VLVT_UINT64: case VLVT_UINT64:
ngroups = 8; break; ngroups = 8; break;
case VLVT_WDATA: { case VLVT_WDATA: {
int elemBits = varp->packed().elements(); ngroups = VL_WORDS_I(varp->packed().elements()) * sizeof(WData); break;
ngroups = (elemBits + 7) / 8; break;
} }
default: default:
ngroups = 0; break; ngroups = 0; break;
@ -3036,13 +3035,17 @@ void vl_get_value_array(vpiHandle object, p_vpi_arrayvalue arrayvalue_p,
index = index % size; index = index % size;
} }
} else if (varp->vltype() == VLVT_WDATA) { } else if (varp->vltype() == VLVT_WDATA) {
CData *ptr = reinterpret_cast<CData*>(vop->varDatap()); WData *rawvals = reinterpret_cast<WData*>(value_ptr);
WData *ptr = reinterpret_cast<WData*>(vop->varDatap());
int elemBits = varp->packed().elements(); const int words = VL_WORDS_I(varp->packed().elements());
int ngroups = (elemBits + 7) / 8;
for (int i = 0; i < num; i++) { for (int i = 0; i < num; i++) {
std::memcpy(&value_ptr[i * ngroups], &ptr[index++ * ngroups], ngroups); for (int j = 0; j < words; j++) {
rawvals[i * words + j] = ptr[index * words + j];
}
index = ++index % size;
} }
} }