Update the FST dumper to include the vpiDefName if it's unique.

This patch adds the vpiDefName for a module if it is different than
the vpiName. This will be used in a future version of GTKWave.
This commit is contained in:
Cary R 2011-03-22 15:50:50 -07:00 committed by Stephen Williams
parent 13519ab5c7
commit 085a5c8d02
1 changed files with 32 additions and 6 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2010 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2011 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -657,6 +657,7 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
if (depth > 0) {
int nskip = (vcd_names_search(&fst_tab, fullname) != 0);
char *defname = NULL;
/* We have to always scan the scope because the
* depth could be different for this call. */
@ -667,8 +668,19 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
vcd_names_add(&fst_tab, fullname);
}
/* This must be done before the other name is fetched
* and the string must always be freed */
if (item_type == vpiModule) {
defname = strdup(vpi_get_str(vpiDefName, item));
}
name = vpi_get_str(vpiName, item);
fstWriterSetScope(dump_file, type, name, NULL);
/* If the two names match only use the vpiName. */
if (defname && (strcmp(defname, name) == 0)) {
free(defname);
defname = NULL;
}
fstWriterSetScope(dump_file, type, name, defname);
free(defname);
for (i=0; types[i]>0; i++) {
vpiHandle hand;
@ -689,15 +701,28 @@ static int draw_scope(vpiHandle item, vpiHandle callh)
{
int depth;
const char *name;
PLI_INT32 type;
char *defname = NULL;
PLI_INT32 scope_type, type;
vpiHandle scope = vpi_handle(vpiScope, item);
if (!scope) return 0;
depth = 1 + draw_scope(scope, callh);
name = vpi_get_str(vpiName, scope);
switch (vpi_get(vpiType, scope)) {
scope_type = vpi_get(vpiType, scope);
/* This must be done before the other name is fetched
* and the string must always be freed */
if (scope_type == vpiModule) {
defname = strdup(vpi_get_str(vpiDefName, scope));
}
name = vpi_get_str(vpiName, scope);
/* If the two names match only use the vpiName. */
if (defname && (strcmp(defname, name) == 0)) {
free(defname);
defname = NULL;
}
switch (scope_type) {
case vpiNamedBegin: type = FST_ST_VCD_BEGIN; break;
case vpiTask: type = FST_ST_VCD_TASK; break;
case vpiFunction: type = FST_ST_VCD_FUNCTION; break;
@ -712,7 +737,8 @@ static int draw_scope(vpiHandle item, vpiHandle callh)
assert(0);
}
fstWriterSetScope(dump_file, type, name, NULL);
fstWriterSetScope(dump_file, type, name, defname);
free(defname);
return depth;
}