diff --git a/vvp/lib_main.cc b/vvp/lib_main.cc index 62256d0ad..a86627421 100644 --- a/vvp/lib_main.cc +++ b/vvp/lib_main.cc @@ -59,18 +59,13 @@ bool verbose_flag = false; static int vvp_return_value = 0; static int vvp_used = 0; -void vvp_set_stop_is_finish(bool flag) +void vvp_set_stop_is_finish(bool flag, int exit_code) { extern bool stop_is_finish; - - stop_is_finish = flag; -} - -void vvp_set_stop_is_finish_exit_code(bool flag) -{ extern int stop_is_finish_exit_code; - stop_is_finish_exit_code = flag; + stop_is_finish = flag; + stop_is_finish_exit_code = exit_code; } void vvp_set_verbose_flag(bool flag) diff --git a/vvp/libvvp.h b/vvp/libvvp.h index 081030f02..dfdd6d012 100644 --- a/vvp/libvvp.h +++ b/vvp/libvvp.h @@ -13,19 +13,19 @@ extern "C" { #include -/* The first three functions may be called at any time. - * vvp_set_stop_is_finish(true) is equivalent to vvp's "-n" option. +/* vvp_set_stop_is_finish(true, 0) is equivalent to vvp's "-n" option. + * vvp_set_stop_is_finish(true, 1) is equivalent to vvp's "-N" option. + * + * This function may be called at any time. */ -extern void vvp_set_stop_is_finish(bool flag); +extern void vvp_set_stop_is_finish(bool flag, int exit_code); -/* vvp_set_stop_is_finish_exit_code(true) is equivalent to vvp's "-N" option. +/* vvp_set_verbose(true) is equivalent to vvp's "-v" option. + * + * This function may be called at any time. */ -extern void vvp_set_stop_is_finish_exit_code(bool flag); - -/* vvp_set_verbose(true) is equivalent to vvp's "-v" option. */ - extern void vvp_set_verbose_flag(bool flag); /* vvp_no_signals() may be called at any time before vvp_run() to prevent diff --git a/vvp/main.cc b/vvp/main.cc index bb33c608c..5ed80ae10 100644 --- a/vvp/main.cc +++ b/vvp/main.cc @@ -87,10 +87,10 @@ int main(int argc, char*argv[]) module_tab[module_cnt++] = optarg; break; case 'n': - vvp_set_stop_is_finish(true); + vvp_set_stop_is_finish(true, 0); break; case 'N': - vvp_set_stop_is_finish_exit_code(true); + vvp_set_stop_is_finish(true, 1); break; case 's': schedule_stop(0); diff --git a/vvp/stop.cc b/vvp/stop.cc index b28696a28..b87298e9c 100644 --- a/vvp/stop.cc +++ b/vvp/stop.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2018 Stephen Williams (steve@icarus.com) + * Copyright (c) 2003-2024 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -41,7 +41,7 @@ # include "ivl_alloc.h" __vpiScope*stop_current_scope = 0; -bool stop_is_finish; /* When set, $stop acts like $finish (set in main.cc). */ +bool stop_is_finish = false; /* When set, $stop acts like $finish (set in main.cc). */ int stop_is_finish_exit_code = 0; #ifndef USE_READLINE