diff --git a/vvp/lib_main.cc b/vvp/lib_main.cc index a86627421..6247a5282 100644 --- a/vvp/lib_main.cc +++ b/vvp/lib_main.cc @@ -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; diff --git a/vvp/libvvp.h b/vvp/libvvp.h index a4c20f14a..2ea913c93 100644 --- a/vvp/libvvp.h +++ b/vvp/libvvp.h @@ -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. diff --git a/vvp/main.cc b/vvp/main.cc index 5ed80ae10..604b26497 100644 --- a/vvp/main.cc +++ b/vvp/main.cc @@ -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; diff --git a/vvp/vpi_mcd.cc b/vvp/vpi_mcd.cc index 1e775e708..93d3e29c3 100644 --- a/vvp/vpi_mcd.cc +++ b/vvp/vpi_mcd.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2020 Stephen G. Tell + * Copyright (c) 2000-2024 Stephen G. Tell * * 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) - fputs(buf_ptr, 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; + if (idx == 0) { + if (logfile) + fwrite(buf, 1, cnt, logfile); + if (vpip_mcd0_disable) + continue; + } fwrite(buf, 1, cnt, mcd_table[idx].fp); - if (idx == 0 && logfile) - fwrite(buf, 1, cnt, logfile); - } } @@ -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<