Add vvp "quiet" flag (issue #1193)
This adds a "-q" option on the vvp command line and a vvp_set_quiet_flag() function in the VVP library API. Setting this flag will cause all output to standard output via MCD bit 0 to be suppressed. It will not prevent the output being sent to a log file if the vvp "-l" option has been used, and it will not affect output to the STDOUT file descriptor.
This commit is contained in:
parent
03835c9d50
commit
adb6a2f454
|
|
@ -68,6 +68,11 @@ void vvp_set_stop_is_finish(bool flag, int exit_code)
|
|||
stop_is_finish_exit_code = exit_code;
|
||||
}
|
||||
|
||||
void vvp_set_quiet_flag(bool flag)
|
||||
{
|
||||
vpip_mcd0_disable = flag;
|
||||
}
|
||||
|
||||
void vvp_set_verbose_flag(bool flag)
|
||||
{
|
||||
verbose_flag = flag;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,13 @@ extern "C" {
|
|||
|
||||
extern void vvp_set_stop_is_finish(bool flag, int exit_code);
|
||||
|
||||
/* vvp_set_quiet_flag(true) is equivalent to vvp's "-q" option.
|
||||
*
|
||||
* This function may be called at any time.
|
||||
*/
|
||||
|
||||
extern void vvp_set_quiet_flag(bool flag);
|
||||
|
||||
/* vvp_set_verbose(true) is equivalent to vvp's "-v" option.
|
||||
*
|
||||
* This function may be called at any time.
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ int main(int argc, char*argv[])
|
|||
unsigned flag_errors = 0;
|
||||
const char *logfile_name = 0x0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "+hil:M:m:nNsvV")) != EOF) switch (opt) {
|
||||
while ((opt = getopt(argc, argv, "+hil:M:m:nNqsvV")) != EOF) switch (opt) {
|
||||
case 'h':
|
||||
fprintf(stderr,
|
||||
"Usage: vvp [options] input-file [+plusargs...]\n"
|
||||
|
|
@ -66,6 +66,7 @@ int main(int argc, char*argv[])
|
|||
" -m module Load vpi module.\n"
|
||||
" -n Non-interactive ($stop = $finish).\n"
|
||||
" -N Same as -n, but exit code is 1 instead of 0\n"
|
||||
" -q Quiet mode (suppress output on MCD bit 0).\n"
|
||||
" -s $stop right away.\n"
|
||||
" -v Verbose progress messages.\n"
|
||||
" -V Print the version information.\n" );
|
||||
|
|
@ -92,6 +93,9 @@ int main(int argc, char*argv[])
|
|||
case 'N':
|
||||
vvp_set_stop_is_finish(true, 1);
|
||||
break;
|
||||
case 'q':
|
||||
vvp_set_quiet_flag(true);
|
||||
break;
|
||||
case 's':
|
||||
schedule_stop(0);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000-2020 Stephen G. Tell <steve@telltronics.org>
|
||||
* Copyright (c) 2000-2024 Stephen G. Tell <steve@telltronics.org>
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
|
|
@ -34,8 +34,8 @@ extern FILE* vpi_trace;
|
|||
/*
|
||||
* 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.
|
||||
* standard output file, which may be replicated to a logfile and/or
|
||||
* suppressed depending on flags to the command line.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
|
@ -55,6 +55,8 @@ static unsigned fd_table_len = 0;
|
|||
|
||||
static FILE* logfile;
|
||||
|
||||
bool vpip_mcd0_disable = false;
|
||||
|
||||
/* Initialize mcd portion of vpi. Must be called before
|
||||
* any vpi_mcd routines can be used.
|
||||
*/
|
||||
|
|
@ -217,9 +219,12 @@ vpi_mcd_vprintf(PLI_UINT32 mcd, const char*fmt, va_list ap)
|
|||
for(int i = 0; i < 31; i++) {
|
||||
if((mcd>>i) & 1) {
|
||||
if(mcd_table[i].fp) {
|
||||
// echo to logfile
|
||||
if (i == 0 && logfile)
|
||||
if (i == 0) {
|
||||
if (logfile)
|
||||
fputs(buf_ptr, logfile);
|
||||
if (vpip_mcd0_disable)
|
||||
continue;
|
||||
}
|
||||
fputs(buf_ptr, mcd_table[i].fp);
|
||||
} else {
|
||||
rc = EOF;
|
||||
|
|
@ -251,10 +256,13 @@ extern "C" void vpip_mcd_rawwrite(PLI_UINT32 mcd, const char*buf, size_t cnt)
|
|||
if (mcd_table[idx].fp == 0)
|
||||
continue;
|
||||
|
||||
fwrite(buf, 1, cnt, mcd_table[idx].fp);
|
||||
if (idx == 0 && logfile)
|
||||
if (idx == 0) {
|
||||
if (logfile)
|
||||
fwrite(buf, 1, cnt, logfile);
|
||||
|
||||
if (vpip_mcd0_disable)
|
||||
continue;
|
||||
}
|
||||
fwrite(buf, 1, cnt, mcd_table[idx].fp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -265,7 +273,12 @@ extern "C" PLI_INT32 vpi_mcd_flush(PLI_UINT32 mcd)
|
|||
if (IS_MCD(mcd)) {
|
||||
for(int i = 0; i < 31; i++) {
|
||||
if((mcd>>i) & 1) {
|
||||
if (i == 0 && logfile) fflush(logfile);
|
||||
if (i == 0) {
|
||||
if (logfile)
|
||||
fflush(logfile);
|
||||
if (vpip_mcd0_disable)
|
||||
continue;
|
||||
}
|
||||
if (fflush(mcd_table[i].fp)) rc |= 1<<i;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1154,4 +1154,7 @@ extern vpiHandle vpip_module(__vpiScope*scope);
|
|||
|
||||
extern int vpip_delay_selection;
|
||||
|
||||
/* A flag to disable output to MCD bit 0. */
|
||||
extern bool vpip_mcd0_disable;
|
||||
|
||||
#endif /* IVL_vpi_priv_H */
|
||||
|
|
|
|||
Loading…
Reference in New Issue