diff --git a/vvp/main.cc b/vvp/main.cc index 539e277d3..76d66a168 100644 --- a/vvp/main.cc +++ b/vvp/main.cc @@ -207,6 +207,7 @@ int main(int argc, char*argv[]) FILE *logfile = 0x0; extern void vpi_set_vlog_info(int, char**); extern bool stop_is_finish; + extern int stop_is_finish_exit_code; #ifdef __MINGW32__ /* In the Windows world, we get the first module path @@ -225,7 +226,7 @@ int main(int argc, char*argv[]) /* For non-interactive runs we do not want to run the interactive * debugger, so make $stop just execute a $finish. */ stop_is_finish = false; - while ((opt = getopt(argc, argv, "+hl:M:m:nsvV")) != EOF) switch (opt) { + while ((opt = getopt(argc, argv, "+hl:M:m:nNsvV")) != EOF) switch (opt) { case 'h': fprintf(stderr, "Usage: vvp [options] input-file [+plusargs...]\n" @@ -236,6 +237,7 @@ int main(int argc, char*argv[]) " -M - Clear VPI module path\n" " -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" " -s $stop right away.\n" " -v Verbose progress messages.\n" " -V Print the version information.\n" ); @@ -257,6 +259,10 @@ int main(int argc, char*argv[]) case 'n': stop_is_finish = true; break; + case 'N': + stop_is_finish = true; + stop_is_finish_exit_code = 1; + break; case 's': schedule_stop(0); break; diff --git a/vvp/stop.cc b/vvp/stop.cc index 889f1b90f..a404f1325 100644 --- a/vvp/stop.cc +++ b/vvp/stop.cc @@ -44,6 +44,7 @@ struct __vpiScope*stop_current_scope = 0; bool stop_is_finish; /* When set, $stop acts like $finish (set in main.cc). */ +int stop_is_finish_exit_code = 0; #ifndef USE_READLINE static char* readline_stub(const char*prompt) @@ -490,6 +491,7 @@ void stop_handler(int rc) /* The user may be running in a non-interactive environment, so * they want $stop and to be the same as $finish. */ if (stop_is_finish) { + vpip_set_return_value(stop_is_finish_exit_code); schedule_finish(0); return; } diff --git a/vvp/vvp.man b/vvp/vvp.man index c680c91cb..d1c0e3c9c 100644 --- a/vvp/vvp.man +++ b/vvp/vvp.man @@ -4,7 +4,7 @@ vvp - Icarus Verilog vvp runtime engine .SH SYNOPSIS .B vvp -[-sv] [-Mpath] [-mmodule] [-llogfile] inputfile [extended-args...] +[-nNsvV] [-Mpath] [-mmodule] [-llogfile] inputfile [extended-args...] .SH DESCRIPTION .PP @@ -46,6 +46,11 @@ This flag makes $stop or a a synonym for $finish. It can be used to give the program a more meaningful interface when running in a non-interactive environment. .TP 8 +.B -N +This flag does the same thing as -n, but results in an exit code +of 1 if the stimulation calls $stop. It can be used to indicate a +simulation failure when running a testbench. +.TP 8 .B -s Stop. This will cause the simulation to stop in the beginning, before any events are scheduled. This allows the interactive user to get