diff --git a/docs/news.d/1101.feature.rst b/docs/news.d/1101.feature.rst new file mode 100644 index 000000000..921882bba --- /dev/null +++ b/docs/news.d/1101.feature.rst @@ -0,0 +1,5 @@ +[GHDL/NVC] It is now possible to pass ``--waves`` to generate waveform files without +opening the GUI. The earlier GHDL-only approach of passing ``--viewer-fmt`` +(or ``--gtkwave-fmt``) is deprecated and will be removed in a later version. +There is also a new alias for providing the waveform format, ``--waves-fmt``, +to make it consistent with the new flag. \ No newline at end of file diff --git a/vunit/sim_if/ghdl.py b/vunit/sim_if/ghdl.py index fb7042a04..d18b1b94d 100644 --- a/vunit/sim_if/ghdl.py +++ b/vunit/sim_if/ghdl.py @@ -58,6 +58,7 @@ def add_arguments(parser): group = parser.add_argument_group("ghdl/nvc", description="GHDL/NVC specific flags") group.add_argument( "--viewer-fmt", + "--waves-fmt", "--gtkwave-fmt", choices=["vcd", "fst", "ghw"], default=None, @@ -65,6 +66,7 @@ def add_arguments(parser): ) group.add_argument("--viewer-args", "--gtkwave-args", default="", help="Arguments to pass to waveform viewer") group.add_argument("--viewer", default=None, help="Waveform viewer to use") + group.add_argument("--waves", action='store_true', help="Generate waveform file") @classmethod def from_args(cls, args, output_path, **kwargs): @@ -79,6 +81,7 @@ def from_args(cls, args, output_path, **kwargs): viewer_fmt=args.viewer_fmt, viewer_args=args.viewer_args, viewer=args.viewer, + waves=args.waves, backend=cls.determine_backend(prefix), ) @@ -98,6 +101,7 @@ def __init__( # pylint: disable=too-many-arguments viewer_fmt=None, viewer_args="", viewer=None, + waves=False, backend="llvm", ): SimulatorInterface.__init__(self, output_path, gui) @@ -111,6 +115,7 @@ def __init__( # pylint: disable=too-many-arguments self._prefix = prefix self._project = None + self._waves = waves self._backend = backend self._vhdl_standard = None @@ -366,6 +371,10 @@ def simulate(self, output_path, test_suite_name, config, elaborate_only): # pyl ghdl_e = elaborate_only and config.sim_options.get("ghdl.elab_e", False) if self._viewer_fmt is not None: + if not self._waves and not self._gui: + LOGGER.warning("Passing --viewer-fmt, or any alias of that, without either " + "--gui or --waves is deprecated and will be removed in a future version.") + data_file_name = str(Path(script_path) / f"wave.{self._viewer_fmt!s}") if Path(data_file_name).exists(): remove(data_file_name) diff --git a/vunit/sim_if/nvc.py b/vunit/sim_if/nvc.py index e0c84cf0a..234994bd4 100644 --- a/vunit/sim_if/nvc.py +++ b/vunit/sim_if/nvc.py @@ -64,6 +64,7 @@ def from_args(cls, args, output_path, **kwargs): viewer_fmt=args.viewer_fmt, viewer_args=args.viewer_args, viewer=args.viewer, + waves=args.waves, ) @classmethod @@ -74,7 +75,7 @@ def find_prefix_from_path(cls): return cls.find_toolchain([cls.executable]) def __init__( # pylint: disable=too-many-arguments - self, output_path, prefix, *, num_threads, gui=False, viewer_fmt=None, viewer_args="", viewer=None + self, output_path, prefix, *, num_threads, gui=False, viewer_fmt=None, viewer_args="", viewer=None, waves=False ): SimulatorInterface.__init__(self, output_path, gui) if viewer_fmt == "ghw": @@ -84,6 +85,7 @@ def __init__( # pylint: disable=too-many-arguments self._prefix = prefix self._project = None + self._waves = waves self._vhdl_standard = None self._coverage_test_dirs = set() @@ -257,7 +259,7 @@ def simulate( libdir = self._project.get_library(config.library_name).directory cmd = self._get_command(self._vhdl_standard, config.library_name, libdir) - if self._gui: + if self._gui or self._waves: wave_file = script_path / (f"{config.entity_name}.{self._viewer_fmt or 'fst'}") if wave_file.exists(): remove(wave_file)