Support scope iterate over vpiNet,vpiReg/vpiMemory.

This commit is contained in:
steve 2002-05-10 16:00:57 +00:00
parent be54bfdc21
commit e9af0c7485
3 changed files with 51 additions and 23 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: compile.cc,v 1.126 2002/05/07 04:15:43 steve Exp $"
#ident "$Id: compile.cc,v 1.127 2002/05/10 16:00:57 steve Exp $"
#endif
# include "arith.h"
@ -1036,6 +1036,7 @@ void compile_memory(char *label, char *name, int msb, int lsb,
vpiHandle obj = vpip_make_memory(mem);
compile_vpi_symbol(label, obj);
vpip_attach_to_current_scope(obj);
free(label);
}
@ -1410,6 +1411,9 @@ vvp_ipoint_t debug_lookup_functor(const char*name)
/*
* $Log: compile.cc,v $
* Revision 1.127 2002/05/10 16:00:57 steve
* Support scope iterate over vpiNet,vpiReg/vpiMemory.
*
* Revision 1.126 2002/05/07 04:15:43 steve
* Fix uninitialized memory accesses.
*

View File

@ -27,7 +27,7 @@
* Picture Elements, Inc., 777 Panoramic Way, Berkeley, CA 94704.
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vpi_memory.cc,v 1.6 2002/05/03 15:44:11 steve Exp $"
#ident "$Id: vpi_memory.cc,v 1.7 2002/05/10 16:00:57 steve Exp $"
#endif
# include "vpi_priv.h"
@ -48,6 +48,7 @@ struct __vpiMemoryWord {
struct __vpiMemory {
struct __vpiHandle base;
struct __vpiScope* scope;
/* The signal has a name (this points to static memory.) */
struct __vpiMemoryWord word;
vvp_memory_t mem;
@ -63,11 +64,15 @@ static vpiHandle memory_get_handle(int code, vpiHandle obj)
assert(obj->vpi_type->type_code==vpiMemory);
switch(code){
case vpiLeftRange:
return &(rfp->left_range->base);
case vpiLeftRange:
return &(rfp->left_range->base);
case vpiRightRange:
return &(rfp->right_range->base);
case vpiScope:
return &rfp->scope->base;
case vpiRightRange:
return &(rfp->right_range->base);
}
return 0;
@ -94,6 +99,8 @@ static char* memory_get_str(int code, vpiHandle ref)
assert(ref->vpi_type->type_code==vpiMemory);
switch (code) {
case vpiName:
return memory_name(rfp->mem);
case vpiFullName:
return memory_name(rfp->mem);
}
@ -356,6 +363,7 @@ vpiHandle vpip_make_memory(vvp_memory_t mem)
malloc(sizeof(struct __vpiMemory));
obj->base.vpi_type = &vpip_memory_rt;
obj->scope = vpip_peek_current_scope();
obj->mem = mem;
obj->left_range = (struct __vpiDecConst*)vpip_make_dec_const(memory_left_range(mem));
obj->right_range = (struct __vpiDecConst*)vpip_make_dec_const(memory_right_range(mem));
@ -370,6 +378,9 @@ vpiHandle vpip_make_memory(vvp_memory_t mem)
/*
* $Log: vpi_memory.cc,v $
* Revision 1.7 2002/05/10 16:00:57 steve
* Support scope iterate over vpiNet,vpiReg/vpiMemory.
*
* Revision 1.6 2002/05/03 15:44:11 steve
* Add vpiModule iterator to vpiScope objects.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: vpi_scope.cc,v 1.13 2002/05/03 15:44:11 steve Exp $"
#ident "$Id: vpi_scope.cc,v 1.14 2002/05/10 16:00:57 steve Exp $"
#endif
# include "compile.h"
@ -91,6 +91,28 @@ static vpiHandle scope_get_handle(int code, vpiHandle obj)
return 0;
}
static vpiHandle module_iter_subset(int code, struct __vpiScope*ref)
{
unsigned mcnt = 0, ncnt = 0;
vpiHandle*args;
for (unsigned idx = 0 ; idx < ref->nintern ; idx += 1)
if (ref->intern[idx]->vpi_type->type_code == code)
mcnt += 1;
if (mcnt == 0)
return 0;
args = (vpiHandle*)calloc(mcnt, sizeof(vpiHandle));
for (unsigned idx = 0 ; idx < ref->nintern ; idx += 1)
if (ref->intern[idx]->vpi_type->type_code == code)
args[ncnt++] = ref->intern[idx];
assert(ncnt == mcnt);
return vpip_make_iterator(mcnt, args, true);
}
/*
* This function implements the vpi_iterate method for vpiModule and
* similar objects. The vpi_iterate allows the user to iterate over
@ -112,24 +134,12 @@ static vpiHandle module_iter(int code, vpiHandle obj)
/* Generate and iterator for all the modules contained
in this scope. */
case vpiMemory:
case vpiModule:
{ unsigned mcnt = 0, ncnt = 0;
vpiHandle*args;
for (unsigned idx = 0 ; idx < ref->nintern ; idx += 1)
if (ref->intern[idx]->vpi_type->type_code == vpiModule)
mcnt += 1;
case vpiNet:
case vpiReg:
return module_iter_subset(code, ref);
if (mcnt == 0)
return 0;
args = (vpiHandle*)calloc(mcnt, sizeof(vpiHandle));
for (unsigned idx = 0 ; idx < ref->nintern ; idx += 1)
if (ref->intern[idx]->vpi_type->type_code == vpiModule)
args[ncnt++] = ref->intern[idx];
assert(ncnt == mcnt);
return vpip_make_iterator(mcnt, args, true);
}
}
return 0;
}
@ -371,6 +381,9 @@ void vpip_attach_to_current_scope(vpiHandle obj)
/*
* $Log: vpi_scope.cc,v $
* Revision 1.14 2002/05/10 16:00:57 steve
* Support scope iterate over vpiNet,vpiReg/vpiMemory.
*
* Revision 1.13 2002/05/03 15:44:11 steve
* Add vpiModule iterator to vpiScope objects.
*