Minor improvements to DPI open array handling (#2316)

- Allow arbitrary number of open array dimensions, not just 3. Note
right now this only works with the array querying functions specified
in IEEE 1800-2017 H.12.2
- Issue error when passing dynamic array or queue as DPI open array
(currently unsupported)
- Also tweaked AstVar::vlArgTypeRecurse, which should now error or fail
for unsupported types.
This commit is contained in:
Geza Lore
2020-05-08 18:22:44 +01:00
committed by GitHub
parent 27953e26b6
commit ac09ad3ffd
8 changed files with 560 additions and 181 deletions
+3 -3
View File
@@ -2445,12 +2445,12 @@ vluint32_t VerilatedVarProps::entSize() const {
size_t VerilatedVarProps::totalSize() const {
size_t size = entSize();
for (int dim = 0; dim <= dims(); ++dim) size *= m_unpacked[dim].elements();
for (int udim = 0; udim <= udims(); ++udim) size *= m_unpacked[udim].elements();
return size;
}
void* VerilatedVarProps::datapAdjustIndex(void* datap, int dim, int indx) const {
if (VL_UNLIKELY(dim <= 0 || dim > m_udims || dim > 3)) return NULL;
if (VL_UNLIKELY(dim <= 0 || dim > udims())) return NULL;
if (VL_UNLIKELY(indx < low(dim) || indx > high(dim))) return NULL;
int indxAdj = indx - low(dim);
vluint8_t* bytep = reinterpret_cast<vluint8_t*>(datap);
@@ -2539,7 +2539,7 @@ void VerilatedScope::varInsert(int finalize, const char* namep, void* datap,
if (i == 0) {
var.m_packed.m_left = msb;
var.m_packed.m_right = lsb;
} else if (i >= 1 && i <= 3) {
} else if (i >= 1 && i <= var.udims()) {
var.m_unpacked[i - 1].m_left = msb;
var.m_unpacked[i - 1].m_right = lsb;
} else {