Clean up dump routines and support of MemoryWord dump.

This patch cleans up the dump routines and adds file and
line number information for errors. It also adds some of
the missing MemoryWord properties so they can now be
dumped and monitored correctly.
This commit is contained in:
Cary R 2008-06-03 17:12:27 -07:00 committed by Stephen Williams
parent 4010f6e710
commit d0e154b830
10 changed files with 221 additions and 334 deletions

View File

@ -1109,11 +1109,16 @@ static PLI_INT32 sys_monitor_calltf(PLI_BYTE8*name)
for (idx = 0 ; idx < monitor_info.nitems ; idx += 1) {
switch (vpi_get(vpiType, monitor_info.items[idx])) {
case vpiMemoryWord:
/*
* We only support constant selections. Make this
* better when we add a real compiletf routine.
*/
assert(vpi_get(vpiConstantSelect, monitor_info.items[idx]));
case vpiNet:
case vpiReg:
case vpiIntegerVar:
case vpiRealVar:
case vpiMemoryWord:
/* Monitoring reg and net values involves setting
a callback for value changes. Pass the storage
pointer for the callback itself as user_data so

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002 Stephen Williams (steve@icarus.com)
* Copyright (c) 2002-2008 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -16,9 +16,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: sys_lxt.c,v 1.28 2007/03/14 04:05:51 steve Exp $"
#endif
# include "sys_priv.h"
# include "lxt_write.h"
@ -324,9 +321,9 @@ inline static int install_dumpvars_callback(void)
return 0;
if (dumpvars_status == 2) {
vpi_mcd_printf(1, "LXT warning:" " $dumpvars ignored, previously"
" called at simtime %" PLI_UINT64_FMT "\n",
dumpvars_time);
vpi_printf("LXT warning: $dumpvars ignored, previously"
" called at simtime %" PLI_UINT64_FMT "\n",
dumpvars_time);
return 1;
}
@ -431,22 +428,23 @@ static void *close_dumpfile(void)
return (dump_file = NULL);
}
static void open_dumpfile(void)
static void open_dumpfile(vpiHandle callh)
{
if (dump_path == 0) dump_path = strdup("dump.lxt");
dump_file = lt_init(dump_path);
if (dump_file == 0) {
vpi_mcd_printf(1, "LXT Error: Unable to open %s for output.\n",
dump_path);
vpi_printf("LXT Error: %s line %d: ", vpi_get_str(vpiFile, callh),
(int)vpi_get(vpiLineNo, callh));
vpi_printf("Unable to open %s for output.\n", dump_path);
vpi_control(vpiFinish, 1);
return;
} else {
int prec = vpi_get(vpiTimePrecision, 0);
vpi_mcd_printf(1, "LXT info: dumpfile %s opened for output.\n",
dump_path);
vpi_printf("LXT info: dumpfile %s opened for output.\n",
dump_path);
assert(prec >= -15);
lt_set_timescale(dump_file, prec);
@ -468,9 +466,9 @@ static PLI_INT32 sys_dumpfile_calltf(PLI_BYTE8*name)
/* $dumpfile must be called before $dumpvars starts! */
if (dumpvars_status != 0) {
vpi_mcd_printf(1, "LXT warning: %s called after $dumpvars started"
",\n using existing file (%s).\n",
name, dump_path);
vpi_printf("LXT warning: %s called after $dumpvars started,\n"
" using existing file (%s).\n",
name, dump_path);
return 0;
}
@ -480,8 +478,8 @@ static PLI_INT32 sys_dumpfile_calltf(PLI_BYTE8*name)
path = strdup(value.value.str);
if (dump_path) {
vpi_mcd_printf(1, "LXT warning: Overriding dump file %s with"
" %s\n", dump_path, path);
vpi_printf("LXT warning: Overriding dump file %s with %s\n",
dump_path, path);
free(dump_path);
}
dump_path = path;
@ -542,16 +540,9 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
switch (vpi_get(vpiType, item)) {
case vpiMemory:
/* don't know how to watch memories. */
break;
case vpiNamedEvent:
/* There is nothing in named events to dump. */
break;
case vpiNet: type = "wire"; if(0){
case vpiIntegerVar:
case vpiMemoryWord:
case vpiTimeVar:
case vpiReg: type = "reg"; }
@ -644,18 +635,16 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
vpi_get_str(vpiFullName, item);
#if 0
vpi_mcd_printf(1,
"LXT info:"
" scanning scope %s, %u levels\n",
fullname, depth);
vpi_printf("LXT info: scanning scope %s, %u levels\n",
fullname, depth);
#endif
nskip = 0 != vcd_names_search(&lxt_tab, fullname);
if (!nskip)
vcd_names_add(&lxt_tab, fullname);
else
vpi_mcd_printf(1, "LXT warning: ignoring signals in"
" previously scanned scope %s\n", fullname);
vpi_printf("LXT warning: ignoring signals in "
"previously scanned scope %s\n", fullname);
name = vpi_get_str(vpiName, item);
@ -674,8 +663,8 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
break;
default:
vpi_mcd_printf(1, "LXT warning: $dumpvars: Unsupported parameter"
" type (%d)\n", vpi_get(vpiType, item));
vpi_printf("LXT warning: $dumpvars: Unsupported parameter "
"type (%s)\n", vpi_get_str(vpiType, item));
}
}
@ -684,7 +673,6 @@ static int draw_scope(vpiHandle item)
{
int depth;
const char *name;
// char *type; // Not needed, see below.
vpiHandle scope = vpi_handle(vpiScope, item);
if (!scope)
@ -693,20 +681,6 @@ static int draw_scope(vpiHandle item)
depth = 1 + draw_scope(scope);
name = vpi_get_str(vpiName, scope);
#if 0 /* The type information is not needed by the LXT dumper. */
switch (vpi_get(vpiType, scope)) {
case vpiNamedBegin: type = "begin"; break;
case vpiTask: type = "task"; break;
case vpiFunction: type = "function"; break;
case vpiNamedFork: type = "fork"; break;
case vpiModule: type = "module"; break;
default:
vpi_mcd_printf(1, "LXT Error: $dumpvars: Unsupported scope "
"type (%d)\n", vpi_get(vpiType, item));
assert(0);
}
#endif
push_scope(name);
return depth;
@ -721,7 +695,7 @@ static PLI_INT32 sys_dumpvars_calltf(PLI_BYTE8*name)
unsigned depth = 0;
if (dump_file == 0) {
open_dumpfile();
open_dumpfile(callh);
if (dump_file == 0) return 0;
}
@ -784,7 +758,7 @@ void sys_lxt_register()
tf_data.type = vpiSysTask;
tf_data.tfname = "$dumpall";
tf_data.calltf = sys_dumpall_calltf;
tf_data.compiletf = sys_dumpall_compiletf;
tf_data.compiletf = sys_no_arg_compiletf;
tf_data.sizetf = 0;
tf_data.user_data = "$dumpall";
vpi_register_systf(&tf_data);
@ -800,7 +774,7 @@ void sys_lxt_register()
tf_data.type = vpiSysTask;
tf_data.tfname = "$dumpflush";
tf_data.calltf = sys_dumpflush_calltf;
tf_data.compiletf = sys_dumpflush_compiletf;
tf_data.compiletf = sys_no_arg_compiletf;
tf_data.sizetf = 0;
tf_data.user_data = "$dumpflush";
vpi_register_systf(&tf_data);
@ -816,7 +790,7 @@ void sys_lxt_register()
tf_data.type = vpiSysTask;
tf_data.tfname = "$dumpoff";
tf_data.calltf = sys_dumpoff_calltf;
tf_data.compiletf = sys_dumpoff_compiletf;
tf_data.compiletf = sys_no_arg_compiletf;
tf_data.sizetf = 0;
tf_data.user_data = "$dumpoff";
vpi_register_systf(&tf_data);
@ -824,7 +798,7 @@ void sys_lxt_register()
tf_data.type = vpiSysTask;
tf_data.tfname = "$dumpon";
tf_data.calltf = sys_dumpon_calltf;
tf_data.compiletf = sys_dumpon_compiletf;
tf_data.compiletf = sys_no_arg_compiletf;
tf_data.sizetf = 0;
tf_data.user_data = "$dumpon";
vpi_register_systf(&tf_data);
@ -837,4 +811,3 @@ void sys_lxt_register()
tf_data.user_data = "$dumpvars";
vpi_register_systf(&tf_data);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003-2004 Stephen Williams (steve@icarus.com)
* Copyright (c) 2003-2008 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -16,9 +16,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: sys_lxt2.c,v 1.10 2007/03/14 04:05:51 steve Exp $"
#endif
# include "sys_priv.h"
# include "lxt2_write.h"
@ -322,9 +319,9 @@ inline static int install_dumpvars_callback(void)
if (dumpvars_status == 1) return 0;
if (dumpvars_status == 2) {
vpi_mcd_printf(1, "LXT2 warning: $dumpvars ignored, previously"
" called at simtime %" PLI_UINT64_FMT "\n",
dumpvars_time);
vpi_printf("LXT2 warning: $dumpvars ignored, previously"
" called at simtime %" PLI_UINT64_FMT "\n",
dumpvars_time);
return 1;
}
@ -429,22 +426,23 @@ static void *close_dumpfile(void)
return 0;
}
static void open_dumpfile(void)
static void open_dumpfile(vpiHandle callh)
{
if (dump_path == 0) dump_path = strdup("dump.lx2");
dump_file = lxt2_wr_init(dump_path);
if (dump_file == 0) {
vpi_mcd_printf(1, "LXT2 Error: Unable to open %s for output.\n",
dump_path);
vpi_printf("LXT2 Error: %s line %d: ", vpi_get_str(vpiFile, callh),
(int)vpi_get(vpiLineNo, callh));
vpi_printf("Unable to open %s for output.\n", dump_path);
vpi_control(vpiFinish, 1);
return;
} else {
int prec = vpi_get(vpiTimePrecision, 0);
vpi_mcd_printf(1, "LXT2 info: dumpfile %s opened for output.\n",
dump_path);
vpi_printf("LXT2 info: dumpfile %s opened for output.\n",
dump_path);
assert(prec >= -15);
lxt2_wr_set_timescale(dump_file, prec);
@ -468,9 +466,9 @@ static PLI_INT32 sys_dumpfile_calltf(PLI_BYTE8*name)
/* $dumpfile must be called before $dumpvars starts! */
if (dumpvars_status != 0) {
vpi_mcd_printf(1, "LXT2 warning: %s called after $dumpvars started"
",\n using existing file (%s).\n",
name, dump_path);
vpi_printf("LXT2 warning: %s called after $dumpvars started,\n"
" using existing file (%s).\n",
name, dump_path);
return 0;
}
@ -480,8 +478,8 @@ static PLI_INT32 sys_dumpfile_calltf(PLI_BYTE8*name)
path = strdup(value.value.str);
if (dump_path) {
vpi_mcd_printf(1, "LXT2 warning: Overriding dump file %s with"
" %s.\n", dump_path, path);
vpi_printf("LXT2 warning: Overriding dump file %s with %s.\n",
dump_path, path);
free(dump_path);
}
dump_path = path;
@ -548,16 +546,9 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
switch (vpi_get(vpiType, item)) {
case vpiMemory:
/* don't know how to watch memories. */
break;
case vpiNamedEvent:
/* There is nothing in named events to dump. */
break;
case vpiNet: type = "wire"; if(0){
case vpiIntegerVar:
case vpiMemoryWord:
case vpiTimeVar:
case vpiReg: type = "reg"; }
@ -657,18 +648,16 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
vpi_get_str(vpiFullName, item);
#if 0
vpi_mcd_printf(1,
"LXT2 info:"
" scanning scope %s, %u levels\n",
fullname, depth);
vpi_printf("LXT2 info: scanning scope %s, %u levels\n",
fullname, depth);
#endif
nskip = 0 != vcd_names_search(&lxt_tab, fullname);
if (!nskip)
vcd_names_add(&lxt_tab, fullname);
else
vpi_mcd_printf(1, "LXT2 warning: ignoring signals in"
" previously scanned scope %s\n", fullname);
vpi_printf("LXT2 warning: ignoring signals in "
"previously scanned scope %s\n", fullname);
name = vpi_get_str(vpiName, item);
@ -687,8 +676,8 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
break;
default:
vpi_mcd_printf(1, "LXT2 warning: $dumpvars: Unsupported parameter"
" type (%d)\n", vpi_get(vpiType, item));
vpi_printf("LXT2 warning: $dumpvars: Unsupported parameter "
"type (%s)\n", vpi_get_str(vpiType, item));
}
}
@ -697,7 +686,6 @@ static int draw_scope(vpiHandle item)
{
int depth;
const char *name;
// char *type; // Not needed, see below.
vpiHandle scope = vpi_handle(vpiScope, item);
if (!scope) return 0;
@ -705,20 +693,6 @@ static int draw_scope(vpiHandle item)
depth = 1 + draw_scope(scope);
name = vpi_get_str(vpiName, scope);
#if 0 /* The type information is not needed by the LXT2 dumper. */
switch (vpi_get(vpiType, item)) {
case vpiNamedBegin: type = "begin"; break;
case vpiTask: type = "task"; break;
case vpiFunction: type = "function"; break;
case vpiNamedFork: type = "fork"; break;
case vpiModule: type = "module"; break;
default:
vpi_mcd_printf(1, "LXT2 Error: $dumpvars: Unsupported scope "
"type (%d)\n", vpi_get(vpiType, item));
assert(0);
}
#endif
push_scope(name);
return depth;
@ -733,7 +707,7 @@ static PLI_INT32 sys_dumpvars_calltf(PLI_BYTE8*name)
unsigned depth = 0;
if (dump_file == 0) {
open_dumpfile();
open_dumpfile(callh);
if (dump_file == 0) return 0;
}
@ -799,7 +773,7 @@ void sys_lxt2_register()
tf_data.type = vpiSysTask;
tf_data.tfname = "$dumpall";
tf_data.calltf = sys_dumpall_calltf;
tf_data.compiletf = sys_dumpall_compiletf;
tf_data.compiletf = sys_no_arg_compiletf;
tf_data.sizetf = 0;
tf_data.user_data = "$dumpall";
vpi_register_systf(&tf_data);
@ -815,7 +789,7 @@ void sys_lxt2_register()
tf_data.type = vpiSysTask;
tf_data.tfname = "$dumpflush";
tf_data.calltf = sys_dumpflush_calltf;
tf_data.compiletf = sys_dumpflush_compiletf;
tf_data.compiletf = sys_no_arg_compiletf;
tf_data.sizetf = 0;
tf_data.user_data = "$dumpflush";
vpi_register_systf(&tf_data);
@ -831,7 +805,7 @@ void sys_lxt2_register()
tf_data.type = vpiSysTask;
tf_data.tfname = "$dumpoff";
tf_data.calltf = sys_dumpoff_calltf;
tf_data.compiletf = sys_dumpoff_compiletf;
tf_data.compiletf = sys_no_arg_compiletf;
tf_data.sizetf = 0;
tf_data.user_data = "$dumpoff";
vpi_register_systf(&tf_data);
@ -839,7 +813,7 @@ void sys_lxt2_register()
tf_data.type = vpiSysTask;
tf_data.tfname = "$dumpon";
tf_data.calltf = sys_dumpon_calltf;
tf_data.compiletf = sys_dumpon_compiletf;
tf_data.compiletf = sys_no_arg_compiletf;
tf_data.sizetf = 0;
tf_data.user_data = "$dumpon";
vpi_register_systf(&tf_data);
@ -852,4 +826,3 @@ void sys_lxt2_register()
tf_data.user_data = "$dumpvars";
vpi_register_systf(&tf_data);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2003 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2008 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -16,9 +16,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: sys_vcd.c,v 1.58 2007/03/14 04:05:51 steve Exp $"
#endif
# include "sys_priv.h"
@ -269,9 +266,9 @@ inline static int install_dumpvars_callback(void)
if (dumpvars_status == 1) return 0;
if (dumpvars_status == 2) {
vpi_mcd_printf(1, "VCD warning: $dumpvars ignored, previously"
" called at simtime %" PLI_UINT64_FMT "\n",
dumpvars_time);
vpi_printf("VCD warning: $dumpvars ignored, previously"
" called at simtime %" PLI_UINT64_FMT "\n",
dumpvars_time);
return 1;
}
@ -374,15 +371,16 @@ static PLI_INT32 sys_dumpall_calltf(PLI_BYTE8*name)
return 0;
}
static void open_dumpfile(void)
static void open_dumpfile(vpiHandle callh)
{
if (dump_path == 0) dump_path = strdup("dump.vcd");
dump_file = fopen(dump_path, "w");
if (dump_file == 0) {
vpi_mcd_printf(1, "VCD Error: Unable to open %s for output.\n",
dump_path);
vpi_printf("VCD Error: %s line %d: ", vpi_get_str(vpiFile, callh),
(int)vpi_get(vpiLineNo, callh));
vpi_printf("Unable to open %s for output.\n", dump_path);
vpi_control(vpiFinish, 1);
return;
} else {
@ -391,8 +389,7 @@ static void open_dumpfile(void)
unsigned udx = 0;
time_t walltime;
vpi_mcd_printf(1, "VCD info: dumpfile %s opened for output.\n",
dump_path);
vpi_printf("VCD info: dumpfile %s opened for output.\n", dump_path);
time(&walltime);
@ -428,9 +425,9 @@ static PLI_INT32 sys_dumpfile_calltf(PLI_BYTE8*name)
/* $dumpfile must be called before $dumpvars starts! */
if (dumpvars_status != 0) {
vpi_mcd_printf(1, "VCD warning: %s called after $dumpvars started"
",\n using existing file (%s).\n",
name, dump_path);
vpi_printf("VCD warning: %s called after $dumpvars started,\n"
" using existing file (%s).\n",
name, dump_path);
return 0;
}
@ -440,8 +437,8 @@ static PLI_INT32 sys_dumpfile_calltf(PLI_BYTE8*name)
path = strdup(value.value.str);
if (dump_path) {
vpi_mcd_printf(1, "VCD warning: Overriding dump file %s with"
" %s\n", dump_path, path);
vpi_printf("VCD warning: Overriding dump file %s with %s\n",
dump_path, path);
free(dump_path);
}
dump_path = path;
@ -502,16 +499,9 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
switch (vpi_get(vpiType, item)) {
case vpiMemory:
/* don't know how to watch memories. */
break;
case vpiNamedEvent:
/* There is nothing in named events to dump. */
break;
case vpiNet: type = "wire"; if(0){
case vpiIntegerVar:
case vpiMemoryWord:
case vpiTimeVar:
case vpiReg: type = "reg"; }
@ -635,18 +625,16 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
vpi_get_str(vpiFullName, item);
#if 0
vpi_mcd_printf(1,
"VCD info:"
" scanning scope %s, %u levels\n",
fullname, depth);
vpi_printf("VCD info: scanning scope %s, %u levels\n",
fullname, depth);
#endif
nskip = 0 != vcd_names_search(&vcd_tab, fullname);
if (!nskip)
vcd_names_add(&vcd_tab, fullname);
else
vpi_mcd_printf(1, "VCD warning: ignoring signals in"
" previously scanned scope %s\n", fullname);
vpi_printf("VCD warning: ignoring signals in "
"previously scanned scope %s\n", fullname);
name = vpi_get_str(vpiName, item);
@ -665,12 +653,12 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
break;
default:
vpi_mcd_printf(1, "VCD warning: $dumpvars: Unsupported parameter "
"type (%d)\n", vpi_get(vpiType, item));
vpi_printf("VCD warning: $dumpvars: Unsupported parameter "
"type (%s)\n", vpi_get_str(vpiType, item));
}
}
static int draw_scope(vpiHandle item)
static int draw_scope(vpiHandle item, vpiHandle callh)
{
int depth;
const char *name;
@ -679,7 +667,7 @@ static int draw_scope(vpiHandle item)
vpiHandle scope = vpi_handle(vpiScope, item);
if (!scope) return 0;
depth = 1 + draw_scope(scope);
depth = 1 + draw_scope(scope, callh);
name = vpi_get_str(vpiName, scope);
switch (vpi_get(vpiType, scope)) {
@ -689,8 +677,9 @@ static int draw_scope(vpiHandle item)
case vpiNamedFork: type = "fork"; break;
case vpiModule: type = "module"; break;
default:
vpi_mcd_printf(1, "VCD Error: $dumpvars: Unsupported scope "
"type (%d)\n", vpi_get(vpiType, item));
vpi_printf("VCD Error: %s line %d: $dumpvars: Unsupported scope "
"type (%d)\n", vpi_get_str(vpiFile, callh),
(int)vpi_get(vpiLineNo, callh), vpi_get(vpiType, item));
assert(0);
}
@ -708,7 +697,7 @@ static PLI_INT32 sys_dumpvars_calltf(PLI_BYTE8*name)
unsigned depth = 0;
if (dump_file == 0) {
open_dumpfile();
open_dumpfile(callh);
if (dump_file == 0) return 0;
}
@ -739,23 +728,23 @@ static PLI_INT32 sys_dumpvars_calltf(PLI_BYTE8*name)
* been included. */
switch (vpi_get(vpiType, item)) {
case vpiIntegerVar:
/* What about MemoryWord? */
case vpiMemoryWord:
case vpiNet:
case vpiRealVar:
case vpiReg:
case vpiTimeVar:
scname = vpi_get_str(vpiFullName, vpi_handle(vpiScope, item));
if (vcd_names_search(&vcd_tab, scname)) {
vpi_mcd_printf(1, "VCD warning: skipping signal %s, "
"it was previously included.\n",
vpi_get_str(vpiFullName, item));
vpi_printf("VCD warning: skipping signal %s, "
"it was previously included.\n",
vpi_get_str(vpiFullName, item));
continue;
} else {
add_var = 1;
}
}
int dep = draw_scope(item);
int dep = draw_scope(item, callh);
scan_item(depth, item, 0);
@ -782,7 +771,7 @@ void sys_vcd_register()
tf_data.type = vpiSysTask;
tf_data.tfname = "$dumpall";
tf_data.calltf = sys_dumpall_calltf;
tf_data.compiletf = sys_dumpall_compiletf;
tf_data.compiletf = sys_no_arg_compiletf;
tf_data.sizetf = 0;
tf_data.user_data = "$dumpall";
vpi_register_systf(&tf_data);
@ -798,7 +787,7 @@ void sys_vcd_register()
tf_data.type = vpiSysTask;
tf_data.tfname = "$dumpflush";
tf_data.calltf = sys_dumpflush_calltf;
tf_data.compiletf = sys_dumpflush_compiletf;
tf_data.compiletf = sys_no_arg_compiletf;
tf_data.sizetf = 0;
tf_data.user_data = "$dumpflush";
vpi_register_systf(&tf_data);
@ -814,7 +803,7 @@ void sys_vcd_register()
tf_data.type = vpiSysTask;
tf_data.tfname = "$dumpoff";
tf_data.calltf = sys_dumpoff_calltf;
tf_data.compiletf = sys_dumpoff_compiletf;
tf_data.compiletf = sys_no_arg_compiletf;
tf_data.sizetf = 0;
tf_data.user_data = "$dumpoff";
vpi_register_systf(&tf_data);
@ -822,7 +811,7 @@ void sys_vcd_register()
tf_data.type = vpiSysTask;
tf_data.tfname = "$dumpon";
tf_data.calltf = sys_dumpon_calltf;
tf_data.compiletf = sys_dumpon_compiletf;
tf_data.compiletf = sys_no_arg_compiletf;
tf_data.sizetf = 0;
tf_data.user_data = "$dumpon";
vpi_register_systf(&tf_data);
@ -835,4 +824,3 @@ void sys_vcd_register()
tf_data.user_data = "$dumpvars";
vpi_register_systf(&tf_data);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003 Stephen Williams (steve@icarus.com)
* Copyright (c) 2003-2008 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -16,9 +16,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: sys_vcdoff.c,v 1.5 2007/03/14 04:05:52 steve Exp $"
#endif
# include "sys_priv.h"
@ -40,7 +37,7 @@
static int dump_flag = 0;
static PLI_INT32 sys_dump_calltf(PLI_BYTE8*name)
static PLI_INT32 sys_dummy_calltf(PLI_BYTE8*name)
{
return 0;
}
@ -48,7 +45,7 @@ static PLI_INT32 sys_dump_calltf(PLI_BYTE8*name)
static PLI_INT32 sys_dumpvars_calltf(PLI_BYTE8*name)
{
if (dump_flag == 0) {
vpi_mcd_printf(1, "VCD info: dumping is suppressed.\n");
vpi_printf("VCD info: dumping is suppressed.\n");
dump_flag = 1;
}
@ -63,15 +60,15 @@ void sys_vcdoff_register()
tf_data.type = vpiSysTask;
tf_data.tfname = "$dumpall";
tf_data.calltf = sys_dump_calltf;
tf_data.compiletf = sys_dumpall_compiletf;
tf_data.calltf = sys_dummy_calltf;
tf_data.compiletf = sys_no_arg_compiletf;
tf_data.sizetf = 0;
tf_data.user_data = "$dumpall";
vpi_register_systf(&tf_data);
tf_data.type = vpiSysTask;
tf_data.tfname = "$dumpfile";
tf_data.calltf = sys_dump_calltf;
tf_data.calltf = sys_dummy_calltf;
tf_data.compiletf = sys_dumpfile_compiletf;
tf_data.sizetf = 0;
tf_data.user_data = "$dumpfile";
@ -79,15 +76,15 @@ void sys_vcdoff_register()
tf_data.type = vpiSysTask;
tf_data.tfname = "$dumpflush";
tf_data.calltf = sys_dump_calltf;
tf_data.compiletf = sys_dumpflush_compiletf;
tf_data.calltf = sys_dummy_calltf;
tf_data.compiletf = sys_no_arg_compiletf;
tf_data.sizetf = 0;
tf_data.user_data = "$dumpflush";
vpi_register_systf(&tf_data);
tf_data.type = vpiSysTask;
tf_data.tfname = "$dumplimit";
tf_data.calltf = sys_dump_calltf;
tf_data.calltf = sys_dummy_calltf;
tf_data.compiletf = sys_dumplimit_compiletf;
tf_data.sizetf = 0;
tf_data.user_data = "$dumplimit";
@ -95,16 +92,16 @@ void sys_vcdoff_register()
tf_data.type = vpiSysTask;
tf_data.tfname = "$dumpoff";
tf_data.calltf = sys_dump_calltf;
tf_data.compiletf = sys_dumpoff_compiletf;
tf_data.calltf = sys_dummy_calltf;
tf_data.compiletf = sys_no_arg_compiletf;
tf_data.sizetf = 0;
tf_data.user_data = "$dumpoff";
vpi_register_systf(&tf_data);
tf_data.type = vpiSysTask;
tf_data.tfname = "$dumpon";
tf_data.calltf = sys_dump_calltf;
tf_data.compiletf = sys_dumpon_compiletf;
tf_data.calltf = sys_dummy_calltf;
tf_data.compiletf = sys_no_arg_compiletf;
tf_data.sizetf = 0;
tf_data.user_data = "$dumpon";
vpi_register_systf(&tf_data);
@ -117,4 +114,3 @@ void sys_vcdoff_register()
tf_data.user_data = "$dumpvars";
vpi_register_systf(&tf_data);
}

View File

@ -57,31 +57,29 @@ static PLI_INT32 simparam_compiletf(PLI_BYTE8* ud)
(int)vpi_get(vpiLineNo, callh));
vpi_printf("The first argument to $simparam%s must be a string.\n", ud);
vpi_control(vpiFinish, 1);
return 0;
}
/* The second argument (default value) is optional. */
arg = vpi_scan(argv);
if (arg == 0) return 0;
/* For the string version the default must also be a string. */
if (strcmp(ud, "$str") == 0) {
if (! is_string_obj(arg)) {
vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh),
(int)vpi_get(vpiLineNo, callh));
vpi_printf("When provided the second argument to $simparam%s"
vpi_printf("When provided, the second argument to $simparam%s"
"must be a string.\n", ud);
vpi_control(vpiFinish, 1);
return 0;
}
/* For the rest the default must be numeric. */
} else {
if (! is_numeric_obj(arg)) {
vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh),
(int)vpi_get(vpiLineNo, callh));
vpi_printf("When provided the second argument to $simparam%s"
vpi_printf("When provided, the second argument to $simparam%s"
"must be numeric.\n", ud);
vpi_control(vpiFinish, 1);
return 0;
}
}
@ -91,7 +89,6 @@ static PLI_INT32 simparam_compiletf(PLI_BYTE8* ud)
(int)vpi_get(vpiLineNo, callh));
vpi_printf("$simparam%s takes at most two arguments.\n", ud);
vpi_control(vpiFinish, 1);
return 0;
}
return 0;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003 Stephen Williams (steve@icarus.com)
* Copyright (c) 2003-2008 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -16,21 +16,19 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: vcd_priv.c,v 1.6 2004/10/04 01:10:58 steve Exp $"
#endif
# include "vpi_config.h"
# include "vcd_priv.h"
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# include <assert.h>
#include "vpi_config.h"
#include "vcd_priv.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#ifdef HAVE_MALLOC_H
# include <malloc.h>
#endif
# include <ctype.h>
# include "stringheap.h"
#include <ctype.h>
#include "stringheap.h"
#include <sys_priv.h>
int is_escaped_id(const char *name)
{
@ -188,86 +186,21 @@ void set_nexus_ident(int nex, const char *id)
vcd_ids[ihash(nex)] = bucket;
}
/* This is used by the compiletf routines to check if an argument
* is numeric. */
static void check_numeric_arg(vpiHandle arg, char *msg, PLI_BYTE8 *name)
{
assert(arg);
switch (vpi_get(vpiType, arg)) {
case vpiConstant:
case vpiParameter:
/* String constants are invalid numeric values. */
if (vpi_get(vpiConstType, arg) == vpiStringConst) {
vpi_mcd_printf(1, msg, name);
vpi_control(vpiFinish, 1);
}
break;
/* These have valid numeric values. */
case vpiIntegerVar:
case vpiMemoryWord:
case vpiNet:
case vpiRealVar:
case vpiReg:
case vpiTimeVar:
break;
default:
/* Anything else is not a numeric value. */
vpi_mcd_printf(1, msg, name);
vpi_control(vpiFinish, 1);
break;
}
}
/* This is used by the compiletf routines to check if an argument
* is a string value. */
static void check_string_arg(vpiHandle arg, char *msg, PLI_BYTE8 *name)
{
assert(arg);
PLI_INT32 ctype = 0;
switch (vpi_get(vpiType, arg)) {
case vpiConstant:
case vpiParameter:
/* These must be a string or binary constant. */
ctype = vpi_get(vpiConstType, arg);
if (ctype != vpiStringConst && ctype != vpiBinaryConst) {
vpi_mcd_printf(1, msg, name);
vpi_control(vpiFinish, 1);
}
break;
/* These have valid string values. */
case vpiIntegerVar:
case vpiMemoryWord:
case vpiNet:
case vpiReg:
case vpiTimeVar:
break;
default:
/* Anything else is not a string. */
vpi_mcd_printf(1, msg, name);
vpi_control(vpiFinish, 1);
break;
}
}
/*
* Since the compiletf routines are all the same they are located here,
* so we only need a single copy.
*/
/* $dumpall does not take an argument. */
PLI_INT32 sys_dumpall_compiletf(PLI_BYTE8 *name)
/* $dumpall, $dumpflush, $dumpoff and $dumpon do not take an argument. */
PLI_INT32 sys_no_arg_compiletf(PLI_BYTE8 *name)
{
vpiHandle callh = vpi_handle(vpiSysTfCall, 0);
vpiHandle argv = vpi_iterate(vpiArgument, callh);
if (argv != 0) {
vpi_mcd_printf(1, "ERROR: %s does not take an argument.\n", name);
vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh),
(int)vpi_get(vpiLineNo, callh));
vpi_printf("%s does not take an argument.\n", name);
vpi_control(vpiFinish, 1);
}
@ -282,31 +215,24 @@ PLI_INT32 sys_dumpfile_compiletf(PLI_BYTE8 *name)
/* Check that there is an argument and that it is a string. */
if (argv == 0) {
vpi_mcd_printf(1, "ERROR: %s requires an argument.\n", name);
vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh),
(int)vpi_get(vpiLineNo, callh));
vpi_printf("%s requires an argument.\n", name);
vpi_control(vpiFinish, 1);
return 0;
}
check_string_arg(vpi_scan(argv), "ERROR: %s's argument must be a"
" string.\n", name);
if (! is_string_obj(vpi_scan(argv))) {
vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh),
(int)vpi_get(vpiLineNo, callh));
vpi_printf("%s's argument must be a string.\n", name);
vpi_control(vpiFinish, 1);
}
/* Check that there is only a single argument. */
if (vpi_scan(argv) != 0) {
vpi_mcd_printf(1, "ERROR: %s takes a single argument.\n", name);
vpi_control(vpiFinish, 1);
return 0;
}
return 0;
}
/* $dumpflush does not take an argument. */
PLI_INT32 sys_dumpflush_compiletf(PLI_BYTE8 *name)
{
vpiHandle callh = vpi_handle(vpiSysTfCall, 0);
vpiHandle argv = vpi_iterate(vpiArgument, callh);
if (argv != 0) {
vpi_mcd_printf(1, "ERROR: %s does not take an argument.\n", name);
vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh),
(int)vpi_get(vpiLineNo, callh));
vpi_printf("%s takes a single argument.\n", name);
vpi_control(vpiFinish, 1);
}
@ -321,45 +247,25 @@ PLI_INT32 sys_dumplimit_compiletf(PLI_BYTE8 *name)
/* Check that there is an argument and that it is numeric. */
if (argv == 0) {
vpi_mcd_printf(1, "ERROR: %s requires an argument.\n", name);
vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh),
(int)vpi_get(vpiLineNo, callh));
vpi_printf("%s requires an argument.\n", name);
vpi_control(vpiFinish, 1);
return 0;
}
check_numeric_arg(vpi_scan(argv), "ERROR: %s's argument must be"
" numeric.\n", name);
if (! is_numeric_obj(vpi_scan(argv))) {
vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh),
(int)vpi_get(vpiLineNo, callh));
vpi_printf("%s's argument must be numeric.\n", name);
vpi_control(vpiFinish, 1);
}
/* Check that there is only a single argument. */
if (vpi_scan(argv) != 0) {
vpi_mcd_printf(1, "ERROR: %s takes a single argument.\n", name);
vpi_control(vpiFinish, 1);
return 0;
}
return 0;
}
/* $dumpoff does not take an argument. */
PLI_INT32 sys_dumpoff_compiletf(PLI_BYTE8 *name)
{
vpiHandle callh = vpi_handle(vpiSysTfCall, 0);
vpiHandle argv = vpi_iterate(vpiArgument, callh);
if (argv != 0) {
vpi_mcd_printf(1, "ERROR: %s does not take an argument.\n", name);
vpi_control(vpiFinish, 1);
}
return 0;
}
/* $dumpon does not take an argument. */
PLI_INT32 sys_dumpon_compiletf(PLI_BYTE8 *name)
{
vpiHandle callh = vpi_handle(vpiSysTfCall, 0);
vpiHandle argv = vpi_iterate(vpiArgument, callh);
if (argv != 0) {
vpi_mcd_printf(1, "ERROR: %s does not take an argument.\n", name);
vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh),
(int)vpi_get(vpiLineNo, callh));
vpi_printf("%s takes a single argument.\n", name);
vpi_control(vpiFinish, 1);
}
@ -374,16 +280,27 @@ PLI_INT32 sys_dumpvars_compiletf(PLI_BYTE8 *name)
vpiHandle arg;
/* No arguments is OK, dump everything. */
if (argv == 0)
return 0;
if (argv == 0) return 0;
/* The first argument is the numeric level. */
check_numeric_arg(vpi_scan(argv), "ERROR: %s's first argument must be"
" numeric.\n", name);
if (! is_numeric_obj(vpi_scan(argv))) {
vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh),
(int)vpi_get(vpiLineNo, callh));
vpi_printf("%s's argument must be numeric.\n", name);
vpi_control(vpiFinish, 1);
}
/* The rest of the arguments are either a module or a variable. */
while ((arg=vpi_scan(argv)) != NULL) {
switch(vpi_get(vpiType, arg)) {
case vpiMemoryWord:
if (vpi_get(vpiConstantSelect, arg) == 0) {
vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh),
(int)vpi_get(vpiLineNo, callh));
vpi_printf("%s cannot dump a non-constant select %s.\n", name,
vpi_get_str(vpiType, arg));
vpi_control(vpiFinish, 1);
}
/* The module types. */
case vpiModule:
case vpiTask:
@ -393,18 +310,18 @@ PLI_INT32 sys_dumpvars_compiletf(PLI_BYTE8 *name)
/* The variable types. */
case vpiNet:
case vpiReg:
case vpiMemoryWord:
case vpiIntegerVar:
case vpiTimeVar:
case vpiRealVar:
break;
default:
vpi_mcd_printf(1, "ERROR: %s cannot dump a %s.\n",
name, vpi_get_str(vpiType, arg));
vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh),
(int)vpi_get(vpiLineNo, callh));
vpi_printf("%s cannot dump a %s.\n", name,
vpi_get_str(vpiType, arg));
vpi_control(vpiFinish, 1);
}
}
return 0;
}

View File

@ -1,7 +1,7 @@
#ifndef __vcd_priv_H
#define __vcd_priv_H
/*
* Copyright (c) 2003 Stephen Williams (steve@icarus.com)
* Copyright (c) 2003-2008 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: vcd_priv.h,v 1.2 2003/02/13 18:13:28 steve Exp $"
#endif
#include "vpi_user.h"
@ -47,12 +44,9 @@ extern const char*find_nexus_ident(int nex);
extern void set_nexus_ident(int nex, const char *id);
/* The compiletf routines are common for the VCD, LXT and LXT2 dumpers. */
extern PLI_INT32 sys_dumpall_compiletf(PLI_BYTE8 *name);
extern PLI_INT32 sys_no_arg_compiletf(PLI_BYTE8 *name);
extern PLI_INT32 sys_dumpfile_compiletf(PLI_BYTE8 *name);
extern PLI_INT32 sys_dumpflush_compiletf(PLI_BYTE8 *name);
extern PLI_INT32 sys_dumplimit_compiletf(PLI_BYTE8 *name);
extern PLI_INT32 sys_dumpoff_compiletf(PLI_BYTE8 *name);
extern PLI_INT32 sys_dumpon_compiletf(PLI_BYTE8 *name);
extern PLI_INT32 sys_dumpvars_compiletf(PLI_BYTE8 *name);
#endif

View File

@ -125,8 +125,10 @@ static void vpi_array_var_word_get_value(vpiHandle, p_vpi_value);
static vpiHandle vpi_array_var_word_put_value(vpiHandle, p_vpi_value, int);
static int vpi_array_vthr_A_get(int code, vpiHandle);
static char*vpi_array_vthr_A_get_str(int code, vpiHandle);
static void vpi_array_vthr_A_get_value(vpiHandle, p_vpi_value);
static vpiHandle vpi_array_vthr_A_put_value(vpiHandle, p_vpi_value, int);
static vpiHandle vpi_array_vthr_A_get_handle(int code, vpiHandle ref);
static const struct __vpirt vpip_arraymem_rt = {
vpiMemory,
@ -181,10 +183,10 @@ static const struct __vpirt vpip_array_var_word_rt = {
static const struct __vpirt vpip_array_vthr_A_rt = {
vpiMemoryWord,
&vpi_array_vthr_A_get,
0,
&vpi_array_vthr_A_get_str,
&vpi_array_vthr_A_get_value,
&vpi_array_vthr_A_put_value,
0,
&vpi_array_vthr_A_get_handle,
0,
0,
0
@ -456,10 +458,31 @@ static int vpi_array_vthr_A_get(int code, vpiHandle ref)
assert(parent->vals);
return parent->vals_width;
// For now &A<> is only a constant select. This will need
// to be changed when it supports variable selection.
case vpiConstantSelect:
return 1;
default:
return 0;
}
}
static char*vpi_array_vthr_A_get_str(int code, vpiHandle ref)
{
struct __vpiArrayVthrA*obj = array_vthr_a_from_handle(ref);
assert(obj);
struct __vpiArray*parent = obj->array;
if (code == vpiFile) { // Not implemented for now!
return simple_set_rbuf_str(file_names[0]);
}
char index [64];
snprintf(index, 63, "%d", (int)obj->address + parent->first_addr.value);
return generic_get_str(code, &parent->scope->base, parent->name, index);
}
static void vpi_array_vthr_A_get_value(vpiHandle ref, p_vpi_value value)
{
struct __vpiArrayVthrA*obj = array_vthr_a_from_handle(ref);
@ -491,6 +514,21 @@ static vpiHandle vpi_array_vthr_A_put_value(vpiHandle ref, p_vpi_value vp, int)
return ref;
}
static vpiHandle vpi_array_vthr_A_get_handle(int code, vpiHandle ref)
{
struct __vpiArrayVthrA*obj = array_vthr_a_from_handle(ref);
assert(obj);
struct __vpiArray*parent = obj->array;
switch (code) {
case vpiScope:
return &parent->scope->base;
}
return 0;
}
void array_set_word(vvp_array_t arr,
unsigned address,

View File

@ -190,26 +190,32 @@ static const char* vpi_type_values(PLI_INT32 code)
switch (code) {
case vpiConstant:
return "vpiConstant";
case vpiFunction:
return "vpiFunction";
case vpiIntegerVar:
return "vpiIntegerVar";
case vpiIterator:
return "vpiIterator";
case vpiFunction:
return "vpiFunction";
case vpiMemory:
return "vpiMemory";
case vpiMemoryWord:
return "vpiMemoryWord";
case vpiModule:
return "vpiModule";
case vpiNet:
return "vpiNet";
case vpiParameter:
return "vpiParameter";
case vpiPartSelect:
return "vpiPartSelect";
case vpiRealVar:
return "vpiRealVar";
case vpiReg:
return "vpiReg";
case vpiTask:
return "vpiTask";
case vpiTimeVar:
return "vpiTimeVar";
default:
sprintf(buf, "%d", code);
}