From 3dfc1d50973ff3ca785201050ced0264ee50d067 Mon Sep 17 00:00:00 2001 From: Cary R Date: Mon, 7 Sep 2009 18:11:52 -0700 Subject: [PATCH] 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 4b5047393974ef745792cb25739c1dc14b330175) --- vvp/array.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/vvp/array.cc b/vvp/array.cc index ec99cd09b..577b8cec5 100644 --- a/vvp/array.cc +++ b/vvp/array.cc @@ -30,6 +30,7 @@ #endif # include # include +# include # include # include "compile.h" # include @@ -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; }