Clean up some VPI issues.
This patch makes sure that objects either support vpiFile and vpiLineNo or adds dummy code so that a runtime error will not occur when accessing these properties. It also returns 1 for the size of real variables and adds a simplified vpiIndex that matches the Memory interface.
This commit is contained in:
parent
b99206ac8e
commit
c0d3bb370f
|
|
@ -130,6 +130,9 @@ static int vpi_array_get(int code, vpiHandle ref)
|
|||
struct __vpiArray*obj = ARRAY_HANDLE(ref);
|
||||
|
||||
switch (code) {
|
||||
case vpiLineNo:
|
||||
return 0; // Not implemented for now!
|
||||
|
||||
case vpiSize:
|
||||
return (int) obj->array_count;
|
||||
|
||||
|
|
@ -142,6 +145,10 @@ static char*vpi_array_get_str(int code, vpiHandle ref)
|
|||
{
|
||||
struct __vpiArray*obj = ARRAY_HANDLE(ref);
|
||||
|
||||
if (code == vpiFile) { // Not implemented for now!
|
||||
return simple_set_rbuf_str(file_names[0]);
|
||||
}
|
||||
|
||||
return generic_get_str(code, &obj->scope->base, obj->name, NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003-2007 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2003-2008 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
|
|
@ -34,8 +34,15 @@ static int real_var_get(int code, vpiHandle ref)
|
|||
|
||||
struct __vpiRealVar*rfp = (struct __vpiRealVar*)ref;
|
||||
|
||||
if (code == vpiArray) {
|
||||
switch (code) {
|
||||
case vpiArray:
|
||||
return rfp->parent != 0;
|
||||
|
||||
case vpiSize:
|
||||
return 1;
|
||||
|
||||
case vpiLineNo:
|
||||
return 0; // Not implemented for now!
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -186,4 +193,3 @@ vpiHandle vpip_make_real_var(const char*name, vvp_net_t*net)
|
|||
|
||||
return &obj->base;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -136,6 +136,15 @@ static int signal_get(int code, vpiHandle ref)
|
|||
case vpiArray:
|
||||
return rfp->parent != 0;
|
||||
|
||||
case vpiIndex: // This only works while we have a single index.
|
||||
if (rfp->parent) {
|
||||
s_vpi_value vp;
|
||||
vp.format = vpiIntVal;
|
||||
vpi_get_value(rfp->id.index, &vp);
|
||||
return vp.value.integer;
|
||||
} else
|
||||
return 0;
|
||||
|
||||
case vpiSize:
|
||||
if (rfp->msb >= rfp->lsb)
|
||||
return rfp->msb - rfp->lsb + 1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue