Make the dumpers match better (VCD, LXT, LXT2).

This patch removes some of the unneeded differences in the
various dumper routines. This is the start of a complete
refactoring, but the first task is to make them as common
as possible and this is the start of that.
This commit is contained in:
Cary R 2009-06-16 13:55:30 -07:00 committed by Stephen Williams
parent 63c7285113
commit 6146a98278
3 changed files with 92 additions and 96 deletions

View File

@ -17,10 +17,9 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
# include "sys_priv.h"
# include "lxt_write.h" # include "lxt_write.h"
# include "vcd_priv.h"
# include "sys_priv.h" # include "sys_priv.h"
# include "vcd_priv.h"
/* /*
* This file contains the implementations of the LXT related * This file contains the implementations of the LXT related
@ -39,6 +38,29 @@
# include "stringheap.h" # include "stringheap.h"
static char *dump_path = NULL;
static struct lt_trace *dump_file = NULL;
struct vcd_info {
vpiHandle item;
vpiHandle cb;
struct t_vpi_time time;
struct lt_symbol *sym;
struct vcd_info *next;
struct vcd_info *dmp_next;
int scheduled;
};
static struct vcd_info *vcd_list = NULL;
static struct vcd_info *vcd_dmp_list = NULL;
static PLI_UINT64 vcd_cur_time = 0;
static int dump_is_off = 0;
static long dump_limit = 0;
static int dump_is_full = 0;
static int finish_status = 0;
static enum lxm_optimum_mode_e { static enum lxm_optimum_mode_e {
LXM_NONE = 0, LXM_NONE = 0,
LXM_SPACE = 1, LXM_SPACE = 1,
@ -140,30 +162,6 @@ static char *create_full_name(const char *name)
return n; return n;
} }
static char *dump_path = 0;
static struct lt_trace *dump_file = 0;
struct vcd_info {
vpiHandle item;
vpiHandle cb;
struct t_vpi_time time;
struct lt_symbol *sym;
struct vcd_info *next;
struct vcd_info *dmp_next;
int scheduled;
};
static struct vcd_info*vcd_list = 0;
static struct vcd_info*vcd_dmp_list = 0;
static PLI_UINT64 vcd_cur_time = 0;
static int dump_is_off = 0;
static long dump_limit = 0;
static int dump_is_full = 0;
static int finish_status = 0;
static void show_this_item(struct vcd_info*info) static void show_this_item(struct vcd_info*info)
{ {
s_vpi_value value; s_vpi_value value;
@ -434,7 +432,8 @@ static PLI_INT32 sys_dumpall_calltf(PLI_BYTE8*name)
static void *close_dumpfile(void) static void *close_dumpfile(void)
{ {
lt_close(dump_file); lt_close(dump_file);
return (dump_file = NULL); dump_file = NULL;
return NULL;
} }
static void open_dumpfile(vpiHandle callh) static void open_dumpfile(vpiHandle callh)
@ -552,7 +551,7 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
case vpiNet: type = "wire"; if(0){ case vpiNet: type = "wire"; if(0){
case vpiMemoryWord: case vpiMemoryWord:
if (vpi_get(vpiConstantSelect, item) == 0) { if (vpi_get(vpiConstantSelect, item) == 0) {
/* Turn a non-constant array word select into a /* Turn a non-constant array word select into a
* constant word select. */ * constant word select. */
vpiHandle array = vpi_handle(vpiParent, item); vpiHandle array = vpi_handle(vpiParent, item);
@ -592,12 +591,12 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
info = malloc(sizeof(*info)); info = malloc(sizeof(*info));
info->time.type = vpiSimTime; info->time.type = vpiSimTime;
info->item = item; info->item = item;
info->sym = lt_symbol_add(dump_file, ident, info->sym = lt_symbol_add(dump_file, ident,
0 /* array rows */, 0 /* array rows */,
vpi_get(vpiLeftRange, item), vpi_get(vpiLeftRange, item),
vpi_get(vpiRightRange, item), vpi_get(vpiRightRange, item),
LT_SYM_F_BITS); LT_SYM_F_BITS);
info->scheduled = 0; info->scheduled = 0;
cb.time = &info->time; cb.time = &info->time;

View File

@ -17,10 +17,9 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
# include "sys_priv.h"
# include "lxt2_write.h" # include "lxt2_write.h"
# include "vcd_priv.h"
# include "sys_priv.h" # include "sys_priv.h"
# include "vcd_priv.h"
/* /*
* This file contains the implementations of the LXT2 related * This file contains the implementations of the LXT2 related
@ -39,6 +38,29 @@
# include "stringheap.h" # include "stringheap.h"
static char *dump_path = NULL;
static struct lxt2_wr_trace *dump_file = NULL;
struct vcd_info {
vpiHandle item;
vpiHandle cb;
struct t_vpi_time time;
struct lxt2_wr_symbol *sym;
struct vcd_info *next;
struct vcd_info *dmp_next;
int scheduled;
};
static struct vcd_info *vcd_list = NULL;
static struct vcd_info *vcd_dmp_list = NULL;
static PLI_UINT64 vcd_cur_time = 0;
static int dump_is_off = 0;
static long dump_limit = 0;
static int dump_is_full = 0;
static int finish_status = 0;
static enum lxm_optimum_mode_e { static enum lxm_optimum_mode_e {
LXM_NONE = 0, LXM_NONE = 0,
LXM_SPACE = 1, LXM_SPACE = 1,
@ -141,30 +163,6 @@ static char *create_full_name(const char *name)
return n; return n;
} }
static char *dump_path = 0;
static struct lxt2_wr_trace *dump_file = 0;
struct vcd_info {
vpiHandle item;
vpiHandle cb;
struct t_vpi_time time;
struct lxt2_wr_symbol *sym;
struct vcd_info *next;
struct vcd_info *dmp_next;
int scheduled;
};
static struct vcd_info*vcd_list = 0;
static struct vcd_info*vcd_dmp_list = 0;
static PLI_UINT64 vcd_cur_time = 0;
static int dump_is_off = 0;
static long dump_limit = 0;
static int dump_is_full = 0;
static int finish_status = 0;
static void show_this_item(struct vcd_info*info) static void show_this_item(struct vcd_info*info)
{ {
s_vpi_value value; s_vpi_value value;
@ -436,8 +434,8 @@ static PLI_INT32 sys_dumpall_calltf(PLI_BYTE8*name)
static void *close_dumpfile(void) static void *close_dumpfile(void)
{ {
lxt2_wr_close(dump_file); lxt2_wr_close(dump_file);
dump_file = 0; dump_file = NULL;
return 0; return NULL;
} }
static void open_dumpfile(vpiHandle callh) static void open_dumpfile(vpiHandle callh)
@ -604,12 +602,12 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
info = malloc(sizeof(*info)); info = malloc(sizeof(*info));
info->time.type = vpiSimTime; info->time.type = vpiSimTime;
info->item = item; info->item = item;
info->sym = lxt2_wr_symbol_add(dump_file, ident, info->sym = lxt2_wr_symbol_add(dump_file, ident,
0 /* array rows */, 0 /* array rows */,
vpi_get(vpiLeftRange, item), vpi_get(vpiLeftRange, item),
vpi_get(vpiRightRange, item), vpi_get(vpiRightRange, item),
LXT2_WR_SYM_F_BITS); LXT2_WR_SYM_F_BITS);
info->scheduled = 0; info->scheduled = 0;
cb.time = &info->time; cb.time = &info->time;

View File

@ -18,6 +18,7 @@
*/ */
# include "sys_priv.h" # include "sys_priv.h"
# include "vcd_priv.h"
/* /*
* This file contains the implementations of the VCD related * This file contains the implementations of the VCD related
@ -33,10 +34,29 @@
#ifdef HAVE_MALLOC_H #ifdef HAVE_MALLOC_H
# include <malloc.h> # include <malloc.h>
#endif #endif
# include "vcd_priv.h"
static char*dump_path = 0; static char *dump_path = NULL;
static FILE*dump_file = 0; static FILE *dump_file = NULL;
struct vcd_info {
vpiHandle item;
vpiHandle cb;
struct t_vpi_time time;
const char *ident;
struct vcd_info *next;
struct vcd_info *dmp_next;
int scheduled;
};
static struct vcd_info *vcd_list = NULL;
static struct vcd_info *vcd_dmp_list = NULL;
static PLI_UINT64 vcd_cur_time = 0;
static int dump_is_off = 0;
static long dump_limit = 0;
static int dump_is_full = 0;
static int finish_status = 0;
static const char*units_names[] = { static const char*units_names[] = {
"s", "s",
@ -47,17 +67,6 @@ static const char*units_names[] = {
"fs" "fs"
}; };
struct vcd_info {
vpiHandle item;
vpiHandle cb;
struct t_vpi_time time;
const char*ident;
struct vcd_info* next;
struct vcd_info* dmp_next;
int scheduled;
};
static char vcdid[8] = "!"; static char vcdid[8] = "!";
static void gen_new_vcd_id(void) static void gen_new_vcd_id(void)
@ -76,14 +85,6 @@ static void gen_new_vcd_id(void)
} }
} }
static struct vcd_info *vcd_list = 0;
static struct vcd_info *vcd_dmp_list = 0;
PLI_UINT64 vcd_cur_time = 0;
static int dump_is_off = 0;
static long dump_limit = 0;
static int dump_is_full = 0;
static int finish_status = 0;
static char *truncate_bitvec(char *s) static char *truncate_bitvec(char *s)
{ {
char l, r; char l, r;
@ -480,7 +481,6 @@ static PLI_INT32 sys_dumplimit_calltf(PLI_BYTE8 *name)
s_vpi_value val; s_vpi_value val;
/* Get the value and set the dump limit. */ /* Get the value and set the dump limit. */
assert(argv);
val.format = vpiIntVal; val.format = vpiIntVal;
vpi_get_value(vpi_scan(argv), &val); vpi_get_value(vpi_scan(argv), &val);
dump_limit = val.value.integer; dump_limit = val.value.integer;
@ -520,13 +520,13 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
case vpiNet: type = "wire"; if(0){ case vpiNet: type = "wire"; if(0){
case vpiMemoryWord: case vpiMemoryWord:
if (vpi_get(vpiConstantSelect, item) == 0) { if (vpi_get(vpiConstantSelect, item) == 0) {
/* Turn a non-constant array word select into a /* Turn a non-constant array word select into a
* constant word select. */ * constant word select. */
vpiHandle array = vpi_handle(vpiParent, item); vpiHandle array = vpi_handle(vpiParent, item);
PLI_INT32 index = vpi_get(vpiIndex, item); PLI_INT32 index = vpi_get(vpiIndex, item);
item = vpi_handle_by_index(array, index); item = vpi_handle_by_index(array, index);
} }
case vpiIntegerVar: case vpiIntegerVar:
case vpiTimeVar: case vpiTimeVar:
case vpiReg: type = "reg"; } case vpiReg: type = "reg"; }
@ -581,9 +581,8 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
cb.reason = cbValueChange; cb.reason = cbValueChange;
cb.cb_rtn = variable_cb_1; cb.cb_rtn = variable_cb_1;
info->dmp_next = 0;
info->next = vcd_list; info->next = vcd_list;
info->dmp_next = 0;
vcd_list = info; vcd_list = info;
info->cb = vpi_register_cb(&cb); info->cb = vpi_register_cb(&cb);