vvp: fix regression in behaviour of -N option (issue #1138)

The -N option was broken by PR #1068. This fix modifies and simplifies
the libvvp API that was introduced in that PR.
This commit is contained in:
Martin Whitaker 2024-06-15 10:47:22 +01:00
parent 8ac44a38b3
commit 713b002138
4 changed files with 15 additions and 20 deletions

View File

@ -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)

View File

@ -13,19 +13,19 @@ extern "C" {
#include <stdbool.h>
/* 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

View File

@ -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);

View File

@ -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