From e34647f79cf52d9d3718874d0aef7aee11609f89 Mon Sep 17 00:00:00 2001 From: Cary R Date: Sat, 29 Dec 2007 22:27:34 -0800 Subject: [PATCH] V0.8: Add vvp flag that allows $stop to act like $finish. This patch adds a new flag to vvp "-n" that can be used to make $stop and hence act like $finish. This may be desired when using vvp in a non-interactive environment. --- vvp/main.cc | 10 +++++++++- vvp/stop.cc | 8 ++++++++ vvp/vvp.man | 5 +++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/vvp/main.cc b/vvp/main.cc index 554006547..5e58d6548 100644 --- a/vvp/main.cc +++ b/vvp/main.cc @@ -129,6 +129,7 @@ int main(int argc, char*argv[]) const char *logfile_name = 0x0; FILE *logfile = 0x0; extern void vpi_set_vlog_info(int, char**); + extern bool stop_is_finish; #ifdef __MINGW32__ /* In the Windows world, we get the first module path @@ -144,7 +145,10 @@ int main(int argc, char*argv[]) } #endif - while ((opt = getopt(argc, argv, "+dhl:M:m:v")) != EOF) switch (opt) { + /* 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, "+dhl:M:m:nv")) != EOF) switch (opt) { case 'h': fprintf(stderr, "Usage: vvp [options] input-file [+plusargs...]\n" @@ -154,6 +158,7 @@ int main(int argc, char*argv[]) " -M path VPI module directory\n" " -M - Clear VPI module path\n" " -m module Load vpi module.\n" + " -n Non-interactive ($stop = $finish).\n" " -v Verbose progress messages.\n" ); exit(0); case 'l': @@ -170,6 +175,9 @@ int main(int argc, char*argv[]) case 'm': module_tab[module_cnt++] = optarg; break; + case 'n': + stop_is_finish = true; + break; case 'v': verbose_flag = true; break; diff --git a/vvp/stop.cc b/vvp/stop.cc index fb15f4146..ea003ca89 100644 --- a/vvp/stop.cc +++ b/vvp/stop.cc @@ -47,6 +47,7 @@ #endif struct __vpiScope*stop_current_scope = 0; +bool stop_is_finish; /* When set, $stop acts like $finish (set in main.cc). */ #ifdef USE_READLINE @@ -449,6 +450,13 @@ static void invoke_command(char*txt) 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) { + schedule_finish(0); + return; + } + printf("** VVP Stop(%d) **\n", rc); printf("** Current simulation time is %" TIME_FMT "u ticks.\n", schedule_simtime()); diff --git a/vvp/vvp.man b/vvp/vvp.man index a91b2ff87..abfecea3f 100644 --- a/vvp/vvp.man +++ b/vvp/vvp.man @@ -41,6 +41,11 @@ the module. However, if the name includes at least one directory character, then the search path is not scanned and the name is assumed to be a complete file name. .TP 8 +.B -n +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 -v Turn on verbose messages. This will cause information about run time progress to be printed to standard out.