Implementation of vpi_handle_by_name, and
add the vpiVariables iterator.
This commit is contained in:
parent
68da84e84a
commit
9e1570dc80
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT) && !defined(macintosh)
|
#if !defined(WINNT) && !defined(macintosh)
|
||||||
#ident "$Id: sys_lxt.c,v 1.8 2002/07/15 03:57:30 steve Exp $"
|
#ident "$Id: sys_lxt.c,v 1.9 2002/07/17 05:13:43 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -548,7 +548,7 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
|
||||||
/* Value */
|
/* Value */
|
||||||
vpiNet,
|
vpiNet,
|
||||||
vpiReg,
|
vpiReg,
|
||||||
vpiIntegerVar,
|
vpiVariables,
|
||||||
/* Scope */
|
/* Scope */
|
||||||
vpiFunction,
|
vpiFunction,
|
||||||
vpiModule,
|
vpiModule,
|
||||||
|
|
@ -570,6 +570,7 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
|
||||||
|
|
||||||
case vpiNet: type = "wire"; if(0){
|
case vpiNet: type = "wire"; if(0){
|
||||||
case vpiIntegerVar:
|
case vpiIntegerVar:
|
||||||
|
case vpiTimeVar:
|
||||||
case vpiReg: type = "reg"; }
|
case vpiReg: type = "reg"; }
|
||||||
|
|
||||||
if (skip)
|
if (skip)
|
||||||
|
|
@ -812,6 +813,10 @@ void sys_lxt_register()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: sys_lxt.c,v $
|
* $Log: sys_lxt.c,v $
|
||||||
|
* Revision 1.9 2002/07/17 05:13:43 steve
|
||||||
|
* Implementation of vpi_handle_by_name, and
|
||||||
|
* add the vpiVariables iterator.
|
||||||
|
*
|
||||||
* Revision 1.8 2002/07/15 03:57:30 steve
|
* Revision 1.8 2002/07/15 03:57:30 steve
|
||||||
* Fix dangling pointer in pop_scope.
|
* Fix dangling pointer in pop_scope.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT) && !defined(macintosh)
|
#if !defined(WINNT) && !defined(macintosh)
|
||||||
#ident "$Id: sys_vcd.c,v 1.34 2002/07/12 17:09:21 steve Exp $"
|
#ident "$Id: sys_vcd.c,v 1.35 2002/07/17 05:13:43 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -537,7 +537,7 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
|
||||||
/* Value */
|
/* Value */
|
||||||
vpiNet,
|
vpiNet,
|
||||||
vpiReg,
|
vpiReg,
|
||||||
vpiIntegerVar,
|
vpiVariables,
|
||||||
/* Scope */
|
/* Scope */
|
||||||
vpiFunction,
|
vpiFunction,
|
||||||
vpiModule,
|
vpiModule,
|
||||||
|
|
@ -559,6 +559,7 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
|
||||||
|
|
||||||
case vpiNet: type = "wire"; if(0){
|
case vpiNet: type = "wire"; if(0){
|
||||||
case vpiIntegerVar:
|
case vpiIntegerVar:
|
||||||
|
case vpiTimeVar:
|
||||||
case vpiReg: type = "reg"; }
|
case vpiReg: type = "reg"; }
|
||||||
|
|
||||||
if (skip)
|
if (skip)
|
||||||
|
|
@ -800,6 +801,10 @@ void sys_vcd_register()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: sys_vcd.c,v $
|
* $Log: sys_vcd.c,v $
|
||||||
|
* Revision 1.35 2002/07/17 05:13:43 steve
|
||||||
|
* Implementation of vpi_handle_by_name, and
|
||||||
|
* add the vpiVariables iterator.
|
||||||
|
*
|
||||||
* Revision 1.34 2002/07/12 17:09:21 steve
|
* Revision 1.34 2002/07/12 17:09:21 steve
|
||||||
* Remember to scan IntegerVars.
|
* Remember to scan IntegerVars.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT) && !defined(macintosh)
|
#if !defined(WINNT) && !defined(macintosh)
|
||||||
#ident "$Id: vpi_user.h,v 1.12 2002/06/21 04:59:35 steve Exp $"
|
#ident "$Id: vpi_user.h,v 1.13 2002/07/17 05:13:43 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -173,6 +173,7 @@ typedef struct t_vpi_value {
|
||||||
#define vpiSysTfCall 85
|
#define vpiSysTfCall 85
|
||||||
#define vpiArgument 89
|
#define vpiArgument 89
|
||||||
#define vpiInternalScope 92
|
#define vpiInternalScope 92
|
||||||
|
#define vpiVariables 100
|
||||||
|
|
||||||
#define vpiCallback 1000
|
#define vpiCallback 1000
|
||||||
|
|
||||||
|
|
@ -287,6 +288,7 @@ extern vpiHandle vpi_handle(int type, vpiHandle ref);
|
||||||
extern vpiHandle vpi_iterate(int type, vpiHandle ref);
|
extern vpiHandle vpi_iterate(int type, vpiHandle ref);
|
||||||
extern vpiHandle vpi_scan(vpiHandle iter);
|
extern vpiHandle vpi_scan(vpiHandle iter);
|
||||||
extern vpiHandle vpi_handle_by_index(vpiHandle ref, int index);
|
extern vpiHandle vpi_handle_by_index(vpiHandle ref, int index);
|
||||||
|
extern vpiHandle vpi_handle_by_name(char*name, vpiHandle scope);
|
||||||
|
|
||||||
extern void vpi_get_time(vpiHandle obj, s_vpi_time*t);
|
extern void vpi_get_time(vpiHandle obj, s_vpi_time*t);
|
||||||
extern int vpi_get(int property, vpiHandle ref);
|
extern int vpi_get(int property, vpiHandle ref);
|
||||||
|
|
@ -326,6 +328,10 @@ EXTERN_C_END
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: vpi_user.h,v $
|
* $Log: vpi_user.h,v $
|
||||||
|
* Revision 1.13 2002/07/17 05:13:43 steve
|
||||||
|
* Implementation of vpi_handle_by_name, and
|
||||||
|
* add the vpiVariables iterator.
|
||||||
|
*
|
||||||
* Revision 1.12 2002/06/21 04:59:35 steve
|
* Revision 1.12 2002/06/21 04:59:35 steve
|
||||||
* Carry integerness throughout the compilation.
|
* Carry integerness throughout the compilation.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
105
vvp/vpi_priv.cc
105
vvp/vpi_priv.cc
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT)
|
#if !defined(WINNT)
|
||||||
#ident "$Id: vpi_priv.cc,v 1.19 2002/07/12 02:04:44 steve Exp $"
|
#ident "$Id: vpi_priv.cc,v 1.20 2002/07/17 05:13:43 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "vpi_priv.h"
|
# include "vpi_priv.h"
|
||||||
|
|
@ -211,14 +211,14 @@ vpiHandle vpi_iterate(int type, vpiHandle ref)
|
||||||
"vpi_register_systf. You can't do that!\n");
|
"vpi_register_systf. You can't do that!\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ref == 0)
|
if (ref == 0)
|
||||||
return vpi_iterate_global(type);
|
return vpi_iterate_global(type);
|
||||||
|
|
||||||
if (ref->vpi_type->iterate_)
|
if (ref->vpi_type->iterate_)
|
||||||
return (ref->vpi_type->iterate_)(type, ref);
|
return (ref->vpi_type->iterate_)(type, ref);
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
vpiHandle vpi_handle_by_index(vpiHandle ref, int idx)
|
vpiHandle vpi_handle_by_index(vpiHandle ref, int idx)
|
||||||
|
|
@ -228,6 +228,98 @@ vpiHandle vpi_handle_by_index(vpiHandle ref, int idx)
|
||||||
return (ref->vpi_type->index_)(ref, idx);
|
return (ref->vpi_type->index_)(ref, idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static vpiHandle find_name(char *name, vpiHandle handle)
|
||||||
|
{
|
||||||
|
vpiHandle rtn = 0;
|
||||||
|
struct __vpiScope*ref = (struct __vpiScope*)handle;
|
||||||
|
|
||||||
|
/* check module names */
|
||||||
|
if (!strcmp(name, vpi_get_str(vpiName, handle)))
|
||||||
|
rtn = handle;
|
||||||
|
|
||||||
|
/* brute force search for the name in all objects in this scope */
|
||||||
|
for (unsigned i = 0 ; i < ref->nintern ; i += 1) {
|
||||||
|
char *nm = vpi_get_str(vpiName, ref->intern[i]);
|
||||||
|
if (!strcmp(name, nm)) {
|
||||||
|
rtn = ref->intern[i];
|
||||||
|
break;
|
||||||
|
} else if (vpi_get(vpiType, ref->intern[i]) == vpiMemory) {
|
||||||
|
/* We need to iterate on the words */
|
||||||
|
vpiHandle word_i, word_h;
|
||||||
|
word_i = vpi_iterate(vpiMemoryWord, ref->intern[i]);
|
||||||
|
while (word_i && (word_h = vpi_scan(word_i))) {
|
||||||
|
nm = vpi_get_str(vpiName, word_h);
|
||||||
|
if (!strcmp(name, nm)) {
|
||||||
|
rtn = word_h;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* found it yet? */
|
||||||
|
if (rtn) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
|
|
||||||
|
static vpiHandle find_scope(char *name, vpiHandle handle, int depth)
|
||||||
|
{
|
||||||
|
vpiHandle iter, hand, rtn = 0;
|
||||||
|
|
||||||
|
iter = !handle ? vpi_iterate(vpiModule, NULL) :
|
||||||
|
vpi_iterate(vpiInternalScope, handle);
|
||||||
|
|
||||||
|
while (iter && (hand = vpi_scan(iter))) {
|
||||||
|
char *nm = vpi_get_str(vpiName, hand);
|
||||||
|
int len = strlen(nm);
|
||||||
|
char *cp = name + len; /* hier seperator */
|
||||||
|
|
||||||
|
if (!handle && !strcmp(name, nm)) {
|
||||||
|
/* root module */
|
||||||
|
rtn = hand;
|
||||||
|
} else if (!strncmp(name, nm, len) && *(cp) == '.')
|
||||||
|
/* recurse deeper */
|
||||||
|
rtn = find_scope(cp+1, hand, depth + 1);
|
||||||
|
|
||||||
|
/* found it yet ? */
|
||||||
|
if (rtn) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* matched up to here */
|
||||||
|
if (!rtn) rtn = handle;
|
||||||
|
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
|
|
||||||
|
vpiHandle vpi_handle_by_name(char *name, vpiHandle scope)
|
||||||
|
{
|
||||||
|
vpiHandle hand;
|
||||||
|
char *nm, *cp;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
/* If scope provided, look in cooresponding module; otherwise
|
||||||
|
* traverse the hierarcy specified in name to find the leaf module
|
||||||
|
* and try finding it there.
|
||||||
|
*/
|
||||||
|
if (scope)
|
||||||
|
hand = vpi_handle(vpiModule, scope);
|
||||||
|
else
|
||||||
|
hand = find_scope(name, NULL, 0);
|
||||||
|
|
||||||
|
if (hand) {
|
||||||
|
/* remove hierarchical portion of name */
|
||||||
|
nm = vpi_get_str(vpiFullName, hand);
|
||||||
|
len = strlen(nm);
|
||||||
|
cp = name + len;
|
||||||
|
if (!strncmp(name, nm, len) && *cp == '.') name = cp + 1;
|
||||||
|
|
||||||
|
/* Ok, time to burn some cycles */
|
||||||
|
return find_name(name, hand);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" void vpi_vprintf(const char*fmt, va_list ap)
|
extern "C" void vpi_vprintf(const char*fmt, va_list ap)
|
||||||
{
|
{
|
||||||
vprintf(fmt, ap);
|
vprintf(fmt, ap);
|
||||||
|
|
@ -248,6 +340,10 @@ extern "C" void vpi_sim_vcontrol(int operation, va_list ap)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: vpi_priv.cc,v $
|
* $Log: vpi_priv.cc,v $
|
||||||
|
* Revision 1.20 2002/07/17 05:13:43 steve
|
||||||
|
* Implementation of vpi_handle_by_name, and
|
||||||
|
* add the vpiVariables iterator.
|
||||||
|
*
|
||||||
* Revision 1.19 2002/07/12 02:04:44 steve
|
* Revision 1.19 2002/07/12 02:04:44 steve
|
||||||
* vpi_iterate return null if there is nothing to iterate.
|
* vpi_iterate return null if there is nothing to iterate.
|
||||||
*
|
*
|
||||||
|
|
@ -296,4 +392,3 @@ extern "C" void vpi_sim_vcontrol(int operation, va_list ap)
|
||||||
* Revision 1.6 2001/06/21 22:54:12 steve
|
* Revision 1.6 2001/06/21 22:54:12 steve
|
||||||
* Support cbValueChange callbacks.
|
* Support cbValueChange callbacks.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT)
|
#if !defined(WINNT)
|
||||||
#ident "$Id: vpi_scope.cc,v 1.18 2002/07/14 02:52:05 steve Exp $"
|
#ident "$Id: vpi_scope.cc,v 1.19 2002/07/17 05:13:43 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "compile.h"
|
# include "compile.h"
|
||||||
|
|
@ -97,19 +97,22 @@ static vpiHandle scope_get_handle(int code, vpiHandle obj)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle subclasses for vpiTypes */
|
/* compares vpiType's considering object classes */
|
||||||
static inline int compare_types(int code, int type)
|
static int compare_types(int code, int type)
|
||||||
{
|
{
|
||||||
if (code == type ||
|
if ( code == type
|
||||||
code == vpiScope &&
|
|| (code == vpiInternalScope &&
|
||||||
type == vpiModule ||
|
(type == vpiModule ||
|
||||||
type == vpiFunction ||
|
type == vpiFunction ||
|
||||||
type == vpiTask ||
|
type == vpiTask ||
|
||||||
type == vpiNamedBegin ||
|
type == vpiNamedBegin ||
|
||||||
type == vpiNamedFork)
|
type == vpiNamedFork))
|
||||||
{
|
|| (code == vpiVariables &&
|
||||||
|
(type == vpiIntegerVar ||
|
||||||
|
type == vpiTimeVar))
|
||||||
|
)
|
||||||
return 1;
|
return 1;
|
||||||
} else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -152,10 +155,6 @@ static vpiHandle module_iter(int code, vpiHandle obj)
|
||||||
|
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case vpiInternalScope:
|
case vpiInternalScope:
|
||||||
return module_iter_subset(vpiScope, ref);
|
|
||||||
|
|
||||||
/* Generate and iterator for all the modules contained
|
|
||||||
in this scope. */
|
|
||||||
case vpiMemory:
|
case vpiMemory:
|
||||||
case vpiModule:
|
case vpiModule:
|
||||||
case vpiNamedEvent:
|
case vpiNamedEvent:
|
||||||
|
|
@ -408,6 +407,10 @@ void vpip_attach_to_current_scope(vpiHandle obj)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: vpi_scope.cc,v $
|
* $Log: vpi_scope.cc,v $
|
||||||
|
* Revision 1.19 2002/07/17 05:13:43 steve
|
||||||
|
* Implementation of vpi_handle_by_name, and
|
||||||
|
* add the vpiVariables iterator.
|
||||||
|
*
|
||||||
* Revision 1.18 2002/07/14 02:52:05 steve
|
* Revision 1.18 2002/07/14 02:52:05 steve
|
||||||
* Fix vpiScope iterator.
|
* Fix vpiScope iterator.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue