Add support for 'bx from a signal to &PV<>

&PV<> was just using vpi_get_value() when a signal was driving
the select. This incorrectly returned 0 for 'bx or 'bz. This
patch adds a check for an undefined value and returns INT_MIN
for this case.
This commit is contained in:
Cary R 2009-09-07 16:41:27 -07:00 committed by Stephen Williams
parent dff6a1ebff
commit 1b0dd8c8e5
1 changed files with 9 additions and 0 deletions

View File

@ -989,6 +989,15 @@ static int PV_get_base(struct __vpiPV*rfp)
/* We return from the symbol base if it is defined. */
if (rfp->sbase != 0) {
s_vpi_value val;
/* Check to see if the value is defined. */
val.format = vpiVectorVal;
vpi_get_value(rfp->sbase, &val);
int words = (vpi_get(vpiSize, rfp->sbase)-1)/32 + 1;
for(int idx = 0; idx < words; idx += 1) {
/* Return INT_MIN to indicate an X base. */
if (val.value.vector[idx].bval != 0) return INT_MIN;
}
/* The value is defined so get and return it. */
val.format = vpiIntVal;
vpi_get_value(rfp->sbase, &val);
return val.value.integer;