Fix VPI parameter iteration (#4798)

This commit is contained in:
Marlon James 2024-01-02 15:57:34 -08:00 committed by GitHub
parent 0195fe9dfd
commit 8ea814e4b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 4 deletions

View File

@ -419,10 +419,19 @@ public:
}
if (m_onlyParams && !m_it->second.isParam()) continue;
if (VL_UNLIKELY(m_topscopep)) {
if (const VerilatedVar* topvarp = m_topscopep->varFind(m_it->second.name()))
return ((new VerilatedVpioVar{topvarp, m_topscopep})->castVpiHandle());
if (const VerilatedVar* topvarp = m_topscopep->varFind(m_it->second.name())) {
if (topvarp->isParam()) {
return ((new VerilatedVpioParam{topvarp, m_topscopep})->castVpiHandle());
} else {
return ((new VerilatedVpioVar{topvarp, m_topscopep})->castVpiHandle());
}
}
}
if (m_it->second.isParam()) {
return ((new VerilatedVpioParam{&(m_it->second), m_scopep})->castVpiHandle());
} else {
return ((new VerilatedVpioVar{&(m_it->second), m_scopep})->castVpiHandle());
}
return ((new VerilatedVpioVar{&(m_it->second), m_scopep})->castVpiHandle());
}
}
};

View File

@ -75,7 +75,9 @@ int count_params(TestVpiHandle& handle, int expectedParams) {
int params = 0;
while (true) {
TestVpiHandle handle = vpi_scan(it);
if (handle == NULL) break;
if (!handle) break;
const int vpi_type = vpi_get(vpiType, handle);
CHECK_RESULT(vpi_type, vpiParameter);
params++;
}
it.freed();