diff --git a/vpi/sys_fst.c b/vpi/sys_fst.c index d445799a4..782fc9ede 100644 --- a/vpi/sys_fst.c +++ b/vpi/sys_fst.c @@ -22,8 +22,7 @@ # include "fstapi.h" /* - * This file contains the implementations of the VCD related - * funcitons. + * This file contains the implementations of the FST related functions. */ # include @@ -469,9 +468,9 @@ static void scan_item(unsigned depth, vpiHandle item, int skip) struct vcd_info* info; PLI_INT32 type; - const char* name; - const char* fullname; - const char* prefix; + const char *name; + const char *fullname; + char *escname; const char *ident; fstHandle new_ident; int nexus_id; @@ -566,12 +565,11 @@ static void scan_item(unsigned depth, vpiHandle item, int skip) /* Generate the $var or $scope commands. */ switch (item_type) { case vpiParameter: - vpi_printf("VCD sorry: $dumpvars: can not dump parameters.\n"); + vpi_printf("FST sorry: $dumpvars: can not dump parameters.\n"); break; case vpiNamedEvent: case vpiIntegerVar: -// case vpiParameter: case vpiRealVar: case vpiMemoryWord: case vpiReg: @@ -586,9 +584,12 @@ static void scan_item(unsigned depth, vpiHandle item, int skip) * This can only happen for implicitly given signals. */ if (vcd_names_search(&fst_var, fullname)) return; - /* Declare the variable in the VCD file. */ + /* Declare the variable in the FST file. */ name = vpi_get_str(vpiName, item); - prefix = is_escaped_id(name) ? "\\" : ""; + if (is_escaped_id(name)) { + escname = malloc(strlen(name) + 2); + sprintf(escname, "\\%s", name); + } else escname = strdup(name); /* Some signals can have an alias so handle that. */ nexus_id = vpi_get(_vpiNexusId, item); @@ -602,12 +603,9 @@ static void scan_item(unsigned depth, vpiHandle item, int skip) if (item_type == vpiNamedEvent) size = 1; else size = vpi_get(vpiSize, item); - - if (vpi_get(vpiSize, item) > 1 - || vpi_get(vpiLeftRange, item) != 0) { - int slen = strlen(name); - char *buf = malloc(slen + 65); - sprintf(buf, "%s [%i:%i]", name, + if (size > 1 || vpi_get(vpiLeftRange, item) != 0) { + char *buf = malloc(strlen(escname) + 65); + sprintf(buf, "%s [%i:%i]", escname, (int)vpi_get(vpiLeftRange, item), (int)vpi_get(vpiRightRange, item)); @@ -617,9 +615,10 @@ static void scan_item(unsigned depth, vpiHandle item, int skip) free(buf); } else { new_ident = fstWriterCreateVar(dump_file, type, - FST_VD_IMPLICIT, size, name, + FST_VD_IMPLICIT, size, escname, (fstHandle)(long)ident); } + free(escname); if (!ident) { if (nexus_id) set_nexus_ident(nexus_id, diff --git a/vpi/sys_lxt.c b/vpi/sys_lxt.c index 24700d79d..6ab697ffa 100644 --- a/vpi/sys_lxt.c +++ b/vpi/sys_lxt.c @@ -23,8 +23,7 @@ # include "vcd_priv.h" /* - * This file contains the implementations of the LXT related - * funcitons. + * This file contains the implementations of the LXT related functions. */ # include diff --git a/vpi/sys_lxt2.c b/vpi/sys_lxt2.c index ea7ebbff0..7bbec0617 100644 --- a/vpi/sys_lxt2.c +++ b/vpi/sys_lxt2.c @@ -23,8 +23,7 @@ # include "vcd_priv.h" /* - * This file contains the implementations of the LXT2 related - * funcitons. + * This file contains the implementations of the LXT2 related functions. */ # include diff --git a/vpi/sys_vcd.c b/vpi/sys_vcd.c index f44023ac6..949ee3167 100644 --- a/vpi/sys_vcd.c +++ b/vpi/sys_vcd.c @@ -21,8 +21,7 @@ # include "vcd_priv.h" /* - * This file contains the implementations of the VCD related - * funcitons. + * This file contains the implementations of the VCD related functions. */ # include @@ -496,11 +495,11 @@ static void scan_item(unsigned depth, vpiHandle item, int skip) struct t_cb_data cb; struct vcd_info* info; - const char* type; - const char* name; - const char* fullname; - const char* prefix; - const char* ident; + const char *type; + const char *name; + const char *fullname; + const char *prefix; + const char *ident; int nexus_id; unsigned size; PLI_INT32 item_type; @@ -598,7 +597,6 @@ static void scan_item(unsigned depth, vpiHandle item, int skip) case vpiNamedEvent: case vpiIntegerVar: -// case vpiParameter: case vpiRealVar: case vpiMemoryWord: case vpiReg: @@ -661,8 +659,7 @@ static void scan_item(unsigned depth, vpiHandle item, int skip) type, size, ident, prefix, name); /* Add a range for vectored values. */ - if (vpi_get(vpiSize, item) > 1 - || vpi_get(vpiLeftRange, item) != 0) { + if (size > 1 || vpi_get(vpiLeftRange, item) != 0) { fprintf(dump_file, " [%i:%i]", (int)vpi_get(vpiLeftRange, item), (int)vpi_get(vpiRightRange, item));