Add missing vpiModule handle code.
Most named objects should have a vpiModule handle to get a handle to the enclosing module. This patch adds code to get this for all the elements that I could find that needed it. It also adds a three more names to vpi_get_str(vpiType, ...) and fixes a problem in the vpiLeftRange for PV signals.
This commit is contained in:
parent
6f9ddea07f
commit
3e2c828778
|
|
@ -387,6 +387,9 @@ static vpiHandle vpi_array_get_handle(int code, vpiHandle ref)
|
||||||
|
|
||||||
case vpiScope:
|
case vpiScope:
|
||||||
return &obj->scope->base;
|
return &obj->scope->base;
|
||||||
|
|
||||||
|
case vpiModule:
|
||||||
|
return vpip_module(obj->scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -529,6 +532,9 @@ static vpiHandle vpi_array_var_word_get_handle(int code, vpiHandle ref)
|
||||||
|
|
||||||
case vpiScope:
|
case vpiScope:
|
||||||
return &parent->scope->base;
|
return &parent->scope->base;
|
||||||
|
|
||||||
|
case vpiModule:
|
||||||
|
return vpip_module(parent->scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -720,6 +726,9 @@ static vpiHandle vpi_array_vthr_A_get_handle(int code, vpiHandle ref)
|
||||||
|
|
||||||
case vpiScope:
|
case vpiScope:
|
||||||
return &parent->scope->base;
|
return &parent->scope->base;
|
||||||
|
|
||||||
|
case vpiModule:
|
||||||
|
return vpip_module(parent->scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -291,6 +291,9 @@ static vpiHandle string_param_handle(int code, vpiHandle obj)
|
||||||
case vpiScope:
|
case vpiScope:
|
||||||
return &rfp->scope->base;
|
return &rfp->scope->base;
|
||||||
|
|
||||||
|
case vpiModule:
|
||||||
|
return vpip_module(rfp->scope);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -492,6 +495,9 @@ static vpiHandle binary_param_handle(int code, vpiHandle obj)
|
||||||
case vpiScope:
|
case vpiScope:
|
||||||
return &rfp->scope->base;
|
return &rfp->scope->base;
|
||||||
|
|
||||||
|
case vpiModule:
|
||||||
|
return vpip_module(rfp->scope);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -745,6 +751,9 @@ static vpiHandle real_param_handle(int code, vpiHandle obj)
|
||||||
case vpiScope:
|
case vpiScope:
|
||||||
return &rfp->scope->base;
|
return &rfp->scope->base;
|
||||||
|
|
||||||
|
case vpiModule:
|
||||||
|
return vpip_module(rfp->scope);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2002-2007 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2002-2009 Stephen Williams (steve@icarus.com)
|
||||||
*
|
*
|
||||||
* This source code is free software; you can redistribute it
|
* This source code is free software; you can redistribute it
|
||||||
* and/or modify it in source code form under the terms of the GNU
|
* and/or modify it in source code form under the terms of the GNU
|
||||||
|
|
@ -61,9 +61,11 @@ static vpiHandle named_event_get_handle(int code, vpiHandle ref)
|
||||||
struct __vpiNamedEvent*obj = (struct __vpiNamedEvent*)ref;
|
struct __vpiNamedEvent*obj = (struct __vpiNamedEvent*)ref;
|
||||||
|
|
||||||
switch (code) {
|
switch (code) {
|
||||||
|
|
||||||
case vpiScope:
|
case vpiScope:
|
||||||
return &obj->scope->base;
|
return &obj->scope->base;
|
||||||
|
|
||||||
|
case vpiModule:
|
||||||
|
return vpip_module(obj->scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,15 @@ struct __vpiScope* vpip_scope(__vpiRealVar*sig)
|
||||||
return sig->within.scope;
|
return sig->within.scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vpiHandle vpip_module(struct __vpiScope*scope)
|
||||||
|
{
|
||||||
|
while(scope && scope->base.vpi_type->type_code != vpiModule) {
|
||||||
|
scope = scope->scope;
|
||||||
|
}
|
||||||
|
assert(scope);
|
||||||
|
return &scope->base;
|
||||||
|
}
|
||||||
|
|
||||||
const char *vpip_string(const char*str)
|
const char *vpip_string(const char*str)
|
||||||
{
|
{
|
||||||
static vpip_string_chunk first_chunk = {0, {0}};
|
static vpip_string_chunk first_chunk = {0, {0}};
|
||||||
|
|
@ -218,6 +227,12 @@ static const char* vpi_type_values(PLI_INT32 code)
|
||||||
return "vpiMemoryWord";
|
return "vpiMemoryWord";
|
||||||
case vpiModule:
|
case vpiModule:
|
||||||
return "vpiModule";
|
return "vpiModule";
|
||||||
|
case vpiNamedBegin:
|
||||||
|
return "vpiNamedBegin";
|
||||||
|
case vpiNamedEvent:
|
||||||
|
return "vpiNamedEvent";
|
||||||
|
case vpiNamedFork:
|
||||||
|
return "vpiNamedFork";
|
||||||
case vpiNet:
|
case vpiNet:
|
||||||
return "vpiNet";
|
return "vpiNet";
|
||||||
case vpiParameter:
|
case vpiParameter:
|
||||||
|
|
|
||||||
|
|
@ -595,4 +595,7 @@ extern char *need_result_buf(unsigned cnt, vpi_rbuf_t type);
|
||||||
extern char *simple_set_rbuf_str(const char *s1);
|
extern char *simple_set_rbuf_str(const char *s1);
|
||||||
extern char *generic_get_str(int code, vpiHandle ref, const char *name, const char *index);
|
extern char *generic_get_str(int code, vpiHandle ref, const char *name, const char *index);
|
||||||
|
|
||||||
|
/* A routine to find the enclosing module. */
|
||||||
|
extern vpiHandle vpip_module(struct __vpiScope*scope);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2003-2008 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2003-2009 Stephen Williams (steve@icarus.com)
|
||||||
*
|
*
|
||||||
* This source code is free software; you can redistribute it
|
* This source code is free software; you can redistribute it
|
||||||
* and/or modify it in source code form under the terms of the GNU
|
* and/or modify it in source code form under the terms of the GNU
|
||||||
|
|
@ -103,6 +103,9 @@ static vpiHandle real_var_get_handle(int code, vpiHandle ref)
|
||||||
|
|
||||||
case vpiScope:
|
case vpiScope:
|
||||||
return &(vpip_scope(rfp)->base);
|
return &(vpip_scope(rfp)->base);
|
||||||
|
|
||||||
|
case vpiModule:
|
||||||
|
return vpip_module(vpip_scope(rfp));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -596,13 +596,7 @@ static vpiHandle signal_get_handle(int code, vpiHandle ref)
|
||||||
return &(vpip_scope(rfp)->base);
|
return &(vpip_scope(rfp)->base);
|
||||||
|
|
||||||
case vpiModule:
|
case vpiModule:
|
||||||
{ struct __vpiScope*scope = vpip_scope(rfp);
|
return vpip_module(vpip_scope(rfp));
|
||||||
while (scope && scope->base.vpi_type->type_code != vpiModule)
|
|
||||||
scope = scope->scope;
|
|
||||||
|
|
||||||
assert(scope);
|
|
||||||
return &scope->base;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -977,7 +971,7 @@ static int PV_get(int code, vpiHandle ref)
|
||||||
return rfp->sbase == 0 && rfp->twid == 0;
|
return rfp->sbase == 0 && rfp->twid == 0;
|
||||||
|
|
||||||
case vpiLeftRange:
|
case vpiLeftRange:
|
||||||
rval += rfp->width;
|
rval += rfp->width - 1;
|
||||||
case vpiRightRange:
|
case vpiRightRange:
|
||||||
rval += vpi_get(vpiRightRange, rfp->parent) + PV_get_base(rfp);
|
rval += vpi_get(vpiRightRange, rfp->parent) + PV_get_base(rfp);
|
||||||
return rval;
|
return rval;
|
||||||
|
|
@ -1129,10 +1123,11 @@ static vpiHandle PV_get_handle(int code, vpiHandle ref)
|
||||||
struct __vpiPV*rfp = (struct __vpiPV*)ref;
|
struct __vpiPV*rfp = (struct __vpiPV*)ref;
|
||||||
|
|
||||||
switch (code) {
|
switch (code) {
|
||||||
|
|
||||||
case vpiParent:
|
case vpiParent:
|
||||||
return rfp->parent;
|
return rfp->parent;
|
||||||
break;
|
|
||||||
|
case vpiModule:
|
||||||
|
return vpi_handle(vpiModule, rfp->parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2008 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2001-2009 Stephen Williams (steve@icarus.com)
|
||||||
*
|
*
|
||||||
* This source code is free software; you can redistribute it
|
* This source code is free software; you can redistribute it
|
||||||
* and/or modify it in source code form under the terms of the GNU
|
* and/or modify it in source code form under the terms of the GNU
|
||||||
|
|
@ -62,6 +62,7 @@ static vpiHandle systask_handle(int type, vpiHandle ref)
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case vpiScope:
|
case vpiScope:
|
||||||
return &rfp->scope->base;
|
return &rfp->scope->base;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
@ -75,8 +76,13 @@ static int systask_get(int type, vpiHandle ref)
|
||||||
|| (ref->vpi_type->type_code == vpiSysFuncCall));
|
|| (ref->vpi_type->type_code == vpiSysFuncCall));
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
/* This is not the correct way to get this information, but
|
||||||
|
* some of the code that implements the acc and tf routines
|
||||||
|
* use this method so we will keep it in for now. */
|
||||||
case vpiTimeUnit:
|
case vpiTimeUnit:
|
||||||
return rfp->scope->time_units;
|
return rfp->scope->time_units;
|
||||||
|
case vpiTimePrecision:
|
||||||
|
return rfp->scope->time_precision;
|
||||||
|
|
||||||
case vpiLineNo:
|
case vpiLineNo:
|
||||||
return rfp->lineno;
|
return rfp->lineno;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue