-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #218 from nikosavola/216-hspice-plot-nets
Remove HSPICE netlist comments for plot_nets
- Loading branch information
Showing
3 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
import klayout.db as kdb | ||
|
||
|
||
class NoCommentReader(kdb.NetlistSpiceReaderDelegate): | ||
"""KLayout Spice reader without comments after $. This allows checking the netlist for HSPICE""" | ||
|
||
def parse_element(self, s: str, element: str) -> kdb.ParseElementData: | ||
if "$" in s: | ||
s = s.split("$")[0] # Don't take comments into account | ||
parsed = super().parse_element(s, element) | ||
return parsed |
This file contains 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 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,25 @@ | ||
import pytest | ||
|
||
from gplugins.klayout.netlist_spice_reader import NoCommentReader | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"s,element,expected_name,expected_nets", | ||
[ | ||
("1 2 POS", "X", "POS", {"1", "2"}), | ||
("2 3 NEG $ This is a comment", "X", "NEG", {"2", "3"}), | ||
( | ||
"5 4 some_elem some_variable=1 $ This is a comment", | ||
"X", | ||
"some_elem", | ||
{"5", "4"}, | ||
), | ||
], | ||
) | ||
def test_NoCommentReader( | ||
s: str, element: str, expected_name: str, expected_nets: set[str] | ||
) -> None: | ||
reader = NoCommentReader() | ||
parsed = reader.parse_element(s, element) | ||
assert set(parsed.net_names) == expected_nets | ||
assert parsed.model_name == expected_name.upper() |