Add escaped identifier support to the FST dumper and some clean up.

This patch adds escaped identifier support to the FST dumper and
cleans up the VCD and FST code a bit. Also a simple spelling fix.
This commit is contained in:
Cary R 2010-06-01 16:48:46 -07:00 committed by Stephen Williams
parent ddf5748b48
commit 3fe68c4c04
4 changed files with 24 additions and 30 deletions

View File

@ -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 <stdio.h>
@ -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,

View File

@ -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 <stdio.h>

View File

@ -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 <stdio.h>

View File

@ -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 <stdio.h>
@ -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));