Arrange for mcd id=00_00_00_01 to go to stdout

as well as a user specified log file, set log
 file to buffer lines.

 Add vpi_flush function, and clear up some cunfused
 return codes from other vpi functions.

 Adjust $display and vcd/lxt messages to use the
 standard output/log file.
This commit is contained in:
steve 2003-05-15 16:51:08 +00:00
parent 04d32a4d4c
commit 2e3ce49400
7 changed files with 169 additions and 61 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: sys_display.c,v 1.59 2003/05/02 15:45:43 steve Exp $"
#ident "$Id: sys_display.c,v 1.60 2003/05/15 16:51:08 steve Exp $"
#endif
# include "config.h"
@ -899,10 +899,10 @@ static int sys_display_calltf(char *name)
vpi_put_userdata(sys, info);
}
do_display(5, info);
do_display(1, info);
if (strncmp(name,"$display",8) == 0)
vpi_mcd_printf(5, "\n");
vpi_mcd_printf(1, "\n");
return 0;
}
@ -1666,6 +1666,17 @@ void sys_display_register()
/*
* $Log: sys_display.c,v $
* Revision 1.60 2003/05/15 16:51:08 steve
* Arrange for mcd id=00_00_00_01 to go to stdout
* as well as a user specified log file, set log
* file to buffer lines.
*
* Add vpi_flush function, and clear up some cunfused
* return codes from other vpi functions.
*
* Adjust $display and vcd/lxt messages to use the
* standard output/log file.
*
* Revision 1.59 2003/05/02 15:45:43 steve
* Certain constants are allowed as mcd parameters.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: sys_lxt.c,v 1.20 2003/04/28 01:03:11 steve Exp $"
#ident "$Id: sys_lxt.c,v 1.21 2003/05/15 16:51:09 steve Exp $"
#endif
# include "config.h"
@ -290,7 +290,7 @@ inline static int install_dumpvars_callback(void)
return 0;
if (dumpvars_status == 2) {
vpi_mcd_printf(6, "VCD Error:"
vpi_mcd_printf(1, "VCD Error:"
" $dumpvars ignored,"
" previously called at simtime %lu\n",
dumpvars_time);
@ -396,14 +396,14 @@ static void open_dumpfile(const char*path)
dump_file = lt_init(path);
if (dump_file == 0) {
vpi_mcd_printf(6,
vpi_mcd_printf(1,
"LXT Error: Unable to open %s for output.\n",
path);
return;
} else {
int prec = vpi_get(vpiTimePrecision, 0);
vpi_mcd_printf(4,
vpi_mcd_printf(1,
"LXT info: dumpfile %s opened for output.\n",
path);
@ -430,7 +430,7 @@ static int sys_dumpfile_calltf(char*name)
if (vpi_get(vpiType, item) != vpiConstant
|| vpi_get(vpiConstType, item) != vpiStringConst) {
vpi_mcd_printf(6,
vpi_mcd_printf(1,
"LXT Error:"
" %s parameter must be a string constant\n",
name);
@ -590,17 +590,18 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
const char* fullname =
vpi_get_str(vpiFullName, item);
vpi_mcd_printf(4,
#if 0
vpi_mcd_printf(1,
"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(6,
vpi_mcd_printf(1,
"LXT warning:"
" ignoring signals"
" in previously scanned scope %s\n",
@ -623,7 +624,7 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
break;
default:
vpi_mcd_printf(6,
vpi_mcd_printf(1,
"LXT Error: $lxtdumpvars: Unsupported parameter "
"type (%d)\n", vpi_get(vpiType, item));
}
@ -793,6 +794,17 @@ void sys_lxt_register()
/*
* $Log: sys_lxt.c,v $
* Revision 1.21 2003/05/15 16:51:09 steve
* Arrange for mcd id=00_00_00_01 to go to stdout
* as well as a user specified log file, set log
* file to buffer lines.
*
* Add vpi_flush function, and clear up some cunfused
* return codes from other vpi functions.
*
* Adjust $display and vcd/lxt messages to use the
* standard output/log file.
*
* Revision 1.20 2003/04/28 01:03:11 steve
* Fix stringheap list management failure.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: sys_vcd.c,v 1.43 2003/04/27 02:22:28 steve Exp $"
#ident "$Id: sys_vcd.c,v 1.44 2003/05/15 16:51:09 steve Exp $"
#endif
# include "config.h"
@ -39,7 +39,6 @@
#endif
# include "vcd_priv.h"
static FILE*dump_file = 0;
static const char*units_names[] = {
@ -249,7 +248,7 @@ inline static int install_dumpvars_callback(void)
return 0;
if (dumpvars_status == 2) {
vpi_mcd_printf(6, "VCD Error:"
vpi_mcd_printf(1, "VCD Error:"
" $dumpvars ignored,"
" previously called at simtime %lu\n",
dumpvars_time);
@ -353,7 +352,7 @@ static void open_dumpfile(const char*path)
dump_file = fopen(path, "w");
if (dump_file == 0) {
vpi_mcd_printf(6,
vpi_mcd_printf(1,
"VCD Error: Unable to open %s for output.\n",
path);
return;
@ -363,7 +362,7 @@ static void open_dumpfile(const char*path)
unsigned udx = 0;
time_t walltime;
vpi_mcd_printf(4,
vpi_mcd_printf(1,
"VCD info: dumpfile %s opened for output.\n",
path);
@ -404,7 +403,7 @@ static int sys_dumpfile_calltf(char*name)
if (vpi_get(vpiType, item) != vpiConstant
|| vpi_get(vpiConstType, item) != vpiStringConst) {
vpi_mcd_printf(6,
vpi_mcd_printf(1,
"VCD Error:"
" %s parameter must be a string constant\n",
name);
@ -570,17 +569,18 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
const char* fullname =
vpi_get_str(vpiFullName, item);
vpi_mcd_printf(4,
#if 0
vpi_mcd_printf(1,
"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(6,
vpi_mcd_printf(1,
"VCD warning:"
" ignoring signals"
" in previously scanned scope %s\n",
@ -603,7 +603,7 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
break;
default:
vpi_mcd_printf(6,
vpi_mcd_printf(1,
"VCD Error: $dumpvars: Unsupported parameter "
"type (%d)\n", vpi_get(vpiType, item));
}
@ -793,6 +793,17 @@ void sys_vcd_register()
/*
* $Log: sys_vcd.c,v $
* Revision 1.44 2003/05/15 16:51:09 steve
* Arrange for mcd id=00_00_00_01 to go to stdout
* as well as a user specified log file, set log
* file to buffer lines.
*
* Add vpi_flush function, and clear up some cunfused
* return codes from other vpi functions.
*
* Adjust $display and vcd/lxt messages to use the
* standard output/log file.
*
* Revision 1.43 2003/04/27 02:22:28 steve
* Capture VCD dump value in the rosync time period.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: vpi_user.h,v 1.24 2003/04/20 02:49:07 steve Exp $"
#ident "$Id: vpi_user.h,v 1.25 2003/05/15 16:51:08 steve Exp $"
#endif
@ -215,19 +215,26 @@ typedef struct t_vpi_value {
/* VPI FUNCTIONS */
extern void vpi_register_systf(const struct t_vpi_systf_data*ss);
extern void vpi_printf(const char*fmt, ...)
/* I/O routines */
extern PLI_UINT32 vpi_mcd_open(char *name);
extern PLI_UINT32 vpi_mcd_close(PLI_UINT32 mcd);
extern char *vpi_mcd_name(PLI_UINT32 mcd);
extern PLI_INT32 vpi_mcd_printf(PLI_UINT32 mcd, const char*fmt, ...)
__attribute__((format (printf,2,3)));
extern PLI_INT32 vpi_printf(const char*fmt, ...)
__attribute__((format (printf,1,2)));
extern void vpi_vprintf(const char*fmt, va_list ap);
extern PLI_INT32 vpi_vprintf(const char*fmt, va_list ap);
extern PLI_INT32 vpi_mcd_vprintf(PLI_UINT32 mcd, const char*fmt, va_list ap);
extern PLI_INT32 vpi_flush(void);
extern PLI_INT32 vpi_mcd_flush(PLI_UINT32 mcd);
extern PLI_UINT32 vpi_mcd_close(unsigned int mcd);
extern char *vpi_mcd_name(PLI_UINT32 mcd);
extern PLI_UINT32 vpi_mcd_open(char *name);
extern PLI_UINT32 vpi_mcd_open_x(char *name, char *mode);
extern PLI_INT32 vpi_mcd_printf(unsigned int mcd, const char*fmt, ...)
__attribute__((format (printf,2,3)));
extern PLI_INT32 vpi_mcd_fputc(unsigned int mcd, unsigned char x);
extern PLI_INT32 vpi_mcd_fgetc(unsigned int mcd);
extern PLI_INT32 vpi_mcd_fputc(PLI_UINT32 mcd, unsigned char x);
extern PLI_INT32 vpi_mcd_fgetc(PLI_UINT32 mcd);
/*
* support for VPI callback functions.
@ -388,6 +395,17 @@ EXTERN_C_END
/*
* $Log: vpi_user.h,v $
* Revision 1.25 2003/05/15 16:51:08 steve
* Arrange for mcd id=00_00_00_01 to go to stdout
* as well as a user specified log file, set log
* file to buffer lines.
*
* Add vpi_flush function, and clear up some cunfused
* return codes from other vpi functions.
*
* Adjust $display and vcd/lxt messages to use the
* standard output/log file.
*
* Revision 1.24 2003/04/20 02:49:07 steve
* acc_fetch_value support for %v format.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: main.cc,v 1.35 2003/03/13 04:36:57 steve Exp $"
#ident "$Id: main.cc,v 1.36 2003/05/15 16:51:09 steve Exp $"
#endif
# include "config.h"
@ -191,12 +191,14 @@ int main(int argc, char*argv[])
if (logfile_name) {
if (!strcmp(logfile_name, "-"))
logfile = stderr;
else
else {
logfile = fopen(logfile_name, "w");
if (!logfile) {
perror(logfile_name);
exit(1);
}
setlinebuf(logfile);
}
}
if (verbose_flag) {
@ -285,6 +287,17 @@ int main(int argc, char*argv[])
/*
* $Log: main.cc,v $
* Revision 1.36 2003/05/15 16:51:09 steve
* Arrange for mcd id=00_00_00_01 to go to stdout
* as well as a user specified log file, set log
* file to buffer lines.
*
* Add vpi_flush function, and clear up some cunfused
* return codes from other vpi functions.
*
* Adjust $display and vcd/lxt messages to use the
* standard output/log file.
*
* Revision 1.35 2003/03/13 04:36:57 steve
* Remove the obsolete functor delete functions.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: vpi_mcd.cc,v 1.8 2002/08/12 01:35:09 steve Exp $"
#ident "$Id: vpi_mcd.cc,v 1.9 2003/05/15 16:51:09 steve Exp $"
#endif
# include "vpi_priv.h"
@ -27,12 +27,19 @@
# include <stdlib.h>
# include <string.h>
/*
* This table keeps track of the MCD files. Note that there may be
* only 31 such files, and mcd bit0 (32'h00_00_00_01) is the special
* standard output file, which may be replicated to a logfile
* depending on flags to the command line.
*/
struct mcd_entry {
FILE *fp;
char *filename;
};
static struct mcd_entry mcd_table[32];
static FILE* logfile;
/* Initialize mcd portion of vpi. Must be called before
* any vpi_mcd routines can be used.
@ -41,21 +48,19 @@ void vpi_mcd_init(FILE *log)
{
mcd_table[0].fp = stdout;
mcd_table[0].filename = "<stdout>";
mcd_table[1].fp = stderr;
mcd_table[1].filename = "<stderr>";
mcd_table[2].fp = log;
mcd_table[2].filename = "<stdlog>";
logfile = log;
}
/*
* close one or more channels. we silently refuse to close the preopened ones.
*/
unsigned int vpi_mcd_close(unsigned int mcd)
extern "C" PLI_UINT32 vpi_mcd_close(unsigned int mcd)
{
int i;
int rc;
rc = 0;
for(i = 3; i < 31; i++) {
for(i = 1; i < 31; i++) {
if( ((mcd>>i) & 1) && mcd_table[i].filename) {
if(fclose(mcd_table[i].fp) != 0)
rc |= 1<<i;
@ -69,7 +74,7 @@ unsigned int vpi_mcd_close(unsigned int mcd)
return rc;
}
char *vpi_mcd_name(unsigned int mcd)
extern "C" char *vpi_mcd_name(unsigned int mcd)
{
int i;
for(i = 0; i < 31; i++) {
@ -79,7 +84,7 @@ char *vpi_mcd_name(unsigned int mcd)
return NULL;
}
unsigned int vpi_mcd_open_x(char *name, char *mode)
extern "C" PLI_UINT32 vpi_mcd_open_x(char *name, char *mode)
{
int i;
for(i = 0; i < 31; i++) {
@ -96,27 +101,27 @@ got_entry:
return 1<<i;
}
unsigned int vpi_mcd_open(char *name)
extern "C" PLI_UINT32 vpi_mcd_open(char *name)
{
return vpi_mcd_open_x(name,"w");
}
extern "C" int vpi_mcd_vprintf(unsigned int mcd, const char*fmt, va_list ap)
extern "C" PLI_INT32
vpi_mcd_vprintf(unsigned int mcd, const char*fmt, va_list ap)
{
int i;
int len;
int rc;
// don't print to stderr twice
if (mcd_table[1].fp == mcd_table[2].fp && (mcd&6) == 6)
mcd &= ~2;
rc = len = 0;
for(i = 0; i < 31; i++) {
if( (mcd>>i) & 1) {
if(mcd_table[i].fp)
if(mcd_table[i].fp) {
// echo to logfile
if (i == 0 && logfile)
vfprintf(logfile, fmt, ap);
len = vfprintf(mcd_table[i].fp, fmt, ap);
else
} else
rc = EOF;
}
}
@ -127,7 +132,7 @@ extern "C" int vpi_mcd_vprintf(unsigned int mcd, const char*fmt, va_list ap)
return len;
}
extern "C" int vpi_mcd_printf(unsigned int mcd, const char *fmt, ...)
extern "C" PLI_INT32 vpi_mcd_printf(unsigned int mcd, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
@ -136,6 +141,16 @@ extern "C" int vpi_mcd_printf(unsigned int mcd, const char *fmt, ...)
return r;
}
extern "C" PLI_INT32 vpi_mcd_flush(unsigned int mcd)
{
int i, rc = 0;
for(i = 0; i < 31; i++) {
if( (mcd>>i) & 1)
if (fflush(mcd_table[i].fp)) rc |= 1<<i;
}
return rc;
}
int vpi_mcd_fputc(unsigned int mcd, unsigned char x)
{
int i;
@ -162,6 +177,17 @@ int vpi_mcd_fgetc(unsigned int mcd)
/*
* $Log: vpi_mcd.cc,v $
* Revision 1.9 2003/05/15 16:51:09 steve
* Arrange for mcd id=00_00_00_01 to go to stdout
* as well as a user specified log file, set log
* file to buffer lines.
*
* Add vpi_flush function, and clear up some cunfused
* return codes from other vpi functions.
*
* Adjust $display and vcd/lxt messages to use the
* standard output/log file.
*
* Revision 1.8 2002/08/12 01:35:09 steve
* conditional ident string using autoconfig.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: vpi_priv.cc,v 1.38 2003/05/15 01:24:46 steve Exp $"
#ident "$Id: vpi_priv.cc,v 1.39 2003/05/15 16:51:09 steve Exp $"
#endif
# include "vpi_priv.h"
@ -592,17 +592,23 @@ vpiHandle vpi_handle_by_name(const char *name, vpiHandle scope)
return 0;
}
extern "C" void vpi_vprintf(const char*fmt, va_list ap)
extern "C" PLI_INT32 vpi_vprintf(const char*fmt, va_list ap)
{
vprintf(fmt, ap);
return vpi_mcd_vprintf(1, fmt, ap);
}
extern "C" void vpi_printf(const char *fmt, ...)
extern "C" PLI_INT32 vpi_printf(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vpi_vprintf(fmt, ap);
int r = vpi_mcd_vprintf(1, fmt, ap);
va_end(ap);
return r;
}
extern "C" PLI_INT32 vpi_flush(void)
{
return vpi_mcd_flush(1);
}
@ -640,6 +646,17 @@ extern "C" void vpi_control(int operation, ...)
/*
* $Log: vpi_priv.cc,v $
* Revision 1.39 2003/05/15 16:51:09 steve
* Arrange for mcd id=00_00_00_01 to go to stdout
* as well as a user specified log file, set log
* file to buffer lines.
*
* Add vpi_flush function, and clear up some cunfused
* return codes from other vpi functions.
*
* Adjust $display and vcd/lxt messages to use the
* standard output/log file.
*
* Revision 1.38 2003/05/15 01:24:46 steve
* Return all 64bits of time in vpi_get_time.
*