|
From: Lennert B. <bu...@wa...> - 2019-01-14 12:20:16
|
On Fri, Jan 04, 2019 at 06:38:11AM +0100, Niels Möller wrote: > > I've been using the hack patch below to make Icarus Verilog > > automatically start in noninteractive mode when standard input is > > not a terminal. This is useful when you're piping test data into a > > testbench and you don't want Ctrl-C to cause your terminal to be > > flooded with endless output like this: > > To me, it seems you'd may want to distinguish between stop due to the > SIGINT signal, and $stop in the simulation. > > And just change the SIGINT handling (set up in vvp/schedule.cc, it > seems) to generate $finish instead of $stop, in the case that stdin > isn't a tty. Hello! I was going along with what is there now, which is that the signal handler always generates a stop, and that there is a stop_is_finish flag which converts $stop to $finish which is set by the startup code if you ask for noninteractive mode (-n) or set by the signal handler if SIGHUP or SIGTERM are received. What my patch does is basically just act if -n is specified if standard input is not a tty. You'd have to keep the stop_is_finish flag to implement -n, but then you'd need an additional flag set at init time if stdin is not a tty and check that flag from the signal handler (as I don't think you can call isatty() from a signal handler) -- or, just split the signal handler into two signal handlers, one that sets schedule_stopped_flag and one that clears schedule_runnable, and then install the right one in signals_capture() based on what mode we are in -- any preferences? |