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:
parent
ddf5748b48
commit
3fe68c4c04
|
|
@ -22,8 +22,7 @@
|
||||||
# include "fstapi.h"
|
# include "fstapi.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file contains the implementations of the VCD related
|
* This file contains the implementations of the FST related functions.
|
||||||
* funcitons.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
|
|
@ -469,9 +468,9 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
|
||||||
struct vcd_info* info;
|
struct vcd_info* info;
|
||||||
|
|
||||||
PLI_INT32 type;
|
PLI_INT32 type;
|
||||||
const char* name;
|
const char *name;
|
||||||
const char* fullname;
|
const char *fullname;
|
||||||
const char* prefix;
|
char *escname;
|
||||||
const char *ident;
|
const char *ident;
|
||||||
fstHandle new_ident;
|
fstHandle new_ident;
|
||||||
int nexus_id;
|
int nexus_id;
|
||||||
|
|
@ -566,12 +565,11 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
|
||||||
/* Generate the $var or $scope commands. */
|
/* Generate the $var or $scope commands. */
|
||||||
switch (item_type) {
|
switch (item_type) {
|
||||||
case vpiParameter:
|
case vpiParameter:
|
||||||
vpi_printf("VCD sorry: $dumpvars: can not dump parameters.\n");
|
vpi_printf("FST sorry: $dumpvars: can not dump parameters.\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case vpiNamedEvent:
|
case vpiNamedEvent:
|
||||||
case vpiIntegerVar:
|
case vpiIntegerVar:
|
||||||
// case vpiParameter:
|
|
||||||
case vpiRealVar:
|
case vpiRealVar:
|
||||||
case vpiMemoryWord:
|
case vpiMemoryWord:
|
||||||
case vpiReg:
|
case vpiReg:
|
||||||
|
|
@ -586,9 +584,12 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
|
||||||
* This can only happen for implicitly given signals. */
|
* This can only happen for implicitly given signals. */
|
||||||
if (vcd_names_search(&fst_var, fullname)) return;
|
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);
|
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. */
|
/* Some signals can have an alias so handle that. */
|
||||||
nexus_id = vpi_get(_vpiNexusId, item);
|
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;
|
if (item_type == vpiNamedEvent) size = 1;
|
||||||
else size = vpi_get(vpiSize, item);
|
else size = vpi_get(vpiSize, item);
|
||||||
|
|
||||||
|
if (size > 1 || vpi_get(vpiLeftRange, item) != 0) {
|
||||||
if (vpi_get(vpiSize, item) > 1
|
char *buf = malloc(strlen(escname) + 65);
|
||||||
|| vpi_get(vpiLeftRange, item) != 0) {
|
sprintf(buf, "%s [%i:%i]", escname,
|
||||||
int slen = strlen(name);
|
|
||||||
char *buf = malloc(slen + 65);
|
|
||||||
sprintf(buf, "%s [%i:%i]", name,
|
|
||||||
(int)vpi_get(vpiLeftRange, item),
|
(int)vpi_get(vpiLeftRange, item),
|
||||||
(int)vpi_get(vpiRightRange, item));
|
(int)vpi_get(vpiRightRange, item));
|
||||||
|
|
||||||
|
|
@ -617,9 +615,10 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
|
||||||
free(buf);
|
free(buf);
|
||||||
} else {
|
} else {
|
||||||
new_ident = fstWriterCreateVar(dump_file, type,
|
new_ident = fstWriterCreateVar(dump_file, type,
|
||||||
FST_VD_IMPLICIT, size, name,
|
FST_VD_IMPLICIT, size, escname,
|
||||||
(fstHandle)(long)ident);
|
(fstHandle)(long)ident);
|
||||||
}
|
}
|
||||||
|
free(escname);
|
||||||
|
|
||||||
if (!ident) {
|
if (!ident) {
|
||||||
if (nexus_id) set_nexus_ident(nexus_id,
|
if (nexus_id) set_nexus_ident(nexus_id,
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,7 @@
|
||||||
# include "vcd_priv.h"
|
# include "vcd_priv.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file contains the implementations of the LXT related
|
* This file contains the implementations of the LXT related functions.
|
||||||
* funcitons.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,7 @@
|
||||||
# include "vcd_priv.h"
|
# include "vcd_priv.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file contains the implementations of the LXT2 related
|
* This file contains the implementations of the LXT2 related functions.
|
||||||
* funcitons.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,7 @@
|
||||||
# include "vcd_priv.h"
|
# include "vcd_priv.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file contains the implementations of the VCD related
|
* This file contains the implementations of the VCD related functions.
|
||||||
* funcitons.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
|
|
@ -496,11 +495,11 @@ 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;
|
||||||
|
|
||||||
const char* type;
|
const char *type;
|
||||||
const char* name;
|
const char *name;
|
||||||
const char* fullname;
|
const char *fullname;
|
||||||
const char* prefix;
|
const char *prefix;
|
||||||
const char* ident;
|
const char *ident;
|
||||||
int nexus_id;
|
int nexus_id;
|
||||||
unsigned size;
|
unsigned size;
|
||||||
PLI_INT32 item_type;
|
PLI_INT32 item_type;
|
||||||
|
|
@ -598,7 +597,6 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
|
||||||
|
|
||||||
case vpiNamedEvent:
|
case vpiNamedEvent:
|
||||||
case vpiIntegerVar:
|
case vpiIntegerVar:
|
||||||
// case vpiParameter:
|
|
||||||
case vpiRealVar:
|
case vpiRealVar:
|
||||||
case vpiMemoryWord:
|
case vpiMemoryWord:
|
||||||
case vpiReg:
|
case vpiReg:
|
||||||
|
|
@ -661,8 +659,7 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
|
||||||
type, size, ident, prefix, name);
|
type, size, ident, prefix, name);
|
||||||
|
|
||||||
/* Add a range for vectored values. */
|
/* Add a range for vectored values. */
|
||||||
if (vpi_get(vpiSize, item) > 1
|
if (size > 1 || vpi_get(vpiLeftRange, item) != 0) {
|
||||||
|| vpi_get(vpiLeftRange, item) != 0) {
|
|
||||||
fprintf(dump_file, " [%i:%i]",
|
fprintf(dump_file, " [%i:%i]",
|
||||||
(int)vpi_get(vpiLeftRange, item),
|
(int)vpi_get(vpiLeftRange, item),
|
||||||
(int)vpi_get(vpiRightRange, item));
|
(int)vpi_get(vpiRightRange, item));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue