mirror of
https://github.com/verilator/verilator.git
synced 2026-09-07 18:06:07 +02:00
Fix vpi_get() and vpi_get64() to return vpiUndefined on errors (#4795)
See IEEE 1800-2017 section 38.6 and 38.7.
This commit is contained in:
@@ -1991,41 +1991,41 @@ PLI_INT32 vpi_get(PLI_INT32 property, vpiHandle object) {
|
||||
}
|
||||
case vpiType: {
|
||||
const VerilatedVpio* const vop = VerilatedVpio::castp(object);
|
||||
if (VL_UNLIKELY(!vop)) return 0;
|
||||
if (VL_UNLIKELY(!vop)) return vpiUndefined;
|
||||
return vop->type();
|
||||
}
|
||||
case vpiConstType: {
|
||||
const VerilatedVpio* const vop = VerilatedVpio::castp(object);
|
||||
if (VL_UNLIKELY(!vop)) return 0;
|
||||
if (VL_UNLIKELY(!vop)) return vpiUndefined;
|
||||
return vop->constType();
|
||||
}
|
||||
case vpiDirection: {
|
||||
// By forethought, the directions already are vpi enumerated
|
||||
const VerilatedVpioVarBase* const vop = VerilatedVpioVarBase::castp(object);
|
||||
if (VL_UNLIKELY(!vop)) return 0;
|
||||
if (VL_UNLIKELY(!vop)) return vpiUndefined;
|
||||
return vop->varp()->vldir();
|
||||
}
|
||||
case vpiScalar: // FALLTHRU
|
||||
case vpiVector: {
|
||||
const VerilatedVpioVarBase* const vop = VerilatedVpioVarBase::castp(object);
|
||||
if (VL_UNLIKELY(!vop)) return 0;
|
||||
if (VL_UNLIKELY(!vop)) return vpiUndefined;
|
||||
return (property == vpiVector) ^ (vop->varp()->dims() == 0);
|
||||
}
|
||||
case vpiSize: {
|
||||
const VerilatedVpioVarBase* const vop = VerilatedVpioVarBase::castp(object);
|
||||
if (VL_UNLIKELY(!vop)) return 0;
|
||||
if (VL_UNLIKELY(!vop)) return vpiUndefined;
|
||||
return vop->size();
|
||||
}
|
||||
default:
|
||||
VL_VPI_WARNING_(__FILE__, __LINE__, "%s: Unsupported type %s, nothing will be returned",
|
||||
__func__, VerilatedVpiError::strFromVpiProp(property));
|
||||
return 0;
|
||||
VL_VPI_ERROR_(__FILE__, __LINE__, "%s: Unsupported property %s, nothing will be returned",
|
||||
__func__, VerilatedVpiError::strFromVpiProp(property));
|
||||
return vpiUndefined;
|
||||
}
|
||||
}
|
||||
|
||||
PLI_INT64 vpi_get64(PLI_INT32 /*property*/, vpiHandle /*object*/) {
|
||||
VL_VPI_UNIMP_();
|
||||
return 0;
|
||||
return vpiUndefined;
|
||||
}
|
||||
|
||||
PLI_BYTE8* vpi_get_str(PLI_INT32 property, vpiHandle object) {
|
||||
|
||||
Reference in New Issue
Block a user