More VCD enhancements.

Make the code smarter so it can keep fewer items in the lists.
Scopes and explicitly given variables are all that is kept.
Includes a few other refinements.
This commit is contained in:
Cary R 2009-06-25 12:46:46 -07:00 committed by Stephen Williams
parent 7e3a7b87ff
commit 067fcc07a1
1 changed files with 22 additions and 22 deletions

View File

@ -495,7 +495,7 @@ static PLI_INT32 sys_dumplimit_calltf(PLI_BYTE8 *name)
return 0; return 0;
} }
static void scan_item(unsigned depth, vpiHandle item, int skip, int expl) static void scan_item(unsigned depth, vpiHandle item, int skip)
{ {
struct t_cb_data cb; struct t_cb_data cb;
struct vcd_info* info; struct vcd_info* info;
@ -613,17 +613,9 @@ static void scan_item(unsigned depth, vpiHandle item, int skip, int expl)
* scope then just return. */ * scope then just return. */
if (skip || vpi_get(vpiAutomatic, item)) return; if (skip || vpi_get(vpiAutomatic, item)) return;
/* Skip this signal if it has already been included. */ /* Skip this signal if it has already been included.
if (vcd_names_search(&vcd_var, fullname)) { * This can only happen for implicitly given signals. */
/* Only warn when the variable is given explicitly. */ if (vcd_names_search(&vcd_var, fullname)) return;
if (expl)
vpi_printf("VCD warning: skipping signal %s, it was "
"previously included.\n", fullname);
return;
}
/* Add implicit signals here. */
if (!expl) vcd_names_add(&vcd_var, fullname);
/* Declare the variable in the VCD file. */ /* Declare the variable in the VCD file. */
name = vpi_get_str(vpiName, item); name = vpi_get_str(vpiName, item);
@ -696,7 +688,10 @@ static void scan_item(unsigned depth, vpiHandle item, int skip, int expl)
if (nskip) { if (nskip) {
vpi_printf("VCD warning: ignoring signals in " vpi_printf("VCD warning: ignoring signals in "
"previously scanned scope %s.\n", fullname); "previously scanned scope %s.\n", fullname);
} else vcd_names_add(&vcd_tab, fullname); } else {
vcd_names_add(&vcd_tab, fullname);
vcd_names_sort(&vcd_tab);
}
name = vpi_get_str(vpiName, item); name = vpi_get_str(vpiName, item);
fprintf(dump_file, "$scope %s %s $end\n", type, name); fprintf(dump_file, "$scope %s %s $end\n", type, name);
@ -705,12 +700,11 @@ static void scan_item(unsigned depth, vpiHandle item, int skip, int expl)
vpiHandle hand; vpiHandle hand;
vpiHandle argv = vpi_iterate(types[i], item); vpiHandle argv = vpi_iterate(types[i], item);
while (argv && (hand = vpi_scan(argv))) { while (argv && (hand = vpi_scan(argv))) {
scan_item(depth-1, hand, nskip, 0); scan_item(depth-1, hand, nskip);
} }
} }
/* Sort any signals that we added above. */ /* Sort any signals that we added above. */
if (!nskip) vcd_names_sort(&vcd_var);
fprintf(dump_file, "$upscope $end\n"); fprintf(dump_file, "$upscope $end\n");
} }
break; break;
@ -784,12 +778,11 @@ static PLI_INT32 sys_dumpvars_calltf(PLI_BYTE8*name)
} }
for ( ; item; item = vpi_scan(argv)) { for ( ; item; item = vpi_scan(argv)) {
const char *scname; char *scname;
const char *fullname;
int add_var = 0; int add_var = 0;
int dep; int dep;
vcd_names_sort(&vcd_tab);
/* If this is a signal make sure it has not already /* If this is a signal make sure it has not already
* been included. */ * been included. */
switch (vpi_get(vpiType, item)) { switch (vpi_get(vpiType, item)) {
@ -801,20 +794,27 @@ static PLI_INT32 sys_dumpvars_calltf(PLI_BYTE8*name)
case vpiRealVar: case vpiRealVar:
case vpiReg: case vpiReg:
case vpiTimeVar: case vpiTimeVar:
scname = vpi_get_str(vpiFullName, vpi_handle(vpiScope, item)); /* Warn if the variables scope (which includes the
if (vcd_names_search(&vcd_var, scname)) { * variable) or the variable itself was already
* included. */
scname = strdup(vpi_get_str(vpiFullName,
vpi_handle(vpiScope, item)));
fullname = vpi_get_str(vpiFullName, item);
if (vcd_names_search(&vcd_tab, scname) ||
vcd_names_search(&vcd_var, fullname)) {
vpi_printf("VCD warning: skipping signal %s, " vpi_printf("VCD warning: skipping signal %s, "
"it was previously included.\n", "it was previously included.\n",
vpi_get_str(vpiFullName, item)); fullname);
continue; continue;
} else { } else {
add_var = 1; add_var = 1;
} }
free(scname);
} }
dep = draw_scope(item, callh); dep = draw_scope(item, callh);
scan_item(depth, item, 0, 1); scan_item(depth, item, 0);
while (dep--) fprintf(dump_file, "$upscope $end\n"); while (dep--) fprintf(dump_file, "$upscope $end\n");