Skip to content

Commit

Permalink
vvp: fix regression in behaviour of -N option (issue #1138)
Browse files Browse the repository at this point in the history
The -N option was broken by PR #1068. This fix modifies and simplifies
the libvvp API that was introduced in that PR.
  • Loading branch information
martinwhitaker committed Jun 15, 2024
1 parent 8ac44a3 commit 713b002
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
11 changes: 3 additions & 8 deletions vvp/lib_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions vvp/libvvp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions vvp/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions vvp/stop.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003-2018 Stephen Williams ([email protected])
* Copyright (c) 2003-2024 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 713b002

Please sign in to comment.