Support default dumpfiles.
This commit is contained in:
parent
4e44515078
commit
53dfdacce8
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT) && !defined(macintosh)
|
#if !defined(WINNT) && !defined(macintosh)
|
||||||
#ident "$Id: sys_vcd.c,v 1.14 2001/01/01 08:10:35 steve Exp $"
|
#ident "$Id: sys_vcd.c,v 1.15 2001/01/22 20:58:31 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -216,6 +216,41 @@ static int sys_dumpall_calltf(char*name)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void open_dumpfile(const char*path)
|
||||||
|
{
|
||||||
|
if (dump_file == 0) {
|
||||||
|
vpi_printf("ERROR: Unable to open %s for output.\n", path);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
int prec = vpi_get(vpiTimePrecision, 0);
|
||||||
|
unsigned scale = 1;
|
||||||
|
unsigned udx = 0;
|
||||||
|
time_t walltime;
|
||||||
|
|
||||||
|
time(&walltime);
|
||||||
|
|
||||||
|
assert(prec >= -15);
|
||||||
|
while (prec < 0) {
|
||||||
|
udx += 1;
|
||||||
|
prec += 3;
|
||||||
|
}
|
||||||
|
while (prec > 0) {
|
||||||
|
scale *= 10;
|
||||||
|
prec -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(dump_file, "$date\n");
|
||||||
|
fprintf(dump_file, "\t%s",asctime(localtime(&walltime)));
|
||||||
|
fprintf(dump_file, "$end\n");
|
||||||
|
fprintf(dump_file, "$version\n");
|
||||||
|
fprintf(dump_file, "\tIcarus Verilog\n");
|
||||||
|
fprintf(dump_file, "$end\n");
|
||||||
|
fprintf(dump_file, "$timescale\n");
|
||||||
|
fprintf(dump_file, "\t%u%s\n", scale, units_names[udx]);
|
||||||
|
fprintf(dump_file, "$end\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int sys_dumpfile_calltf(char*name)
|
static int sys_dumpfile_calltf(char*name)
|
||||||
{
|
{
|
||||||
char*path;
|
char*path;
|
||||||
|
|
@ -248,38 +283,7 @@ static int sys_dumpfile_calltf(char*name)
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(dump_file == 0);
|
assert(dump_file == 0);
|
||||||
dump_file = fopen(path, "w");
|
open_dumpfile(path);
|
||||||
if (dump_file == 0) {
|
|
||||||
vpi_printf("ERROR: Unable to open %s for output.\n", path);
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
int prec = vpi_get(vpiTimePrecision, 0);
|
|
||||||
unsigned scale = 1;
|
|
||||||
unsigned udx = 0;
|
|
||||||
time_t walltime;
|
|
||||||
|
|
||||||
time(&walltime);
|
|
||||||
|
|
||||||
assert(prec >= -15);
|
|
||||||
while (prec < 0) {
|
|
||||||
udx += 1;
|
|
||||||
prec += 3;
|
|
||||||
}
|
|
||||||
while (prec > 0) {
|
|
||||||
scale *= 10;
|
|
||||||
prec -= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(dump_file, "$date\n");
|
|
||||||
fprintf(dump_file, "\t%s",asctime(localtime(&walltime)));
|
|
||||||
fprintf(dump_file, "$end\n");
|
|
||||||
fprintf(dump_file, "$version\n");
|
|
||||||
fprintf(dump_file, "\tIcarus Verilog\n");
|
|
||||||
fprintf(dump_file, "$end\n");
|
|
||||||
fprintf(dump_file, "$timescale\n");
|
|
||||||
fprintf(dump_file, "\t%u%s\n", scale, units_names[udx]);
|
|
||||||
fprintf(dump_file, "$end\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
|
|
@ -367,8 +371,14 @@ static int sys_dumpvars_calltf(char*name)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dump_file == 0) {
|
if (dump_file == 0) {
|
||||||
vpi_printf("ERROR: %s called but no dumpfile is opened.\n", name);
|
vpi_printf("warning: %s caused default dumpfile "
|
||||||
return 0;
|
"dumpfile.vcd to be opened.\n", name);
|
||||||
|
open_dumpfile("dumpfile.vcd");
|
||||||
|
if (dump_file == 0) {
|
||||||
|
vpi_printf("error: Unable to open "
|
||||||
|
"dumpfile.vcd for output.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
item = vpi_scan(argv);
|
item = vpi_scan(argv);
|
||||||
|
|
@ -432,6 +442,9 @@ void sys_vcd_register()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: sys_vcd.c,v $
|
* $Log: sys_vcd.c,v $
|
||||||
|
* Revision 1.15 2001/01/22 20:58:31 steve
|
||||||
|
* Support default dumpfiles.
|
||||||
|
*
|
||||||
* Revision 1.14 2001/01/01 08:10:35 steve
|
* Revision 1.14 2001/01/01 08:10:35 steve
|
||||||
* Handle function scopes in dumpvars scn (PR#95)
|
* Handle function scopes in dumpvars scn (PR#95)
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue