-
Notifications
You must be signed in to change notification settings - Fork 288
Support arbitrary waveform viewer #1002
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| [GHDL/NVC] Arbitrary waveform viewers are now supported by passing the ``--viewer`` | ||
| command line argument. As a consequence, ``ghdl.gtkwave_script.gui`` and | ||
| ``nvc.gtkwave_script.gui`` are deprecated in favour of ``ghdl.viewer_script.gui`` | ||
| and ``nvc.viewer_script.gui``, respectively. The ``--gtkwave-args`` and | ||
| ``--gtkwave-fmt`` command line arguments are deprecated in favour of ``--viewer-args`` | ||
| and ``--viewer-fmt``, respectively. ``ghdl.viewer.gui`` and ``nvc.viewer.gui`` can | ||
| be used to set the preferred viewer from the run-file. If no viewer is explicitly | ||
| requested, ``gtkwave`` or ``surfer`` is used, in that order. This also means that | ||
| VUnit now uses ``surfer`` if ``gtkwave`` is not installed. | ||
|
|
||
| [NVC] It is possible to get VCD waveform files by passing ``--viewer-fmt=vcd``. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # This Source Code Form is subject to the terms of the Mozilla Public | ||
| # License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
| # You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| # | ||
| # Copyright (c) 2014-2024, Lars Asplund [email protected] | ||
| """ | ||
| Viewer handling for GHDL and NVC. | ||
| """ | ||
|
|
||
|
|
||
| class ViewerMixin: | ||
| """ | ||
| Mixin class for handling common viewer functionality for the GHDL and NVC simulators. | ||
| """ | ||
|
|
||
| __slots__ = ( | ||
| "_gui", | ||
| "_viewer", | ||
| "_viewer_fmt", | ||
| "_viewer_args", | ||
| "_gtkwave_available", | ||
| "_surfer_available", | ||
| ) | ||
|
|
||
| def __init__(self, gui, viewer, viewer_fmt, viewer_args): | ||
| self._gui = gui | ||
| self._viewer_fmt = viewer_fmt | ||
| self._viewer_args = viewer_args | ||
| self._viewer = viewer | ||
| if gui: | ||
| self._gtkwave_available = self.find_executable("gtkwave") | ||
| self._surfer_available = self.find_executable("surfer") | ||
|
|
||
| def _get_viewer(self, config): | ||
| """ | ||
| Determine the waveform viewer to use. | ||
|
|
||
| Falls back to gtkwave or surfer, in that order, if none is provided. | ||
| """ | ||
| viewer = self._viewer or config.sim_options.get(self.name + ".viewer.gui", None) | ||
|
|
||
| if viewer is None: | ||
| if self._gtkwave_available: | ||
| viewer = "gtkwave" | ||
| elif self._surfer_available: | ||
| viewer = "surfer" | ||
| else: | ||
| raise RuntimeError("No viewer found. GUI not possible. Install GTKWave or Surfer.") | ||
|
|
||
| elif not self.find_executable(viewer): | ||
| viewers = [] | ||
| if self._gtkwave_available: | ||
| viewers += ["gtkwave"] | ||
| if self._surfer_available: | ||
| viewers += ["surfer"] | ||
| addendum = f" The following viewer(s) are found in the path: {', '.join(viewers)}" if viewers else "" | ||
| raise RuntimeError( | ||
| f"Cannot find the {viewer} executable in the PATH environment variable. GUI not possible.{addendum}" | ||
| ) | ||
| return viewer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.