From 95e25ad40f80f6f008cfb6a648b579d4dde3c3cb Mon Sep 17 00:00:00 2001 From: Cary R Date: Mon, 5 Dec 2011 19:52:49 -0800 Subject: [PATCH] Apply a slightly modified user patch. --- vvp/vpi_priv.cc | 10 +++++++--- vvp/vpi_scope.cc | 11 +++++------ vvp/vpi_signal.cc | 15 +++++++++------ 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/vvp/vpi_priv.cc b/vvp/vpi_priv.cc index 7a626f192..f1c2ab814 100644 --- a/vvp/vpi_priv.cc +++ b/vvp/vpi_priv.cc @@ -1016,7 +1016,11 @@ vpiHandle vpi_put_value(vpiHandle obj, s_vpi_value*vp, vpiHandle vpi_handle(PLI_INT32 type, vpiHandle ref) { if (type == vpiSysTfCall) { - assert(ref == 0); + if (ref != 0) { + fprintf(stderr, "VPI error: vpi_handle(vpiSysTfCall, " + "ref!=0).\n"); + return 0; + } if (vpi_trace) { fprintf(vpi_trace, "vpi_handle(vpiSysTfCall, 0) " @@ -1028,10 +1032,10 @@ vpiHandle vpi_handle(PLI_INT32 type, vpiHandle ref) } if (ref == 0) { - fprintf(stderr, "internal error: vpi_handle(type=%d, ref=0)\n", + fprintf(stderr, "VPI error: vpi_handle(type=%d, ref=0).\n", (int)type); + return 0; } - assert(ref); if (ref->vpi_type->handle_ == 0) { diff --git a/vvp/vpi_scope.cc b/vvp/vpi_scope.cc index 5d9d95b9e..33bb34ace 100644 --- a/vvp/vpi_scope.cc +++ b/vvp/vpi_scope.cc @@ -155,7 +155,7 @@ static int scope_get(int code, vpiHandle obj) return (int) ref->is_automatic; } - return 0; + return vpiUndefined; } static void construct_scope_fullname(struct __vpiScope*ref, char*buf) @@ -182,8 +182,8 @@ static const char* scope_get_type(int code) case vpiNamedFork: return "vpiNamedFork"; default: - fprintf(stderr, "ERROR: invalid code %d.", code); - assert(0); + fprintf(stderr, "VPI error: invalid scope type code %d.\n", code); + return NULL; } } @@ -223,9 +223,8 @@ static char* scope_get_str(int code, vpiHandle obj) break; default: - fprintf(stderr, "ERROR: invalid code %d.", code); - assert(0); - return 0; + fprintf(stderr, "VPI error: invalid scope string code %d.\n", code); + return NULL; } return simple_set_rbuf_str(p); } diff --git a/vvp/vpi_signal.cc b/vvp/vpi_signal.cc index 08df4e1ce..4add39a1a 100644 --- a/vvp/vpi_signal.cc +++ b/vvp/vpi_signal.cc @@ -549,7 +549,7 @@ static int signal_get(int code, vpiHandle ref) vpi_get_value(rfp->id.index, &vp); return vp.value.integer; } else { - return 0; + return vpiUndefined; } case vpiSize: @@ -562,7 +562,7 @@ static int signal_get(int code, vpiHandle ref) if (ref->vpi_type->type_code==vpiNet) return vpiWire; else - return 0; + return vpiUndefined; case vpiLeftRange: return rfp->msb; @@ -577,11 +577,12 @@ static int signal_get(int code, vpiHandle ref) if (rfp->msb == rfp->lsb) return (int) (unsigned long) rfp->node; else - return 0; + return vpiUndefined; default: - fprintf(stderr, "signal_get: property %d is unknown\n", code); - return 0; + fprintf(stderr, "VPI error: unknow signal_get property %d.\n", + code); + return vpiUndefined; } } @@ -594,13 +595,15 @@ static char* signal_get_str(int code, vpiHandle ref) return simple_set_rbuf_str(file_names[0]); } + if (code != vpiName) return NULL; + char *nm, *ixs; if (rfp->is_netarray) { nm = strdup(vpi_get_str(vpiName, rfp->within.parent)); s_vpi_value vp; vp.format = vpiDecStrVal; vpi_get_value(rfp->id.index, &vp); - ixs = vp.value.str; /* do I need to strdup() this? */ + ixs = vp.value.str; /* do I need to strdup() this? */ } else { nm = strdup(rfp->id.name); ixs = NULL;