From 6146a98278ac40932f4e6c73caacce064ef91f80 Mon Sep 17 00:00:00 2001 From: Cary R Date: Tue, 16 Jun 2009 13:55:30 -0700 Subject: [PATCH] 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. --- vpi/sys_lxt.c | 67 +++++++++++++++++++++++++------------------------- vpi/sys_lxt2.c | 66 ++++++++++++++++++++++++------------------------- vpi/sys_vcd.c | 55 ++++++++++++++++++++--------------------- 3 files changed, 92 insertions(+), 96 deletions(-) diff --git a/vpi/sys_lxt.c b/vpi/sys_lxt.c index a784a4643..eb53451a3 100644 --- a/vpi/sys_lxt.c +++ b/vpi/sys_lxt.c @@ -17,10 +17,9 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -# include "sys_priv.h" # include "lxt_write.h" -# include "vcd_priv.h" # include "sys_priv.h" +# include "vcd_priv.h" /* * This file contains the implementations of the LXT related @@ -39,6 +38,29 @@ # 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 { LXM_NONE = 0, LXM_SPACE = 1, @@ -140,30 +162,6 @@ static char *create_full_name(const char *name) 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) { s_vpi_value value; @@ -434,7 +432,8 @@ static PLI_INT32 sys_dumpall_calltf(PLI_BYTE8*name) static void *close_dumpfile(void) { lt_close(dump_file); - return (dump_file = NULL); + dump_file = NULL; + return NULL; } 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 vpiMemoryWord: - if (vpi_get(vpiConstantSelect, item) == 0) { + if (vpi_get(vpiConstantSelect, item) == 0) { /* Turn a non-constant array word select into a * constant word select. */ 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->time.type = vpiSimTime; - info->item = item; - info->sym = lt_symbol_add(dump_file, ident, - 0 /* array rows */, - vpi_get(vpiLeftRange, item), - vpi_get(vpiRightRange, item), - LT_SYM_F_BITS); + info->item = item; + info->sym = lt_symbol_add(dump_file, ident, + 0 /* array rows */, + vpi_get(vpiLeftRange, item), + vpi_get(vpiRightRange, item), + LT_SYM_F_BITS); info->scheduled = 0; cb.time = &info->time; diff --git a/vpi/sys_lxt2.c b/vpi/sys_lxt2.c index 016aeb8c2..5eddf6ad4 100644 --- a/vpi/sys_lxt2.c +++ b/vpi/sys_lxt2.c @@ -17,10 +17,9 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -# include "sys_priv.h" # include "lxt2_write.h" -# include "vcd_priv.h" # include "sys_priv.h" +# include "vcd_priv.h" /* * This file contains the implementations of the LXT2 related @@ -39,6 +38,29 @@ # 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 { LXM_NONE = 0, LXM_SPACE = 1, @@ -141,30 +163,6 @@ static char *create_full_name(const char *name) 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) { s_vpi_value value; @@ -436,8 +434,8 @@ static PLI_INT32 sys_dumpall_calltf(PLI_BYTE8*name) static void *close_dumpfile(void) { lxt2_wr_close(dump_file); - dump_file = 0; - return 0; + dump_file = NULL; + return NULL; } 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->time.type = vpiSimTime; - info->item = item; - info->sym = lxt2_wr_symbol_add(dump_file, ident, - 0 /* array rows */, - vpi_get(vpiLeftRange, item), - vpi_get(vpiRightRange, item), - LXT2_WR_SYM_F_BITS); + info->item = item; + info->sym = lxt2_wr_symbol_add(dump_file, ident, + 0 /* array rows */, + vpi_get(vpiLeftRange, item), + vpi_get(vpiRightRange, item), + LXT2_WR_SYM_F_BITS); info->scheduled = 0; cb.time = &info->time; diff --git a/vpi/sys_vcd.c b/vpi/sys_vcd.c index 12780d78c..6fbbfd95c 100644 --- a/vpi/sys_vcd.c +++ b/vpi/sys_vcd.c @@ -18,6 +18,7 @@ */ # include "sys_priv.h" +# include "vcd_priv.h" /* * This file contains the implementations of the VCD related @@ -33,10 +34,29 @@ #ifdef HAVE_MALLOC_H # include #endif -# include "vcd_priv.h" -static char*dump_path = 0; -static FILE*dump_file = 0; +static char *dump_path = NULL; +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[] = { "s", @@ -47,17 +67,6 @@ static const char*units_names[] = { "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 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) { char l, r; @@ -480,7 +481,6 @@ static PLI_INT32 sys_dumplimit_calltf(PLI_BYTE8 *name) s_vpi_value val; /* Get the value and set the dump limit. */ - assert(argv); val.format = vpiIntVal; vpi_get_value(vpi_scan(argv), &val); 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 vpiMemoryWord: - if (vpi_get(vpiConstantSelect, item) == 0) { + if (vpi_get(vpiConstantSelect, item) == 0) { /* Turn a non-constant array word select into a * constant word select. */ vpiHandle array = vpi_handle(vpiParent, item); PLI_INT32 index = vpi_get(vpiIndex, item); item = vpi_handle_by_index(array, index); - } + } case vpiIntegerVar: case vpiTimeVar: case vpiReg: type = "reg"; } @@ -581,9 +581,8 @@ static void scan_item(unsigned depth, vpiHandle item, int skip) cb.reason = cbValueChange; cb.cb_rtn = variable_cb_1; - - info->next = vcd_list; - info->dmp_next = 0; + info->dmp_next = 0; + info->next = vcd_list; vcd_list = info; info->cb = vpi_register_cb(&cb);