From bf42be12dea8000dbbe3a5209726c104bef107d0 Mon Sep 17 00:00:00 2001 From: steve Date: Sun, 28 Nov 1999 00:56:08 +0000 Subject: [PATCH] Build up the lists in the scope of a module, and get $dumpvars to scan the scope for items. --- t-vvm.cc | 33 +++++++++++------- vpi/sys_vcd.c | 90 +++++++++++++++++++++++++++++-------------------- vpi/vpi_user.h | 7 +++- vvm/vpi_priv.h | 9 ++++- vvm/vpi_scope.c | 36 ++++++++++++++++++-- 5 files changed, 123 insertions(+), 52 deletions(-) diff --git a/t-vvm.cc b/t-vvm.cc index c122f241a..3bb2343ba 100644 --- a/t-vvm.cc +++ b/t-vvm.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: t-vvm.cc,v 1.80 1999/11/27 19:07:58 steve Exp $" +#ident "$Id: t-vvm.cc,v 1.81 1999/11/28 00:56:08 steve Exp $" #endif # include @@ -720,7 +720,21 @@ bool target_vvm::process(ostream&os, const NetProcTop*top) void target_vvm::signal(ostream&os, const NetNet*sig) { #if 1 - os << "// XXXX handle signal " << sig->name() << endl; + string net_name = mangle(sig->name()); + os << "static vvm_bitset_t<" << sig->pin_count() << "> " << + net_name<< "_bits; /* " << sig->name() << + " */" << endl; + os << "static vvm_signal_t<" << sig->pin_count() << "> " << + net_name << "(&" << net_name << "_bits);" << endl; + + init_code << " vpip_make_reg(&" << net_name << + ", \"" << sig->name() << "\");" << endl; + + if (const NetScope*scope = sig->scope()) { + string sname = mangle(scope->name()) + "_scope"; + init_code << " vpip_attach_to_scope(&" << sname + << ", &" << net_name << ".base);" << endl; + } #endif /* Scan the signals of the vector, passing the initial value @@ -1299,6 +1313,7 @@ void target_vvm::net_const(ostream&os, const NetConst*gate) void target_vvm::net_esignal(ostream&os, const NetESignal*net) { +#if 0 bool&flag = esignal_printed_flag[net->name()]; if (flag) return; @@ -1313,16 +1328,6 @@ void target_vvm::net_esignal(ostream&os, const NetESignal*net) init_code << " vpip_make_reg(&" << net_name << ", \"" << net->name() << "\");" << endl; - -#if 0 - /* If the signal (that I am declaring and initializing) is - attached to a scope in the netlist, then attach it to the - scope for real here. */ - if (const NetScope*scope = net->scope()) { - init_code << " vpip_attach_to_scope(&" << - mangle(scope->name()) << "_scope, &" << net_name << - ".base);" << endl; - } #endif } @@ -1987,6 +1992,10 @@ extern const struct target tgt_vvm = { }; /* * $Log: t-vvm.cc,v $ + * Revision 1.81 1999/11/28 00:56:08 steve + * Build up the lists in the scope of a module, + * and get $dumpvars to scan the scope for items. + * * Revision 1.80 1999/11/27 19:07:58 steve * Support the creation of scopes. * diff --git a/vpi/sys_vcd.c b/vpi/sys_vcd.c index c7deb44e9..9e74b6145 100644 --- a/vpi/sys_vcd.c +++ b/vpi/sys_vcd.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: sys_vcd.c,v 1.1 1999/11/07 20:33:30 steve Exp $" +#ident "$Id: sys_vcd.c,v 1.2 1999/11/28 00:56:08 steve Exp $" #endif /* @@ -122,13 +122,60 @@ static int sys_dumpfile_calltf(char*name) return 0; } -static int sys_dumpvars_calltf(char*name) +static void scan_scope(unsigned depth, vpiHandle argv) { struct t_cb_data cb; struct vcd_info*info; char ident[64]; unsigned nident = 0; + vpiHandle item; + vpiHandle sublist; + + cb.reason = cbValueChange; + cb.cb_rtn = variable_cb; + + for (item = vpi_scan(argv) ; item ; item = vpi_scan(argv)) { + const char*type; + + switch (vpi_get(vpiType, item)) { + case vpiNet: + case vpiReg: + type = "wire"; + if (vpi_get(vpiType, item) == vpiReg) + type = "reg"; + + sprintf(ident, "<%u", nident++); + info = malloc(sizeof(*info)); + info->time.type = vpiSimTime; + cb.time = &info->time; + cb.user_data = (char*)info; + cb.obj = item; + info->item = item; + info->ident = strdup(ident); + info->cb = vpi_register_cb(&cb); + info->next = vcd_list; + vcd_list = info; + fprintf(dump_file, "$var %s %u %s %s $end\n", + type, vpi_get(vpiSize, item), ident, + vpi_get_str(vpiFullName, item)); + break; + + case vpiModule: + sublist = vpi_iterate(vpiInternalScope, item); + if (sublist && (depth > 0)) + scan_scope(depth-1, sublist); + break; + + default: + vpi_printf("ERROR: $dumpvars: Unsupported parameter type\n"); + } + + } +} + +static int sys_dumpvars_calltf(char*name) +{ vpiHandle sys = vpi_handle(vpiSysTfCall, 0); vpiHandle argv = vpi_iterate(vpiArgument, sys); vpiHandle item = vpi_scan(argv); @@ -140,40 +187,7 @@ static int sys_dumpvars_calltf(char*name) assert(dump_file); - cb.reason = cbValueChange; - cb.cb_rtn = variable_cb; - - for (item = vpi_scan(argv) ; item ; item = vpi_scan(argv)) { - - switch (vpi_get(vpiType, item)) { - case vpiNet: - case vpiReg: { - const char*type = "wire"; - if (vpi_get(vpiType, item) == vpiReg) - type = "reg"; - - sprintf(ident, "<%u", nident++); - info = malloc(sizeof(*info)); - info->time.type = vpiSimTime; - cb.time = &info->time; - cb.user_data = (char*)info; - cb.obj = item; - info->item = item; - info->ident = strdup(ident); - info->cb = vpi_register_cb(&cb); - info->next = vcd_list; - vcd_list = info; - fprintf(dump_file, "$var %s %u %s %s $end\n", - type, vpi_get(vpiSize, item), ident, - vpi_get_str(vpiFullName, item)); - break; - } - - default: - vpi_printf("ERROR: (%s): Unsupported parameter type\n", - name); - } - } + scan_scope(99, argv); fprintf(dump_file, "$enddefinitions $end\n"); fprintf(dump_file, "#0\n"); @@ -212,6 +226,10 @@ void sys_vcd_register() /* * $Log: sys_vcd.c,v $ + * Revision 1.2 1999/11/28 00:56:08 steve + * Build up the lists in the scope of a module, + * and get $dumpvars to scan the scope for items. + * * Revision 1.1 1999/11/07 20:33:30 steve * Add VCD output and related system tasks. * diff --git a/vpi/vpi_user.h b/vpi/vpi_user.h index 97189000e..2852493ae 100644 --- a/vpi/vpi_user.h +++ b/vpi/vpi_user.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: vpi_user.h,v 1.8 1999/11/27 19:07:58 steve Exp $" +#ident "$Id: vpi_user.h,v 1.9 1999/11/28 00:56:08 steve Exp $" #endif #ifdef __cplusplus @@ -107,6 +107,7 @@ typedef struct t_vpi_value { #define vpiTimeVar 63 #define vpiSysTfCall 85 #define vpiArgument 89 +#define vpiInternalScope 92 #define vpiCallback 1000 @@ -210,6 +211,10 @@ extern void (*vlog_startup_routines[])(); /* * $Log: vpi_user.h,v $ + * Revision 1.9 1999/11/28 00:56:08 steve + * Build up the lists in the scope of a module, + * and get $dumpvars to scan the scope for items. + * * Revision 1.8 1999/11/27 19:07:58 steve * Support the creation of scopes. * diff --git a/vvm/vpi_priv.h b/vvm/vpi_priv.h index 062d5fe8c..9f4da3b96 100644 --- a/vvm/vpi_priv.h +++ b/vvm/vpi_priv.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: vpi_priv.h,v 1.7 1999/11/27 19:07:58 steve Exp $" +#ident "$Id: vpi_priv.h,v 1.8 1999/11/28 00:56:08 steve Exp $" #endif /* @@ -123,6 +123,9 @@ struct __vpiScope { struct __vpiHandle base; /* The scope has a name. (this points to static memory.) */ const char*name; + /* Keep an array of internal scope items. */ + struct __vpiHandle**intern; + unsigned nintern; }; extern void vpip_attach_to_scope(struct __vpiScope*scope, vpiHandle obj); @@ -271,6 +274,10 @@ extern int vpip_finished(); /* * $Log: vpi_priv.h,v $ + * Revision 1.8 1999/11/28 00:56:08 steve + * Build up the lists in the scope of a module, + * and get $dumpvars to scan the scope for items. + * * Revision 1.7 1999/11/27 19:07:58 steve * Support the creation of scopes. * diff --git a/vvm/vpi_scope.c b/vvm/vpi_scope.c index 6ba650067..8811abed5 100644 --- a/vvm/vpi_scope.c +++ b/vvm/vpi_scope.c @@ -17,23 +17,39 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: vpi_scope.c,v 1.1 1999/11/27 19:07:58 steve Exp $" +#ident "$Id: vpi_scope.c,v 1.2 1999/11/28 00:56:08 steve Exp $" #endif # include "vpi_priv.h" +# include # include +static vpiHandle module_iter(int code, vpiHandle obj) +{ + struct __vpiScope*ref = (struct __vpiScope*)obj; + assert(obj->vpi_type->type_code == vpiModule); + + switch (code) { + case vpiInternalScope: + return vpip_make_iterator(ref->nintern, ref->intern); + } + return 0; +} + static const struct __vpirt vpip_module_rt = { vpiModule, 0, 0, 0, 0, - 0 + module_iter }; vpiHandle vpip_make_scope(struct __vpiScope*ref, int type, const char*name) { + ref->intern = 0; + ref->nintern = 0; + switch (type) { case vpiModule: ref->base.vpi_type = &vpip_module_rt; @@ -45,8 +61,24 @@ vpiHandle vpip_make_scope(struct __vpiScope*ref, int type, const char*name) return &ref->base; } +void vpip_attach_to_scope(struct __vpiScope*ref, vpiHandle obj) +{ + unsigned idx = ref->nintern++; + + if (ref->intern == 0) + ref->intern = malloc(sizeof(vpiHandle)); + else + ref->intern = realloc(ref->intern, sizeof(vpiHandle)*ref->nintern); + + ref->intern[idx] = obj; +} + /* * $Log: vpi_scope.c,v $ + * Revision 1.2 1999/11/28 00:56:08 steve + * Build up the lists in the scope of a module, + * and get $dumpvars to scan the scope for items. + * * Revision 1.1 1999/11/27 19:07:58 steve * Support the creation of scopes. *