Fix &A<> to support an undefined word index.

This patch adds support to &A<> for an undefined word index.
It mostly matches what was done for &PV<>.
(cherry picked from commit 4b50473939)
This commit is contained in:
Cary R 2009-09-07 18:11:52 -07:00 committed by Stephen Williams
parent 6bbf97a05d
commit 3dfc1d5097
1 changed files with 11 additions and 1 deletions

View File

@ -30,6 +30,7 @@
#endif
# include <stdlib.h>
# include <string.h>
# include <limits.h>
# include <iostream>
# include "compile.h"
# include <assert.h>
@ -132,6 +133,15 @@ struct __vpiArrayVthrA {
{
if (address_handle) {
s_vpi_value vp;
/* Check to see if the value is defined. */
vp.format = vpiVectorVal;
vpi_get_value(address_handle, &vp);
int words = (vpi_get(vpiSize, address_handle)-1)/32 + 1;
for(int idx = 0; idx < words; idx += 1) {
/* Return UINT_MAX to indicate an X base. */
if (vp.value.vector[idx].bval != 0) return UINT_MAX;
}
/* The value is defined so get and return it. */
vp.format = vpiIntVal;
vpi_get_value(address_handle, &vp);
return vp.value.integer;
@ -145,7 +155,7 @@ struct __vpiArrayVthrA {
vvp_bit4_t bit = vthread_get_bit(vpip_current_vthread, address+idx);
tmp.set_bit(idx, bit);
}
unsigned long val;
unsigned long val = ULONG_MAX;
vector4_to_value(tmp, val);
return val;
}