From e9af0c74854f634a47c39f6c318bf9aa69b9a1b9 Mon Sep 17 00:00:00 2001 From: steve Date: Fri, 10 May 2002 16:00:57 +0000 Subject: [PATCH] Support scope iterate over vpiNet,vpiReg/vpiMemory. --- vvp/compile.cc | 6 +++++- vvp/vpi_memory.cc | 21 ++++++++++++++++----- vvp/vpi_scope.cc | 47 ++++++++++++++++++++++++++++++----------------- 3 files changed, 51 insertions(+), 23 deletions(-) diff --git a/vvp/compile.cc b/vvp/compile.cc index f40d2ce89..50d39cc43 100644 --- a/vvp/compile.cc +++ b/vvp/compile.cc @@ -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. * diff --git a/vvp/vpi_memory.cc b/vvp/vpi_memory.cc index 0b36fb88f..f6c03a37b 100644 --- a/vvp/vpi_memory.cc +++ b/vvp/vpi_memory.cc @@ -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. * diff --git a/vvp/vpi_scope.cc b/vvp/vpi_scope.cc index 5d1b759ce..014656c66 100644 --- a/vvp/vpi_scope.cc +++ b/vvp/vpi_scope.cc @@ -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. *