diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml
index 5140c2ee..2bfe490b 100644
--- a/.github/workflows/pylint.yml
+++ b/.github/workflows/pylint.yml
@@ -4,7 +4,7 @@ on: [push]
jobs:
build:
- if: github.ref == 'refs/heads/master'
+ # if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
strategy:
matrix:
@@ -22,4 +22,4 @@ jobs:
pip install pylint-exit
- name: Analysing the code with pylint
run: |
- pylint --rcfile=.pylintrc spydrnet/ || pylint-exit $?
+ pylint --rcfile=.pylintrc spydrnet/ || pylint-exit --error-fail $?
diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml
index bc4e9391..0bc148cc 100644
--- a/.github/workflows/pytest.yml
+++ b/.github/workflows/pytest.yml
@@ -14,13 +14,17 @@ jobs:
- "3.8"
- "3.9"
- "3.10"
+ env:
+ EXAMPLE_NETLISTS_PATH: ${{ github.workspace }}/example_netlists/
steps:
- uses: actions/checkout@master
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
+ - name: Install Dependencies
+ run: |
+ python -m pip install requests pytest
- name: Run Pytest for SpyDrNet
- uses: cclauss/GitHub-Action-for-pytest@master
- with:
- args: python -m pytest -v
+ run: |
+ python3 -m pytest -v
diff --git a/.pylintrc b/.pylintrc
index f00075cf..9c64b903 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -23,18 +23,18 @@ extension-pkg-whitelist=
fail-on=
# Specify a score threshold to be exceeded before program exits with error.
-fail-under=6.0
+fail-under=8.3
# Files or directories to be skipped. They should be base names, not paths.
ignore=CVS
# Add files or directories matching the regex patterns to the ignore-list. The
# regex matches against paths.
-ignore-paths=
+ignore-paths= spydrnet/parsers/primatives/parsetab.py
# Files or directories matching the regex patterns are skipped. The regex
# matches against base names, not paths.
-ignore-patterns= parsetab.py
+ignore-patterns=
# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
@@ -42,7 +42,7 @@ ignore-patterns= parsetab.py
# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the
# number of processors available to use.
-jobs=0
+jobs=1
# Control the amount of potential inferred values when inferring a single
# object. This can help the performance when dealing with large functions or
@@ -80,16 +80,17 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use "--disable=all --enable=classes
# --disable=W".
-disable=print-statement,
- parameter-unpacking,
- unpacking-in-except,
- old-raise-syntax,
- backtick,
- long-suffix,
- old-ne-operator,
- old-octal-literal,
- import-star-module-level,
- non-ascii-bytes-literal,
+disable=
+# print-statement,
+# parameter-unpacking,
+# unpacking-in-except,
+# old-raise-syntax,
+# backtick,
+# long-suffix,
+# old-ne-operator,
+# old-octal-literal,
+# import-star-module-level,
+# non-ascii-bytes-literal,
raw-checker-failed,
bad-inline-option,
locally-disabled,
@@ -98,67 +99,67 @@ disable=print-statement,
useless-suppression,
deprecated-pragma,
use-symbolic-message-instead,
- apply-builtin,
- basestring-builtin,
- buffer-builtin,
- cmp-builtin,
- coerce-builtin,
- execfile-builtin,
- file-builtin,
- long-builtin,
- raw_input-builtin,
- reduce-builtin,
- standarderror-builtin,
- unicode-builtin,
- xrange-builtin,
- coerce-method,
- delslice-method,
- getslice-method,
- setslice-method,
- no-absolute-import,
- old-division,
- dict-iter-method,
- dict-view-method,
- next-method-called,
- metaclass-assignment,
- indexing-exception,
- raising-string,
- reload-builtin,
- oct-method,
- hex-method,
- nonzero-method,
- cmp-method,
- input-builtin,
- round-builtin,
- intern-builtin,
- unichr-builtin,
- map-builtin-not-iterating,
- zip-builtin-not-iterating,
- range-builtin-not-iterating,
- filter-builtin-not-iterating,
- using-cmp-argument,
- eq-without-hash,
- div-method,
- idiv-method,
- rdiv-method,
- exception-message-attribute,
- invalid-str-codec,
- sys-max-int,
- bad-python3-import,
- deprecated-string-function,
- deprecated-str-translate-call,
- deprecated-itertools-function,
- deprecated-types-field,
- next-method-defined,
- dict-items-not-iterating,
- dict-keys-not-iterating,
- dict-values-not-iterating,
- deprecated-operator-function,
- deprecated-urllib-function,
- xreadlines-attribute,
- deprecated-sys-function,
- exception-escape,
- comprehension-escape
+# apply-builtin,
+# basestring-builtin,
+# buffer-builtin,
+# cmp-builtin,
+# coerce-builtin,
+# execfile-builtin,
+# file-builtin,
+# long-builtin,
+# raw_input-builtin,
+# reduce-builtin,
+# standarderror-builtin,
+# unicode-builtin,
+# xrange-builtin,
+# coerce-method,
+# delslice-method,
+# getslice-method,
+# setslice-method,
+# no-absolute-import,
+# old-division,
+# dict-iter-method,
+# dict-view-method,
+# next-method-called,
+# metaclass-assignment,
+# indexing-exception,
+# raising-string,
+# reload-builtin,
+# oct-method,
+# hex-method,
+# nonzero-method,
+# cmp-method,
+# input-builtin,
+# round-builtin,
+# intern-builtin,
+# unichr-builtin,
+# map-builtin-not-iterating,
+# zip-builtin-not-iterating,
+# range-builtin-not-iterating,
+# filter-builtin-not-iterating,
+# using-cmp-argument,
+# eq-without-hash,
+# div-method,
+# idiv-method,
+# rdiv-method,
+# exception-message-attribute,
+# invalid-str-codec,
+# sys-max-int,
+# bad-python3-import,
+# deprecated-string-function,
+# deprecated-str-translate-call,
+# deprecated-itertools-function,
+# deprecated-types-field,
+# next-method-defined,
+# dict-items-not-iterating,
+# dict-keys-not-iterating,
+# dict-values-not-iterating,
+# deprecated-operator-function,
+# deprecated-urllib-function,
+# xreadlines-attribute,
+# deprecated-sys-function,
+# exception-escape,
+# comprehension-escape
# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
diff --git a/README.rst b/README.rst
index 0d2f975f..a346541a 100644
--- a/README.rst
+++ b/README.rst
@@ -24,7 +24,7 @@ SpyDrNet can be used to create netlists from scratch. Because it is a low-level
**Loading Example Netlists**
-Several example netlists are included with the package to introduce the framework, its features, and functionality. To list and load these netlists, modify the following example:
+Several example netlists are included in the repository to introduce the framework, its features, and functionality. To list and load these netlists, see the :ref:`using_example_netlists` page and then run the following:
.. code:: python
diff --git a/RELEASE.rst b/RELEASE.rst
index 47d70ce6..ce15e376 100644
--- a/RELEASE.rst
+++ b/RELEASE.rst
@@ -1,9 +1,20 @@
+SpyDrNet 1.13.0
+----------------
+August 14, 2023
+
+* Moved the example netlists and tests out of the python package and added documentation how to use the example netlists
+* Updated to use pathlib instead of os
+* Added Github actions check to run Pylint and to fail if score is too low
+* Added documentation about Pylint and code formatting
+* Various minor improvements
+* Other small edits to documentation
+
SpyDrNet 1.12.2
----------------
April 18, 2023
-Bug fix for Verilog parser for partially connected ports being misaligned and fixed primitive name with a space at the end.
-Changed some of the os.path to pathlib to conform to updated coding standards
+* Bug fix for Verilog parser for partially connected ports being misaligned and fixed primitive name with a space at the end.
+* Changed some of the os.path to pathlib to conform to updated coding standards
SpyDrNet 1.12.1
----------------
diff --git a/docs/source/conf.py b/docs/source/conf.py
index e9a23837..dd4545ad 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -17,14 +17,17 @@
# sys.path.insert(0, os.path.abspath('.'))
import os
import sys
+import pathlib
sys.path.insert(0,os.path.abspath('../..'))
import spydrnet as sdn
+# import sphinxgallery
+
# -- Project information -----------------------------------------------------
-project = 'SpyDrNet'
-copyright = '2019, Brigham Young Universitiy'
-author = 'BYU Configurable Computing Lab'
+project = "SpyDrNet"
+copyright = "2019, Brigham Young Universitiy"
+author = "BYU Configurable Computing Lab"
# The short X.Y version
version = sdn.__version__
@@ -44,33 +47,35 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
- 'sphinx.ext.autosummary',
- 'sphinx.ext.autodoc',
- 'sphinx.ext.coverage',
- 'sphinx.ext.doctest',
- 'sphinx.ext.intersphinx',
- 'sphinx.ext.mathjax',
- 'sphinx.ext.napoleon',
- 'sphinx.ext.todo',
- 'sphinx.ext.viewcode',
- 'sphinx.ext.githubpages',
- 'sphinx_gallery.gen_gallery',
+ "sphinx.ext.autosummary",
+ "sphinx.ext.autodoc",
+ "sphinx.ext.coverage",
+ "sphinx.ext.doctest",
+ "sphinx.ext.intersphinx",
+ "sphinx.ext.mathjax",
+ "sphinx.ext.napoleon",
+ "sphinx.ext.todo",
+ "sphinx.ext.viewcode",
+ "sphinx.ext.githubpages",
+ "sphinx_gallery.gen_gallery",
]
# generate autosummary pages
autosummary_generate = True
# Add any paths that contain templates here, relative to this directory.
-templates_path = ['_templates']
+templates_path = ["_templates"]
+
+# html_static_path = ["_static", sphinxgallery.path_static()]
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
-source_suffix = '.rst'
+source_suffix = ".rst"
# The master toctree document.
-master_doc = 'index'
+master_doc = "index"
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@@ -101,7 +106,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
-html_theme = 'sphinx_rtd_theme'
+html_theme = "sphinx_rtd_theme"
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
@@ -129,7 +134,7 @@
# -- Options for HTMLHelp output ---------------------------------------------
# Output file base name for HTML help builder.
-htmlhelp_basename = 'SpyDrNet'
+htmlhelp_basename = "SpyDrNet"
# -- Options for LaTeX output ------------------------------------------------
@@ -137,31 +142,32 @@
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
- 'papersize': 'letterpaper',
-
+ "papersize": "letterpaper",
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
-
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
-
# Latex figure (float) alignment
#
- 'figure_align': 'H',
-
- # Oneside (remove blank pages)
- #
- 'extraclassoptions': 'openany,oneside'
+ "figure_align": "H",
+ # Oneside (remove blank pages)
+ #
+ "extraclassoptions": "openany,oneside",
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
- ('reference/index', 'spydrnet_reference.tex', 'SpyDrNet Reference',
- 'BYU Configurable Computing Lab', 'manual'),
+ (
+ "reference/index",
+ "spydrnet_reference.tex",
+ "SpyDrNet Reference",
+ "BYU Configurable Computing Lab",
+ "manual",
+ ),
]
latex_appendices = ['overview/tutorial','overview/start']
@@ -170,10 +176,7 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
-man_pages = [
- (master_doc, 'spydrnet', 'SpyDrNet Documentation',
- [author], 1)
-]
+man_pages = [(master_doc, "spydrnet", "SpyDrNet Documentation", [author], 1)]
# -- Options for Texinfo output ----------------------------------------------
@@ -182,9 +185,15 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
- (master_doc, 'SpyDrNet', 'SpyDrNet Documentation',
- author, 'SpyDrNet', 'One line description of project.',
- 'Miscellaneous'),
+ (
+ master_doc,
+ "SpyDrNet",
+ "SpyDrNet Documentation",
+ author,
+ "SpyDrNet",
+ "One line description of project.",
+ "Miscellaneous",
+ ),
]
@@ -203,14 +212,14 @@
# epub_uid = ''
# A list of files that should not be packed into the epub file.
-epub_exclude_files = ['search.html']
+epub_exclude_files = ["search.html"]
# -- Options for Sphinx-Gallery ----------------------------------------------
sphinx_gallery_conf = {
- 'examples_dirs': os.path.join('..', '..', 'examples'), # path to your example scripts
+ 'examples_dirs': pathlib.Path('..').joinpath('..', 'examples'), # path to your example scripts
'gallery_dirs': 'auto_examples', # path to where to save gallery generated output
- 'remove_config_comments': True,
+ 'remove_config_comments': True
}
-# -- Extension configuration -------------------------------------------------
\ No newline at end of file
+# -- Extension configuration -------------------------------------------------
diff --git a/docs/source/developer/contribute.rst b/docs/source/developer/contribute.rst
index 8be9e0d2..c6e9c4ae 100644
--- a/docs/source/developer/contribute.rst
+++ b/docs/source/developer/contribute.rst
@@ -12,7 +12,7 @@ This section aims to help you do a spydrnet release, meaning you make the latest
4. :ref:`update_documentation` and ensure it can build properly
5. On Github, create a pull request with the updated code in the next_release branch.
6. Accept and merge the pull request when the checks have finished.
-7. Move to the master branch using `git checkout master`
+7. Move to the master branch using `git checkout master` and run `git pull`
8. :ref:`create_and_update_tag`
9. :ref:`build_package` (this will update the documentation's version number)
10. :ref:`build_documentation`
@@ -103,9 +103,9 @@ Upgrade pip if needed.
Make sure everything is up to date
->>> python3 -m pip install --user --upgrade setuptools wheel
+>>> python3 -m pip install --upgrade setuptools wheel
-Make the python archive package:
+Make sure you are in the top level directory. Make the python archive package:
>>> python3 setup.py sdist bdist_wheel
@@ -163,10 +163,11 @@ proper release number.
Enter a description–it could just be a reiteration of the release notes or other relevant information.
-Three files should be added as assets to the new release:
+Four files should be added as assets to the new release:
1. The .tar.gz file from the previous step
2. The .whl file from the previous step
3. The spydrnet_reference pdf document created in the :ref:`build_documentation` step. Go to docs/latex folder, change the `spydrnet_reference.pdf` name to `spydrnet_reference-new_release_number.pdf`, and then copy it to the assets under the new release.
+ 4. The `pylint_output.txt`
.. _publish_documentation:
diff --git a/docs/source/developer/linting.rst b/docs/source/developer/formatting.rst
similarity index 76%
rename from docs/source/developer/linting.rst
rename to docs/source/developer/formatting.rst
index 9340deff..f34b0f9b 100644
--- a/docs/source/developer/linting.rst
+++ b/docs/source/developer/formatting.rst
@@ -1,7 +1,7 @@
-Linting
-=======
+Code Formatting
+===============
-SpyDrNet developers strive to provide high quality code that follows a general coding standard and does not contain errors. To help accomplish this goal, the `Pylint `__ python package is used.
+SpyDrNet developers strive to provide high quality code that follows a general coding standard and does not contain errors. To help accomplish this goal, the `Pylint `__ and `Black `_ python packages are used.
Running Pylint
--------------
@@ -19,10 +19,18 @@ Pylint will then provide a score from 0.0 to 10.0 for your code. The best way to
pylint /
pylint .py
-It is strongly encouraged to run pylint on any code that you change or create that will be added into the SpyDrNet repository, and ensure that the code scores well (getting 10.0 is not terribly difficult). This not only improves the SpyDrNet codebase, but will improve your own skills as a competant programmer.
+It is strongly encouraged to run pylint on any code that you change or create that will be added into the SpyDrNet repository, and ensure that the code scores well. This not only improves the SpyDrNet codebase, but will improve your own skills as a competant programmer.
Pylint, along with pytest, will be run every time code is pushed to the GitHub repository with GitHub actions (as specificed in the `.github/workflows/pylint.yml` file in the root SpyDrNet directory).
Viewing Pylint score for each release
-------------------------------------
-On the `byuccl/spydrnet `__ page, navigate to the "Actions" tab. From there, you should be able to select the "Pylint" workflow and view all jobs within that workflow. Open up a job, and then find the "Analysing the code with pylint" tab. Here, all pylint output can be found for each push done for the repository.
\ No newline at end of file
+On the `byuccl/spydrnet `__ page, navigate to the "Actions" tab. From there, you should be able to select the "Pylint" workflow and view all jobs within that workflow. Open up a job, and then find the "Analysing the code with pylint" tab. Here, all pylint output can be found for each push done for the repository.
+
+Running Black
+-------------
+Simply run
+
+ black
+
+and changes will be made to your code to ensure the format is proper.
\ No newline at end of file
diff --git a/docs/source/developer/index.rst b/docs/source/developer/index.rst
index fc1870ec..1d2719b9 100644
--- a/docs/source/developer/index.rst
+++ b/docs/source/developer/index.rst
@@ -8,5 +8,5 @@ Developer's Guide
contribute
repository
- testing
- linting
\ No newline at end of file
+ formatting
+ testing
\ No newline at end of file
diff --git a/docs/source/overview/start.rst b/docs/source/overview/start.rst
index 4daed726..11bdfa68 100644
--- a/docs/source/overview/start.rst
+++ b/docs/source/overview/start.rst
@@ -65,7 +65,7 @@ write_blackbox
write_eblif_cname
-- Flag
+- Flag used for eblif (Yosys to F4PGA)
defparam
diff --git a/docs/source/overview/tutorial.rst b/docs/source/overview/tutorial.rst
index dc6afdc5..82546563 100644
--- a/docs/source/overview/tutorial.rst
+++ b/docs/source/overview/tutorial.rst
@@ -60,7 +60,7 @@ Or the following for a Verilog file
netlist = sdn.parse('.v')
-SpyDrNet has built in example netlists. For this tutorial, we will use the example 'one_counter'. This is the same as if we parsed a netlist named 'one_counter'.
+The SpyDrNet repo has example netlists. For this tutorial, we will use the example 'one_counter'. This is the same as if we parsed a netlist named 'one_counter'. Review the :ref:`using_example_netlists` page for help loading example netlists.
.. code-block::
diff --git a/docs/source/reference/index.rst b/docs/source/reference/index.rst
index 0f367b12..3ea5afd2 100644
--- a/docs/source/reference/index.rst
+++ b/docs/source/reference/index.rst
@@ -10,6 +10,7 @@ Reference
:maxdepth: 2
classes/index.rst
+ using_example_netlists
netlist_types
built_in_architecture
functions/index
diff --git a/docs/source/reference/using_example_netlists.rst b/docs/source/reference/using_example_netlists.rst
new file mode 100644
index 00000000..864d956e
--- /dev/null
+++ b/docs/source/reference/using_example_netlists.rst
@@ -0,0 +1,58 @@
+.. _using_example_netlists:
+
+Using SpyDrNet Example Netlists
+----------------------------------
+
+Many EDIF, Verilog, and EBLIF example netlists are found in the SpyDrNet repo under *example_netlists*. In versions of SpyDrNet previous to 1.13, the example netlists were included in the python package. From version 1.13 on, perform the steps below to access the example netlists using *sdn.load_example_netlist_by_name()*.
+
+Option 1
+^^^^^^^^^
+
+1. Download the `example netlists directory `_ from the `SpyDrNet repo `_, or just clone the repo.
+
+2. In the Linux terminal, run
+
+ .. code-block::
+
+ export EXAMPLE_NETLISTS_PATH=
+
+ where the is the path to the top level example netlists directory in the spydrnet repo.
+
+3. Use the *sdn.load_example_netlist_by_name()* to access the example netlist. For example:
+
+ .. code-block::
+
+ import spydrnet as sdn
+ netlist = sdn.load_example_netlist_by_name("b13")
+
+Option 2
+^^^^^^^^^
+
+Run the following code and type 'y' and then hit enter when asked whether or not to download the example netlists.
+
+.. code-block::
+
+ import spydrnet as sdn
+ netlist = sdn.load_example_netlist_by_name()
+
+Additional Information
+^^^^^^^^^^^^^^^^^^^^^^^
+
+It is possible to see the names of the example netlists for each netlist format
+
+.. code-block::
+
+ print(sdn.example_netlist_names) # lists the names of the EDIF example netlists
+ print(sdn.verilog_example_netlist_names) # lists the names of the Verilog example netlists
+ print(sdn.eblif_example_netlist_names) # lists the names of the EBLIF example netlists
+
+By default, sdn.load_example_netlist_by_name() assumes the netlists is EDIF format. To load a Verilog or EBLIF example netlist, do the following:
+
+.. code-block::
+
+ import spydrnet as sdn
+ from spydrnet.util.netlist_type import VERILOG, EBLIF
+
+ verilog_example_netlist = sdn.load_example_netlist_by_name(name, VERILOG)
+ eblif_example_netlist = sdn.load_example_netlist_by_name(name, EBLIF)
+
diff --git a/spydrnet/support_files/EDIF_netlists/4bitadder.edf.zip b/example_netlists/EDIF_netlists/4bitadder.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/4bitadder.edf.zip
rename to example_netlists/EDIF_netlists/4bitadder.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/8051.edf.zip b/example_netlists/EDIF_netlists/8051.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/8051.edf.zip
rename to example_netlists/EDIF_netlists/8051.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/AND_gate.edf.zip b/example_netlists/EDIF_netlists/AND_gate.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/AND_gate.edf.zip
rename to example_netlists/EDIF_netlists/AND_gate.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/Readme.md b/example_netlists/EDIF_netlists/Readme.md
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/Readme.md
rename to example_netlists/EDIF_netlists/Readme.md
diff --git a/spydrnet/support_files/EDIF_netlists/SID.edf.zip b/example_netlists/EDIF_netlists/SID.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/SID.edf.zip
rename to example_netlists/EDIF_netlists/SID.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/TMR_hierarchy.edf.zip b/example_netlists/EDIF_netlists/TMR_hierarchy.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/TMR_hierarchy.edf.zip
rename to example_netlists/EDIF_netlists/TMR_hierarchy.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/adder.edf.zip b/example_netlists/EDIF_netlists/adder.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/adder.edf.zip
rename to example_netlists/EDIF_netlists/adder.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/aes_128_noBRAM.edf.zip b/example_netlists/EDIF_netlists/aes_128_noBRAM.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/aes_128_noBRAM.edf.zip
rename to example_netlists/EDIF_netlists/aes_128_noBRAM.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/b13.edf.zip b/example_netlists/EDIF_netlists/b13.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/b13.edf.zip
rename to example_netlists/EDIF_netlists/b13.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/basic_clock_crossing.edf.zip b/example_netlists/EDIF_netlists/basic_clock_crossing.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/basic_clock_crossing.edf.zip
rename to example_netlists/EDIF_netlists/basic_clock_crossing.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/basic_synchronizer.edf.zip b/example_netlists/EDIF_netlists/basic_synchronizer.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/basic_synchronizer.edf.zip
rename to example_netlists/EDIF_netlists/basic_synchronizer.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/bram.edf.zip b/example_netlists/EDIF_netlists/bram.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/bram.edf.zip
rename to example_netlists/EDIF_netlists/bram.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/carrychain.edf.zip b/example_netlists/EDIF_netlists/carrychain.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/carrychain.edf.zip
rename to example_netlists/EDIF_netlists/carrychain.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/counters128.edf.zip b/example_netlists/EDIF_netlists/counters128.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/counters128.edf.zip
rename to example_netlists/EDIF_netlists/counters128.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/flappy_nexys.edf.zip b/example_netlists/EDIF_netlists/flappy_nexys.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/flappy_nexys.edf.zip
rename to example_netlists/EDIF_netlists/flappy_nexys.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/float_demo.edf.zip b/example_netlists/EDIF_netlists/float_demo.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/float_demo.edf.zip
rename to example_netlists/EDIF_netlists/float_demo.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/fourBitCounter.edf.zip b/example_netlists/EDIF_netlists/fourBitCounter.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/fourBitCounter.edf.zip
rename to example_netlists/EDIF_netlists/fourBitCounter.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/fourBitCounterWithAnd.edf.zip b/example_netlists/EDIF_netlists/fourBitCounterWithAnd.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/fourBitCounterWithAnd.edf.zip
rename to example_netlists/EDIF_netlists/fourBitCounterWithAnd.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/hierarchical_luts.edf.zip b/example_netlists/EDIF_netlists/hierarchical_luts.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/hierarchical_luts.edf.zip
rename to example_netlists/EDIF_netlists/hierarchical_luts.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/inverter.edf.zip b/example_netlists/EDIF_netlists/inverter.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/inverter.edf.zip
rename to example_netlists/EDIF_netlists/inverter.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/lc2.edf.zip b/example_netlists/EDIF_netlists/lc2.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/lc2.edf.zip
rename to example_netlists/EDIF_netlists/lc2.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/lc3.edf.zip b/example_netlists/EDIF_netlists/lc3.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/lc3.edf.zip
rename to example_netlists/EDIF_netlists/lc3.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/leon3mp.edf.zip b/example_netlists/EDIF_netlists/leon3mp.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/leon3mp.edf.zip
rename to example_netlists/EDIF_netlists/leon3mp.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/leon3mp_hierarchical.edf.zip b/example_netlists/EDIF_netlists/leon3mp_hierarchical.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/leon3mp_hierarchical.edf.zip
rename to example_netlists/EDIF_netlists/leon3mp_hierarchical.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/leon3mp_hierarchical_flat.edf.zip b/example_netlists/EDIF_netlists/leon3mp_hierarchical_flat.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/leon3mp_hierarchical_flat.edf.zip
rename to example_netlists/EDIF_netlists/leon3mp_hierarchical_flat.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/lfsr_kc705.edf.zip b/example_netlists/EDIF_netlists/lfsr_kc705.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/lfsr_kc705.edf.zip
rename to example_netlists/EDIF_netlists/lfsr_kc705.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/lfsr_zybo.edf.zip b/example_netlists/EDIF_netlists/lfsr_zybo.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/lfsr_zybo.edf.zip
rename to example_netlists/EDIF_netlists/lfsr_zybo.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/multi_port.edf.zip b/example_netlists/EDIF_netlists/multi_port.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/multi_port.edf.zip
rename to example_netlists/EDIF_netlists/multi_port.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/n_bit_counter.edf.zip b/example_netlists/EDIF_netlists/n_bit_counter.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/n_bit_counter.edf.zip
rename to example_netlists/EDIF_netlists/n_bit_counter.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/namespace.edf.zip b/example_netlists/EDIF_netlists/namespace.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/namespace.edf.zip
rename to example_netlists/EDIF_netlists/namespace.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/netlist_with_large_integer.edf.zip b/example_netlists/EDIF_netlists/netlist_with_large_integer.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/netlist_with_large_integer.edf.zip
rename to example_netlists/EDIF_netlists/netlist_with_large_integer.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/one_counter.edf.zip b/example_netlists/EDIF_netlists/one_counter.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/one_counter.edf.zip
rename to example_netlists/EDIF_netlists/one_counter.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/osfbm.edf.zip b/example_netlists/EDIF_netlists/osfbm.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/osfbm.edf.zip
rename to example_netlists/EDIF_netlists/osfbm.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/passthrough_test.edf.zip b/example_netlists/EDIF_netlists/passthrough_test.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/passthrough_test.edf.zip
rename to example_netlists/EDIF_netlists/passthrough_test.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/port_test.edf.zip b/example_netlists/EDIF_netlists/port_test.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/port_test.edf.zip
rename to example_netlists/EDIF_netlists/port_test.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/ports_diff_modules.edf.zip b/example_netlists/EDIF_netlists/ports_diff_modules.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/ports_diff_modules.edf.zip
rename to example_netlists/EDIF_netlists/ports_diff_modules.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/register_file.edf.zip b/example_netlists/EDIF_netlists/register_file.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/register_file.edf.zip
rename to example_netlists/EDIF_netlists/register_file.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/riscv_multi_core.edf.zip b/example_netlists/EDIF_netlists/riscv_multi_core.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/riscv_multi_core.edf.zip
rename to example_netlists/EDIF_netlists/riscv_multi_core.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/sha3_core.edf.zip b/example_netlists/EDIF_netlists/sha3_core.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/sha3_core.edf.zip
rename to example_netlists/EDIF_netlists/sha3_core.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/shift_reg.edf.zip b/example_netlists/EDIF_netlists/shift_reg.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/shift_reg.edf.zip
rename to example_netlists/EDIF_netlists/shift_reg.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/synchronizer_test.edf.zip b/example_netlists/EDIF_netlists/synchronizer_test.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/synchronizer_test.edf.zip
rename to example_netlists/EDIF_netlists/synchronizer_test.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/synth_th1_slaac.edf.zip b/example_netlists/EDIF_netlists/synth_th1_slaac.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/synth_th1_slaac.edf.zip
rename to example_netlists/EDIF_netlists/synth_th1_slaac.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/testCountMult.edf.zip b/example_netlists/EDIF_netlists/testCountMult.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/testCountMult.edf.zip
rename to example_netlists/EDIF_netlists/testCountMult.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/three_layer_hierarchy.edf.zip b/example_netlists/EDIF_netlists/three_layer_hierarchy.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/three_layer_hierarchy.edf.zip
rename to example_netlists/EDIF_netlists/three_layer_hierarchy.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/three_stage_synchronizer.edf.zip b/example_netlists/EDIF_netlists/three_stage_synchronizer.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/three_stage_synchronizer.edf.zip
rename to example_netlists/EDIF_netlists/three_stage_synchronizer.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/three_stage_synchronizer2.edf.zip b/example_netlists/EDIF_netlists/three_stage_synchronizer2.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/three_stage_synchronizer2.edf.zip
rename to example_netlists/EDIF_netlists/three_stage_synchronizer2.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/toggle.edf.zip b/example_netlists/EDIF_netlists/toggle.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/toggle.edf.zip
rename to example_netlists/EDIF_netlists/toggle.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/unique_challenge.edf.zip b/example_netlists/EDIF_netlists/unique_challenge.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/unique_challenge.edf.zip
rename to example_netlists/EDIF_netlists/unique_challenge.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/unique_different_modules.edf.zip b/example_netlists/EDIF_netlists/unique_different_modules.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/unique_different_modules.edf.zip
rename to example_netlists/EDIF_netlists/unique_different_modules.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/unused_blackbox.edf.zip b/example_netlists/EDIF_netlists/unused_blackbox.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/unused_blackbox.edf.zip
rename to example_netlists/EDIF_netlists/unused_blackbox.edf.zip
diff --git a/spydrnet/support_files/EDIF_netlists/zpu4.edf.zip b/example_netlists/EDIF_netlists/zpu4.edf.zip
similarity index 100%
rename from spydrnet/support_files/EDIF_netlists/zpu4.edf.zip
rename to example_netlists/EDIF_netlists/zpu4.edf.zip
diff --git a/spydrnet/support_files/eblif_netlists/example.eblif.zip b/example_netlists/eblif_netlists/example.eblif.zip
similarity index 100%
rename from spydrnet/support_files/eblif_netlists/example.eblif.zip
rename to example_netlists/eblif_netlists/example.eblif.zip
diff --git a/spydrnet/support_files/eblif_netlists/example_no_carry.eblif.zip b/example_netlists/eblif_netlists/example_no_carry.eblif.zip
similarity index 100%
rename from spydrnet/support_files/eblif_netlists/example_no_carry.eblif.zip
rename to example_netlists/eblif_netlists/example_no_carry.eblif.zip
diff --git a/spydrnet/support_files/eblif_netlists/jAsynchronousCounter.eblif.zip b/example_netlists/eblif_netlists/jAsynchronousCounter.eblif.zip
similarity index 100%
rename from spydrnet/support_files/eblif_netlists/jAsynchronousCounter.eblif.zip
rename to example_netlists/eblif_netlists/jAsynchronousCounter.eblif.zip
diff --git a/spydrnet/support_files/eblif_netlists/jfsmMealyWithOverlap.eblif.zip b/example_netlists/eblif_netlists/jfsmMealyWithOverlap.eblif.zip
similarity index 100%
rename from spydrnet/support_files/eblif_netlists/jfsmMealyWithOverlap.eblif.zip
rename to example_netlists/eblif_netlists/jfsmMealyWithOverlap.eblif.zip
diff --git a/spydrnet/support_files/eblif_netlists/juniversalShiftRegister.eblif.zip b/example_netlists/eblif_netlists/juniversalShiftRegister.eblif.zip
similarity index 100%
rename from spydrnet/support_files/eblif_netlists/juniversalShiftRegister.eblif.zip
rename to example_netlists/eblif_netlists/juniversalShiftRegister.eblif.zip
diff --git a/spydrnet/support_files/eblif_netlists/synchronouscounter.eblif.zip b/example_netlists/eblif_netlists/synchronouscounter.eblif.zip
similarity index 100%
rename from spydrnet/support_files/eblif_netlists/synchronouscounter.eblif.zip
rename to example_netlists/eblif_netlists/synchronouscounter.eblif.zip
diff --git a/spydrnet/support_files/eblif_netlists/synchronouscounter_nocarry.eblif.zip b/example_netlists/eblif_netlists/synchronouscounter_nocarry.eblif.zip
similarity index 100%
rename from spydrnet/support_files/eblif_netlists/synchronouscounter_nocarry.eblif.zip
rename to example_netlists/eblif_netlists/synchronouscounter_nocarry.eblif.zip
diff --git a/spydrnet/support_files/eblif_netlists/toggle.eblif.zip b/example_netlists/eblif_netlists/toggle.eblif.zip
similarity index 100%
rename from spydrnet/support_files/eblif_netlists/toggle.eblif.zip
rename to example_netlists/eblif_netlists/toggle.eblif.zip
diff --git a/spydrnet/support_files/verilog_netlists/4bitadder.v.zip b/example_netlists/verilog_netlists/4bitadder.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/4bitadder.v.zip
rename to example_netlists/verilog_netlists/4bitadder.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/8051.v.zip b/example_netlists/verilog_netlists/8051.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/8051.v.zip
rename to example_netlists/verilog_netlists/8051.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/SID.v.zip b/example_netlists/verilog_netlists/SID.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/SID.v.zip
rename to example_netlists/verilog_netlists/SID.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/TMR_hierarchy.v.zip b/example_netlists/verilog_netlists/TMR_hierarchy.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/TMR_hierarchy.v.zip
rename to example_netlists/verilog_netlists/TMR_hierarchy.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/adder.v.zip b/example_netlists/verilog_netlists/adder.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/adder.v.zip
rename to example_netlists/verilog_netlists/adder.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/b13.v.zip b/example_netlists/verilog_netlists/b13.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/b13.v.zip
rename to example_netlists/verilog_netlists/b13.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/basic_clock_crossing.v.zip b/example_netlists/verilog_netlists/basic_clock_crossing.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/basic_clock_crossing.v.zip
rename to example_netlists/verilog_netlists/basic_clock_crossing.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/basic_synchronizer.v.zip b/example_netlists/verilog_netlists/basic_synchronizer.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/basic_synchronizer.v.zip
rename to example_netlists/verilog_netlists/basic_synchronizer.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/bram.v.zip b/example_netlists/verilog_netlists/bram.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/bram.v.zip
rename to example_netlists/verilog_netlists/bram.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/carrychain.v.zip b/example_netlists/verilog_netlists/carrychain.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/carrychain.v.zip
rename to example_netlists/verilog_netlists/carrychain.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/counters128.v.zip b/example_netlists/verilog_netlists/counters128.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/counters128.v.zip
rename to example_netlists/verilog_netlists/counters128.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/flappy_nexys.v.zip b/example_netlists/verilog_netlists/flappy_nexys.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/flappy_nexys.v.zip
rename to example_netlists/verilog_netlists/flappy_nexys.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/float_demo.v.zip b/example_netlists/verilog_netlists/float_demo.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/float_demo.v.zip
rename to example_netlists/verilog_netlists/float_demo.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/fourBitCounter.v.zip b/example_netlists/verilog_netlists/fourBitCounter.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/fourBitCounter.v.zip
rename to example_netlists/verilog_netlists/fourBitCounter.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/fourBitCounterWithAnd.v.zip b/example_netlists/verilog_netlists/fourBitCounterWithAnd.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/fourBitCounterWithAnd.v.zip
rename to example_netlists/verilog_netlists/fourBitCounterWithAnd.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/hierarchical_luts.v.zip b/example_netlists/verilog_netlists/hierarchical_luts.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/hierarchical_luts.v.zip
rename to example_netlists/verilog_netlists/hierarchical_luts.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/inverter.v.zip b/example_netlists/verilog_netlists/inverter.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/inverter.v.zip
rename to example_netlists/verilog_netlists/inverter.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/lc2.v.zip b/example_netlists/verilog_netlists/lc2.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/lc2.v.zip
rename to example_netlists/verilog_netlists/lc2.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/lc3.v.zip b/example_netlists/verilog_netlists/lc3.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/lc3.v.zip
rename to example_netlists/verilog_netlists/lc3.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/lfsr_kc705.v.zip b/example_netlists/verilog_netlists/lfsr_kc705.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/lfsr_kc705.v.zip
rename to example_netlists/verilog_netlists/lfsr_kc705.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/lfsr_zybo.v.zip b/example_netlists/verilog_netlists/lfsr_zybo.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/lfsr_zybo.v.zip
rename to example_netlists/verilog_netlists/lfsr_zybo.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/multi_port.v.zip b/example_netlists/verilog_netlists/multi_port.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/multi_port.v.zip
rename to example_netlists/verilog_netlists/multi_port.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/namespace.v.zip b/example_netlists/verilog_netlists/namespace.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/namespace.v.zip
rename to example_netlists/verilog_netlists/namespace.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/netlist_with_large_integer.v.zip b/example_netlists/verilog_netlists/netlist_with_large_integer.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/netlist_with_large_integer.v.zip
rename to example_netlists/verilog_netlists/netlist_with_large_integer.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/one_counter.v.zip b/example_netlists/verilog_netlists/one_counter.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/one_counter.v.zip
rename to example_netlists/verilog_netlists/one_counter.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/passthrough_test.v.zip b/example_netlists/verilog_netlists/passthrough_test.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/passthrough_test.v.zip
rename to example_netlists/verilog_netlists/passthrough_test.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/port_test.v.zip b/example_netlists/verilog_netlists/port_test.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/port_test.v.zip
rename to example_netlists/verilog_netlists/port_test.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/ports_diff_modules.v.zip b/example_netlists/verilog_netlists/ports_diff_modules.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/ports_diff_modules.v.zip
rename to example_netlists/verilog_netlists/ports_diff_modules.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/register_file.v.zip b/example_netlists/verilog_netlists/register_file.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/register_file.v.zip
rename to example_netlists/verilog_netlists/register_file.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/riscv_multi_core.v.zip b/example_netlists/verilog_netlists/riscv_multi_core.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/riscv_multi_core.v.zip
rename to example_netlists/verilog_netlists/riscv_multi_core.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/sha3_core.v.zip b/example_netlists/verilog_netlists/sha3_core.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/sha3_core.v.zip
rename to example_netlists/verilog_netlists/sha3_core.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/shift_reg.v.zip b/example_netlists/verilog_netlists/shift_reg.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/shift_reg.v.zip
rename to example_netlists/verilog_netlists/shift_reg.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/synchronizer_test.v.zip b/example_netlists/verilog_netlists/synchronizer_test.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/synchronizer_test.v.zip
rename to example_netlists/verilog_netlists/synchronizer_test.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/synth_th1_slaac.v.zip b/example_netlists/verilog_netlists/synth_th1_slaac.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/synth_th1_slaac.v.zip
rename to example_netlists/verilog_netlists/synth_th1_slaac.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/testCountMult.v.zip b/example_netlists/verilog_netlists/testCountMult.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/testCountMult.v.zip
rename to example_netlists/verilog_netlists/testCountMult.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/three_layer_hierarchy.v.zip b/example_netlists/verilog_netlists/three_layer_hierarchy.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/three_layer_hierarchy.v.zip
rename to example_netlists/verilog_netlists/three_layer_hierarchy.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/three_stage_synchronizer.v.zip b/example_netlists/verilog_netlists/three_stage_synchronizer.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/three_stage_synchronizer.v.zip
rename to example_netlists/verilog_netlists/three_stage_synchronizer.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/three_stage_synchronizer2.v.zip b/example_netlists/verilog_netlists/three_stage_synchronizer2.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/three_stage_synchronizer2.v.zip
rename to example_netlists/verilog_netlists/three_stage_synchronizer2.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/unique_challenge.v.zip b/example_netlists/verilog_netlists/unique_challenge.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/unique_challenge.v.zip
rename to example_netlists/verilog_netlists/unique_challenge.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/unique_different_modules.v.zip b/example_netlists/verilog_netlists/unique_different_modules.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/unique_different_modules.v.zip
rename to example_netlists/verilog_netlists/unique_different_modules.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/unused_blackbox.v.zip b/example_netlists/verilog_netlists/unused_blackbox.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/unused_blackbox.v.zip
rename to example_netlists/verilog_netlists/unused_blackbox.v.zip
diff --git a/spydrnet/support_files/verilog_netlists/zpu4.v.zip b/example_netlists/verilog_netlists/zpu4.v.zip
similarity index 100%
rename from spydrnet/support_files/verilog_netlists/zpu4.v.zip
rename to example_netlists/verilog_netlists/zpu4.v.zip
diff --git a/examples/basic/built_in_libraries.py b/examples/basic/built_in_libraries.py
index c2d4075c..848efea4 100644
--- a/examples/basic/built_in_libraries.py
+++ b/examples/basic/built_in_libraries.py
@@ -28,7 +28,7 @@
print(port.name + " " + str(port.direction))
print("\nUsing the primitive library:")
-netlist_2 = sdn.parse("b13.v", XILINX_7SERIES)
+netlist_2 = sdn.parse("b13.v", architecture=XILINX_7SERIES)
for definition in netlist_2.get_definitions():
if definition is not netlist_2.top_instance.reference:
for port in definition.get_ports():
diff --git a/examples/basic/test.edf b/examples/basic/test.edf
deleted file mode 100644
index 24b51d04..00000000
--- a/examples/basic/test.edf
+++ /dev/null
@@ -1,88 +0,0 @@
-(edif netlist
- (edifversion 2 0 0)
- (edifLevel 0)
- (keywordmap (keywordlevel 0))
- (status
- (written
- (timeStamp 2023 03 21 11 11 58)
-
- (comment "Built by 'BYU spydrnet tool'")
- )
- )
- (Library work
- (edifLevel 0)
- (technology (numberDefinition ))
- (Cell AND2 (celltype GENERIC)
- (view netlist (viewtype NETLIST)
- (interface
- (port A(direction INPUT))
- (port B(direction INPUT))
- (port Q(direction OUTPUT))
- )
- )
- )
- (Cell OR2 (celltype GENERIC)
- (view netlist (viewtype NETLIST)
- (interface
- (port A(direction INPUT))
- (port B(direction INPUT))
- (port Q(direction OUTPUT))
- )
- )
- )
- (Cell widget (celltype GENERIC)
- (view netlist (viewtype NETLIST)
- (interface
- (port A(direction INPUT))
- (port B(direction INPUT))
- (port C(direction INPUT))
- (port D(direction INPUT))
- (port O(direction OUTPUT))
- )
- (contents
- (instance and2_1 (viewref netlist (cellref AND2(libraryref work)))
- )(instance and2_2 (viewref netlist (cellref AND2(libraryref work)))
- )(instance or2 (viewref netlist (cellref OR2(libraryref work)))
- )(net A (joined
- (portref A)
- (portref A (instanceref and2_1))
-
- )
- )(net B (joined
- (portref B)
- (portref B (instanceref and2_1))
-
- )
- )(net C (joined
- (portref C)
- (portref A (instanceref and2_2))
-
- )
- )(net D (joined
- (portref D)
- (portref B (instanceref and2_2))
-
- )
- )(net Q1 (joined
- (portref Q (instanceref and2_1))
- (portref A (instanceref or2))
-
- )
- )(net Q2 (joined
- (portref Q (instanceref and2_2))
- (portref B (instanceref or2))
-
- )
- )(net O (joined
- (portref O)
- (portref Q (instanceref or2))
-
- )
- ))
- )
- )
- )
- (design widget
- (cellref widget(libraryref work))
- )
- )
\ No newline at end of file
diff --git a/examples/extended/plot_connectivity_graph.py b/examples/extended/plot_connectivity_graph.py
index 78148740..7dc0f1cb 100644
--- a/examples/extended/plot_connectivity_graph.py
+++ b/examples/extended/plot_connectivity_graph.py
@@ -116,7 +116,7 @@ def get_leaf_instance_nodes(top_instance_node):
"""
This function returns all leaf instance nodes in a netlist.
"""
- leaf_instance_nodes = list()
+ leaf_instance_nodes = []
search_stack = [top_instance_node]
while search_stack:
current_node = search_stack.pop()
@@ -139,9 +139,9 @@ def get_downstream_nodes(node, include_top_ports):
This function finds downstream nodes (leaf instance and optionally top_level ports) from a given node. There are
some involved traversals included in this function (going from an InnerPin to and OuterPin and visa-versa).
"""
- downstream_nodes = list()
+ downstream_nodes = []
found_pin_nodes = set()
- search_stack = list()
+ search_stack = []
# Find starting wires if provided node is a leaf instance.
if isinstance(node.item, sdn.Instance):
instance = node.item
@@ -227,10 +227,10 @@ class Node:
def __init__(self, parent, item):
self.parent = parent
self.item = item
- self.children = dict()
+ self.children = {}
def get_hiearchical_name(self):
- parents = list()
+ parents = []
parent = self.parent
while parent:
parents.append(parent)
diff --git a/examples/extended/plot_flatten.py b/examples/extended/plot_flatten.py
index f4a74090..8726f726 100644
--- a/examples/extended/plot_flatten.py
+++ b/examples/extended/plot_flatten.py
@@ -97,14 +97,14 @@ def clean_up(instance):
def flatten_definition(definition, top_definition=False):
# Create a copy of the list of children
children = definition.children.copy()
- created = list()
+ created = []
# Loop through each pre-existing child of the definition
for child in children:
- leaf_grandchildren = list()
+ leaf_grandchildren = []
child_reference = child.reference
# Create a copy of the list of the children for the current child reference
grandchildren = child_reference.children.copy()
- map = dict()
+ map = {}
# Check if progress information should be printed
if top_definition and not is_black_box(child):
print("Need to move cells from", child['EDIF.identifier'],
diff --git a/examples/extended/plot_four_to_five_bit_counter.py b/examples/extended/plot_four_to_five_bit_counter.py
index 221c0729..55db56e2 100644
--- a/examples/extended/plot_four_to_five_bit_counter.py
+++ b/examples/extended/plot_four_to_five_bit_counter.py
@@ -75,7 +75,7 @@ def get_pin(instance, identifier):
ff['EDIF.identifier'] = 'out_reg_4_'
# Set the original identifier for the new instance (Being use to be consistence with example)
ff['EDIF.original_identifier'] = 'out_reg[4]'
-properties = list()
+properties = []
# Create properties for the new instance
properties.append({'identifier': 'INIT', 'value': "1'b0"})
ff['EDIF.properties'] = properties
diff --git a/examples/extended/plot_single_use_definitions.py b/examples/extended/plot_single_use_definitions.py
index 2e5e0a06..f69f749f 100644
--- a/examples/extended/plot_single_use_definitions.py
+++ b/examples/extended/plot_single_use_definitions.py
@@ -50,7 +50,7 @@ def get_reverse_topological_order(ir):
if not is_black_box(child):
depth_first_search.extend(trace_definition(child.reference))
visited = set()
- reverse_topological_order = list()
+ reverse_topological_order = []
while len(depth_first_search) != 0:
definition = depth_first_search.popleft()
if definition not in visited:
@@ -138,9 +138,9 @@ def definition_clean_up(definition):
def make_definition_copies(def_to_copy, num_of_copies):
- copies = dict()
+ copies = {}
copies[def_to_copy] = collections.deque()
- definition_copies[def_to_copy] = list()
+ definition_copies[def_to_copy] = []
for i in range(num_of_copies):
def_copy = sdn.Definition()
copy_definition(def_to_copy, def_copy, i)
@@ -171,11 +171,11 @@ def libraries_definitions(my_netlist):
print(" DEFINITIONS IN '",library.name,"':",definitions)
-definition_count = dict()
-original_inner_pin_to_new_inner_pin = dict()
-instance_map = dict()
-outer_pin_map = dict()
-definition_copies = dict()
+definition_count = {}
+original_inner_pin_to_new_inner_pin = {}
+instance_map = {}
+outer_pin_map = {}
+definition_copies = {}
example_name = 'unique_challenge'
ir = sdn.load_example_netlist_by_name(example_name)
diff --git a/examples/vivado/LUT_builder.py b/examples/vivado/LUT_builder.py
index a1530502..bdda0a1a 100644
--- a/examples/vivado/LUT_builder.py
+++ b/examples/vivado/LUT_builder.py
@@ -119,8 +119,8 @@
prim_LUT_pin_output = prim_LUT_port_output.create_pin()
# Create lookup table input ports and pins, and store them in lists
-prim_LUT_port_input_list = list()
-prim_LUT_pin_input_list = list()
+prim_LUT_port_input_list = []
+prim_LUT_pin_input_list = []
for i in range(LUT_SIZE):
prim_LUT_port_input = prim_LUT_def.create_port(
name="I" + str(i), direction=sdn.IN
@@ -143,8 +143,8 @@
my_LUT_pin_output = my_LUT_port_output.create_pin()
# Create ports and pins for the inputs to the custom LUT
-my_prim_LUT_port_input_list = list()
-my_LUT_pin_input_list = list()
+my_prim_LUT_port_input_list = []
+my_LUT_pin_input_list = []
for i in range(LUT_SIZE):
my_LUT_port_input = my_LUT_def.create_port(
name=string.ascii_uppercase[i], direction=sdn.IN
@@ -153,8 +153,8 @@
my_LUT_pin_input_list.append(my_LUT_port_input.create_pin())
# Create cables with wires to connect primitive LUT instance to ports
-my_LUT_cable_list = list()
-my_LUT_wire_list = list()
+my_LUT_cable_list = []
+my_LUT_wire_list = []
# cables with wires for input ports
for i in range(LUT_SIZE):
@@ -172,7 +172,7 @@
)
# Modify the lookup table configuration
-my_LUT_inst_properties = list()
+my_LUT_inst_properties = []
my_LUT_inst_properties.append(
{"identifier": "INIT", "value": "16'h" + str(hex(LUT_CONFIG))[2:]}
)
@@ -206,7 +206,7 @@
)
# instance switch input buffers
-top_sw_IBUF_inst_list = list()
+top_sw_IBUF_inst_list = []
for i in range(LUT_SIZE):
top_sw_IBUF_inst_list.append(
top_def.create_child(
diff --git a/pylint_output.txt b/pylint_output.txt
new file mode 100644
index 00000000..f013c2d0
--- /dev/null
+++ b/pylint_output.txt
@@ -0,0 +1,4016 @@
+************* Module .pylintrc
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'print-statement' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'parameter-unpacking' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'unpacking-in-except' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'old-raise-syntax' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'backtick' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'import-star-module-level' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'apply-builtin' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'basestring-builtin' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'buffer-builtin' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'cmp-builtin' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'coerce-builtin' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'execfile-builtin' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'file-builtin' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'long-builtin' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'raw_input-builtin' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'reduce-builtin' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'standarderror-builtin' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'unicode-builtin' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'xrange-builtin' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'coerce-method' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'delslice-method' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'getslice-method' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'setslice-method' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'no-absolute-import' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'old-division' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'dict-iter-method' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'dict-view-method' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'next-method-called' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'metaclass-assignment' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'indexing-exception' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'raising-string' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'reload-builtin' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'oct-method' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'hex-method' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'nonzero-method' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'cmp-method' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'input-builtin' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'round-builtin' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'intern-builtin' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'unichr-builtin' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'map-builtin-not-iterating' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'zip-builtin-not-iterating' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'range-builtin-not-iterating' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'filter-builtin-not-iterating' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'using-cmp-argument' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'div-method' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'idiv-method' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'rdiv-method' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'exception-message-attribute' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'invalid-str-codec' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'sys-max-int' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'bad-python3-import' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'deprecated-string-function' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'deprecated-str-translate-call' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'deprecated-itertools-function' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'deprecated-types-field' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'next-method-defined' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'dict-items-not-iterating' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'dict-keys-not-iterating' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'dict-values-not-iterating' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'deprecated-operator-function' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'deprecated-urllib-function' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'xreadlines-attribute' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'deprecated-sys-function' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'exception-escape' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: R0022: Useless option value for '--disable', 'comprehension-escape' was removed from pylint, see https://github.com/pylint-dev/pylint/pull/4942. (useless-option-value)
+.pylintrc:1:0: W0012: Unknown option value for '--disable', expected a valid pylint message and got 'long-suffix' (unknown-option-value)
+.pylintrc:1:0: W0012: Unknown option value for '--disable', expected a valid pylint message and got 'old-ne-operator' (unknown-option-value)
+.pylintrc:1:0: W0012: Unknown option value for '--disable', expected a valid pylint message and got 'old-octal-literal' (unknown-option-value)
+.pylintrc:1:0: W0012: Unknown option value for '--disable', expected a valid pylint message and got 'non-ascii-bytes-literal' (unknown-option-value)
+.pylintrc:1:0: W0012: Unknown option value for '--disable', expected a valid pylint message and got 'eq-without-hash' (unknown-option-value)
+************* Module spydrnet
+spydrnet/__init__.py:70:0: C0301: Line too long (117/100) (line-too-long)
+spydrnet/__init__.py:38:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/__init__.py:38:24: C0103: Argument name "LOG_LEVEL" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/__init__.py:38:24: W0621: Redefining name 'LOG_LEVEL' from outer scope (line 32) (redefined-outer-name)
+spydrnet/__init__.py:55:0: E1205: Too many arguments for logging format string (logging-too-many-args)
+spydrnet/__init__.py:58:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/__init__.py:68:12: W0621: Redefining name 'plugin' from outer scope (line 95) (redefined-outer-name)
+spydrnet/__init__.py:68:22: R1732: Consider using 'with' for resource-allocating operations (consider-using-with)
+spydrnet/__init__.py:68:22: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
+spydrnet/__init__.py:76:16: W1201: Use lazy % formatting in logging functions (logging-not-lazy)
+spydrnet/__init__.py:76:29: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/__init__.py:81:0: E1205: Too many arguments for logging format string (logging-too-many-args)
+spydrnet/__init__.py:84:0: C0413: Import "from spydrnet import release" should be placed at the top of the module (wrong-import-position)
+spydrnet/__init__.py:86:13: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/__init__.py:95:0: C0413: Import "from spydrnet.ir import *" should be placed at the top of the module (wrong-import-position)
+spydrnet/__init__.py:96:0: C0413: Import "from spydrnet.util.hierarchical_reference import HRef" should be placed at the top of the module (wrong-import-position)
+spydrnet/__init__.py:103:0: C0413: Import "from spydrnet.composers import compose" should be placed at the top of the module (wrong-import-position)
+spydrnet/__init__.py:104:0: C0413: Import "from spydrnet.parsers import parse" should be placed at the top of the module (wrong-import-position)
+spydrnet/__init__.py:105:0: C0413: Import "from spydrnet.plugins import namespace_manager" should be placed at the top of the module (wrong-import-position)
+spydrnet/__init__.py:106:0: C0413: Import "from spydrnet.testing.test import run as test" should be placed at the top of the module (wrong-import-position)
+spydrnet/__init__.py:107:0: C0413: Import "from spydrnet.util import get_cables, get_definitions, get_hcables, get_hinstances, get_hpins, get_hports, get_hwires, get_instances, get_libraries, get_netlists, get_pins, get_ports, get_wires" should be placed at the top of the module (wrong-import-position)
+spydrnet/__init__.py:122:0: C0413: Import "from spydrnet.util.selection import ALL, BOTH, INSIDE, OUTSIDE" should be placed at the top of the module (wrong-import-position)
+spydrnet/__init__.py:123:0: C0413: Import "from spydrnet.util.netlist_type import EDIF, VERILOG, EBLIF" should be placed at the top of the module (wrong-import-position)
+spydrnet/__init__.py:126:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/__init__.py:127:4: W0621: Redefining name 'example_netlists_path' from outer scope (line 166) (redefined-outer-name)
+spydrnet/__init__.py:148:12: W0621: Redefining name 'filename' from outer scope (line 95) (redefined-outer-name)
+spydrnet/__init__.py:136:8: W0104: Statement seems to have no effect (pointless-statement)
+spydrnet/__init__.py:149:23: W3101: Missing timeout argument for method 'requests.get' can cause your program to hang indefinitely (missing-timeout)
+spydrnet/__init__.py:152:12: C0415: Import outside toplevel (zipfile) (import-outside-toplevel)
+spydrnet/__init__.py:175:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/__init__.py:178:8: W0621: Redefining name 'filename' from outer scope (line 95) (redefined-outer-name)
+spydrnet/__init__.py:201:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/__init__.py:201:33: W0621: Redefining name 'name' from outer scope (line 95) (redefined-outer-name)
+spydrnet/__init__.py:202:4: W0621: Redefining name 'example_netlists_path' from outer scope (line 166) (redefined-outer-name)
+************* Module spydrnet.release
+spydrnet/release.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/release.py:15:0: W0622: Redefining built-in 'license' (redefined-builtin)
+spydrnet/release.py:5:0: C0103: Constant name "name" doesn't conform to UPPER_CASE naming style (invalid-name)
+spydrnet/release.py:6:0: C0103: Constant name "version" doesn't conform to UPPER_CASE naming style (invalid-name)
+spydrnet/release.py:7:0: C0103: Constant name "release" doesn't conform to UPPER_CASE naming style (invalid-name)
+spydrnet/release.py:8:0: C0103: Constant name "date" doesn't conform to UPPER_CASE naming style (invalid-name)
+spydrnet/release.py:12:0: C0103: Constant name "dev" doesn't conform to UPPER_CASE naming style (invalid-name)
+spydrnet/release.py:14:0: C0103: Constant name "description" doesn't conform to UPPER_CASE naming style (invalid-name)
+spydrnet/release.py:15:0: C0103: Constant name "license" doesn't conform to UPPER_CASE naming style (invalid-name)
+spydrnet/release.py:21:0: C0103: Constant name "maintainer" doesn't conform to UPPER_CASE naming style (invalid-name)
+spydrnet/release.py:22:0: C0103: Constant name "maintainer_email" doesn't conform to UPPER_CASE naming style (invalid-name)
+spydrnet/release.py:23:0: C0103: Constant name "url" doesn't conform to UPPER_CASE naming style (invalid-name)
+spydrnet/release.py:69:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/release.py:70:4: W0603: Using the global statement (global-statement)
+spydrnet/release.py:71:4: W0603: Using the global statement (global-statement)
+spydrnet/release.py:72:4: W0603: Using the global statement (global-statement)
+spydrnet/release.py:74:13: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
+spydrnet/release.py:74:39: C0103: Variable name "fi" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/release.py:83:15: W0612: Unused variable 'char' (unused-variable)
+spydrnet/release.py:94:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/release.py:95:4: C0415: Import outside toplevel (datetime) (import-outside-toplevel)
+spydrnet/release.py:96:4: C0415: Import outside toplevel (time) (import-outside-toplevel)
+spydrnet/release.py:97:4: C0415: Import outside toplevel (subprocess) (import-outside-toplevel)
+spydrnet/release.py:99:4: W0603: Using the global statement (global-statement)
+spydrnet/release.py:100:4: W0603: Using the global statement (global-statement)
+spydrnet/release.py:127:17: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
+spydrnet/release.py:127:44: C0103: Variable name "fh" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/release.py:119:25: R1732: Consider using 'with' for resource-allocating operations (consider-using-with)
+************* Module spydrnet.uniquify
+spydrnet/uniquify.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/uniquify.py:7:0: W0105: String statement has no effect (pointless-string-statement)
+spydrnet/uniquify.py:19:4: W0603: Using the global statement (global-statement)
+************* Module spydrnet.flatten
+spydrnet/flatten.py:87:1: W0511: #TODO put this code somewhere where people can use it to visualize simple netlists (fixme)
+spydrnet/flatten.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/flatten.py:4:0: W0401: Wildcard import spydrnet.ir (wildcard-import)
+spydrnet/flatten.py:6:0: W0105: String statement has no effect (pointless-string-statement)
+spydrnet/flatten.py:11:0: C0103: Constant name "unique_number" doesn't conform to UPPER_CASE naming style (invalid-name)
+spydrnet/flatten.py:13:0: C0103: Constant name "mod_name_uid" doesn't conform to UPPER_CASE naming style (invalid-name)
+spydrnet/flatten.py:17:4: W0603: Using the global statement (global-statement)
+spydrnet/flatten.py:23:20: C0103: Argument name "e" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/flatten.py:24:4: W0603: Using the global statement (global-statement)
+spydrnet/flatten.py:43:16: C0103: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/flatten.py:48:16: C0103: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/flatten.py:53:18: C0103: Argument name "e" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/flatten.py:56:8: W0602: Using global for 'mod_name_uid' but no assignment is done (global-variable-not-assigned)
+spydrnet/flatten.py:70:8: C0103: Variable name "d" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/flatten.py:73:8: C0103: Variable name "d" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/flatten.py:4:0: W0614: Unused import(s) importlib, typing, RegisterModule, filename, eachModule, cls, name, plugin, ext_cls, cls_bases, get_active_plugins, Element, FirstClassElement, Bundle, Pin, InnerPin, OuterPin, Port, Wire, Instance, Definition, Library and Netlist from wildcard import of spydrnet.ir (unused-wildcard-import)
+************* Module spydrnet.callback.callback_listener
+spydrnet/callback/callback_listener.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/callback/callback_listener.py:17:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:20:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:23:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:26:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:29:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:32:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:35:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:38:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:41:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:44:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:47:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:50:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:53:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:56:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:59:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:62:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:65:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:68:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:71:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:74:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:77:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:80:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:83:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:86:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:89:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:92:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:95:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:98:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:98:4: R0912: Too many branches (27/12) (too-many-branches)
+spydrnet/callback/callback_listener.py:98:4: R0915: Too many statements (55/50) (too-many-statements)
+spydrnet/callback/callback_listener.py:216:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:219:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:222:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:225:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:228:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:231:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:234:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:237:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:240:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:243:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:246:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:249:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:252:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:255:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:258:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:261:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:264:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:269:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:272:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:275:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:278:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:281:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:284:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:287:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:290:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:293:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:296:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:299:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:299:4: R0912: Too many branches (27/12) (too-many-branches)
+spydrnet/callback/callback_listener.py:299:4: R0915: Too many statements (55/50) (too-many-statements)
+spydrnet/callback/callback_listener.py:417:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:420:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:423:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:426:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:429:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:432:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:435:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:438:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:441:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:444:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:447:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:450:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:453:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:456:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:459:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:462:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:465:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:470:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:473:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:476:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:479:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:482:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:485:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:488:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:491:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:494:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:497:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/callback/callback_listener.py:4:0: R0904: Too many public methods (83/20) (too-many-public-methods)
+************* Module spydrnet.plugins
+spydrnet/plugins/__init__.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+************* Module spydrnet.plugins.namespace_manager.edif_namespace
+spydrnet/plugins/namespace_manager/edif_namespace.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/plugins/namespace_manager/edif_namespace.py:6:0: C0115: Missing class docstring (missing-class-docstring)
+spydrnet/plugins/namespace_manager/edif_namespace.py:26:4: C0103: Method name "_check_EDIF_identifier" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/plugins/namespace_manager/edif_namespace.py:29:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
+spydrnet/plugins/namespace_manager/edif_namespace.py:41:4: R0911: Too many return statements (11/6) (too-many-return-statements)
+spydrnet/plugins/namespace_manager/edif_namespace.py:41:4: R0912: Too many branches (38/12) (too-many-branches)
+spydrnet/plugins/namespace_manager/edif_namespace.py:41:4: R0915: Too many statements (58/50) (too-many-statements)
+spydrnet/plugins/namespace_manager/edif_namespace.py:180:4: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)
+************* Module spydrnet.plugins.namespace_manager.default_namespace
+spydrnet/plugins/namespace_manager/default_namespace.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/plugins/namespace_manager/default_namespace.py:4:0: C0115: Missing class docstring (missing-class-docstring)
+spydrnet/plugins/namespace_manager/default_namespace.py:18:38: W0613: Unused argument 'element' (unused-argument)
+spydrnet/plugins/namespace_manager/default_namespace.py:27:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/plugins/namespace_manager/default_namespace.py:27:27: W0613: Unused argument 'key' (unused-argument)
+spydrnet/plugins/namespace_manager/default_namespace.py:27:32: W0613: Unused argument 'value' (unused-argument)
+spydrnet/plugins/namespace_manager/default_namespace.py:31:4: R0912: Too many branches (23/12) (too-many-branches)
+spydrnet/plugins/namespace_manager/default_namespace.py:81:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/plugins/namespace_manager/default_namespace.py:89:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/plugins/namespace_manager/default_namespace.py:100:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/plugins/namespace_manager/default_namespace.py:112:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/plugins/namespace_manager/default_namespace.py:122:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/plugins/namespace_manager/default_namespace.py:122:4: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)
+************* Module spydrnet.plugins.namespace_manager
+spydrnet/plugins/namespace_manager/__init__.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/plugins/namespace_manager/__init__.py:17:0: C0115: Missing class docstring (missing-class-docstring)
+spydrnet/plugins/namespace_manager/__init__.py:36:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/plugins/namespace_manager/__init__.py:36:4: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)
+spydrnet/plugins/namespace_manager/__init__.py:100:24: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/plugins/namespace_manager/__init__.py:154:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/plugins/namespace_manager/__init__.py:178:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/plugins/namespace_manager/__init__.py:184:20: R1704: Redefining argument with the local name 'key' (redefined-argument-from-local)
+spydrnet/plugins/namespace_manager/__init__.py:191:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/plugins/namespace_manager/__init__.py:204:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/plugins/namespace_manager/__init__.py:223:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/plugins/namespace_manager/__init__.py:261:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/plugins/namespace_manager/__init__.py:17:0: R0904: Too many public methods (28/20) (too-many-public-methods)
+************* Module spydrnet.util.get_hpins
+spydrnet/util/get_hpins.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/util/get_hpins.py:103:0: R0913: Too many arguments (6/5) (too-many-arguments)
+spydrnet/util/get_hpins.py:111:0: R0914: Too many local variables (35/15) (too-many-locals)
+spydrnet/util/get_hpins.py:116:4: R1702: Too many nested blocks (8/5) (too-many-nested-blocks)
+spydrnet/util/get_hpins.py:116:4: R1702: Too many nested blocks (7/5) (too-many-nested-blocks)
+spydrnet/util/get_hpins.py:116:4: R1702: Too many nested blocks (9/5) (too-many-nested-blocks)
+spydrnet/util/get_hpins.py:116:4: R1702: Too many nested blocks (7/5) (too-many-nested-blocks)
+spydrnet/util/get_hpins.py:222:16: C0206: Consider iterating with .items() (consider-using-dict-items)
+spydrnet/util/get_hpins.py:211:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+spydrnet/util/get_hpins.py:111:0: R0912: Too many branches (47/12) (too-many-branches)
+spydrnet/util/get_hpins.py:111:0: R0915: Too many statements (94/50) (too-many-statements)
+spydrnet/util/get_hpins.py:211:4: R1702: Too many nested blocks (7/5) (too-many-nested-blocks)
+spydrnet/util/get_hpins.py:231:0: R0914: Too many local variables (18/15) (too-many-locals)
+spydrnet/util/get_hpins.py:257:40: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/util/get_hpins.py:234:4: R1702: Too many nested blocks (7/5) (too-many-nested-blocks)
+spydrnet/util/get_hpins.py:231:0: R0912: Too many branches (13/12) (too-many-branches)
+spydrnet/util/get_hpins.py:234:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+************* Module spydrnet.util.get_hcables
+spydrnet/util/get_hcables.py:159:0: C0325: Unnecessary parens after 'yield' keyword (superfluous-parens)
+spydrnet/util/get_hcables.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/util/get_hcables.py:78:12: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/util/get_hcables.py:117:0: R0913: Too many arguments (7/5) (too-many-arguments)
+spydrnet/util/get_hcables.py:129:0: R0913: Too many arguments (6/5) (too-many-arguments)
+spydrnet/util/get_hcables.py:129:0: R0914: Too many local variables (44/15) (too-many-locals)
+spydrnet/util/get_hcables.py:135:4: R1702: Too many nested blocks (8/5) (too-many-nested-blocks)
+spydrnet/util/get_hcables.py:135:4: R1702: Too many nested blocks (8/5) (too-many-nested-blocks)
+spydrnet/util/get_hcables.py:135:4: R1702: Too many nested blocks (8/5) (too-many-nested-blocks)
+spydrnet/util/get_hcables.py:135:4: R1702: Too many nested blocks (8/5) (too-many-nested-blocks)
+spydrnet/util/get_hcables.py:135:4: R1702: Too many nested blocks (10/5) (too-many-nested-blocks)
+spydrnet/util/get_hcables.py:135:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+spydrnet/util/get_hcables.py:278:16: C0206: Consider iterating with .items() (consider-using-dict-items)
+spydrnet/util/get_hcables.py:267:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+spydrnet/util/get_hcables.py:129:0: R0912: Too many branches (59/12) (too-many-branches)
+spydrnet/util/get_hcables.py:129:0: R0915: Too many statements (124/50) (too-many-statements)
+spydrnet/util/get_hcables.py:267:4: R1702: Too many nested blocks (7/5) (too-many-nested-blocks)
+spydrnet/util/get_hcables.py:290:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+spydrnet/util/get_hcables.py:290:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+spydrnet/util/get_hcables.py:343:0: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)
+spydrnet/util/get_hcables.py:355:0: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)
+************* Module spydrnet.util.get_hports
+spydrnet/util/get_hports.py:139:0: C0325: Unnecessary parens after 'yield' keyword (superfluous-parens)
+spydrnet/util/get_hports.py:149:0: C0325: Unnecessary parens after 'yield' keyword (superfluous-parens)
+spydrnet/util/get_hports.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/util/get_hports.py:103:0: R0913: Too many arguments (6/5) (too-many-arguments)
+spydrnet/util/get_hports.py:111:0: R0914: Too many local variables (33/15) (too-many-locals)
+spydrnet/util/get_hports.py:116:4: R1702: Too many nested blocks (7/5) (too-many-nested-blocks)
+spydrnet/util/get_hports.py:116:4: R1702: Too many nested blocks (7/5) (too-many-nested-blocks)
+spydrnet/util/get_hports.py:116:4: R1702: Too many nested blocks (9/5) (too-many-nested-blocks)
+spydrnet/util/get_hports.py:116:4: R1702: Too many nested blocks (7/5) (too-many-nested-blocks)
+spydrnet/util/get_hports.py:215:16: C0206: Consider iterating with .items() (consider-using-dict-items)
+spydrnet/util/get_hports.py:204:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+spydrnet/util/get_hports.py:111:0: R0912: Too many branches (45/12) (too-many-branches)
+spydrnet/util/get_hports.py:111:0: R0915: Too many statements (91/50) (too-many-statements)
+spydrnet/util/get_hports.py:204:4: R1702: Too many nested blocks (7/5) (too-many-nested-blocks)
+spydrnet/util/get_hports.py:227:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+spydrnet/util/get_hports.py:227:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+************* Module spydrnet.util.get_libraries
+spydrnet/util/get_libraries.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/util/get_libraries.py:96:12: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/util/get_libraries.py:139:0: R0913: Too many arguments (8/5) (too-many-arguments)
+spydrnet/util/get_libraries.py:151:0: R0913: Too many arguments (7/5) (too-many-arguments)
+spydrnet/util/get_libraries.py:151:0: R0914: Too many local variables (26/15) (too-many-locals)
+spydrnet/util/get_libraries.py:156:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+spydrnet/util/get_libraries.py:156:4: R1702: Too many nested blocks (8/5) (too-many-nested-blocks)
+spydrnet/util/get_libraries.py:156:4: R1702: Too many nested blocks (8/5) (too-many-nested-blocks)
+spydrnet/util/get_libraries.py:156:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+spydrnet/util/get_libraries.py:151:0: R0912: Too many branches (60/12) (too-many-branches)
+spydrnet/util/get_libraries.py:151:0: R0915: Too many statements (105/50) (too-many-statements)
+************* Module spydrnet.util.hierarchical_reference
+spydrnet/util/hierarchical_reference.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/util/hierarchical_reference.py:99:4: R0912: Too many branches (22/12) (too-many-branches)
+spydrnet/util/hierarchical_reference.py:151:4: R0912: Too many branches (17/12) (too-many-branches)
+spydrnet/util/hierarchical_reference.py:276:15: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/util/hierarchical_reference.py:324:16: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
+spydrnet/util/hierarchical_reference.py:317:4: R0911: Too many return statements (18/6) (too-many-return-statements)
+spydrnet/util/hierarchical_reference.py:317:4: R0912: Too many branches (24/12) (too-many-branches)
+spydrnet/util/hierarchical_reference.py:403:45: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/util/hierarchical_reference.py:404:16: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+************* Module spydrnet.util.netlist_type
+spydrnet/util/netlist_type.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/util/netlist_type.py:4:0: C0115: Missing class docstring (missing-class-docstring)
+************* Module spydrnet.util.architecture
+spydrnet/util/architecture.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+************* Module spydrnet.util.patterns
+spydrnet/util/patterns.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/util/patterns.py:6:4: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
+spydrnet/util/patterns.py:15:0: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)
+************* Module spydrnet.util.get_cables
+spydrnet/util/get_cables.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/util/get_cables.py:91:12: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/util/get_cables.py:131:0: R0913: Too many arguments (8/5) (too-many-arguments)
+spydrnet/util/get_cables.py:143:0: R0913: Too many arguments (7/5) (too-many-arguments)
+spydrnet/util/get_cables.py:143:0: R0914: Too many local variables (31/15) (too-many-locals)
+spydrnet/util/get_cables.py:149:4: R1702: Too many nested blocks (7/5) (too-many-nested-blocks)
+spydrnet/util/get_cables.py:149:4: R1702: Too many nested blocks (8/5) (too-many-nested-blocks)
+spydrnet/util/get_cables.py:149:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+spydrnet/util/get_cables.py:149:4: R1702: Too many nested blocks (7/5) (too-many-nested-blocks)
+spydrnet/util/get_cables.py:283:16: C0206: Consider iterating with .items() (consider-using-dict-items)
+spydrnet/util/get_cables.py:264:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+spydrnet/util/get_cables.py:143:0: R0912: Too many branches (73/12) (too-many-branches)
+spydrnet/util/get_cables.py:143:0: R0915: Too many statements (128/50) (too-many-statements)
+************* Module spydrnet.util.get_hwires
+spydrnet/util/get_hwires.py:161:0: C0325: Unnecessary parens after 'yield' keyword (superfluous-parens)
+spydrnet/util/get_hwires.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/util/get_hwires.py:78:12: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/util/get_hwires.py:117:0: R0913: Too many arguments (7/5) (too-many-arguments)
+spydrnet/util/get_hwires.py:129:0: R0913: Too many arguments (6/5) (too-many-arguments)
+spydrnet/util/get_hwires.py:129:0: R0914: Too many local variables (45/15) (too-many-locals)
+spydrnet/util/get_hwires.py:135:4: R1702: Too many nested blocks (9/5) (too-many-nested-blocks)
+spydrnet/util/get_hwires.py:135:4: R1702: Too many nested blocks (8/5) (too-many-nested-blocks)
+spydrnet/util/get_hwires.py:135:4: R1702: Too many nested blocks (8/5) (too-many-nested-blocks)
+spydrnet/util/get_hwires.py:135:4: R1702: Too many nested blocks (8/5) (too-many-nested-blocks)
+spydrnet/util/get_hwires.py:135:4: R1702: Too many nested blocks (10/5) (too-many-nested-blocks)
+spydrnet/util/get_hwires.py:135:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+spydrnet/util/get_hwires.py:284:16: C0206: Consider iterating with .items() (consider-using-dict-items)
+spydrnet/util/get_hwires.py:273:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+spydrnet/util/get_hwires.py:129:0: R0912: Too many branches (60/12) (too-many-branches)
+spydrnet/util/get_hwires.py:129:0: R0915: Too many statements (125/50) (too-many-statements)
+spydrnet/util/get_hwires.py:273:4: R1702: Too many nested blocks (7/5) (too-many-nested-blocks)
+spydrnet/util/get_hwires.py:293:0: R0914: Too many local variables (18/15) (too-many-locals)
+spydrnet/util/get_hwires.py:319:40: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/util/get_hwires.py:296:4: R1702: Too many nested blocks (7/5) (too-many-nested-blocks)
+spydrnet/util/get_hwires.py:293:0: R0912: Too many branches (13/12) (too-many-branches)
+spydrnet/util/get_hwires.py:296:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+spydrnet/util/get_hwires.py:359:0: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)
+spydrnet/util/get_hwires.py:371:0: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)
+************* Module spydrnet.util.get_instances
+spydrnet/util/get_instances.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/util/get_instances.py:97:12: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/util/get_instances.py:139:0: R0913: Too many arguments (8/5) (too-many-arguments)
+spydrnet/util/get_instances.py:151:0: R0913: Too many arguments (7/5) (too-many-arguments)
+spydrnet/util/get_instances.py:151:0: R0914: Too many local variables (27/15) (too-many-locals)
+spydrnet/util/get_instances.py:156:4: R1702: Too many nested blocks (8/5) (too-many-nested-blocks)
+spydrnet/util/get_instances.py:156:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+spydrnet/util/get_instances.py:156:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+spydrnet/util/get_instances.py:151:0: R0912: Too many branches (51/12) (too-many-branches)
+spydrnet/util/get_instances.py:151:0: R0915: Too many statements (91/50) (too-many-statements)
+************* Module spydrnet.util.selection
+spydrnet/util/selection.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/util/selection.py:4:0: C0115: Missing class docstring (missing-class-docstring)
+************* Module spydrnet.util
+spydrnet/util/__init__.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+************* Module spydrnet.util.get_ports
+spydrnet/util/get_ports.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/util/get_ports.py:96:0: R0913: Too many arguments (6/5) (too-many-arguments)
+spydrnet/util/get_ports.py:103:0: R0914: Too many local variables (21/15) (too-many-locals)
+spydrnet/util/get_ports.py:106:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+spydrnet/util/get_ports.py:172:16: C0206: Consider iterating with .items() (consider-using-dict-items)
+spydrnet/util/get_ports.py:152:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+spydrnet/util/get_ports.py:103:0: R0912: Too many branches (36/12) (too-many-branches)
+spydrnet/util/get_ports.py:103:0: R0915: Too many statements (63/50) (too-many-statements)
+************* Module spydrnet.util.get_wires
+spydrnet/util/get_wires.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/util/get_wires.py:60:12: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/util/get_wires.py:89:0: R0914: Too many local variables (19/15) (too-many-locals)
+spydrnet/util/get_wires.py:92:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+spydrnet/util/get_wires.py:92:4: R1702: Too many nested blocks (7/5) (too-many-nested-blocks)
+spydrnet/util/get_wires.py:92:4: R1702: Too many nested blocks (11/5) (too-many-nested-blocks)
+spydrnet/util/get_wires.py:157:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+spydrnet/util/get_wires.py:157:4: R1702: Too many nested blocks (8/5) (too-many-nested-blocks)
+spydrnet/util/get_wires.py:157:4: R1702: Too many nested blocks (10/5) (too-many-nested-blocks)
+spydrnet/util/get_wires.py:157:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+spydrnet/util/get_wires.py:89:0: R0912: Too many branches (68/12) (too-many-branches)
+spydrnet/util/get_wires.py:89:0: R0915: Too many statements (114/50) (too-many-statements)
+spydrnet/util/get_wires.py:157:4: R1702: Too many nested blocks (8/5) (too-many-nested-blocks)
+************* Module spydrnet.util.get_hinstances
+spydrnet/util/get_hinstances.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/util/get_hinstances.py:103:0: R0913: Too many arguments (6/5) (too-many-arguments)
+spydrnet/util/get_hinstances.py:111:0: R0914: Too many local variables (23/15) (too-many-locals)
+spydrnet/util/get_hinstances.py:188:16: C0206: Consider iterating with .items() (consider-using-dict-items)
+spydrnet/util/get_hinstances.py:177:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+spydrnet/util/get_hinstances.py:111:0: R0912: Too many branches (39/12) (too-many-branches)
+spydrnet/util/get_hinstances.py:111:0: R0915: Too many statements (74/50) (too-many-statements)
+spydrnet/util/get_hinstances.py:177:4: R1702: Too many nested blocks (7/5) (too-many-nested-blocks)
+spydrnet/util/get_hinstances.py:201:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+************* Module spydrnet.util.get_definitions
+spydrnet/util/get_definitions.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/util/get_definitions.py:95:12: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/util/get_definitions.py:137:0: R0913: Too many arguments (8/5) (too-many-arguments)
+spydrnet/util/get_definitions.py:149:0: R0913: Too many arguments (7/5) (too-many-arguments)
+spydrnet/util/get_definitions.py:149:0: R0914: Too many local variables (23/15) (too-many-locals)
+spydrnet/util/get_definitions.py:154:4: R1702: Too many nested blocks (7/5) (too-many-nested-blocks)
+spydrnet/util/get_definitions.py:154:4: R1702: Too many nested blocks (7/5) (too-many-nested-blocks)
+spydrnet/util/get_definitions.py:154:4: R1702: Too many nested blocks (7/5) (too-many-nested-blocks)
+spydrnet/util/get_definitions.py:154:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+spydrnet/util/get_definitions.py:154:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+spydrnet/util/get_definitions.py:251:16: C0206: Consider iterating with .items() (consider-using-dict-items)
+spydrnet/util/get_definitions.py:232:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
+spydrnet/util/get_definitions.py:149:0: R0912: Too many branches (56/12) (too-many-branches)
+spydrnet/util/get_definitions.py:149:0: R0915: Too many statements (94/50) (too-many-statements)
+************* Module spydrnet.util.get_netlists
+spydrnet/util/get_netlists.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/util/get_netlists.py:95:0: R0913: Too many arguments (6/5) (too-many-arguments)
+spydrnet/util/get_netlists.py:102:0: R0914: Too many local variables (22/15) (too-many-locals)
+spydrnet/util/get_netlists.py:102:0: R0912: Too many branches (31/12) (too-many-branches)
+spydrnet/util/get_netlists.py:102:0: R0915: Too many statements (62/50) (too-many-statements)
+************* Module spydrnet.util.get_pins
+spydrnet/util/get_pins.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/util/get_pins.py:56:12: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/util/get_pins.py:86:4: R1702: Too many nested blocks (7/5) (too-many-nested-blocks)
+spydrnet/util/get_pins.py:84:0: R0912: Too many branches (29/12) (too-many-branches)
+spydrnet/util/get_pins.py:84:0: R0915: Too many statements (54/50) (too-many-statements)
+************* Module spydrnet.global_state.global_callback
+spydrnet/global_state/global_callback.py:274:5: W0511: TODO: look into inlining this function perhaps, may not be necessary since it won't be called (fixme)
+spydrnet/global_state/global_callback.py:389:5: W0511: TODO: look into inlining this function perhaps, may not be necessary since it won't be called (fixme)
+spydrnet/global_state/global_callback.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/global_state/global_callback.py:165:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:169:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:173:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:177:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:181:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:185:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:189:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:193:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:197:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:201:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:205:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:209:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:213:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:217:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:221:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:225:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:229:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:233:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:237:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:241:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:245:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:249:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:253:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:257:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:261:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:265:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:269:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:280:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:284:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:288:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:292:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:296:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:300:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:304:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:308:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:312:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:316:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:320:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:324:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:328:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:332:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:336:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:340:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:344:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:348:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:352:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:356:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:360:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:364:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:368:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:372:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:376:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:380:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_callback.py:384:0: C0116: Missing function or method docstring (missing-function-docstring)
+************* Module spydrnet.global_state.global_service
+spydrnet/global_state/global_service.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/global_state/global_service.py:4:0: C0103: Constant name "_registered_hierarchical_lookup" doesn't conform to UPPER_CASE naming style (invalid-name)
+spydrnet/global_state/global_service.py:7:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_service.py:8:4: R1720: Unnecessary "else" after "raise", remove the "else" and de-indent the code inside it (no-else-raise)
+spydrnet/global_state/global_service.py:16:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_service.py:21:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/global_state/global_service.py:22:4: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
+spydrnet/global_state/global_service.py:21:0: R0911: Too many return statements (7/6) (too-many-return-statements)
+spydrnet/global_state/global_service.py:21:0: R0912: Too many branches (19/12) (too-many-branches)
+************* Module spydrnet.ir.netlist
+spydrnet/ir/netlist.py:131:9: W0511: TODO: should We have a DRC that makes sure the instance is of a definition contained in (fixme)
+spydrnet/ir/netlist.py:162:9: W0511: TODO: should We have a DRC that makes sure the instance is of a definition contained in (fixme)
+spydrnet/ir/netlist.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/ir/netlist.py:72:8: C0415: Import outside toplevel (spydrnet.composers.compose) (import-outside-toplevel)
+spydrnet/ir/netlist.py:126:12: R1701: Consider merging these isinstance calls to isinstance(instance, (Definition, Instance)) (consider-merging-isinstance)
+spydrnet/ir/netlist.py:130:8: W0212: Access to a protected member _call_netlist_top_instance of a client class (protected-access)
+spydrnet/ir/netlist.py:157:12: R1701: Consider merging these isinstance calls to isinstance(instance, (Definition, Instance)) (consider-merging-isinstance)
+spydrnet/ir/netlist.py:161:8: W0212: Access to a protected member _call_netlist_top_instance of a client class (protected-access)
+spydrnet/ir/netlist.py:204:8: W0212: Access to a protected member _call_netlist_add_library of a client class (protected-access)
+spydrnet/ir/netlist.py:209:8: W0212: Access to a protected member _netlist of a client class (protected-access)
+spydrnet/ir/netlist.py:252:8: W0212: Access to a protected member _call_netlist_remove_library of a client class (protected-access)
+spydrnet/ir/netlist.py:253:8: W0212: Access to a protected member _netlist of a client class (protected-access)
+spydrnet/ir/netlist.py:258:25: W0212: Access to a protected member _definitions of a client class (protected-access)
+spydrnet/ir/netlist.py:260:27: W0212: Access to a protected member _references of a client class (protected-access)
+spydrnet/ir/netlist.py:263:16: W0212: Access to a protected member _references of a client class (protected-access)
+spydrnet/ir/netlist.py:273:8: C0415: Import outside toplevel (spydrnet.ir.Netlist) (import-outside-toplevel)
+spydrnet/ir/netlist.py:275:8: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/netlist.py:277:8: W0212: Access to a protected member _data of a client class (protected-access)
+spydrnet/ir/netlist.py:281:33: W0212: Access to a protected member _clone of a client class (protected-access)
+spydrnet/ir/netlist.py:282:8: W0212: Access to a protected member _libraries of a client class (protected-access)
+spydrnet/ir/netlist.py:285:12: W0212: Access to a protected member _top_instance of a client class (protected-access)
+spydrnet/ir/netlist.py:288:16: W0212: Access to a protected member _top_instance of a client class (protected-access)
+spydrnet/ir/netlist.py:290:26: W0212: Access to a protected member _clone of a client class (protected-access)
+spydrnet/ir/netlist.py:291:16: W0212: Access to a protected member _clone_rip_and_replace_in_definition of a client class (protected-access)
+spydrnet/ir/netlist.py:292:16: W0212: Access to a protected member _clone_rip_and_replace_in_library of a client class (protected-access)
+spydrnet/ir/netlist.py:293:16: W0212: Access to a protected member _top_instance of a client class (protected-access)
+spydrnet/ir/netlist.py:295:23: W0212: Access to a protected member _libraries of a client class (protected-access)
+spydrnet/ir/netlist.py:296:12: W0212: Access to a protected member _netlist of a client class (protected-access)
+spydrnet/ir/netlist.py:297:12: W0212: Access to a protected member _clone_rip_and_replace of a client class (protected-access)
+spydrnet/ir/netlist.py:307:8: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/netlist.py:308:8: W0212: Access to a protected member _clone_rip of a client class (protected-access)
+spydrnet/ir/netlist.py:329:12: R1724: Unnecessary "else" after "continue", remove the "else" and de-indent the code inside it (no-else-continue)
+************* Module spydrnet.ir.innerpin
+spydrnet/ir/innerpin.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/ir/innerpin.py:46:8: C0415: Import outside toplevel (spydrnet.ir.InnerPin) (import-outside-toplevel)
+spydrnet/ir/innerpin.py:48:8: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/innerpin.py:50:8: W0212: Access to a protected member _wire of a client class (protected-access)
+spydrnet/ir/innerpin.py:51:8: W0212: Access to a protected member _port of a client class (protected-access)
+spydrnet/ir/innerpin.py:64:8: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/innerpin.py:65:8: W0212: Access to a protected member _clone_rip of a client class (protected-access)
+************* Module spydrnet.ir.element
+spydrnet/ir/element.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+************* Module spydrnet.ir.bundle
+spydrnet/ir/bundle.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+************* Module spydrnet.ir.instance
+spydrnet/ir/instance.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/ir/instance.py:57:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/ir/instance.py:76:8: W0212: Access to a protected member _call_instance_reference of a client class (protected-access)
+spydrnet/ir/instance.py:83:20: W0212: Access to a protected member _instance of a client class (protected-access)
+spydrnet/ir/instance.py:84:20: W0212: Access to a protected member _inner_pin of a client class (protected-access)
+spydrnet/ir/instance.py:87:16: W0212: Access to a protected member _references of a client class (protected-access)
+spydrnet/ir/instance.py:95:16: W0212: Access to a protected member _references of a client class (protected-access)
+spydrnet/ir/instance.py:99:24: W0212: Access to a protected member _inner_pin of a client class (protected-access)
+spydrnet/ir/instance.py:105:12: W0212: Access to a protected member _references of a client class (protected-access)
+spydrnet/ir/instance.py:113:8: C0415: Import outside toplevel (spydrnet.util.get_ports.get_ports) (import-outside-toplevel)
+spydrnet/ir/instance.py:129:12: C0103: Variable name "op" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/instance.py:130:12: W0212: Access to a protected member _clone_rip_and_replace of a client class (protected-access)
+spydrnet/ir/instance.py:139:12: C0103: Variable name "ip" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/instance.py:139:16: C0103: Variable name "op" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/instance.py:149:12: C0103: Variable name "op" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/instance.py:150:12: W0212: Access to a protected member _wire of a client class (protected-access)
+spydrnet/ir/instance.py:151:8: W0212: Access to a protected member _references of a client class (protected-access)
+spydrnet/ir/instance.py:161:8: C0415: Import outside toplevel (spydrnet.ir.Instance) (import-outside-toplevel)
+spydrnet/ir/instance.py:163:8: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/instance.py:165:8: W0212: Access to a protected member _parent of a client class (protected-access)
+spydrnet/ir/instance.py:167:28: W0212: Access to a protected member _clone of a client class (protected-access)
+spydrnet/ir/instance.py:168:12: W0212: Access to a protected member _instance of a client class (protected-access)
+spydrnet/ir/instance.py:169:12: W0212: Access to a protected member _pins of a client class (protected-access)
+spydrnet/ir/instance.py:170:8: W0212: Access to a protected member _reference of a client class (protected-access)
+spydrnet/ir/instance.py:171:8: W0212: Access to a protected member _data of a client class (protected-access)
+spydrnet/ir/instance.py:188:8: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/instance.py:189:8: W0212: Access to a protected member _clone_rip of a client class (protected-access)
+spydrnet/ir/instance.py:198:8: R1705: Unnecessary "elif" after "return", remove the leading "el" from "elif" (no-else-return)
+spydrnet/ir/instance.py:200:17: W0212: Access to a protected member _children of a client class (protected-access)
+spydrnet/ir/instance.py:200:55: W0212: Access to a protected member _cables of a client class (protected-access)
+spydrnet/ir/instance.py:208:8: R1703: The if statement can be replaced with 'return bool(test)' (simplifiable-if-statement)
+spydrnet/ir/instance.py:208:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
+spydrnet/ir/instance.py:239:4: C0116: Missing function or method docstring (missing-function-docstring)
+************* Module spydrnet.ir.outerpin
+spydrnet/ir/outerpin.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/ir/outerpin.py:22:8: C0415: Import outside toplevel (spydrnet.ir.OuterPin) (import-outside-toplevel)
+spydrnet/ir/outerpin.py:87:8: C0415: Import outside toplevel (spydrnet.ir.OuterPin) (import-outside-toplevel)
+spydrnet/ir/outerpin.py:89:8: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/outerpin.py:91:8: W0212: Access to a protected member _instance of a client class (protected-access)
+spydrnet/ir/outerpin.py:92:8: W0212: Access to a protected member _inner_pin of a client class (protected-access)
+spydrnet/ir/outerpin.py:93:8: W0212: Access to a protected member _wire of a client class (protected-access)
+spydrnet/ir/outerpin.py:105:8: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/outerpin.py:106:8: W0212: Access to a protected member _clone_rip of a client class (protected-access)
+spydrnet/ir/outerpin.py:109:4: C0116: Missing function or method docstring (missing-function-docstring)
+************* Module spydrnet.ir.library
+spydrnet/ir/library.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/ir/library.py:113:8: W0212: Access to a protected member _call_library_add_definition of a client class (protected-access)
+spydrnet/ir/library.py:118:8: W0212: Access to a protected member _library of a client class (protected-access)
+spydrnet/ir/library.py:161:8: W0212: Access to a protected member _call_library_remove_definition of a client class (protected-access)
+spydrnet/ir/library.py:162:8: W0212: Access to a protected member _library of a client class (protected-access)
+spydrnet/ir/library.py:167:8: W0107: Unnecessary pass statement (unnecessary-pass)
+spydrnet/ir/library.py:170:12: W0212: Access to a protected member _clone_rip_and_replace of a client class (protected-access)
+spydrnet/ir/library.py:179:23: W0212: Access to a protected member _references of a client class (protected-access)
+spydrnet/ir/library.py:182:28: W0212: Access to a protected member _children of a client class (protected-access)
+spydrnet/ir/library.py:183:16: W0212: Access to a protected member _references of a client class (protected-access)
+spydrnet/ir/library.py:183:16: W0212: Access to a protected member _reference of a client class (protected-access)
+spydrnet/ir/library.py:185:12: W0212: Access to a protected member _references of a client class (protected-access)
+spydrnet/ir/library.py:196:8: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/library.py:198:8: W0212: Access to a protected member _netlist of a client class (protected-access)
+spydrnet/ir/library.py:199:8: W0212: Access to a protected member _data of a client class (protected-access)
+spydrnet/ir/library.py:203:35: W0212: Access to a protected member _clone of a client class (protected-access)
+spydrnet/ir/library.py:204:8: W0212: Access to a protected member _definitions of a client class (protected-access)
+spydrnet/ir/library.py:206:26: W0212: Access to a protected member _definitions of a client class (protected-access)
+spydrnet/ir/library.py:207:12: W0212: Access to a protected member _library of a client class (protected-access)
+spydrnet/ir/library.py:208:12: W0212: Access to a protected member _clone_rip_and_replace of a client class (protected-access)
+spydrnet/ir/library.py:226:8: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/library.py:227:8: W0212: Access to a protected member _clone_rip of a client class (protected-access)
+************* Module spydrnet.ir.cable
+spydrnet/ir/cable.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/ir/cable.py:19:4: R0913: Too many arguments (6/5) (too-many-arguments)
+spydrnet/ir/cable.py:120:8: W0212: Access to a protected member _call_cable_add_wire of a client class (protected-access)
+spydrnet/ir/cable.py:125:8: W0212: Access to a protected member _cable of a client class (protected-access)
+spydrnet/ir/cable.py:161:8: W0212: Access to a protected member _call_cable_remove_wire of a client class (protected-access)
+spydrnet/ir/cable.py:162:8: W0212: Access to a protected member _cable of a client class (protected-access)
+spydrnet/ir/cable.py:167:12: C0103: Variable name "w" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/cable.py:168:12: W0212: Access to a protected member _clone_rip_and_replace of a client class (protected-access)
+spydrnet/ir/cable.py:173:12: C0103: Variable name "w" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/cable.py:174:12: W0212: Access to a protected member _clone_rip of a client class (protected-access)
+spydrnet/ir/cable.py:175:12: W0212: Access to a protected member _cable of a client class (protected-access)
+spydrnet/ir/cable.py:184:8: C0415: Import outside toplevel (spydrnet.ir.Cable) (import-outside-toplevel)
+spydrnet/ir/cable.py:186:8: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/cable.py:189:12: C0103: Variable name "w" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/cable.py:190:29: W0212: Access to a protected member _clone of a client class (protected-access)
+spydrnet/ir/cable.py:191:8: W0212: Access to a protected member _wires of a client class (protected-access)
+spydrnet/ir/cable.py:192:12: C0103: Variable name "w" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/cable.py:192:17: W0212: Access to a protected member _wires of a client class (protected-access)
+spydrnet/ir/cable.py:193:12: W0212: Access to a protected member _cable of a client class (protected-access)
+spydrnet/ir/cable.py:194:8: W0212: Access to a protected member _definition of a client class (protected-access)
+spydrnet/ir/cable.py:195:8: W0212: Access to a protected member _is_downto of a client class (protected-access)
+spydrnet/ir/cable.py:196:8: W0212: Access to a protected member _is_scalar of a client class (protected-access)
+spydrnet/ir/cable.py:197:8: W0212: Access to a protected member _lower_index of a client class (protected-access)
+spydrnet/ir/cable.py:198:8: W0212: Access to a protected member _data of a client class (protected-access)
+spydrnet/ir/cable.py:211:8: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/cable.py:212:8: W0212: Access to a protected member _clone_rip of a client class (protected-access)
+************* Module spydrnet.ir.definition
+spydrnet/ir/definition.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/ir/definition.py:149:4: R0913: Too many arguments (8/5) (too-many-arguments)
+spydrnet/ir/definition.py:195:8: W0212: Access to a protected member _call_definition_add_port of a client class (protected-access)
+spydrnet/ir/definition.py:200:8: W0212: Access to a protected member _definition of a client class (protected-access)
+spydrnet/ir/definition.py:203:16: W0212: Access to a protected member _pins of a client class (protected-access)
+spydrnet/ir/definition.py:248:8: W0212: Access to a protected member _call_definition_remove_port of a client class (protected-access)
+spydrnet/ir/definition.py:255:20: W0212: Access to a protected member _pins of a client class (protected-access)
+spydrnet/ir/definition.py:256:16: W0212: Access to a protected member _instance of a client class (protected-access)
+spydrnet/ir/definition.py:257:16: W0212: Access to a protected member _inner_pin of a client class (protected-access)
+spydrnet/ir/definition.py:258:8: W0212: Access to a protected member _definition of a client class (protected-access)
+spydrnet/ir/definition.py:312:8: W0212: Access to a protected member _call_definition_add_child of a client class (protected-access)
+spydrnet/ir/definition.py:317:8: W0212: Access to a protected member _parent of a client class (protected-access)
+spydrnet/ir/definition.py:362:8: W0212: Access to a protected member _call_definition_remove_child of a client class (protected-access)
+spydrnet/ir/definition.py:363:8: W0212: Access to a protected member _parent of a client class (protected-access)
+spydrnet/ir/definition.py:365:4: R0913: Too many arguments (7/5) (too-many-arguments)
+spydrnet/ir/definition.py:410:8: W0212: Access to a protected member _call_definition_add_cable of a client class (protected-access)
+spydrnet/ir/definition.py:415:8: W0212: Access to a protected member _definition of a client class (protected-access)
+spydrnet/ir/definition.py:461:8: W0212: Access to a protected member _call_definition_remove_cable of a client class (protected-access)
+spydrnet/ir/definition.py:462:8: W0212: Access to a protected member _definition of a client class (protected-access)
+spydrnet/ir/definition.py:485:16: W0212: Access to a protected member _reference of a client class (protected-access)
+spydrnet/ir/definition.py:486:16: W0212: Access to a protected member _clone_rip_and_replace_in_library of a client class (protected-access)
+spydrnet/ir/definition.py:494:12: W0212: Access to a protected member _references of a client class (protected-access)
+spydrnet/ir/definition.py:494:12: W0212: Access to a protected member _reference of a client class (protected-access)
+spydrnet/ir/definition.py:505:8: C0415: Import outside toplevel (spydrnet.ir.Definition) (import-outside-toplevel)
+spydrnet/ir/definition.py:507:8: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/definition.py:509:8: W0212: Access to a protected member _data of a client class (protected-access)
+spydrnet/ir/definition.py:510:8: W0212: Access to a protected member _library of a client class (protected-access)
+spydrnet/ir/definition.py:513:12: C0103: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/definition.py:514:29: W0212: Access to a protected member _clone of a client class (protected-access)
+spydrnet/ir/definition.py:515:8: W0212: Access to a protected member _ports of a client class (protected-access)
+spydrnet/ir/definition.py:518:12: C0103: Variable name "ca" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/definition.py:519:30: W0212: Access to a protected member _clone of a client class (protected-access)
+spydrnet/ir/definition.py:520:8: W0212: Access to a protected member _cables of a client class (protected-access)
+spydrnet/ir/definition.py:523:12: C0103: Variable name "ch" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/definition.py:524:32: W0212: Access to a protected member _clone of a client class (protected-access)
+spydrnet/ir/definition.py:525:8: W0212: Access to a protected member _children of a client class (protected-access)
+spydrnet/ir/definition.py:527:8: W0212: Access to a protected member _references of a client class (protected-access)
+spydrnet/ir/definition.py:529:20: W0212: Access to a protected member _ports of a client class (protected-access)
+spydrnet/ir/definition.py:530:12: W0212: Access to a protected member _definition of a client class (protected-access)
+spydrnet/ir/definition.py:531:12: W0212: Access to a protected member _clone_rip_and_replace of a client class (protected-access)
+spydrnet/ir/definition.py:533:21: W0212: Access to a protected member _cables of a client class (protected-access)
+spydrnet/ir/definition.py:534:12: W0212: Access to a protected member _definition of a client class (protected-access)
+spydrnet/ir/definition.py:535:12: W0212: Access to a protected member _clone_rip_and_replace of a client class (protected-access)
+spydrnet/ir/definition.py:537:24: W0212: Access to a protected member _children of a client class (protected-access)
+spydrnet/ir/definition.py:538:12: W0212: Access to a protected member _parent of a client class (protected-access)
+spydrnet/ir/definition.py:539:12: W0212: Access to a protected member _clone_rip_and_replace_in_definition of a client class (protected-access)
+spydrnet/ir/definition.py:556:8: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/definition.py:557:8: W0212: Access to a protected member _clone_rip of a client class (protected-access)
+************* Module spydrnet.ir.pin
+spydrnet/ir/pin.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+************* Module spydrnet.ir.first_class_element
+spydrnet/ir/first_class_element.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/ir/first_class_element.py:96:8: W0212: Access to a protected member _call_dictionary_pop of a client class (protected-access)
+************* Module spydrnet.ir
+spydrnet/ir/__init__.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/ir/__init__.py:44:40: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+************* Module spydrnet.ir.port
+spydrnet/ir/port.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/ir/port.py:35:4: R0913: Too many arguments (7/5) (too-many-arguments)
+spydrnet/ir/port.py:122:16: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/ir/port.py:169:8: W0404: Reimport 'InnerPin' (imported line 4) (reimported)
+spydrnet/ir/port.py:169:8: C0415: Import outside toplevel (spydrnet.ir.InnerPin) (import-outside-toplevel)
+spydrnet/ir/port.py:175:16: W0212: Access to a protected member _pins of a client class (protected-access)
+spydrnet/ir/port.py:191:8: W0212: Access to a protected member _call_port_add_pin of a client class (protected-access)
+spydrnet/ir/port.py:196:8: W0212: Access to a protected member _port of a client class (protected-access)
+spydrnet/ir/port.py:239:8: W0212: Access to a protected member _call_port_remove_pin of a client class (protected-access)
+spydrnet/ir/port.py:246:20: W0212: Access to a protected member _pins of a client class (protected-access)
+spydrnet/ir/port.py:247:16: W0212: Access to a protected member _instance of a client class (protected-access)
+spydrnet/ir/port.py:248:16: W0212: Access to a protected member _inner_pin of a client class (protected-access)
+spydrnet/ir/port.py:249:8: W0212: Access to a protected member _port of a client class (protected-access)
+spydrnet/ir/port.py:254:12: C0103: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/port.py:255:12: W0212: Access to a protected member _clone_rip_and_replace of a client class (protected-access)
+spydrnet/ir/port.py:261:12: C0103: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/port.py:262:12: W0212: Access to a protected member _clone_rip of a client class (protected-access)
+spydrnet/ir/port.py:273:8: C0415: Import outside toplevel (spydrnet.ir.Port) (import-outside-toplevel)
+spydrnet/ir/port.py:275:8: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/port.py:277:8: W0212: Access to a protected member _direction of a client class (protected-access)
+spydrnet/ir/port.py:279:12: C0103: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/port.py:280:28: W0212: Access to a protected member _clone of a client class (protected-access)
+spydrnet/ir/port.py:281:8: W0212: Access to a protected member _pins of a client class (protected-access)
+spydrnet/ir/port.py:282:8: W0212: Access to a protected member _definition of a client class (protected-access)
+spydrnet/ir/port.py:283:8: W0212: Access to a protected member _is_downto of a client class (protected-access)
+spydrnet/ir/port.py:284:8: W0212: Access to a protected member _is_scalar of a client class (protected-access)
+spydrnet/ir/port.py:285:8: W0212: Access to a protected member _lower_index of a client class (protected-access)
+spydrnet/ir/port.py:286:12: C0103: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/port.py:286:17: W0212: Access to a protected member _pins of a client class (protected-access)
+spydrnet/ir/port.py:287:12: W0212: Access to a protected member _port of a client class (protected-access)
+spydrnet/ir/port.py:288:8: W0212: Access to a protected member _data of a client class (protected-access)
+spydrnet/ir/port.py:302:8: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/port.py:303:8: W0212: Access to a protected member _clone_rip of a client class (protected-access)
+************* Module spydrnet.ir.wire
+spydrnet/ir/wire.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/ir/wire.py:48:8: W0212: Access to a protected member _call_wire_connect_pin of a client class (protected-access)
+spydrnet/ir/wire.py:59:12: W0212: Access to a protected member _wire of a client class (protected-access)
+spydrnet/ir/wire.py:67:8: W0212: Access to a protected member _wire of a client class (protected-access)
+spydrnet/ir/wire.py:136:8: W0212: Access to a protected member _call_wire_disconnect_pin of a client class (protected-access)
+spydrnet/ir/wire.py:137:8: W0212: Access to a protected member _wire of a client class (protected-access)
+spydrnet/ir/wire.py:143:12: C0103: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/wire.py:147:8: W0107: Unnecessary pass statement (unnecessary-pass)
+spydrnet/ir/wire.py:154:8: W0107: Unnecessary pass statement (unnecessary-pass)
+spydrnet/ir/wire.py:164:8: C0415: Import outside toplevel (spydrnet.ir.Wire) (import-outside-toplevel)
+spydrnet/ir/wire.py:166:8: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/wire.py:168:8: W0212: Access to a protected member _cable of a client class (protected-access)
+spydrnet/ir/wire.py:170:8: W0212: Access to a protected member _pins of a client class (protected-access)
+spydrnet/ir/wire.py:181:8: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/wire.py:182:8: W0212: Access to a protected member _clone_rip of a client class (protected-access)
+************* Module spydrnet.ir.views.outerpinsview
+spydrnet/ir/views/outerpinsview.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/ir/views/outerpinsview.py:5:0: C0115: Missing class docstring (missing-class-docstring)
+spydrnet/ir/views/outerpinsview.py:6:4: W0246: Useless parent or super() delegation in method '__init__' (useless-parent-delegation)
+************* Module spydrnet.ir.views.listview
+spydrnet/ir/views/listview.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/ir/views/listview.py:1:0: C0115: Missing class docstring (missing-class-docstring)
+spydrnet/ir/views/listview.py:54:23: C0103: Argument name "n" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/ir/views/listview.py:75:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/ir/views/listview.py:78:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/ir/views/listview.py:78:20: W0622: Redefining built-in 'object' (redefined-builtin)
+spydrnet/ir/views/listview.py:81:4: C0116: Missing function or method docstring (missing-function-docstring)
+************* Module spydrnet.ir.views.setview
+spydrnet/ir/views/setview.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/ir/views/setview.py:1:0: C0115: Missing class docstring (missing-class-docstring)
+spydrnet/ir/views/setview.py:73:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/ir/views/setview.py:76:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/ir/views/setview.py:79:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/ir/views/setview.py:82:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/ir/views/setview.py:85:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/ir/views/setview.py:88:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/ir/views/setview.py:91:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/ir/views/setview.py:94:4: C0116: Missing function or method docstring (missing-function-docstring)
+************* Module spydrnet.ir.views.dictview
+spydrnet/ir/views/dictview.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/ir/views/dictview.py:1:0: C0115: Missing class docstring (missing-class-docstring)
+spydrnet/ir/views/dictview.py:38:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/ir/views/dictview.py:41:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/ir/views/dictview.py:44:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/ir/views/dictview.py:47:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/ir/views/dictview.py:50:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/ir/views/dictview.py:53:4: C0116: Missing function or method docstring (missing-function-docstring)
+************* Module spydrnet.compare.compare_netlists
+spydrnet/compare/compare_netlists.py:133:0: C0301: Line too long (107/100) (line-too-long)
+spydrnet/compare/compare_netlists.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/compare/compare_netlists.py:5:0: C0115: Missing class docstring (missing-class-docstring)
+spydrnet/compare/compare_netlists.py:13:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/compare/compare_netlists.py:16:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/compare/compare_netlists.py:37:12: R1724: Unnecessary "else" after "continue", remove the "else" and de-indent the code inside it (no-else-continue)
+spydrnet/compare/compare_netlists.py:46:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/compare/compare_netlists.py:69:12: R1724: Unnecessary "else" after "continue", remove the "else" and de-indent the code inside it (no-else-continue)
+spydrnet/compare/compare_netlists.py:80:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/compare/compare_netlists.py:80:4: R0914: Too many local variables (20/15) (too-many-locals)
+spydrnet/compare/compare_netlists.py:100:12: R1724: Unnecessary "else" after "continue", remove the "else" and de-indent the code inside it (no-else-continue)
+spydrnet/compare/compare_netlists.py:121:12: R1724: Unnecessary "else" after "continue", remove the "else" and de-indent the code inside it (no-else-continue)
+spydrnet/compare/compare_netlists.py:136:12: R1724: Unnecessary "else" after "continue", remove the "else" and de-indent the code inside it (no-else-continue)
+spydrnet/compare/compare_netlists.py:141:16: R1724: Unnecessary "else" after "continue", remove the "else" and de-indent the code inside it (no-else-continue)
+spydrnet/compare/compare_netlists.py:159:8: C0103: Variable name "ci" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/compare/compare_netlists.py:166:12: C0103: Variable name "ci" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/compare/compare_netlists.py:168:8: C0103: Variable name "oi" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/compare/compare_netlists.py:175:12: C0103: Variable name "oi" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/compare/compare_netlists.py:177:8: C0206: Consider iterating with .items() (consider-using-dict-items)
+spydrnet/compare/compare_netlists.py:177:17: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary)
+spydrnet/compare/compare_netlists.py:80:4: R0912: Too many branches (18/12) (too-many-branches)
+spydrnet/compare/compare_netlists.py:182:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/compare/compare_netlists.py:208:23: C0123: Use isinstance() rather than type() for a typecheck. (unidiomatic-typecheck)
+spydrnet/compare/compare_netlists.py:216:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/compare/compare_netlists.py:233:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/compare/compare_netlists.py:238:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/compare/compare_netlists.py:274:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/compare/compare_netlists.py:287:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/compare/compare_netlists.py:325:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/compare/compare_netlists.py:329:12: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/compare/compare_netlists.py:344:12: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/compare/compare_netlists.py:366:12: C0200: Consider using enumerate instead of iterating with range and len (consider-using-enumerate)
+spydrnet/compare/compare_netlists.py:366:16: C0103: Variable name "x" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/compare/compare_netlists.py:367:25: W0612: Unused variable 'value' (unused-variable)
+spydrnet/compare/compare_netlists.py:373:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/compare/compare_netlists.py:381:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/compare/compare_netlists.py:381:4: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)
+************* Module spydrnet.composers
+spydrnet/composers/__init__.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/composers/__init__.py:7:0: W0102: Dangerous default value [] as argument (dangerous-default-value)
+spydrnet/composers/__init__.py:7:0: R0913: Too many arguments (6/5) (too-many-arguments)
+spydrnet/composers/__init__.py:21:12: W0719: Raising too general exception: Exception (broad-exception-raised)
+spydrnet/composers/__init__.py:30:27: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+************* Module spydrnet.composers.verilog.composer
+spydrnet/composers/verilog/composer.py:699:9: W0511: TODO maybe also check if all of the cable is used. So no skipped wires. (fixme)
+spydrnet/composers/verilog/composer.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/composers/verilog/composer.py:8:0: C0115: Missing class docstring (missing-class-docstring)
+spydrnet/composers/verilog/composer.py:8:0: R0902: Too many instance attributes (9/7) (too-many-instance-attributes)
+spydrnet/composers/verilog/composer.py:36:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/composers/verilog/composer.py:36:18: C0103: Argument name "ir" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:41:8: C0103: Variable name "f" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:41:12: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
+spydrnet/composers/verilog/composer.py:41:12: R1732: Consider using 'with' for resource-allocating operations (consider-using-with)
+spydrnet/composers/verilog/composer.py:70:16: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:90:16: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:111:8: W0107: Unnecessary pass statement (unnecessary-pass)
+spydrnet/composers/verilog/composer.py:113:38: C0103: Argument name "o" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:123:19: C0103: Variable name "v" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:185:12: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:213:12: C0103: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:222:12: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:238:12: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:264:12: C0103: Variable name "w" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:297:16: W0104: Statement seems to have no effect (pointless-statement)
+spydrnet/composers/verilog/composer.py:312:12: C0103: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:323:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/composers/verilog/composer.py:323:28: C0103: Argument name "p" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:348:12: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:357:12: C0103: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:374:12: C0103: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:376:12: C0103: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:394:8: C0103: Variable name "hi" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:395:8: C0103: Variable name "li" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:400:8: C0103: Variable name "hi" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:401:8: C0103: Variable name "li" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:370:8: W0612: Unused variable 'left_wires' (unused-variable)
+spydrnet/composers/verilog/composer.py:371:8: W0612: Unused variable 'right_wires' (unused-variable)
+spydrnet/composers/verilog/composer.py:412:15: C0103: Variable name "v" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:436:15: C0103: Variable name "v" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:461:12: C0103: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:485:12: C0103: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:502:16: C0103: Variable name "wl" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:503:16: C0103: Variable name "wr" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:506:20: C0103: Variable name "wl" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:507:16: C0103: Variable name "il" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:508:16: C0103: Variable name "ir" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:513:4: R0914: Too many local variables (16/15) (too-many-locals)
+spydrnet/composers/verilog/composer.py:519:12: C0103: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:532:12: C0103: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:539:16: C0103: Variable name "wl" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:540:16: C0103: Variable name "wr" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:543:20: C0103: Variable name "wl" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:544:16: C0103: Variable name "il" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:545:16: C0103: Variable name "ir" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:550:26: C0103: Argument name "o" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:599:27: E1120: No value for argument 'o' in method call (no-value-for-parameter)
+spydrnet/composers/verilog/composer.py:611:8: R1705: Unnecessary "elif" after "return", remove the leading "el" from "elif" (no-else-return)
+spydrnet/composers/verilog/composer.py:634:19: R1716: Simplify chained comparison between the operands (chained-comparison)
+spydrnet/composers/verilog/composer.py:650:16: R1716: Simplify chained comparison between the operands (chained-comparison)
+spydrnet/composers/verilog/composer.py:655:16: R1716: Simplify chained comparison between the operands (chained-comparison)
+spydrnet/composers/verilog/composer.py:667:12: C0103: Variable name "w" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:677:12: C0103: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:715:12: C0103: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/verilog/composer.py:721:37: C0103: Argument name "o" doesn't conform to snake_case naming style (invalid-name)
+************* Module spydrnet.composers.edif.edifify_names
+spydrnet/composers/edif/edifify_names.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/composers/edif/edifify_names.py:78:12: C0103: Variable name "r" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/edif/edifify_names.py:79:12: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
+spydrnet/composers/edif/edifify_names.py:96:8: C0200: Consider using enumerate instead of iterating with range and len (consider-using-enumerate)
+spydrnet/composers/edif/edifify_names.py:134:12: C0103: Variable name "r" doesn't conform to snake_case naming style (invalid-name)
+************* Module spydrnet.composers.edif.composer
+spydrnet/composers/edif/composer.py:352:13: W0511: TODO Clean up code in this if statement (fixme)
+spydrnet/composers/edif/composer.py:398:9: W0511: TODO this should be checked against some sort of metadata (fixme)
+spydrnet/composers/edif/composer.py:427:13: W0511: for port in cable.getConnectionList(): #TODO create fuction cable.getConnectionList() (fixme)
+spydrnet/composers/edif/composer.py:533:9: W0511: TODO this only handles string properties for now (fixme)
+spydrnet/composers/edif/composer.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/composers/edif/composer.py:4:0: W0401: Wildcard import spydrnet.ir (wildcard-import)
+spydrnet/composers/edif/composer.py:18:18: C0103: Argument name "ir" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/edif/composer.py:60:24: W0719: Raising too general exception: Exception (broad-exception-raised)
+spydrnet/composers/edif/composer.py:80:12: W0719: Raising too general exception: Exception (broad-exception-raised)
+spydrnet/composers/edif/composer.py:101:20: C0103: Argument name "o" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/edif/composer.py:127:12: C0103: Variable name "o" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/edif/composer.py:136:8: W0621: Redefining name 'name' from outer scope (line 4) (redefined-outer-name)
+spydrnet/composers/edif/composer.py:135:12: W0719: Raising too general exception: Exception (broad-exception-raised)
+spydrnet/composers/edif/composer.py:146:13: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
+spydrnet/composers/edif/composer.py:146:36: C0103: Variable name "fi" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/edif/composer.py:150:24: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
+spydrnet/composers/edif/composer.py:150:24: R1732: Consider using 'with' for resource-allocating operations (consider-using-with)
+spydrnet/composers/edif/composer.py:188:12: W0719: Raising too general exception: Exception (broad-exception-raised)
+spydrnet/composers/edif/composer.py:186:8: W0612: Unused variable 'test' (unused-variable)
+spydrnet/composers/edif/composer.py:220:28: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/composers/edif/composer.py:227:16: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/composers/edif/composer.py:233:20: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/composers/edif/composer.py:284:16: W0621: Redefining name 'name' from outer scope (line 4) (redefined-outer-name)
+spydrnet/composers/edif/composer.py:298:12: W0621: Redefining name 'name' from outer scope (line 4) (redefined-outer-name)
+spydrnet/composers/edif/composer.py:380:8: R1705: Unnecessary "elif" after "return", remove the leading "el" from "elif" (no-else-return)
+spydrnet/composers/edif/composer.py:449:12: W0621: Redefining name 'name' from outer scope (line 4) (redefined-outer-name)
+spydrnet/composers/edif/composer.py:457:12: C0103: Variable name "w" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/edif/composer.py:472:12: C0200: Consider using enumerate instead of iterating with range and len (consider-using-enumerate)
+spydrnet/composers/edif/composer.py:472:16: C0103: Variable name "x" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/edif/composer.py:485:8: W0107: Unnecessary pass statement (unnecessary-pass)
+spydrnet/composers/edif/composer.py:491:12: C0200: Consider using enumerate instead of iterating with range and len (consider-using-enumerate)
+spydrnet/composers/edif/composer.py:491:16: C0103: Variable name "x" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/edif/composer.py:487:42: W0613: Unused argument 'cable_name' (unused-argument)
+spydrnet/composers/edif/composer.py:512:30: C0103: Argument name "netlistObj" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/edif/composer.py:513:8: W0621: Redefining name 'name' from outer scope (line 4) (redefined-outer-name)
+spydrnet/composers/edif/composer.py:514:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
+spydrnet/composers/edif/composer.py:517:12: C0103: Variable name "oldName" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/edif/composer.py:28:8: W0201: Attribute 'output_filename' defined outside __init__ (attribute-defined-outside-init)
+spydrnet/composers/edif/composer.py:32:12: W0201: Attribute 'filename' defined outside __init__ (attribute-defined-outside-init)
+spydrnet/composers/edif/composer.py:8:0: R0903: Too few public methods (1/2) (too-few-public-methods)
+spydrnet/composers/edif/composer.py:2:0: W0611: Unused import inspect (unused-import)
+spydrnet/composers/edif/composer.py:4:0: W0614: Unused import(s) importlib, typing, RegisterModule, filename, eachModule, cls, name, plugin, ext_cls, cls_bases, get_active_plugins, Element, FirstClassElement, Bundle, Pin, InnerPin, Wire, Cable, Instance, Definition, Library and Netlist from wildcard import of spydrnet.ir (unused-wildcard-import)
+************* Module spydrnet.composers.eblif.eblif_composer
+spydrnet/composers/eblif/eblif_composer.py:181:0: C0325: Unnecessary parens after 'if' keyword (superfluous-parens)
+spydrnet/composers/eblif/eblif_composer.py:194:0: C0325: Unnecessary parens after 'if' keyword (superfluous-parens)
+spydrnet/composers/eblif/eblif_composer.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/composers/eblif/eblif_composer.py:6:0: C0115: Missing class docstring (missing-class-docstring)
+spydrnet/composers/eblif/eblif_composer.py:16:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/composers/eblif/eblif_composer.py:16:18: C0103: Argument name "ir" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/eblif/eblif_composer.py:20:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/composers/eblif/eblif_composer.py:22:12: C0103: Variable name "f" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/eblif/eblif_composer.py:22:16: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
+spydrnet/composers/eblif/eblif_composer.py:24:12: C0103: Variable name "f" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/eblif/eblif_composer.py:24:16: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
+spydrnet/composers/eblif/eblif_composer.py:24:16: R1732: Consider using 'with' for resource-allocating operations (consider-using-with)
+spydrnet/composers/eblif/eblif_composer.py:27:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/composers/eblif/eblif_composer.py:30:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/composers/eblif/eblif_composer.py:33:23: C0103: Argument name "ir" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/composers/eblif/eblif_composer.py:39:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/composers/eblif/eblif_composer.py:47:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/composers/eblif/eblif_composer.py:57:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/composers/eblif/eblif_composer.py:68:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/composers/eblif/eblif_composer.py:93:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/composers/eblif/eblif_composer.py:100:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/composers/eblif/eblif_composer.py:102:29: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary)
+spydrnet/composers/eblif/eblif_composer.py:104:27: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary)
+spydrnet/composers/eblif/eblif_composer.py:106:28: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary)
+spydrnet/composers/eblif/eblif_composer.py:108:28: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary)
+spydrnet/composers/eblif/eblif_composer.py:110:28: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary)
+spydrnet/composers/eblif/eblif_composer.py:113:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/composers/eblif/eblif_composer.py:121:12: W0622: Redefining built-in 'type' (redefined-builtin)
+spydrnet/composers/eblif/eblif_composer.py:129:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/composers/eblif/eblif_composer.py:146:57: W0640: Cell variable port defined in loop (cell-var-from-loop)
+spydrnet/composers/eblif/eblif_composer.py:129:4: R0912: Too many branches (13/12) (too-many-branches)
+spydrnet/composers/eblif/eblif_composer.py:165:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/composers/eblif/eblif_composer.py:203:16: W0104: Statement seems to have no effect (pointless-statement)
+spydrnet/composers/eblif/eblif_composer.py:207:16: W0104: Statement seems to have no effect (pointless-statement)
+spydrnet/composers/eblif/eblif_composer.py:211:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/composers/eblif/eblif_composer.py:223:62: W0640: Cell variable port_type defined in loop (cell-var-from-loop)
+spydrnet/composers/eblif/eblif_composer.py:236:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/composers/eblif/eblif_composer.py:244:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/composers/eblif/eblif_composer.py:256:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/composers/eblif/eblif_composer.py:278:4: C0116: Missing function or method docstring (missing-function-docstring)
+************* Module spydrnet.testing.test
+spydrnet/testing/test.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/testing/test.py:13:4: C0415: Import outside toplevel (pytest) (import-outside-toplevel)
+************* Module spydrnet.testing
+spydrnet/testing/__init__.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+************* Module spydrnet.shortcuts.getter
+spydrnet/shortcuts/getter.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/shortcuts/getter.py:1:0: C0115: Missing class docstring (missing-class-docstring)
+spydrnet/shortcuts/getter.py:9:8: C0415: Import outside toplevel (spydrnet.util.get_netlists) (import-outside-toplevel)
+spydrnet/shortcuts/getter.py:18:8: C0415: Import outside toplevel (spydrnet.util.get_libraries) (import-outside-toplevel)
+spydrnet/shortcuts/getter.py:27:8: C0415: Import outside toplevel (spydrnet.util.get_definitions) (import-outside-toplevel)
+spydrnet/shortcuts/getter.py:36:8: C0415: Import outside toplevel (spydrnet.util.get_instances) (import-outside-toplevel)
+spydrnet/shortcuts/getter.py:45:8: C0415: Import outside toplevel (spydrnet.util.get_ports) (import-outside-toplevel)
+spydrnet/shortcuts/getter.py:54:8: C0415: Import outside toplevel (spydrnet.util.get_pins) (import-outside-toplevel)
+spydrnet/shortcuts/getter.py:63:8: C0415: Import outside toplevel (spydrnet.util.get_cables) (import-outside-toplevel)
+spydrnet/shortcuts/getter.py:72:8: C0415: Import outside toplevel (spydrnet.util.get_wires) (import-outside-toplevel)
+spydrnet/shortcuts/getter.py:81:8: C0415: Import outside toplevel (spydrnet.util.get_hinstances) (import-outside-toplevel)
+spydrnet/shortcuts/getter.py:90:8: C0415: Import outside toplevel (spydrnet.util.get_hports) (import-outside-toplevel)
+spydrnet/shortcuts/getter.py:99:8: C0415: Import outside toplevel (spydrnet.util.get_hpins) (import-outside-toplevel)
+spydrnet/shortcuts/getter.py:108:8: C0415: Import outside toplevel (spydrnet.util.get_hcables) (import-outside-toplevel)
+spydrnet/shortcuts/getter.py:117:8: C0415: Import outside toplevel (spydrnet.util.get_hwires) (import-outside-toplevel)
+************* Module spydrnet.parsers.primitive_library_reader
+spydrnet/parsers/primitive_library_reader.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/parsers/primitive_library_reader.py:32:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/primitive_library_reader.py:45:14: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/parsers/primitive_library_reader.py:47:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/primitive_library_reader.py:53:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/primitive_library_reader.py:55:14: R1714: Consider merging these comparisons with 'in' by using 'token not in (vt.MODULE, vt.PRIMITIVE)'. Use a set instead if elements are hashable. (consider-using-in)
+spydrnet/parsers/primitive_library_reader.py:60:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/primitive_library_reader.py:65:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/primitive_library_reader.py:68:27: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary)
+spydrnet/parsers/primitive_library_reader.py:74:56: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary)
+spydrnet/parsers/primitive_library_reader.py:80:4: C0116: Missing function or method docstring (missing-function-docstring)
+************* Module spydrnet.parsers
+spydrnet/parsers/__init__.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/parsers/__init__.py:5:0: W0105: String statement has no effect (pointless-string-statement)
+spydrnet/parsers/__init__.py:50:46: W0622: Redefining built-in 'zip' (redefined-builtin)
+spydrnet/parsers/__init__.py:46:11: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/parsers/__init__.py:67:8: C0415: Import outside toplevel (spydrnet.parsers.edif.parser.EdifParser) (import-outside-toplevel)
+spydrnet/parsers/__init__.py:70:8: C0415: Import outside toplevel (spydrnet.parsers.verilog.parser.VerilogParser) (import-outside-toplevel)
+spydrnet/parsers/__init__.py:74:8: C0415: Import outside toplevel (spydrnet.parsers.eblif.eblif_parser.EBLIFParser) (import-outside-toplevel)
+spydrnet/parsers/__init__.py:78:27: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/parsers/__init__.py:88:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/__init__.py:94:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/__init__.py:95:4: C0415: Import outside toplevel (spydrnet.parsers.primitive_library_reader.PrimitiveLibraryReader) (import-outside-toplevel)
+spydrnet/parsers/__init__.py:101:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/__init__.py:102:4: C0415: Import outside toplevel (spydrnet.parsers.eblif.eblif_parser.EBLIFParser) (import-outside-toplevel)
+************* Module spydrnet.parsers.primatives.parse_primatives
+spydrnet/parsers/primatives/parse_primatives.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/parsers/primatives/parse_primatives.py:55:13: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
+spydrnet/parsers/primatives/parse_primatives.py:55:35: C0103: Variable name "vf" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/primatives/parse_primatives.py:69:12: R1724: Unnecessary "elif" after "continue", remove the leading "el" from "elif" (no-else-continue)
+spydrnet/parsers/primatives/parse_primatives.py:110:4: R0913: Too many arguments (6/5) (too-many-arguments)
+spydrnet/parsers/primatives/parse_primatives.py:111:21: E1101: Module 'spydrnet' has no 'create_definition' member (no-member)
+spydrnet/parsers/primatives/parse_primatives.py:114:12: C0103: Variable name "o" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/primatives/parse_primatives.py:116:12: C0103: Variable name "io" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/primatives/parse_primatives.py:110:40: W0613: Unused argument 'name' (unused-argument)
+spydrnet/parsers/primatives/parse_primatives.py:110:46: W0613: Unused argument 'parameters' (unused-argument)
+spydrnet/parsers/primatives/parse_primatives.py:121:15: E1101: Module 'spydrnet' has no 'create_port' member (no-member)
+spydrnet/parsers/primatives/parse_primatives.py:20:0: R0903: Too few public methods (1/2) (too-few-public-methods)
+************* Module spydrnet.parsers.verilog.verilog_tokens
+spydrnet/parsers/verilog/verilog_tokens.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/parsers/verilog/verilog_tokens.py:205:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/verilog_tokens.py:206:4: R1705: Unnecessary "elif" after "return", remove the leading "el" from "elif" (no-else-return)
+spydrnet/parsers/verilog/verilog_tokens.py:216:12: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/verilog/verilog_tokens.py:222:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/verilog_tokens.py:225:8: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/verilog/verilog_tokens.py:231:0: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/verilog_tokens.py:232:4: R1705: Unnecessary "elif" after "return", remove the leading "el" from "elif" (no-else-return)
+************* Module spydrnet.parsers.verilog.parser
+spydrnet/parsers/verilog/parser.py:567:0: C0301: Line too long (102/100) (line-too-long)
+spydrnet/parsers/verilog/parser.py:766:0: C0301: Line too long (101/100) (line-too-long)
+spydrnet/parsers/verilog/parser.py:1043:0: C0301: Line too long (108/100) (line-too-long)
+spydrnet/parsers/verilog/parser.py:1043:0: C0325: Unnecessary parens after 'if' keyword (superfluous-parens)
+spydrnet/parsers/verilog/parser.py:1423:0: C0301: Line too long (110/100) (line-too-long)
+spydrnet/parsers/verilog/parser.py:1527:0: C0301: Line too long (110/100) (line-too-long)
+spydrnet/parsers/verilog/parser.py:1:0: C0302: Too many lines in module (1610/1000) (too-many-lines)
+spydrnet/parsers/verilog/parser.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/parsers/verilog/parser.py:12:0: R0902: Too many instance attributes (12/7) (too-many-instance-attributes)
+spydrnet/parsers/verilog/parser.py:53:12: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
+spydrnet/parsers/verilog/parser.py:68:16: C0103: Variable name "v" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/verilog/parser.py:77:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:83:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:116:8: C2801: Unnecessarily calls dunder method __del__. Use del keyword. (unnecessary-dunder-call)
+spydrnet/parsers/verilog/parser.py:119:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:122:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:139:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:181:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:239:23: C0103: Variable name "v" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/verilog/parser.py:246:16: W0107: Unnecessary pass statement (unnecessary-pass)
+spydrnet/parsers/verilog/parser.py:181:4: R0912: Too many branches (18/12) (too-many-branches)
+spydrnet/parsers/verilog/parser.py:259:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:261:12: C0103: Variable name "d" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/verilog/parser.py:265:4: W0102: Dangerous default value [] as argument (dangerous-default-value)
+spydrnet/parsers/verilog/parser.py:275:15: R1714: Consider merging these comparisons with 'in' by using 'token in (vt.MODULE, vt.PRIMITIVE)'. Use a set instead if elements are hashable. (consider-using-in)
+spydrnet/parsers/verilog/parser.py:307:14: R1714: Consider merging these comparisons with 'in' by using 'token not in (vt.END_MODULE, vt.END_PRIMITIVE)'. Use a set instead if elements are hashable. (consider-using-in)
+spydrnet/parsers/verilog/parser.py:320:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:505:8: C0200: Consider using enumerate instead of iterating with range and len (consider-using-enumerate)
+spydrnet/parsers/verilog/parser.py:525:16: C0103: Variable name "w" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/verilog/parser.py:535:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:535:29: C0103: Argument name "w" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/verilog/parser.py:572:16: R1712: Consider using tuple unpacking for swapping variables (consider-swap-variables)
+spydrnet/parsers/verilog/parser.py:589:8: C0200: Consider using enumerate instead of iterating with range and len (consider-using-enumerate)
+spydrnet/parsers/verilog/parser.py:624:23: C0103: Variable name "v" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/verilog/parser.py:699:20: C0103: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/verilog/parser.py:714:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:748:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:868:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:884:19: C0103: Variable name "v" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/verilog/parser.py:899:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:918:8: C0103: Variable name "v" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/verilog/parser.py:927:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:993:12: C0200: Consider using enumerate instead of iterating with range and len (consider-using-enumerate)
+spydrnet/parsers/verilog/parser.py:1008:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:1008:28: C0103: Argument name "p" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/verilog/parser.py:1013:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:1013:4: R0914: Too many local variables (16/15) (too-many-locals)
+spydrnet/parsers/verilog/parser.py:1069:16: C0200: Consider using enumerate instead of iterating with range and len (consider-using-enumerate)
+spydrnet/parsers/verilog/parser.py:1079:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:1148:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
+spydrnet/parsers/verilog/parser.py:1165:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:1188:22: R1714: Consider merging these comparisons with 'in' by using 'token not in (vt.STAR, vt.COMMA)'. Use a set instead if elements are hashable. (consider-using-in)
+spydrnet/parsers/verilog/parser.py:1251:4: R0913: Too many arguments (7/5) (too-many-arguments)
+spydrnet/parsers/verilog/parser.py:1251:4: R0914: Too many local variables (16/15) (too-many-locals)
+spydrnet/parsers/verilog/parser.py:1275:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:1278:12: C0103: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/verilog/parser.py:1282:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:1283:15: C0103: Variable name "v" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/verilog/parser.py:1287:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:1288:15: C0103: Variable name "v" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/verilog/parser.py:1291:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:1291:43: C0103: Argument name "v" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/verilog/parser.py:1301:12: C0103: Variable name "w" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/verilog/parser.py:1302:16: C0103: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/verilog/parser.py:1307:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:1316:16: C0103: Variable name "w" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/verilog/parser.py:1329:16: C0103: Variable name "w" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/verilog/parser.py:1334:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:1339:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
+spydrnet/parsers/verilog/parser.py:1348:4: W0105: String statement has no effect (pointless-string-statement)
+spydrnet/parsers/verilog/parser.py:1385:8: C0200: Consider using enumerate instead of iterating with range and len (consider-using-enumerate)
+spydrnet/parsers/verilog/parser.py:1394:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:1394:4: R0913: Too many arguments (6/5) (too-many-arguments)
+spydrnet/parsers/verilog/parser.py:1441:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:1441:4: R0913: Too many arguments (6/5) (too-many-arguments)
+spydrnet/parsers/verilog/parser.py:1464:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:1470:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:1487:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:1487:4: R0913: Too many arguments (7/5) (too-many-arguments)
+spydrnet/parsers/verilog/parser.py:1536:16: W0104: Statement seems to have no effect (pointless-statement)
+spydrnet/parsers/verilog/parser.py:1487:4: R0912: Too many branches (13/12) (too-many-branches)
+spydrnet/parsers/verilog/parser.py:1550:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:1550:4: R0913: Too many arguments (6/5) (too-many-arguments)
+spydrnet/parsers/verilog/parser.py:1573:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:1579:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:1582:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:1584:12: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/verilog/parser.py:1593:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/parser.py:1594:12: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/verilog/parser.py:12:0: R0904: Too many public methods (59/20) (too-many-public-methods)
+************* Module spydrnet.parsers.verilog.tokenizer
+spydrnet/parsers/verilog/tokenizer.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/parsers/verilog/tokenizer.py:13:0: C0115: Missing class docstring (missing-class-docstring)
+spydrnet/parsers/verilog/tokenizer.py:15:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/tokenizer.py:20:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/tokenizer.py:26:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/tokenizer.py:37:16: W0622: Redefining built-in 'zip' (redefined-builtin)
+spydrnet/parsers/verilog/tokenizer.py:44:36: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
+spydrnet/parsers/verilog/tokenizer.py:54:36: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
+spydrnet/parsers/verilog/tokenizer.py:47:22: R1732: Consider using 'with' for resource-allocating operations (consider-using-with)
+spydrnet/parsers/verilog/tokenizer.py:50:25: R1732: Consider using 'with' for resource-allocating operations (consider-using-with)
+spydrnet/parsers/verilog/tokenizer.py:54:36: R1732: Consider using 'with' for resource-allocating operations (consider-using-with)
+spydrnet/parsers/verilog/tokenizer.py:67:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/tokenizer.py:74:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/tokenizer.py:82:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/tokenizer.py:83:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
+spydrnet/parsers/verilog/tokenizer.py:100:12: C0103: Variable name "tf" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/verilog/tokenizer.py:102:20: C0103: Variable name "ch" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/verilog/tokenizer.py:118:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/tokenizer.py:123:0: C0115: Missing class docstring (missing-class-docstring)
+spydrnet/parsers/verilog/tokenizer.py:135:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/tokenizer.py:139:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/tokenizer.py:146:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/tokenizer.py:154:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/tokenizer.py:155:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
+spydrnet/parsers/verilog/tokenizer.py:5:0: W0611: Unused import re (unused-import)
+************* Module spydrnet.parsers.verilog.verilog_token_factory
+spydrnet/parsers/verilog/verilog_token_factory.py:13:0: C0301: Line too long (114/100) (line-too-long)
+spydrnet/parsers/verilog/verilog_token_factory.py:117:0: C0301: Line too long (114/100) (line-too-long)
+spydrnet/parsers/verilog/verilog_token_factory.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/parsers/verilog/verilog_token_factory.py:4:0: C0115: Missing class docstring (missing-class-docstring)
+spydrnet/parsers/verilog/verilog_token_factory.py:15:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/verilog_token_factory.py:18:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/verilog_token_factory.py:27:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/verilog_token_factory.py:44:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/verilog/verilog_token_factory.py:121:4: C0116: Missing function or method docstring (missing-function-docstring)
+************* Module spydrnet.parsers.edif.edif_tokens
+spydrnet/parsers/edif/edif_tokens.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+************* Module spydrnet.parsers.edif.parser
+spydrnet/parsers/edif/parser.py:1017:0: C0301: Line too long (109/100) (line-too-long)
+spydrnet/parsers/edif/parser.py:1031:0: C0301: Line too long (115/100) (line-too-long)
+spydrnet/parsers/edif/parser.py:1:0: C0302: Too many lines in module (1228/1000) (too-many-lines)
+spydrnet/parsers/edif/parser.py:462:21: W0511: TODO: what about multi-dimensional ports, non-downto ports, and when (fixme)
+spydrnet/parsers/edif/parser.py:478:13: W0511: TODO: what about single pin array ports with a non_zero starting index. (fixme)
+spydrnet/parsers/edif/parser.py:571:21: W0511: TODO: Add warning about merging nets together (fixme)
+spydrnet/parsers/edif/parser.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/parsers/edif/parser.py:5:0: W0401: Wildcard import spydrnet.parsers.edif.edif_tokens (wildcard-import)
+spydrnet/parsers/edif/parser.py:10:0: C0115: Missing class docstring (missing-class-docstring)
+spydrnet/parsers/edif/parser.py:11:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:18:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:24:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:36:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:42:8: C2801: Unnecessarily calls dunder method __del__. Use del keyword. (unnecessary-dunder-call)
+spydrnet/parsers/edif/parser.py:44:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:50:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:59:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:64:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:64:4: C0103: Method name "parse_edifVersion" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:73:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:73:4: C0103: Method name "parse_edifLevel" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:81:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:81:4: C0103: Method name "parse_keywordMap" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:90:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:90:4: C0103: Method name "parse_keywordLevel" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:98:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:125:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:136:38: E1131: unsupported operand type(s) for | (unsupported-binary-operation)
+spydrnet/parsers/edif/parser.py:136:38: E1131: unsupported operand type(s) for | (unsupported-binary-operation)
+spydrnet/parsers/edif/parser.py:140:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:147:8: C0103: Variable name "has_dataOrigin" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:158:16: C0103: Variable name "has_dataOrigin" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:185:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:185:4: C0103: Method name "parse_timeStamp" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:197:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:204:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:219:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:223:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:227:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:249:16: C0103: Variable name "e" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:257:28: W0707: Consider explicitly re-raising using 'except ValueError as exc' and 'raise e from exc' (raise-missing-from)
+spydrnet/parsers/edif/parser.py:272:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:276:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:276:4: C0103: Method name "parse_numberDefinition" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:280:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:289:8: C0103: Variable name "has_viewMap" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:298:16: C0103: Variable name "has_viewMap" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:315:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:315:4: C0103: Method name "parse_cellType" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:330:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:359:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:359:4: C0103: Method name "parse_viewType" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:363:12: R0916: Too many boolean expressions in if statement (10/5) (too-many-boolean-expressions)
+spydrnet/parsers/edif/parser.py:396:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:396:4: R0912: Too many branches (19/12) (too-many-branches)
+spydrnet/parsers/edif/parser.py:442:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:446:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:446:4: R0912: Too many branches (21/12) (too-many-branches)
+spydrnet/parsers/edif/parser.py:446:4: R0915: Too many statements (59/50) (too-many-statements)
+spydrnet/parsers/edif/parser.py:516:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:524:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:538:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:547:16: C0103: Variable name "e" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:555:28: W0707: Consider explicitly re-raising using 'except ValueError as exc' and 'raise e from exc' (raise-missing-from)
+spydrnet/parsers/edif/parser.py:570:16: C0103: Variable name "e" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:538:4: R0912: Too many branches (29/12) (too-many-branches)
+spydrnet/parsers/edif/parser.py:538:4: R0915: Too many statements (68/50) (too-many-statements)
+spydrnet/parsers/edif/parser.py:570:16: W0612: Unused variable 'e' (unused-variable)
+spydrnet/parsers/edif/parser.py:624:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:652:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:652:4: C0103: Method name "parse_viewRef" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:663:16: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/parsers/edif/parser.py:673:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:673:4: C0103: Method name "parse_cellRef" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:694:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:694:4: C0103: Method name "parse_libraryRef" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:713:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:733:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:748:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:748:4: C0103: Method name "parse_portRef" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:762:12: R1720: Unnecessary "elif" after "raise", remove the leading "el" from "elif" (no-else-raise)
+spydrnet/parsers/edif/parser.py:794:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:794:4: C0103: Method name "parse_instanceRef" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:798:8: R1720: Unnecessary "else" after "raise", remove the "else" and de-indent the code inside it (no-else-raise)
+spydrnet/parsers/edif/parser.py:801:12: W0101: Unreachable code (unreachable)
+spydrnet/parsers/edif/parser.py:816:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:825:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:825:4: C0103: Method name "parse_viewMap" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:829:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:853:26: W0631: Using possibly undefined loop variable 'library' (undefined-loop-variable)
+spydrnet/parsers/edif/parser.py:856:29: W0631: Using possibly undefined loop variable 'definition' (undefined-loop-variable)
+spydrnet/parsers/edif/parser.py:861:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:861:4: C0103: Method name "parse_dataOrigin" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:865:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:865:4: C0103: Method name "parse_userData" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:869:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:879:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:884:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:889:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:928:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:928:4: C0103: Method name "parse_typedValue" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:943:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:956:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:960:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:969:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:976:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:980:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:984:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:987:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:987:4: C0103: Method name "parse_nameRef" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:992:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:992:4: C0103: Method name "parse_nameDef" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:1001:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:1001:4: R0914: Too many local variables (19/15) (too-many-locals)
+spydrnet/parsers/edif/parser.py:1035:24: C0103: Variable name "w" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:1036:24: C0103: Variable name "ew" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:1039:28: C0103: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:1063:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:1079:35: W0631: Using possibly undefined loop variable 'i' (undefined-loop-variable)
+spydrnet/parsers/edif/parser.py:1110:35: W0631: Using possibly undefined loop variable 'i' (undefined-loop-variable)
+spydrnet/parsers/edif/parser.py:1113:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:1124:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:1129:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:1129:4: C0103: Method name "parse_stringToken" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:1134:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:1134:4: C0103: Method name "parse_integerToken" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/parser.py:1139:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:1143:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:1148:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:1152:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:1155:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:1167:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:1174:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:1183:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:1186:16: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/parsers/edif/parser.py:1192:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:1197:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:1202:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:1207:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:1211:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:1217:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/parser.py:40:8: W0201: Attribute 'netlist' defined outside __init__ (attribute-defined-outside-init)
+spydrnet/parsers/edif/parser.py:10:0: R0904: Too many public methods (79/20) (too-many-public-methods)
+************* Module spydrnet.parsers.edif.tokenizer
+spydrnet/parsers/edif/tokenizer.py:193:0: C0301: Line too long (179/100) (line-too-long)
+spydrnet/parsers/edif/tokenizer.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/parsers/edif/tokenizer.py:8:0: C0115: Missing class docstring (missing-class-docstring)
+spydrnet/parsers/edif/tokenizer.py:10:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/tokenizer.py:15:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/tokenizer.py:21:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/tokenizer.py:32:16: W0622: Redefining built-in 'zip' (redefined-builtin)
+spydrnet/parsers/edif/tokenizer.py:39:36: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
+spydrnet/parsers/edif/tokenizer.py:49:36: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
+spydrnet/parsers/edif/tokenizer.py:42:22: R1732: Consider using 'with' for resource-allocating operations (consider-using-with)
+spydrnet/parsers/edif/tokenizer.py:45:25: R1732: Consider using 'with' for resource-allocating operations (consider-using-with)
+spydrnet/parsers/edif/tokenizer.py:49:36: R1732: Consider using 'with' for resource-allocating operations (consider-using-with)
+spydrnet/parsers/edif/tokenizer.py:62:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/tokenizer.py:69:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/tokenizer.py:77:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/tokenizer.py:78:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
+spydrnet/parsers/edif/tokenizer.py:84:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/tokenizer.py:90:20: C0103: Variable name "ch" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/tokenizer.py:84:4: R0912: Too many branches (15/12) (too-many-branches)
+spydrnet/parsers/edif/tokenizer.py:126:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/tokenizer.py:130:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/tokenizer.py:133:16: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/parsers/edif/tokenizer.py:138:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/tokenizer.py:142:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/tokenizer.py:146:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/tokenizer.py:147:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
+spydrnet/parsers/edif/tokenizer.py:151:12: R1705: Unnecessary "elif" after "return", remove the leading "el" from "elif" (no-else-return)
+spydrnet/parsers/edif/tokenizer.py:157:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/tokenizer.py:160:16: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/parsers/edif/tokenizer.py:165:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/tokenizer.py:170:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/tokenizer.py:170:4: C0103: Method name "expect_valid_integerToken" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/tokenizer.py:173:16: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/parsers/edif/tokenizer.py:178:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/tokenizer.py:178:4: C0103: Method name "is_valid_integerToken" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/tokenizer.py:183:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/tokenizer.py:183:4: C0103: Method name "expect_valid_stringToken" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/edif/tokenizer.py:186:16: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/parsers/edif/tokenizer.py:191:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/edif/tokenizer.py:191:4: C0103: Method name "is_valid_stringToken" doesn't conform to snake_case naming style (invalid-name)
+************* Module spydrnet.parsers.eblif.eblif_parser
+spydrnet/parsers/eblif/eblif_parser.py:296:0: C0301: Line too long (121/100) (line-too-long)
+spydrnet/parsers/eblif/eblif_parser.py:297:0: C0301: Line too long (103/100) (line-too-long)
+spydrnet/parsers/eblif/eblif_parser.py:491:0: C0301: Line too long (109/100) (line-too-long)
+spydrnet/parsers/eblif/eblif_parser.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:12:0: R0902: Too many instance attributes (11/7) (too-many-instance-attributes)
+spydrnet/parsers/eblif/eblif_parser.py:28:12: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
+spydrnet/parsers/eblif/eblif_parser.py:43:16: C0103: Variable name "v" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/eblif/eblif_parser.py:52:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:58:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:76:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:82:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:87:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:103:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:109:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:137:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:149:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:157:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:175:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:201:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:206:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:217:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:230:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:251:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:264:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:293:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:312:62: W0640: Cell variable port_name defined in loop (cell-var-from-loop)
+spydrnet/parsers/eblif/eblif_parser.py:313:61: W0640: Cell variable pin_index defined in loop (cell-var-from-loop)
+spydrnet/parsers/eblif/eblif_parser.py:318:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:326:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:329:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:333:12: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
+spydrnet/parsers/eblif/eblif_parser.py:352:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:355:19: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary)
+spydrnet/parsers/eblif/eblif_parser.py:364:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:379:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:389:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:395:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:405:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:453:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:460:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:466:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:481:25: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary)
+spydrnet/parsers/eblif/eblif_parser.py:501:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:511:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:527:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:572:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:576:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:580:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_parser.py:581:12: C0103: Variable name "d" doesn't conform to snake_case naming style (invalid-name)
+spydrnet/parsers/eblif/eblif_parser.py:12:0: R0904: Too many public methods (37/20) (too-many-public-methods)
+************* Module spydrnet.parsers.eblif.eblif_tokenizer
+spydrnet/parsers/eblif/eblif_tokenizer.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+spydrnet/parsers/eblif/eblif_tokenizer.py:7:0: C0115: Missing class docstring (missing-class-docstring)
+spydrnet/parsers/eblif/eblif_tokenizer.py:9:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_tokenizer.py:14:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_tokenizer.py:20:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_tokenizer.py:39:36: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
+spydrnet/parsers/eblif/eblif_tokenizer.py:41:32: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
+spydrnet/parsers/eblif/eblif_tokenizer.py:32:25: R1732: Consider using 'with' for resource-allocating operations (consider-using-with)
+spydrnet/parsers/eblif/eblif_tokenizer.py:35:25: R1732: Consider using 'with' for resource-allocating operations (consider-using-with)
+spydrnet/parsers/eblif/eblif_tokenizer.py:41:32: R1732: Consider using 'with' for resource-allocating operations (consider-using-with)
+spydrnet/parsers/eblif/eblif_tokenizer.py:50:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_tokenizer.py:60:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_tokenizer.py:67:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_tokenizer.py:83:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_tokenizer.py:84:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
+spydrnet/parsers/eblif/eblif_tokenizer.py:90:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_tokenizer.py:93:16: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
+spydrnet/parsers/eblif/eblif_tokenizer.py:98:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_tokenizer.py:101:4: C0116: Missing function or method docstring (missing-function-docstring)
+spydrnet/parsers/eblif/eblif_tokenizer.py:102:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
+spydrnet/parsers/eblif/eblif_tokenizer.py:106:12: R1705: Unnecessary "elif" after "return", remove the leading "el" from "elif" (no-else-return)
+************* Module spydrnet.parsers.eblif.eblif_tokens
+spydrnet/parsers/eblif/eblif_tokens.py:1:0: C0114: Missing module docstring (missing-module-docstring)
+************* Module spydrnet.parsers.eblif.__init__
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hcables:[337:390]
+==spydrnet.util.get_hwires:[353:406]
+ search_stack += (
+ x for x in _get_hpins_from_hwire(hwire_outside) if x != hpin
+ )
+
+
+def _get_inner_hwire_from_hpin(hpin):
+ wire = hpin.item.wire
+ if wire:
+ cable = wire.cable
+ if cable:
+ hport = hpin.parent
+ hinst = hport.parent
+ hcable = HRef.from_parent_and_item(hinst, cable)
+ hwire = HRef.from_parent_and_item(hcable, wire)
+ return hwire
+
+
+def _get_outer_hwire_from_hpin(hpin):
+ hport = hpin.parent
+ hinst = hport.parent
+ instance = hinst.item
+ pin = hpin.item
+ if pin in instance.pins:
+ outer_pin = instance.pins[hpin.item]
+ outer_wire = outer_pin.wire
+ if outer_wire:
+ cable = outer_wire.cable
+ if cable:
+ hcable = HRef.from_parent_and_item(hinst.parent, cable)
+ hwire = HRef.from_parent_and_item(hcable, outer_wire)
+ return hwire
+
+
+def _get_hpins_from_hwire(hwire):
+ hcable = hwire.parent
+ hinst = hcable.parent
+ for pin in hwire.item.pins:
+ if isinstance(pin, InnerPin):
+ port = pin.port
+ if port:
+ hport = HRef.from_parent_and_item(hinst, port)
+ hpin = HRef.from_parent_and_item(hport, pin)
+ yield hpin
+ else:
+ instance = pin.instance
+ inner_pin = pin.inner_pin
+ if instance and inner_pin:
+ port = inner_pin.port
+ if port:
+ other_hinst = HRef.from_parent_and_item(hinst, instance)
+ other_hport = HRef.from_parent_and_item(other_hinst, port)
+ other_hpin = HRef.from_parent_and_item(other_hport, inner_pin)
+ yield other_hpin (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hcables:[62:111]
+==spydrnet.util.get_hwires:[62:111]
+ if len(args) == 1 and "patterns" in kwargs:
+ raise TypeError("get_hwires() got multiple values for argument 'patterns'")
+ if len(args) > 1 or any(
+ x not in {"patterns", "selection", "recursive", "filter", "is_case", "is_re"}
+ for x in kwargs
+ ):
+ raise TypeError("Unknown usage. Please see help for more information.")
+
+ # Default values
+ selection = kwargs.get("selection", Selection.INSIDE)
+ if isinstance(selection, str):
+ if selection in Selection.__members__:
+ selection = Selection[selection]
+ if isinstance(selection, Selection) is False:
+ raise TypeError(
+ "selection must be '{}'".format("', '".join(Selection.__members__.keys()))
+ )
+
+ filter_func = kwargs.get("filter", lambda x: True)
+ recursive = kwargs.get("recursive", False)
+ is_case = kwargs.get("is_case", True)
+ is_re = kwargs.get("is_re", False)
+ patterns = (
+ args[0] if len(args) == 1 else kwargs.get("patterns", ".*" if is_re else "*")
+ )
+
+ if isinstance(obj, (FirstClassElement, InnerPin, OuterPin, Wire)) is False:
+ try:
+ object_collection = list(iter(obj))
+ except TypeError:
+ object_collection = [obj]
+ else:
+ object_collection = [obj]
+ if (
+ all(
+ isinstance(x, (HRef, FirstClassElement, InnerPin, OuterPin, Wire))
+ for x in object_collection
+ )
+ is False
+ ):
+ raise TypeError(
+ "get_hwires() supports all netlist related objects and hierarchical references or a "
+ "collection of theses as the object searched, unsupported object provided"
+ )
+
+ if isinstance(patterns, str):
+ patterns = (patterns,)
+ assert isinstance(patterns, (FirstClassElement, InnerPin, OuterPin, Wire)) is False
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.parsers.edif.tokenizer:[22:69]
+==spydrnet.parsers.verilog.tokenizer:[27:74]
+ return tokenizer
+
+ def __init__(self, input_source):
+ self.token = None
+ self.next_token = None
+ self.line_number = 0
+
+ if isinstance(input_source, str):
+ if zipfile.is_zipfile(input_source):
+ zip = zipfile.ZipFile(input_source)
+ filename = Path(input_source).name
+ filename = filename[: filename.rindex(".")]
+ stream = zip.open(filename)
+ stream = io.TextIOWrapper(stream)
+ self.input_stream = stream
+ else:
+ self.input_stream = open(input_source, "r")
+ elif isinstance(input_source, Path):
+ if zipfile.is_zipfile(input_source):
+ zip = zipfile.ZipFile(input_source)
+ filename = Path(input_source).name
+ filename = filename[: filename.rindex(".")]
+ stream = zip.open(filename)
+ stream = io.TextIOWrapper(stream)
+ self.input_stream = stream
+ else:
+ self.input_stream = open(input_source, "r")
+ else:
+ if isinstance(input_source, io.TextIOBase) is False:
+ self.input_stream = io.TextIOWrapper(input_source)
+ else:
+ self.input_stream = input_source
+
+ self.generator = self.generate_tokens()
+
+ def __del__(self):
+ if hasattr(self, "input_stream"):
+ self.close()
+
+ def has_next(self):
+ try:
+ self.peek()
+ return True
+ except StopIteration:
+ return False
+
+ def next(self): (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hpins:[207:245]
+==spydrnet.util.get_hwires:[269:307]
+ for href in in_yield:
+ in_namemap.discard(href)
+
+ if in_namemap: # namemap is to cable
+ for pattern in patterns:
+ pattern_is_absolute = _is_pattern_absolute(pattern, is_case, is_re)
+ if pattern_is_absolute:
+ if pattern in namemap:
+ result = namemap[pattern]
+ for href in result:
+ if href in in_namemap:
+ in_namemap.remove(href)
+ yield href
+ else:
+ for name in namemap:
+ if _value_matches_pattern(name, pattern, is_case, is_re):
+ result = namemap[name]
+ for href in result:
+ if href in in_namemap:
+ in_namemap.remove(href)
+ yield href
+
+
+def _update_hwire_namemap(href_instance, recursive, found, namemap):
+ search_stack = [(href_instance, False)]
+ name_stack = []
+ while search_stack:
+ href_instance, visited = search_stack.pop()
+ if visited:
+ name_stack.pop()
+ else:
+ search_stack.append((href_instance, True))
+ name_stack.append(
+ href_instance.item.name if href_instance.item.name else ""
+ )
+ item = href_instance.item
+ reference = item.reference
+ if reference: (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_instances:[74:112]
+==spydrnet.util.get_libraries:[73:111]
+ if len(args) > 1 or any(
+ x
+ not in {
+ "patterns",
+ "key",
+ "filter",
+ "is_case",
+ "is_re",
+ "selection",
+ "recursive",
+ }
+ for x in kwargs
+ ):
+ raise TypeError("Unknown usage. Please see help for more information.")
+
+ # Default values
+ selection = kwargs.get("selection", Selection.INSIDE)
+ if isinstance(selection, str):
+ if selection in Selection.__members__:
+ selection = Selection[selection]
+ if selection not in {Selection.INSIDE, Selection.OUTSIDE}:
+ raise TypeError(
+ "selection must be '{}'".format(
+ "', '".join([Selection.INSIDE.name, Selection.OUTSIDE.name])
+ )
+ )
+
+ filter_func = kwargs.get("filter", lambda x: True)
+ is_case = kwargs.get("is_case", True)
+ is_re = kwargs.get("is_re", False)
+ patterns = (
+ args[0] if len(args) == 1 else kwargs.get("patterns", ".*" if is_re else "*")
+ )
+ key = kwargs.get("key", ".NAME")
+ recursive = kwargs.get("recursive", False)
+
+ if isinstance(obj, (FirstClassElement, InnerPin, OuterPin, Wire)) is False:
+ try: (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_definitions:[72:108]
+==spydrnet.util.get_libraries:[73:109]
+ if len(args) > 1 or any(
+ x
+ not in {
+ "patterns",
+ "key",
+ "filter",
+ "is_case",
+ "is_re",
+ "selection",
+ "recursive",
+ }
+ for x in kwargs
+ ):
+ raise TypeError("Unknown usage. Please see help for more information.")
+
+ # Default values
+ selection = kwargs.get("selection", Selection.INSIDE)
+ if isinstance(selection, str):
+ if selection in Selection.__members__:
+ selection = Selection[selection]
+ if selection not in {Selection.INSIDE, Selection.OUTSIDE}:
+ raise TypeError(
+ "selection must be '{}'".format(
+ "', '".join([Selection.INSIDE.name, Selection.OUTSIDE.name])
+ )
+ )
+
+ filter_func = kwargs.get("filter", lambda x: True)
+ is_case = kwargs.get("is_case", True)
+ is_re = kwargs.get("is_re", False)
+ patterns = (
+ args[0] if len(args) == 1 else kwargs.get("patterns", ".*" if is_re else "*")
+ )
+ key = kwargs.get("key", ".NAME")
+ recursive = kwargs.get("recursive", False)
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hpins:[194:230]
+==spydrnet.util.get_hports:[187:223]
+ elif isinstance(obj, Library):
+ object_collection += obj.definitions
+ elif isinstance(obj, Definition):
+ hrefs = set(HRef.get_all_hrefs_of_instances(obj.references))
+ bypass_namesearch |= hrefs
+ object_collection += hrefs
+ elif isinstance(obj, Instance):
+ hrefs = set(HRef.get_all_hrefs_of_instances(obj))
+ bypass_namesearch |= hrefs
+ object_collection += hrefs
+ elif isinstance(obj, (Port, Cable, InnerPin, OuterPin, Wire)):
+ object_collection += HRef.get_all_hrefs_of_item(obj)
+
+ for href in in_yield:
+ in_namemap.discard(href)
+
+ if in_namemap: # namemap is to cable
+ for pattern in patterns:
+ pattern_is_absolute = _is_pattern_absolute(pattern, is_case, is_re)
+ if pattern_is_absolute:
+ if pattern in namemap:
+ result = namemap[pattern]
+ for href in result:
+ if href in in_namemap:
+ in_namemap.remove(href)
+ yield href
+ else:
+ for name in namemap:
+ if _value_matches_pattern(name, pattern, is_case, is_re):
+ result = namemap[name]
+ for href in result:
+ if href in in_namemap:
+ in_namemap.remove(href)
+ yield href
+
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hcables:[80:111]
+==spydrnet.util.get_hpins:[66:97]
+ filter_func = kwargs.get("filter", lambda x: True)
+ recursive = kwargs.get("recursive", False)
+ is_case = kwargs.get("is_case", True)
+ is_re = kwargs.get("is_re", False)
+ patterns = (
+ args[0] if len(args) == 1 else kwargs.get("patterns", ".*" if is_re else "*")
+ )
+
+ if isinstance(obj, (FirstClassElement, InnerPin, OuterPin, Wire)) is False:
+ try:
+ object_collection = list(iter(obj))
+ except TypeError:
+ object_collection = [obj]
+ else:
+ object_collection = [obj]
+ if (
+ all(
+ isinstance(x, (HRef, FirstClassElement, InnerPin, OuterPin, Wire))
+ for x in object_collection
+ )
+ is False
+ ):
+ raise TypeError(
+ "get_hwires() supports all netlist related objects and hierarchical references or a "
+ "collection of theses as the object searched, unsupported object provided"
+ )
+
+ if isinstance(patterns, str):
+ patterns = (patterns,)
+ assert isinstance(patterns, (FirstClassElement, InnerPin, OuterPin, Wire)) is False
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hpins:[60:89]
+==spydrnet.util.get_hports:[60:89]
+ if len(args) > 1 or any(
+ x not in {"patterns", "recursive", "filter", "is_case", "is_re"} for x in kwargs
+ ):
+ raise TypeError("Unknown usage. Please see help for more information.")
+
+ # Default values
+ filter_func = kwargs.get("filter", lambda x: True)
+ recursive = kwargs.get("recursive", False)
+ is_case = kwargs.get("is_case", True)
+ is_re = kwargs.get("is_re", False)
+ patterns = (
+ args[0] if len(args) == 1 else kwargs.get("patterns", ".*" if is_re else "*")
+ )
+
+ if isinstance(obj, (FirstClassElement, InnerPin, OuterPin, Wire)) is False:
+ try:
+ object_collection = list(iter(obj))
+ except TypeError:
+ object_collection = [obj]
+ else:
+ object_collection = [obj]
+ if (
+ all(
+ isinstance(x, (HRef, FirstClassElement, InnerPin, OuterPin, Wire))
+ for x in object_collection
+ )
+ is False
+ ):
+ raise TypeError( (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hcables:[160:185]
+==spydrnet.util.get_hwires:[162:187]
+ if recursive or selection == Selection.ALL:
+ for child in reference.children:
+ href_child = HRef.from_parent_and_item(obj, child)
+ bypass_namesearch.add(href_child)
+ object_collection.append(href_child)
+ if selection in {
+ Selection.OUTSIDE,
+ Selection.BOTH,
+ Selection.ALL,
+ }:
+ for port in reference.ports:
+ href_port = HRef.from_parent_and_item(obj, port)
+ for pin in port.pins:
+ href_pin = HRef.from_parent_and_item(href_port, pin)
+ hpin_search.add(href_pin)
+ elif isinstance(item, Port):
+ for pin in item.pins:
+ href_pin = HRef.from_parent_and_item(obj, pin)
+ hpin_search.add(href_pin)
+ elif isinstance(item, Cable):
+ for wire in item.wires:
+ href_wire = HRef.from_parent_and_item(obj, wire)
+ object_collection.append(href_wire)
+ elif isinstance(item, Wire):
+ if selection == Selection.INSIDE: (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hinstances:[66:89]
+==spydrnet.util.get_hwires:[80:103]
+ filter_func = kwargs.get("filter", lambda x: True)
+ recursive = kwargs.get("recursive", False)
+ is_case = kwargs.get("is_case", True)
+ is_re = kwargs.get("is_re", False)
+ patterns = (
+ args[0] if len(args) == 1 else kwargs.get("patterns", ".*" if is_re else "*")
+ )
+
+ if isinstance(obj, (FirstClassElement, InnerPin, OuterPin, Wire)) is False:
+ try:
+ object_collection = list(iter(obj))
+ except TypeError:
+ object_collection = [obj]
+ else:
+ object_collection = [obj]
+ if (
+ all(
+ isinstance(x, (HRef, FirstClassElement, InnerPin, OuterPin, Wire))
+ for x in object_collection
+ )
+ is False
+ ):
+ raise TypeError( (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_instances:[237:259]
+==spydrnet.util.get_libraries:[252:274]
+ if other_instance in found:
+ continue
+ found.add(other_instance)
+ name = other_instance[key] if key in other_instance else ""
+ if name not in namemap:
+ namemap[name] = []
+ namemap[name].append(other_instance)
+ for pattern in patterns:
+ pattern_is_absolute = _is_pattern_absolute(pattern, is_case, is_re)
+ if pattern_is_absolute:
+ if pattern in namemap:
+ result = namemap[pattern]
+ for instance in result:
+ yield instance
+ else:
+ discard = set()
+ for instance in found:
+ value = instance[key] if key in instance else ""
+ if _value_matches_pattern(value, pattern, is_case, is_re):
+ discard.add(instance)
+ yield instance
+ found -= discard (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hcables:[235:258]
+==spydrnet.util.get_hwires:[242:265]
+ href_pin = HRef.from_parent_and_item(href_port, pin)
+ else:
+ port = pin.port
+ href_port = HRef.from_parent_and_item(href_inst, port)
+ href_pin = HRef.from_parent_and_item(href_port, pin)
+ object_collection.append(href_pin)
+ elif isinstance(item, InnerPin):
+ hpin_search.add(obj)
+ elif isinstance(obj, Library):
+ object_collection += obj.definitions
+ elif isinstance(obj, Definition):
+ hrefs = set(HRef.get_all_hrefs_of_instances(obj.references))
+ bypass_namesearch |= hrefs
+ object_collection += hrefs
+ elif isinstance(obj, Instance):
+ hrefs = set(HRef.get_all_hrefs_of_instances(obj))
+ bypass_namesearch |= hrefs
+ object_collection += hrefs
+ elif isinstance(obj, (Port, Cable, InnerPin, OuterPin, Wire)):
+ object_collection += HRef.get_all_hrefs_of_item(obj)
+
+ if hpin_search:
+ for hwire in _get_hwires_from_hpins(hpin_search, selection): (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hcables:[80:103]
+==spydrnet.util.get_hports:[66:89]
+ filter_func = kwargs.get("filter", lambda x: True)
+ recursive = kwargs.get("recursive", False)
+ is_case = kwargs.get("is_case", True)
+ is_re = kwargs.get("is_re", False)
+ patterns = (
+ args[0] if len(args) == 1 else kwargs.get("patterns", ".*" if is_re else "*")
+ )
+
+ if isinstance(obj, (FirstClassElement, InnerPin, OuterPin, Wire)) is False:
+ try:
+ object_collection = list(iter(obj))
+ except TypeError:
+ object_collection = [obj]
+ else:
+ object_collection = [obj]
+ if (
+ all(
+ isinstance(x, (HRef, FirstClassElement, InnerPin, OuterPin, Wire))
+ for x in object_collection
+ )
+ is False
+ ):
+ raise TypeError( (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hpins:[153:174]
+==spydrnet.util.get_hports:[149:170]
+ elif isinstance(item, Cable):
+ for wire in item.wires:
+ href_wire = HRef.from_parent_and_item(obj, wire)
+ object_collection.append(href_wire)
+ elif isinstance(item, Wire):
+ href_parent_cable = obj.parent
+ href_parent_instance = href_parent_cable.parent
+ for pin in item.pins:
+ if isinstance(pin, OuterPin):
+ instance = pin.instance
+ if instance:
+ href_inst = HRef.from_parent_and_item(
+ href_parent_instance, pin.instance
+ )
+ inner_pin = pin.inner_pin
+ if inner_pin:
+ inner_port = inner_pin.port
+ if inner_port:
+ href_port = HRef.from_parent_and_item(
+ href_inst, inner_port
+ ) (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_netlists:[61:84]
+==spydrnet.util.get_ports:[62:85]
+ if len(args) > 1 or any(
+ x not in {"patterns", "key", "filter", "is_case", "is_re"} for x in kwargs
+ ):
+ raise TypeError("Unknown usage. Please see help for more information.")
+
+ # Default values
+ filter_func = kwargs.get("filter", lambda x: True)
+ is_case = kwargs.get("is_case", True)
+ is_re = kwargs.get("is_re", False)
+ patterns = (
+ args[0] if len(args) == 1 else kwargs.get("patterns", ".*" if is_re else "*")
+ )
+ key = kwargs.get("key", ".NAME")
+
+ if isinstance(obj, (FirstClassElement, InnerPin, OuterPin, Wire)) is False:
+ try:
+ object_collection = list(iter(obj))
+ except TypeError:
+ object_collection = [obj]
+ else:
+ object_collection = [obj]
+ if all(isinstance(x, (Element, HRef)) for x in object_collection) is False:
+ raise TypeError( (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_cables:[66:88]
+==spydrnet.util.get_instances:[72:94]
+ if len(args) == 1 and "patterns" in kwargs:
+ raise TypeError("get_cables() got multiple values for argument 'patterns'")
+ if len(args) > 1 or any(
+ x
+ not in {
+ "patterns",
+ "key",
+ "filter",
+ "is_case",
+ "is_re",
+ "selection",
+ "recursive",
+ }
+ for x in kwargs
+ ):
+ raise TypeError("Unknown usage. Please see help for more information.")
+
+ # Default values
+ selection = kwargs.get("selection", Selection.INSIDE)
+ if isinstance(selection, str):
+ if selection in Selection.__members__:
+ selection = Selection[selection] (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hports:[200:223]
+==spydrnet.util.get_hwires:[269:292]
+ for href in in_yield:
+ in_namemap.discard(href)
+
+ if in_namemap: # namemap is to cable
+ for pattern in patterns:
+ pattern_is_absolute = _is_pattern_absolute(pattern, is_case, is_re)
+ if pattern_is_absolute:
+ if pattern in namemap:
+ result = namemap[pattern]
+ for href in result:
+ if href in in_namemap:
+ in_namemap.remove(href)
+ yield href
+ else:
+ for name in namemap:
+ if _value_matches_pattern(name, pattern, is_case, is_re):
+ result = namemap[name]
+ for href in result:
+ if href in in_namemap:
+ in_namemap.remove(href)
+ yield href
+
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hcables:[263:286]
+==spydrnet.util.get_hpins:[207:230]
+ for href in in_yield:
+ in_namemap.discard(href)
+
+ if in_namemap: # namemap is to cable
+ for pattern in patterns:
+ pattern_is_absolute = _is_pattern_absolute(pattern, is_case, is_re)
+ if pattern_is_absolute:
+ if pattern in namemap:
+ result = namemap[pattern]
+ for href in result:
+ if href in in_namemap:
+ in_namemap.remove(href)
+ yield href
+ else:
+ for name in namemap:
+ if _value_matches_pattern(name, pattern, is_case, is_re):
+ result = namemap[name]
+ for href in result:
+ if href in in_namemap:
+ in_namemap.remove(href)
+ yield href
+
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_cables:[91:111]
+==spydrnet.util.get_definitions:[97:117]
+ )
+
+ filter_func = kwargs.get("filter", lambda x: True)
+ is_case = kwargs.get("is_case", True)
+ is_re = kwargs.get("is_re", False)
+ patterns = (
+ args[0] if len(args) == 1 else kwargs.get("patterns", ".*" if is_re else "*")
+ )
+ key = kwargs.get("key", ".NAME")
+ recursive = kwargs.get("recursive", False)
+
+ if isinstance(obj, (Element, HRef)) is False:
+ try:
+ object_collection = list(iter(obj))
+ except TypeError:
+ object_collection = [obj]
+ else:
+ object_collection = [obj]
+ if all(isinstance(x, (Element, HRef)) for x in object_collection) is False:
+ raise TypeError( (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_cables:[272:290]
+==spydrnet.util.get_ports:[161:179]
+ for pattern in patterns:
+ pattern_is_absolute = _is_pattern_absolute(pattern, is_case, is_re)
+ if pattern_is_absolute:
+ if pattern in namemap:
+ result = namemap[pattern]
+ del namemap[pattern]
+ for port in result:
+ yield port
+ else:
+ names_to_remove = []
+ for name in namemap:
+ if _value_matches_pattern(name, pattern, is_case, is_re):
+ result = namemap[name]
+ names_to_remove.append(name)
+ for port in result:
+ yield port
+ for name in names_to_remove:
+ del namemap[name] (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_cables:[68:88]
+==spydrnet.util.get_libraries:[73:93]
+ if len(args) > 1 or any(
+ x
+ not in {
+ "patterns",
+ "key",
+ "filter",
+ "is_case",
+ "is_re",
+ "selection",
+ "recursive",
+ }
+ for x in kwargs
+ ):
+ raise TypeError("Unknown usage. Please see help for more information.")
+
+ # Default values
+ selection = kwargs.get("selection", Selection.INSIDE)
+ if isinstance(selection, str):
+ if selection in Selection.__members__:
+ selection = Selection[selection] (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hcables:[287:305]
+==spydrnet.util.get_hwires:[293:311]
+ search_stack = [(href_instance, False)]
+ name_stack = []
+ while search_stack:
+ href_instance, visited = search_stack.pop()
+ if visited:
+ name_stack.pop()
+ else:
+ search_stack.append((href_instance, True))
+ name_stack.append(
+ href_instance.item.name if href_instance.item.name else ""
+ )
+ item = href_instance.item
+ reference = item.reference
+ if reference:
+ for cable in reference.cables:
+ hcable = HRef.from_parent_and_item(href_instance, cable)
+ name_stack.append(cable.name if cable.name else "")
+ cable_hname = "/".join(name_stack[1:]) (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hcables:[129:147]
+==spydrnet.util.get_hwires:[129:147]
+ in_namemap = set()
+ in_yield = set()
+ namemap = {}
+ hpin_search = set()
+ bypass_namesearch = set()
+ while object_collection:
+ obj = object_collection.pop()
+ if isinstance(obj, Netlist):
+ top_instance = obj.top_instance
+ if top_instance:
+ href = HRef.from_parent_and_item(None, top_instance)
+ object_collection.append(href)
+ elif isinstance(obj, HRef):
+ if obj.is_valid is False:
+ continue
+ item = obj.item
+ if isinstance(item, Instance):
+ if selection == Selection.INSIDE and obj not in bypass_namesearch: (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hpins:[231:249]
+==spydrnet.util.get_hports:[224:242]
+ search_stack = [(href_instance, False)]
+ name_stack = []
+ while search_stack:
+ href_instance, visited = search_stack.pop()
+ if visited:
+ name_stack.pop()
+ else:
+ search_stack.append((href_instance, True))
+ name_stack.append(
+ href_instance.item.name if href_instance.item.name else ""
+ )
+ item = href_instance.item
+ reference = item.reference
+ if reference:
+ for port in reference.ports:
+ hport = HRef.from_parent_and_item(href_instance, port)
+ name_stack.append(port.name if port.name else "")
+ port_hname = "/".join(name_stack[1:]) (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hpins:[111:128]
+==spydrnet.util.get_hports:[111:128]
+ in_namemap = set()
+ in_yield = set()
+ namemap = {}
+ bypass_namesearch = set()
+ while object_collection:
+ obj = object_collection.pop()
+ if isinstance(obj, Netlist):
+ top_instance = obj.top_instance
+ if top_instance:
+ href = HRef.from_parent_and_item(None, top_instance)
+ object_collection.append(href)
+ elif isinstance(obj, HRef):
+ if obj.is_valid is False:
+ continue
+ item = obj.item
+ if isinstance(item, Instance):
+ if obj not in bypass_namesearch: (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hcables:[310:328]
+==spydrnet.util.get_hwires:[324:342]
+ name_stack.pop()
+ if recursive:
+ for child in reference.children:
+ if child.reference and child.reference.is_leaf() is False:
+ href_child = HRef.from_parent_and_item(href_instance, child)
+ search_stack.append((href_child, False))
+
+
+def _get_hwires_from_hpins(hpin_search, selection):
+ found_hwires = set()
+ search_stack = list(hpin_search)
+ while search_stack:
+ hpin = search_stack.pop()
+ if selection in {Selection.INSIDE, Selection.BOTH, Selection.ALL}:
+ hwire_inside = _get_inner_hwire_from_hpin(hpin)
+ if hwire_inside and hwire_inside not in found_hwires:
+ found_hwires.add(hwire_inside)
+ yield hwire_inside (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hcables:[0:17]
+==spydrnet.util.get_hwires:[0:17]
+from spydrnet import (
+ FirstClassElement,
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition,
+ Instance,
+ Port,
+ Cable,
+)
+from spydrnet.util.hierarchical_reference import HRef
+from spydrnet.util.selection import Selection
+from spydrnet.util.patterns import _is_pattern_absolute, _value_matches_pattern
+
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hports:[224:238]
+==spydrnet.util.get_hwires:[293:307]
+ search_stack = [(href_instance, False)]
+ name_stack = []
+ while search_stack:
+ href_instance, visited = search_stack.pop()
+ if visited:
+ name_stack.pop()
+ else:
+ search_stack.append((href_instance, True))
+ name_stack.append(
+ href_instance.item.name if href_instance.item.name else ""
+ )
+ item = href_instance.item
+ reference = item.reference
+ if reference: (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hcables:[189:203]
+==spydrnet.util.get_hwires:[190:204]
+ elif selection == Selection.OUTSIDE:
+ href_parent_cable = obj.parent
+ href_parent_instance = href_parent_cable.parent
+ for pin in item.pins:
+ if isinstance(pin, OuterPin):
+ href_inst = HRef.from_parent_and_item(
+ href_parent_instance, pin.instance
+ )
+ inner_wire = pin.inner_pin.wire
+ if inner_wire:
+ inner_cable = inner_wire.cable
+ href_cable = HRef.from_parent_and_item(
+ href_inst, inner_cable
+ ) (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hpins:[0:16]
+==spydrnet.util.get_hports:[0:16]
+from spydrnet import (
+ FirstClassElement,
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition,
+ Instance,
+ Port,
+ Cable,
+)
+from spydrnet.util.hierarchical_reference import HRef
+from spydrnet.util.patterns import _is_pattern_absolute, _value_matches_pattern
+
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hcables:[287:301]
+==spydrnet.util.get_hpins:[231:245]
+ search_stack = [(href_instance, False)]
+ name_stack = []
+ while search_stack:
+ href_instance, visited = search_stack.pop()
+ if visited:
+ name_stack.pop()
+ else:
+ search_stack.append((href_instance, True))
+ name_stack.append(
+ href_instance.item.name if href_instance.item.name else ""
+ )
+ item = href_instance.item
+ reference = item.reference
+ if reference: (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.parsers.eblif.eblif_parser:[31:52]
+==spydrnet.parsers.verilog.parser:[56:77]
+ definition.name = name
+ self.name_lookup[name] = definition
+ return definition
+
+ def define(self, name):
+ """adds the name to the defined set"""
+ self.defined.add(self.name_lookup[name])
+
+ def get_undefined_blackboxes(self):
+ """return an iterable of all undefined blackboxes"""
+ undef = set()
+ for v in self.name_lookup.values():
+ if v not in self.defined:
+ undef.add(v)
+ return undef
+
+ #######################################################
+ # setup functions
+ #######################################################
+ @staticmethod
+ def from_filename(filename): (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hports:[114:127]
+==spydrnet.util.get_hwires:[133:146]
+ bypass_namesearch = set()
+ while object_collection:
+ obj = object_collection.pop()
+ if isinstance(obj, Netlist):
+ top_instance = obj.top_instance
+ if top_instance:
+ href = HRef.from_parent_and_item(None, top_instance)
+ object_collection.append(href)
+ elif isinstance(obj, HRef):
+ if obj.is_valid is False:
+ continue
+ item = obj.item
+ if isinstance(item, Instance): (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hports:[0:13]
+==spydrnet.util.get_hwires:[0:13]
+from spydrnet import (
+ FirstClassElement,
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition,
+ Instance,
+ Port,
+ Cable,
+)
+from spydrnet.util.hierarchical_reference import HRef (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hcables:[133:146]
+==spydrnet.util.get_hpins:[114:127]
+ bypass_namesearch = set()
+ while object_collection:
+ obj = object_collection.pop()
+ if isinstance(obj, Netlist):
+ top_instance = obj.top_instance
+ if top_instance:
+ href = HRef.from_parent_and_item(None, top_instance)
+ object_collection.append(href)
+ elif isinstance(obj, HRef):
+ if obj.is_valid is False:
+ continue
+ item = obj.item
+ if isinstance(item, Instance): (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hcables:[0:13]
+==spydrnet.util.get_hpins:[0:13]
+from spydrnet import (
+ FirstClassElement,
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition,
+ Instance,
+ Port,
+ Cable,
+)
+from spydrnet.util.hierarchical_reference import HRef (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.parsers.eblif.eblif_tokenizer:[59:73]
+==spydrnet.parsers.edif.tokenizer:[61:74]
+ def has_next(self):
+ try:
+ self.peek()
+ return True
+ except StopIteration:
+ return False
+
+ def next(self):
+ if self.next_token:
+ self.token = self.next_token
+ self.next_token = None
+ else:
+ self.token = next(self.generator)
+ # print(self.token) (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_instances:[1:13]
+==spydrnet.util.get_ports:[1:13]
+ Element,
+ FirstClassElement,
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition,
+ Instance,
+ Port,
+ Cable,
+) (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_libraries:[86:101]
+==spydrnet.util.get_pins:[46:62]
+ raise TypeError("Unknown usage. Please see help for more information.")
+
+ # Default values
+ selection = kwargs.get("selection", Selection.INSIDE)
+ if isinstance(selection, str):
+ if selection in Selection.__members__:
+ selection = Selection[selection]
+ if selection not in {Selection.INSIDE, Selection.OUTSIDE}:
+ raise TypeError(
+ "selection must be '{}'".format(
+ "', '".join([Selection.INSIDE.name, Selection.OUTSIDE.name])
+ )
+ )
+
+ filter_func = kwargs.get("filter", lambda x: True)
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hports:[187:200]
+==spydrnet.util.get_hwires:[250:263]
+ elif isinstance(obj, Library):
+ object_collection += obj.definitions
+ elif isinstance(obj, Definition):
+ hrefs = set(HRef.get_all_hrefs_of_instances(obj.references))
+ bypass_namesearch |= hrefs
+ object_collection += hrefs
+ elif isinstance(obj, Instance):
+ hrefs = set(HRef.get_all_hrefs_of_instances(obj))
+ bypass_namesearch |= hrefs
+ object_collection += hrefs
+ elif isinstance(obj, (Port, Cable, InnerPin, OuterPin, Wire)):
+ object_collection += HRef.get_all_hrefs_of_item(obj)
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hcables:[2:14]
+==spydrnet.util.get_pins:[2:16]
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition,
+ Instance,
+ Port,
+ Cable,
+)
+from spydrnet.util.hierarchical_reference import HRef
+from spydrnet.util.selection import Selection
+
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hcables:[67:82]
+==spydrnet.util.get_wires:[49:65]
+ ):
+ raise TypeError("Unknown usage. Please see help for more information.")
+
+ # Default values
+ selection = kwargs.get("selection", Selection.INSIDE)
+ if isinstance(selection, str):
+ if selection in Selection.__members__:
+ selection = Selection[selection]
+ if isinstance(selection, Selection) is False:
+ raise TypeError(
+ "selection must be '{}'".format("', '".join(Selection.__members__.keys()))
+ )
+
+ filter_func = kwargs.get("filter", lambda x: True)
+ recursive = kwargs.get("recursive", False)
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hcables:[206:218]
+==spydrnet.util.get_hwires:[210:222]
+ else:
+ href_parent = href_parent_instance.parent
+ if href_parent:
+ instance = href_parent_instance.item
+ if pin in instance.pins:
+ outer_pin = instance.pins[pin]
+ outer_wire = outer_pin.wire
+ if outer_wire:
+ outer_cable = outer_wire.cable
+ href_cable = HRef.from_parent_and_item(
+ href_parent, outer_cable
+ ) (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_cables:[79:94]
+==spydrnet.util.get_hcables:[66:81]
+ for x in kwargs
+ ):
+ raise TypeError("Unknown usage. Please see help for more information.")
+
+ # Default values
+ selection = kwargs.get("selection", Selection.INSIDE)
+ if isinstance(selection, str):
+ if selection in Selection.__members__:
+ selection = Selection[selection]
+ if isinstance(selection, Selection) is False:
+ raise TypeError(
+ "selection must be '{}'".format("', '".join(Selection.__members__.keys()))
+ )
+
+ filter_func = kwargs.get("filter", lambda x: True) (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hpins:[1:13]
+==spydrnet.util.get_ports:[2:14]
+ FirstClassElement,
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition,
+ Instance,
+ Port,
+ Cable,
+)
+from spydrnet.util.hierarchical_reference import HRef (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hcables:[243:256]
+==spydrnet.util.get_hpins:[194:207]
+ elif isinstance(obj, Library):
+ object_collection += obj.definitions
+ elif isinstance(obj, Definition):
+ hrefs = set(HRef.get_all_hrefs_of_instances(obj.references))
+ bypass_namesearch |= hrefs
+ object_collection += hrefs
+ elif isinstance(obj, Instance):
+ hrefs = set(HRef.get_all_hrefs_of_instances(obj))
+ bypass_namesearch |= hrefs
+ object_collection += hrefs
+ elif isinstance(obj, (Port, Cable, InnerPin, OuterPin, Wire)):
+ object_collection += HRef.get_all_hrefs_of_item(obj)
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_pins:[63:75]
+==spydrnet.util.get_ports:[77:89]
+ try:
+ object_collection = list(iter(obj))
+ except TypeError:
+ object_collection = [obj]
+ else:
+ object_collection = [obj]
+ if all(isinstance(x, (Element, HRef)) for x in object_collection) is False:
+ raise TypeError(
+ "get_ports() supports netlist elements and hierarchical references, or a collection of "
+ "these as the object searched"
+ )
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_cables:[80:94]
+==spydrnet.util.get_wires:[49:63]
+ ):
+ raise TypeError("Unknown usage. Please see help for more information.")
+
+ # Default values
+ selection = kwargs.get("selection", Selection.INSIDE)
+ if isinstance(selection, str):
+ if selection in Selection.__members__:
+ selection = Selection[selection]
+ if isinstance(selection, Selection) is False:
+ raise TypeError(
+ "selection must be '{}'".format("', '".join(Selection.__members__.keys()))
+ )
+
+ filter_func = kwargs.get("filter", lambda x: True) (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hpins:[2:13]
+==spydrnet.util.get_pins:[2:13]
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition,
+ Instance,
+ Port,
+ Cable,
+)
+from spydrnet.util.hierarchical_reference import HRef (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hpins:[1:12]
+==spydrnet.util.get_instances:[2:13]
+ FirstClassElement,
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition,
+ Instance,
+ Port,
+ Cable,
+) (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_instances:[3:13]
+==spydrnet.util.get_pins:[2:12]
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition,
+ Instance,
+ Port,
+ Cable,
+) (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.plugins.namespace_manager.default_namespace:[67:77]
+==spydrnet.plugins.namespace_manager.edif_namespace:[102:112]
+ else:
+ return False
+ namespace.clear()
+ for instance in element.children:
+ if ".NAME" in instance:
+ name = instance[".NAME"]
+ if name not in namespace:
+ namespace.add(name)
+ else:
+ return False (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.plugins.namespace_manager.default_namespace:[59:69]
+==spydrnet.plugins.namespace_manager.edif_namespace:[88:98]
+ else:
+ return False
+ namespace.clear()
+ for cable in element.cables:
+ if ".NAME" in cable:
+ name = cable[".NAME"]
+ if name not in namespace:
+ namespace.add(name)
+ else:
+ return False (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.plugins.namespace_manager.default_namespace:[51:61]
+==spydrnet.plugins.namespace_manager.edif_namespace:[74:84]
+ else:
+ return False
+ elif isinstance(element, Definition):
+ for port in element.ports:
+ if ".NAME" in port:
+ name = port[".NAME"]
+ if name not in namespace:
+ namespace.add(name)
+ else:
+ return False (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.plugins.namespace_manager.default_namespace:[43:53]
+==spydrnet.plugins.namespace_manager.edif_namespace:[60:70]
+ else:
+ return False
+ elif isinstance(element, Library):
+ for definition in element.definitions:
+ if ".NAME" in definition:
+ name = definition[".NAME"]
+ if name not in namespace:
+ namespace.add(name)
+ else:
+ return False (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.parsers.eblif.eblif_tokenizer:[101:110]
+==spydrnet.parsers.edif.tokenizer:[146:156]
+ if this == that:
+ return True
+ else:
+ lowercase_this = this.lower()
+ if lowercase_this == that:
+ return True
+ elif lowercase_this == that.lower():
+ return True
+ return False (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.parsers.edif.tokenizer:[30:39]
+==spydrnet.parsers.verilog.tokenizer:[45:54]
+ if zipfile.is_zipfile(input_source):
+ zip = zipfile.ZipFile(input_source)
+ filename = Path(input_source).name
+ filename = filename[: filename.rindex(".")]
+ stream = zip.open(filename)
+ stream = io.TextIOWrapper(stream)
+ self.input_stream = stream
+ else:
+ self.input_stream = open(input_source, "r") (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.parsers.edif.tokenizer:[40:49]
+==spydrnet.parsers.verilog.tokenizer:[35:44]
+ if zipfile.is_zipfile(input_source):
+ zip = zipfile.ZipFile(input_source)
+ filename = Path(input_source).name
+ filename = filename[: filename.rindex(".")]
+ stream = zip.open(filename)
+ stream = io.TextIOWrapper(stream)
+ self.input_stream = stream
+ else:
+ self.input_stream = open(input_source, "r") (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.ir.library:[208:233]
+==spydrnet.ir.netlist:[297:314]
+ return c
+
+ def clone(self):
+ """Clone the library in an API safe manner.
+
+ The following describes the structure of the returned object:
+
+ * the instances that pointed to reference definitions within the library will have updated
+ references
+ * the instances that pointed to reference definitions outside the library will maintain
+ their definitions
+ * the references lists (of definitions) both inside and outsde the library will be updated
+ to reflect the change
+ * all definitions are cloned within the library.
+
+ """
+ memo = {}
+ c = self._clone(memo)
+ c._clone_rip(memo)
+ return c
+
+ def __str__(self):
+ """Re-define the print function so it is easier to read"""
+ rep = super().__str__()
+ rep = rep[:-1] + "; " (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_netlists:[0:9]
+==spydrnet.util.get_ports:[0:9]
+from spydrnet.ir import (
+ Element,
+ FirstClassElement,
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition, (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_instances:[110:119]
+==spydrnet.util.get_ports:[76:85]
+ if isinstance(obj, (FirstClassElement, InnerPin, OuterPin, Wire)) is False:
+ try:
+ object_collection = list(iter(obj))
+ except TypeError:
+ object_collection = [obj]
+ else:
+ object_collection = [obj]
+ if all(isinstance(x, (Element, HRef)) for x in object_collection) is False:
+ raise TypeError( (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_cables:[102:111]
+==spydrnet.util.get_pins:[62:71]
+ if isinstance(obj, (Element, HRef)) is False:
+ try:
+ object_collection = list(iter(obj))
+ except TypeError:
+ object_collection = [obj]
+ else:
+ object_collection = [obj]
+ if all(isinstance(x, (Element, HRef)) for x in object_collection) is False:
+ raise TypeError( (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_cables:[119:130]
+==spydrnet.util.get_instances:[127:138]
+ object_collection,
+ patterns,
+ key,
+ is_case,
+ is_re,
+ selection,
+ recursive,
+ filter_func,
+ )
+
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_cables:[91:102]
+==spydrnet.util.get_libraries:[98:109]
+ )
+
+ filter_func = kwargs.get("filter", lambda x: True)
+ is_case = kwargs.get("is_case", True)
+ is_re = kwargs.get("is_re", False)
+ patterns = (
+ args[0] if len(args) == 1 else kwargs.get("patterns", ".*" if is_re else "*")
+ )
+ key = kwargs.get("key", ".NAME")
+ recursive = kwargs.get("recursive", False)
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hpins:[2:11]
+==spydrnet.util.get_wires:[1:10]
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition,
+ Instance,
+ Port,
+ Cable, (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.parsers.eblif.eblif_parser:[17:30]
+==spydrnet.parsers.verilog.parser:[42:55]
+ class BlackboxHolder:
+ """this is an internal class that helps manage
+ modules that are instanced before they are declared"""
+
+ def __init__(self):
+ self.name_lookup = {}
+ self.defined = set()
+
+ def get_blackbox(self, name):
+ """creates or returns the black box based on the name"""
+ if name in self.name_lookup:
+ return self.name_lookup[name]
+ else: (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.ir.port:[124:145]
+==spydrnet.ir.wire:[24:34]
+ @property
+ def pins(self):
+ """Get a list of the pins that are in the port"""
+ return ListView(self._pins)
+
+ @pins.setter
+ def pins(self, value):
+ """
+ This function can set the pins for the port, but it can only be used to reorder the pins
+ in the port. It cannot be used to add or remove pins from the port. to do this use the
+ add_pin or remove_pin functions instead
+
+ parameters
+ ----------
+
+ value - (List of InnerPin objects) the reordered pins
+
+ """
+ value_list = list(value)
+ value_set = set(value_list)
+ assert ( (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.ir.definition:[540:568]
+==spydrnet.ir.port:[288:309]
+ return c
+
+ def clone(self):
+ """Clone the port in an api safe way.
+
+ The following rules will be observed:
+
+ * all the pins will be disconnected from wires
+ * the port will be orphaned
+ * all pins will belong to the returned port
+ * direction, downto, is_scalar, lower_index will all be maintained
+
+ """
+ c = self._clone({})
+ c._clone_rip()
+ return c
+
+ def __str__(self):
+ """Re-define the print function so it is easier to read"""
+ rep = super().__str__()
+ rep = rep[:-1] + "; " (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.ir.cable:[43:55]
+==spydrnet.ir.port:[63:74]
+ if name is not None:
+ self.name = name
+
+ if is_downto is not None:
+ self.is_downto = is_downto
+
+ if is_scalar is not None:
+ self.is_scalar = is_scalar
+
+ if lower_index is not None:
+ self.lower_index = lower_index
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_netlists:[76:84]
+==spydrnet.util.get_pins:[63:71]
+ try:
+ object_collection = list(iter(obj))
+ except TypeError:
+ object_collection = [obj]
+ else:
+ object_collection = [obj]
+ if all(isinstance(x, (Element, HRef)) for x in object_collection) is False:
+ raise TypeError( (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_definitions:[221:229]
+==spydrnet.util.get_netlists:[139:147]
+ if definition:
+ object_collection.append(definition)
+ elif isinstance(obj, Wire):
+ cable = obj.cable
+ if cable:
+ object_collection.append(cable)
+ elif isinstance(obj, HRef):
+ if obj.is_valid: (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_definitions:[109:117]
+==spydrnet.util.get_ports:[77:85]
+ try:
+ object_collection = list(iter(obj))
+ except TypeError:
+ object_collection = [obj]
+ else:
+ object_collection = [obj]
+ if all(isinstance(x, (Element, HRef)) for x in object_collection) is False:
+ raise TypeError( (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_instances:[1:9]
+==spydrnet.util.get_netlists:[1:9]
+ Element,
+ FirstClassElement,
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition, (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_cables:[100:109]
+==spydrnet.util.get_wires:[63:72]
+ recursive = kwargs.get("recursive", False)
+
+ if isinstance(obj, (Element, HRef)) is False:
+ try:
+ object_collection = list(iter(obj))
+ except TypeError:
+ object_collection = [obj]
+ else:
+ object_collection = [obj] (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_cables:[103:111]
+==spydrnet.util.get_instances:[111:119]
+ try:
+ object_collection = list(iter(obj))
+ except TypeError:
+ object_collection = [obj]
+ else:
+ object_collection = [obj]
+ if all(isinstance(x, (Element, HRef)) for x in object_collection) is False:
+ raise TypeError( (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_libraries:[230:238]
+==spydrnet.util.get_netlists:[126:134]
+ definition = obj.definition
+ if definition:
+ object_collection.append(definition)
+ elif isinstance(obj, InnerPin):
+ port = obj.port
+ if port:
+ object_collection.append(port)
+ elif isinstance(obj, OuterPin): (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_definitions:[8:18]
+==spydrnet.util.get_libraries:[9:19]
+ Instance,
+ Port,
+ Cable,
+)
+from spydrnet.util.hierarchical_reference import HRef
+from spydrnet.util.selection import Selection
+from spydrnet.global_state.global_service import lookup
+from spydrnet.util.patterns import _is_pattern_absolute, _value_matches_pattern
+
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_cables:[120:130]
+==spydrnet.util.get_libraries:[128:138]
+ patterns,
+ key,
+ is_case,
+ is_re,
+ selection,
+ recursive,
+ filter_func,
+ )
+
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hcables:[328:337]
+==spydrnet.util.get_hwires:[343:352]
+ search_stack += (
+ x for x in _get_hpins_from_hwire(hwire_inside) if x != hpin
+ )
+
+ if selection in {Selection.OUTSIDE, Selection.BOTH, Selection.ALL}:
+ hwire_outside = _get_outer_hwire_from_hpin(hpin)
+ if hwire_outside and hwire_outside not in found_hwires:
+ found_hwires.add(hwire_outside)
+ yield hwire_outside (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.plugins.namespace_manager.default_namespace:[102:111]
+==spydrnet.plugins.namespace_manager.edif_namespace:[144:152]
+ if element_type not in self.namespaces:
+ self.namespaces[element_type] = {}
+ namespace = self.namespaces[element_type]
+ if ".NAME" in element:
+ old_name = element[".NAME"]
+ if old_name in namespace:
+ del namespace[old_name]
+ namespace[value] = element (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.plugins.namespace_manager.default_namespace:[37:45]
+==spydrnet.plugins.namespace_manager.edif_namespace:[48:56]
+ if isinstance(element, Netlist):
+ for library in element.libraries:
+ if ".NAME" in library:
+ name = library[".NAME"]
+ if name not in namespace:
+ namespace.add(name)
+ else:
+ return False (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.parsers.eblif.eblif_tokenizer:[89:97]
+==spydrnet.parsers.edif.tokenizer:[129:137]
+ def expect(self, other):
+ if not self.token_equals(other):
+ raise RuntimeError(
+ "Parse error: Expecting {} on line {}, recieved {}".format(
+ other, self.line_number, self.token
+ )
+ )
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.parsers.eblif.eblif_tokenizer:[80:89]
+==spydrnet.parsers.edif.tokenizer:[74:83]
+ return self.token
+
+ def peek(self):
+ if self.next_token:
+ return self.next_token
+ else:
+ self.next_token = next(self.generator)
+ return self.next_token
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.parsers.eblif.eblif_tokenizer:[59:67]
+==spydrnet.parsers.verilog.tokenizer:[66:74]
+ def has_next(self):
+ try:
+ self.peek()
+ return True
+ except StopIteration:
+ return False
+
+ def next(self): (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.parsers.eblif.eblif_tokenizer:[40:49]
+==spydrnet.parsers.verilog.tokenizer:[53:62]
+ self.input_stream = open(input_source, "r")
+ else:
+ if isinstance(input_source, io.TextIOBase) is False:
+ self.input_stream = io.TextIOWrapper(input_source)
+ else:
+ self.input_stream = input_source
+
+ self.generator = self.generate_tokens()
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.parsers.edif.tokenizer:[61:69]
+==spydrnet.parsers.verilog.tokenizer:[138:146]
+ def has_next(self):
+ try:
+ self.peek()
+ return True
+ except StopIteration:
+ return False
+
+ def next(self): (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.parsers.eblif.eblif_parser:[274:282]
+==spydrnet.parsers.verilog.parser:[777:785]
+ while True:
+ current_level = current_level.parent
+ try:
+ current_level.parent
+ except AttributeError:
+ new_level = current_level
+ break
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.ir.definition:[250:257]
+==spydrnet.ir.port:[241:248]
+ outer_pin = reference.pins[pin]
+ wire = outer_pin.wire
+ if wire:
+ wire.disconnect_pin(outer_pin)
+ del reference._pins[pin]
+ outer_pin._instance = None
+ outer_pin._inner_pin = None (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.ir.definition:[149:156]
+==spydrnet.ir.port:[35:42]
+ self,
+ name=None,
+ properties=None,
+ is_downto=None,
+ is_scalar=None,
+ lower_index=None,
+ direction=None, (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.ir.cable:[197:216]
+==spydrnet.ir.port:[287:307]
+ c._data = deepcopy(self._data)
+ return c
+
+ def clone(self):
+ """Clone the port in an api safe way.
+
+ The following rules will be observed:
+
+ * all the pins will be disconnected from wires
+ * the port will be orphaned
+ * all pins will belong to the returned port
+ * direction, downto, is_scalar, lower_index will all be maintained
+
+ """
+ c = self._clone({})
+ c._clone_rip()
+ return c
+
+ def __str__(self):
+ """Re-define the print function so it is easier to read""" (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.ir.cable:[18:25]
+==spydrnet.ir.port:[34:41]
+ def __init__(
+ self,
+ name=None,
+ properties=None,
+ is_downto=None,
+ is_scalar=None,
+ lower_index=None, (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.ir.instance:[44:52]
+==spydrnet.ir.library:[32:41]
+ if name is not None:
+ self.name = name
+ if properties is not None:
+ assert isinstance(properties, dict), "properties must be a dictionary"
+ for key in properties:
+ self[key] = properties[key]
+
+ @property (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_pins:[62:69]
+==spydrnet.util.get_wires:[65:72]
+ if isinstance(obj, (Element, HRef)) is False:
+ try:
+ object_collection = list(iter(obj))
+ except TypeError:
+ object_collection = [obj]
+ else:
+ object_collection = [obj] (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_pins:[90:97]
+==spydrnet.util.get_ports:[123:130]
+ elif isinstance(obj, Netlist):
+ for library in obj.libraries:
+ for definition in library.definitions:
+ object_collection.append(definition)
+ elif isinstance(obj, Library):
+ object_collection += obj.definitions
+ elif isinstance(obj, Instance): (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_instances:[222:229]
+==spydrnet.util.get_netlists:[141:148]
+ elif isinstance(obj, Wire):
+ cable = obj.cable
+ if cable:
+ object_collection.append(cable)
+ elif isinstance(obj, HRef):
+ if obj.is_valid:
+ item = obj.item (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hwires:[66:75]
+==spydrnet.util.get_instances:[85:94]
+ for x in kwargs
+ ):
+ raise TypeError("Unknown usage. Please see help for more information.")
+
+ # Default values
+ selection = kwargs.get("selection", Selection.INSIDE)
+ if isinstance(selection, str):
+ if selection in Selection.__members__:
+ selection = Selection[selection] (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_cables:[93:100]
+==spydrnet.util.get_netlists:[67:75]
+ filter_func = kwargs.get("filter", lambda x: True)
+ is_case = kwargs.get("is_case", True)
+ is_re = kwargs.get("is_re", False)
+ patterns = (
+ args[0] if len(args) == 1 else kwargs.get("patterns", ".*" if is_re else "*")
+ )
+ key = kwargs.get("key", ".NAME")
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_cables:[0:7]
+==spydrnet.util.get_definitions:[0:7]
+from spydrnet.ir import (
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition, (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_definitions:[223:231]
+==spydrnet.util.get_libraries:[241:249]
+ elif isinstance(obj, Wire):
+ cable = obj.cable
+ if cable:
+ object_collection.append(cable)
+ elif isinstance(obj, HRef):
+ if obj.is_valid:
+ object_collection.append(obj.item)
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hinstances:[146:153]
+==spydrnet.util.get_libraries:[229:236]
+ elif isinstance(obj, (Port, Cable)):
+ definition = obj.definition
+ if definition:
+ object_collection.append(definition)
+ elif isinstance(obj, InnerPin):
+ port = obj.port
+ if port: (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_libraries:[100:107]
+==spydrnet.util.get_ports:[68:76]
+ filter_func = kwargs.get("filter", lambda x: True)
+ is_case = kwargs.get("is_case", True)
+ is_re = kwargs.get("is_re", False)
+ patterns = (
+ args[0] if len(args) == 1 else kwargs.get("patterns", ".*" if is_re else "*")
+ )
+ key = kwargs.get("key", ".NAME")
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_instances:[214:221]
+==spydrnet.util.get_libraries:[233:240]
+ elif isinstance(obj, InnerPin):
+ port = obj.port
+ if port:
+ object_collection.append(port)
+ elif isinstance(obj, OuterPin):
+ instance = obj.instance
+ if instance: (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hports:[74:81]
+==spydrnet.util.get_netlists:[75:82]
+ if isinstance(obj, (FirstClassElement, InnerPin, OuterPin, Wire)) is False:
+ try:
+ object_collection = list(iter(obj))
+ except TypeError:
+ object_collection = [obj]
+ else:
+ object_collection = [obj] (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hcables:[88:95]
+==spydrnet.util.get_ports:[76:83]
+ if isinstance(obj, (FirstClassElement, InnerPin, OuterPin, Wire)) is False:
+ try:
+ object_collection = list(iter(obj))
+ except TypeError:
+ object_collection = [obj]
+ else:
+ object_collection = [obj] (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hcables:[148:156]
+==spydrnet.util.get_hwires:[148:156]
+ else:
+ bypass_namesearch.discard(obj)
+ reference = item.reference
+ if reference:
+ if selection in {Selection.INSIDE, Selection.ALL}:
+ # Get all cables inside a hierarchical instance
+ for cable in reference.cables:
+ hcable = HRef.from_parent_and_item(obj, cable) (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hcables:[66:75]
+==spydrnet.util.get_libraries:[84:93]
+ for x in kwargs
+ ):
+ raise TypeError("Unknown usage. Please see help for more information.")
+
+ # Default values
+ selection = kwargs.get("selection", Selection.INSIDE)
+ if isinstance(selection, str):
+ if selection in Selection.__members__:
+ selection = Selection[selection] (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hcables:[7:14]
+==spydrnet.util.get_libraries:[8:15]
+ Definition,
+ Instance,
+ Port,
+ Cable,
+)
+from spydrnet.util.hierarchical_reference import HRef
+from spydrnet.util.selection import Selection (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hpins:[1:8]
+==spydrnet.util.get_netlists:[2:9]
+ FirstClassElement,
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition, (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hpins:[74:81]
+==spydrnet.util.get_instances:[110:117]
+ if isinstance(obj, (FirstClassElement, InnerPin, OuterPin, Wire)) is False:
+ try:
+ object_collection = list(iter(obj))
+ except TypeError:
+ object_collection = [obj]
+ else:
+ object_collection = [obj] (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.parsers.edif.tokenizer:[70:77]
+==spydrnet.parsers.verilog.tokenizer:[75:82]
+ self.token = self.next_token
+ self.next_token = None
+ else:
+ self.token = next(self.generator)
+ return self.token
+
+ def peek(self): (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.ir.definition:[365:371]
+==spydrnet.ir.port:[35:41]
+ self,
+ name=None,
+ properties=None,
+ is_downto=None,
+ is_scalar=None,
+ lower_index=None, (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.ir.cable:[198:216]
+==spydrnet.ir.definition:[540:566]
+ return c
+
+ def clone(self):
+ """
+ Clone the Cable and all of its wires in an api safe way
+ the following will be true of the returned cable
+
+ * The cable will be orphaned from any definitions
+ * the wires in the cable will not be connected to any pins
+ * is_downto, is_scalar, lower_index will be maintained
+ * the wires in the cable will all have the cable set as the parent
+ """
+ c = self._clone({})
+ c._clone_rip()
+ return c
+
+ def __str__(self):
+ """Re-define the print function so it is easier to read""" (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.ir.cable:[19:25]
+==spydrnet.ir.definition:[149:155]
+ self,
+ name=None,
+ properties=None,
+ is_downto=None,
+ is_scalar=None,
+ lower_index=None, (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.ir.outerpin:[93:109]
+==spydrnet.ir.wire:[170:187]
+ return c
+
+ def clone(self):
+ """clone wire in an api safe way.
+
+ The following properties can be expected from the returned element:
+ * The wire is not connected to any pins.
+ * The wire is orphaned from any cable.
+ * No pins are connected to the wire
+ """
+ c = self._clone({})
+ c._clone_rip()
+ return c
+
+ def index(self):
+ """if this wire is in a cable, returns the index number of the wire in the parent cable"""
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.ir.instance:[44:51]
+==spydrnet.ir.netlist:[58:65]
+ if name is not None:
+ self.name = name
+ if properties is not None:
+ assert isinstance(properties, dict), "properties must be a dictionary"
+ for key in properties:
+ self[key] = properties[key]
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hinstances:[147:153]
+==spydrnet.util.get_netlists:[126:132]
+ definition = obj.definition
+ if definition:
+ object_collection.append(definition)
+ elif isinstance(obj, InnerPin):
+ port = obj.port
+ if port: (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_netlists:[3:9]
+==spydrnet.util.get_wires:[1:7]
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition, (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_pins:[125:131]
+==spydrnet.util.get_ports:[143:149]
+ elif isinstance(obj, Wire):
+ object_collection += obj.pins
+ elif isinstance(obj, Cable):
+ object_collection += obj.wires
+ elif isinstance(obj, HRef):
+ if obj.is_valid: (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hwires:[89:95]
+==spydrnet.util.get_pins:[63:69]
+ try:
+ object_collection = list(iter(obj))
+ except TypeError:
+ object_collection = [obj]
+ else:
+ object_collection = [obj] (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_cables:[199:205]
+==spydrnet.util.get_pins:[106:112]
+ port = obj.port
+ if port:
+ definition = port.definition
+ if definition:
+ for instance in definition.references:
+ outer_pin = instance.pins[obj] (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_cables:[280:286]
+==spydrnet.util.get_definitions:[248:254]
+ else:
+ names_to_remove = []
+ for name in namemap:
+ if _value_matches_pattern(name, pattern, is_case, is_re):
+ result = namemap[name]
+ names_to_remove.append(name) (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_definitions:[193:199]
+==spydrnet.util.get_libraries:[210:216]
+ if recursive:
+ object_collection.append(parent)
+ elif isinstance(obj, Instance):
+ if selection == Selection.INSIDE:
+ reference = obj.reference
+ if reference: (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_libraries:[85:93]
+==spydrnet.util.get_wires:[49:57]
+ ):
+ raise TypeError("Unknown usage. Please see help for more information.")
+
+ # Default values
+ selection = kwargs.get("selection", Selection.INSIDE)
+ if isinstance(selection, str):
+ if selection in Selection.__members__:
+ selection = Selection[selection] (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_instances:[222:228]
+==spydrnet.util.get_libraries:[241:247]
+ elif isinstance(obj, Wire):
+ cable = obj.cable
+ if cable:
+ object_collection.append(cable)
+ elif isinstance(obj, HRef):
+ if obj.is_valid: (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_definitions:[109:115]
+==spydrnet.util.get_hports:[75:81]
+ try:
+ object_collection = list(iter(obj))
+ except TypeError:
+ object_collection = [obj]
+ else:
+ object_collection = [obj] (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_definitions:[8:14]
+==spydrnet.util.get_hcables:[8:14]
+ Instance,
+ Port,
+ Cable,
+)
+from spydrnet.util.hierarchical_reference import HRef
+from spydrnet.util.selection import Selection (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_definitions:[1:7]
+==spydrnet.util.get_hcables:[2:8]
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition, (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hcables:[89:95]
+==spydrnet.util.get_wires:[66:72]
+ try:
+ object_collection = list(iter(obj))
+ except TypeError:
+ object_collection = [obj]
+ else:
+ object_collection = [obj] (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hinstances:[115:121]
+==spydrnet.util.get_hpins:[115:121]
+ while object_collection:
+ obj = object_collection.pop()
+ if isinstance(obj, Netlist):
+ top_instance = obj.top_instance
+ if top_instance:
+ href = HRef.from_parent_and_item(None, top_instance) (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_cables:[103:109]
+==spydrnet.util.get_hpins:[75:81]
+ try:
+ object_collection = list(iter(obj))
+ except TypeError:
+ object_collection = [obj]
+ else:
+ object_collection = [obj] (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_cables:[1:7]
+==spydrnet.util.get_hpins:[2:8]
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition, (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hpins:[7:13]
+==spydrnet.util.get_libraries:[8:14]
+ Definition,
+ Instance,
+ Port,
+ Cable,
+)
+from spydrnet.util.hierarchical_reference import HRef (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hpins:[1:7]
+==spydrnet.util.get_libraries:[1:7]
+ FirstClassElement,
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library, (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hpins:[262:268]
+==spydrnet.util.get_hports:[247:253]
+ name_stack.pop()
+ if recursive:
+ for child in reference.children:
+ if child.reference:
+ href_child = HRef.from_parent_and_item(href_instance, child)
+ search_stack.append((href_child, False)) (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hpins:[180:186]
+==spydrnet.util.get_hports:[173:179]
+ else:
+ port = pin.port
+ if port:
+ href_port = HRef.from_parent_and_item(
+ href_parent_instance, port
+ ) (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hpins:[142:148]
+==spydrnet.util.get_hports:[140:146]
+ if recursive:
+ for child in reference.children:
+ href_child = HRef.from_parent_and_item(obj, child)
+ bypass_namesearch.add(href_child)
+ object_collection.append(href_child)
+ elif isinstance(item, Port): (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hpins:[129:136]
+==spydrnet.util.get_hports:[129:136]
+ else:
+ bypass_namesearch.discard(obj)
+ reference = item.reference
+ if reference:
+ # Get all cables inside a hierarchical instance
+ for port in reference.ports:
+ hport = HRef.from_parent_and_item(obj, port) (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.parsers.eblif.eblif_tokenizer:[35:40]
+==spydrnet.parsers.verilog.tokenizer:[40:45]
+ stream = io.TextIOWrapper(stream)
+ self.input_stream = stream
+ else:
+ self.input_stream = open(input_source, "r")
+ elif isinstance(input_source, Path): (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.parsers.eblif.eblif_tokenizer:[21:28]
+==spydrnet.parsers.verilog.tokenizer:[27:34]
+ return tokenizer
+
+ def __init__(self, input_source):
+ # self.file = file
+ self.token = None
+ self.next_token = None
+ self.line_number = 0 (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.parsers.edif.tokenizer:[0:7]
+==spydrnet.parsers.verilog.tokenizer:[3:8]
+from functools import partial
+import re
+import zipfile
+import io
+from pathlib import Path
+
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.ir.cable:[198:214]
+==spydrnet.ir.wire:[170:184]
+ return c
+
+ def clone(self):
+ """clone wire in an api safe way.
+
+ The following properties can be expected from the returned element:
+ * The wire is not connected to any pins.
+ * The wire is orphaned from any cable.
+ * No pins are connected to the wire
+ """
+ c = self._clone({})
+ c._clone_rip()
+ return c
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.ir.cable:[55:62]
+==spydrnet.ir.port:[77:84]
+ if properties is not None:
+ assert isinstance(properties, dict), "properties must be a dictionary"
+ for key in properties:
+ self[key] = properties[key]
+
+ def _items(self):
+ """Overrides the bundle _items function to return wires""" (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.ir.innerpin:[51:66]
+==spydrnet.ir.outerpin:[93:108]
+ return c
+
+ def clone(self):
+ """Clone the pin in an api safe way.
+
+ The following conditions will be met with the returned outer pin:
+
+ * the pin will not be connected to any wires
+ * the pin will be orphaned from any instance
+ * the pin will not be connected to any inner pins
+ """
+ c = self._clone({})
+ c._clone_rip()
+ return c
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.ir.innerpin:[35:45]
+==spydrnet.ir.outerpin:[76:86]
+ self._wire = None
+
+ def _clone(self, memo):
+ """Not api safe clone function
+
+ clone leaving all references in tact.
+ the element can then either be ripped or ripped and replaced"""
+ assert (
+ self not in memo
+ ), "the object should not have been copied twice in this pass" (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_definitions:[241:246]
+==spydrnet.util.get_hinstances:[177:182]
+ for pattern in patterns:
+ pattern_is_absolute = _is_pattern_absolute(pattern, is_case, is_re)
+ if pattern_is_absolute:
+ if pattern in namemap:
+ result = namemap[pattern] (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_ports:[129:134]
+==spydrnet.util.get_wires:[112:117]
+ elif isinstance(obj, Instance):
+ reference = obj.reference
+ if reference:
+ object_collection.append(reference)
+ elif isinstance(obj, Port): (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_instances:[214:219]
+==spydrnet.util.get_netlists:[129:134]
+ elif isinstance(obj, InnerPin):
+ port = obj.port
+ if port:
+ object_collection.append(port)
+ elif isinstance(obj, OuterPin): (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hwires:[186:191]
+==spydrnet.util.get_wires:[122:127]
+ if selection == Selection.INSIDE:
+ if obj not in in_yield:
+ in_yield.add(obj)
+ yield obj
+ elif selection == Selection.OUTSIDE: (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hwires:[273:278]
+==spydrnet.util.get_ports:[161:166]
+ for pattern in patterns:
+ pattern_is_absolute = _is_pattern_absolute(pattern, is_case, is_re)
+ if pattern_is_absolute:
+ if pattern in namemap:
+ result = namemap[pattern] (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_cables:[167:172]
+==spydrnet.util.get_wires:[106:111]
+ if recursive or selection == Selection.ALL:
+ object_collection += obj.children
+ if selection in {Selection.OUTSIDE, Selection.BOTH, Selection.ALL}:
+ for port in obj.ports:
+ for pin in port.pins: (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_instances:[202:207]
+==spydrnet.util.get_libraries:[219:224]
+ if recursive:
+ object_collection += reference.children
+ else:
+ parent = obj.parent
+ if parent: (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_cables:[1:6]
+==spydrnet.util.get_libraries:[2:7]
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library, (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hports:[204:209]
+==spydrnet.util.get_instances:[244:249]
+ for pattern in patterns:
+ pattern_is_absolute = _is_pattern_absolute(pattern, is_case, is_re)
+ if pattern_is_absolute:
+ if pattern in namemap:
+ result = namemap[pattern] (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hports:[149:154]
+==spydrnet.util.get_hwires:[181:186]
+ elif isinstance(item, Cable):
+ for wire in item.wires:
+ href_wire = HRef.from_parent_and_item(obj, wire)
+ object_collection.append(href_wire)
+ elif isinstance(item, Wire): (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hcables:[68:75]
+==spydrnet.util.get_pins:[46:53]
+ raise TypeError("Unknown usage. Please see help for more information.")
+
+ # Default values
+ selection = kwargs.get("selection", Selection.INSIDE)
+ if isinstance(selection, str):
+ if selection in Selection.__members__:
+ selection = Selection[selection] (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_cables:[272:277]
+==spydrnet.util.get_hcables:[267:272]
+ for pattern in patterns:
+ pattern_is_absolute = _is_pattern_absolute(pattern, is_case, is_re)
+ if pattern_is_absolute:
+ if pattern in namemap:
+ result = namemap[pattern] (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hinstances:[122:127]
+==spydrnet.util.get_hpins:[122:127]
+ elif isinstance(obj, HRef):
+ if obj.is_valid is False:
+ continue
+ item = obj.item
+ if isinstance(item, Instance): (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hpins:[128:134]
+==spydrnet.util.get_hwires:[147:152]
+ _update_hwire_namemap(obj, recursive, in_namemap, namemap)
+ else:
+ bypass_namesearch.discard(obj)
+ reference = item.reference
+ if reference: (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hpins:[211:216]
+==spydrnet.util.get_libraries:[259:264]
+ for pattern in patterns:
+ pattern_is_absolute = _is_pattern_absolute(pattern, is_case, is_re)
+ if pattern_is_absolute:
+ if pattern in namemap:
+ result = namemap[pattern] (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.util.get_hcables:[179:184]
+==spydrnet.util.get_hpins:[153:158]
+ elif isinstance(item, Cable):
+ for wire in item.wires:
+ href_wire = HRef.from_parent_and_item(obj, wire)
+ object_collection.append(href_wire)
+ elif isinstance(item, Wire): (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.plugins.namespace_manager.default_namespace:[121:126]
+==spydrnet.plugins.namespace_manager.edif_namespace:[179:184]
+ def lookup(self, element_type, key, value):
+ if key == ".NAME":
+ if element_type in self.namespaces:
+ namespace = self.namespaces[element_type]
+ return namespace.get(value, None) (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.plugins.namespace_manager.default_namespace:[114:121]
+==spydrnet.plugins.namespace_manager.edif_namespace:[165:171]
+ if element_type in self.namespaces:
+ namespace = self.namespaces[element_type]
+ if ".NAME" in element:
+ old_name = element[".NAME"]
+ if old_name in namespace:
+ del namespace[old_name]
+ (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.plugins.namespace_manager.default_namespace:[104:109]
+==spydrnet.plugins.namespace_manager.edif_namespace:[166:171]
+ namespace = self.namespaces[element_type]
+ if ".NAME" in element:
+ old_name = element[".NAME"]
+ if old_name in namespace:
+ del namespace[old_name] (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.plugins.namespace_manager.default_namespace:[115:121]
+==spydrnet.plugins.namespace_manager.edif_namespace:[146:151]
+ namespace = self.namespaces[element_type]
+ if ".NAME" in element:
+ old_name = element[".NAME"]
+ if old_name in namespace:
+ del namespace[old_name] (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0801: Similar lines in 2 files
+==spydrnet.plugins.namespace_manager.default_namespace:[92:97]
+==spydrnet.plugins.namespace_manager.edif_namespace:[127:132]
+ if element_type in self.namespaces:
+ namespace = self.namespaces[element_type]
+ if value in namespace:
+ if namespace[value] != element:
+ return False (duplicate-code)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet.shortcuts.getter -> spydrnet.util.get_hports -> spydrnet.util.hierarchical_reference) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.util.get_instances -> spydrnet.util.hierarchical_reference -> spydrnet.shortcuts.getter -> spydrnet.util.get_hports) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet.shortcuts.getter -> spydrnet.util.get_instances -> spydrnet.util.hierarchical_reference) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.util.get_instances -> spydrnet.util.hierarchical_reference -> spydrnet.shortcuts.getter -> spydrnet.util.get_pins -> spydrnet.ir) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.parsers -> spydrnet.parsers.primitive_library_reader -> spydrnet.parsers.verilog.parser -> spydrnet.plugins.namespace_manager -> spydrnet.ir) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.parsers -> spydrnet.parsers.primitive_library_reader -> spydrnet.parsers.verilog.parser -> spydrnet.plugins.namespace_manager -> spydrnet.plugins.namespace_manager.default_namespace -> spydrnet.ir) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.parsers -> spydrnet.parsers.primitive_library_reader -> spydrnet.parsers.verilog.parser -> spydrnet.plugins.namespace_manager -> spydrnet.plugins.namespace_manager.edif_namespace -> spydrnet.plugins.namespace_manager.default_namespace -> spydrnet.ir) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.util.get_instances) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.util.get_hpins -> spydrnet.util.hierarchical_reference -> spydrnet.shortcuts.getter -> spydrnet.util.get_hports) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.util.get_hports) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.util.get_hcables -> spydrnet.util.hierarchical_reference -> spydrnet.shortcuts.getter -> spydrnet.util.get_hports) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet.shortcuts.getter -> spydrnet.util.get_pins -> spydrnet.util.hierarchical_reference) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.util.get_instances -> spydrnet.global_state.global_service -> spydrnet.ir) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.util.get_pins -> spydrnet.ir) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.util.get_instances -> spydrnet.util.hierarchical_reference -> spydrnet.shortcuts.getter -> spydrnet.util.get_libraries -> spydrnet.ir) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.util.get_instances -> spydrnet.util.hierarchical_reference -> spydrnet.shortcuts.getter -> spydrnet.util.get_cables -> spydrnet.ir) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.util.get_hwires -> spydrnet.util.hierarchical_reference -> spydrnet.shortcuts.getter -> spydrnet.util.get_hports) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.parsers -> spydrnet.parsers.primitive_library_reader -> spydrnet.ir) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.util.get_instances -> spydrnet.util.hierarchical_reference -> spydrnet.shortcuts.getter -> spydrnet.util.get_cables -> spydrnet.global_state.global_service -> spydrnet.ir) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.util.get_instances -> spydrnet.util.hierarchical_reference -> spydrnet.shortcuts.getter -> spydrnet.util.get_ports -> spydrnet.global_state.global_service -> spydrnet.ir) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.util.get_wires -> spydrnet.util.hierarchical_reference -> spydrnet.shortcuts.getter -> spydrnet.util.get_hports) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.util.get_hinstances -> spydrnet.util.hierarchical_reference -> spydrnet.shortcuts.getter -> spydrnet.util.get_hports) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.util.get_instances -> spydrnet.util.hierarchical_reference -> spydrnet.shortcuts.getter -> spydrnet.util.get_definitions -> spydrnet.ir) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.util.get_netlists -> spydrnet.util.hierarchical_reference -> spydrnet.shortcuts.getter -> spydrnet.util.get_hports) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.util.get_pins -> spydrnet.util.hierarchical_reference -> spydrnet.shortcuts.getter -> spydrnet.util.get_hports) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.util.get_instances -> spydrnet.util.hierarchical_reference -> spydrnet.ir) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.util.get_hports -> spydrnet.util.hierarchical_reference -> spydrnet.ir) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.composers -> spydrnet.composers.verilog.composer -> spydrnet.ir) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.composers -> spydrnet.composers.edif.composer -> spydrnet.ir) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.composers -> spydrnet.composers.eblif.eblif_composer) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.parsers -> spydrnet.parsers.primitive_library_reader -> spydrnet.parsers.verilog.verilog_tokens) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.parsers -> spydrnet.parsers.edif.parser -> spydrnet.plugins.namespace_manager -> spydrnet.ir) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.parsers -> spydrnet.parsers.primitive_library_reader -> spydrnet.parsers.verilog.parser -> spydrnet.parsers.verilog.tokenizer -> spydrnet.parsers.verilog.verilog_token_factory -> spydrnet.parsers.verilog.verilog_tokens) (cyclic-import)
+spydrnet/parsers/eblif/__init__.py:1:0: R0401: Cyclic import (spydrnet -> spydrnet.parsers -> spydrnet.parsers.eblif.eblif_parser -> spydrnet.ir) (cyclic-import)
+
+------------------------------------------------------------------
+Your code has been rated at 8.33/10 (previous run: 8.31/10, +0.01)
+
diff --git a/setup.py b/setup.py
index 5911353e..b1d0e362 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,6 @@
import sys
import setuptools
-import glob
-import os
+from pathlib import Path
if sys.argv[-1] == "setup.py":
print("To install, run 'python setup.py install'")
@@ -24,12 +23,12 @@
with open("README.rst", "r") as fh:
long_description = fh.read().replace(':ref:','')
-support_files = list()
-folder_path = os.path.normpath(os.path.join(os.path.dirname(__file__), "spydrnet", "support_files"))
-for filename in glob.glob(os.path.join(folder_path, "**", "*"), recursive=True):
- if os.path.isfile(filename) and \
- (os.path.getsize(filename) < 1024 * 10 or "architecture_libraries" in filename):
- support_files.append("support_files/" + str(filename)[len(folder_path) + 1:].replace('\\', '/'))
+support_files = []
+folder_path = Path(Path(__file__).parent).joinpath("spydrnet", "support_files")
+for filename in Path.glob(folder_path, "**/*"):
+ if filename.is_file() and \
+ (filename.stat().st_size < 1024 * 10 or "architecture_libraries" in str(filename)):
+ support_files.append("support_files/" + str(filename)[len(str(folder_path)) + 1:].replace('\\', '/'))
extras_require = {
"all": [
diff --git a/spydrnet/__init__.py b/spydrnet/__init__.py
index bbedcf13..79d52998 100644
--- a/spydrnet/__init__.py
+++ b/spydrnet/__init__.py
@@ -13,6 +13,8 @@
import pathlib
import pkgutil
import sys
+from pathlib import Path
+import requests
# ===================
# Setup Logging
@@ -22,7 +24,7 @@
# by defualt log file (_spydrnet.log) will be creted in the script directory
LOG_FORMAT = "%(levelname)5s %(filename)s:%(lineno)s (%(threadName)10s) - %(message)s"
-logger = logging.getLogger('spydrnet_logs')
+logger = logging.getLogger("spydrnet_logs")
# This is global log level other logger can not have lower level than this
logger.setLevel(logging.DEBUG)
@@ -35,7 +37,7 @@
def enable_file_logging(LOG_LEVEL=None):
LOG_LEVEL = logging.getLevelName(LOG_LEVEL or "INFO")
- file_handler = logging.FileHandler("_spydrnet.log", mode='w')
+ file_handler = logging.FileHandler("_spydrnet.log", mode="w")
file_handler.setFormatter(logging.Formatter(LOG_FORMAT))
file_handler.setLevel(LOG_LEVEL)
logger.addHandler(file_handler)
@@ -47,9 +49,8 @@ def enable_file_logging(LOG_LEVEL=None):
# =============================
discovered_plugins = {
name: name
- for finder, name, ispkg
- in pkgutil.iter_modules()
- if name.startswith('spydrnet_')
+ for finder, name, ispkg in pkgutil.iter_modules()
+ if name.startswith("spydrnet_")
}
logger.debug("Installed Plugins", discovered_plugins.keys())
@@ -57,20 +58,20 @@ def enable_file_logging(LOG_LEVEL=None):
def get_active_plugins():
active_plugins = {}
config_file = None
- config_file_home = os.path.join(str(pathlib.Path.home()), ".spydrnet")
- if os.path.isfile(config_file_home):
+ config_file_home = Path(str(pathlib.Path.home()), ".spydrnet")
+ if Path(config_file_home).is_file():
config_file = config_file_home
- config_file_local = os.path.join(".", ".spydrnet")
- if os.path.isfile(config_file_local):
+ config_file_local = Path(".", ".spydrnet")
+ if Path(config_file_local).is_file():
config_file = config_file_local
if config_file:
for plugin in open(config_file, "r").read().split():
if discovered_plugins.get(plugin, None):
- if (plugin not in sys.modules) and (plugin not in dir()): # prevents reimporting over and over again
+ if (plugin not in sys.modules) and (plugin not in dir()): # prevents reimporting over and over again
active_plugins.update({plugin: importlib.import_module(plugin)})
# print("imported", plugin)
- else:
- active_plugins.update({plugin:sys.modules[plugin]})
+ else:
+ active_plugins.update({plugin: sys.modules[plugin]})
else:
logger.debug("Plugin %s is not installed " % plugin)
@@ -82,9 +83,9 @@ def get_active_plugins():
# Release data
from spydrnet import release
-__author__ = '%s <%s>\n%s <%s>\n%s <%s>' % \
- (release.authors['Keller'] + release.authors['Skouson'] +
- release.authors['Wirthlin'])
+__author__ = "%s <%s>\n%s <%s>\n%s <%s>" % (
+ release.authors["Keller"] + release.authors["Skouson"] + release.authors["Wirthlin"]
+)
__license__ = release.license
__date__ = release.date
@@ -99,51 +100,119 @@ def get_active_plugins():
INOUT = Port.Direction.INOUT
UNDEFINED = Port.Direction.UNDEFINED
-import os
-
from spydrnet.composers import compose
from spydrnet.parsers import parse
from spydrnet.plugins import namespace_manager
from spydrnet.testing.test import run as test
-from spydrnet.util import (get_cables, get_definitions, get_hcables,
- get_hinstances, get_hpins, get_hports, get_hwires,
- get_instances, get_libraries, get_netlists,
- get_pins, get_ports, get_wires)
+from spydrnet.util import (
+ get_cables,
+ get_definitions,
+ get_hcables,
+ get_hinstances,
+ get_hpins,
+ get_hports,
+ get_hwires,
+ get_instances,
+ get_libraries,
+ get_netlists,
+ get_pins,
+ get_ports,
+ get_wires,
+)
from spydrnet.util.selection import ALL, BOTH, INSIDE, OUTSIDE
from spydrnet.util.netlist_type import EDIF, VERILOG, EBLIF
-base_dir = os.path.dirname(os.path.abspath(__file__))
-
-import glob
-
-example_netlist_names = list()
-for filename in glob.glob(os.path.join(base_dir, 'support_files', 'EDIF_netlists', "*")):
- basename = os.path.basename(filename)
- example_netlist_names.append(basename[:basename.index('.')])
-example_netlist_names.sort()
-
-verilog_example_netlist_names = list()
-for filename in glob.glob(os.path.join(base_dir, 'support_files', 'verilog_netlists', "*")):
- basename = os.path.basename(filename)
- verilog_example_netlist_names.append(basename[:basename.index('.')])
-verilog_example_netlist_names.sort()
-
-eblif_example_netlist_names = list()
-for filename in glob.glob(os.path.join(base_dir, 'support_files', 'eblif_netlists', "*")):
- basename = os.path.basename(filename)
- eblif_example_netlist_names.append(basename[:basename.index('.')])
-eblif_example_netlist_names.sort()
-
-def load_example_netlist_by_name(name, format=EDIF):
- if format is EDIF:
- assert name in example_netlist_names, "Example netlist not found"
- return parse(os.path.join(base_dir, 'support_files', 'EDIF_netlists', name + ".edf.zip"))
- elif format is VERILOG:
- assert name in verilog_example_netlist_names, "Example netlist not found"
- return parse(os.path.join(base_dir, 'support_files', 'verilog_netlists', name + ".v.zip"))
- elif format is EBLIF:
- assert name in eblif_example_netlist_names, "Example netlist not found"
- return parse(os.path.join(base_dir, 'support_files', 'eblif_netlists', name + ".eblif.zip"))
- else: # if no version is recognized, default to edif
- assert name in example_netlist_names, "Example netlist not found"
- return parse(os.path.join(base_dir, 'support_files', 'EDIF_netlists', name + ".edf.zip"))
+
+def determine_example_netlists_path(download_option):
+ example_netlists_path = pathlib.Path("example_netlists")
+ temp_dir_loc = pathlib.Path(
+ "/tmp/spydrnet_example_netlists/spydrnet-next_release/example_netlists/"
+ )
+ if "EXAMPLE_NETLISTS_PATH" in os.environ:
+ example_netlists_path = pathlib.Path(os.environ["EXAMPLE_NETLISTS_PATH"])
+ elif temp_dir_loc.exists():
+ example_netlists_path = temp_dir_loc
+ else:
+ None
+
+ if not example_netlists_path.exists() and download_option:
+ print(
+ "Could not find example netlists. Download to /tmp/spydrnet_example_netlists? y/n"
+ )
+ response = input()
+ if response == "y":
+ print("Downloading example netlists...")
+ url = (
+ "https://github.com/byuccl/spydrnet/archive/refs/heads/next_release.zip"
+ )
+ filename = pathlib.Path("/tmp/spydrnet_temp.zip")
+ response = requests.get(url)
+ filename.write_bytes(response.content)
+
+ import zipfile
+
+ extract_loc = "/tmp/spydrnet_example_netlists"
+ with zipfile.ZipFile(filename, "r") as zip_ref:
+ zip_ref.extractall(extract_loc)
+ env_variable = extract_loc + "/spydrnet-next_release/example_netlists/"
+ os.environ["EXAMPLE_NETLISTS_PATH"] = env_variable
+ print("Example netlists located in " + os.environ["EXAMPLE_NETLISTS_PATH"])
+ example_netlists_path = pathlib.Path(os.environ["EXAMPLE_NETLISTS_PATH"])
+
+ example_netlists_path = example_netlists_path.resolve()
+ return example_netlists_path
+
+
+example_netlists_path = determine_example_netlists_path(False)
+
+base_dir = Path(Path(__file__).absolute()).parent
+
+example_netlist_names = []
+verilog_example_netlist_names = []
+eblif_example_netlist_names = []
+
+
+def get_example_netlist_names(path):
+ example_netlist_names.clear()
+ edif_path = Path(path).joinpath("EDIF_netlists")
+ for filename in Path.glob(edif_path, "*"):
+ basename = Path(filename).name
+ example_netlist_names.append(basename[: basename.index(".")])
+ example_netlist_names.sort()
+
+ verilog_example_netlist_names.clear()
+ verilog_path = Path(path).joinpath("verilog_netlists")
+ for filename in Path.glob(verilog_path, "*"):
+ basename = Path(filename).name
+ verilog_example_netlist_names.append(basename[: basename.index(".")])
+ verilog_example_netlist_names.sort()
+
+ eblif_example_netlist_names.clear()
+ eblif_path = Path(path).joinpath("eblif_netlists")
+ for filename in Path.glob(eblif_path, "*"):
+ basename = Path(filename).name
+ eblif_example_netlist_names.append(basename[: basename.index(".")])
+ eblif_example_netlist_names.sort()
+
+
+get_example_netlist_names(example_netlists_path)
+
+
+def load_example_netlist_by_name(name, netlist_format=EDIF):
+ example_netlists_path = determine_example_netlists_path(True)
+ get_example_netlist_names(example_netlists_path)
+ error_message = "Example netlist not found. Either run 'export EXAMPLE_NETLISTS_PATH=' \
+ or allow downloading to /tmp/spydrnet_example_netlists."
+ if netlist_format is EDIF:
+ assert name in example_netlist_names, error_message
+ return parse(Path(example_netlists_path, "EDIF_netlists", name + ".edf.zip"))
+ if netlist_format is VERILOG:
+ assert name in verilog_example_netlist_names, error_message
+ return parse(Path(example_netlists_path, "verilog_netlists", name + ".v.zip"))
+ if netlist_format is EBLIF:
+ assert name in eblif_example_netlist_names, error_message
+ return parse(Path(example_netlists_path, "eblif_netlists", name + ".eblif.zip"))
+
+ # if no version is recognized, default to edif
+ assert name in example_netlist_names, error_message
+ return parse(Path(example_netlists_path, "EDIF_netlists", name + ".edf.zip"))
diff --git a/spydrnet/callback/callback_listener.py b/spydrnet/callback/callback_listener.py
index 6fc3fe6f..8c5d89d8 100644
--- a/spydrnet/callback/callback_listener.py
+++ b/spydrnet/callback/callback_listener.py
@@ -7,7 +7,8 @@ class CallbackListener:
In this class are all of the functions that are used as callbacks. There are also
register methods whos function is to register the callback functions that are present.
- callbacks are netlist dependent. If a callback is registered to one netlist it is not automatically registered to all netlists.
+ callbacks are netlist dependent. If a callback is registered to one netlist it is not
+ automatically registered to all netlists.
"""
def __init__(self):
@@ -84,7 +85,7 @@ def wire_connect_pin(self, wire, pin):
def wire_disconnect_pin(self, wire, pin):
raise NotImplementedError
-
+
def dictionary_set(self, element, key, value):
raise NotImplementedError
@@ -119,40 +120,73 @@ def register_all_listeners(self):
if self.cable_remove_wire.__func__ is not CallbackListener.cable_remove_wire:
self.register_cable_remove_wire()
- if self.definition_add_port.__func__ is not CallbackListener.definition_add_port:
+ if (
+ self.definition_add_port.__func__
+ is not CallbackListener.definition_add_port
+ ):
self.register_definition_add_port()
- if self.definition_remove_port.__func__ is not CallbackListener.definition_remove_port:
+ if (
+ self.definition_remove_port.__func__
+ is not CallbackListener.definition_remove_port
+ ):
self.register_definition_remove_port()
- if self.definition_add_child.__func__ is not CallbackListener.definition_add_child:
+ if (
+ self.definition_add_child.__func__
+ is not CallbackListener.definition_add_child
+ ):
self.register_definition_add_child()
- if self.definition_remove_child.__func__ is not CallbackListener.definition_remove_child:
+ if (
+ self.definition_remove_child.__func__
+ is not CallbackListener.definition_remove_child
+ ):
self.register_definition_remove_child()
- if self.definition_add_cable.__func__ is not CallbackListener.definition_add_cable:
+ if (
+ self.definition_add_cable.__func__
+ is not CallbackListener.definition_add_cable
+ ):
self.register_definition_add_cable()
- if self.definition_remove_cable.__func__ is not CallbackListener.definition_remove_cable:
+ if (
+ self.definition_remove_cable.__func__
+ is not CallbackListener.definition_remove_cable
+ ):
self.register_definition_remove_cable()
if self.instance_reference.__func__ is not CallbackListener.instance_reference:
self.register_instance_reference()
- if self.library_add_definition.__func__ is not CallbackListener.library_add_definition:
+ if (
+ self.library_add_definition.__func__
+ is not CallbackListener.library_add_definition
+ ):
self.register_library_add_definition()
- if self.library_remove_definition.__func__ is not CallbackListener.library_remove_definition:
+ if (
+ self.library_remove_definition.__func__
+ is not CallbackListener.library_remove_definition
+ ):
self.register_library_remove_definition()
- if self.netlist_top_instance.__func__ is not CallbackListener.netlist_top_instance:
+ if (
+ self.netlist_top_instance.__func__
+ is not CallbackListener.netlist_top_instance
+ ):
self.register_netlist_top_instance()
- if self.netlist_add_library.__func__ is not CallbackListener.netlist_add_library:
+ if (
+ self.netlist_add_library.__func__
+ is not CallbackListener.netlist_add_library
+ ):
self.register_netlist_add_library()
- if self.netlist_remove_library.__func__ is not CallbackListener.netlist_remove_library:
+ if (
+ self.netlist_remove_library.__func__
+ is not CallbackListener.netlist_remove_library
+ ):
self.register_netlist_remove_library()
if self.port_add_pin.__func__ is not CallbackListener.port_add_pin:
@@ -164,7 +198,10 @@ def register_all_listeners(self):
if self.wire_connect_pin.__func__ is not CallbackListener.wire_connect_pin:
self.register_wire_connect_pin()
- if self.wire_disconnect_pin.__func__ is not CallbackListener.wire_disconnect_pin:
+ if (
+ self.wire_disconnect_pin.__func__
+ is not CallbackListener.wire_disconnect_pin
+ ):
self.register_wire_disconnect_pin()
if self.dictionary_set.__func__ is not CallbackListener.dictionary_set:
@@ -175,7 +212,7 @@ def register_all_listeners(self):
if self.dictionary_pop.__func__ is not CallbackListener.dictionary_pop:
self.register_dictionary_pop()
-
+
def register_create_netlist(self):
global_callback.register_create_netlist(self.create_netlist)
@@ -225,7 +262,9 @@ def register_library_add_definition(self):
global_callback.register_library_add_definition(self.library_add_definition)
def register_library_remove_definition(self):
- global_callback.register_library_remove_definition(self.library_remove_definition)
+ global_callback.register_library_remove_definition(
+ self.library_remove_definition
+ )
def register_netlist_top_instance(self):
global_callback.register_netlist_top_instance(self.netlist_top_instance)
@@ -282,40 +321,73 @@ def deregister_all_listeners(self):
if self.cable_remove_wire.__func__ is not CallbackListener.cable_remove_wire:
self.deregister_cable_remove_wire()
- if self.definition_add_port.__func__ is not CallbackListener.definition_add_port:
+ if (
+ self.definition_add_port.__func__
+ is not CallbackListener.definition_add_port
+ ):
self.deregister_definition_add_port()
- if self.definition_remove_port.__func__ is not CallbackListener.definition_remove_port:
+ if (
+ self.definition_remove_port.__func__
+ is not CallbackListener.definition_remove_port
+ ):
self.deregister_definition_remove_port()
- if self.definition_add_child.__func__ is not CallbackListener.definition_add_child:
+ if (
+ self.definition_add_child.__func__
+ is not CallbackListener.definition_add_child
+ ):
self.deregister_definition_add_child()
- if self.definition_remove_child.__func__ is not CallbackListener.definition_remove_child:
+ if (
+ self.definition_remove_child.__func__
+ is not CallbackListener.definition_remove_child
+ ):
self.deregister_definition_remove_child()
- if self.definition_add_cable.__func__ is not CallbackListener.definition_add_cable:
+ if (
+ self.definition_add_cable.__func__
+ is not CallbackListener.definition_add_cable
+ ):
self.deregister_definition_add_cable()
- if self.definition_remove_cable.__func__ is not CallbackListener.definition_remove_cable:
+ if (
+ self.definition_remove_cable.__func__
+ is not CallbackListener.definition_remove_cable
+ ):
self.deregister_definition_remove_cable()
if self.instance_reference.__func__ is not CallbackListener.instance_reference:
self.deregister_instance_reference()
- if self.library_add_definition.__func__ is not CallbackListener.library_add_definition:
+ if (
+ self.library_add_definition.__func__
+ is not CallbackListener.library_add_definition
+ ):
self.deregister_library_add_definition()
- if self.library_remove_definition.__func__ is not CallbackListener.library_remove_definition:
+ if (
+ self.library_remove_definition.__func__
+ is not CallbackListener.library_remove_definition
+ ):
self.deregister_library_remove_definition()
- if self.netlist_top_instance.__func__ is not CallbackListener.netlist_top_instance:
+ if (
+ self.netlist_top_instance.__func__
+ is not CallbackListener.netlist_top_instance
+ ):
self.deregister_netlist_top_instance()
- if self.netlist_add_library.__func__ is not CallbackListener.netlist_add_library:
+ if (
+ self.netlist_add_library.__func__
+ is not CallbackListener.netlist_add_library
+ ):
self.deregister_netlist_add_library()
- if self.netlist_remove_library.__func__ is not CallbackListener.netlist_remove_library:
+ if (
+ self.netlist_remove_library.__func__
+ is not CallbackListener.netlist_remove_library
+ ):
self.deregister_netlist_remove_library()
if self.port_add_pin.__func__ is not CallbackListener.port_add_pin:
@@ -327,7 +399,10 @@ def deregister_all_listeners(self):
if self.wire_connect_pin.__func__ is not CallbackListener.wire_connect_pin:
self.deregister_wire_connect_pin()
- if self.wire_disconnect_pin.__func__ is not CallbackListener.wire_disconnect_pin:
+ if (
+ self.wire_disconnect_pin.__func__
+ is not CallbackListener.wire_disconnect_pin
+ ):
self.deregister_wire_disconnect_pin()
if self.dictionary_set.__func__ is not CallbackListener.dictionary_set:
@@ -388,7 +463,9 @@ def deregister_library_add_definition(self):
global_callback.deregister_library_add_definition(self.library_add_definition)
def deregister_library_remove_definition(self):
- global_callback.deregister_library_remove_definition(self.library_remove_definition)
+ global_callback.deregister_library_remove_definition(
+ self.library_remove_definition
+ )
def deregister_netlist_top_instance(self):
global_callback.deregister_netlist_top_instance(self.netlist_top_instance)
@@ -418,4 +495,4 @@ def deregister_dictionary_delete(self):
global_callback.deregister_dictionary_delete(self.dictionary_delete)
def deregister_dictionary_pop(self):
- global_callback.deregister_dictionary_pop(self.dictionary_pop)
\ No newline at end of file
+ global_callback.deregister_dictionary_pop(self.dictionary_pop)
diff --git a/spydrnet/clone.py b/spydrnet/clone.py
index bf9e2575..eb99c149 100644
--- a/spydrnet/clone.py
+++ b/spydrnet/clone.py
@@ -1,6 +1,3 @@
-from spydrnet import ir
-from copy import deepcopy, copy, error
-
"""provide the clone function for spydrnet."""
@@ -16,12 +13,16 @@ def clone(element):
Properties
* cloned using python's built in deepcopy functionality.
- * expected to be string objects but if you store something else there make sure you override deepcopy on that object.
+ * expected to be string objects but if you store something else there make sure you override
+ deepcopy on that object.
Instances have some special considerations
- * when cloned without the library containing the reference definition the instance will still point to the definition of it's clone.
- * in the same case as the above point the references of the definition will be updated accordingly
- * when a library is cloned some of the instances may be defined in another library these instances will follow the premises above
+ * when cloned without the library containing the reference definition the instance will still
+ point to the definition of it's clone.
+ * in the same case as the above point the references of the definition will be updated
+ accordingly
+ * when a library is cloned some of the instances may be defined in another library these
+ instances will follow the premises above
* instances defined and referenced in the cloned library will point to the cloned definition
"""
diff --git a/spydrnet/compare/compare_netlists.py b/spydrnet/compare/compare_netlists.py
index 4c9d59cb..912c6df3 100644
--- a/spydrnet/compare/compare_netlists.py
+++ b/spydrnet/compare/compare_netlists.py
@@ -3,9 +3,10 @@
class Comparer:
-
def __init__(self, ir_orig, ir_composer):
- assert ir_orig and ir_composer, "Both orig_netlist and composer netlist must be specified"
+ assert (
+ ir_orig and ir_composer
+ ), "Both orig_netlist and composer netlist must be specified"
self.ir_orig = ir_orig
self.ir_composer = ir_composer
@@ -14,101 +15,127 @@ def run(self):
def compare(self):
# try:
- assert self.get_identifier(self.ir_orig) == self.get_identifier(self.ir_composer), \
- "Environments do not have the same identifier"
- assert self.get_original_identifier(self.ir_orig) == self.get_original_identifier(self.ir_composer), \
- "Environments do not have the same original identifier"
+ assert self.get_identifier(self.ir_orig) == self.get_identifier(
+ self.ir_composer
+ ), "Environments do not have the same identifier"
+ assert self.get_original_identifier(
+ self.ir_orig
+ ) == self.get_original_identifier(
+ self.ir_composer
+ ), "Environments do not have the same original identifier"
# if there is no top instance in either then this test passes.
- if (self.ir_composer.top_instance != None or self.ir_orig.top_instance != None):
+ if self.ir_composer.top_instance is not None or self.ir_orig.top_instance is not None:
self.compare_instances(
- self.ir_orig.top_instance, self.ir_composer.top_instance)
- assert len(self.ir_orig.libraries) == len(self.ir_composer.libraries), \
- "Environments do not have the same number of libraries"
+ self.ir_orig.top_instance, self.ir_composer.top_instance
+ )
+ assert len(self.ir_orig.libraries) == len(
+ self.ir_composer.libraries
+ ), "Environments do not have the same number of libraries"
# except Exception:
# import pdb; pdb.set_trace()
for orig_library in self.ir_orig.libraries:
- if orig_library.name == None:
+ if orig_library.name is None:
# ports with no name are not compared
- print("WARNING: library with name == None exists and is not compared")
+ print("WARNING: library with name is None exists and is not compared")
continue
else:
patterns = orig_library.name
- composer_library = next(
- sdn.get_libraries(self.ir_composer, patterns))
+ composer_library = next(sdn.get_libraries(self.ir_composer, patterns))
self.compare_libraries(orig_library, composer_library)
def compare_libraries(self, library_orig, library_composer):
# try:
- assert self.get_identifier(library_orig) == self.get_identifier(library_composer), \
- "Libraries do not have the same identifier"
- assert self.get_original_identifier(library_orig) == self.get_original_identifier(library_composer), \
- "Libraries do not have the same original identifier"
- assert len(library_orig.definitions) == len(library_composer.definitions), \
- "Libraries do not have the same amount of definitions " \
- + str(library_orig) + " " + str(len(library_orig.definitions)) + " " +\
- str(library_composer) + " " + \
- str(len(library_composer.definitions))
+ assert self.get_identifier(library_orig) == self.get_identifier(
+ library_composer
+ ), "Libraries do not have the same identifier"
+ assert self.get_original_identifier(
+ library_orig
+ ) == self.get_original_identifier(
+ library_composer
+ ), "Libraries do not have the same original identifier"
+ assert len(library_orig.definitions) == len(library_composer.definitions), (
+ "Libraries do not have the same amount of definitions "
+ + str(library_orig)
+ + " "
+ + str(len(library_orig.definitions))
+ + " "
+ + str(library_composer)
+ + " "
+ + str(len(library_composer.definitions))
+ )
# except Exception:
# import pdb; pdb.set_trace()
for orig_definition in library_orig.definitions:
- if orig_definition.name == None:
+ if orig_definition.name is None:
# ports with no name are not compared
print(
- "WARNING: definitions with name == None exist but are not compared")
+ "WARNING: definitions with name is None exist but are not compared"
+ )
continue
else:
patterns = orig_definition.name
- composer_definition = next(
- sdn.get_definitions(library_composer, patterns))
+ composer_definition = next(sdn.get_definitions(library_composer, patterns))
self.compare_definition(orig_definition, composer_definition)
- def compare_definition(self, definition_orig, definition_composer, check_identifier=True):
+ def compare_definition(
+ self, definition_orig, definition_composer, check_identifier=True
+ ):
if check_identifier:
- assert self.get_identifier(definition_orig) == self.get_identifier(definition_composer), \
- "Definitions do not have the same identifier"
- assert self.get_original_identifier(definition_orig) == self.get_original_identifier(definition_composer), \
- "Definitions do not have the same original identifier"
-
- assert len(definition_orig.ports) == len(definition_composer.ports), \
- "Definitions do not have the same number of ports"
+ assert self.get_identifier(definition_orig) == self.get_identifier(
+ definition_composer
+ ), "Definitions do not have the same identifier"
+ assert self.get_original_identifier(
+ definition_orig
+ ) == self.get_original_identifier(
+ definition_composer
+ ), "Definitions do not have the same original identifier"
+
+ assert len(definition_orig.ports) == len(
+ definition_composer.ports
+ ), "Definitions do not have the same number of ports"
# for orig_port, composer_port in zip(definition_orig.ports, definition_composer.ports):
# self.compare_ports(orig_port, composer_port)
# do a smarter compare
for orig_port in definition_orig.ports:
- if orig_port.name == None:
+ if orig_port.name is None:
# ports with no name are not compared
- print("WARNING: ports with name == None exist and are not compared")
+ print("WARNING: ports with name is None exist and are not compared")
continue
else:
patterns = orig_port.name
composer_port = next(sdn.get_ports(definition_composer, patterns))
self.compare_ports(orig_port, composer_port)
- assert len(definition_orig.cables) == len(definition_composer.cables), \
- "Definitions do not have the same number of cables "\
- + definition_orig.name + " " + str(len(definition_orig.cables))\
- + " " + definition_composer.name + " " + \
- str(len(definition_composer.cables))
+ assert len(definition_orig.cables) == len(definition_composer.cables), (
+ "Definitions do not have the same number of cables "
+ + definition_orig.name
+ + " "
+ + str(len(definition_orig.cables))
+ + " "
+ + definition_composer.name
+ + " "
+ + str(len(definition_composer.cables))
+ )
for orig_cable in definition_orig.cables:
- if orig_cable.name == None:
+ if orig_cable.name is None:
# ports with no name are not compared
- print("WARNING: cables with name == None exist and are not compared")
+ print("WARNING: cables with name is None exist and are not compared")
continue
else:
patterns = orig_cable.name
- composer_cable = next(sdn.get_cables(
- definition_composer, patterns))
+ composer_cable = next(sdn.get_cables(definition_composer, patterns))
self.compare_cables(orig_cable, composer_cable)
- assert len(definition_orig.children) == len(definition_composer.children), \
- "Definitions do not have the same number of instances"
+ assert len(definition_orig.children) == len(
+ definition_composer.children
+ ), "Definitions do not have the same number of instances"
# for orig_instance, composer_cable in zip(definition_orig.children, definition_composer.children):
# self.compare_instances(orig_instance, composer_cable)
for orig_instance in definition_orig.children:
- if orig_instance.name == None:
+ if orig_instance.name is None:
# ports with no name are not compared
- print("WARNING: children with name == None exist and are not compared")
+ print("WARNING: children with name is None exist and are not compared")
continue
else:
if orig_instance.name.startswith("SDN_Assignment_"):
@@ -117,8 +144,7 @@ def compare_definition(self, definition_orig, definition_composer, check_identif
else:
patterns = orig_instance.name
- composer_instance = next(
- sdn.get_instances(definition_composer, patterns))
+ composer_instance = next(sdn.get_instances(definition_composer, patterns))
self.compare_instances(orig_instance, composer_instance)
@@ -127,8 +153,8 @@ def compare_definition(self, definition_orig, definition_composer, check_identif
composer_generator = sdn.get_instances(definition_composer, pattern)
orig_generator = sdn.get_instances(definition_orig, pattern)
# i just need to make sure that they both contain the same number of each width assignment
- composer_dict = dict()
- orig_dict = dict()
+ composer_dict = {}
+ orig_dict = {}
ci = next(composer_generator, None)
while ci is not None:
@@ -149,140 +175,203 @@ def compare_definition(self, definition_orig, definition_composer, check_identif
oi = next(orig_generator, None)
for k in composer_dict.keys():
- assert k in orig_dict and orig_dict[k] == composer_dict[k], "there are a different number of " + str(
- k) + " width assignment"
+ assert k in orig_dict and orig_dict[k] == composer_dict[k], (
+ "there are a different number of " + str(k) + " width assignment"
+ )
def compare_cables(self, cable_orig, cable_composer):
- assert self.get_identifier(cable_orig) == self.get_identifier(cable_composer), \
- "Cables do not have the same identifier"
- assert self.get_original_identifier(cable_orig) == self.get_original_identifier(cable_composer), \
- "Cables do not have the same original identifier"
- assert len(cable_orig.wires) == len(cable_composer.wires), \
- "Cables do not have the same number of wires " + cable_orig.name + " " + \
- str(len(cable_orig.wires)) + " " + cable_composer.name + \
- " " + str(len(cable_composer.wires))
+ assert self.get_identifier(cable_orig) == self.get_identifier(
+ cable_composer
+ ), "Cables do not have the same identifier"
+ assert self.get_original_identifier(cable_orig) == self.get_original_identifier(
+ cable_composer
+ ), "Cables do not have the same original identifier"
+ assert len(cable_orig.wires) == len(cable_composer.wires), (
+ "Cables do not have the same number of wires "
+ + cable_orig.name
+ + " "
+ + str(len(cable_orig.wires))
+ + " "
+ + cable_composer.name
+ + " "
+ + str(len(cable_composer.wires))
+ )
# zip is left here because the order of wires in cables matters.
for orig_wire, composer_wire in zip(cable_orig.wires, cable_composer.wires):
- assert len(orig_wire.pins) == len(composer_wire.pins), \
- "wires connect to a different number of pins " + \
- orig_wire.cable.name + " " + composer_wire.cable.name
+ assert len(orig_wire.pins) == len(composer_wire.pins), (
+ "wires connect to a different number of pins "
+ + orig_wire.cable.name
+ + " "
+ + composer_wire.cable.name
+ )
for orig_pin, composer_pin in zip(orig_wire.pins, composer_wire.pins):
- assert type(orig_pin) == type(composer_pin), \
- "pin types do not match up."
+ assert type(orig_pin) == type(
+ composer_pin
+ ), "pin types do not match up."
if isinstance(orig_pin, OuterPin):
self.compare_outer_pins(orig_pin, composer_pin)
else:
self.compare_inner_pins(orig_pin, composer_pin)
def compare_outer_pins(self, pin_orig, pin_composer):
- assert pin_orig.instance.reference == pin_orig.inner_pin.port.definition and \
- pin_composer.instance.reference == pin_composer.inner_pin.port.definition, \
- "DRC failure, outer pin instance reference on associated pin definition not the same"
+ assert (
+ pin_orig.instance.reference == pin_orig.inner_pin.port.definition
+ and pin_composer.instance.reference
+ == pin_composer.inner_pin.port.definition
+ ), "DRC failure, outer pin instance reference on associated pin definition not the same"
# try:
- assert self.are_instances_equivalent(pin_orig.instance, pin_composer.instance), \
- "Net does not connect to a pin on the same instance"
+ assert self.are_instances_equivalent(
+ pin_orig.instance, pin_composer.instance
+ ), "Net does not connect to a pin on the same instance"
# except Exception:
# import pdb; pdb.set_trace()
- assert self.are_inner_pins_equivalent(pin_orig.inner_pin, pin_orig.inner_pin), \
- "Net does not connect the same pin"
+ assert self.are_inner_pins_equivalent(
+ pin_orig.inner_pin, pin_orig.inner_pin
+ ), "Net does not connect the same pin"
def compare_inner_pins(self, pin_orig, pin_composer):
- assert self.are_inner_pins_equivalent(pin_orig, pin_composer), \
- "Net does not connect the same pin"
+ assert self.are_inner_pins_equivalent(
+ pin_orig, pin_composer
+ ), "Net does not connect the same pin"
def are_instances_equivalent(self, orig_instance, composer_instance):
orig_name = self.get_identifier(orig_instance)
composer_name = self.get_identifier(composer_instance)
# assignment instances are not very well kept when written out so just compare the width
- if orig_name.startswith("SDN_Assignment_") and composer_name.startswith("SDN_Assignment_"):
+ if orig_name.startswith("SDN_Assignment_") and composer_name.startswith(
+ "SDN_Assignment_"
+ ):
orig_split = orig_name.split("_")
composer_split = composer_name.split("_")
- assert orig_split[3] == composer_split[3], "the widths of the assignments are off " + \
- orig_split[3] + " " + composer_split[3]
+ assert orig_split[3] == composer_split[3], (
+ "the widths of the assignments are off "
+ + orig_split[3]
+ + " "
+ + composer_split[3]
+ )
else:
- assert orig_name == composer_name, "Names are not the same " + \
- orig_name + " " + composer_name
- assert self.get_identifier(orig_instance.reference) == self.get_identifier(composer_instance.reference) and \
- self.get_identifier(orig_instance.reference.library) == \
- self.get_identifier(composer_instance.reference.library) and \
- self.get_identifier(orig_instance.parent) == self.get_identifier(composer_instance.parent) and \
- self.get_identifier(orig_instance.parent.library) == \
- self.get_identifier(composer_instance.parent.library), \
- 'Instances are not equivalent ' + orig_instance.name + " " + composer_instance.name
+ assert orig_name == composer_name, (
+ "Names are not the same " + orig_name + " " + composer_name
+ )
+ assert (
+ self.get_identifier(orig_instance.reference)
+ == self.get_identifier(composer_instance.reference)
+ and self.get_identifier(orig_instance.reference.library)
+ == self.get_identifier(composer_instance.reference.library)
+ and self.get_identifier(orig_instance.parent)
+ == self.get_identifier(composer_instance.parent)
+ and self.get_identifier(orig_instance.parent.library)
+ == self.get_identifier(composer_instance.parent.library)
+ ), (
+ "Instances are not equivalent "
+ + orig_instance.name
+ + " "
+ + composer_instance.name
+ )
return True
def are_inner_pins_equivalent(self, orig_pin, composer_pin):
- assert orig_pin.port.pins.index(orig_pin) == composer_pin.port.pins.index(composer_pin), \
- "Pin indices do not match"
- assert self.get_identifier(orig_pin.port) == self.get_identifier(composer_pin.port) and \
- self.get_identifier(orig_pin.port.definition) == self.get_identifier(composer_pin.port.definition) and \
- self.get_identifier(orig_pin.port.definition.library) == \
- self.get_identifier(composer_pin.port.definition.library), \
- "Pins are not from equivalent ports"
+ assert orig_pin.port.pins.index(orig_pin) == composer_pin.port.pins.index(
+ composer_pin
+ ), "Pin indices do not match"
+ assert (
+ self.get_identifier(orig_pin.port) == self.get_identifier(composer_pin.port)
+ and self.get_identifier(orig_pin.port.definition)
+ == self.get_identifier(composer_pin.port.definition)
+ and self.get_identifier(orig_pin.port.definition.library)
+ == self.get_identifier(composer_pin.port.definition.library)
+ ), "Pins are not from equivalent ports"
return True
def compare_ports(self, port_orig, port_composer):
- assert self.get_identifier(port_orig) == self.get_identifier(port_composer), \
- "Ports do not have the same identifier"
- assert self.get_original_identifier(port_orig) == self.get_original_identifier(port_composer), \
- "Ports do not have the same original identifier"
-
- assert port_orig.direction == port_composer.direction, \
- "Ports are not facing the same direction, " + \
- str(port_orig.direction) + " " + str(port_composer.direction)
-
- assert port_orig.is_array == port_composer.is_array, \
- "Ports Array mismatch"
-
- assert len(port_orig.pins) > 0 and len(port_composer.pins) > 0, \
- "DRC failure, ports should have at least one pin"
-
- assert len(port_orig.pins) == len(port_composer.pins), \
- "Ports do not have the same number of pins, " + port_orig.name + " " + \
- str(len(port_orig.pins)) + " " + port_composer.name + \
- " " + str(len(port_composer.pins))
-
- assert self.get_identifier(port_orig.definition) == self.get_identifier(port_composer.definition) and \
- self.get_identifier(port_orig.definition.library) == \
- self.get_identifier(port_composer.definition.library), \
- "Ports do not belong to an equivalent definition"
+ assert self.get_identifier(port_orig) == self.get_identifier(
+ port_composer
+ ), "Ports do not have the same identifier"
+ assert self.get_original_identifier(port_orig) == self.get_original_identifier(
+ port_composer
+ ), "Ports do not have the same original identifier"
+
+ assert port_orig.direction == port_composer.direction, (
+ "Ports are not facing the same direction, "
+ + str(port_orig.direction)
+ + " "
+ + str(port_composer.direction)
+ )
+
+ assert port_orig.is_array == port_composer.is_array, "Ports Array mismatch"
+
+ assert (
+ len(port_orig.pins) > 0 and len(port_composer.pins) > 0
+ ), "DRC failure, ports should have at least one pin"
+
+ assert len(port_orig.pins) == len(port_composer.pins), (
+ "Ports do not have the same number of pins, "
+ + port_orig.name
+ + " "
+ + str(len(port_orig.pins))
+ + " "
+ + port_composer.name
+ + " "
+ + str(len(port_composer.pins))
+ )
+
+ assert self.get_identifier(port_orig.definition) == self.get_identifier(
+ port_composer.definition
+ ) and self.get_identifier(port_orig.definition.library) == self.get_identifier(
+ port_composer.definition.library
+ ), "Ports do not belong to an equivalent definition"
def compare_instances(self, instances_orig, instances_composer):
instances_orig_identifier = self.get_identifier(instances_orig)
instances_composer_identifier = self.get_identifier(instances_composer)
- assert instances_orig_identifier == instances_composer_identifier, \
- "Instances do not have the same identifier, orig \"{}\" " \
- "composer \"{}\"".format(
- instances_orig_identifier, instances_composer_identifier)
+ assert instances_orig_identifier == instances_composer_identifier, (
+ 'Instances do not have the same identifier, orig "{}" '
+ 'composer "{}"'.format(
+ instances_orig_identifier, instances_composer_identifier
+ )
+ )
instances_orig_original_identifier = self.get_original_identifier(
- instances_orig)
+ instances_orig
+ )
instances_composer_original_identifier = self.get_original_identifier(
- instances_composer)
- assert instances_orig_original_identifier == instances_composer_original_identifier, \
- "Instances do not have the same original identifier, orig " \
- "\"{}\" composer \"{}\"".format(
- instances_orig_original_identifier, instances_composer_original_identifier)
-
- assert (instances_orig.reference == None and instances_composer.reference == None) or \
- (self.get_identifier(instances_orig.reference) == self.get_identifier(instances_composer.reference) and
- self.get_identifier(instances_orig.reference.library) ==
- self.get_identifier(instances_composer.reference.library)), \
- "Instances do not have the same reference definition."
+ instances_composer
+ )
+ assert (
+ instances_orig_original_identifier == instances_composer_original_identifier
+ ), (
+ "Instances do not have the same original identifier, orig "
+ '"{}" composer "{}"'.format(
+ instances_orig_original_identifier,
+ instances_composer_original_identifier,
+ )
+ )
+
+ assert (
+ instances_orig.reference is None and instances_composer.reference is None
+ ) or (
+ self.get_identifier(instances_orig.reference)
+ == self.get_identifier(instances_composer.reference)
+ and self.get_identifier(instances_orig.reference.library)
+ == self.get_identifier(instances_composer.reference.library)
+ ), "Instances do not have the same reference definition."
if "EDIF.properties" in instances_orig:
- assert "EDIF.properties" in instances_composer, "Composer is missing properties"
+ assert (
+ "EDIF.properties" in instances_composer
+ ), "Composer is missing properties"
properties_orig = instances_orig["EDIF.properties"]
properties_composer = instances_composer["EDIF.properties"]
for x in range(len(properties_orig)):
for key, value in properties_orig[x].items():
- assert properties_orig[x][key] == properties_composer[x][key], \
- "Instances do not have the same properties"
+ assert (
+ properties_orig[x][key] == properties_composer[x][key]
+ ), "Instances do not have the same properties"
@staticmethod
def get_identifier(obj):
- if obj == None:
+ if obj is None:
return None
return obj.name
# if "EDIF.identifier" in obj:
@@ -290,7 +379,7 @@ def get_identifier(obj):
@staticmethod
def get_original_identifier(obj):
- if obj == None:
+ if obj is None:
return None
if "EDIF.original_identifier" in obj:
return obj["EDIF.original_identifier"]
diff --git a/spydrnet/composers/__init__.py b/spydrnet/composers/__init__.py
index 52ce4e14..60a56a07 100644
--- a/spydrnet/composers/__init__.py
+++ b/spydrnet/composers/__init__.py
@@ -1,25 +1,30 @@
-import os
from pathlib import Path
+from spydrnet.composers.edif.composer import ComposeEdif
+from spydrnet.composers.verilog.composer import Composer as VerilogComposer
+from spydrnet.composers.eblif.eblif_composer import EBLIFComposer
-def compose(netlist, filename, voters=[], definition_list=[], write_blackbox=True, write_eblif_cname=True, defparam = False):
+def compose(
+ netlist,
+ filename,
+ definition_list=[],
+ write_blackbox=True,
+ write_eblif_cname=True,
+ defparam=False,
+):
"""To compose a file into a netlist format"""
extension = Path(filename).suffix
extension_lower = extension.lower()
if extension_lower in {".edf", ".edif"}:
- from spydrnet.composers.edif.composer import ComposeEdif
composer = ComposeEdif()
if netlist.name is None:
raise Exception("netlist.name undefined")
composer.run(netlist, filename)
elif extension_lower in [".v", ".vh", ".vm"]:
- from spydrnet.composers.verilog.composer import Composer
- composer = Composer(definition_list, write_blackbox, defparam)
+ composer = VerilogComposer(definition_list, write_blackbox, defparam)
composer.run(netlist, file_out=filename)
- elif extension_lower in [".eblif",".blif"]:
- from spydrnet.composers.eblif.eblif_composer import EBLIFComposer
+ elif extension_lower in [".eblif", ".blif"]:
composer = EBLIFComposer(write_blackbox, write_eblif_cname)
- composer.run(netlist,filename)
- None
+ composer.run(netlist, filename)
else:
raise RuntimeError("Extension {} not recognized.".format(extension))
diff --git a/spydrnet/composers/eblif/eblif_composer.py b/spydrnet/composers/eblif/eblif_composer.py
index 6979e182..50cc07ff 100644
--- a/spydrnet/composers/eblif/eblif_composer.py
+++ b/spydrnet/composers/eblif/eblif_composer.py
@@ -1,6 +1,7 @@
+from pathlib import Path
from spydrnet.util.selection import Selection
import spydrnet as sdn
-from pathlib import Path
+
class EBLIFComposer:
def __init__(self, write_blackbox, write_cname=True):
@@ -15,34 +16,34 @@ def __init__(self, write_blackbox, write_cname=True):
def run(self, ir, file_out):
self.open_file = self.prepare_file(file_out)
self._compose(ir)
-
- def prepare_file(self,out_file):
- if (Path(out_file).exists()):
- f = open(out_file,"w")
+
+ def prepare_file(self, out_file):
+ if Path(out_file).exists():
+ f = open(out_file, "w")
else:
- f = open(out_file,"x")
+ f = open(out_file, "x")
return f
-
- def write_out(self,string):
+
+ def write_out(self, string):
self.open_file.write(string)
-
+
def clean_up(self):
self.open_file.close()
- def _compose(self,ir):
+ def _compose(self, ir):
self.netlist = ir
self.compose_comments()
self.compose_models()
self.clean_up()
-
+
def compose_comments(self):
if "EBLIF.comment" in self.netlist.data:
for comment in self.netlist["EBLIF.comment"]:
- to_write = "# "+comment+"\n"
+ to_write = "# " + comment + "\n"
self.write_out(to_write)
- self.write_out("# Generated by \'BYU spydrnet tool\'\n")
+ self.write_out("# Generated by 'BYU spydrnet tool'\n")
self.write_out("\n")
-
+
def compose_models(self):
self.compose_model(self.netlist.top_instance.reference)
for model in self.netlist.get_hinstances(recursive=True):
@@ -52,7 +53,7 @@ def compose_models(self):
self.models_written.append(model)
if self.write_blackbox:
self.compose_blackboxes()
-
+
def compose_model(self, model):
if model.library.name == "hdi_primitives":
return
@@ -66,47 +67,51 @@ def compose_model(self, model):
def compose_model_ports(self):
to_write = ".inputs "
- for port in self.current_model.get_ports(filter = lambda x: x.direction in {sdn.IN, sdn.INOUT}):
+ for port in self.current_model.get_ports(
+ filter=lambda x: x.direction in {sdn.IN, sdn.INOUT}
+ ):
if len(port.pins) > 1:
for i in range(len(port.pins)):
- to_write+=port.name+"["+str(i)+"] "
+ to_write += port.name + "[" + str(i) + "] "
else:
- to_write+=port.name+" "
- to_write+="\n"
+ to_write += port.name + " "
+ to_write += "\n"
self.write_out(to_write)
to_write = ".outputs "
- for port in self.current_model.get_ports(filter = lambda x: x.direction in {sdn.OUT, sdn.INOUT}):
+ for port in self.current_model.get_ports(
+ filter=lambda x: x.direction in {sdn.OUT, sdn.INOUT}
+ ):
if len(port.pins) > 1:
for i in range(len(port.pins)):
- to_write+=port.name+"["+str(i)+"] "
+ to_write += port.name + "[" + str(i) + "] "
else:
- to_write+=port.name+" "
- to_write+="\n"
+ to_write += port.name + " "
+ to_write += "\n"
self.write_out(to_write)
-
+
def compose_model_clocks(self):
if "EBLIF.clock" in self.current_model.data:
to_write = ".clock "
for clock in self.current_model["EBLIF.clock"]:
- to_write+=clock+" "
- self.write_out(to_write+"\n")
-
+ to_write += clock + " "
+ self.write_out(to_write + "\n")
+
def compose_instances(self):
categories = self.separate_by_type()
if "EBLIF.subckt" in categories.keys():
self.compose_subcircuits(categories["EBLIF.subckt"])
if "EBLIF.gate" in categories.keys():
- self.compose_subcircuits(categories["EBLIF.gate"],is_gate=True)
+ self.compose_subcircuits(categories["EBLIF.gate"], is_gate=True)
if "EBLIF.other" in categories.keys():
self.compose_subcircuits(categories["EBLIF.other"])
if "EBLIF.names" in categories.keys():
self.compose_names(categories["EBLIF.names"])
if "EBLIF.latch" in categories.keys():
self.compose_latches(categories["EBLIF.latch"])
-
+
def separate_by_type(self):
- dict_by_types = dict()
+ dict_by_types = {}
for instance in self.current_model.children:
try:
instance["EBLIF.type"]
@@ -117,123 +122,156 @@ def separate_by_type(self):
try:
dict_by_types[type]
except KeyError:
- dict_by_types[type] = list()
+ dict_by_types[type] = []
dict_by_types[type].append(instance)
return dict_by_types
-
- def compose_subcircuits(self,list_of_subcircuits,is_gate=False):
+
+ def compose_subcircuits(self, list_of_subcircuits, is_gate=False):
for subckt in list_of_subcircuits:
- if (subckt.is_leaf()):
+ if subckt.is_leaf():
self.blackboxes_to_compose.add(subckt.reference)
to_add = ""
if is_gate:
- to_write = ".gate "+ subckt.reference.name+" "
+ to_write = ".gate " + subckt.reference.name + " "
else:
- to_write = ".subckt "+ subckt.reference.name+" "
+ to_write = ".subckt " + subckt.reference.name + " "
amount_of_ports_to_write = 0
for port in subckt.get_ports():
for pin in port.pins:
- amount_of_ports_to_write+=1
+ amount_of_ports_to_write += 1
for port in subckt.reference.get_ports():
- inner_pin_list = port.pins
- for pin in subckt.get_pins(selection=Selection.OUTSIDE,filter=lambda x: x.inner_pin.port is port):
- if (amount_of_ports_to_write > 5):
- to_write+=to_add+" \\\n"
+ inner_pin_list = port.pins
+ for pin in subckt.get_pins(
+ selection=Selection.OUTSIDE,
+ filter=lambda x: x.inner_pin.port is port,
+ ):
+ if amount_of_ports_to_write > 5:
+ to_write += to_add + " \\\n"
to_add = ""
if len(inner_pin_list) > 1:
index = inner_pin_list.index(pin.inner_pin)
- to_add+=port.name+"["+str(index)+"]"+"="
+ to_add += port.name + "[" + str(index) + "]" + "="
else:
- to_add+=port.name+"="
+ to_add += port.name + "="
if pin.wire:
- to_add+=self.find_connected_wire_info(pin)
+ to_add += self.find_connected_wire_info(pin)
else:
- to_add+='unconn'
- to_add+=" "
- to_write+=to_add+'\n'
+ to_add += "unconn"
+ to_add += " "
+ to_write += to_add + "\n"
self.write_out(to_write)
self.find_and_write_additional_instance_info(subckt)
-
- def compose_names(self,list_of_names):
+
+ def compose_names(self, list_of_names):
for name_instance in list_of_names:
to_write = ".names "
- in_pin_list = list(x for x in name_instance.get_pins(selection=Selection.OUTSIDE,filter=lambda x: x.inner_pin.port.direction is sdn.IN))
+ in_pin_list = list(
+ x
+ for x in name_instance.get_pins(
+ selection=Selection.OUTSIDE,
+ filter=lambda x: x.inner_pin.port.direction is sdn.IN,
+ )
+ )
in_pin_list.reverse()
for pin in in_pin_list:
- # for pin in name_instance.get_pins(selection=Selection.OUTSIDE,filter=lambda x: x.inner_pin.port.direction is sdn.IN):
+ # for pin in name_instance.get_pins(selection=Selection.OUTSIDE,
+ # filter=lambda x: x.inner_pin.port.direction is sdn.IN):
if pin.wire:
- to_write+=pin.wire.cable.name
- if len(pin.wire.cable.wires) > 1: # if a multi bit wire, add the index
- to_write+="["+str(pin.wire.cable.wires.index(pin.wire))+"]"
+ to_write += pin.wire.cable.name
+ if (len(pin.wire.cable.wires) > 1): # if a multi bit wire, add the index
+ to_write += (
+ "[" + str(pin.wire.cable.wires.index(pin.wire)) + "]"
+ )
else:
- to_write+="unconn"
- to_write+=" "
- for pin in name_instance.get_pins(selection=Selection.OUTSIDE,filter=lambda x: x.inner_pin.port.direction is sdn.OUT):
+ to_write += "unconn"
+ to_write += " "
+ for pin in name_instance.get_pins(
+ selection=Selection.OUTSIDE,
+ filter=lambda x: x.inner_pin.port.direction is sdn.OUT,
+ ):
if pin.wire:
- to_write+=pin.wire.cable.name
- if len(pin.wire.cable.wires) > 1: # if a multi bit wire, add the index
- to_write+="["+str(pin.wire.cable.wires.index(pin.wire))+"]"
+ to_write += pin.wire.cable.name
+ if (len(pin.wire.cable.wires) > 1): # if a multi bit wire, add the index
+ to_write += (
+ "[" + str(pin.wire.cable.wires.index(pin.wire)) + "]"
+ )
else:
- to_write+="unconn"
- to_write+=" "
- to_write+="\n"
+ to_write += "unconn"
+ to_write += " "
+ to_write += "\n"
try:
name_instance["EBLIF.output_covers"]
for output_cover in name_instance["EBLIF.output_covers"]:
- to_write+=output_cover+"\n"
+ to_write += output_cover + "\n"
except KeyError:
None
self.write_out(to_write)
self.find_and_write_additional_instance_info(name_instance)
- def compose_latches(self,latch_list):
+ def compose_latches(self, latch_list):
for latch_instance in latch_list:
to_write = ".latch "
- for port_type in ['input', 'output', 'type', 'control', 'init-val']: # this is the specific order of ports
- for pin in latch_instance.get_pins(selection=Selection.OUTSIDE,filter=lambda x: x.inner_pin.port.name == port_type):
+ for port_type in [
+ "input",
+ "output",
+ "type",
+ "control",
+ "init-val",
+ ]: # this is the specific order of ports
+ for pin in latch_instance.get_pins(
+ selection=Selection.OUTSIDE,
+ filter=lambda x: x.inner_pin.port.name == port_type,
+ ):
if pin.wire:
- to_write+=pin.wire.cable.name
- if (len(pin.wire.cable.wires)>1):
- to_write+="["+str(pin.wire.index())+"]"
- to_write+=" "
+ to_write += pin.wire.cable.name
+ if len(pin.wire.cable.wires) > 1:
+ to_write += "[" + str(pin.wire.index()) + "]"
+ to_write += " "
else:
- to_write+="unconn "
- to_write+='\n'
+ to_write += "unconn "
+ to_write += "\n"
self.write_out(to_write)
self.find_and_write_additional_instance_info(latch_instance)
- def find_connected_wire_info(self,pin):
+ def find_connected_wire_info(self, pin):
string_to_return = ""
cable = pin.wire.cable
- string_to_return+=cable.name
+ string_to_return += cable.name
if len(cable.wires) > 1:
- string_to_return+="["+str(pin.wire.index()) +"]"
+ string_to_return += "[" + str(pin.wire.index()) + "]"
return string_to_return
- def find_and_write_additional_instance_info(self,instance):
+ def find_and_write_additional_instance_info(self, instance):
to_write = ""
if self.write_cname:
- to_write+=".cname "+instance.name+'\n'
+ to_write += ".cname " + instance.name + "\n"
if "EBLIF.attr" in instance.data:
for key, value in instance.data["EBLIF.attr"].items():
- to_write+=".attr "+key+" "+value+'\n'
+ to_write += ".attr " + key + " " + value + "\n"
if "EBLIF.param" in instance.data:
for key, value in instance.data["EBLIF.param"].items():
- to_write+=".param "+key+" "+value+'\n'
+ to_write += ".param " + key + " " + value + "\n"
self.write_out(to_write)
-
+
def compose_blackboxes(self):
primitive_library = next(self.netlist.get_libraries("hdi_primitives"))
for definition in primitive_library.definitions:
- if definition in self.blackboxes_to_compose and "logic-gate" not in definition.name: # only compose blackboxes that are not .names
+ if (
+ definition in self.blackboxes_to_compose
+ and "logic-gate" not in definition.name
+ ): # only compose blackboxes that are not .names
to_write = ".model " + definition.name
- to_write+="\n.inputs"
- for port in definition.get_ports(filter=lambda x: x.direction is sdn.IN):
- to_write+=" "+port.name
- to_write+="\n.outputs"
- for port in definition.get_ports(filter=lambda x: x.direction is sdn.OUT):
- to_write+=" "+port.name
- self.write_out(to_write+"\n")
+ to_write += "\n.inputs"
+ for port in definition.get_ports(
+ filter=lambda x: x.direction is sdn.IN
+ ):
+ to_write += " " + port.name
+ to_write += "\n.outputs"
+ for port in definition.get_ports(
+ filter=lambda x: x.direction is sdn.OUT
+ ):
+ to_write += " " + port.name
+ self.write_out(to_write + "\n")
self.write_out(".blackbox\n")
self.compose_end()
diff --git a/spydrnet/composers/eblif/tests/test_eblif_composer.py b/spydrnet/composers/eblif/tests/test_eblif_composer.py
deleted file mode 100644
index d688427c..00000000
--- a/spydrnet/composers/eblif/tests/test_eblif_composer.py
+++ /dev/null
@@ -1,56 +0,0 @@
-import unittest
-import os
-import spydrnet as sdn
-from spydrnet import base_dir
-from pathlib import Path
-
-"""
-Test the EBLIF composer. The best way I can think to do this is to parse a netlist, compose it, then parse it again to see if anything changed. It should all be the same
-"""
-
-class TestEBLIFComposer(unittest.TestCase):
- def setUp(self):
- self.netlist_1 = sdn.parse(Path(base_dir, 'support_files', 'eblif_netlists', "toggle.eblif.zip"))
- self.definition_list = ["INV","BUFG","FDRE","IBUF","OBUF","toggle", "logic-gate_0"]
- sdn.compose(self.netlist_1,"temp_for_composer_test.eblif")
- sdn.compose(self.netlist_1,"temp_for_composer_test_no_blackbox.eblif",write_blackbox=False)
- self.netlist_2 = sdn.parse("temp_for_composer_test.eblif")
- self.netlist_3 = sdn.parse("temp_for_composer_test_no_blackbox.eblif")
- os.remove("temp_for_composer_test.eblif")
- os.remove("temp_for_composer_test_no_blackbox.eblif")
-
- def test_netlist_name(self):
- self.assertEqual(self.netlist_1.name,self.netlist_2.name)
-
- def test_top_instance(self):
- self.assertEqual(self.netlist_1.top_instance.name,self.netlist_2.top_instance.name)
-
- def test_instances(self):
- instances_1 = list(instance.name for instance in self.netlist_1.get_instances())
- instances_2 = list(instance.name for instance in self.netlist_2.get_instances())
- instances_1.sort()
- instances_2.sort()
- self.assertEqual(instances_1,instances_2)
- self.assertEqual(len(instances_1),len(instances_2))
-
- def test_definitions(self):
- definitions_1 = list(definition.name for definition in self.netlist_1.get_definitions())
- definitions_2 = list(definition.name for definition in self.netlist_2.get_definitions())
- definitions_1.sort()
- definitions_2.sort()
- self.assertEqual(definitions_1,definitions_2)
- self.assertEqual(len(definitions_1),len(definitions_2))
-
- def test_cables(self):
- cables_1 = list(cable.name for cable in self.netlist_1.get_cables())
- cables_2 = list(cable.name for cable in self.netlist_2.get_cables())
- cables_1.sort()
- cables_2.sort()
- self.assertEqual(cables_1,cables_2)
- self.assertEqual(len(cables_1),len(cables_2))
-
-
- # TODO add wires and connections tests
-
- # test the composing of each individual part
-
\ No newline at end of file
diff --git a/spydrnet/composers/edif/composer.py b/spydrnet/composers/edif/composer.py
index da21de88..918c9d00 100644
--- a/spydrnet/composers/edif/composer.py
+++ b/spydrnet/composers/edif/composer.py
@@ -1,7 +1,7 @@
import json
-from spydrnet.ir import *
import inspect # used for debug.
from datetime import datetime
+from spydrnet.ir import *
from spydrnet.composers.edif.edifify_names import EdififyNames
@@ -22,16 +22,19 @@ def run(self, ir=None, file_out="out.edf"):
Keyword Arguments:
ir -- the object(environment) to be composed to edif (default None)
- file_out -- the path and name of the file to which the edif will be written (default "out.edf")
+ file_out -- the path and name of the file to which the edif will be written (default
+ "out.edf")
"""
self.output_filename = file_out
self._edifify_netlist(ir)
self._data_ = ir
- if (isinstance(ir, str)):
+ if isinstance(ir, str):
self.filename = ir
self._read_data_() # only needed if we start to accept the json format files
print(
- "currently input files directly to the composer are unsupported! read in with the parser first.")
+ "currently input files directly to the composer are unsupported! read in with \
+ the parser first."
+ )
else:
self._data_ = ir
self._open_output_()
@@ -39,7 +42,6 @@ def run(self, ir=None, file_out="out.edf"):
self._close_output_()
def _edifify_netlist(self, netlist):
-
# functions defined to be used as dependency getters in topological sort
# declared here to be used more as functional oriented code.
def _get_definition_dependency_same_library(definition):
@@ -55,18 +57,21 @@ def _get_library_dependency(library):
for definition in library.definitions:
for child in definition.children:
if child.reference is None:
- raise Exception("definition: ", child,
- ".reference is undefined")
+ raise Exception(
+ "definition: ", child, ".reference is undefined"
+ )
if child.reference.library != library:
depend_set.add(child.reference.library)
return depend_set
# try:
netlist.libraries = self._topological_sort(
- netlist.libraries, _get_library_dependency)
+ netlist.libraries, _get_library_dependency
+ )
for library in netlist.libraries:
library.definitions = self._topological_sort(
- library.definitions, _get_definition_dependency_same_library)
+ library.definitions, _get_definition_dependency_same_library
+ )
# except:
# #import pdb; pdb.set_trace()
@@ -84,13 +89,11 @@ def _get_library_dependency(library):
for cable in definition.cables:
self._add_rename_property(cable, definition.cables, names)
for instance in definition.children:
- self._add_rename_property(
- instance, definition.children, names)
+ self._add_rename_property(instance, definition.children, names)
for port in definition.ports:
self._add_rename_property(port, definition.ports, names)
def _topological_sort(self, list_of_objects, dependecy_function):
-
visited = set()
output_list = []
get_dependents = dependecy_function
@@ -100,7 +103,7 @@ def iterate(o):
nonlocal output_list
nonlocal get_dependents
stack = [o]
- while(len(stack) > 0):
+ while len(stack) > 0:
o = stack[-1]
for child in get_dependents(o):
if child not in visited:
@@ -129,7 +132,7 @@ def iterate(o):
def _add_rename_property(self, obj, namespace_list, rename_helper):
if obj.name is None:
- raise Exception('obj, ', obj, '.name undefined')
+ raise Exception("obj, ", obj, ".name undefined")
name = obj.name
if "EDIF.identifier" in obj.data:
return
@@ -144,7 +147,7 @@ def _read_data_(self):
self._data_ = json.load(fi)
def _open_output_(self):
- self._output_ = open(self.output_filename, 'w', buffering=1)
+ self._output_ = open(self.output_filename, "w", buffering=1)
def _output_environment_(self):
self._lisp_increment_()
@@ -171,7 +174,7 @@ def _output_environment_(self):
self._output_status_()
self._new_line_()
for library in self._data_.libraries:
- #if library.name != "SDN.verilog_primitives":
+ # if library.name != "SDN.verilog_primitives":
self._output_library_(library)
self._lisp_increment_()
@@ -183,12 +186,12 @@ def _output_environment_(self):
test = self._data_.top_instance
if self._data_.top_instance.reference is None:
raise Exception("netlist.reference undefined")
- self._output_.write(
- self._data_.top_instance.reference['EDIF.identifier'])
+ self._output_.write(self._data_.top_instance.reference["EDIF.identifier"])
self._lisp_increment_()
self._output_.write("libraryref ")
self._output_.write(
- self._data_.top_instance.reference.library['EDIF.identifier'])
+ self._data_.top_instance.reference.library["EDIF.identifier"]
+ )
self._lisp_decrement_()
self._lisp_decrement_()
self._new_line_()
@@ -197,8 +200,11 @@ def _output_environment_(self):
self._lisp_decrement_()
- assert self._lisp_depth_ == 0, "There was an error with parenthesis matching off by " + \
- str(self._lisp_depth_)
+ assert (
+ self._lisp_depth_ == 0
+ ), "There was an error with parenthesis matching off by " + str(
+ self._lisp_depth_
+ )
def _output_status_(self):
self._new_line_()
@@ -214,21 +220,23 @@ def _output_status_(self):
self._output_.write("{}".format(now.strftime("%Y %m %d %H %M %S")))
self._lisp_decrement_()
self._new_line_()
- if 'EDIF.status.written.program' in self._data_:
+ if "EDIF.status.written.program" in self._data_:
self._lisp_increment_()
self._output_.write("program ")
- self._output_.write('"{}" '.format(
- self._data_['EDIF.status.written.program']))
- if 'EDIF.status.written.program.version' in self._data_:
+ self._output_.write(
+ '"{}" '.format(self._data_["EDIF.status.written.program"])
+ )
+ if "EDIF.status.written.program.version" in self._data_:
self._lisp_increment_()
self._output_.write("version ")
- self._output_.write('"{}"'.format(
- self._data_['EDIF.status.written.program.version']))
+ self._output_.write(
+ '"{}"'.format(self._data_["EDIF.status.written.program.version"])
+ )
self._lisp_decrement_()
self._lisp_decrement_()
self._new_line_()
self._lisp_increment_()
- self._output_.write('comment "Built by \'BYU spydrnet tool\'"')
+ self._output_.write("comment \"Built by 'BYU spydrnet tool'\"")
self._lisp_decrement_()
self._new_line_()
self._lisp_decrement_()
@@ -261,7 +269,9 @@ def _output_library_(self, library):
self._new_line_()
def _output_name_of_object_(self, obj):
- # if '.NAME' not in obj or (obj['.NAME'] == obj['EDIF.identifier'] and obj.get('EDIF.rename', False) is False):
+ # if '.NAME' not in obj or
+ # (obj['.NAME'] == obj['EDIF.identifier'] and
+ # obj.get('EDIF.rename', False) is False):
# self._output_.write(obj['EDIF.identifier'])
# else:
# identifier = obj['EDIF.identifier']
@@ -280,13 +290,16 @@ def _output_name_of_object_(self, obj):
self._output_.write(name)
def _get_name_string_(self, obj):
- if '.NAME' not in obj or (obj['.NAME'] == obj['EDIF.identifier'] and obj.get('EDIF.rename', False) is False):
+ if ".NAME" not in obj or (
+ obj[".NAME"] == obj["EDIF.identifier"]
+ and obj.get("EDIF.rename", False) is False
+ ):
rename = False
- name = obj['EDIF.identifier']
+ name = obj["EDIF.identifier"]
else:
rename = True
- identifier = obj['EDIF.identifier']
- rename_name = obj.get('.NAME', identifier)
+ identifier = obj["EDIF.identifier"]
+ rename_name = obj.get(".NAME", identifier)
name = "rename " + identifier + ' "' + rename_name + '"'
return rename, name
@@ -346,8 +359,9 @@ def _output_port_(self, port):
self._output_.write(" ")
self._lisp_increment_()
self._output_.write("direction ")
- self._output_.write(self._direction_to_string_(
- port.direction)) # str(port.direction))
+ self._output_.write(
+ self._direction_to_string_(port.direction)
+ ) # str(port.direction))
self._lisp_decrement_()
self._lisp_decrement_()
self._new_line_()
@@ -355,8 +369,9 @@ def _output_port_(self, port):
self._output_name_of_object_(port)
self._lisp_increment_()
self._output_.write("direction ")
- self._output_.write(self._direction_to_string_(
- port.direction)) # str(port.direction))
+ self._output_.write(
+ self._direction_to_string_(port.direction)
+ ) # str(port.direction))
self._lisp_decrement_()
self._lisp_decrement_()
self._new_line_()
@@ -409,7 +424,7 @@ def _output_cable_(self, cable):
self._lisp_increment_()
self._output_.write("joined")
self._new_line_()
- # for port in cable.getConnectionList(): #TODO fuction cable.getConnectionList() needs to be created
+ # for port in cable.getConnectionList(): #TODO create fuction cable.getConnectionList()
for pin in wire.pins:
# port = pin.port
# print(type(pin))
@@ -417,8 +432,7 @@ def _output_cable_(self, cable):
self._output_inner_pin_(pin)
pin = pin.inner_pin
else:
- self._output_port_ref_(
- pin.port, self._get_edif_name_(cable), pin)
+ self._output_port_ref_(pin.port, self._get_edif_name_(cable), pin)
self._new_line_()
self._lisp_decrement_()
self._new_line_()
@@ -430,10 +444,8 @@ def _output_name_of_cable_wire_(self, cable, wire):
else:
# cable_name = self._get_name_string_(cable)
cable_index = self._get_wire_index_(cable, wire)
- identifier = cable['EDIF.identifier'] + \
- "_" + str(cable_index) + "_"
- rename_name = cable.get('.NAME', identifier) + \
- "[" + str(cable_index) + "]"
+ identifier = cable["EDIF.identifier"] + "_" + str(cable_index) + "_"
+ rename_name = cable.get(".NAME", identifier) + "[" + str(cable_index) + "]"
name = "rename " + identifier + ' "' + rename_name + '"'
self._lisp_increment_()
self._output_.write(name)
@@ -499,7 +511,7 @@ def _output_port_ref_(self, port_ref, cable_name, pin):
def _get_edif_name_(self, netlistObj):
name = netlistObj["EDIF.identifier"]
- if not ("oldName" in netlistObj):
+ if not "oldName" in netlistObj:
return name
else:
oldName = netlistObj["oldName"]
@@ -521,17 +533,17 @@ def _output_property_(self, prop):
# TODO this only handles string properties for now
self._lisp_increment_()
self._output_.write("property ")
- if 'original_identifier' in prop:
+ if "original_identifier" in prop:
self._lisp_increment_()
self._output_.write("rename ")
- self._output_.write(prop['identifier'])
+ self._output_.write(prop["identifier"])
self._output_.write(' "')
- self._output_.write(prop['original_identifier'])
+ self._output_.write(prop["original_identifier"])
self._output_.write('"')
self._lisp_decrement_()
else:
- self._output_.write(prop['identifier'])
- value = prop['value']
+ self._output_.write(prop["identifier"])
+ value = prop["value"]
self._output_.write(" ")
self._lisp_increment_()
if isinstance(value, str):
@@ -539,12 +551,12 @@ def _output_property_(self, prop):
self._output_.write(value)
self._output_.write('"')
elif isinstance(value, bool):
- self._output_.write('boolean ')
+ self._output_.write("boolean ")
self._lisp_increment_()
self._output_.write(str(value))
self._lisp_decrement_()
else:
- self._output_.write('integer ')
+ self._output_.write("integer ")
self._output_.write(str(value))
self._lisp_decrement_()
self._lisp_decrement_()
diff --git a/spydrnet/composers/edif/edifify_names.py b/spydrnet/composers/edif/edifify_names.py
index 16094602..785fa04e 100644
--- a/spydrnet/composers/edif/edifify_names.py
+++ b/spydrnet/composers/edif/edifify_names.py
@@ -66,19 +66,23 @@ def __init__(self):
self.name_length_target = 256
def _length_good(self, identifier):
- """returns a boolean indicating whether or not the indentifier fits the 256 character limit"""
+ """returns a boolean indicating whether or not the indentifier fits the 256 character
+ limit"""
return len(identifier) < self.name_length_target
def _length_fix(self, identifier):
"""returns the name with the fixed length of 256 characters if the limit is exceeded"""
if not self._length_good(identifier):
- pattern = re.compile('_sdn_[0-9]+_$')
+ pattern = re.compile("_sdn_[0-9]+_$")
r = pattern.search(identifier)
if r is None:
- return identifier[:self.name_length_target]
+ return identifier[: self.name_length_target]
else:
- return identifier[:self.name_length_target - (r.end() - r.start())] + identifier[r.start():]
+ return (
+ identifier[: self.name_length_target - (r.end() - r.start())]
+ + identifier[r.start() :]
+ )
else:
return identifier
@@ -90,7 +94,7 @@ def _characters_good(self, identifier):
if not identifier[0].isalpha():
return False
for i in range(0, len(identifier)):
- if not identifier[i].isalnum() and identifier[i] != '-':
+ if not identifier[i].isalnum() and identifier[i] != "-":
return False
return True
@@ -103,12 +107,12 @@ def _characters_fix(self, identifier):
if not self._characters_good(identifier):
starting_index = 0
if not identifier[0].isalpha():
- identifier = '&' + identifier[:]
+ identifier = "&" + identifier[:]
starting_index = 1
for i in range(starting_index, len(identifier)):
if not identifier[i].isalnum():
- identifier = identifier[: i] + '_' + identifier[i+1:]
+ identifier = identifier[:i] + "_" + identifier[i + 1 :]
identifier = self._length_fix(identifier)
return identifier
@@ -116,26 +120,28 @@ def _conflicts_good(self, obj, identifier, objects):
for element in objects:
if element == obj:
continue
- if element.name == identifier or ("EDIF.identifier" in element.data and element["EDIF.identifier"] == identifier):
+ if element.name == identifier or (
+ "EDIF.identifier" in element.data
+ and element["EDIF.identifier"] == identifier
+ ):
return False
return True
def _conflicts_fix(self, obj, identifier, objects):
identifier_lower = identifier.lower()
if not self._conflicts_good(obj, identifier_lower, objects):
- pattern = re.compile('_sdn_[0-9]+_$')
+ pattern = re.compile("_sdn_[0-9]+_$")
r = pattern.search(identifier_lower)
if r is None:
- identifier_lower = identifier_lower + '_sdn_1_'
+ identifier_lower = identifier_lower + "_sdn_1_"
else:
# get the number out of the string
- num = int(
- re.search(r'\d+', identifier_lower[r.start():]).group())
- identifier_lower = identifier_lower[:r.start(
- )+5] + str(num + 1) + '_'
+ num = int(re.search(r"\d+", identifier_lower[r.start() :]).group())
+ identifier_lower = (
+ identifier_lower[: r.start() + 5] + str(num + 1) + "_"
+ )
identifier_lower = self._length_fix(identifier_lower)
- identifier_lower = self._conflicts_fix(
- obj, identifier_lower, objects)
+ identifier_lower = self._conflicts_fix(obj, identifier_lower, objects)
identifier = identifier_lower
return identifier
diff --git a/spydrnet/composers/verilog/composer.py b/spydrnet/composers/verilog/composer.py
index 69f48fe6..b9daf818 100644
--- a/spydrnet/composers/verilog/composer.py
+++ b/spydrnet/composers/verilog/composer.py
@@ -1,13 +1,15 @@
-from collections import deque, OrderedDict
+from collections import deque
from spydrnet.ir import Port
from spydrnet.ir import Cable
import spydrnet.parsers.verilog.verilog_tokens as vt
import spydrnet as sdn
-class Composer:
- def __init__(self, definition_list=None, write_blackbox=False, defparam = False, reverse=False):
- """ Write a verilog netlist from SDN netlist
+class Composer:
+ def __init__(
+ self, definition_list=None, write_blackbox=False, defparam=False, reverse=False, skip_constraints=False
+ ):
+ """Write a verilog netlist from SDN netlist
parameters
----------
@@ -15,10 +17,11 @@ def __init__(self, definition_list=None, write_blackbox=False, defparam = False,
definition_list - (list[str]) list of definitions to write
write_blackbox - (bool) Skips writing black boxes/verilog primitives
defparam - (bool) Compose parameters in *defparam* statements instead of using #()
+ skip_constraints - (bool) Skips writing constraints to the output verilog file
reverse - (bool) Compose the netlist bottom to top
"""
self.file = None
- self.direction_string_map = dict()
+ self.direction_string_map = {}
self.direction_string_map[Port.Direction.IN] = "input"
self.direction_string_map[Port.Direction.OUT] = "output"
self.direction_string_map[Port.Direction.INOUT] = "inout"
@@ -28,14 +31,15 @@ def __init__(self, definition_list=None, write_blackbox=False, defparam = False,
self.write_blackbox = write_blackbox
self.definition_list = definition_list
self.defparam = defparam
+ self.skip_constraints = skip_constraints
+
self.module_body_ports_written = []
self.reverse = reverse
-
def run(self, ir, file_out="out.v"):
self._open_file(file_out)
self._compose(ir)
-
+
def _open_file(self, file_name):
f = open(file_name, "w")
self.file = f
@@ -58,10 +62,10 @@ def _write_header(self, netlist):
self.file.write("//netlist name: " + self._fix_name(netlist.name) + "\n")
def _write_from_top(self, instance):
- #self.written = set()
+ # self.written = set()
to_write = deque()
to_write.append(instance.reference)
- while(len(to_write) != 0):
+ while len(to_write) != 0:
definition = to_write.popleft()
if definition in self.written:
continue
@@ -70,7 +74,8 @@ def _write_from_top(self, instance):
if c.reference not in self.written:
to_write.append(c.reference)
assert definition.name is not None, self._error_string(
- "definition has no name set", definition)
+ "definition has no name set", definition
+ )
self._write_module(definition)
def _write_from_bottom(self, instance):
@@ -80,7 +85,7 @@ def _write_from_bottom(self, instance):
to_write_stack = []
to_write_list.append(instance.reference)
to_write_stack.append(instance.reference)
- while(len(to_write_list) != 0):
+ while len(to_write_list) != 0:
definition = to_write_list.popleft()
if definition in visited:
continue
@@ -90,7 +95,7 @@ def _write_from_bottom(self, instance):
to_write_list.append(c.reference)
to_write_stack.append(c.reference)
# print(list(x.name for x in to_write_stack if len(x.children) > 0))
- while(to_write_stack):
+ while to_write_stack:
definition = to_write_stack.pop()
if definition not in self.written:
self.written.add(definition)
@@ -101,15 +106,17 @@ def _write_from_bottom(self, instance):
###########################################################################
def _write_preprocessor_directives(self, module):
- '''write out the backtick preprocessor directives.
+ """write out the backtick preprocessor directives.
this will likely just be `timescale 1 ps / 1 ps
UPDATE: I'm just going to skip this for now.
- It can be added if simulation support is needed later'''
+ It can be added if simulation support is needed later"""
pass # not currently implemented, just pass
def _write_star_constraints(self, o):
- if "VERILOG.InlineConstraints" in o and len(o["VERILOG.InlineConstraints"]) != 0:
+ if "VERILOG.InlineConstraints" in o and \
+ len(o["VERILOG.InlineConstraints"]) != 0 and \
+ self.skip_constraints is False:
dictionary = o["VERILOG.InlineConstraints"]
self.file.write(vt.OPEN_PARENTHESIS)
self.file.write(vt.STAR)
@@ -118,7 +125,7 @@ def _write_star_constraints(self, o):
for k, v in dictionary.items():
if v is not None:
self.file.write(first + k + vt.SPACE +
- vt.EQUAL + vt.SPACE + v)
+ vt.EQUAL + vt.SPACE + str(v))
else:
self.file.write(first + k)
first = vt.COMMA + vt.SPACE
@@ -128,15 +135,15 @@ def _write_star_constraints(self, o):
self.file.write(vt.NEW_LINE)
def _write_bundle_with_indicies(self, bundle, low, high):
- '''write out a bundle name and indicies. in name indicies order.
- useful for cable and port instances'''
+ """write out a bundle name and indicies. in name indicies order.
+ useful for cable and port instances"""
self._write_name(bundle)
self._write_brackets(bundle, low, high)
def _write_module(self, definition):
- '''write the constraints then the module header then the module body'''
+ """write the constraints then the module header then the module body"""
if self.definition_list:
- if not (definition.name in self.definition_list):
+ if not definition.name in self.definition_list:
return
if definition.library.name == "SDN_VERILOG_ASSIGNMENT":
return # don't write assignment definitions
@@ -156,10 +163,10 @@ def _write_module(self, definition):
self.file.write(2 * vt.NEW_LINE)
def _write_module_header(self, definition):
- '''write out the module header with the following style:
+ """write out the module header with the following style:
module module_name (port_name, port_name);
start with module and end with semi colon
- '''
+ """
self.file.write(vt.MODULE)
self.file.write(vt.SPACE)
self._write_name(definition)
@@ -170,7 +177,7 @@ def _write_module_header(self, definition):
self.file.write(vt.NEW_LINE)
def _write_module_body(self, definition):
- '''write out the module body start with ports, then do assignments then instances'''
+ """write out the module body start with ports, then do assignments then instances"""
self._write_module_body_ports(definition)
if definition.library.name != "hdi_primitives":
self._write_module_body_cables(definition)
@@ -213,7 +220,8 @@ def _write_module_body_ports(self, definition):
def _write_module_body_port(self, port):
_, cables = self._all_wires_and_cables_from_pinset(port.pins)
if len(cables) == 0:
- cables.append(port) #adding the port will let composer to still print out disconnected ports
+ # adding the port will let composer to still print out disconnected ports
+ cables.append(port)
for c in cables:
if c.name in self.module_body_ports_written:
continue
@@ -248,8 +256,8 @@ def _write_module_body_cable(self, cable):
self.file.write(vt.NEW_LINE)
def _write_concatenation(self, wires):
- '''write out the concatenation statement
- {wire_1, wire_2}'''
+ """write out the concatenation statement
+ {wire_1, wire_2}"""
self.file.write(vt.OPEN_BRACE)
first = True
previous_cable = Cable()
@@ -263,22 +271,26 @@ def _write_concatenation(self, wires):
if index == (previous_index - 1):
previous_index = index
else:
- #write the previous and save new stuff
+ # write the previous and save new stuff
if not first:
self.file.write(vt.COMMA)
self.file.write(vt.SPACE)
- self._write_bundle_with_indicies(previous_cable, previous_index, first_index)
+ self._write_bundle_with_indicies(
+ previous_cable, previous_index, first_index
+ )
first = False
previous_cable = w.cable
first_index = index
previous_index = index
else:
if has_to_write:
- #write the previous and save new stuff
+ # write the previous and save new stuff
if not first:
self.file.write(vt.COMMA)
self.file.write(vt.SPACE)
- self._write_bundle_with_indicies(previous_cable, previous_index, first_index)
+ self._write_bundle_with_indicies(
+ previous_cable, previous_index, first_index
+ )
first = False
previous_cable = w.cable
first_index = index
@@ -291,7 +303,9 @@ def _write_concatenation(self, wires):
if not first:
self.file.write(vt.COMMA)
self.file.write(vt.SPACE)
- self._write_bundle_with_indicies(previous_cable, previous_index, first_index)
+ self._write_bundle_with_indicies(
+ previous_cable, previous_index, first_index
+ )
self.file.write(vt.CLOSE_BRACE)
@@ -308,15 +322,15 @@ def _write_module_header_ports(self, definition):
self.file.write(vt.CLOSE_PARENTHESIS)
self.file.write(vt.SEMI_COLON)
self.file.write(vt.NEW_LINE)
-
+
def pin_sort_func(self, p):
if isinstance(p, sdn.OuterPin):
return p.inner_pin.port.pins.index(p.inner_pin)
return p.port.pins.index(p)
def _write_module_header_port(self, port):
- '''does not write the input output or width,
- check for concatenation port as well'''
+ """does not write the input output or width,
+ check for concatenation port as well"""
self.file.write((self.indent_count * vt.SPACE))
aliased = self._is_pinset_concatenated(port.pins, port.name)
if aliased:
@@ -339,8 +353,8 @@ def _write_assignments(self, definition):
self._write_assignment(c)
def _write_assignment(self, instance):
- '''take an assignment instance and write an assignment out
- assign cable_out = cable_in;'''
+ """take an assignment instance and write an assignment out
+ assign cable_out = cable_in;"""
in_port = None
out_port = None
for p in instance.reference.ports:
@@ -349,9 +363,13 @@ def _write_assignment(self, instance):
if p.name == "i":
in_port = p
assert in_port is not None, self._error_string(
- "instance does not appear to be an assignment with a port named i and o", instance)
+ "instance does not appear to be an assignment with a port named i and o",
+ instance,
+ )
assert out_port is not None, self._error_string(
- "instance does not appear to be an assignment with a port named i and o", instance)
+ "instance does not appear to be an assignment with a port named i and o",
+ instance,
+ )
left_wires = []
right_wires = []
in_pins = []
@@ -362,10 +380,18 @@ def _write_assignment(self, instance):
out_pins.append(instance.pins[p])
in_wires, in_cables = self._all_wires_and_cables_from_pinset(in_pins)
out_wires, out_cables = self._all_wires_and_cables_from_pinset(out_pins)
- assert not self._is_pinset_concatenated(in_pins, in_wires[0].cable.name), self._error_string(
- "multiple cables appear to be connected to a single assignment input", instance)
- assert not self._is_pinset_concatenated(out_pins, out_wires[0].cable.name), self._error_string(
- "multiple cables appear to be connected to a single assignment output", instance)
+ assert not self._is_pinset_concatenated(
+ in_pins, in_wires[0].cable.name
+ ), self._error_string(
+ "multiple cables appear to be connected to a single assignment input",
+ instance,
+ )
+ assert not self._is_pinset_concatenated(
+ out_pins, out_wires[0].cable.name
+ ), self._error_string(
+ "multiple cables appear to be connected to a single assignment output",
+ instance,
+ )
self.file.write(vt.ASSIGN)
self.file.write(vt.SPACE)
hi = self._index_of_wire_in_cable(out_wires[-1])
@@ -381,7 +407,7 @@ def _write_assignment(self, instance):
self.file.write(vt.NEW_LINE)
def _write_module_parameters(self, definition):
- '''write out the parameters in the module header'''
+ """write out the parameters in the module header"""
self.file.write(vt.OCTOTHORP)
self.file.write(vt.OPEN_PARENTHESIS)
indentation = "\n "
@@ -401,11 +427,11 @@ def _write_module_parameters(self, definition):
self.file.write(vt.CLOSE_PARENTHESIS)
def _write_instance_parameters(self, instance):
- '''write out the parameters in the instance
+ """write out the parameters in the instance
#(
.key(value),
...
- )'''
+ )"""
self.file.write(vt.OCTOTHORP)
self.file.write(vt.OPEN_PARENTHESIS)
self.file.write(vt.NEW_LINE)
@@ -422,7 +448,7 @@ def _write_instance_parameters(self, instance):
self.file.write(vt.NEW_LINE)
def _write_instance_parameter(self, key, value):
- self.file.write(2*self.indent_count * vt.SPACE)
+ self.file.write(2 * self.indent_count * vt.SPACE)
self.file.write(vt.DOT)
self.file.write(key)
self.file.write(vt.OPEN_PARENTHESIS)
@@ -430,7 +456,7 @@ def _write_instance_parameter(self, key, value):
self.file.write(vt.CLOSE_PARENTHESIS)
def _write_instance_ports(self, instance):
- '''write out the port mapping on an instance.'''
+ """write out the port mapping on an instance."""
self.file.write(self.indent_count * vt.SPACE)
self.file.write(vt.OPEN_PARENTHESIS)
self.file.write(vt.NEW_LINE)
@@ -450,8 +476,11 @@ def _write_instance_ports(self, instance):
self.file.write(vt.SEMI_COLON)
def _write_implicitly_mapped_instance_port(self, instance, port):
- '''Ports that have no name must be implicitly mapped. E.g. inst(VCC_net) rather than inst(.p(VCC_net))'''
- self.file.write(2*self.indent_count * vt.SPACE)
+ """
+ Ports that have no name must be implicitly mapped. E.g. inst(VCC_net) rather than
+ inst(.p(VCC_net))
+ """
+ self.file.write(2 * self.indent_count * vt.SPACE)
# self.file.write(vt.DOT)
# self._write_name(port)
# self.file.write(vt.OPEN_PARENTHESIS)
@@ -485,7 +514,7 @@ def _write_implicitly_mapped_instance_port(self, instance, port):
# self.file.write(vt.CLOSE_PARENTHESIS)
def _write_instance_port(self, instance, port):
- self.file.write(2*self.indent_count * vt.SPACE)
+ self.file.write(2 * self.indent_count * vt.SPACE)
self.file.write(vt.DOT)
self._write_name(port)
self.file.write(vt.OPEN_PARENTHESIS)
@@ -522,22 +551,22 @@ def _write_instance_port(self, instance, port):
self.file.write(vt.CLOSE_PARENTHESIS)
def _write_name(self, o):
- '''write the name of an o. this is split out to give an error message if the name is not set
- In the future this could be changed to add a name to os that do not have a name set'''
+ """write the name of an o. this is split out to give an error message if the name is not set
+ In the future this could be changed to add a name to os that do not have a name set
+ """
name = o.name
assert name is not None, self._error_string("name of o is not set", o)
name = self._fix_name(name)
self.file.write(name)
-
+
def _fix_name(self, name):
- if name[0] == '\\':
+ if name[0] == "\\":
if name[-1] != " ":
- name+=" "
+ name += " "
return name
-
def _write_brackets_defining(self, bundle):
- '''write the brackets for port or cable definitions'''
+ """write the brackets for port or cable definitions"""
if isinstance(bundle, Cable):
array = bundle.wires
elif isinstance(bundle, Port):
@@ -545,7 +574,10 @@ def _write_brackets_defining(self, bundle):
width = len(array)
assert width != 0, self._error_string(
- "bundle has 0 width, this will not write correctly please add a pin to the port or wire to the cable.", bundle)
+ "bundle has 0 width, this will not write correctly please add a \
+ pin to the port or wire to the cable.",
+ bundle,
+ )
if width == 1 and bundle.lower_index == 0:
return # no need to write because this is assumed
@@ -557,9 +589,9 @@ def _write_brackets_defining(self, bundle):
self.file.write(vt.CLOSE_BRACKET)
def _write_brackets(self, bundle, low_index, high_index):
- '''write a bundle's brackets based on the low and high indicies given
- does not write out the name, works on both cables and ports'''
- if low_index == None and high_index == None:
+ """write a bundle's brackets based on the low and high indicies given
+ does not write out the name, works on both cables and ports"""
+ if low_index is None and high_index is None:
return # nothing to write.
if isinstance(bundle, Cable):
@@ -567,48 +599,68 @@ def _write_brackets(self, bundle, low_index, high_index):
elif isinstance(bundle, Port):
array = bundle.pins
width = len(array)
- assert width != 0, self._error_string(
- "cannot index into 0 width cable")
+ assert width != 0, self._error_string("cannot index into 0 width cable")
lower_bundle = bundle.lower_index
upper_bundle = lower_bundle + width - 1
- #intended logic
- #the bundle is a single bit: assert indicies are within but nothing to be written
- #the bundle is multibit and the indicies match the upper and lower(or none): nothing to be written
- #the bundle is multibit but the indicies match each other or one is none: write a single index
- #the bundle is multibit but the indicies don't match each other: write both indicies
-
+ # intended logic
+ # the bundle is a single bit: assert indicies are within but nothing to be written
+ # the bundle is multibit and the indicies match the upper and
+ # lower(or none): nothing to be written
+ # the bundle is multibit but the indicies match each other or
+ # one is none: write a single index
+ # the bundle is multibit but the indicies don't match each other: write both indicies
+
if width == 1:
- assert (low_index == None or low_index == lower_bundle), \
- self._error_string("attempted to index bundle out of bounds at " + str(low_index), bundle)
- assert (high_index == None or high_index == upper_bundle), \
- self._error_string("attempted to index bundle out of bounds at " + str(high_index), bundle)
+ assert low_index is None or low_index == lower_bundle, self._error_string(
+ "attempted to index bundle out of bounds at " + str(low_index), bundle
+ )
+ assert high_index is None or high_index == upper_bundle, self._error_string(
+ "attempted to index bundle out of bounds at " + str(high_index), bundle
+ )
return
- elif (low_index == lower_bundle and high_index == upper_bundle) or (low_index == None and high_index == None):
+ elif (low_index == lower_bundle and high_index == upper_bundle) or (
+ low_index is None and high_index is None
+ ):
self.file.write("[" + str(high_index) + ":" + str(low_index) + "]")
return
elif low_index == high_index or low_index is None or high_index is None:
index = low_index
if index is None:
index = high_index
- #this assertion checks the logic of this if statement
- assert index is not None, self._error_string("if both high and low indicies are None no brackets need to be written", bundle)
- #the following assertion will check the inputs to the function
- assert index >= lower_bundle and index <= upper_bundle,\
- self._error_string("attempted to write an index out of bounds: " + str(index), bundle)
+ # this assertion checks the logic of this if statement
+ assert index is not None, self._error_string(
+ "if both high and low indicies are None no brackets need to be written",
+ bundle,
+ )
+ # the following assertion will check the inputs to the function
+ assert index >= lower_bundle and index <= upper_bundle, self._error_string(
+ "attempted to write an index out of bounds: " + str(index), bundle
+ )
self.file.write("[" + str(index) + "]")
else:
- #first assertion is an internal error, check the if elif logic here.
- assert low_index != high_index and low_index is not None and high_index is not None,\
- self._error_string("a single value needs to be written if any of these conditions are true ", bundle)
- #these assertions highlight issues with the input to the function
- assert low_index >= lower_bundle and low_index <= upper_bundle,\
- self._error_string("attempted to write an index out of bounds: " + str(low_index), bundle)
- assert high_index >= lower_bundle and high_index <= upper_bundle,\
- self._error_string("attempted to write an index out of bounds: " + str(high_index), bundle)
+ # first assertion is an internal error, check the if elif logic here.
+ assert (
+ low_index != high_index
+ and low_index is not None
+ and high_index is not None
+ ), self._error_string(
+ "a single value needs to be written if any of these conditions are true ",
+ bundle,
+ )
+ # these assertions highlight issues with the input to the function
+ assert (
+ low_index >= lower_bundle and low_index <= upper_bundle
+ ), self._error_string(
+ "attempted to write an index out of bounds: " + str(low_index), bundle
+ )
+ assert (
+ high_index >= lower_bundle and high_index <= upper_bundle
+ ), self._error_string(
+ "attempted to write an index out of bounds: " + str(high_index), bundle
+ )
self.file.write("[" + str(high_index) + ":" + str(low_index) + "]")
-
###############################################################################
# helper functions for composing
###############################################################################
@@ -631,10 +683,10 @@ def _is_pinset_concatenated(self, pins, name):
now_none = True
else:
next_name = p.wire.cable.name
- if now_none == True:
+ if now_none is True:
aliased = True
index = self._index_of_wire_in_cable(p.wire)
- if last_index == None:
+ if last_index is None:
last_index = index
else:
if index != last_index + 1:
@@ -645,8 +697,8 @@ def _is_pinset_concatenated(self, pins, name):
aliased = True
break
- # if all the wires connected to the pins are from the same cable, don't count as aliased
- # otherwise, return previous answer
+ # if all the wires connected to the pins are from the same cable,
+ # don't count as aliased. Otherwise, return previous answer
# TODO maybe also check if all of the cable is used. So no skipped wires.
# name = None
# for p in pins:
diff --git a/spydrnet/composers/verilog/tests/test_composer.py b/spydrnet/composers/verilog/tests/test_composer.py
deleted file mode 100644
index 1d693899..00000000
--- a/spydrnet/composers/verilog/tests/test_composer.py
+++ /dev/null
@@ -1,115 +0,0 @@
-import unittest
-import spydrnet as sdn
-from spydrnet import composers
-from spydrnet import parsers
-import os
-import tempfile
-import glob
-from pathlib import Path
-
-class TestVerilogComposer(unittest.TestCase):
-
- @classmethod
- def setUpClass(cls) -> None:
- cls.dir_of_verilog_netlists = Path(sdn.base_dir, "support_files", "verilog_netlists")
- cls.verilog_files = sorted(glob.glob(os.path.join(cls.dir_of_verilog_netlists, "*.v.zip")), key = os.path.getsize)
-
- @unittest.skip("Test takes a long time right now.")
- def test_large_verilog_compose(self):
- i = 0
- errors = 0
- for ii, filename in enumerate(self.verilog_files):
- with self.subTest(i=ii):
- if Path(filename).stat().st_size <= 1024 * 10:
- continue
- if filename.endswith(".zip"):
- with tempfile.TemporaryDirectory() as tempdirectory:
- # try:
- print("*********************"+filename+"*********************")
- # vp = sdn.parsers.verilog.parser.VerilogParser.from_filename(os.path.join(directory, filename))
- # netlist = vp.parse()
- netlist = parsers.parse(filename)
- composers.compose(netlist, Path(tempdirectory, Path(filename).name + "-spydrnet.v"))
- #comp.run(netlist,"temp2/"+filename[:len(filename)-6] + "-spydrnet.v")
- # comp.run(netlist,os.path.join(tempdirectory, filename[:len(filename)-6] + "-spydrnet.v"))
- i+=1
- print("pass")
- # except Exception as identifier:
- # print("FAIL")
- # print(identifier)
- # errors += 1
- else:
- continue
-
- print("processed",i,"errors", errors)
-
- assert errors == 0, "there were errors while parsing and composing files. Please see the output."
-
- def test_small_verilog_compose(self):
- i = 0
- errors = 0
- for ii, filename in enumerate(self.verilog_files):
- with self.subTest(i=ii):
- if Path(filename).stat().st_size > 1024 * 10:
- continue
- if filename.endswith(".zip"):
- with tempfile.TemporaryDirectory() as tempdirectory:
- # try:
- print("*********************"+filename+"*********************")
- # vp = sdn.parsers.verilog.parser.VerilogParser.from_filename(os.path.join(directory, filename))
- # netlist = vp.parse()
- netlist = parsers.parse(filename)
- composers.compose(netlist, Path(tempdirectory, Path(filename).name + "-spydrnet.v"))
- #comp.run(netlist,"temp2/"+filename[:len(filename)-6] + "-spydrnet.v")
- # comp.run(netlist,os.path.join(tempdirectory, filename[:len(filename)-6] + "-spydrnet.v"))
- i+=1
- print("pass")
- # except Exception as identifier:
- # print("FAIL")
- # print(identifier)
- # errors += 1
- else:
- continue
-
- print("processed",i,"errors", errors)
-
- assert errors == 0, "there were errors while parsing and composing files. Please see the output."
-
- def test_definition_list_option(self):
- for filename in glob.glob(os.path.join(
- self.dir_of_verilog_netlists, "*4bitadder.v.zip")):
- with tempfile.TemporaryDirectory() as tempdirectory:
- netlist = parsers.parse(filename)
- out_file = Path(
- tempdirectory, Path(filename).name + "-spydrnet.v")
- composers.compose(netlist, out_file, definition_list=['adder'])
-
- with open(out_file, "r") as fp:
- lines = fp.readlines()
- print(len(lines))
- m = list(filter(lambda x: x.startswith('module'), lines))
- self.assertGreater(len(m), 0, "Adder module not written")
- self.assertLess(len(m), 2, "Failed to write only definition_list")
- return
- raise AssertionError("Adder design not found " +
- "definition_list options not tested,")
-
- def test_write_blackbox_option(self):
- for filename in glob.glob(os.path.join(
- self.dir_of_verilog_netlists, "*4bitadder.v.zip")):
- with tempfile.TemporaryDirectory() as tempdirectory:
- netlist = parsers.parse(filename)
- out_file = Path(
- tempdirectory, Path(filename).name + "-spydrnet.v")
- composers.compose(netlist, out_file, write_blackbox=False)
-
- with open(out_file, "r") as fp:
- lines = fp.readlines()
- print(len(lines))
- m = list(filter(lambda x: x.startswith('module'), lines))
- self.assertGreater(len(m), 0, "Adder module not written")
- self.assertLess(len(m), 2, "Failed to write only definition_list" +
- "%s" % m)
- return
- raise AssertionError("definition_list options not test," +
- "Adder design not found")
diff --git a/spydrnet/flatten.py b/spydrnet/flatten.py
index 0afff408..9d286390 100644
--- a/spydrnet/flatten.py
+++ b/spydrnet/flatten.py
@@ -1,8 +1,7 @@
# Copyright 2020 Dallin Skouson, Andrew Keller, Michael Wirthlin
-from spydrnet.ir import *
from collections import deque
-from spydrnet.uniquify import uniquify
+from spydrnet.ir import *
"""How to flatten (brainstorm):
start at the top and take all of the subelements out and add them to the top definition
@@ -74,7 +73,7 @@ def _bring_to_top(e, add_to_name, top_definition):
d = e.parent
d.remove_child(e)
# _rename_element(c)
- if(add_to_name != ''):
+ if add_to_name != "":
e.name = add_to_name + "/" + e.name
else:
e.name = e.name
@@ -101,6 +100,7 @@ def _bring_to_top(e, add_to_name, top_definition):
# recurse(top_instance, 0)
+
def flatten(netlist):
"""
starts at the top instance and brings all the different subelements to the top level.
@@ -115,7 +115,7 @@ def flatten(netlist):
# put all of tops children on a stack
for chld in top_definition.children:
instance_queue.append(chld)
- name_queue.append('')
+ name_queue.append("")
to_remove = []
# for each of the children on the stack
diff --git a/spydrnet/global_state/global_callback.py b/spydrnet/global_state/global_callback.py
index fdf61145..1d7b1641 100644
--- a/spydrnet/global_state/global_callback.py
+++ b/spydrnet/global_state/global_callback.py
@@ -1,30 +1,30 @@
-_container_create_netlist = list()
-_container_create_library = list()
-_container_create_definition = list()
-_container_create_port = list()
-_container_create_cable = list()
-_container_create_instance = list()
-_container_cable_add_wire = list()
-_container_cable_remove_wire = list()
-_container_definition_add_port = list()
-_container_definition_remove_port = list()
-_container_definition_add_child = list()
-_container_definition_remove_child = list()
-_container_definition_add_cable = list()
-_container_definition_remove_cable = list()
-_container_instance_reference = list()
-_container_library_add_definition = list()
-_container_library_remove_definition = list()
-_container_netlist_top_instance = list()
-_container_netlist_add_library = list()
-_container_netlist_remove_library = list()
-_container_port_add_pin = list()
-_container_port_remove_pin = list()
-_container_wire_connect_pin = list()
-_container_wire_disconnect_pin = list()
-_container_dictionary_set = list()
-_container_dictionary_delete = list()
-_container_dictionary_pop = list()
+_container_create_netlist = []
+_container_create_library = []
+_container_create_definition = []
+_container_create_port = []
+_container_create_cable = []
+_container_create_instance = []
+_container_cable_add_wire = []
+_container_cable_remove_wire = []
+_container_definition_add_port = []
+_container_definition_remove_port = []
+_container_definition_add_child = []
+_container_definition_remove_child = []
+_container_definition_add_cable = []
+_container_definition_remove_cable = []
+_container_instance_reference = []
+_container_library_add_definition = []
+_container_library_remove_definition = []
+_container_netlist_top_instance = []
+_container_netlist_add_library = []
+_container_netlist_remove_library = []
+_container_port_add_pin = []
+_container_port_remove_pin = []
+_container_wire_connect_pin = []
+_container_wire_disconnect_pin = []
+_container_dictionary_set = []
+_container_dictionary_delete = []
+_container_dictionary_pop = []
def _call_create_netlist(*args, **kwargs):
@@ -271,7 +271,8 @@ def register_dictionary_pop(*args, **kwargs):
def _register(container_to_register, method):
- # TODO: look into inlining this function perhaps, not not be necessary since is won't be called often.
+ # TODO: look into inlining this function perhaps, may not be necessary since it won't be called
+ # often.
assert method not in container_to_register
container_to_register.append(method)
@@ -385,6 +386,7 @@ def deregister_dictionary_pop(*args, **kwargs):
def _deregister(container_to_deregister, method):
- # TODO: look into inlining this function perhaps, may not be necessary since it won't be called often.
+ # TODO: look into inlining this function perhaps, may not be necessary since it won't be called
+ # often.
assert method in container_to_deregister
container_to_deregister.remove(method)
diff --git a/spydrnet/global_state/global_service.py b/spydrnet/global_state/global_service.py
index a27e83ca..a4c04d4b 100644
--- a/spydrnet/global_state/global_service.py
+++ b/spydrnet/global_state/global_service.py
@@ -1,13 +1,14 @@
from spydrnet.ir import Netlist, Library, Definition, Port, Cable, Instance
-_registered_lookups = dict()
+_registered_lookups = {}
_registered_hierarchical_lookup = None
def register_lookup(key, func):
if key in _registered_lookups:
raise ValueError(
- "Cannot register a fast lookup under the key {}, lookup already registered.")
+ "Cannot register a fast lookup under the key {}, lookup already registered."
+ )
else:
_registered_lookups[key] = func
diff --git a/spydrnet/global_state/tests/test_global_callback.py b/spydrnet/global_state/tests/test_global_callback.py
deleted file mode 100644
index 933d8dc5..00000000
--- a/spydrnet/global_state/tests/test_global_callback.py
+++ /dev/null
@@ -1,126 +0,0 @@
-import unittest
-
-import spydrnet.global_state.global_callback as gc
-from spydrnet.plugins import namespace_manager
-
-
-class TestGlobalCallback(unittest.TestCase):
- @classmethod
- def setUpClass(cls) -> None:
- namespace_manager.deregister_all_listeners()
-
- @classmethod
- def tearDownClass(cls) -> None:
- namespace_manager.register_all_listeners()
-
- def setUp(self) -> None:
- self.arg1 = 1
- self.arg2 = 2
- self.kwarg = 3
- self.callcount = 0
- self.callcount2 = 0
-
- def mycall(self, a1, a2, ka = 0):
- self.callcount += 1
- assert(a1 is self.arg1)
- assert(a2 is self.arg2)
- assert(ka is self.kwarg)
-
- def mycall2(self, a1, a2, ka = 0):
- self.callcount2 += 1
- assert(a1 is self.arg1)
- assert(a2 is self.arg2)
- assert(ka is self.kwarg)
-
- def test_cable_add_wire(self):
- self.call_for_each(gc._container_cable_add_wire, gc.register_cable_add_wire, gc._call_cable_add_wire, gc.deregister_cable_add_wire)
-
- def test_cable_remove_wire(self):
- self.call_for_each(gc._container_cable_remove_wire, gc.register_cable_remove_wire, gc._call_cable_remove_wire, gc.deregister_cable_remove_wire)
-
- def test_definition_add_port(self):
- self.call_for_each(gc._container_definition_add_port, gc.register_definition_add_port, gc._call_definition_add_port, gc.deregister_definition_add_port)
-
- def test_definition_remove_port(self):
- self.call_for_each(gc._container_definition_remove_port, gc.register_definition_remove_port, gc._call_definition_remove_port, gc.deregister_definition_remove_port)
-
- def test_definition_add_child(self):
- self.call_for_each(gc._container_definition_add_child, gc.register_definition_add_child, gc._call_definition_add_child, gc.deregister_definition_add_child)
-
- def test_definition_remove_child(self):
- self.call_for_each(gc._container_definition_remove_child, gc.register_definition_remove_child, gc._call_definition_remove_child, gc.deregister_definition_remove_child)
-
- def test_definition_add_cable(self):
- self.call_for_each(gc._container_definition_add_cable, gc.register_definition_add_cable, gc._call_definition_add_cable, gc.deregister_definition_add_cable)
-
- def test_definition_remove_cable(self):
- self.call_for_each(gc._container_definition_remove_cable, gc.register_definition_remove_cable, gc._call_definition_remove_cable, gc.deregister_definition_remove_cable)
-
- def test_instance_reference(self):
- self.call_for_each(gc._container_instance_reference, gc.register_instance_reference, gc._call_instance_reference, gc.deregister_instance_reference)
-
- def test_library_add_definition(self):
- self.call_for_each(gc._container_library_add_definition, gc.register_library_add_definition, gc._call_library_add_definition, gc.deregister_library_add_definition)
-
- def test_library_remove_definition(self):
- self.call_for_each(gc._container_library_remove_definition, gc.register_library_remove_definition, gc._call_library_remove_definition, gc.deregister_library_remove_definition)
-
- def test_netlist_top_instance(self):
- self.call_for_each(gc._container_netlist_top_instance, gc.register_netlist_top_instance, gc._call_netlist_top_instance, gc.deregister_netlist_top_instance)
-
- def test_netlist_add_library(self):
- self.call_for_each(gc._container_netlist_add_library, gc.register_netlist_add_library, gc._call_netlist_add_library, gc.deregister_netlist_add_library)
-
- def test_netlist_remove_library(self):
- self.call_for_each(gc._container_netlist_remove_library, gc.register_netlist_remove_library, gc._call_netlist_remove_library, gc.deregister_netlist_remove_library)
-
- def test_port_add_pin(self):
- self.call_for_each(gc._container_port_add_pin, gc.register_port_add_pin, gc._call_port_add_pin, gc.deregister_port_add_pin)
-
- def test_port_remove_pin(self):
- self.call_for_each(gc._container_port_remove_pin, gc.register_port_remove_pin, gc._call_port_remove_pin, gc.deregister_port_remove_pin)
-
- def test_wire_connect_pin(self):
- self.call_for_each(gc._container_wire_connect_pin, gc.register_wire_connect_pin, gc._call_wire_connect_pin, gc.deregister_wire_connect_pin)
-
- def test_wire_disconnect_pin(self):
- self.call_for_each(gc._container_wire_disconnect_pin, gc.register_wire_disconnect_pin, gc._call_wire_disconnect_pin, gc.deregister_wire_disconnect_pin)
-
- def test_dictionary_delete(self):
- self.call_for_each(gc._container_dictionary_delete, gc.register_dictionary_delete, gc._call_dictionary_delete, gc.deregister_dictionary_delete)
-
- def test_dictionary_pop(self):
- self.call_for_each(gc._container_dictionary_pop, gc.register_dictionary_pop, gc._call_dictionary_pop, gc.deregister_dictionary_pop)
-
- def test_dictionary_add(self):
- self.call_for_each(gc._container_dictionary_set, gc.register_dictionary_set, gc._call_dictionary_set, gc.deregister_dictionary_set)
-
- def call_for_each(self, container, register, call, deregister):
- '''
- general strategy:
- check to make sure the _container is empty
- register a function
- check to make sure the function is registered
- call the function with some parameters
- check to make sure the function was called with the parameters
- deregister the function
- check to make sure the function was deregistered
- call the function
- check to make sure the funciton was not called
- '''
- assert self.mycall not in container
- assert self.mycall2 not in container
- register(self.mycall)
- assert self.mycall in container
- register(self.mycall2)
- assert self.mycall2 in container
- call(self.arg1, self.arg2, ka=self.kwarg)
- assert self.callcount == 1 and self.callcount2 == 1
- deregister(self.mycall)
- assert self.mycall not in container
- call(self.arg1, self.arg2, ka=self.kwarg)
- assert self.callcount2 == 2 and self.callcount == 1
- deregister(self.mycall2)
- assert self.mycall2 not in container
- call(self.arg1, self.arg2, ka=self.kwarg)
- assert self.callcount == 1 and self.callcount2 == 2
\ No newline at end of file
diff --git a/spydrnet/ir/__init__.py b/spydrnet/ir/__init__.py
index 21a3e56d..ad8e19fb 100644
--- a/spydrnet/ir/__init__.py
+++ b/spydrnet/ir/__init__.py
@@ -1,7 +1,6 @@
-
-from spydrnet import get_active_plugins
import importlib
import typing
+from spydrnet import get_active_plugins
if typing.TYPE_CHECKING:
from spydrnet.ir.element import Element
@@ -18,30 +17,32 @@
from spydrnet.ir.library import Library
from spydrnet.ir.netlist import Netlist
-RegisterModule = [('element', 'Element'),
- ('first_class_element', 'FirstClassElement'),
- ('bundle', 'Bundle'),
- ('pin', 'Pin'),
- ('innerpin', 'InnerPin'),
- ('outerpin', 'OuterPin'),
- ('port', 'Port'),
- ('wire', 'Wire'),
- ('cable', 'Cable'),
- ('instance', 'Instance'),
- ('definition', 'Definition'),
- ('library', 'Library'),
- ('netlist', 'Netlist')]
+RegisterModule = [
+ ("element", "Element"),
+ ("first_class_element", "FirstClassElement"),
+ ("bundle", "Bundle"),
+ ("pin", "Pin"),
+ ("innerpin", "InnerPin"),
+ ("outerpin", "OuterPin"),
+ ("port", "Port"),
+ ("wire", "Wire"),
+ ("cable", "Cable"),
+ ("instance", "Instance"),
+ ("definition", "Definition"),
+ ("library", "Library"),
+ ("netlist", "Netlist"),
+]
# Following section will extend all the classes imported in this file
for filename, eachModule in RegisterModule:
- cls = getattr(importlib.import_module(
- "spydrnet.ir."+filename), eachModule)
+ cls = getattr(importlib.import_module("spydrnet.ir." + filename), eachModule)
locals()[eachModule] = type(cls.__name__, (cls,), {})
for name, plugin in get_active_plugins().items():
try:
- ext_cls = getattr(importlib.import_module(
- "%s.ir.%s" % (name, filename)), eachModule)
+ ext_cls = getattr(
+ importlib.import_module("%s.ir.%s" % (name, filename)), eachModule
+ )
cls_bases = (ext_cls, cls)
locals()[eachModule] = type(cls.__name__, cls_bases, {})
cls = locals()[eachModule]
diff --git a/spydrnet/ir/bundle.py b/spydrnet/ir/bundle.py
index d260bda5..871c2bd9 100644
--- a/spydrnet/ir/bundle.py
+++ b/spydrnet/ir/bundle.py
@@ -7,7 +7,8 @@ class Bundle(FirstClassElement):
Since both of these objects represent arrays of objects they both inherit from
this parent class.
"""
- __slots__ = ['_definition', '_is_downto', '_is_scalar', '_lower_index']
+
+ __slots__ = ["_definition", "_is_downto", "_is_scalar", "_lower_index"]
def __init__(self):
super().__init__()
@@ -48,7 +49,8 @@ def is_downto(self, value):
def _items(self):
"""
- this function must be overridden in classes which extend this to return either a list of pins or wires
+ this function must be overridden in classes which extend this to return either a list of
+ pins or wires
"""
raise NotImplementedError
@@ -70,22 +72,21 @@ def is_scalar(self):
def is_scalar(self, value):
"""Set the scalar status of single item bundles.
- The item is not a scalar if it has more than one pin or wire in it. if it has one or zero pins this function
- can be used to set the value or wire in it it may be a scalar. This mimics vhdl's downto usage which can
- represent single pin arrays ie. std_logic_vector(0 downto 0) which would have a single pin but not be a scalar.
+ The item is not a scalar if it has more than one pin or wire in it. if it has one or zero
+ pins this function can be used to set the value or wire in it it may be a scalar. This
+ mimics vhdl's downto usage which can represent single pin arrays ie. std_logic_vector(0
+ downto 0) which would have a single pin but not be a scalar.
parameters
----------
- value - (boolean) True if the item is to be a scalar False if it is not. Multi element bundles cannot set
- is_scalar to True.
+ value - (boolean) True if the item is to be a scalar False if it is not. Multi
+ elementbundles cannot set is_scalar to True.
"""
_items = self._items()
if _items and len(_items) > 1 and value is True:
- raise RuntimeError(
- "Cannot set is_scalar to True on a multi-item bundle")
- else:
- self._is_scalar = value
+ raise RuntimeError("Cannot set is_scalar to True on a multi-item bundle")
+ self._is_scalar = value
@property
def is_array(self):
@@ -104,15 +105,13 @@ def is_array(self, value):
parameters
----------
- value - (boolean) True if the object is an array. False otherwise. Multi element bundles cannot set is_array to
- false.
+ value - (boolean) True if the object is an array. False otherwise. Multi element bundles
+ cannot set is_array to false.
"""
_items = self._items()
if _items and len(_items) > 1 and value is False:
- raise RuntimeError(
- "Cannot set is_array to False on a multi-item bundle")
- else:
- self._is_scalar = not value
+ raise RuntimeError("Cannot set is_array to False on a multi-item bundle")
+ self._is_scalar = not value
@property
def lower_index(self):
diff --git a/spydrnet/ir/cable.py b/spydrnet/ir/cable.py
index 715b422a..a61934cc 100644
--- a/spydrnet/ir/cable.py
+++ b/spydrnet/ir/cable.py
@@ -1,19 +1,29 @@
+from copy import deepcopy
from spydrnet.ir import Bundle
from spydrnet.ir import Wire
from spydrnet.ir.views.listview import ListView
from spydrnet.global_state import global_callback
from spydrnet.global_state.global_callback import _call_create_cable
-from copy import deepcopy, copy, error
class Cable(Bundle):
"""Representation of several wires in a collection.
- Much like ports, cables extend the bundle class, giving them indexing ability. They represent several wires in a collection or bus that are generally related.
- This could be thought of much like vector types in VHDL ie std_logic_vector (7 downto 0)"""
- __slots__ = ['_wires']
-
- def __init__(self, name=None, properties=None, is_downto=None, is_scalar=None, lower_index=None):
+ Much like ports, cables extend the bundle class, giving them indexing ability. They represent
+ several wires in a collection or bus that are generally related. This could be thought of much
+ like vector types in VHDL ie std_logic_vector (7 downto 0)
+ """
+
+ __slots__ = ["_wires"]
+
+ def __init__(
+ self,
+ name=None,
+ properties=None,
+ is_downto=None,
+ is_scalar=None,
+ lower_index=None,
+ ):
"""Create a cable with no wires and default values for a bundle.
parameters
@@ -21,15 +31,17 @@ def __init__(self, name=None, properties=None, is_downto=None, is_scalar=None, l
name - (str) the name of this instance
properties - (dict) the dictionary which holds the properties
- id_downto - (bool) set the downto status. Downto is False if the right index is higher than the left one, True otherwise
- is_scalar - (bool) set the scalar status. Return True if the item is a scalar False otherwise.
+ id_downto - (bool) set the downto status. Downto is False if the right index is higher than
+ the left one, True otherwise
+ is_scalar - (bool) set the scalar status. Return True if the item is a scalar False
+ otherwise.
lower_index - (int) get the value of the lower index of the array.
"""
super().__init__()
- self._wires = list()
+ self._wires = []
_call_create_cable(self)
- if name != None:
+ if name is not None:
self.name = name
if is_downto is not None:
@@ -41,9 +53,8 @@ def __init__(self, name=None, properties=None, is_downto=None, is_scalar=None, l
if lower_index is not None:
self.lower_index = lower_index
- if properties != None:
- assert isinstance(
- properties, dict), "properties must be a dictionary"
+ if properties is not None:
+ assert isinstance(properties, dict), "properties must be a dictionary"
for key in properties:
self[key] = properties[key]
@@ -65,8 +76,10 @@ def wires(self, value):
value_list = list(value)
value_set = set(value_list)
# try:
- assert len(value_list) == len(value_set) and set(self._wires) == value_set, \
- "Set of values does not match, assigment can only be used for reordering, values must be unique"
+ assert (
+ len(value_list) == len(value_set) and set(self._wires) == value_set
+ ), "Set of values does not match, assigment can only be used for reordering, \
+ values must be unique"
# except:
# import pdb; pdb.set_trace()
self._wires = value_list
@@ -90,12 +103,15 @@ def create_wire(self):
return wire
def add_wire(self, wire, position=None):
- """Adds a wire to the cable at the given position. This wire must not belong to a cable already
+ """
+ Adds a wire to the cable at the given position. This wire must not belong to
+ a cable already
parameters
----------
- wire - (Wire) the wire to be added to the cable. This wire must not belong to any other cable.
+ wire - (Wire) the wire to be added to the cable. This wire must not belong to any other
+ cable.
position - (int, default None) the index in the wires list at which to add the wire.
"""
@@ -109,7 +125,8 @@ def add_wire(self, wire, position=None):
wire._cable = self
def remove_wire(self, wire):
- """removes the given wire from the cable and return it. The wire must belong to this cable
+ """
+ removes the given wire from the cable and return it. The wire must belong to this cable
parameters
----------
@@ -133,7 +150,8 @@ def remove_wires_from(self, wires):
else:
excluded_wires = set(wires)
assert all(
- x.cable == self for x in excluded_wires), "Some wires do not belong to this cable"
+ x.cable == self for x in excluded_wires
+ ), "Some wires do not belong to this cable"
for wire in excluded_wires:
self._remove_wire(wire)
self._wires = list(x for x in self._wires if x not in excluded_wires)
@@ -144,12 +162,14 @@ def _remove_wire(self, wire):
wire._cable = None
def _clone_rip_and_replace(self, memo):
- """Remove from its current environment and place it into the new cloned environment with references held in the memo dictionary"""
+ """Remove from its current environment and place it into the new cloned environment with
+ references held in the memo dictionary"""
for w in self._wires:
w._clone_rip_and_replace(memo)
def _clone_rip(self):
- """Remove from its current environmnet. This will remove all pin pointers and create a floating stand alone instance."""
+ """Remove from its current environmnet. This will remove all pin pointers and create a
+ floating stand alone instance."""
for w in self._wires:
w._clone_rip()
w._cable = self
@@ -158,11 +178,14 @@ def _clone(self, memo):
"""Not api safe clone function
clone leaving all references in tact.
the element can then either be ripped or ripped and replaced"""
- assert self not in memo, "the object should not have been copied twice in this pass"
+ assert (
+ self not in memo
+ ), "the object should not have been copied twice in this pass"
from spydrnet.ir import Cable as CableExtended
+
c = CableExtended()
memo[self] = c
- new_wires = list()
+ new_wires = []
for w in self._wires:
new_wires.append(w._clone(memo))
c._wires = new_wires
@@ -185,22 +208,22 @@ def clone(self):
* is_downto, is_scalar, lower_index will be maintained
* the wires in the cable will all have the cable set as the parent
"""
- c = self._clone(dict())
+ c = self._clone({})
c._clone_rip()
return c
def __str__(self):
"""Re-define the print function so it is easier to read"""
rep = str(type(self))
- rep = rep[:-1] + '; '
+ rep = rep[:-1] + "; "
if self.is_downto is not None and self.is_downto is True:
- rep += 'is_downto: True; '
+ rep += "is_downto: True; "
else:
- rep += 'is_downto: False; '
+ rep += "is_downto: False; "
if self.is_scalar is True:
- rep += 'is_scalar: True; '
+ rep += "is_scalar: True; "
else:
- rep += 'is_scalar: False; '
- rep += 'lower index: ' + str(self.lower_index)
- rep += '>'
+ rep += "is_scalar: False; "
+ rep += "lower index: " + str(self.lower_index)
+ rep += ">"
return rep
diff --git a/spydrnet/ir/definition.py b/spydrnet/ir/definition.py
index 32e55d04..3d8e031c 100644
--- a/spydrnet/ir/definition.py
+++ b/spydrnet/ir/definition.py
@@ -1,4 +1,4 @@
-from copy import copy, deepcopy, error
+from copy import copy, deepcopy
from spydrnet.global_state import global_callback
from spydrnet.global_state.global_callback import _call_create_definition
@@ -13,7 +13,8 @@ class Definition(FirstClassElement):
Contains a pointer to parent library, ports, cables, and instances.
"""
- __slots__ = ['_library', '_ports', '_cables', '_children', '_references']
+
+ __slots__ = ["_library", "_ports", "_cables", "_children", "_references"]
def __init__(self, name=None, properties=None):
"""Creates an empty object of type definition
@@ -26,18 +27,17 @@ def __init__(self, name=None, properties=None):
"""
super().__init__()
self._library = None
- self._ports = list()
- self._cables = list()
- self._children = list()
+ self._ports = []
+ self._cables = []
+ self._children = []
self._references = set()
_call_create_definition(self)
- if name != None:
+ if name is not None:
self.name = name
- if properties != None:
- assert isinstance(
- properties, dict), "properties must be a dictionary"
+ if properties is not None:
+ assert isinstance(properties, dict), "properties must be a dictionary"
for key in properties:
self[key] = properties[key]
@@ -69,8 +69,10 @@ def ports(self, value):
"""
target = list(value)
target_set = set(target)
- assert len(target) == len(target_set) and set(self._ports) == target_set, \
- "Set of values do not match, this function can only reorder values, values must be unique"
+ assert (
+ len(target) == len(target_set) and set(self._ports) == target_set
+ ), "Set of values do not match, this function can only reorder \
+ values, values must be unique"
self._ports = target
@property
@@ -83,7 +85,8 @@ def cables(self):
@cables.setter
def cables(self, value):
"""
- Reorder the cables in this definition. Use add_cable and remove_cable to add or remove cables.
+ Reorder the cables in this definition. Use add_cable and remove_cable to add or remove
+ cables.
parameters
@@ -93,8 +96,10 @@ def cables(self, value):
"""
target = list(value)
target_set = set(target)
- assert len(target) == len(target_set) and set(self._cables) == set(target), \
- "Set of values do not match, this function can only reorder values, values must be unique"
+ assert len(target) == len(target_set) and set(self._cables) == set(
+ target
+ ), "Set of values do not match, this function can only reorder values, values \
+ must be unique"
self._cables = target
@property
@@ -107,8 +112,8 @@ def children(self):
@children.setter
def children(self, value):
"""
- Reorder the list of instances instantiated in this definition use add_child and remove_child to add or remove
- instances to or from the definition
+ Reorder the list of instances instantiated in this definition use add_child and remove_child
+ to add or remove instances to or from the definition
parameters
----------
@@ -117,8 +122,10 @@ def children(self, value):
"""
target = list(value)
target_set = set(target)
- assert len(target) == len(target_set) and set(self._children) == target_set, \
- "Set of values do not match, this function can only reorder values, values must be unique"
+ assert (
+ len(target) == len(target_set) and set(self._children) == target_set
+ ), "Set of values do not match, this function can only reorder values, values \
+ must be unique"
self._children = target
@property
@@ -132,14 +139,23 @@ def is_leaf(self):
"""
Check to see if this definition represents a leaf cell.
- Leaf cells are cells with no children instances or no
- children cables. Blackbox cells are considered leaf cells as well as direct pass through cells with cables only
+ Leaf cells are cells with no children instances or no children cables. Blackbox cells are
+ considered leaf cells as well as direct pass through cells with cables only
"""
if len(self._children) > 0 or len(self._cables) > 0:
return False
return True
- def create_port(self, name=None, properties=None, is_downto=None, is_scalar=None, lower_index=None, direction=None, pins=None):
+ def create_port(
+ self,
+ name=None,
+ properties=None,
+ is_downto=None,
+ is_scalar=None,
+ lower_index=None,
+ direction=None,
+ pins=None,
+ ):
"""Create a port, add it to the definition, and return that port.
parameters
@@ -147,14 +163,16 @@ def create_port(self, name=None, properties=None, is_downto=None, is_scalar=None
name - (str) the name of this instance
properties - (dict) the dictionary which holds the properties
- id_downto - (bool) set the downto status. Downto is False if the right index is higher than the left one, True otherwise
- is_scalar - (bool) set the scalar status. Return True if the item is a scalar False otherwise.
+ id_downto - (bool) set the downto status. Downto is False if the right index is higher than
+ the left one, True otherwise
+ is_scalar - (bool) set the scalar status. Return True if the item is a scalar False
+ otherwise.
lower_index - (int) get the value of the lower index of the array.
- direction - (Enum) Define the possible directions for a given port. (UNDEFINED, INOUT, IN, OUT)
+ direction - (Enum) Define the possible directions for a given port. (UNDEFINED, INOUT, IN,
+ OUT)
pins - (int) Create number of pins in the newly created port
"""
- port = Port(name, properties, is_downto,
- is_scalar, lower_index, direction)
+ port = Port(name, properties, is_downto, is_scalar, lower_index, direction)
self.add_port(port)
if pins:
port.create_pins(pins)
@@ -212,8 +230,9 @@ def remove_ports_from(self, ports):
excluded_ports = ports
else:
excluded_ports = set(ports)
- assert all(x.definition == self for x in excluded_ports), "Some ports to remove are not included in the " \
- "definition."
+ assert all(x.definition == self for x in excluded_ports), (
+ "Some ports to remove are not included in the " "definition."
+ )
for port in excluded_ports:
self._remove_port(port)
self._ports = list(x for x in self._ports if x not in excluded_ports)
@@ -246,8 +265,8 @@ def create_child(self, name=None, properties=None, reference=None):
parameters
----------
- name - (str) the name of this instance
- properties - (dict) the dictionary which holds the properties
+ name - (str) the name of this instance properties - (dict) the dictionary which holds the
+ properties
Example
-------
@@ -261,7 +280,8 @@ def create_child(self, name=None, properties=None, reference=None):
To create a child with optional parameters
- >>> child_instance = definition.create_child(name="child_instance", reference=reference_definition)
+ >>> child_instance = definition.create_child(name="child_instance",
+ reference=reference_definition)
The reference of the instance is the definition that initialized this instance.
"""
@@ -286,7 +306,9 @@ def add_child(self, instance, position=None):
position - (int, default None) the index in the children list at which to add the instance.
"""
assert instance.parent is not self, "Instance already included in definition"
- assert instance.parent is None, "Instance already belongs to a different definition"
+ assert (
+ instance.parent is None
+ ), "Instance already belongs to a different definition"
global_callback._call_definition_add_child(self, instance)
if position is not None:
self._children.insert(position, instance)
@@ -323,8 +345,9 @@ def remove_children_from(self, children):
else:
excluded_children = set(children)
assert all(
- x.parent == self for x in excluded_children), "Some children are not parented by the definition"
- included_children = list()
+ x.parent == self for x in excluded_children
+ ), "Some children are not parented by the definition"
+ included_children = []
for child in self._children:
if child not in excluded_children:
included_children.append(child)
@@ -339,7 +362,15 @@ def _remove_child(self, child):
global_callback._call_definition_remove_child(self, child)
child._parent = None
- def create_cable(self, name=None, properties=None, is_downto=None, is_scalar=None, lower_index=None, wires=None):
+ def create_cable(
+ self,
+ name=None,
+ properties=None,
+ is_downto=None,
+ is_scalar=None,
+ lower_index=None,
+ wires=None,
+ ):
"""Create a cable, add it to the definition, and return the cable.
parameters
@@ -347,8 +378,10 @@ def create_cable(self, name=None, properties=None, is_downto=None, is_scalar=Non
name - (str) the name of this instance
properties - (dict) the dictionary which holds the properties
- id_downto - (bool) set the downto status. Downto is False if the right index is higher than the left one, True otherwise
- is_scalar - (bool) set the scalar status. Return True if the item is a scalar False otherwise.
+ id_downto - (bool) set the downto status. Downto is False if the right index is higher than
+ the left one, True otherwise
+ is_scalar - (bool) set the scalar status. Return True if the item is a scalar False
+ otherwise.
lower_index - (int) get the value of the lower index of the array.
wires - (int) Create number of wires in the newly created cable
"""
@@ -371,7 +404,9 @@ def add_cable(self, cable, position=None):
position - (int, default None) the position in the cable list at which to add the cable
"""
assert cable.definition is not self, "Cable already included in definition"
- assert cable.definition is None, "Cable already belongs to a different definition"
+ assert (
+ cable.definition is None
+ ), "Cable already belongs to a different definition"
global_callback._call_definition_add_cable(self, cable)
if position is not None:
self._cables.insert(position, cable)
@@ -408,8 +443,9 @@ def remove_cables_from(self, cables):
else:
excluded_cables = set(cables)
assert all(
- x.definition == self for x in excluded_cables), "Some cables are not included in the definition"
- included_cables = list()
+ x.definition == self for x in excluded_cables
+ ), "Some cables are not included in the definition"
+ included_cables = []
for cable in self._cables:
if cable not in excluded_cables:
included_cables.append(cable)
@@ -426,10 +462,14 @@ def _remove_cable(self, cable):
cable._definition = None
def _clone_rip_and_replace(self, memo):
- """If an instance that is a reference of this definition was cloned then update the list of references of the definition.
+ """
+ If an instance that is a reference of this definition was cloned then update the list of
+ references of the definition.
- For each of the children instances, we should also update the reference to refer to any cloned dictionaries
- inner pins now also need to be updated with new inner pins for each of the definitions that was cloned."""
+ For each of the children instances, we should also update the reference to refer to any
+ cloned dictionaries inner pins now also need to be updated with new inner pins for each of
+ the definitions that was cloned.
+ """
new_references = set()
for instance in self._references:
# if the instance was cloned then replace it in our references also update its reference
@@ -459,24 +499,27 @@ def _clone(self, memo):
clone leaving all references in tact.
the element can then either be ripped or ripped and replaced"""
- assert self not in memo, "the object should not have been copied twice in this pass"
+ assert (
+ self not in memo
+ ), "the object should not have been copied twice in this pass"
from spydrnet.ir import Definition as DefinitionExtended
+
c = DefinitionExtended()
memo[self] = c
c._data = deepcopy(self._data)
c._library = None
- new_ports = list()
+ new_ports = []
for p in self.ports:
new_ports.append(p._clone(memo))
c._ports = new_ports
- new_cables = list()
+ new_cables = []
for ca in self.cables:
new_cables.append(ca._clone(memo))
c._cables = new_cables
- new_children = list()
+ new_children = []
for ch in self.children:
new_children.append(ch._clone(memo))
c._children = new_children
@@ -504,35 +547,39 @@ def clone(self):
The cloned object will have the following properties
* the definition will be orphaned and will not belong to any library
- * each of the sub elements of the definition will also be cloned and the connection structure between them will be updated.
- * the cloned instances will still point to the reference to which the pointed before. They will also be members of the references list of those definitions.
+ * each of the sub elements of the definition will also be cloned and the connection
+ structure between them will be updated.
+ * the cloned instances will still point to the reference to which the pointed before. They
+ will also be members of the references list of those definitions.
"""
- c = self._clone(dict())
+ c = self._clone({})
c._clone_rip()
return c
# def __repr__(self):
- # return ""
+ # return ""
def __str__(self):
"""Re-define the print function so it is easier to read"""
rep = super().__str__()
- rep = rep[:-1] + '; '
+ rep = rep[:-1] + "; "
if self.library is None:
- rep += 'Library undefined'
+ rep += "Library undefined"
elif self.library.name is None:
- rep += 'Library.name undefined'
+ rep += "Library.name undefined"
else:
- rep += 'Library.name \'' + self.library.name + '\''
- rep += '; '
- rep += 'ports: '
+ rep += "Library.name '" + self.library.name + "'"
+ rep += "; "
+ rep += "ports: "
rep += str(sum(1 for _ in self.get_ports()))
- rep += '; cables: '
+ rep += "; cables: "
rep += str(sum(1 for _ in self.get_cables()))
- rep += '; children: '
+ rep += "; children: "
rep += str(len(self.children))
- rep += '; references: '
+ rep += "; references: "
rep += str(len(self.references))
- rep += '>'
+ rep += ">"
return rep
diff --git a/spydrnet/ir/element.py b/spydrnet/ir/element.py
index 62099144..8a157ff6 100644
--- a/spydrnet/ir/element.py
+++ b/spydrnet/ir/element.py
@@ -5,4 +5,5 @@ class Element(GetterShortcuts):
"""
Represents an object
"""
+
__slots__ = tuple()
diff --git a/spydrnet/ir/first_class_element.py b/spydrnet/ir/first_class_element.py
index 88d91f17..fe214497 100644
--- a/spydrnet/ir/first_class_element.py
+++ b/spydrnet/ir/first_class_element.py
@@ -8,30 +8,35 @@ class FirstClassElement(Element):
"""
Base class of all intermediate representation objects.
- An intermediate representation object represents an item in a netlist. Items range in specificity from pins on a
- port or wires in a cable up to an item that represents the netlist as a whole.
-
- Each element implements a dictionary for storing key-value pairs. The key should be a case sensitive string and the
- value should be a primitive type (string, integer, float, boolean) or potentially nested collections of primitive
- types. The purpose of this dictionary is to provide a space for properties and metadata associated with the element.
-
- Key namespaces are separated with a *period* character. If the key is void of a *period* than the key resides in the
- root namespace. Keys in the root namespace are considered properties. Other keys are considered metadata. For
- example '.': is considered metadata associated with the netlist's
- language of origin.
-
- Only data pertinent to the netlist should be stored in this dictionary. Cached data (namespace management, anything
- that can be recreated from the netlist) should be excluded from this dictionary. The intent of the IR is to house
- the basis of data for the netlist.
-
- The only key that is reserved is 'NAME'. It is the primary name of the element. NAME may be undefined or inferred,
- for example, a pin on a port may be nameless, but infer its name for its parent port and position.
+ An intermediate representation object represents an item in a netlist. Items range in
+ specificity from pins on a port or wires in a cable up to an item that represents the netlist as
+ a whole.
+
+ Each element implements a dictionary for storing key-value pairs. The key should be a case
+ sensitive string and the value should be a primitive type (string, integer, float, boolean) or
+ potentially nested collections of primitive types. The purpose of this dictionary is to provide
+ a space for properties and metadata associated with the element.
+
+ Key namespaces are separated with a *period* character. If the key is void of a *period* than
+ the key resides in the root namespace. Keys in the root namespace are considered properties.
+ Other keys are considered metadata. For example
+ '.': is considered metadata associated with the
+ netlist's language of origin.
+
+ Only data pertinent to the netlist should be stored in this dictionary. Cached data (namespace
+ management, anything that can be recreated from the netlist) should be excluded from this
+ dictionary. The intent of the IR is to house the basis of data for the netlist.
+
+ The only key that is reserved is 'NAME'. It is the primary name of the element. NAME may be
+ undefined or inferred, for example, a pin on a port may be nameless, but infer its name for its
+ parent port and position.
"""
- __slots__ = ['_data',]
+
+ __slots__ = ["_data",]
def __init__(self):
"""Initialize an element with an empty data dictionary."""
- self._data = dict()
+ self._data = {}
@property
def data(self):
@@ -73,7 +78,7 @@ def __setitem__(self, key, value):
self._data.__setitem__(sys.intern(key), value)
def __delitem__(self, key):
- """ delete the item from the data structure"""
+ """delete the item from the data structure"""
global_callback._call_dictionary_delete(self, key)
self._data.__delitem__(key)
@@ -98,10 +103,10 @@ def get(self, *args, **kwargs):
def __str__(self):
"""Re-define the print function so it is easier to read"""
rep = str(type(self))
- rep = rep[:-1] + '; '
+ rep = rep[:-1] + "; "
if self.name is None:
- rep += 'name undefined'
+ rep += "name undefined"
else:
- rep += 'name \'' + self.name + '\''
- rep += '>'
+ rep += "name '" + self.name + "'"
+ rep += ">"
return rep
diff --git a/spydrnet/ir/innerpin.py b/spydrnet/ir/innerpin.py
index 959f0ba2..380627b9 100644
--- a/spydrnet/ir/innerpin.py
+++ b/spydrnet/ir/innerpin.py
@@ -1,5 +1,4 @@
from spydrnet.ir import Pin
-from copy import deepcopy, copy, error
class InnerPin(Pin):
@@ -8,7 +7,8 @@ class InnerPin(Pin):
These pins can be thought of as on the inside of a definition. There can be
many outer pins for each inner pin
"""
- __slots__ = ['_port']
+
+ __slots__ = ["_port"]
def __init__(self):
super().__init__()
@@ -22,13 +22,17 @@ def port(self):
return self._port
def _clone_rip_and_replace(self, memo):
- """Remove from its current environment and place it into the new cloned environment with references held in the memo dictionary"""
- if self._wire != None:
- assert self._wire in memo, "wire must have been cloned in order to rip and replace innerpin"
+ """Remove from its current environment and place it into the new cloned environment with
+ references held in the memo dictionary"""
+ if self._wire is not None:
+ assert (
+ self._wire in memo
+ ), "wire must have been cloned in order to rip and replace innerpin"
self._wire = memo[self._wire]
def _clone_rip(self):
- """Remove from its current environmnet. This will remove all pin pointers and create a floating stand alone instance."""
+ """Remove from its current environmnet. This will remove all pin pointers and create a
+ floating stand alone instance."""
self._wire = None
def _clone(self, memo):
@@ -36,8 +40,11 @@ def _clone(self, memo):
Clone leaving all references in tact.
the element can then either be ripped or ripped and replaced"""
- assert self not in memo, "the object should not have been copied twice in this pass"
+ assert (
+ self not in memo
+ ), "the object should not have been copied twice in this pass"
from spydrnet.ir import InnerPin as InnerPinExtended
+
c = InnerPinExtended()
memo[self] = c
c._wire = self._wire
@@ -54,6 +61,6 @@ def clone(self):
* The pin will not be referenced to by any wires or outer pins
"""
- c = self._clone(dict())
+ c = self._clone({})
c._clone_rip()
return c
diff --git a/spydrnet/ir/instance.py b/spydrnet/ir/instance.py
index e3b36ac9..850e1acb 100644
--- a/spydrnet/ir/instance.py
+++ b/spydrnet/ir/instance.py
@@ -1,27 +1,31 @@
+from copy import deepcopy
+from collections import OrderedDict
from spydrnet.ir import FirstClassElement
from spydrnet.ir import OuterPin
from spydrnet.ir.views.outerpinsview import OuterPinsView
from spydrnet.global_state import global_callback
from spydrnet.global_state.global_callback import _call_create_instance
-from copy import deepcopy
-from collections import OrderedDict
class Instance(FirstClassElement):
"""Netlist instance of a netlist definition.
Instances are literally instances of definitions and they reside inside other definitions.
- Function names have been set to prevent potential confusion that could arise because instances have both a parent definition and definitions which they reference.
+ Function names have been set to prevent potential confusion that could arise because instances
+ have both a parent definition and definitions which they reference.
- :ivar parent: the parent of the object. Parent is the definition that instances another definition.
+ :ivar parent: the parent of the object. Parent is the definition that instances another
+ definition.
:ivar child: the instance itself is the child of the parent.
:ivar reference: the item of the object. Reference is the definition of the instance.
- For example, when writing definition 1, we instance definition 2. Definition 1 is the parent, the instance is the child, and definition 2 is the instance's reference.
+ For example, when writing definition 1, we instance definition 2. Definition 1 is the parent,
+ the instance is the child, and definition 2 is the instance's reference.
"""
- __slots__ = ['_parent', '_reference', '_pins','_is_top_instance']
+
+ __slots__ = ["_parent", "_reference", "_pins", "_is_top_instance"]
def __init__(self, name=None, properties=None):
"""Creates an empty object of type instance.
@@ -38,11 +42,10 @@ def __init__(self, name=None, properties=None):
self._pins = OrderedDict()
self._is_top_instance = False
_call_create_instance(self)
- if name != None:
+ if name is not None:
self.name = name
- if properties != None:
- assert isinstance(
- properties, dict), "properties must be a dictionary"
+ if properties is not None:
+ assert isinstance(properties, dict), "properties must be a dictionary"
for key in properties:
self[key] = properties[key]
@@ -52,7 +55,6 @@ def parent(self):
return self._parent
def test(self):
-
return True
@property
@@ -69,7 +71,8 @@ def reference(self, value):
parameters
----------
- value - (Definition) the definition that this instance should be an instance of"""
+ value - (Definition) the definition that this instance should be an instance of
+ """
global_callback._call_instance_reference(self, value)
if value is None:
for pin in self.pins:
@@ -84,9 +87,11 @@ def reference(self, value):
self._reference._references.remove(self)
else:
if self._reference is not None:
- assert len(self.reference.ports) == len(value.ports) and all(len(x.pins) == len(y.pins) for x, y in
- zip(self.reference.ports, value.ports)), \
- "Reference reassignment only supported for definitions with matching port positions"
+ assert len(self.reference.ports) == len(value.ports) and all(
+ len(x.pins) == len(y.pins)
+ for x, y in zip(self.reference.ports, value.ports)
+ ), "Reference reassignment only supported for definitions with matching \
+ port positions"
self._reference._references.remove(self)
for cur_port, new_port in zip(self.reference.ports, value.ports):
for cur_pin, new_pin in zip(cur_port.pins, new_port.pins):
@@ -106,12 +111,14 @@ def reference(self):
def get_ports(self, *args, **kwargs):
from spydrnet.util.get_ports import get_ports
+
return get_ports(self, *args, **kwargs)
@property
def pins(self):
"""Get the pins on this instance.
- Can do instance.pins[] to get the inner pin's associated outer pins."""
+ Can do instance.pins[] to get the inner pin's associated outer pins.
+ """
return OuterPinsView(self._pins)
def _clone_rip_and_replace_in_definition(self, memo):
@@ -125,8 +132,8 @@ def _clone_rip_and_replace_in_definition(self, memo):
def _clone_rip_and_replace_in_library(self, memo):
"""Move the instance into a new library/netlist.
- This will replace the reference if affected and replace the inner pins that will be affected as well.
- The instance should not be in the references list of the reference definition
+ This will replace the reference if affected and replace the inner pins that will be affected
+ as well. The instance should not be in the references list of the reference definition
"""
new_pins = OrderedDict()
for ip, op in self._pins.items():
@@ -136,7 +143,8 @@ def _clone_rip_and_replace_in_library(self, memo):
def _clone_rip(self):
"""Remove the instance from its current environmnet.
- This will remove the instance from any wires but it will add it in to the references set on the definition which it instantiates.
+ This will remove the instance from any wires but it will add it in to the references set on
+ the definition which it instantiates.
"""
for op in self._pins.values():
op._wire = None
@@ -147,8 +155,11 @@ def _clone(self, memo):
clone the instance leaving all references in tact.
The instance can then either be ripped or ripped and replaced
"""
- assert self not in memo, "the object should not have been copied twice in this pass"
+ assert (
+ self not in memo
+ ), "the object should not have been copied twice in this pass"
from spydrnet.ir import Instance as InstanceExtended
+
c = InstanceExtended()
memo[self] = c
c._parent = None
@@ -166,10 +177,12 @@ def clone(self):
Clone the instance in an api safe way.
This call will return a cloned instance that has the following properties:
- * the pins in the instance will all be disconnected from wires but they will maintain their references to inner pins
+ * the pins in the instance will all be disconnected from wires but they will maintain their
+ references to inner pins
* the instance references is the same as the cloned object
* the reference's references list contains this instance
- * the instance is orphaned (no longer a child of the definition to which the cloned definition belonged
+ * the instance is orphaned (no longer a child of the definition to which the cloned
+ definition belonged
"""
c = self._clone(OrderedDict())
@@ -179,8 +192,8 @@ def clone(self):
def is_leaf(self):
"""Check to see if the definition that this instance contains represents a leaf cell.
- Leaf cells are cells with no children instances or no children cables.
- Blackbox cells are considered leaf cells as well as direct pass through cells with cables only
+ Leaf cells are cells with no children instances or no children cables. Blackbox cells are
+ considered leaf cells as well as direct pass through cells with cables only
"""
if self._reference is None:
return False
@@ -200,23 +213,23 @@ def is_unique(self):
def __str__(self):
"""Re-define the print function so it is easier to read"""
rep = super().__str__()
- rep = rep[:-1] + '; '
+ rep = rep[:-1] + "; "
if self.parent is None:
- rep += 'parent definition undefined'
+ rep += "parent definition undefined"
elif self.parent.name is None:
- rep += 'parent definition.name undefined'
+ rep += "parent definition.name undefined"
else:
- rep += 'parent definition.name \'' + self.parent.name + '\''
+ rep += "parent definition.name '" + self.parent.name + "'"
- rep += '; '
+ rep += "; "
if self.reference is None:
- rep += 'reference definition undefined'
+ rep += "reference definition undefined"
elif self.reference.name is None:
- rep += 'reference definition.name undefined'
+ rep += "reference definition.name undefined"
else:
- rep += 'reference definition.name \'' + self.reference.name + '\''
- rep += '>'
+ rep += "reference definition.name '" + self.reference.name + "'"
+ rep += ">"
return rep
def __lt__(self, other):
@@ -227,5 +240,5 @@ def is_top_instance(self):
return self._is_top_instance
@is_top_instance.setter
- def is_top_instance(self,value):
- self._is_top_instance = value
\ No newline at end of file
+ def is_top_instance(self, value):
+ self._is_top_instance = value
diff --git a/spydrnet/ir/library.py b/spydrnet/ir/library.py
index 8d000a7d..1450a4da 100644
--- a/spydrnet/ir/library.py
+++ b/spydrnet/ir/library.py
@@ -1,9 +1,9 @@
+from copy import deepcopy
from spydrnet.ir import FirstClassElement
from spydrnet.ir import Definition
from spydrnet.ir.views.listview import ListView
from spydrnet.global_state import global_callback
from spydrnet.global_state.global_callback import _call_create_library
-from copy import deepcopy, copy, error
class Library(FirstClassElement):
@@ -12,7 +12,8 @@ class Library(FirstClassElement):
Contains a pointer to parent netlist and definitions.
"""
- __slots__ = ['_netlist', '_definitions']
+
+ __slots__ = ["_netlist", "_definitions"]
def __init__(self, name=None, properties=None):
"""
@@ -27,14 +28,13 @@ def __init__(self, name=None, properties=None):
super().__init__()
self._netlist = None
- self._definitions = list()
+ self._definitions = []
_call_create_library(self)
- if name != None:
+ if name is not None:
self.name = name
- if properties != None:
- assert isinstance(
- properties, dict), "properties must be a dictionary"
+ if properties is not None:
+ assert isinstance(properties, dict), "properties must be a dictionary"
for key in properties:
self[key] = properties[key]
@@ -66,8 +66,10 @@ def definitions(self, value):
"""
value_list = list(value)
value_set = set(value_list)
- assert len(value_list) == len(value_set) and set(self._definitions) == value_set, \
- "Set of values do not match, this function can only reorder values, values must be unique"
+ assert (
+ len(value_list) == len(value_set) and set(self._definitions) == value_set
+ ), "Set of values do not match, this function can only reorder values, values must \
+ be unique"
self._definitions = value_list
def create_definition(self, name=None, properties=None):
@@ -96,8 +98,18 @@ def add_definition(self, definition, position=None):
position - int, (default None)
the index in the library list at which to add the definition
"""
- assert definition.library is not self, "Definition " + str(definition) + " already included in library " + str(self)
- assert definition.library is None, "Definition " + str(definition) + " already belongs to a different library " + str(definition.library)
+ assert definition.library is not self, (
+ "Definition "
+ + str(definition)
+ + " already included in library "
+ + str(self)
+ )
+ assert definition.library is None, (
+ "Definition "
+ + str(definition)
+ + " already belongs to a different library "
+ + str(definition.library)
+ )
global_callback._call_library_add_definition(self, definition)
if position is not None:
self._definitions.insert(position, definition)
@@ -133,9 +145,10 @@ def remove_definitions_from(self, definitions):
excluded_definitions = definitions
else:
excluded_definitions = set(definitions)
- assert all(x.library == self for x in excluded_definitions), "Some definitions to remove are not included in " \
- "the library "
- included_definitions = list()
+ assert all(x.library == self for x in excluded_definitions), (
+ "Some definitions to remove are not included in " "the library "
+ )
+ included_definitions = []
for definition in self._definitions:
if definition not in excluded_definitions:
included_definitions.append(definition)
@@ -149,8 +162,10 @@ def _remove_definition(self, definition):
definition._library = None
def _clone_rip_and_replace(self, memo):
- """Remove from its current environment and place it into the new cloned environment with references held in the memo dictionary"""
- pass # this function will need to call rip and replace in library on each of the definitions when called from the netlist.
+ """Remove from its current environment and place it into the new cloned environment with
+ references held in the memo dictionary"""
+ pass # this function will need to call rip and replace in library on each of
+ # the definitions when called from the netlist.
for definition in self._definitions:
definition._clone_rip_and_replace(memo)
@@ -175,13 +190,15 @@ def _clone(self, memo):
clone leaving all references in tact.
The element can then either be ripped or ripped and replaced
"""
- assert self not in memo, "the object should not have been copied twice in this pass"
+ assert (
+ self not in memo
+ ), "the object should not have been copied twice in this pass"
c = Library()
memo[self] = c
c._netlist = None
c._data = deepcopy(self._data)
- new_definitions = list()
+ new_definitions = []
for definition in self._definitions:
new_definitions.append(definition._clone(memo))
c._definitions = new_definitions
@@ -196,13 +213,16 @@ def clone(self):
The following describes the structure of the returned object:
- * the instances that pointed to reference definitions within the library will have updated references
- * the instances that pointed to reference definitions outside the library will maintain their definitions
- * the references lists (of definitions) both inside and outsde the library will be updated to reflect the change
+ * the instances that pointed to reference definitions within the library will have updated
+ references
+ * the instances that pointed to reference definitions outside the library will maintain
+ their definitions
+ * the references lists (of definitions) both inside and outsde the library will be updated
+ to reflect the change
* all definitions are cloned within the library.
- """
- memo = dict()
+ """
+ memo = {}
c = self._clone(memo)
c._clone_rip(memo)
return c
@@ -210,12 +230,12 @@ def clone(self):
def __str__(self):
"""Re-define the print function so it is easier to read"""
rep = super().__str__()
- rep = rep[:-1] + '; '
+ rep = rep[:-1] + "; "
if self.netlist is None:
- rep += 'parent netlist undefined'
+ rep += "parent netlist undefined"
elif self.netlist.name is None:
- rep += 'parent netlist.name undefined'
+ rep += "parent netlist.name undefined"
else:
- rep += 'parent netlist.name \'' + self.netlist.name + '\''
- rep += '>'
+ rep += "parent netlist.name '" + self.netlist.name + "'"
+ rep += ">"
return rep
diff --git a/spydrnet/ir/netlist.py b/spydrnet/ir/netlist.py
index b268f087..d6ee02cb 100644
--- a/spydrnet/ir/netlist.py
+++ b/spydrnet/ir/netlist.py
@@ -1,10 +1,10 @@
+from copy import deepcopy
from spydrnet.ir import FirstClassElement
from spydrnet.ir import Library
from spydrnet.ir import Instance
from spydrnet.ir.views.listview import ListView
from spydrnet.global_state import global_callback
from spydrnet.global_state.global_callback import _call_create_netlist
-from copy import deepcopy, copy, error
from spydrnet.ir import Definition
@@ -38,7 +38,8 @@ class Netlist(FirstClassElement):
>>> work_library = netlist.create_library()
>>> work_library['EDIF.identifier'] = 'work'
"""
- __slots__ = ['_libraries', '_top_instance']
+
+ __slots__ = ["_libraries", "_top_instance"]
def __init__(self, name=None, properties=None):
"""
@@ -51,15 +52,14 @@ def __init__(self, name=None, properties=None):
properties - (dict) the dictionary which holds the properties
"""
super().__init__()
- self._libraries = list()
+ self._libraries = []
self._top_instance = None
_call_create_netlist(self)
- if name != None:
+ if name is not None:
self.name = name
- if properties != None:
- assert isinstance(
- properties, dict), "properties must be a dictionary"
+ if properties is not None:
+ assert isinstance(properties, dict), "properties must be a dictionary"
for key in properties:
self[key] = properties[key]
@@ -70,6 +70,7 @@ def compose(self, *args, **kwargs):
Shortcut to :func:`~spydrnet.compose`.
"""
from spydrnet.composers import compose
+
compose(self, *args, **kwargs)
@property
@@ -91,8 +92,10 @@ def libraries(self, value):
"""
value_list = list(value)
value_set = set(value_list)
- assert len(value_list) == len(value_set) and set(self._libraries) == value_set, \
- "Set of values do not match, this assignment can only reorder values, values must be unique"
+ assert (
+ len(value_list) == len(value_set) and set(self._libraries) == value_set
+ ), "Set of values do not match, this assignment can only reorder values, \
+ values must be unique"
self._libraries = value_list
@property
@@ -115,14 +118,18 @@ def top_instance(self, instance):
Parameters
----------
- instance - (Instance or Definition) the instance to set as the top instance. If a definition is passed into the funciton,
+ instance - (Instance or Definition) the instance to set as the top instance. If a definition
+ is passed into the funciton,
creates a new instance with that definition and set it as the top instance.
"""
- assert instance is None or isinstance(instance, Instance) or isinstance(
- instance, Definition), "Must specify an instance"
+ assert (
+ instance is None
+ or isinstance(instance, Instance)
+ or isinstance(instance, Definition)
+ ), "Must specify an instance"
global_callback._call_netlist_top_instance(self, instance)
- # TODO: should We have a DRC that makes sure the instance is of a definition contained in netlist? I think no
- # but I am open to hear other points of veiw.
+ # TODO: should We have a DRC that makes sure the instance is of a definition contained in
+ # netlist? I think no but I am open to hear other points of veiw.
if self.top_instance:
self.top_instance.is_top_instance = False
if isinstance(instance, Definition):
@@ -135,21 +142,25 @@ def top_instance(self, instance):
if instance:
instance.is_top_instance = True
- def set_top_instance(self, instance, instance_name='instance'):
+ def set_top_instance(self, instance, instance_name="instance"):
"""Sets the top instance of the design.
The instance must not be null and should probably come from this netlist
Parameters
----------
- instance - (Instance or Definition) the instance to set as the top instance. If a definition is passed into the funciton,
+ instance - (Instance or Definition) the instance to set as the top instance. If a definition
+ is passed into the funciton,
creates a new instance with that definition and set it as the top instance.
"""
- assert instance is None or isinstance(instance, Instance) or isinstance(
- instance, Definition), "Must specify an instance"
+ assert (
+ instance is None
+ or isinstance(instance, Instance)
+ or isinstance(instance, Definition)
+ ), "Must specify an instance"
global_callback._call_netlist_top_instance(self, instance)
- # TODO: should We have a DRC that makes sure the instance is of a definition contained in netlist? I think no
- # but I am open to hear other points of veiw.
+ # TODO: should We have a DRC that makes sure the instance is of a definition contained in
+ # netlist? I think no but I am open to hear other points of veiw.
if isinstance(instance, Definition):
top = Instance()
@@ -225,9 +236,10 @@ def remove_libraries_from(self, libraries):
excluded_libraries = libraries
else:
excluded_libraries = set(libraries)
- assert all(x.netlist == self for x in excluded_libraries), "Some libraries to remove are not included in " \
- "netlist "
- included_libraries = list()
+ assert all(x.netlist == self for x in excluded_libraries), (
+ "Some libraries to remove are not included in " "netlist "
+ )
+ included_libraries = []
for library in self._libraries:
if library not in excluded_libraries:
included_libraries.append(library)
@@ -255,18 +267,21 @@ def _clone(self, memo):
The element can then either be ripped or ripped and replaced.
"""
- assert self not in memo, "the object should not have been copied twice in this pass"
+ assert (
+ self not in memo
+ ), "the object should not have been copied twice in this pass"
from spydrnet.ir import Netlist as NetlistExtended
+
c = NetlistExtended()
memo[self] = c
c._data = deepcopy(self._data)
- new_libraries = list()
+ new_libraries = []
for library in self._libraries:
new_libraries.append(library._clone(memo))
c._libraries = new_libraries
- if self._top_instance == None:
+ if self._top_instance is None:
c._top_instance = None
else:
if self._top_instance in memo:
@@ -288,7 +303,7 @@ def clone(self):
This clone function should act just the way you would expect
All references are internal to the netlist that has been cloned.
"""
- memo = dict()
+ memo = {}
c = self._clone(memo)
c._clone_rip(memo)
return c
@@ -296,14 +311,14 @@ def clone(self):
def __str__(self):
"""Re-define the print function so it is easier to read"""
rep = super().__str__()
- rep = rep[:-1] + '; '
+ rep = rep[:-1] + "; "
if self.top_instance is None:
- rep += 'top_instance undefined'
+ rep += "top_instance undefined"
elif self.top_instance.name is None:
- rep += 'top_instance.name undefined'
+ rep += "top_instance.name undefined"
else:
- rep += 'top_instance.name \'' + self.top_instance.name + '\''
- rep += '>'
+ rep += "top_instance.name '" + self.top_instance.name + "'"
+ rep += ">"
return rep
def is_unique(self):
diff --git a/spydrnet/ir/outerpin.py b/spydrnet/ir/outerpin.py
index d993b66a..609aaa61 100644
--- a/spydrnet/ir/outerpin.py
+++ b/spydrnet/ir/outerpin.py
@@ -1,13 +1,13 @@
from spydrnet.ir import Pin
-from copy import deepcopy, copy, error
class OuterPin(Pin):
"""
- Pins that correspond to instances. These pins can be thought of as on the outside of an instance. There can be many
- outer pins for each inner pin
+ Pins that correspond to instances. These pins can be thought of as on the outside of an
+ instance. There can be many outer pins for each inner pin
"""
- __slots__ = ['_instance', '_inner_pin']
+
+ __slots__ = ["_instance", "_inner_pin"]
@staticmethod
def from_instance_and_inner_pin(instance, inner_pin):
@@ -20,6 +20,7 @@ def from_instance_and_inner_pin(instance, inner_pin):
inner_pin - (InnerPin) the inner pin with which to associate this outer pin"""
from spydrnet.ir import OuterPin as OuterPinExtended
+
return OuterPinExtended(instance, inner_pin)
def __init__(self, instance=None, inner_pin=None):
@@ -30,7 +31,9 @@ def __init__(self, instance=None, inner_pin=None):
instance - (Instance) the instance with which to associate this outper pin.
- inner_pin - (InnerPin) a definition's inner pin to be associated with this instance outer pin."""
+ inner_pin - (InnerPin) a definition's inner pin to be associated with this instance outer
+ pin.
+ """
super().__init__()
self._instance = instance
self._inner_pin = inner_pin
@@ -47,16 +50,22 @@ def inner_pin(self):
def __eq__(self, other):
if isinstance(other, OuterPin):
- return self._instance == other._instance and self._inner_pin == other._inner_pin
+ return (
+ self._instance == other._instance
+ and self._inner_pin == other._inner_pin
+ )
return False
def __hash__(self):
return hash((self._instance, self._inner_pin))
def _clone_rip_and_replace(self, memo):
- """remove from its current environment and place it into the new cloned environment with references held in the memo dictionary"""
- if self._wire != None:
- assert self._wire in memo, "can't call this function when the wire has not been cloned yet"
+ """remove from its current environment and place it into the new cloned environment with
+ references held in the memo dictionary"""
+ if self._wire is not None:
+ assert (
+ self._wire in memo
+ ), "can't call this function when the wire has not been cloned yet"
self._wire = memo[self._wire]
def _clone_rip(self):
@@ -72,8 +81,11 @@ def _clone(self, memo):
clone leaving all references in tact.
the element can then either be ripped or ripped and replaced"""
- assert self not in memo, "the object should not have been copied twice in this pass"
+ assert (
+ self not in memo
+ ), "the object should not have been copied twice in this pass"
from spydrnet.ir import OuterPin as OuterPinExtended
+
c = OuterPinExtended()
memo[self] = c
c._instance = None
@@ -90,9 +102,9 @@ def clone(self):
* the pin will be orphaned from any instance
* the pin will not be connected to any inner pins
"""
- c = self._clone(dict())
+ c = self._clone({})
c._clone_rip()
return c
def index(self):
- return self._inner_pin.port.pins.index(self._inner_pin)
\ No newline at end of file
+ return self._inner_pin.port.pins.index(self._inner_pin)
diff --git a/spydrnet/ir/pin.py b/spydrnet/ir/pin.py
index 67e85d47..7517212a 100644
--- a/spydrnet/ir/pin.py
+++ b/spydrnet/ir/pin.py
@@ -5,23 +5,25 @@ class Pin(Element):
"""Pin connects to a single wire.
This class is extended by InnerPin and OuterPin"""
- __slots__ = ['_wire',]
+
+ __slots__ = ["_wire",]
def __init__(self):
self._wire = None
@property
def wire(self):
- """Get the wire the pin is connected to. This value cannot be modified directly by the end user."""
+ """Get the wire the pin is connected to. This value cannot be modified directly by the end
+ user."""
return self._wire
def __str__(self):
"""Re-define the print function so it is easier to read"""
rep = str(type(self))
- rep = rep[:-1] + '; '
+ rep = rep[:-1] + "; "
if self.wire is None:
- rep += 'Wire connected undefined'
+ rep += "Wire connected undefined"
else:
- rep += 'connected to\'' + str(self.wire) + '\''
- rep += '>'
+ rep += "connected to'" + str(self.wire) + "'"
+ rep += ">"
return rep
diff --git a/spydrnet/ir/port.py b/spydrnet/ir/port.py
index a1aeccf0..e72515fa 100644
--- a/spydrnet/ir/port.py
+++ b/spydrnet/ir/port.py
@@ -1,21 +1,23 @@
+from copy import deepcopy
+from enum import Enum
from spydrnet.ir import Bundle
from spydrnet.ir import InnerPin
from spydrnet.ir import OuterPin
from spydrnet.ir.views.listview import ListView
from spydrnet.global_state import global_callback
from spydrnet.global_state.global_callback import _call_create_port
-from copy import deepcopy, copy, error
-from enum import Enum
class Port(Bundle):
"""
Located on the inside of a definition.
- Ports contain information about the quantity and directon of pins that go into and out of the defined struture when instanced.
+ Ports contain information about the quantity and directon of pins that go into and out of the
+ defined struture when instanced.
"""
- __slots__ = ['_direction', '_pins']
+
+ __slots__ = ["_direction", "_pins"]
class Direction(Enum):
"""Define the possible directions for a given port.
@@ -24,12 +26,21 @@ class Direction(Enum):
UNDEFINED, INOUT, IN, OUT
"""
+
UNDEFINED = 0
INOUT = 1
IN = 2
OUT = 3
- def __init__(self, name=None, properties=None, is_downto=None, is_scalar=None, lower_index=None, direction=None):
+ def __init__(
+ self,
+ name=None,
+ properties=None,
+ is_downto=None,
+ is_scalar=None,
+ lower_index=None,
+ direction=None,
+ ):
"""Setup an empty port
parameters
@@ -37,17 +48,20 @@ def __init__(self, name=None, properties=None, is_downto=None, is_scalar=None, l
name - (str) the name of this instance
properties - (dict) the dictionary which holds the properties
- id_downto - (bool) set the downto status. Downto is False if the right index is higher than the left one, True otherwise
- is_scalar - (bool) set the scalar status. Return True if the item is a scalar False otherwise.
+ id_downto - (bool) set the downto status. Downto is False if the right index is higher than
+ the left one, True otherwise
+ is_scalar - (bool) set the scalar status. Return True if the item is a scalar False
+ otherwise.
lower_index - (int) get the value of the lower index of the array.
- direction - (Enum) Define the possible directions for a given port. (UNDEFINED, INOUT, IN, OUT)
+ direction - (Enum) Define the possible directions for a given port. (UNDEFINED, INOUT, IN,
+ OUT)
"""
super().__init__()
self._direction = self.Direction.UNDEFINED
- self._pins = list()
+ self._pins = []
_call_create_port(self)
- if name != None:
+ if name is not None:
self.name = name
if is_downto is not None:
@@ -61,9 +75,8 @@ def __init__(self, name=None, properties=None, is_downto=None, is_scalar=None, l
if direction is not None:
self.direction = direction
- if properties != None:
- assert isinstance(
- properties, dict), "properties must be a dictionary"
+ if properties is not None:
+ assert isinstance(properties, dict), "properties must be a dictionary"
for key in properties:
self[key] = properties[key]
@@ -86,7 +99,10 @@ def direction(self, value):
parameters
----------
- value - (Port.Direction or int or str) when a Port.Direction is passed in it will set the port accordingly. when an int is passed in it will be 0: UNDEFINED, 1: INOUT, 2: IN, 3: OUT. if a string is passed in it is case insensitively compared with the names and assigned accordingly
+ value - (Port.Direction or int or str) when a Port.Direction is passed in it will set the
+ port accordingly. when an int is passed in it will be 0: UNDEFINED, 1: INOUT, 2: IN, 3: OUT.
+ if a string is passed in it is case insensitively compared with the names and assigned
+ accordingly
"""
if isinstance(value, self.Direction):
self._direction = value
@@ -103,7 +119,8 @@ def direction(self, value):
break
else:
raise TypeError(
- "Type {} cannot be assigned to direction".format(type(value)))
+ "Type {} cannot be assigned to direction".format(type(value))
+ )
@property
def pins(self):
@@ -112,8 +129,10 @@ def pins(self):
@pins.setter
def pins(self, value):
- """This function can set the pins for the port, but it can only be used to reorder the pins in the port.
- It cannot be used to add or remove pins from the port. to do this use the add_pin or remove_pin functions instead
+ """
+ This function can set the pins for the port, but it can only be used to reorder the pins
+ in the port. It cannot be used to add or remove pins from the port. to do this use the
+ add_pin or remove_pin functions instead
parameters
----------
@@ -123,8 +142,10 @@ def pins(self, value):
"""
value_list = list(value)
value_set = set(value_list)
- assert len(value_set) == len(value_list) and set(self._pins) == value_set, \
- "Set of values do not match, assignment can only be used to reorder values, values must be unique"
+ assert (
+ len(value_set) == len(value_list) and set(self._pins) == value_set
+ ), "Set of values do not match, assignment can only be used to reorder values, values \
+ must be unique"
self._pins = value_list
def create_pins(self, pin_count):
@@ -146,6 +167,7 @@ def create_pin(self):
the inner_pin created
"""
from spydrnet.ir import InnerPin as InnerPinExtended
+
pin = InnerPinExtended()
self.add_pin(pin)
if self.definition:
@@ -176,7 +198,8 @@ def add_pin(self, pin, position=None):
def remove_pin(self, pin):
"""Remove the given pin from the port.
- The pin must belong to the port in order to be removed. Wires are disconnected from the pin that is removed.
+ The pin must belong to the port in order to be removed. Wires are disconnected from the pin
+ that is removed.
parameters
----------
@@ -202,15 +225,17 @@ def remove_pins_from(self, pins):
exclude_pins = pins
else:
exclude_pins = set(pins)
- assert all(isinstance(x, InnerPin) and x.port == self for x in exclude_pins), "All pins to remove must be " \
- "InnerPins and belong to the port"
+ assert all(isinstance(x, InnerPin) and x.port == self for x in exclude_pins), (
+ "All pins to remove must be " "InnerPins and belong to the port"
+ )
for pin in exclude_pins:
self._remove_pin(pin)
self._pins = list(x for x in self._pins if x not in exclude_pins)
def _remove_pin(self, pin):
"""Internal pin removal function.
- Disconnects the wires from the pin and remvoes all the pins reference to other pins."""
+ Disconnects the wires from the pin and remvoes all the pins reference to other pins.
+ """
global_callback._call_port_remove_pin(self, pin)
if self.definition:
for reference in self.definition.references:
@@ -224,7 +249,8 @@ def _remove_pin(self, pin):
pin._port = None
def _clone_rip_and_replace(self, memo):
- """Remove from its current environment and place it into the new cloned environment with references held in the memo dictionary"""
+ """Remove from its current environment and place it into the new cloned environment with
+ references held in the memo dictionary"""
for p in self._pins:
p._clone_rip_and_replace(memo)
@@ -241,12 +267,15 @@ def _clone(self, memo):
Clone leaving all references in tact.
The element can then either be ripped or ripped and replaced.
"""
- assert self not in memo, "the object should not have been copied twice in this pass"
+ assert (
+ self not in memo
+ ), "the object should not have been copied twice in this pass"
from spydrnet.ir import Port as PortExtended
+
c = PortExtended()
memo[self] = c
c._direction = deepcopy(self._direction)
- new_pins = list()
+ new_pins = []
for p in self._pins:
new_pins.append(p._clone(memo))
c._pins = new_pins
@@ -270,14 +299,14 @@ def clone(self):
* direction, downto, is_scalar, lower_index will all be maintained
"""
- c = self._clone(dict())
+ c = self._clone({})
c._clone_rip()
return c
def __str__(self):
"""Re-define the print function so it is easier to read"""
rep = super().__str__()
- rep = rep[:-1] + '; '
+ rep = rep[:-1] + "; "
rep += str(self.direction)
- rep += '>'
- return rep
\ No newline at end of file
+ rep += ">"
+ return rep
diff --git a/spydrnet/ir/tests/test_shortcuts.py b/spydrnet/ir/tests/test_shortcuts.py
deleted file mode 100644
index 4320eb7f..00000000
--- a/spydrnet/ir/tests/test_shortcuts.py
+++ /dev/null
@@ -1,164 +0,0 @@
-import unittest
-
-
-from spydrnet.ir import FirstClassElement
-from spydrnet.ir import Instance
-from spydrnet.ir import Definition
-from spydrnet.ir import Netlist
-from spydrnet.ir import Cable
-from spydrnet.ir import Wire
-from spydrnet.util.hierarchical_reference import HRef
-from spydrnet.ir import Library
-from spydrnet.ir import Port
-
-class TestShortcuts(unittest.TestCase):
- def test_hRef_shortcut(self):
- item = Instance("myCable")
- def2 = Definition("Hello")
- item.reference = def2
- hr = HRef(item)
- self.assertEqual(hr.item.name,item.name,'Href item shorcut error')
-
-
- def test_netlist_top_instance_definition_shortcut(self):
- top_definition = Definition('this is my name')
- netlist = Netlist()
- netlist.top_instance = top_definition
- self.assertEqual(netlist.top_instance.reference.name,top_definition.name,'Netlist\'s top instance\'s shorcut error')
-
- def test_if_leaf_shortcut(self):
- instance = Instance()
- definition = Definition()
- instance.reference = definition
- self.assertEqual(definition.is_leaf(), instance.is_leaf(), 'is_leaf shortcut error')
- definition.create_cable()
- instance.reference = definition
- self.assertEqual(definition.is_leaf(), instance.is_leaf(), 'is_leaf shortcut error')
-
- def test_wire_index_shortcut(self):
- cable = Cable()
- cable.create_wires(3)
- wire = Wire()
- cable.add_wire(wire,1)
- self.assertEqual(wire.cable.wires.index(wire), wire.index(), 'wire index shorcut error')
- self.assertEqual(wire.index(), 1, 'wire index shorcut error')
- wire2 = Wire()
- cable.add_wire(wire2,3)
- self.assertEqual(wire2.cable.wires.index(wire2), wire2.index(), 'wire index shorcut error')
- self.assertEqual(wire2.index(), 3, 'wire index shorcut error')
-
- def test_name_init_shortcut(self):
- d = Definition('d_name')
- self.assertEqual(d.name, 'd_name', 'Definition name init shorcut error')
- l = Library('l_name')
- self.assertEqual(l.name, 'l_name', 'Library name init shorcut error')
- n = Netlist('n_name')
- self.assertEqual(n.name, 'n_name', 'Netlist name init shorcut error')
- i = Instance('i_name')
- self.assertEqual(i.name, 'i_name', 'Instance name init shorcut error')
- c = Cable('c_name')
- self.assertEqual(c.name, 'c_name', 'Cable name init shorcut error')
- p = Port('p_name')
- self.assertEqual(p.name, 'p_name', 'Port name init shorcut error')
-
- def test_cable_shortcut(self):
- c = Cable('c_name', None, False, True, 2)
- self.assertEqual(c.name, 'c_name', 'Cable name init shorcut error')
- self.assertEqual(c.is_downto, False, 'Cable is_downto init shorcut error')
- self.assertEqual(c.is_scalar, True, 'Cable is_scalar init shorcut error')
- self.assertEqual(c.lower_index, 2, 'Cable lower_index init shorcut error')
-
- c2 = Cable(is_scalar = False)
- self.assertEqual(c2.name, None, 'Cable name init shorcut error')
- self.assertEqual(c2.is_downto, True, 'Cable is_downto init shorcut error')
- self.assertEqual(c2.is_scalar, False, 'Cable is_scalar init shorcut error')
- self.assertEqual(c2.lower_index, 0, 'Cable lower_index init shorcut error')
-
-
- def test_port_shortcut(self):
- p = Port('p_name', None, False, True, 4)
-
- self.assertEqual(p.name, 'p_name', 'Port name init shorcut error')
- self.assertEqual(p.is_downto, False, 'Port is_downto init shorcut error')
- self.assertEqual(p.is_scalar, True, 'Port is_scalar init shorcut error')
- self.assertEqual(p.lower_index, 4, 'Port lower_index init shorcut error')
-
- p2 = Port(is_downto = False)
- self.assertEqual(p2.name, None, 'Port name init shorcut error')
- self.assertEqual(p2.is_downto, False, 'Port is_downto init shorcut error')
- self.assertEqual(p2.is_scalar, True, 'Port is_scalar init shorcut error')
- self.assertEqual(p2.lower_index, 0, 'Port lower_index init shorcut error')
-
- def test_properties_init_shortcut(self):
-
- d = Definition('d_name',{'key1':1, 'key2':'value2' })
- self.assertEqual(d['key1'], 1, 'Definition properties init shorcut error')
-
- l = Library('l_name',{'key1':'value1', 'key2':'value2' })
- self.assertEqual(l['key1'], 'value1', 'Library properties init shorcut error')
-
- n = Netlist('n_name',{'key1':'value1', 'key2': 63 })
- self.assertEqual(n['key2'], 63, 'Netlist properties init shorcut error')
-
- i = Instance('i_name',{'key1':'value1', 'key2':'value2' })
- self.assertEqual(i['key1'], 'value1', 'Instance properties init shorcut error')
-
- c = Cable('c_name',{'key1':'value1', 'key2':'value2' })
- self.assertEqual(c['key2'], 'value2', 'Cable properties init shorcut error')
-
- p = Port('p_name',{'key1':'value1', 'key2':'value2' })
- self.assertEqual(p['key1'], 'value1', 'Port properties init shorcut error')
-
- def test_library_child_instance_creation(self):
- l = Library('l_name',{'key1':'value1', 'key2':'value2' })
- self.assertEqual(l['key1'], 'value1', 'Library properties init shorcut error')
-
- l.create_definition("l_d_name", {'key1': 50, 'key2':'value2' })
- self.assertEqual('l_d_name', l.definitions[0].name, 'library\'s definition cretion shorcut error')
- self.assertEqual(l.definitions[0]['key1'], 50, 'library\'s definition cretion shorcut error')
-
- l2 = Library()
- l2.create_definition(properties = {'key1': 50, 'key2':'value2' })
- self.assertEqual(l2.definitions[0]['key1'], 50, 'library\'s definition cretion shorcut error')
-
- def test_definition_child_instance_creation(self):
- d = Definition('d_name',{'key1':1, 'key2':'value2' })
- self.assertEqual(d['key1'], 1, 'Definition properties init shorcut error')
-
- d.create_port('p_name')
- self.assertEqual(d.ports[0].name, 'p_name', 'Port name init shorcut error')
- d.create_port(properties = {'key1':'value1', 'key2':'value2' })
- self.assertEqual(d.ports[1]['key1'], 'value1', 'Port properties init shorcut error')
-
- d.create_port(properties = {'key1':'value1', 'key2':'value2' })
- self.assertEqual(d.ports[1]['key1'], 'value1', 'Port properties init shorcut error')
-
- d.create_child('d_c_name', {'key1':1, 'key2':'value2' })
- self.assertEqual(d.children[0]['key1'], 1, 'Definition properties init shorcut error')
- self.assertEqual(d['key1'], 1, 'Definition properties init shorcut error')
-
- d.create_cable('c_name', None, False, True, 2)
- self.assertEqual(d.cables[0].name, 'c_name', 'Cable name init shorcut error')
- self.assertEqual(d.cables[0].is_downto, False, 'Cable is_downto init shorcut error')
- self.assertEqual(d.cables[0].is_scalar, True, 'Cable is_scalar init shorcut error')
- self.assertEqual(d.cables[0].lower_index, 2, 'Cable lower_index init shorcut error')
-
- d.create_cable(is_scalar = False)
- self.assertEqual(d.cables[1].name, None, 'Cable name init shorcut error')
- self.assertEqual(d.cables[1].is_downto, True, 'Cable is_downto init shorcut error')
- self.assertEqual(d.cables[1].is_scalar, False, 'Cable is_scalar init shorcut error')
- self.assertEqual(d.cables[1].lower_index, 0, 'Cable lower_index init shorcut error')
-
- def test_netlist_child_instance_creation(self):
- n = Netlist('n_name')
- self.assertEqual(n.name, 'n_name', 'Netlist name init shorcut error')
- n.create_library('l_name',{'key1':'value1', 'key2':'value2' })
- self.assertEqual(n.libraries[0]['key1'], 'value1', 'Library properties init shorcut error')
-
-
-
-
-
-
-
-
diff --git a/spydrnet/ir/views/dictview.py b/spydrnet/ir/views/dictview.py
index 31b2d432..681bcd5f 100644
--- a/spydrnet/ir/views/dictview.py
+++ b/spydrnet/ir/views/dictview.py
@@ -1,5 +1,5 @@
class DictView:
- __slots__ = ['_dict']
+ __slots__ = ["_dict"]
def __init__(self, dict_object):
self._dict = dict_object
diff --git a/spydrnet/ir/views/listview.py b/spydrnet/ir/views/listview.py
index 0bc3542a..d14becb6 100644
--- a/spydrnet/ir/views/listview.py
+++ b/spydrnet/ir/views/listview.py
@@ -1,5 +1,5 @@
class ListView:
- __slots__ = ['_list']
+ __slots__ = ["_list"]
def __init__(self, list_object):
self._list = list_object
@@ -79,4 +79,4 @@ def count(self, object):
return self._list.count(object)
def index(self, *args, **kwargs):
- return self._list.index(*args, **kwargs)
\ No newline at end of file
+ return self._list.index(*args, **kwargs)
diff --git a/spydrnet/ir/views/outerpinsview.py b/spydrnet/ir/views/outerpinsview.py
index 4cda9f4d..6f7b461e 100644
--- a/spydrnet/ir/views/outerpinsview.py
+++ b/spydrnet/ir/views/outerpinsview.py
@@ -3,7 +3,6 @@
class OuterPinsView(DictView):
-
def __init__(self, dict_object):
super().__init__(dict_object)
diff --git a/spydrnet/ir/views/setview.py b/spydrnet/ir/views/setview.py
index eaec93db..83f9f886 100644
--- a/spydrnet/ir/views/setview.py
+++ b/spydrnet/ir/views/setview.py
@@ -1,5 +1,5 @@
class SetView:
- __slots__ = ['_set']
+ __slots__ = ["_set"]
def __init__(self, set_object):
self._set = set_object
diff --git a/spydrnet/ir/views/tests/test_outerpinsview.py b/spydrnet/ir/views/tests/test_outerpinsview.py
deleted file mode 100644
index dae7eb5a..00000000
--- a/spydrnet/ir/views/tests/test_outerpinsview.py
+++ /dev/null
@@ -1,36 +0,0 @@
-import unittest
-import spydrnet as sdn
-
-
-class TestOuterPinsView(unittest.TestCase):
- def setUp(self) -> None:
- definition = sdn.Definition()
- port = definition.create_port()
- self.inner_pins = port.create_pins(10)
- self.instance = sdn.Instance()
- self.instance.reference = definition
- self.outer_pins_view = self.instance.pins
-
- def test_contains(self):
- self.assertTrue(all(x in self.outer_pins_view for x in self.inner_pins))
- self.assertTrue(all(sdn.OuterPin(self.instance, x) in self.outer_pins_view for x in self.inner_pins))
-
- def test_equal(self):
- self.assertEqual(self.outer_pins_view, dict(map(lambda x: (x, sdn.OuterPin(self.instance, x)),
- self.inner_pins)))
-
- def test_getitem(self):
- self.assertTrue(all(self.outer_pins_view[x] == sdn.OuterPin(self.instance, x) for x in self.inner_pins))
- self.assertTrue(all(self.outer_pins_view[x] is self.outer_pins_view[sdn.OuterPin(self.instance, x)] for x in
- self.inner_pins))
-
- def test_iter(self):
- self.assertTrue(all(isinstance(x, sdn.OuterPin) for x in self.outer_pins_view))
-
- def test_len(self):
- self.assertEqual(len(self.outer_pins_view), 10)
-
- def test_get(self):
- self.assertEqual(self.outer_pins_view.get(self.inner_pins[0]), sdn.OuterPin(self.instance, self.inner_pins[0]))
- self.assertEqual(self.outer_pins_view.get(sdn.OuterPin(self.instance, self.inner_pins[0])),
- sdn.OuterPin(self.instance, self.inner_pins[0]))
diff --git a/spydrnet/ir/wire.py b/spydrnet/ir/wire.py
index 5f029167..e1df642f 100644
--- a/spydrnet/ir/wire.py
+++ b/spydrnet/ir/wire.py
@@ -10,11 +10,12 @@ class Wire(Element):
"""
Represents a wire object
"""
- __slots__ = ['_cable', '_pins']
+
+ __slots__ = ["_cable", "_pins"]
def __init__(self):
self._cable = None
- self._pins = list()
+ self._pins = []
@property
def cable(self):
@@ -30,8 +31,10 @@ def pins(self):
def pins(self, value):
value_list = list(value)
value_set = set(value_list)
- assert len(value_list) == len(value_set) and set(self._pins) == value_set, \
- "Set of values do not match, assignment can only be used to reorder, values must be unique"
+ assert (
+ len(value_list) == len(value_set) and set(self._pins) == value_set
+ ), "Set of values do not match, assignment can only be used to reorder, values \
+ must be unique"
self._pins = value_list
def connect_pin(self, pin, position=None):
@@ -46,8 +49,9 @@ def connect_pin(self, pin, position=None):
if isinstance(pin, OuterPin):
instance = pin.instance
inner_pin = pin.inner_pin
- assert instance is not None and inner_pin is not None, \
- "Outer pin must represent an instance and an inner_pin"
+ assert (
+ instance is not None and inner_pin is not None
+ ), "Outer pin must represent an instance and an inner_pin"
assert inner_pin in instance.pins, "Pin not associated with instance"
outer_pin = instance.pins[inner_pin]
assert outer_pin.wire is not self, "Pin already connected to this wire"
@@ -73,11 +77,14 @@ def disconnect_pin(self, pin):
if isinstance(pin, OuterPin):
instance = pin.instance
inner_pin = pin.inner_pin
- assert instance is not None and inner_pin is not None, \
- "Outer pin must represent an instance and an inner_pin"
+ assert (
+ instance is not None and inner_pin is not None
+ ), "Outer pin must represent an instance and an inner_pin"
assert inner_pin in instance.pins, "Pin not associated with instance"
outer_pin = instance.pins[inner_pin]
- assert outer_pin.wire is self, "Pin is disconnected or connected to a different wire."
+ assert (
+ outer_pin.wire is self
+ ), "Pin is disconnected or connected to a different wire."
self._disconnect_pin(pin)
pin = outer_pin
else:
@@ -102,16 +109,22 @@ def disconnect_pins_from(self, pins):
if isinstance(pin, OuterPin):
instance = pin.instance
inner_pin = pin.inner_pin
- if instance is None or inner_pin is None or inner_pin not in instance.pins or \
- instance.pins[inner_pin].wire is not self:
+ if (
+ instance is None
+ or inner_pin is None
+ or inner_pin not in instance.pins
+ or instance.pins[inner_pin].wire is not self
+ ):
all_pins_can_be_disconnected = False
break
else:
if pin.wire != self:
all_pins_can_be_disconnected = False
break
- assert all_pins_can_be_disconnected, "Some of the pins to disconnect are not associated with an instance, " \
- "already disconnected, or connected to a different wire"
+ assert all_pins_can_be_disconnected, (
+ "Some of the pins to disconnect are not associated with an instance, "
+ "already disconnected, or connected to a different wire"
+ )
for pin in excluded_pins:
if isinstance(pin, OuterPin):
self._disconnect_pin(pin)
@@ -124,8 +137,9 @@ def _disconnect_pin(self, pin):
pin._wire = None
def _clone_rip_and_replace(self, memo):
- """Remove from its current environment and place it into the new cloned environment with references held in the memo dictionary"""
- new_pins = list()
+ """Remove from its current environment and place it into the new cloned environment with
+ references held in the memo dictionary"""
+ new_pins = []
for p in self._pins:
assert p in memo, "the pin must be cloned"
new_pins.append(memo[p])
@@ -136,7 +150,7 @@ def _clone_rip(self):
"""Remove from its current environmnet.
This will remove all pin pointers and create a floating stand alone instance."""
- self._pins = list()
+ self._pins = []
pass
def _clone(self, memo):
@@ -144,8 +158,11 @@ def _clone(self, memo):
clone leaving all references in tact.
the element can then either be ripped or ripped and replaced"""
- assert self not in memo, "the object should not have been copied twice in this pass"
+ assert (
+ self not in memo
+ ), "the object should not have been copied twice in this pass"
from spydrnet.ir import Wire as ExtendedWire
+
c = ExtendedWire()
memo[self] = c
c._cable = None
@@ -160,8 +177,8 @@ def clone(self):
* The wire is not connected to any pins.
* The wire is orphaned from any cable.
* No pins are connected to the wire
- """
- c = self._clone(dict())
+ """
+ c = self._clone({})
c._clone_rip()
return c
@@ -175,20 +192,25 @@ def index(self):
def __str__(self):
"""Re-define the print function so it is easier to read"""
rep = str(type(self))
- rep = rep[:-1] + '; '
+ rep = rep[:-1] + "; "
if self.cable is None:
- rep += 'Not contained by any Cable'
+ rep += "Not contained by any Cable"
elif self.cable.name is None:
- rep += 'Contained by Cable whose name is undefined'
+ rep += "Contained by Cable whose name is undefined"
else:
- rep += 'Contained by Cable.name \'' + str(self.cable.name) + '\' ' + str(self.cable)
- rep += '>'
+ rep += (
+ "Contained by Cable.name '"
+ + str(self.cable.name)
+ + "' "
+ + str(self.cable)
+ )
+ rep += ">"
return rep
def get_driver(self):
- '''
+ """
returns the driver(s) of the wire
- '''
+ """
drivers = []
for pin in self._pins:
if pin.__class__ is sdn.InnerPin:
diff --git a/spydrnet/parsers/__init__.py b/spydrnet/parsers/__init__.py
index 9e32110b..52539151 100644
--- a/spydrnet/parsers/__init__.py
+++ b/spydrnet/parsers/__init__.py
@@ -10,14 +10,16 @@
def parse(filename, architecture=None):
"""
- The parse function is able to parse an EDIF (.edf) file, a Verilog file (.v), or an EBLIF file (.eblif).
+ The parse function is able to parse an EDIF (.edf) file, a Verilog file (.v), or an EBLIF file
+ (.eblif).
This functions also supports the parsing of .zip files. Such as the ones in support_files folder
Returns
-------
Netlist
- The netlist that comes as the result of the parsing of the file if the file was parsed successfully
+ The netlist that comes as the result of the parsing of the file if the file was parsed
+ successfully
Examples
--------
@@ -37,38 +39,44 @@ def parse(filename, architecture=None):
"""
basename_less_final_extension = Path(filename).stem
- extension = get_lowercase_extension(filename)
+ extension = get_lowercase_extension(filename)
if extension == ".zip":
- assert zipfile.is_zipfile(filename), \
- "Input filename {} with extension .zip is not a zip file.".format(
- basename_less_final_extension)
+ assert zipfile.is_zipfile(
+ filename
+ ), "Input filename {} with extension .zip is not a zip file.".format(
+ basename_less_final_extension
+ )
with tempfile.TemporaryDirectory() as tempdirname:
with zipfile.ZipFile(filename) as zip:
files = zip.namelist()
- assert len(files) == 1 and files[0] == basename_less_final_extension, \
- "Only single file archives allowed with a file whose name matches the name of the archive"
+ assert (
+ len(files) == 1 and files[0] == basename_less_final_extension
+ ), "Only single file archives allowed with a file whose name matches \
+ the name of the archive"
zip.extract(basename_less_final_extension, tempdirname)
# filename = Path(tempdirname).joinpath(basename_less_final_extension)
filename = Path(tempdirname, basename_less_final_extension)
return _parse(filename, architecture)
-
- return _parse(filename, architecture)
+
+ return _parse(filename, architecture)
-def _parse(filename, architecture=None):
+def _parse(filename, architecture):
extension = get_lowercase_extension(filename)
if extension in [".edf", ".edif", ".edn"]:
from spydrnet.parsers.edif.parser import EdifParser
parser = EdifParser.from_filename(filename)
elif extension in [".v", ".vh", ".vm"]:
from spydrnet.parsers.verilog.parser import VerilogParser
+
parser = VerilogParser.from_filename(filename)
- elif extension in [".eblif",".blif"]:
+ elif extension in [".eblif", ".blif"]:
from spydrnet.parsers.eblif.eblif_parser import EBLIFParser
+
parser = EBLIFParser.from_filename(filename)
else:
raise RuntimeError("Extension {} not recognized.".format(extension))
- parser.parse()
+ parser.parse()
if architecture:
read_primitive_library(architecture, parser.netlist)
@@ -82,13 +90,17 @@ def get_lowercase_extension(filename):
extension_lower = extension.lower()
return extension_lower
+
def read_primitive_library(architecture, netlist):
from spydrnet.parsers.primitive_library_reader import PrimitiveLibraryReader
+
reader = PrimitiveLibraryReader(architecture, netlist)
reader.run()
+
def set_eblif_names(netlist):
from spydrnet.parsers.eblif.eblif_parser import EBLIFParser
+
eblif_parser = EBLIFParser()
eblif_parser.netlist = netlist
- eblif_parser.set_subcircuit_names_by_convention()
\ No newline at end of file
+ eblif_parser.set_subcircuit_names_by_convention()
diff --git a/spydrnet/parsers/eblif/eblif_parser.py b/spydrnet/parsers/eblif/eblif_parser.py
index 1db1c7c4..4ee97fdf 100644
--- a/spydrnet/parsers/eblif/eblif_parser.py
+++ b/spydrnet/parsers/eblif/eblif_parser.py
@@ -8,6 +8,7 @@
from spydrnet.ir import Wire
from spydrnet.util.selection import Selection
+
class EBLIFParser:
"""
Parse BLIF and EBLIF files into SpyDrNet
@@ -15,15 +16,15 @@ class EBLIFParser:
"""
class BlackboxHolder:
- '''this is an internal class that helps manage
- modules that are instanced before they are declared'''
+ """this is an internal class that helps manage
+ modules that are instanced before they are declared"""
def __init__(self):
self.name_lookup = {}
self.defined = set()
def get_blackbox(self, name):
- '''creates or returns the black box based on the name'''
+ """creates or returns the black box based on the name"""
if name in self.name_lookup:
return self.name_lookup[name]
else:
@@ -33,11 +34,11 @@ def get_blackbox(self, name):
return definition
def define(self, name):
- '''adds the name to the defined set'''
+ """adds the name to the defined set"""
self.defined.add(self.name_lookup[name])
def get_undefined_blackboxes(self):
- '''return an iterable of all undefined blackboxes'''
+ """return an iterable of all undefined blackboxes"""
undef = set()
for v in self.name_lookup.values():
if v not in self.defined:
@@ -72,14 +73,14 @@ def __init__(self):
self.work = None
self.blackbox_holder = self.BlackboxHolder()
- def createTokenizer(self):
+ def create_tokenizer(self):
self.tokenizer = Tokenizer(self.file_name)
#######################################################
# parse functions
#######################################################
def parse(self):
- self.createTokenizer()
+ self.create_tokenizer()
self.parse_eblif()
return self.netlist
@@ -94,8 +95,7 @@ def parse_eblif(self):
self.parse_comment()
elif token == et.MODEL:
self.parse_model()
- else:
- None
+
self.set_subcircuit_names_by_convention()
self.insert_comments_into_netlist_data()
self.add_blackbox_definitions()
@@ -128,8 +128,7 @@ def parse_model_helper(self, model_name):
is_blackbox = True
elif token == et.END:
break
- else:
- None
+
if is_blackbox:
self.primitives.add_definition(model)
else:
@@ -144,7 +143,7 @@ def parse_model_header(self, model_name):
self.netlist.set_top_instance(parent_instance)
self.netlist.name = model_def.name
self.current_model = model_def
- self.tokenizer.next() # should be end of line so proceed to next line
+ self.tokenizer.next() # should be end of line so proceed to next line
self.parse_model_ports()
def parse_model_ports(self):
@@ -166,11 +165,11 @@ def parse_input_ports(self):
port = self.create_model_port(sdn.Port.Direction.IN, port_name)
self.current_model.add_port(port)
else:
- port.direction=sdn.IN
- while len(port.pins) < index+1:
+ port.direction = sdn.IN
+ while len(port.pins) < index + 1:
port.create_pin()
pin = port.pins[index]
- self.connect_pin_to_wire(pin,port_name,index)
+ self.connect_pin_to_wire(pin, port_name, index)
self.tokenizer.next()
def parse_output_ports(self):
@@ -184,16 +183,19 @@ def parse_output_ports(self):
if not port:
port = self.create_model_port(sdn.Port.Direction.OUT, port_name)
self.current_model.add_port(port)
- if port.direction in {sdn.IN, sdn.INOUT}: # it's an input port and now an output, so it's inout
+ if port.direction in {
+ sdn.IN,
+ sdn.INOUT,
+ }: # it's an input port and now an output, so it's inout
port.direction = sdn.INOUT
is_inout = True
else:
port.direction = sdn.OUT
- while len(port.pins) < index+1:
+ while len(port.pins) < index + 1:
port.create_pin()
pin = port.pins[index]
if not is_inout:
- self.connect_pin_to_wire(pin,port_name,index)
+ self.connect_pin_to_wire(pin, port_name, index)
self.tokenizer.next()
def create_model_port(self, port_direction, port_name):
@@ -217,9 +219,11 @@ def connect_pin_to_wire(self, pin, cable_name, wire_index):
cable = next(self.current_model.get_cables(cable_name), None)
if not cable:
cable = self.current_model.create_cable(name=cable_name)
- while (len(cable.wires)-1) < wire_index: # add wires to cable until we get the right index
+ while (
+ len(cable.wires) - 1
+ ) < wire_index: # add wires to cable until we get the right index
wire = Wire()
- cable.add_wire(wire,wire_index)
+ cable.add_wire(wire, wire_index)
wire = cable.wires[wire_index]
wire.connect_pin(pin)
@@ -254,12 +258,13 @@ def parse_subcircuit_port(self, definition):
port = definition.create_port(name=name)
if index > (len(port.pins) - 1):
pin = InnerPin()
- port.add_pin(pin,index)
- self.current_instance_info[port_name_and_index] = token[equal_index+1:]
+ port.add_pin(pin, index)
+ self.current_instance_info[port_name_and_index] = token[equal_index + 1 :]
def check_hierarchy(self, child_definition_name):
if child_definition_name == self.netlist.top_instance.reference.name:
- # print(self.current_definition.name + " is instancing the current top instance (" + name+ " which is a "+ self.netlist.top_instance.reference.name+")")
+ # print(self.current_definition.name + " is instancing the current top instance (" + \
+ # name+ " which is a "+ self.netlist.top_instance.reference.name+")")
old_top_instance = self.netlist.top_instance
new_level = self.current_model
# we know the current top is not right. So now we can move it up a level.
@@ -280,54 +285,66 @@ def check_hierarchy(self, child_definition_name):
self.netlist.top_instance.reference = new_level
self.netlist.name = new_level.name
- # this instance should just go away. It was created to be the top instance but we don't want that
- # it has no parent. And now with no reference, it should have no ties to the netlist.
+ # this instance should just go away. It was created to be the top instance but we don't
+ # want that it has no parent. And now with no reference, it should have no ties to the
+ # netlist.
old_top_instance.reference = None
- def connect_instance_pins(self,instance):
+ def connect_instance_pins(self, instance):
for key, cable_info in self.current_instance_info.items():
# cable_info = self.current_instance_info[key]
- cable_name, cable_index = self.get_port_name_and_index(cable_info) # get connected cable name and wire index
- port_name, pin_index = self.get_port_name_and_index(key) # get own port name and pin index
+ cable_name, cable_index = self.get_port_name_and_index(cable_info) # get connected cable name and wire index
+ port_name, pin_index = self.get_port_name_and_index(key) # get own port name and pin index
if cable_name == et.UNCONN: # intentionally disconnected so put that into metadata
try:
instance[et.UNCONN]
except KeyError:
instance[et.UNCONN] = []
- instance[et.UNCONN].append(port_name+"["+str(pin_index)+"]")
+ instance[et.UNCONN].append(port_name + "[" + str(pin_index) + "]")
continue
port = next(instance.get_ports(port_name))
- while len(port.pins) < (pin_index+1): # multibit port that isn't yet multibit
+ while len(port.pins) < (pin_index + 1): # multibit port that isn't yet multibit
port.create_pin()
- pin = next(instance.get_pins(selection=Selection.OUTSIDE, filter=lambda x: x.inner_pin.port.name == port_name and x.inner_pin is x.inner_pin.port.pins[pin_index]))
+ pin = next(
+ instance.get_pins(
+ selection=Selection.OUTSIDE,
+ filter=lambda x: x.inner_pin.port.name == port_name
+ and x.inner_pin is x.inner_pin.port.pins[pin_index],
+ )
+ )
self.connect_pin_to_wire(pin, cable_name, cable_index)
def parse_comment(self):
token = self.tokenizer.next()
comment = ""
while token is not et.NEW_LINE:
- comment+=token+" "
+ comment += token + " "
token = self.tokenizer.next()
self.comments.append(comment)
def insert_comments_into_netlist_data(self):
self.netlist["EBLIF.comment"] = self.comments
- def get_port_name_and_index(self,string):
- index_specified = (string[-1] == "]")
+ def get_port_name_and_index(self, string):
+ index_specified = string[-1] == "]"
if index_specified:
open_bracket = string.rfind("[")
if open_bracket == -1:
return string, 0
else:
- close_bracket = string.find("]",open_bracket)
+ close_bracket = string.find("]", open_bracket)
name = string[:open_bracket]
- index = string[open_bracket+1:close_bracket]
+ index = string[open_bracket + 1 : close_bracket]
if ":" in index:
old_index = index
- index = index[:index.find(':')]
- print("EBLIFParser: Index was: " + old_index + ". To avoid an error, it was changed to " + index)
+ index = index[: index.find(":")]
+ print(
+ "EBLIFParser: Index was: "
+ + old_index
+ + ". To avoid an error, it was changed to "
+ + index
+ )
return name, int(index)
else:
return string, 0
@@ -337,7 +354,7 @@ def assign_instance_a_default_name(self, instance):
index = 0
if name in self.default_names.keys():
index = self.default_names[name] + 1
- self.default_names[name]+=1
+ self.default_names[name] += 1
else:
index = 0
self.default_names[name] = 0
@@ -393,19 +410,21 @@ def parse_name(self):
port_nets.append(self.tokenizer.token)
self.tokenizer.next()
single_output_covers = []
- while (self.check_if_init_values(self.tokenizer.peek())): # make sure next token is init values
- single_output_cover=self.tokenizer.next()
- single_output_cover+=" "
+ while self.check_if_init_values(
+ self.tokenizer.peek()
+ ): # make sure next token is init values
+ single_output_cover = self.tokenizer.next()
+ single_output_cover += " "
possible_next = self.tokenizer.next()
if possible_next != et.NEW_LINE:
- single_output_cover+=possible_next
+ single_output_cover += possible_next
self.tokenizer.next()
single_output_covers.append(single_output_cover)
# then make/get def called logic-gate_# where # is the # of ports-1
- name = "logic-gate_"+str(len(port_nets)-1)
+ name = "logic-gate_" + str(len(port_nets) - 1)
definition = self.blackbox_holder.get_blackbox(name)
- for i in range(len(port_nets)-1):
+ for i in range(len(port_nets) - 1):
port_name = "in_" + str(i)
port = next(definition.get_ports(port_name), None)
if not port:
@@ -420,18 +439,19 @@ def parse_name(self):
instance["EBLIF.output_covers"] = single_output_covers
instance["EBLIF.type"] = "EBLIF.names"
- for port, net in zip(definition.get_ports(),port_nets):
+ for port, net in zip(definition.get_ports(), port_nets):
self.current_instance_info[port.name] = net
- if "unconn" in port_nets[len(port_nets)-1]:
+ if "unconn" in port_nets[len(port_nets) - 1]:
self.assign_instance_a_default_name(instance)
else:
- instance.name = port_nets[len(port_nets)-1] # by convention, the name of the instance is the name of the driven net
+ # by convention, the name of the instance is the name of the driven net
+ instance.name = port_nets[len(port_nets) - 1]
self.connect_instance_pins(instance)
self.parse_instance_info()
- def check_if_init_values(self,string):
- allowed = {'1','0','-'}
+ def check_if_init_values(self, string):
+ allowed = {"1", "0", "-"}
for char in string:
if char not in allowed:
return False
@@ -445,20 +465,20 @@ def create_names_port(self, name, direction):
def parse_latch(self):
self.current_instance_info.clear()
- self.tokenizer.next() # first collect the information
- port_order = ["input","output","type","control","init-val"]
+ self.tokenizer.next() # first collect the information
+ port_order = ["input", "output", "type", "control", "init-val"]
token_list = []
port_info = {}
while self.tokenizer.token is not et.NEW_LINE:
token_list.append(self.tokenizer.token)
self.tokenizer.next()
- for order, token in zip(port_order,token_list):
+ for order, token in zip(port_order, token_list):
port_info[order] = token
name = "generic-latch"
definition = self.blackbox_holder.get_blackbox(name)
if len(definition.ports) == 0:
- for order in port_info.keys() :
+ for order in port_info.keys():
if order == "output":
port = self.create_names_port(order, Port.Direction.OUT)
definition.add_port(port)
@@ -468,7 +488,7 @@ def parse_latch(self):
# create an instance of it
instance = self.current_model.create_child(reference=definition)
- instance.name = port_info["output"] # by convention, the latch name is the name of the net it drives
+ instance.name = port_info["output"] # by convention, the latch name is the name of the net it drives
self.current_instance = instance
instance["EBLIF.type"] = "EBLIF.latch"
@@ -483,7 +503,9 @@ def parse_conn(self):
cable_two_info = self.tokenizer.next()
cable_one_name, cable_one_index = self.get_port_name_and_index(cable_one_info)
cable_two_name, cable_two_index = self.get_port_name_and_index(cable_two_info)
- wire_one, wire_two = self.get_connected_wires(cable_one_name, cable_one_index, cable_two_name, cable_two_index)
+ wire_one, wire_two = self.get_connected_wires(
+ cable_one_name, cable_one_index, cable_two_name, cable_two_index
+ )
self.merge_wires(wire_one, wire_two)
def get_connected_wires(self, cable_one_name, index_one, cable_two_name, index_two):
@@ -522,20 +544,26 @@ def merge_wires(self, wire_one, wire_two):
new_wire.connect_pin(pin)
wire_two.cable.remove_wire(wire_two)
- def set_subcircuit_names_by_convention(self): # by convention, the instance names are defined by the net they drive
+ def set_subcircuit_names_by_convention(self):
+ """
+ by convention, the instance names are defined by the net they drive
+ """
for instance in self.netlist.get_instances():
if instance["EBLIF.type"] not in ["EBLIF.subckt", "EBLIF.gate"]:
continue
if "EBLIF.cname" in instance.data:
continue
- iterator = instance.get_pins(selection=Selection.OUTSIDE, filter=lambda x: x.inner_pin.port.direction is sdn.OUT)
+ iterator = instance.get_pins(
+ selection=Selection.OUTSIDE,
+ filter=lambda x: x.inner_pin.port.direction is sdn.OUT,
+ )
while True:
pin = next(iterator, None)
if pin:
if pin.wire:
name = pin.wire.cable.name
if len(pin.wire.cable.wires) > 1:
- name+="_"+str(pin.wire.cable.wires.index(pin.wire))
+ name += "_" + str(pin.wire.cable.wires.index(pin.wire))
instance.name = name
break
else:
diff --git a/spydrnet/parsers/eblif/eblif_tokenizer.py b/spydrnet/parsers/eblif/eblif_tokenizer.py
index 4da5729d..8093c813 100644
--- a/spydrnet/parsers/eblif/eblif_tokenizer.py
+++ b/spydrnet/parsers/eblif/eblif_tokenizer.py
@@ -1,10 +1,8 @@
import io
-import re
import zipfile
-import io
-import os
-from spydrnet.parsers.eblif.eblif_tokens import BACKSLASH
from pathlib import Path
+from spydrnet.parsers.eblif.eblif_tokens import BACKSLASH
+
class Tokenizer:
@staticmethod
@@ -23,24 +21,24 @@ def from_filename(filename):
tokenizer = Tokenizer(filename)
return tokenizer
- def __init__(self,input_source):
+ def __init__(self, input_source):
# self.file = file
self.token = None
self.next_token = None
self.line_number = 0
- self.current_line_tokens = list()
+ self.current_line_tokens = []
if isinstance(input_source, str):
if zipfile.is_zipfile(input_source):
- zip = zipfile.ZipFile(input_source)
+ zipped = zipfile.ZipFile(input_source)
filename = Path(input_source).name
- filename = filename[:filename.rindex(".")]
- stream = zip.open(filename)
+ filename = filename[: filename.rindex(".")]
+ stream = zipped.open(filename)
stream = io.TextIOWrapper(stream)
self.input_stream = stream
else:
- self.input_stream = open(input_source, 'r')
+ self.input_stream = open(input_source, "r")
elif isinstance(input_source, Path):
- self.input_stream = open(input_source,"r")
+ self.input_stream = open(input_source, "r")
else:
if isinstance(input_source, io.TextIOBase) is False:
self.input_stream = io.TextIOWrapper(input_source)
@@ -48,15 +46,15 @@ def __init__(self,input_source):
self.input_stream = input_source
self.generator = self.generate_tokens()
-
+
def generate_tokens(self):
- # with open(file) as file:
- for line in self.input_stream:
- self.current_line_tokens.clear()
+ # with open(file) as file:
+ for line in self.input_stream:
+ self.current_line_tokens.clear()
for word in line.split():
self.current_line_tokens.append(word)
yield word
- self.line_number+=1
+ self.line_number += 1
yield "\n"
def has_next(self):
@@ -72,22 +70,17 @@ def next(self):
self.next_token = None
else:
self.token = next(self.generator)
- # print(self.token)
- if (self.token is BACKSLASH):
- # print("BACKSLASH!!!!")
- # print("Token is " + self.token)
+ if self.token is BACKSLASH:
self.next()
- # print("Token is " + self.token)
self.next()
- # print("Token is " + self.token)
return self.token
def peek(self):
if self.next_token:
return self.next_token
- else:
- self.next_token = next(self.generator)
- return self.next_token
+
+ self.next_token = next(self.generator)
+ return self.next_token
def expect(self, other):
if not self.token_equals(other):
@@ -103,10 +96,10 @@ def token_equals(self, other):
def equals(self, this, that):
if this == that:
return True
- else:
- lowercase_this = this.lower()
- if lowercase_this == that:
- return True
- elif lowercase_this == that.lower():
- return True
- return False
\ No newline at end of file
+
+ lowercase_this = this.lower()
+ if lowercase_this == that:
+ return True
+ if lowercase_this == that.lower():
+ return True
+ return False
diff --git a/spydrnet/parsers/eblif/eblif_tokens.py b/spydrnet/parsers/eblif/eblif_tokens.py
index 32c0d89b..6bdcdddc 100644
--- a/spydrnet/parsers/eblif/eblif_tokens.py
+++ b/spydrnet/parsers/eblif/eblif_tokens.py
@@ -17,5 +17,5 @@
PARAM = ".param"
SUBCIRCUIT = ".subckt"
TRUE_WIRE = "$true"
-UNDEF_WIRE= "$undef"
-UNCONN = "unconn"
\ No newline at end of file
+UNDEF_WIRE = "$undef"
+UNCONN = "unconn"
diff --git a/spydrnet/parsers/eblif/tests/test_eblif_parser.py b/spydrnet/parsers/eblif/tests/test_eblif_parser.py
deleted file mode 100644
index 1f9f1373..00000000
--- a/spydrnet/parsers/eblif/tests/test_eblif_parser.py
+++ /dev/null
@@ -1,70 +0,0 @@
-import unittest
-import spydrnet as sdn
-from spydrnet import base_dir
-from spydrnet.util.selection import Selection
-from pathlib import Path
-
-"""
-Test the EBLIFParser by parsing in a simple netlist and making sure that:
- - Everything is there
- - Everything is working together as a netlist as it should (to be sure things were created and placed in the netlist correctly)
-"""
-class TestEBLIFParser(unittest.TestCase):
- def setUp(self):
- self.netlist = sdn.parse(Path(base_dir, 'support_files', 'eblif_netlists', "toggle.eblif.zip"))
- self.definition_list = ["INV","BUFG","FDRE","IBUF","OBUF","toggle", "logic-gate_0"]
-
- def test_name(self):
- self.assertEqual(self.netlist.name,"toggle")
-
- def test_definitions(self):
- count = 0
- for definition in self.netlist.get_definitions():
- self.assertTrue(definition.name in self.definition_list, definition.name + " not found in list")
- count+=1
- self.assertEqual(count,len(self.definition_list))
-
- def test_instances(self):
- self.assertEqual(self.netlist.top_instance.name,"toggle")
- for instance in self.netlist.get_instances():
- self.assertTrue(instance.reference.name in self.definition_list)
- self.assertTrue(self.netlist_is_own_netlist(instance))
- if "logic-gate_0" in instance.reference.name:
- self.assertEqual(instance["EBLIF.type"],"EBLIF.names")
- else:
- self.assertEqual(instance["EBLIF.type"],"EBLIF.subckt")
-
- def test_top_level_ports(self):
- input_port_list = ["clk","reset"]
- output_port_list = ["out"]
- for port in self.netlist.get_hports():
- if port.item.direction is sdn.IN:
- self.assertTrue(port.item.name in input_port_list,port.item.name+" is not in "+str(input_port_list))
- self.assertTrue(self.netlist_is_own_netlist(port))
- elif port.item.direction is sdn.OUT:
- self.assertTrue(port.item.name in output_port_list,port.item.name+" is not in "+str(output_port_list))
- self.assertTrue(self.netlist_is_own_netlist(port))
-
- def test_cables(self):
- count = 0
- for cable in self.netlist.get_cables():
- self.assertTrue(self.netlist_is_own_netlist(cable))
- count+=1
- self.assertEqual(count, 11)
-
- def netlist_is_own_netlist(self,object):
- netlist_list = list(x for x in object.get_netlists())
- if (self.netlist in netlist_list):
- return True
- return False
-
- def test_flip_flop_connections(self):
- instance = next(self.netlist.get_instances(filter=lambda x: x.reference.name == "FDRE"))
- pin_connections = {"C":"clk"}
- for input_pin in instance.get_pins(selection=Selection.OUTSIDE,filter=lambda x: x.inner_pin.port.direction is sdn.IN):
- self.assertTrue(input_pin.wire is not None, input_pin.inner_pin.port.name + " does not have a wire")
- # driver_pin = next(pin for pin in input_pin.wire.pins)
- # get the driver
- # make sure it's the right driver
-
- # TODO add wire and connections tests
diff --git a/spydrnet/parsers/edif/edif_tokens.py b/spydrnet/parsers/edif/edif_tokens.py
index 4b485dae..7b4188f5 100644
--- a/spydrnet/parsers/edif/edif_tokens.py
+++ b/spydrnet/parsers/edif/edif_tokens.py
@@ -1,109 +1,109 @@
-ARRAY = 'array'
-AUTHOR = 'author'
-BEHAVIOR = 'behavior'
-BOOLEAN = 'boolean'
-CELL = 'cell'
-CELL_REF = 'cellref'
-CELL_TYPE = 'celltype'
-COMMENT = 'comment'
-CONTENTS = 'contents'
-DATA_ORIGIN = 'dataorigin'
-DESIGN = 'design'
-DIRECTION = 'direction'
-DOCUMENT = 'document'
-E = 'e'
-EDIF = 'edif'
-EDIF_VERSION = 'edifversion'
-EDIF_LEVEL = 'ediflevel'
-EXTERNAL = 'external'
-FALSE = 'false'
-GENERIC = 'generic'
-GRAPHIC = 'graphic'
-INOUT = 'inout'
-INPUT = 'input'
-INSTANCE = 'instance'
-INSTANCE_REF = 'instanceref'
-INTEGER = 'integer'
-INTERFACE = 'interface'
-KEYWORD_MAP = 'keywordmap'
-KEYWORD_LEVEL = 'keywordlevel'
-LEFT_PAREN = '('
-LIBRARY = 'library'
-LIBRARY_REF = 'libraryref'
-LOGICMODEL = 'logicmodel'
-MASKLAYOUT = 'masklayout'
-MEMBER = 'member'
-METAX = 'metax'
-NET = 'net'
-NETLIST = 'netlist'
-OUTPUT = 'output'
-OWNER = 'owner'
-PCBLAYOUT = 'netlist'
-PORT = 'port'
-PORT_REF = 'portref'
-PROGRAM = 'program'
-PROPERTY = 'property'
-NUMBER = 'number'
-NUMBER_DEFINITION = 'numberdefinition'
-RENAME = 'rename'
-RIGHT_PAREN = ')'
-RIPPER = 'ripper'
-SCHEMATIC = 'schematic'
-STATUS = 'status'
-STRANGER = 'stranger'
-STRING = 'string'
-SYMBOLIC = 'symbolic'
-TECHNOLOGY = 'technology'
-TIE = 'tie'
-TIME_STAMP = 'timestamp'
-TRUE = 'true'
-UNIT = 'unit'
-USER_DATA = 'userdata'
-VERSION = 'version'
-VIEW = 'view'
-VIEW_MAP = 'viewmap'
-VIEW_REF = 'viewref'
-VIEW_TYPE = 'viewtype'
-WRITTEN = 'written'
+ARRAY = "array"
+AUTHOR = "author"
+BEHAVIOR = "behavior"
+BOOLEAN = "boolean"
+CELL = "cell"
+CELL_REF = "cellref"
+CELL_TYPE = "celltype"
+COMMENT = "comment"
+CONTENTS = "contents"
+DATA_ORIGIN = "dataorigin"
+DESIGN = "design"
+DIRECTION = "direction"
+DOCUMENT = "document"
+E = "e"
+EDIF = "edif"
+EDIF_VERSION = "edifversion"
+EDIF_LEVEL = "ediflevel"
+EXTERNAL = "external"
+FALSE = "false"
+GENERIC = "generic"
+GRAPHIC = "graphic"
+INOUT = "inout"
+INPUT = "input"
+INSTANCE = "instance"
+INSTANCE_REF = "instanceref"
+INTEGER = "integer"
+INTERFACE = "interface"
+KEYWORD_MAP = "keywordmap"
+KEYWORD_LEVEL = "keywordlevel"
+LEFT_PAREN = "("
+LIBRARY = "library"
+LIBRARY_REF = "libraryref"
+LOGICMODEL = "logicmodel"
+MASKLAYOUT = "masklayout"
+MEMBER = "member"
+METAX = "metax"
+NET = "net"
+NETLIST = "netlist"
+OUTPUT = "output"
+OWNER = "owner"
+PCBLAYOUT = "netlist"
+PORT = "port"
+PORT_REF = "portref"
+PROGRAM = "program"
+PROPERTY = "property"
+NUMBER = "number"
+NUMBER_DEFINITION = "numberdefinition"
+RENAME = "rename"
+RIGHT_PAREN = ")"
+RIPPER = "ripper"
+SCHEMATIC = "schematic"
+STATUS = "status"
+STRANGER = "stranger"
+STRING = "string"
+SYMBOLIC = "symbolic"
+TECHNOLOGY = "technology"
+TIE = "tie"
+TIME_STAMP = "timestamp"
+TRUE = "true"
+UNIT = "unit"
+USER_DATA = "userdata"
+VERSION = "version"
+VIEW = "view"
+VIEW_MAP = "viewmap"
+VIEW_REF = "viewref"
+VIEW_TYPE = "viewtype"
+WRITTEN = "written"
-ARRAY_RELATED_INFO = 'arrayrelatedinfo'
-DESIGNATOR = 'designator'
-PORT_BUNDLE = 'portbundle'
-PROTECTION_FRAME = 'protectionframe'
-SYMBOL = 'symbol'
-PARAMETER = 'parameter'
-JOINED = 'joined'
-MUST_JOIN = 'mustjoin'
-WEAK_JOINED = 'weakjoined'
-PERMUTABLE = 'permutable'
-TIMING = 'timing'
-SIMULATE = 'simulate'
-WEAK_JOINED = 'weakjoined'
+ARRAY_RELATED_INFO = "arrayrelatedinfo"
+DESIGNATOR = "designator"
+PORT_BUNDLE = "portbundle"
+PROTECTION_FRAME = "protectionframe"
+SYMBOL = "symbol"
+PARAMETER = "parameter"
+JOINED = "joined"
+MUST_JOIN = "mustjoin"
+WEAK_JOINED = "weakjoined"
+PERMUTABLE = "permutable"
+TIMING = "timing"
+SIMULATE = "simulate"
+WEAK_JOINED = "weakjoined"
-UNUSED = 'unused'
-DC_FANIN_LOAD = 'dc_fanin_load'
-DC_FANOUT_LOAD = 'dc_fanout_load'
-DC_MAX_FANIN = 'dc_max_fanout'
-DC_MAX_FANOUT = 'dc_max_fanin'
-AC_LOAD = 'ac_load'
-PORT_DELAY = 'port_delay'
+UNUSED = "unused"
+DC_FANIN_LOAD = "dc_fanin_load"
+DC_FANOUT_LOAD = "dc_fanout_load"
+DC_MAX_FANIN = "dc_max_fanout"
+DC_MAX_FANOUT = "dc_max_fanin"
+AC_LOAD = "ac_load"
+PORT_DELAY = "port_delay"
-OFF_PAGE_CONNECTOR = 'offpageconnector'
-FIGURE = 'figure'
-SECTION = 'section'
-NET_BUNDLE = 'netbundle'
-PAGE = 'page'
-COMMENT_GRAPHICS = 'commentgraphics'
-PORT_IMPLEMENTATION = 'portimplementation'
-WHEN = 'when'
-FOLLOW = 'follow'
-LOGIC_PORT = 'logicport'
-BOUNDING_BOX = 'boundingbox'
+OFF_PAGE_CONNECTOR = "offpageconnector"
+FIGURE = "figure"
+SECTION = "section"
+NET_BUNDLE = "netbundle"
+PAGE = "page"
+COMMENT_GRAPHICS = "commentgraphics"
+PORT_IMPLEMENTATION = "portimplementation"
+WHEN = "when"
+FOLLOW = "follow"
+LOGIC_PORT = "logicport"
+BOUNDING_BOX = "boundingbox"
-VIEW_LIST = 'viewlist'
+VIEW_LIST = "viewlist"
-PORT_LIST = 'portlist'
-GLOBAL_PORT_REF = 'globalportref'
+PORT_LIST = "portlist"
+GLOBAL_PORT_REF = "globalportref"
-POINT = 'point'
-MI_NO_MAX = 'minomax'
\ No newline at end of file
+POINT = "point"
+MI_NO_MAX = "minomax"
diff --git a/spydrnet/parsers/edif/parser.py b/spydrnet/parsers/edif/parser.py
index c8e3e146..23f19da5 100644
--- a/spydrnet/parsers/edif/parser.py
+++ b/spydrnet/parsers/edif/parser.py
@@ -1,11 +1,11 @@
+from functools import reduce
+import re
+
from spydrnet.parsers.edif.tokenizer import EdifTokenizer
from spydrnet.parsers.edif.edif_tokens import *
from spydrnet.ir import Netlist, Library, Definition, Port, Cable, Instance
from spydrnet.plugins import namespace_manager
-from functools import reduce
-import re
-
class EdifParser:
def parse_construct(self, construct_parser):
@@ -27,10 +27,10 @@ def from_file_handle(file_handle):
return parser
def __init__(self):
- self.edif_identifier_namespace = dict() # class -> object -> subclass -> identifier -> object
+ self.edif_identifier_namespace = {} # class -> object -> subclass -> identifier -> object
self.filename = None
self.file_handle = None
- self.elements = list()
+ self.elements = []
self.tokenizer = None
def parse(self):
@@ -63,7 +63,7 @@ def parse_header(self):
def parse_edifVersion(self):
self.expect(EDIF_VERSION)
- self.prefix_append('edifVersion')
+ self.prefix_append("edifVersion")
version_0 = self.parse_integerToken()
version_1 = self.parse_integerToken()
version_2 = self.parse_integerToken()
@@ -72,7 +72,7 @@ def parse_edifVersion(self):
def parse_edifLevel(self):
self.expect(EDIF_LEVEL)
- self.prefix_append('edifLevel')
+ self.prefix_append("edifLevel")
level = self.parse_integerToken()
if level != 0:
self.set_attribute(level)
@@ -80,7 +80,7 @@ def parse_edifLevel(self):
def parse_keywordMap(self):
self.expect(KEYWORD_MAP)
- self.prefix_append('keywordMap')
+ self.prefix_append("keywordMap")
self.parse_construct(self.parse_keywordLevel)
while self.begin_construct():
@@ -89,7 +89,7 @@ def parse_keywordMap(self):
def parse_keywordLevel(self):
self.expect(KEYWORD_LEVEL)
- self.prefix_append('keywordLevel')
+ self.prefix_append("keywordLevel")
level = self.parse_integerToken()
if level != 0:
self.set_attribute(level)
@@ -117,12 +117,14 @@ def parse_body(self):
elif self.construct_is(USER_DATA):
self.parse_userData()
else:
- self.expect("|".join([STATUS, EXTERNAL, LIBRARY, DESIGN, COMMENT, USER_DATA]))
+ self.expect(
+ "|".join([STATUS, EXTERNAL, LIBRARY, DESIGN, COMMENT, USER_DATA])
+ )
self.expect_end_construct()
def parse_status(self):
self.expect(STATUS)
- self.prefix_append('status')
+ self.prefix_append("status")
while self.begin_construct():
if self.construct_is(WRITTEN):
self.parse_written()
@@ -137,7 +139,7 @@ def parse_status(self):
def parse_written(self):
self.expect(WRITTEN)
- self.prefix_append('written')
+ self.prefix_append("written")
self.parse_construct(self.parse_timeStamp)
has_author = False
@@ -164,13 +166,25 @@ def parse_written(self):
elif self.construct_is(USER_DATA):
self.parse_userData()
else:
- self.expect("|".join([AUTHOR, PROGRAM, DATA_ORIGIN, PROPERTY, METAX, COMMENT, USER_DATA]))
+ self.expect(
+ "|".join(
+ [
+ AUTHOR,
+ PROGRAM,
+ DATA_ORIGIN,
+ PROPERTY,
+ METAX,
+ COMMENT,
+ USER_DATA,
+ ]
+ )
+ )
self.expect_end_construct()
self.prefix_pop()
def parse_timeStamp(self):
self.expect(TIME_STAMP)
- self.prefix_append('timeStamp')
+ self.prefix_append("timeStamp")
year = self.parse_integerToken()
month = self.parse_integerToken()
day = self.parse_integerToken()
@@ -182,20 +196,20 @@ def parse_timeStamp(self):
def parse_author(self):
self.expect(AUTHOR)
- self.prefix_append('author')
+ self.prefix_append("author")
author = self.parse_stringToken()
self.set_attribute(author)
self.prefix_pop()
def parse_program(self):
self.expect(PROGRAM)
- self.prefix_append('program')
+ self.prefix_append("program")
program = self.parse_stringToken()
self.set_attribute(program)
if self.begin_construct():
self.expect(VERSION)
- self.prefix_append('version')
+ self.prefix_append("version")
version = self.parse_stringToken()
self.set_attribute(version)
self.prefix_pop()
@@ -213,7 +227,7 @@ def parse_external(self):
def parse_library_like_element(self, is_external=False):
library = Library()
if is_external:
- library['EDIF.external'] = True
+ library["EDIF.external"] = True
self.append_new_element(library)
self.parse_nameDef()
@@ -234,7 +248,7 @@ def parse_library_like_element(self, is_external=False):
library.add_definition(definition)
except ValueError as e:
name = definition.name
- identifier = definition['EDIF.identifier']
+ identifier = definition["EDIF.identifier"]
if name != identifier:
try:
definition.name = identifier
@@ -291,7 +305,9 @@ def parse_cell(self):
elif self.construct_is(USER_DATA):
self.parse_userData()
else:
- self.expect('|'.join([STATUS, VIEW, VIEW_MAP, PROPERTY, COMMENT, USER_DATA]))
+ self.expect(
+ "|".join([STATUS, VIEW, VIEW_MAP, PROPERTY, COMMENT, USER_DATA])
+ )
self.expect_end_construct()
return self.pop_element()
@@ -299,9 +315,11 @@ def parse_cell(self):
def parse_cellType(self):
self.expect(CELL_TYPE)
self.prefix_append("cellType")
- if self.construct_is(GENERIC) \
- or self.construct_is(TIE) \
- or self.construct_is(RIPPER):
+ if (
+ self.construct_is(GENERIC)
+ or self.construct_is(TIE)
+ or self.construct_is(RIPPER)
+ ):
if not self.tokenizer.token_equals(GENERIC):
self.set_attribute(self.tokenizer.token)
else:
@@ -311,7 +329,7 @@ def parse_cellType(self):
def parse_view(self):
self.expect(VIEW)
- self.prefix_append('view')
+ self.prefix_append("view")
self.parse_nameDef()
self.parse_construct(self.parse_viewType)
self.parse_construct(self.parse_interface)
@@ -334,29 +352,44 @@ def parse_view(self):
elif self.construct_is(USER_DATA):
self.parse_userData()
else:
- self.expect('|'.join([STATUS, CONTENTS, COMMENT, PROPERTY, USER_DATA]))
+ self.expect("|".join([STATUS, CONTENTS, COMMENT, PROPERTY, USER_DATA]))
self.expect_end_construct()
self.prefix_pop()
def parse_viewType(self):
- self.prefix_append('viewType')
+ self.prefix_append("viewType")
self.expect(VIEW_TYPE)
- if self.construct_is(BEHAVIOR) \
- or self.construct_is(DOCUMENT) \
- or self.construct_is(GRAPHIC) \
- or self.construct_is(LOGICMODEL) \
- or self.construct_is(MASKLAYOUT) \
- or self.construct_is(NETLIST) \
- or self.construct_is(PCBLAYOUT) \
- or self.construct_is(SCHEMATIC) \
- or self.construct_is(STRANGER) \
- or self.construct_is(SYMBOLIC):
+ if (
+ self.construct_is(BEHAVIOR)
+ or self.construct_is(DOCUMENT)
+ or self.construct_is(GRAPHIC)
+ or self.construct_is(LOGICMODEL)
+ or self.construct_is(MASKLAYOUT)
+ or self.construct_is(NETLIST)
+ or self.construct_is(PCBLAYOUT)
+ or self.construct_is(SCHEMATIC)
+ or self.construct_is(STRANGER)
+ or self.construct_is(SYMBOLIC)
+ ):
if not self.tokenizer.token_equals(NETLIST):
self.set_attribute(self.tokenizer.token)
else:
- self.expect("|".join(
- [BEHAVIOR, DOCUMENT, GRAPHIC, LOGICMODEL, MASKLAYOUT, NETLIST, PCBLAYOUT, SCHEMATIC, STRANGER,
- SYMBOLIC]))
+ self.expect(
+ "|".join(
+ [
+ BEHAVIOR,
+ DOCUMENT,
+ GRAPHIC,
+ LOGICMODEL,
+ MASKLAYOUT,
+ NETLIST,
+ PCBLAYOUT,
+ SCHEMATIC,
+ STRANGER,
+ SYMBOLIC,
+ ]
+ )
+ )
self.tokenizer.next()
self.prefix_pop()
@@ -403,7 +436,7 @@ def parse_interface(self):
elif self.construct_is(USER_DATA):
self.parse_userData()
else:
- self.expect('|'.join([PORT, PROPERTY, COMMENT, USER_DATA]))
+ self.expect("|".join([PORT, PROPERTY, COMMENT, USER_DATA]))
self.expect_end_construct()
def parse_designator(self):
@@ -425,9 +458,10 @@ def parse_port(self):
port = self.elements[-1]
port.create_pins(pin_count)
port.is_array = True
- if 'EDIF.original_identifier' in port:
- # TODO: what about multi-dimensional ports, non-downto ports, and when non-square brackets are used <0:17><31:0>
- original_identifier = port['EDIF.original_identifier']
+ if "EDIF.original_identifier" in port:
+ # TODO: what about multi-dimensional ports, non-downto ports, and when
+ # non-square brackets are used <0:17><31:0>
+ original_identifier = port["EDIF.original_identifier"]
match = re.match(r".*\[(\d+):(\d+)\]", original_identifier)
if match:
left_index = int(match.group(1))
@@ -435,7 +469,7 @@ def parse_port(self):
port.lower_index = min(right_index, left_index)
else:
- self.expect('|'.join([RENAME, ARRAY]))
+ self.expect("|".join([RENAME, ARRAY]))
self.expect_end_construct()
else:
self.parse_nameDef()
@@ -475,7 +509,7 @@ def parse_port(self):
elif self.construct_is(USER_DATA):
self.parse_userData()
else:
- self.expect('|'.join([DIRECTION, PROPERTY, COMMENT, USER_DATA]))
+ self.expect("|".join([DIRECTION, PROPERTY, COMMENT, USER_DATA]))
self.expect_end_construct()
return self.elements.pop()
@@ -497,7 +531,7 @@ def parse_direction(self):
elif self.construct_is(OUTPUT):
direction = Port.Direction.OUT
else:
- self.expect('|'.join([INOUT, INPUT, OUTPUT]))
+ self.expect("|".join([INOUT, INPUT, OUTPUT]))
self.tokenizer.next()
return direction
@@ -512,7 +546,7 @@ def parse_contents(self):
definition.add_child(instance)
except ValueError as e:
name = instance.name
- identifier = instance['EDIF.identifier']
+ identifier = instance["EDIF.identifier"]
if name != identifier:
try:
instance.name = identifier
@@ -535,9 +569,15 @@ def parse_contents(self):
self.multibit_add_cable(definition, cable)
except ValueError as e:
# TODO: Add warning about merging nets together
- existing_cable = next(definition.get_cables(cable.name, key="EDIF.identifier"), None)
+ existing_cable = next(
+ definition.get_cables(cable.name, key="EDIF.identifier"), None
+ )
if existing_cable is None:
- existing_cable = next(definition.get_cables(cable['EDIF.identifier'], key="EDIF.identifier"))
+ existing_cable = next(
+ definition.get_cables(
+ cable["EDIF.identifier"], key="EDIF.identifier"
+ )
+ )
for existing_wire, pending_wire in zip(existing_cable.wires, cable.wires):
pins = list(pending_wire.pins)
pending_wire.disconnect_pins_from(pins)
@@ -578,7 +618,7 @@ def parse_contents(self):
elif self.construct_is(USER_DATA):
self.parse_userData()
else:
- self.expect('|'.join([INSTANCE, NET, COMMENT, USER_DATA]))
+ self.expect("|".join([INSTANCE, NET, COMMENT, USER_DATA]))
self.expect_end_construct()
def parse_instance(self):
@@ -605,50 +645,68 @@ def parse_instance(self):
elif self.construct_is(USER_DATA):
self.parse_userData()
else:
- self.expect('|'.join([PROPERTY, COMMENT, USER_DATA]))
+ self.expect("|".join([PROPERTY, COMMENT, USER_DATA]))
self.expect_end_construct()
return self.pop_element()
def parse_viewRef(self):
- self.prefix_append('viewRef')
+ self.prefix_append("viewRef")
self.expect(VIEW_REF)
self.parse_nameRef()
- view_identifier = self.elements[-1].pop('EDIF.viewRef.identifier')
+ view_identifier = self.elements[-1].pop("EDIF.viewRef.identifier")
definition = self.elements[-2]
if self.begin_construct():
definition = self.parse_cellRef()
self.expect_end_construct()
- if definition['EDIF.view.identifier'].lower() != view_identifier.lower():
- raise RuntimeError("Parser error, non-existant view referenced on line {}, revieved {} expected {}".format(
- self.tokenizer.line_number, view_identifier, definition['EDIF.view.identifier']
- ))
+ if definition["EDIF.view.identifier"].lower() != view_identifier.lower():
+ raise RuntimeError(
+ "Parser error, non-existant view referenced on line {}, \
+ revieved {} expected {}".format(
+ self.tokenizer.line_number,
+ view_identifier,
+ definition["EDIF.view.identifier"],
+ )
+ )
self.prefix_pop()
return definition
def parse_cellRef(self):
- self.prefix_append('cellRef')
+ self.prefix_append("cellRef")
self.expect(CELL_REF)
self.parse_nameRef()
- definition_identifer = self.elements[-1].pop('EDIF.viewRef.cellRef.identifier')
+ definition_identifer = self.elements[-1].pop("EDIF.viewRef.cellRef.identifier")
library = self.elements[-3]
if self.begin_construct():
library = self.parse_libraryRef()
self.expect_end_construct()
- definition = next(library.get_definitions(definition_identifer, key="EDIF.identifier"), None)
- assert definition is not None, "Definition not found within library by EDIF identifier. definition: " + definition_identifer + ' in ' + library.name
+ definition = next(
+ library.get_definitions(definition_identifer, key="EDIF.identifier"), None
+ )
+ assert definition is not None, (
+ "Definition not found within library by EDIF identifier. definition: "
+ + definition_identifer
+ + " in "
+ + library.name
+ )
self.prefix_pop()
return definition
def parse_libraryRef(self):
- self.prefix_append('libraryRef')
+ self.prefix_append("libraryRef")
self.expect(LIBRARY_REF)
self.parse_nameRef()
- library_identifier = self.elements[-1].pop('EDIF.viewRef.cellRef.libraryRef.identifier')
+ library_identifier = self.elements[-1].pop("EDIF.viewRef.cellRef.libraryRef.identifier")
environment = self.elements[-4]
library = self.elements[-3]
- if library['EDIF.identifier'].lower() != library_identifier.lower():
- library = next(environment.get_libraries(library_identifier, key="EDIF.identifier"), None)
- assert library is not None, "Library not found within netlist by EDIF identifier " + library_identifier
+ if library["EDIF.identifier"].lower() != library_identifier.lower():
+ library = next(
+ environment.get_libraries(library_identifier, key="EDIF.identifier"),
+ None,
+ )
+ assert library is not None, (
+ "Library not found within netlist by EDIF identifier "
+ + library_identifier
+ )
self.prefix_pop()
return library
@@ -668,7 +726,7 @@ def parse_net(self):
elif self.construct_is(USER_DATA):
self.parse_userData()
else:
- self.expect('|'.join([PROPERTY, COMMENT, USER_DATA]))
+ self.expect("|".join([PROPERTY, COMMENT, USER_DATA]))
self.expect_end_construct()
return self.pop_element()
@@ -688,13 +746,13 @@ def parse_joined(self):
self.expect_end_construct()
def parse_portRef(self):
- self.prefix_append('portRef')
+ self.prefix_append("portRef")
self.expect(PORT_REF)
index = 0
instance_or_definition = self.elements[-2]
if self.begin_construct():
indicies = self.parse_member()
- assert (len(indicies) == 1)
+ assert len(indicies) == 1
index = indicies[0]
self.expect_end_construct()
else:
@@ -708,22 +766,33 @@ def parse_portRef(self):
elif self.construct_is(VIEW_REF):
raise NotImplementedError()
self.expect_end_construct()
- port_identifier = self.elements[-1].pop('EDIF.portRef.identifier')
+ port_identifier = self.elements[-1].pop("EDIF.portRef.identifier")
if isinstance(instance_or_definition, Instance):
definition = instance_or_definition.reference
- port = next(definition.get_ports(port_identifier, key="EDIF.identifier"), None)
- assert port is not None, "Port not found within definition by EDIF identifier"
+ port = next(
+ definition.get_ports(port_identifier, key="EDIF.identifier"), None
+ )
+ assert (
+ port is not None
+ ), "Port not found within definition by EDIF identifier"
inner_pin = port.pins[index]
pin = instance_or_definition.pins[inner_pin]
else:
- port = next(instance_or_definition.get_ports(port_identifier, key="EDIF.identifier"), None)
- assert port is not None, "Port not found within instance or definition by EDIF identifier"
+ port = next(
+ instance_or_definition.get_ports(
+ port_identifier, key="EDIF.identifier"
+ ),
+ None,
+ )
+ assert (
+ port is not None
+ ), "Port not found within instance or definition by EDIF identifier"
pin = port.pins[index]
self.prefix_pop()
return pin
def parse_instanceRef(self):
- self.prefix_append('instanceRef')
+ self.prefix_append("instanceRef")
definition = self.elements[-2]
self.expect(INSTANCE_REF)
if self.begin_construct():
@@ -732,9 +801,15 @@ def parse_instanceRef(self):
self.expect_end_construct()
else:
self.parse_nameRef()
- instance_identifier = self.elements[-1].pop('EDIF.portRef.instanceRef.identifier')
- instance = next(definition.get_instances(instance_identifier, key="EDIF.identifier"), None)
- assert instance is not None, "Instance not found within definition by EDIF identifier"
+ instance_identifier = self.elements[-1].pop(
+ "EDIF.portRef.instanceRef.identifier"
+ )
+ instance = next(
+ definition.get_instances(instance_identifier, key="EDIF.identifier"), None
+ )
+ assert (
+ instance is not None
+ ), "Instance not found within definition by EDIF identifier"
self.prefix_pop()
return instance
@@ -755,14 +830,14 @@ def parse_design(self):
self.expect(DESIGN)
# self.tokenizer.next()
instance = Instance()
- instance['metadata_prefix'] = list()
+ instance["metadata_prefix"] = []
self.elements.append(instance)
- instance['metadata_prefix'] = ['EDIF']
+ instance["metadata_prefix"] = ["EDIF"]
if self.begin_construct():
self.parse_rename()
self.tokenizer.next()
else:
- self.prefix_append('identifier')
+ self.prefix_append("identifier")
self.set_attribute(self.parse_identifier())
self.prefix_pop()
self.prefix_pop()
@@ -773,10 +848,10 @@ def parse_design(self):
self.tokenizer.next()
library_name = self.tokenizer.next()
for library in self.elements[0].libraries:
- if library['EDIF.identifier'] == library_name:
+ if library["EDIF.identifier"] == library_name:
break
for definition in library.definitions:
- if definition['EDIF.identifier'] == definition_name:
+ if definition["EDIF.identifier"] == definition_name:
break
instance.reference = definition
self.elements.pop()
@@ -792,9 +867,9 @@ def parse_userData(self):
raise NotImplementedError()
def parse_comment(self):
- self.prefix_append('comments')
+ self.prefix_append("comments")
self.expect(COMMENT)
- comment = list()
+ comment = []
while self.not_end_construct():
comment.append(self.parse_stringToken())
comment = (*comment,)
@@ -802,29 +877,33 @@ def parse_comment(self):
self.prefix_pop()
def parse_property(self):
- self.prefix_append('properties')
+ self.prefix_append("properties")
self.expect(PROPERTY)
self.parse_property_like_element()
def parse_metax(self):
- self.prefix_append('metaxes')
+ self.prefix_append("metaxes")
self.expect(METAX)
self.parse_property_like_element()
def parse_property_like_element(self):
self.parse_nameDef()
- property_ = dict()
- identifier = self.elements[-1].pop('.'.join([*self.elements[-1]['metadata_prefix'], 'identifier']))
- property_['identifier'] = identifier
+ property_ = {}
+ identifier = self.elements[-1].pop(
+ ".".join([*self.elements[-1]["metadata_prefix"], "identifier"])
+ )
+ property_["identifier"] = identifier
- original_identifier_prefix = '.'.join([*self.elements[-1]['metadata_prefix'], 'original_identifier'])
+ original_identifier_prefix = ".".join(
+ [*self.elements[-1]["metadata_prefix"], "original_identifier"]
+ )
if original_identifier_prefix in self.elements[-1]:
original_identifier = self.elements[-1].pop(original_identifier_prefix)
- property_['original_identifier'] = original_identifier
+ property_["original_identifier"] = original_identifier
value = self.parse_construct(self.parse_typedValue)
- property_['value'] = value
+ property_["value"] = value
self.append_attribute(property_)
@@ -849,18 +928,17 @@ def parse_property_like_element(self):
def parse_typedValue(self):
if self.construct_is(BOOLEAN):
return self.parse_boolean()
- elif self.construct_is(INTEGER):
+ if self.construct_is(INTEGER):
return self.parse_integer()
- elif self.construct_is(MI_NO_MAX):
+ if self.construct_is(MI_NO_MAX):
raise NotImplementedError()
- elif self.construct_is(NUMBER):
+ if self.construct_is(NUMBER):
return self.parse_number()
- elif self.construct_is(POINT):
+ if self.construct_is(POINT):
raise NotImplementedError()
- elif self.construct_is(STRING):
+ if self.construct_is(STRING):
return self.parse_string()
- else:
- return self.expect('|'.join([BOOLEAN, INTEGER, NUMBER, STRING]))
+ return self.expect("|".join([BOOLEAN, INTEGER, NUMBER, STRING]))
def parse_boolean(self):
self.expect(BOOLEAN)
@@ -871,7 +949,7 @@ def parse_boolean(self):
elif self.tokenizer.token_equals(FALSE):
result = False
else:
- self.expect('|'.join([TRUE, FALSE]))
+ self.expect("|".join([TRUE, FALSE]))
self.expect_end_construct()
return result
@@ -892,7 +970,7 @@ def parse_e(self):
self.expect(E)
mantissa = self.parse_integerToken()
exponent = self.parse_integerToken()
- result = mantissa * 10.0 ** exponent
+ result = mantissa * 10.0**exponent
return result
def parse_string(self):
@@ -907,7 +985,7 @@ def parse_unit(self):
raise NotImplementedError()
def parse_nameRef(self):
- self.prefix_append('identifier')
+ self.prefix_append("identifier")
self.set_attribute(self.parse_identifier())
self.prefix_pop()
@@ -916,7 +994,7 @@ def parse_nameDef(self):
self.parse_rename()
self.expect_end_construct()
else:
- self.prefix_append('identifier')
+ self.prefix_append("identifier")
self.set_attribute(self.parse_identifier())
self.prefix_pop()
@@ -926,17 +1004,19 @@ def multibit_add_cable(self, definition, cable):
e_index, e_short = self.separate_name_and_index(c_edif_id, "_")
n_index, n_short = self.separate_name_and_index(c_name, "[")
-
+
index = n_index
- if e_index == None:
+ if e_index is None:
index = None
existing_cable = next(definition.get_cables(n_short), None)
- if existing_cable == None: #maybe the name is in the EDIF.identifier only?
- existing_cable = next(definition.get_cables(e_short, key="EDIF.identifier"), None)
- if existing_cable is None: #if it is still none after checking both the name and EDIF.identifier...
+ if existing_cable is None: # maybe the name is in the EDIF.identifier only?
+ existing_cable = next(
+ definition.get_cables(e_short, key="EDIF.identifier"), None
+ )
+ if existing_cable is None: # if it is still none after checking both the name and EDIF.identifier...
if index is None:
- cable.is_array = False
+ cable.is_array = False
cable.lower_index = 0
else:
cable.is_array = True
@@ -946,10 +1026,10 @@ def multibit_add_cable(self, definition, cable):
cable.lower_index = index
definition.add_cable(cable)
- else: #there is alread a cable that could need to be merged.
- if existing_cable.is_array == False or index == None:
- definition.add_cable(cable) #if this works great. otherwise the parent code will handle the error
- else: # the cables should be merged
+ else: # there is alread a cable that could need to be merged.
+ if existing_cable.is_array is False or index is None:
+ definition.add_cable(cable) # if this works great. otherwise the parent code will handle the error
+ else: # the cables should be merged
if index > existing_cable.lower_index:
if index < existing_cable.lower_index + len(existing_cable.wires):
w = cable.wires[0]
@@ -959,12 +1039,14 @@ def multibit_add_cable(self, definition, cable):
p = pins[0]
w.disconnect_pin(p)
ew.connect_pin(p)
- else: # index is outside current cable range
- existing_cable.create_wires(index - existing_cable.lower_index - len(existing_cable.wires))
+ else: # index is outside current cable range
+ existing_cable.create_wires(
+ index - existing_cable.lower_index - len(existing_cable.wires)
+ )
wire = cable.wires[0]
cable.remove_wire(wire)
existing_cable.add_wire(wire)
- else: #index is lower than the lowest current index in the cable
+ else: # index is lower than the lowest current index in the cable
difference = existing_cable.lower_index - index
starting_count = len(existing_cable.wires)
wire = cable.wires[0]
@@ -972,44 +1054,57 @@ def multibit_add_cable(self, definition, cable):
existing_cable.add_wire(wire)
existing_cable.create_wires(difference - 1)
existing_cable.lower_index = index
- wire_list = existing_cable.wires[starting_count:] + existing_cable.wires[:starting_count]
+ wire_list = (
+ existing_cable.wires[starting_count:]
+ + existing_cable.wires[:starting_count]
+ )
existing_cable.wires = wire_list
-
+
def separate_name_and_index(self, name, split_character):
name_split = name.split(split_character)
index = None
short_name = name
- if split_character == "[" and (name[0] != "\\" or (len(name.split(" ")) == 2 and name.split(" ")[1] != "")):
- if len(name_split) > 1 and name_split[-1][-1] == "]" and name_split[-1][:-1].isdigit():
+ if split_character == "[" and (
+ name[0] != "\\" or (len(name.split(" ")) == 2 and name.split(" ")[1] != "")
+ ):
+ if (
+ len(name_split) > 1
+ and name_split[-1][-1] == "]"
+ and name_split[-1][:-1].isdigit()
+ ):
index = int(name_split[-1][:-1])
for i in reversed(range(len(name))):
if name[i] == split_character:
break
short_name = name[:i]
- elif split_character == "_":# and (name[0:2] == "&_" or ():
-
+ elif split_character == "_": # and (name[0:2] == "&_" or ():
# Assuming that all names that start with a &_ map to escaped \
#
# from https://www.xilinx.com/support/answers/1554.html
#
# "When the Cadence SIR2EDF encounters escaped Verilog names (please
- # refer to (Xilinx Answer 2533)), "\L/R " is mapped by the Cadence
- # SIR2EDF netlister to "&_l_r_". The SIR2EDF netlister also creates
- # a map file, which shows that the identifier "&_l_r_" is mapped to
- # "\l/r ". Such conversions of backslashes and forward slashes may
- # be fairly common in netlists generated by NGD2VER if
- # user-specified names do not conform to Verilog naming
+ # refer to (Xilinx Answer 2533)), "\L/R " is mapped by the Cadence
+ # SIR2EDF netlister to "&_l_r_". The SIR2EDF netlister also creates
+ # a map file, which shows that the identifier "&_l_r_" is mapped to
+ # "\l/r ". Such conversions of backslashes and forward slashes may
+ # be fairly common in netlists generated by NGD2VER if
+ # user-specified names do not conform to Verilog naming
# restrictions."
#
- # Other than here we try to maintain the user supplied name and do
+ # Other than here we try to maintain the user supplied name and do
# not change characters. a name starting with &_ will simply become
- if len(name_split) > 2 and name_split[-1] == "" and name_split[-2].isdigit() and (name[0:2] != "&_" or (name_split[-3] == "")):
+ if (
+ len(name_split) > 2
+ and name_split[-1] == ""
+ and name_split[-2].isdigit()
+ and (name[0:2] != "&_" or (name_split[-3] == ""))
+ ):
index = int(name_split[-2])
count = 0
for i in reversed(range(len(name))):
if name[i] == split_character:
- count+=1
+ count += 1
if count == 2:
break
short_name = name[:i]
@@ -1018,11 +1113,11 @@ def separate_name_and_index(self, name, split_character):
def parse_rename(self):
self.expect(RENAME)
- self.prefix_append('identifier')
+ self.prefix_append("identifier")
self.set_attribute(self.parse_identifier())
self.prefix_pop()
- self.prefix_append('original_identifier')
+ self.prefix_append("original_identifier")
self.set_attribute(self.parse_stringToken())
self.prefix_pop()
@@ -1042,24 +1137,24 @@ def parse_integerToken(self):
return int(self.tokenizer.token)
def append_new_element(self, element):
- element['metadata_prefix'] = ['EDIF']
+ element["metadata_prefix"] = ["EDIF"]
self.elements.append(element)
def pop_element(self):
element = self.elements.pop()
- del element['metadata_prefix']
+ del element["metadata_prefix"]
return element
def prefix_append(self, value):
element = self.elements[-1]
- element['metadata_prefix'].append(value)
+ element["metadata_prefix"].append(value)
def prefix_pop(self):
- return self.elements[-1]['metadata_prefix'].pop()
+ return self.elements[-1]["metadata_prefix"].pop()
def set_attribute(self, value):
element = self.elements[-1]
- key = '.'.join(element['metadata_prefix'])
+ key = ".".join(element["metadata_prefix"])
if key == "EDIF.original_identifier":
element.name = value
elif key == "EDIF.identifier":
@@ -1071,9 +1166,9 @@ def set_attribute(self, value):
def append_attribute(self, attribute):
element = self.elements[-1]
- key = '.'.join(element['metadata_prefix'])
+ key = ".".join(element["metadata_prefix"])
if key not in element:
- element[key] = list()
+ element[key] = []
element[key].append(attribute)
def skip_until_next_construct(self):
@@ -1088,7 +1183,10 @@ def skip_until_next_construct(self):
def check_for_multiples(self, token, already_contains):
if already_contains:
raise RuntimeError(
- "Parse error: Multiple occurances of {}, near line {}".format(token, self.tokenizer.line_number))
+ "Parse error: Multiple occurances of {}, near line {}".format(
+ token, self.tokenizer.line_number
+ )
+ )
return True
def expect_begin_construct(self):
@@ -1121,8 +1219,10 @@ def construct_is(self, token):
return True
return False
- get_parent = {Library: lambda x: x.netlist,
- Definition: lambda x: x.library,
- Port: lambda x: x.definition,
- Cable: lambda x: x.definition,
- Instance: lambda x: x.parent}
+ get_parent = {
+ Library: lambda x: x.netlist,
+ Definition: lambda x: x.library,
+ Port: lambda x: x.definition,
+ Cable: lambda x: x.definition,
+ Instance: lambda x: x.parent,
+ }
diff --git a/spydrnet/parsers/edif/tokenizer.py b/spydrnet/parsers/edif/tokenizer.py
index ea9483ba..f1c000fd 100644
--- a/spydrnet/parsers/edif/tokenizer.py
+++ b/spydrnet/parsers/edif/tokenizer.py
@@ -38,7 +38,15 @@ def __init__(self, input_source):
else:
self.input_stream = open(input_source, "r")
elif isinstance(input_source, Path):
- self.input_stream = open(input_source,"r")
+ if zipfile.is_zipfile(input_source):
+ zip = zipfile.ZipFile(input_source)
+ filename = Path(input_source).name
+ filename = filename[: filename.rindex(".")]
+ stream = zip.open(filename)
+ stream = io.TextIOWrapper(stream)
+ self.input_stream = stream
+ else:
+ self.input_stream = open(input_source, "r")
else:
if isinstance(input_source, io.TextIOBase) is False:
self.input_stream = io.TextIOWrapper(input_source)
@@ -77,7 +85,7 @@ def generate_tokens(self):
try:
self.line_number = 1
in_quote = False
- token_buffer = list()
+ token_buffer = []
for buffer in iter(partial(self.input_stream.read, 32768), ""):
for ch in buffer:
if ch == "\n":
diff --git a/spydrnet/parsers/primatives/parse_primatives.py b/spydrnet/parsers/primatives/parse_primatives.py
index f274d3d4..78685ece 100644
--- a/spydrnet/parsers/primatives/parse_primatives.py
+++ b/spydrnet/parsers/primatives/parse_primatives.py
@@ -4,7 +4,8 @@
#See the license that accompanies SpyDrNet tools for more information
#
#Currently implemented vendors:
-#Xilinx vivado tested with and designed for files from Vivado/2019.1/data/verilog/src/xeclib (other versions should hopefully work)
+#Xilinx vivado tested with and designed for files from Vivado/2019.1/data/verilog/src/xeclib (other
+#versions should hopefully work)
#
#Future capabilities
#accept files from other locations for Xilinx
@@ -21,7 +22,8 @@ class PrimativeParser:
Parses primative libraries for use with the tools
This class is a standalone class as of the first release.
- Hopefully the xilinx part of this parser can be combined with the structural verilog parser so that they can share code
+ Hopefully the xilinx part of this parser can be combined with the structural verilog parser so
+ that they can share code
Extracts the ports, parameters, and names of primatives
The primative libraries can be found in the following location
@@ -49,7 +51,7 @@ def _vivado_parse_file(self, verilog_file):
Definition created from the verilog file
'''
if not verilog_file.endswith('.v'):
- print("File " + verilog_file + " in directory does not end with the proper extension")
+ print("File " + verilog_file + " in directory does not end with the proper extension")
with open(verilog_file) as vf:
self._vivado_parse(vf)
@@ -69,7 +71,8 @@ def _vivado_parse(self, stream):
elif statement[0] == 'parameter':
pass
elif statement[0] == 'module':
- name = statement[1] #this is lazy but I think it might work with all the xilinx verilog files for now....
+ #this is lazy but I think it might work with all xilinx verilog files for now....
+ name = statement[1]
elif statement[0] == 'input':
self._vivado_get_port_info(statement, inputs)
elif statement[0] == 'output':
@@ -79,7 +82,7 @@ def _vivado_parse(self, stream):
else:
pass
- if(VERBOSE):
+ if VERBOSE:
print("\nModule " + name)
print("Inputs:")
print(inputs)
@@ -103,7 +106,7 @@ def _vivado_get_port_info(self, line, port_container):
else:
for i in range(1,len(line)):
port_container[line[i]] = ''
-
+
def _vivado_create_definition(self, name, parameters, inputs, outputs, inouts):
definition = SpyDrNet.create_definition()
for i, val in inputs.items():
@@ -113,7 +116,7 @@ def _vivado_create_definition(self, name, parameters, inputs, outputs, inouts):
for io, val in inouts.items():
definition.add_port(self._create_port(io,val,SpyDrNet.Port.Direction.INOUT))
return definition
-
+
def _create_port(self, name, indicies, direction):
port = SpyDrNet.create_port(name = name)
port.set_direction(direction)
@@ -123,4 +126,4 @@ def _create_port(self, name, indicies, direction):
if __name__ == "__main__":
parse = PrimativeParser()
- parse.vivado_parse_xeclib("/home/dallin/Documents/byuccl/xeclib")
\ No newline at end of file
+ parse.vivado_parse_xeclib("/home/dallin/Documents/byuccl/xeclib")
diff --git a/spydrnet/parsers/primitive_library_reader.py b/spydrnet/parsers/primitive_library_reader.py
index b7585414..dc94c871 100644
--- a/spydrnet/parsers/primitive_library_reader.py
+++ b/spydrnet/parsers/primitive_library_reader.py
@@ -1,4 +1,3 @@
-import spydrnet as sdn
from spydrnet.ir import Library
from spydrnet.parsers.verilog.parser import VerilogParser
import spydrnet.parsers.verilog.verilog_tokens as vt
@@ -9,9 +8,12 @@
OUTPUT = "output"
PARAMETER = "parameter"
-class PrimitiveLibraryReader():
+
+class PrimitiveLibraryReader:
"""
- A class to extract primitive port information from a Verilog file and insert it into the netlist. The input file is parsed using the Verilog Parser and if any module information is found for a definition in the given netlist, the port information (i.e. directions) is added.
+ A class to extract primitive port information from a Verilog file and insert it into the
+ netlist. The input file is parsed using the Verilog Parser and if any module information is
+ found for a definition in the given netlist, the port information (i.e. directions) is added.
parameters
----------
@@ -22,24 +24,26 @@ class PrimitiveLibraryReader():
def __init__(self, architecture, netlist):
self.input_file = architecture
self.netlist = netlist
- self.definition_list = list()
- self.netlist_defs = dict()
- self.parsed_defs = dict()
+ self.definition_list = []
+ self.netlist_defs = {}
+ self.parsed_defs = {}
self.parser = None
-
+
def run(self):
self.initialize()
- while(self.parser.tokenizer.has_next()):
+ while self.parser.tokenizer.has_next():
self.progress_past_comments()
- self.parser.parse_primitive(definition_list=self.definition_list, bypass_name_check=True)
+ self.parser.parse_primitive(
+ definition_list=self.definition_list, bypass_name_check=True
+ )
definition = self.parser.current_definition
if definition:
self.parsed_defs[definition.name] = definition
- if len(self.parsed_defs) == len(self.netlist_defs): # found all needed information
+ if len(self.parsed_defs) == len(self.netlist_defs): # found all needed information
break
cnt = self.insert_info()
print("Found information for %d definitions" % cnt)
-
+
def initialize(self):
self.parser = VerilogParser.from_filename(self.input_file)
self.parser.initialize_tokenizer()
@@ -48,7 +52,7 @@ def initialize(self):
def progress_past_comments(self):
token = self.parser.peek_token()
- while(token != vt.MODULE and token != vt.PRIMITIVE):
+ while token != vt.MODULE and token != vt.PRIMITIVE:
# print(token)
self.parser.next_token()
token = self.parser.peek_token()
@@ -66,16 +70,16 @@ def insert_info(self):
port_dict = self.create_port_dict(match)
# print(definition.name + " " + str(port_dict))
for port in definition.get_ports():
- if port.name is None: # no port name, so assume it's the only port.
+ if port.name is None: # no port name, so assume it's the only port.
port.name = next(key for key in port_dict.keys())
# print("Port name was None so changed to " + port.name)
port.direction = port_dict[port.name]
- cnt+=1
+ cnt += 1
return cnt
def create_port_dict(self, definition):
- port_dict = dict()
+ port_dict = {}
for port in definition.get_ports():
port_dict[port.name] = port.direction
# print(port.name + " has direction " + str(port.direction))
- return port_dict
\ No newline at end of file
+ return port_dict
diff --git a/spydrnet/parsers/verilog/parser.py b/spydrnet/parsers/verilog/parser.py
index 1983ea74..d5228383 100644
--- a/spydrnet/parsers/verilog/parser.py
+++ b/spydrnet/parsers/verilog/parser.py
@@ -4,23 +4,20 @@
from spydrnet.parsers.verilog.tokenizer import VerilogTokenizer, VerilogTokenizerSimple
import spydrnet.parsers.verilog.verilog_tokens as vt
-from spydrnet.ir import Netlist, Library, Definition, Port, Cable, Instance, OuterPin
+from spydrnet.ir import Netlist, Definition, Instance, OuterPin
from spydrnet.plugins import namespace_manager
import spydrnet as sdn
-from functools import reduce
-import re
-
class VerilogParser:
- '''
+ """
Parse verilog files into spydrnet.
Higher level functions will always peek when deciding what lower level function to call.
within your own function call next instead to keep the flow moving.
the first token to expect in a function will be the token that starts that construct.
- '''
+ """
#########################################################
# Note to contributors
@@ -44,29 +41,29 @@ class VerilogParser:
#########################################################
class BlackboxHolder:
- '''this is an internal class that helps manage
- modules that are instanced before they are declared'''
+ """this is an internal class that helps manage
+ modules that are instanced before they are declared"""
def __init__(self):
- self.name_lookup = dict()
+ self.name_lookup = {}
self.defined = set()
def get_blackbox(self, name):
- '''creates or returns the black box based on the name'''
+ """creates or returns the black box based on the name"""
if name in self.name_lookup:
return self.name_lookup[name]
else:
- definition = sdn.Definition()
+ definition = Definition()
definition.name = name
self.name_lookup[name] = definition
return definition
def define(self, name):
- '''adds the name to the defined set'''
+ """adds the name to the defined set"""
self.defined.add(self.name_lookup[name])
def get_undefined_blackboxes(self):
- '''return an iterable of all undefined blackboxes'''
+ """return an iterable of all undefined blackboxes"""
undef = set()
for v in self.name_lookup.values():
if v not in self.defined:
@@ -104,27 +101,27 @@ def __init__(self):
self.blackbox_holder = self.BlackboxHolder()
- self.implicitly_mapped_ports = dict()
+ self.implicitly_mapped_ports = {}
def parse(self):
- ''' parse a verilog netlist represented by verilog file
+ """parse a verilog netlist represented by verilog file
- verilog_file can be a filename or stream
- '''
+ verilog_file can be a filename or stream
+ """
self.initialize_tokenizer()
ns_default = namespace_manager.default
namespace_manager.default = "DEFAULT"
self.parse_verilog()
namespace_manager.default = ns_default
self.tokenizer.__del__()
- return self.netlist
+ return self.netlist
def initialize_tokenizer(self):
self.tokenizer = VerilogTokenizer(self.filename)
def peek_token(self):
token = self.peek_token_remove_comments()
- if token[0] == '`':
+ if token[0] == "`":
t_split = token.split(maxsplit=1)
if len(t_split) > 1 and t_split[0] in [vt.IFDEF]:
while t_split[0] != vt.ENDIF:
@@ -133,12 +130,15 @@ def peek_token(self):
token = self.peek_token_remove_comments()
if len(t_split) > 1 and t_split[0] == vt.DEFINE:
assert False, self.error_string(
- "define not supported", "assumes all macros are undefined", vt.DEFINE)
+ "define not supported",
+ "assumes all macros are undefined",
+ vt.DEFINE,
+ )
return token
def next_token(self):
token = self.next_token_remove_comments()
- if token[0] == '`':
+ if token[0] == "`":
t_split = token.split(maxsplit=1)
if len(t_split) > 1 and t_split[0] in [vt.IFDEF]:
while t_split[0] != vt.ENDIF:
@@ -147,22 +147,29 @@ def next_token(self):
token = self.next_token_remove_comments()
if len(t_split) > 1 and t_split[0] == vt.DEFINE:
assert False, self.error_string(
- "define not supported", "assumes all macros are undefined", vt.DEFINE)
+ "define not supported",
+ "assumes all macros are undefined",
+ vt.DEFINE,
+ )
return token
def peek_token_remove_comments(self):
- '''peeks from the tokenizer this wrapper function exists to skip comment tokens'''
+ """peeks from the tokenizer this wrapper function exists to skip comment tokens"""
token = self.tokenizer.peek()
- while len(token) >= 2 and token[0] == "/" and (token[1] == "/" or token[1] == "*"):
+ while (
+ len(token) >= 2 and token[0] == "/" and (token[1] == "/" or token[1] == "*")
+ ):
# this is a comment token skip it
self.tokenizer.next()
token = self.tokenizer.peek()
return token
def next_token_remove_comments(self):
- '''peeks from the tokenizer this wrapper function exists to skip comment tokens'''
+ """peeks from the tokenizer this wrapper function exists to skip comment tokens"""
token = self.tokenizer.next()
- while len(token) >= 2 and (token[0:2] == vt.OPEN_LINE_COMMENT or token[0:2] == vt.OPEN_BLOCK_COMMENT):
+ while len(token) >= 2 and (
+ token[0:2] == vt.OPEN_LINE_COMMENT or token[0:2] == vt.OPEN_BLOCK_COMMENT
+ ):
# this is a comment token, skip it
token = self.tokenizer.next()
return token
@@ -172,14 +179,14 @@ def next_token_remove_comments(self):
#######################################################
def parse_verilog(self):
- self.netlist = sdn.Netlist()
+ self.netlist = Netlist()
self.netlist.name = "SDN_VERILOG_NETLIST"
self.work = self.netlist.create_library("work")
self.primitives = self.netlist.create_library("hdi_primitives")
self.current_library = self.work
preprocessor_defines = set()
- star_properties = dict()
+ star_properties = {}
time_scale = None
primitive_cell = False
@@ -188,12 +195,12 @@ def parse_verilog(self):
if token.split(maxsplit=1)[0] == vt.CELL_DEFINE:
primitive_cell = True
self.current_library = self.primitives
- #token = token.split(maxsplit = 1)[1]
+ # token = token.split(maxsplit = 1)[1]
token = self.next_token()
elif token.split(maxsplit=1)[0] == vt.END_CELL_DEFINE:
primitive_cell = False
self.current_library = self.work
- #token = token.split(maxsplit = 1)[1]
+ # token = token.split(maxsplit = 1)[1]
token = self.next_token()
elif token == vt.MODULE:
@@ -206,7 +213,7 @@ def parse_verilog(self):
self.current_definition["VERILOG.TimeScale"] = time_scale
if len(star_properties.keys()) > 0:
self.current_definition["VERILOG.InlineConstraints"] = star_properties
- star_properties = dict()
+ star_properties = {}
elif token == vt.PRIMITIVE:
# self.parse_primitive()
@@ -214,8 +221,8 @@ def parse_verilog(self):
# self.current_definition["VERILOG.TimeScale"] = time_scale
# if len(star_properties.keys()) > 0:
# self.current_definition["VERILOG.InlineConstraints"] = star_properties
- # star_properties = dict()
- star_properties = dict()
+ # star_properties = {}
+ star_properties = {}
while token != vt.END_PRIMITIVE:
token = self.next_token()
@@ -238,10 +245,13 @@ def parse_verilog(self):
else:
pass
assert False, self.error_string(
- "something at the top level of the file", "got unexpected token", token)
+ "something at the top level of the file",
+ "got unexpected token",
+ token,
+ )
self.add_blackbox_definitions()
-
+
self.connect_implicitly_mapped_ports()
return self.netlist
@@ -252,25 +262,29 @@ def add_blackbox_definitions(self):
d["VERILOG.primitive"] = True
self.current_library.add_definition(d)
- def parse_primitive(self, definition_list = [], bypass_name_check=False):
- '''
- similar to parse module but it will only look for the inputs and outputs to get an idea of how those things look
+ def parse_primitive(self, definition_list=[], bypass_name_check=False):
+ """
+ similar to parse module but it will only look for the inputs and outputs to get an idea of
+ how those things look
- definition_list is an optional parameter that is used by primitive_library_reader as primitive libraries are parsed. If the primitive name is not
- in the definition list, it is not needed and will be skipped.
- '''
+ definition_list is an optional parameter that is used by primitive_library_reader as
+ primitive libraries are parsed. If the primitive name is not in the definition list, it is
+ not needed and will be skipped.
+ """
token = self.next_token()
assert token == vt.MODULE or token == vt.PRIMITIVE, self.error_string(
- vt.MODULE, "to begin module statement", token)
+ vt.MODULE, "to begin module statement", token
+ )
token = self.next_token()
if not bypass_name_check:
assert vt.is_valid_identifier(token), self.error_string(
- "identifier", "not a valid module name", token)
+ "identifier", "not a valid module name", token
+ )
name = token.strip()
-
+
if definition_list:
- if name not in definition_list: # we don't need this primitive info
- while(token != vt.END_MODULE):
+ if name not in definition_list: # we don't need this primitive info
+ while token != vt.END_MODULE:
token = self.next_token()
# self.next_token()
return
@@ -286,7 +300,7 @@ def parse_primitive(self, definition_list = [], bypass_name_check=False):
self.parse_primitive_body()
def parse_primitive_body(self):
- ''' just look for port information, skip tasks and functions to help out.'''
+ """just look for port information, skip tasks and functions to help out."""
token = self.peek_token()
@@ -299,18 +313,19 @@ def parse_primitive_body(self):
while token != vt.END_TASK:
token = self.next_token()
elif token in vt.PORT_DIRECTIONS:
- self.parse_port_declaration(dict())
+ self.parse_port_declaration({})
else:
token = self.next_token()
def parse_module(self):
-
token = self.next_token()
assert token == vt.MODULE, self.error_string(
- vt.MODULE, "to begin module statement", token)
+ vt.MODULE, "to begin module statement", token
+ )
token = self.next_token()
assert vt.is_valid_identifier(token), self.error_string(
- "identifier", "not a valid module name", token)
+ "identifier", "not a valid module name", token
+ )
name = token.strip()
definition = self.blackbox_holder.get_blackbox(name)
@@ -319,7 +334,7 @@ def parse_module(self):
self.current_definition = definition
self.assignment_count = 0
if self.netlist.top_instance is None:
- self.netlist.top_instance = sdn.Instance()
+ self.netlist.top_instance = Instance()
self.netlist.top_instance.name = definition.name + "_top"
self.netlist.top_instance.reference = definition
self.netlist.name = "SDN_VERILOG_NETLIST_" + definition.name
@@ -329,7 +344,8 @@ def parse_module(self):
self.parse_module_body()
def parse_module_header(self):
- '''parse a module header and add the parameter dictionary and port list to the current_definition'''
+ """parse a module header and add the parameter dictionary and port list to the
+ current_definition"""
token = self.peek_token()
if token == "#":
self.parse_module_header_parameters()
@@ -341,42 +357,49 @@ def parse_module_header(self):
token = self.next_token()
assert token == vt.CLOSE_PARENTHESIS, self.error_string(
- vt.CLOSE_PARENTHESIS, "to end the module ports in the header", token)
+ vt.CLOSE_PARENTHESIS, "to end the module ports in the header", token
+ )
token = self.next_token()
assert token == vt.SEMI_COLON, self.error_string(
- vt.SEMI_COLON, "to end the module header section", token)
+ vt.SEMI_COLON, "to end the module header section", token
+ )
def parse_module_header_parameters(self):
- '''parse a parameter block in a module header, add all parameters to the current definition'''
+ """parse a parameter block in a module header, add all parameters to the current
+ definition"""
token = self.next_token()
assert token == vt.OCTOTHORP, self.error_string(
- vt.OCTOTHORP, "to begin parameter map", token)
+ vt.OCTOTHORP, "to begin parameter map", token
+ )
token = self.next_token()
assert token == vt.OPEN_PARENTHESIS, self.error_string(
- vt.OPEN_PARENTHESIS, "to begin parameter map", token)
+ vt.OPEN_PARENTHESIS, "to begin parameter map", token
+ )
token = self.next_token()
- parameter_dictionary = dict()
+ parameter_dictionary = {}
while token != ")":
# this is happening twice for all but the first one.. could simplify
assert token == vt.PARAMETER, self.error_string(
- vt.PARAMETER, "parameter declaration", token)
+ vt.PARAMETER, "parameter declaration", token
+ )
key = ""
token = self.peek_token()
if token == vt.OPEN_BRACKET:
left, right = self.parse_brackets()
- if right != None:
+ if right is not None:
key = "[" + str(left) + ":" + str(right) + "] "
else:
key = "[" + str(left) + "] "
token = self.next_token()
assert vt.is_valid_identifier(token), self.error_string(
- 'identifer', "in parameter list", token)
+ "identifer", "in parameter list", token
+ )
key += token.strip()
token = self.next_token()
@@ -385,7 +408,8 @@ def parse_module_header_parameters(self):
token = self.next_token()
assert token == vt.EQUAL, self.error_string(
- vt.EQUAL, "in parameter list", token)
+ vt.EQUAL, "in parameter list", token
+ )
token = self.next_token()
# not really sure what to assert here.
@@ -396,19 +420,21 @@ def parse_module_header_parameters(self):
if token == vt.COMMA: # just keep going
token = self.next_token()
assert token == vt.PARAMETER, self.error_string(
- vt.PARAMETER, "after comma in parameter map", token)
+ vt.PARAMETER, "after comma in parameter map", token
+ )
else:
assert token == vt.CLOSE_PARENTHESIS, self.error_string(
- vt.CLOSE_PARENTHESIS, "to end parameter declarations", token)
+ vt.CLOSE_PARENTHESIS, "to end parameter declarations", token
+ )
- self.set_definition_parameters(
- self.current_definition, parameter_dictionary)
+ self.set_definition_parameters(self.current_definition, parameter_dictionary)
def parse_module_header_ports(self):
- '''parse port declarations in the module header and add them to the definition'''
+ """parse port declarations in the module header and add them to the definition"""
token = self.next_token()
assert token == vt.OPEN_PARENTHESIS, self.error_string(
- vt.OPEN_PARENTHESIS, "to begin port declarations", token)
+ vt.OPEN_PARENTHESIS, "to begin port declarations", token
+ )
token = self.peek_token()
@@ -421,30 +447,36 @@ def parse_module_header_ports(self):
token = self.peek_token()
if token != vt.CLOSE_PARENTHESIS:
assert token == vt.COMMA, self.error_string(
- vt.COMMA, "to separate port declarations", token)
+ vt.COMMA, "to separate port declarations", token
+ )
token = self.next_token() # consume the comma token
token = self.peek_token() # setup the next token
def parse_module_header_port_alias(self):
- '''parse the port alias portion of the module header
- this parses the port alias section so that the port name is only a port and the mapped wires are the cables names that connect to that port.
+ """
+ parse the port alias portion of the module header
+
+ this parses the port alias section so that the port name is only a port and the mapped wires
+ are the cables names that connect to that port.
- this requires that the cables names be kept in a dictionary to allow for setting the direction when the direction is given to the internal port names.
+ this requires that the cables names be kept in a dictionary to allow for setting the
+ direction when the direction is given to the internal port names.
example syntax
- .canale({\\canale[3] ,\\canale[2] ,\\canale[1] ,\\canale[0] }),'''
-
+ .canale({\\canale[3] ,\\canale[2] ,\\canale[1] ,\\canale[0] }),"""
+
token = self.next_token()
- assert token == vt.DOT, self.error_string(
- vt.DOT, "for port aliasing", token)
+ assert token == vt.DOT, self.error_string(vt.DOT, "for port aliasing", token)
token = self.next_token()
assert vt.is_valid_identifier(token), self.error_string(
- "identifier", "for port in port aliasing", token)
+ "identifier", "for port in port aliasing", token
+ )
name = token.strip()
token = self.next_token()
assert token == vt.OPEN_PARENTHESIS, self.error_string(
- vt.OPEN_PARENTHESIS, "parethesis to enclose port aliasing", token)
+ vt.OPEN_PARENTHESIS, "parethesis to enclose port aliasing", token
+ )
token = self.peek_token()
if token == vt.OPEN_BRACE:
@@ -455,14 +487,18 @@ def parse_module_header_port_alias(self):
token = self.next_token()
assert token == vt.CLOSE_PARENTHESIS, self.error_string(
- vt.CLOSE_PARENTHESIS, "parethesis to end port aliasing construct", token)
+ vt.CLOSE_PARENTHESIS, "parethesis to end port aliasing construct", token
+ )
port = self.create_or_update_port(
- name, left_index=len(wires)-1, right_index=0)
+ name, left_index=len(wires) - 1, right_index=0
+ )
# connect the wires to the pins
assert len(port.pins) == len(
- wires), "Internal Error: the pins in a created port and the number of wires the aliased cable do not match up"
+ wires
+ ), "Internal Error: the pins in a created port and the number of wires the \
+ aliased cable do not match up"
pin_list = list(p for p in port.pins)
pin_list.sort(reverse=True, key=self.pin_sort_func)
@@ -470,25 +506,29 @@ def parse_module_header_port_alias(self):
wires[i].connect_pin(pin_list[i])
def parse_cable_concatenation(self):
- '''parse a concatenation structure of cables, create the cables mentioned, and deal with indicies
- return a list of ordered wires that represents the cable concatenation
+ """
+ parse a concatenation structure of cables, create the cables mentioned, and deal with
+ indicies return a list of ordered wires that represents the cable concatenation
example syntax
- {wire1, wire2, wire3, wire4}'''
+ {wire1, wire2, wire3, wire4}
+ """
token = self.next_token()
assert token == vt.OPEN_BRACE, self.error_string(
- vt.OPEN_BRACE, "to start cable concatenation", token)
+ vt.OPEN_BRACE, "to start cable concatenation", token
+ )
token = self.peek_token()
wires = []
while token != vt.CLOSE_BRACE:
cable, left, right = self.parse_variable_instantiation()
wires_temp = self.get_wires_from_cable(cable, left, right)
- wires_temp.sort(reverse=True,key=self.wire_sort_func)
+ wires_temp.sort(reverse=True, key=self.wire_sort_func)
for w in wires_temp:
wires.append(w)
token = self.next_token()
if token != vt.COMMA:
assert token == vt.CLOSE_BRACE, self.error_string(
- vt.CLOSE_BRACE, "to end cable concatenation", token)
+ vt.CLOSE_BRACE, "to end cable concatenation", token
+ )
return wires
@@ -496,7 +536,7 @@ def wire_sort_func(self, w):
return w.cable.wires.index(w)
def parse_module_header_port(self):
- '''parse the port declaration in the module header'''
+ """parse the port declaration in the module header"""
token = self.peek_token()
direction = None
defining = False
@@ -513,13 +553,19 @@ def parse_module_header_port(self):
token = self.next_token()
assert vt.is_valid_identifier(token), self.error_string(
- "identifier", "for port declaration", token)
+ "identifier", "for port declaration", token
+ )
name = token.strip()
port = self.create_or_update_port(
- name, left_index=left, right_index=right, direction=direction, defining=defining)
+ name,
+ left_index=left,
+ right_index=right,
+ direction=direction,
+ defining=defining,
+ )
# get the left and right out of the port (in case we got more information out of an instance?)
- if left == None and right == None:
+ if left is None and right is None:
left = port.lower_index + len(port.pins) - 1
right = port.lower_index
if not port.is_downto:
@@ -528,66 +574,75 @@ def parse_module_header_port(self):
right = temp
cable = self.create_or_update_cable(
- name, left_index=left, right_index=right, defining=defining)
+ name, left_index=left, right_index=right, defining=defining
+ )
# wire together the cables and the port
assert len(port.pins) == len(cable.wires), self.error_string(
- "the pins in a created port and the number of wires in it's cable do not match up", "wires: " + str(len(cable.wires)), "pins: " + str(len(port.pins)))
-
+ "the pins in a created port and the number of wires in it's cable do not match up",
+ "wires: " + str(len(cable.wires)),
+ "pins: " + str(len(port.pins)),
+ )
+
pin_list = list(p for p in port.pins)
- pin_list.sort(reverse=False, key=self.pin_sort_func)
+ pin_list.sort(reverse=False, key=self.pin_sort_func)
for i in range(len(pin_list)):
cable.wires[i].connect_pin(pin_list[i])
def parse_module_body(self):
- '''
+ """
parse through a module body
- module bodies consist of port declarations,
- wire and reg declarations
- and instantiations
+ module bodies consist of port declarations, wire and reg declarations and instantiations
- expects port declarations to start with the direction and then include the cable type if provided
- '''
+ expects port declarations to start with the direction and then include the cable type if
+ provided
+ """
direction_tokens = [vt.INPUT, vt.OUTPUT, vt.INOUT]
variable_tokens = [vt.WIRE, vt.REG, vt.TRI0, vt.TRI1]
token = self.peek_token()
- params = dict()
+ params = {}
while token != vt.END_MODULE:
if token in direction_tokens:
self.parse_port_declaration(params)
- params = dict()
+ params = {}
elif token in variable_tokens:
self.parse_cable_declaration(params)
- params = dict()
+ params = {}
elif token == vt.ASSIGN:
o_cable, o_left, o_right, i_cable, i_left, i_right = self.parse_assign()
self.connect_wires_for_assign(
- o_cable, o_left, o_right, i_cable, i_left, i_right)
+ o_cable, o_left, o_right, i_cable, i_left, i_right
+ )
elif token == vt.DEFPARAM:
self.parse_defparam_parameters()
elif vt.is_valid_identifier(token):
self.parse_instantiation(params)
- params = dict()
+ params = {}
elif token == vt.OPEN_PARENTHESIS:
stars = self.parse_star_property()
for k, v in stars.items():
params[k] = v
else:
assert False, self.error_string(
- "direction, reg, wire, star_properties, or instance identifier", "in module body", token)
+ "direction, reg, wire, star_properties, or instance identifier",
+ "in module body",
+ token,
+ )
token = self.peek_token()
token = self.next_token()
assert token == vt.END_MODULE, self.error_string(
- vt.END_MODULE, "to end the module body", token)
+ vt.END_MODULE, "to end the module body", token
+ )
def parse_port_declaration(self, properties):
- '''parse the port declaration post port list.'''
+ """parse the port declaration post port list."""
token = self.next_token()
assert token in vt.PORT_DIRECTIONS, self.error_string(
- "direction keyword", "to define port", token)
+ "direction keyword", "to define port", token
+ )
direction = vt.string_to_port_direction(token)
token = self.peek_token()
@@ -606,7 +661,8 @@ def parse_port_declaration(self, properties):
token = self.next_token()
assert vt.is_valid_identifier(token), self.error_string(
- "port identifier", "identify port", token)
+ "port identifier", "identify port", token
+ )
names = []
names.append(token.strip())
@@ -617,35 +673,50 @@ def parse_port_declaration(self, properties):
token = self.next_token()
assert token == vt.SEMI_COLON, self.error_string(
- vt.SEMI_COLON, "to end port declaration", token)
+ vt.SEMI_COLON, "to end port declaration", token
+ )
for name in names:
cable = self.create_or_update_cable(
- name, left_index=left, right_index=right, var_type=var_type, defining=True)
+ name,
+ left_index=left,
+ right_index=right,
+ var_type=var_type,
+ defining=True,
+ )
port_list = self.get_all_ports_from_wires(
- self.get_wires_from_cable(cable, left, right))
+ self.get_wires_from_cable(cable, left, right)
+ )
assert len(port_list) > 0, self.error_string(
- "port name defined in the module header", "to declare a port", cable.name)
+ "port name defined in the module header",
+ "to declare a port",
+ cable.name,
+ )
if len(port_list) > 1:
for p in port_list:
- port = self.create_or_update_port(
- p.name, direction=direction)
+ port = self.create_or_update_port(p.name, direction=direction)
port["VERILOG.InlineConstraints"] = properties
else:
- port = self.create_or_update_port(port_list.pop(
- ).name, left_index=left, right_index=right, direction=direction, defining=True)
-
+ port = self.create_or_update_port(
+ port_list.pop().name,
+ left_index=left,
+ right_index=right,
+ direction=direction,
+ defining=True,
+ )
+
if len(cable.wires) > 1:
self.connect_resized_port_cable(cable, port)
- def parse_cable_declaration(self, properties, var_type = None):
+ def parse_cable_declaration(self, properties, var_type=None):
if not var_type:
token = self.next_token()
assert token in [vt.REG, vt.WIRE, vt.TRI0, vt.TRI1], self.error_string(
- "reg, tri1, tri0, or wire", "for cable declaration", token)
+ "reg, tri1, tri0, or wire", "for cable declaration", token
+ )
var_type = token
token = self.peek_token()
@@ -657,48 +728,54 @@ def parse_cable_declaration(self, properties, var_type = None):
token = self.next_token()
assert vt.is_valid_identifier(token), self.error_string(
- "valid cable identifier", "identify the cable", token)
+ "valid cable identifier", "identify the cable", token
+ )
name = token.strip()
cable = self.create_or_update_cable(
- name, left_index=left, right_index=right, var_type=var_type)
+ name, left_index=left, right_index=right, var_type=var_type
+ )
cable["VERILOG.InlineConstraints"] = properties
token = self.next_token()
- if token == vt.COMMA: # continue listing wires
- self.parse_cable_declaration(dict(), var_type)
+ if token == vt.COMMA: # continue listing wires
+ self.parse_cable_declaration({}, var_type)
else:
assert token == vt.SEMI_COLON, self.error_string(
- vt.SEMI_COLON, "to end cable declaration", token)
+ vt.SEMI_COLON, "to end cable declaration", token
+ )
def parse_instantiation(self, properties):
token = self.next_token()
assert vt.is_valid_identifier(token), self.error_string(
- "module identifier", "for instantiation", token)
+ "module identifier", "for instantiation", token
+ )
def_name = token.strip()
- parameter_dict = dict()
+ parameter_dict = {}
token = self.peek_token()
if token == vt.OCTOTHORP:
parameter_dict = self.parse_parameter_mapping()
token = self.next_token()
assert vt.is_valid_identifier(token), self.error_string(
- "instance name", "for instantiation", token)
+ "instance name", "for instantiation", token
+ )
name = token.strip()
# the current definition is instancing the current top instance, so a change needs to be made
if def_name == self.netlist.top_instance.reference.name:
- # print(self.current_definition.name + " is instancing the current top instance (" + name+ " which is a "+ self.netlist.top_instance.reference.name+")")
+ # print(self.current_definition.name + " is instancing the current top instance (" + \
+ # name+ " which is a "+ self.netlist.top_instance.reference.name+")")
old_top_instance = self.netlist.top_instance
new_level = self.current_definition
# we know the current top is not right. So now we can move it up a level.
# But double check to make sure nothing is instancing the potential new top.
# Move up levels until we reach a new top
- if (len(self.current_definition.references) > 0):
+ if len(self.current_definition.references) > 0:
current_level = list(x for x in self.current_definition.references)[0]
- while(True):
+ while True:
current_level = current_level.parent
try:
current_level.parent
@@ -706,21 +783,22 @@ def parse_instantiation(self, properties):
new_level = current_level
break
- self.netlist.top_instance = sdn.Instance()
+ self.netlist.top_instance = Instance()
self.netlist.top_instance.name = new_level.name + "_top"
self.netlist.top_instance.reference = new_level
self.netlist.name = "SDN_VERILOG_NETLIST_" + new_level.name
# print("New top instance is "+ self.netlist.top_instance.name)
- # this instance should just go away. It was created to be the top instance but we don't want that
- # it has no parent. And now with no reference, it should have no ties to the netlist.
+ # this instance should just go away. It was created to be the top instance but we don't
+ # want that it has no parent. And now with no reference, it should have no ties to the
+ # netlist.
old_top_instance.reference = None
-
token = self.peek_token()
assert token == vt.OPEN_PARENTHESIS, self.error_string(
- vt.OPEN_PARENTHESIS, "to start port to cable mapping", token)
+ vt.OPEN_PARENTHESIS, "to start port to cable mapping", token
+ )
instance = self.current_definition.create_child()
self.current_instance = instance
@@ -735,54 +813,71 @@ def parse_instantiation(self, properties):
token = self.next_token()
assert token == vt.SEMI_COLON, self.error_string(
- vt.SEMI_COLON, "to end instatiation", token)
+ vt.SEMI_COLON, "to end instatiation", token
+ )
def parse_defparam_parameters(self):
- '''parse a defparam structure and add the parameters to the associated instance
+ """parse a defparam structure and add the parameters to the associated instance
this looks like:
- defparam \\avs_s1_readdata[12]~output .bus_hold = "false"; //single backslash to escape name
+ defparam \\avs_s1_readdata[12]~output .bus_hold = "false"; //single backslash to escape
+ name
- and must come after the associated instance (I'm not sure this is the verilog spec but
- it is the way quartus wrote my example and is much simpler)
- '''
- params = dict()
+ and must come after the associated instance (I'm not sure this is the verilog spec but it
+ is the way quartus wrote my example and is much simpler)
+ """
+ params = {}
token = self.next_token()
- assert token == vt.DEFPARAM, self.error_string(vt.DEFPARAM, "to being defparam statement", token)
+ assert token == vt.DEFPARAM, self.error_string(
+ vt.DEFPARAM, "to being defparam statement", token
+ )
token = self.next_token()
- assert vt.is_valid_identifier(token), self.error_string("valid identifier", "of an instance to apply the defparam to", token)
+ assert vt.is_valid_identifier(token), self.error_string(
+ "valid identifier", "of an instance to apply the defparam to", token
+ )
instance_name = token.strip()
if self.current_instance.name == instance_name:
instance = self.current_instance
else:
instance = next(self.current_definition.get_instances(instance_name), None)
- assert instance is not None, self.error_string("identifer of existing instance", "within the current definition", instance_name)
+ assert instance is not None, self.error_string(
+ "identifer of existing instance",
+ "within the current definition",
+ instance_name,
+ )
token = self.next_token()
- assert token == vt.DOT, self.error_string(vt.DOT, "give separate parameter key from the instance name", token)
+ assert token == vt.DOT, self.error_string(
+ vt.DOT, "give separate parameter key from the instance name", token
+ )
token = self.next_token()
key = token
token = self.next_token()
- assert token == vt.EQUAL, self.error_string(vt.EQUAL, "separate the key from the value in a defparam statement", token)
+ assert token == vt.EQUAL, self.error_string(
+ vt.EQUAL, "separate the key from the value in a defparam statement", token
+ )
token = self.next_token()
value = token
params[key] = value
token = self.next_token()
- assert token == vt.SEMI_COLON, self.error_string(vt.SEMI_COLON, "to end the defparam statement", token)
+ assert token == vt.SEMI_COLON, self.error_string(
+ vt.SEMI_COLON, "to end the defparam statement", token
+ )
self.set_instance_parameters(instance, params)
-
def parse_parameter_mapping(self):
- params = dict()
+ params = {}
token = self.next_token()
assert token == vt.OCTOTHORP, self.error_string(
- vt.OCTOTHORP, "to begin parameter mapping", token)
+ vt.OCTOTHORP, "to begin parameter mapping", token
+ )
token = self.next_token()
assert token == vt.OPEN_PARENTHESIS, self.error_string(
- vt.OPEN_PARENTHESIS, "after # to begin parameter mapping", token)
+ vt.OPEN_PARENTHESIS, "after # to begin parameter mapping", token
+ )
- if self.peek_token() == vt.CLOSE_PARENTHESIS: # empty parameters
+ if self.peek_token() == vt.CLOSE_PARENTHESIS: # empty parameters
token = self.next_token()
else:
while token != vt.CLOSE_PARENTHESIS:
@@ -790,10 +885,14 @@ def parse_parameter_mapping(self):
params[k] = v
token = self.next_token()
assert token in [vt.CLOSE_PARENTHESIS, vt.COMMA], self.error_string(
- vt.COMMA + " or " + vt.CLOSE_PARENTHESIS, "to separate parameters or end parameter mapping", token)
+ vt.COMMA + " or " + vt.CLOSE_PARENTHESIS,
+ "to separate parameters or end parameter mapping",
+ token,
+ )
assert token == vt.CLOSE_PARENTHESIS, self.error_string(
- vt.CLOSE_PARENTHESIS, "to terminate ", token)
+ vt.CLOSE_PARENTHESIS, "to terminate ", token
+ )
return params
@@ -801,76 +900,88 @@ def parse_parameter_map_single(self):
# syntax looks like .identifier(value)
token = self.next_token()
assert token == vt.DOT, self.error_string(
- vt.DOT, "to begin parameter mapping", token)
+ vt.DOT, "to begin parameter mapping", token
+ )
token = self.next_token()
assert vt.is_valid_identifier(token), self.error_string(
- "valid parameter identifier", "in parameter mapping", token)
+ "valid parameter identifier", "in parameter mapping", token
+ )
k = token.strip()
token = self.next_token()
assert token == vt.OPEN_PARENTHESIS, self.error_string(
- vt.OPEN_PARENTHESIS, "after identifier in parameter mapping", token)
+ vt.OPEN_PARENTHESIS, "after identifier in parameter mapping", token
+ )
token = self.next_token()
v = token
token = self.next_token()
assert token == vt.CLOSE_PARENTHESIS, self.error_string(
- vt.CLOSE_PARENTHESIS, "to close the parameter mapping value", token)
+ vt.CLOSE_PARENTHESIS, "to close the parameter mapping value", token
+ )
return k, v
def parse_port_mapping(self):
token = self.next_token()
assert token == vt.OPEN_PARENTHESIS, self.error_string(
- vt.OPEN_PARENTHESIS, "to start the port mapping", token)
+ vt.OPEN_PARENTHESIS, "to start the port mapping", token
+ )
peeked_token = self.peek_token()
- if peeked_token != vt.DOT: # the ports are implicitly mapped
- token_list = list()
- while (token != vt.CLOSE_PARENTHESIS):
+ if peeked_token != vt.DOT: # the ports are implicitly mapped
+ token_list = []
+ while token != vt.CLOSE_PARENTHESIS:
token_list.append(token)
token = self.next_token()
token_list.append(token)
self.implicitly_mapped_ports[self.current_instance] = token_list
- else: # the ports are explicitly mapped
+ else: # the ports are explicitly mapped
while token != vt.CLOSE_PARENTHESIS:
self.parse_port_map_single()
token = self.next_token()
assert token in [vt.COMMA, vt.CLOSE_PARENTHESIS], self.error_string(
- vt.COMMA + " or " + vt.CLOSE_PARENTHESIS, "between port mapping elements or to end the port mapping", token)
+ vt.COMMA + " or " + vt.CLOSE_PARENTHESIS,
+ "between port mapping elements or to end the port mapping",
+ token,
+ )
def parse_port_map_single(self):
- '''acutally does the mapping of the pins'''
+ """acutally does the mapping of the pins"""
token = self.next_token()
assert token == vt.DOT, self.error_string(
- vt.DOT, "to start a port mapping instance", token)
+ vt.DOT, "to start a port mapping instance", token
+ )
token = self.next_token()
assert vt.is_valid_identifier(token), self.error_string(
- "valid port identifier", "for port in instantiation port map", token)
+ "valid port identifier", "for port in instantiation port map", token
+ )
port_name = token.strip()
token = self.next_token()
assert token == vt.OPEN_PARENTHESIS, self.error_string(
- vt.OPEN_PARENTHESIS, "to encapsulate cable name in port mapping", token)
+ vt.OPEN_PARENTHESIS, "to encapsulate cable name in port mapping", token
+ )
token = self.peek_token()
if token != vt.CLOSE_PARENTHESIS:
-
if token == vt.OPEN_BRACE:
wires = self.parse_cable_concatenation()
else:
cable, left, right = self.parse_variable_instantiation()
wires = self.get_wires_from_cable(cable, left, right)
- pins = self.create_or_update_port_on_instance(
- port_name, len(wires))
+ pins = self.create_or_update_port_on_instance(port_name, len(wires))
assert len(pins) >= len(wires), self.error_string(
- "pins length to match or exceed cable.wires length", "INTERNAL ERROR", str(len(pins)) + "!=" + str(len(wires)))
+ "pins length to match or exceed cable.wires length",
+ "INTERNAL ERROR",
+ str(len(pins)) + "!=" + str(len(wires)),
+ )
# there can be unconnected pins at the end of the port.
pins.sort(reverse=True, key=self.pin_sort_func)
@@ -878,7 +989,7 @@ def parse_port_map_single(self):
# end of the port for partially connected ports
offset = 0
if len(pins) > len(wires):
- offset = len(pins)-len(wires)
+ offset = len(pins) - len(wires)
for i in range(len(wires)):
wires[i].connect_pin(pins[offset + i])
@@ -891,10 +1002,11 @@ def parse_port_map_single(self):
self.create_or_update_port_on_instance(port_name, 1)
assert token == vt.CLOSE_PARENTHESIS, self.error_string(
- vt.CLOSE_PARENTHESIS, "to end cable name in port mapping", token)
-
+ vt.CLOSE_PARENTHESIS, "to end cable name in port mapping", token
+ )
+
def pin_sort_func(self, p):
- if isinstance(p, sdn.OuterPin):
+ if isinstance(p, OuterPin):
return p.inner_pin.port.pins.index(p.inner_pin)
return p.port.pins.index(p)
@@ -907,8 +1019,9 @@ def connect_implicitly_mapped_ports(self):
token = self.next_token()
assert token == vt.OPEN_PARENTHESIS, self.error_string(
- vt.OPEN_PARENTHESIS, "to encapsulate cable name in port mapping", token)
-
+ vt.OPEN_PARENTHESIS, "to encapsulate cable name in port mapping", token
+ )
+
index = 0
# There may be no mapped wires at all. It may be empty or filled with whitespace
@@ -918,7 +1031,7 @@ def connect_implicitly_mapped_ports(self):
# Consume the token, we're going to skip the loop
token = self.next_token()
- while (token != vt.CLOSE_PARENTHESIS):
+ while token != vt.CLOSE_PARENTHESIS:
token = self.peek_token()
if token == vt.OPEN_BRACE:
@@ -927,20 +1040,23 @@ def connect_implicitly_mapped_ports(self):
cable, left, right = self.parse_variable_instantiation()
wires = self.get_wires_from_cable(cable, left, right)
- if (index > len(port_list) - 1): # no port exists yet i.e. no module information in netlist
+ if (index > len(port_list) - 1): # no port exists yet i.e. no module information in netlist
# print("Not enough ports for "+ instance.name)
port = instance.reference.create_port()
- self.populate_new_port(port, None, len(wires)-1, 0, None)
+ self.populate_new_port(port, None, len(wires) - 1, 0, None)
else:
port = port_list[index]
- pins = list()
+ pins = []
for pin in self.current_instance.pins:
if pin.inner_pin in port.pins:
pins.append(pin)
assert len(pins) >= len(wires), self.error_string(
- "pins length to match or exceed cable.wires length", "INTERNAL ERROR", str(len(pins)) + "!=" + str(len(wires)))
+ "pins length to match or exceed cable.wires length",
+ "INTERNAL ERROR",
+ str(len(pins)) + "!=" + str(len(wires)),
+ )
# there can be unconnected pins at the end of the port.
pin_list = list(p for p in pins)
@@ -949,7 +1065,7 @@ def connect_implicitly_mapped_ports(self):
# end of the port for partially connected ports
offset = 0
if len(pin_list) > len(wires):
- offset = len(pin_list)-len(wires)
+ offset = len(pin_list) - len(wires)
for i in range(len(wires)):
wires[i].connect_pin(pin_list[offset + i])
@@ -957,44 +1073,56 @@ def connect_implicitly_mapped_ports(self):
index += 1
assert token == vt.CLOSE_PARENTHESIS, self.error_string(
- vt.CLOSE_PARENTHESIS, "to end cable name in port mapping", token)
+ vt.CLOSE_PARENTHESIS, "to end cable name in port mapping", token
+ )
def parse_assign(self):
token = self.next_token()
assert token == vt.ASSIGN, self.error_string(
- vt.ASSIGN, "to begin assignment statement", token)
+ vt.ASSIGN, "to begin assignment statement", token
+ )
l_cable, l_left, l_right = self.parse_variable_instantiation()
token = self.next_token()
assert token == vt.EQUAL, self.error_string(
- vt.EQUAL, "in assigment statment", token)
+ vt.EQUAL, "in assigment statment", token
+ )
r_cable, r_left, r_right = self.parse_variable_instantiation()
token = self.next_token()
assert token == vt.SEMI_COLON, self.error_string(
- vt.SEMI_COLON, "to terminate assign statement", token)
+ vt.SEMI_COLON, "to terminate assign statement", token
+ )
return l_cable, l_left, l_right, r_cable, r_left, r_right
def parse_variable_instantiation(self):
- '''parse the cable name and its indicies if any
+ """parse the cable name and its indicies if any
if we are in Intel land then 2 other things can happen.
the "cable" is a constant,
attach it to the \\ or \\ cable.
the cable is inverted,
- create a new cable and an inverter block similar to the assign but with an inversion in the block
- '''
+ create a new cable and an inverter block similar to the assign but with an inversion in
+ the block
+ """
token = self.next_token()
if token[0] == "1":
- assert token[1] == vt.SINGLE_QUOTE, self.error_string(vt.SINGLE_QUOTE, "in the constant", token)
- assert token[2] == 'b', self.error_string('b', "in the constant", token)
- assert token[3] in ["0", "1", "x", "X", "z", "Z"], self.error_string("one of 0, 1, x, X, z, Z", "represent the constant value after '", token)
+ assert token[1] == vt.SINGLE_QUOTE, self.error_string(
+ vt.SINGLE_QUOTE, "in the constant", token
+ )
+ assert token[2] == "b", self.error_string("b", "in the constant", token)
+ assert token[3] in ["0", "1", "x", "X", "z", "Z"], self.error_string(
+ "one of 0, 1, x, X, z, Z", "represent the constant value after '", token
+ )
name = "\\ "
elif vt.is_numeric(token[0]):
- assert False, self.error_string("single bit constant", "multibit constants not supported", token)
+ assert False, self.error_string(
+ "single bit constant", "multibit constants not supported", token
+ )
else:
name = token
assert vt.is_valid_identifier(name), self.error_string(
- "valid port identifier", "for port in instantiation port map", name)
+ "valid port identifier", "for port in instantiation port map", name
+ )
token = self.peek_token()
left = None
right = None
@@ -1002,49 +1130,58 @@ def parse_variable_instantiation(self):
left, right = self.parse_brackets()
cable = self.create_or_update_cable(
- name.strip(), left_index=left, right_index=right)
+ name.strip(), left_index=left, right_index=right
+ )
return cable, left, right
def parse_brackets(self):
- '''returns 2 integer values or 1 integer value and none'''
+ """returns 2 integer values or 1 integer value and none"""
token = self.next_token()
assert token == vt.OPEN_BRACKET, self.error_string(
- "[", "to begin array slice", token)
+ "[", "to begin array slice", token
+ )
token = self.next_token()
- assert self.is_numeric(token), self.error_string(
- "number", "after [", token)
+ assert self.is_numeric(token), self.error_string("number", "after [", token)
left = int(token)
token = self.next_token()
if token == "]":
return left, None
else:
- assert(token == vt.COLON), self.error_string(
- "] or :", "in array slice", token)
+ assert token == vt.COLON, self.error_string(
+ "] or :", "in array slice", token
+ )
token = self.next_token()
- assert(self.is_numeric(token)), self.error_string(
- "number", "after : in array slice", token)
+ assert self.is_numeric(token), self.error_string(
+ "number", "after : in array slice", token
+ )
right = int(token)
token = self.next_token()
assert token == vt.CLOSE_BRACKET, self.error_string(
- "]", "to terminate array slice", token)
+ "]", "to terminate array slice", token
+ )
return left, right
def parse_star_property(self):
token = self.next_token()
assert token == vt.OPEN_PARENTHESIS, self.error_string(
- vt.OPEN_PARENTHESIS, "to begin star property", token)
+ vt.OPEN_PARENTHESIS, "to begin star property", token
+ )
token = self.next_token()
assert token == vt.STAR, self.error_string(
- vt.STAR, "to begin star property", token)
- properties_dict = dict()
+ vt.STAR, "to begin star property", token
+ )
+ properties_dict = {}
token = self.next_token()
while token != vt.STAR:
assert vt.is_valid_identifier(token)
key = token.strip()
token = self.next_token()
assert token in [vt.EQUAL, vt.STAR, vt.COMMA], self.error_string(
- vt.EQUAL + " or " + vt.STAR + " or " + vt.COMMA, "to set a star parameter", token)
+ vt.EQUAL + " or " + vt.STAR + " or " + vt.COMMA,
+ "to set a star parameter",
+ token,
+ )
if token == vt.EQUAL:
token = self.next_token()
value = ""
@@ -1057,10 +1194,12 @@ def parse_star_property(self):
if token != vt.STAR:
token = self.next_token()
assert token == vt.STAR, self.error_string(
- vt.STAR, "to start the ending of a star property", token)
+ vt.STAR, "to start the ending of a star property", token
+ )
token = self.next_token()
assert token == vt.CLOSE_PARENTHESIS, self.error_string(
- vt.CLOSE_PARENTHESIS, "to end the star property", token)
+ vt.CLOSE_PARENTHESIS, "to end the star property", token
+ )
return properties_dict
@@ -1069,19 +1208,18 @@ def parse_star_property(self):
#######################################################
def get_assignment_library(self):
- '''create or return a previously created assignment library'''
- if self.assigns == None:
- self.assigns = self.netlist.create_library(
- name="SDN_VERILOG_ASSIGNMENT")
+ """create or return a previously created assignment library"""
+ if self.assigns is None:
+ self.assigns = self.netlist.create_library(name="SDN_VERILOG_ASSIGNMENT")
return self.assigns
def get_assignment_definition(self, width):
- '''get the definition of the specified width for assignments'''
+ """get the definition of the specified width for assignments"""
proposed_name = "SDN_VERILOG_ASSIGNMENT_" + str(width)
library = self.get_assignment_library()
definition = next(library.get_definitions(proposed_name), None)
- if definition == None:
+ if definition is None:
definition = library.create_definition(name=proposed_name)
in_port = definition.create_port("i")
out_port = definition.create_port("o")
@@ -1091,7 +1229,8 @@ def get_assignment_definition(self, width):
in_port.direction = sdn.Port.Direction.IN
out_port.direction = sdn.Port.Direction.OUT
- # no need for this. It actually messes with other spydrnet functions like uniquify() and is_leaf()
+ # no need for this. It actually messes with other spydrnet functions like uniquify() and
+ # is_leaf()
# cable = definition.create_cable("through")
# cable.create_wires(width)
# for i in range(width):
@@ -1101,7 +1240,7 @@ def get_assignment_definition(self, width):
return definition
def create_assignment_instance(self, width):
- '''create a new assign instance of the specified width on the current definition'''
+ """create a new assign instance of the specified width on the current definition"""
definition = self.get_assignment_definition(width)
instance_name = definition.name + "_" + str(self.assignment_count)
self.assignment_count += 1
@@ -1110,7 +1249,7 @@ def create_assignment_instance(self, width):
return instance
def connect_wires_for_assign(self, l_cable, l_left, l_right, r_cable, r_left, r_right):
- '''connect the wires in r_left to the wires in l_left'''
+ """connect the wires in r_left to the wires in l_left"""
out_wires = self.get_wires_from_cable(l_cable, l_left, l_right)
in_wires = self.get_wires_from_cable(r_cable, r_left, r_right)
@@ -1119,8 +1258,8 @@ def connect_wires_for_assign(self, l_cable, l_left, l_right, r_cable, r_left, r_
width = min(len(out_wires), len(in_wires))
instance = self.create_assignment_instance(width)
- in_port = next(instance.reference.get_ports('i'), None)
- out_port = next(instance.reference.get_ports('o'), None)
+ in_port = next(instance.reference.get_ports("i"), None)
+ out_port = next(instance.reference.get_ports("o"), None)
in_pins = self.get_pins_by_port_from_instance(instance, in_port)
out_pins = self.get_pins_by_port_from_instance(instance, out_port)
@@ -1142,7 +1281,7 @@ def get_pins_by_port_from_instance(self, instance, port):
def set_instance_parameters(self, instance, params):
for k, v in params.items():
- #self.set_single_parameter(instance.reference, k, None)
+ # self.set_single_parameter(instance.reference, k, None)
self.set_single_parameter(instance, k, v)
def set_definition_parameters(self, definition, params):
@@ -1151,13 +1290,13 @@ def set_definition_parameters(self, definition, params):
def set_single_parameter(self, var, k, v):
if "VERILOG.Parameters" not in var:
- var["VERILOG.Parameters"] = dict()
+ var["VERILOG.Parameters"] = {}
if k not in var["VERILOG.Parameters"] or var["VERILOG.Parameters"][k] is None:
var["VERILOG.Parameters"][k] = v
def get_all_ports_from_wires(self, wires):
- '''gets all ports associated with a set of wires'''
+ """gets all ports associated with a set of wires"""
ports = set()
for w in wires:
for p in w.pins:
@@ -1168,17 +1307,17 @@ def get_all_ports_from_wires(self, wires):
def get_wires_from_cable(self, cable, left, right):
wires = []
- if left != None and right != None:
+ if left is not None and right is not None:
left = left - cable.lower_index
right = right - cable.lower_index
- temp_wires = cable.wires[min(left, right): max(left, right) + 1]
+ temp_wires = cable.wires[min(left, right) : max(left, right) + 1]
# if right > left:
temp_wires.reverse()
for w in temp_wires:
wires.append(w)
- elif left != None or right != None:
- if left != None:
+ elif left is not None or right is not None:
+ if left is not None:
index = left - cable.lower_index
else:
index = right - cable.lower_index
@@ -1206,7 +1345,7 @@ def convert_string_to_port_direction(self, token):
# Port and cable creation and update managment
########################################################################################
- '''I'm handed a few different possible senarios
+ """I'm handed a few different possible senarios
module name(port1, port2,...);
input [3:0] port1
@@ -1227,13 +1366,22 @@ def convert_string_to_port_direction(self, token):
module name(.port1({cable1, cable2}));
input [1:0] cable1;
output [1:0] cable2;
- '''
+ """
def connect_resized_port_cable(self, resized_cable, resized_port):
- '''One to one connector. Don't use with alias statements. this expects that the given cable should completely fill the port...
- after a cable has been updated that is attached to a port it may need to update the port and reconnect the'''
- assert len(resized_cable.wires) == len(resized_port.pins), self.error_string("cable and port to have same size",
- "to reconnect expanded cables and ports", "wires: " + str(len(resized_cable.wires)) + " pins: " + str(len(resized_port.pins)))
+ """
+ One to one connector. Don't use with alias statements. this expects that the given cable
+ should completely fill the port... after a cable has been updated that is attached to a port
+ it may need to update the port and reconnect the
+ """
+ assert len(resized_cable.wires) == len(resized_port.pins), self.error_string(
+ "cable and port to have same size",
+ "to reconnect expanded cables and ports",
+ "wires: "
+ + str(len(resized_cable.wires))
+ + " pins: "
+ + str(len(resized_port.pins)),
+ )
for i in range(len(resized_port.pins)):
# I think these should be lined up right?
if resized_port.pins[i] not in resized_cable.wires[i].pins:
@@ -1243,13 +1391,14 @@ def connect_resized_port_cable(self, resized_cable, resized_port):
# this likely occurred because of an alias statement.
resized_cable.wires[i].connect_pin(resized_port.pins[i])
- def create_or_update_cable(self, name, left_index=None, right_index=None, var_type=None, defining=False):
+ def create_or_update_cable(
+ self, name, left_index=None, right_index=None, var_type=None, defining=False
+ ):
cable_generator = self.current_definition.get_cables(name)
cable = next(cable_generator, None)
- if cable == None:
+ if cable is None:
cable = self.current_definition.create_cable()
- self.populate_new_cable(
- cable, name, left_index, right_index, var_type)
+ self.populate_new_cable(cable, name, left_index, right_index, var_type)
return cable
assert cable.name == name
@@ -1271,13 +1420,12 @@ def create_or_update_cable(self, name, left_index=None, right_index=None, var_ty
in_upper = None
in_lower = None
- if defining and in_lower is not None: # if the cable width is being defined then recenter the cable
+ if (defining and in_lower is not None): # if the cable width is being defined then recenter the cable
cable.lower_index = in_lower
cable_lower = cable.lower_index
cable_upper = cable.lower_index + len(cable.wires) - 1
if in_upper is not None and in_lower is not None:
-
if in_lower < cable_lower:
prepend = cable_lower - in_lower
self.prepend_wires(cable, prepend)
@@ -1294,8 +1442,9 @@ def populate_new_cable(self, cable, name, left_index, right_index, var_type):
cable.name = name
if left_index is not None and right_index is not None:
cable.is_downto = right_index <= left_index
- cable.create_wires(max(left_index, right_index) -
- min(left_index, right_index) + 1)
+ cable.create_wires(
+ max(left_index, right_index) - min(left_index, right_index) + 1
+ )
cable.lower_index = min(left_index, right_index)
elif left_index is not None:
cable.lower_index = left_index
@@ -1322,25 +1471,36 @@ def postpend_wires(self, cable, count):
cable.create_wires(count)
def create_or_update_port_on_instance(self, name, width):
- '''returns the set of pins associated with the port on the instance'''
+ """returns the set of pins associated with the port on the instance"""
pins = []
port = self.create_or_update_port(
- name, left_index=width - 1, right_index=0, definition=self.current_instance.reference)
+ name,
+ left_index=width - 1,
+ right_index=0,
+ definition=self.current_instance.reference,
+ )
for pin in self.current_instance.pins:
if pin.inner_pin in port.pins:
pins.append(pin)
return pins
- def create_or_update_port(self, name, left_index=None, right_index=None, direction=None, definition=None, defining=False):
- if definition == None:
+ def create_or_update_port(
+ self,
+ name,
+ left_index=None,
+ right_index=None,
+ direction=None,
+ definition=None,
+ defining=False,
+ ):
+ if definition is None:
definition = self.current_definition
port_generator = definition.get_ports(name)
port = next(port_generator, None)
- if port == None:
+ if port is None:
port = definition.create_port()
- self.populate_new_port(
- port, name, left_index, right_index, direction)
+ self.populate_new_port(port, name, left_index, right_index, direction)
return port
assert port.name == name
@@ -1364,7 +1524,7 @@ def create_or_update_port(self, name, left_index=None, right_index=None, directi
in_upper = None
in_lower = None
- if defining and in_lower is not None: # if the cable width is being defined then recenter the cable
+ if (defining and in_lower is not None): # if the cable width is being defined then recenter the cable
port.lower_index = in_lower
port_lower = port.lower_index
port_upper = port.lower_index + len(port.pins) - 1
@@ -1372,7 +1532,7 @@ def create_or_update_port(self, name, left_index=None, right_index=None, directi
if in_upper is not None and in_lower is not None:
# to prevent unneccessary pins being added, check to see if port
# width is already correct
- if (in_upper-in_lower) == (port_upper-port_lower):
+ if (in_upper - in_lower) == (port_upper - port_lower):
None
else:
if in_lower < port_lower:
@@ -1391,8 +1551,9 @@ def populate_new_port(self, port, name, left_index, right_index, direction):
port.name = name
if left_index is not None and right_index is not None:
port.is_downto = right_index <= left_index
- port.create_pins(max(left_index, right_index) -
- min(left_index, right_index) + 1)
+ port.create_pins(
+ max(left_index, right_index) - min(left_index, right_index) + 1
+ )
port.lower_index = min(left_index, right_index)
elif left_index is not None:
port.lower_index = left_index
@@ -1436,5 +1597,14 @@ def is_alphanumeric(self, token):
return True
def error_string(self, expected, why, result):
- '''put in the expectation and then the reason or location and the actual result'''
- return "expected " + str(expected) + " " + why + " but got " + str(result) + " Line: " + str(self.tokenizer.line_number)
+ """put in the expectation and then the reason or location and the actual result"""
+ return (
+ "expected "
+ + str(expected)
+ + " "
+ + why
+ + " but got "
+ + str(result)
+ + " Line: "
+ + str(self.tokenizer.line_number)
+ )
diff --git a/spydrnet/parsers/verilog/tokenizer.py b/spydrnet/parsers/verilog/tokenizer.py
index caa535ab..42dd7a34 100644
--- a/spydrnet/parsers/verilog/tokenizer.py
+++ b/spydrnet/parsers/verilog/tokenizer.py
@@ -5,10 +5,9 @@
import re
import zipfile
import io
-import os
+from pathlib import Path
import spydrnet.parsers.verilog.verilog_tokens as vt
from spydrnet.parsers.verilog.verilog_token_factory import TokenFactory
-from pathlib import Path
class VerilogTokenizer:
@@ -37,14 +36,22 @@ def __init__(self, input_source):
if zipfile.is_zipfile(input_source):
zip = zipfile.ZipFile(input_source)
filename = Path(input_source).name
- filename = filename[:filename.rindex(".")]
+ filename = filename[: filename.rindex(".")]
stream = zip.open(filename)
stream = io.TextIOWrapper(stream)
self.input_stream = stream
else:
- self.input_stream = open(input_source, 'r')
+ self.input_stream = open(input_source, "r")
elif isinstance(input_source, Path):
- self.input_stream = open(input_source,"r")
+ if zipfile.is_zipfile(input_source):
+ zip = zipfile.ZipFile(input_source)
+ filename = Path(input_source).name
+ filename = filename[: filename.rindex(".")]
+ stream = zip.open(filename)
+ stream = io.TextIOWrapper(stream)
+ self.input_stream = stream
+ else:
+ self.input_stream = open(input_source, "r")
else:
if isinstance(input_source, io.TextIOBase) is False:
self.input_stream = io.TextIOWrapper(input_source)
@@ -77,14 +84,16 @@ def peek(self):
return self.next_token
else:
token = next(self.generator)
- while len(token) >= 2 and (token[0:2] == vt.OPEN_LINE_COMMENT
- or token[0:2] == vt.OPEN_BLOCK_COMMENT):
+ while len(token) >= 2 and (
+ token[0:2] == vt.OPEN_LINE_COMMENT
+ or token[0:2] == vt.OPEN_BLOCK_COMMENT
+ ):
token = next(self.generator)
self.next_token = token
return self.next_token
def generate_tokens(self):
- '''give independent tokens from the token factory'''
+ """give independent tokens from the token factory"""
try:
self.line_number = 1
@@ -99,10 +108,11 @@ def generate_tokens(self):
finally:
self.input_stream.close()
- # if the input doesn't end in white space there will be one token left in the token factory try and get it.
+ # if the input doesn't end in white space there will be one token left in the token factory
+ # try and get it.
result = tf.flush()
- if result != None:
+ if result is not None:
yield result
def close(self):
@@ -110,7 +120,7 @@ def close(self):
self.input_stream.close()
-class VerilogTokenizerSimple():
+class VerilogTokenizerSimple:
def __init__(self, token_list):
self.token = None
self.next_token = None
@@ -146,8 +156,10 @@ def peek(self):
return self.next_token
else:
token = next(self.generator)
- while len(token) >= 2 and (token[0:2] == vt.OPEN_LINE_COMMENT
- or token[0:2] == vt.OPEN_BLOCK_COMMENT):
+ while len(token) >= 2 and (
+ token[0:2] == vt.OPEN_LINE_COMMENT
+ or token[0:2] == vt.OPEN_BLOCK_COMMENT
+ ):
token = next(self.generator)
self.next_token = token
return self.next_token
diff --git a/spydrnet/parsers/verilog/verilog_token_factory.py b/spydrnet/parsers/verilog/verilog_token_factory.py
index 1b099ab6..bd55ca7a 100644
--- a/spydrnet/parsers/verilog/verilog_token_factory.py
+++ b/spydrnet/parsers/verilog/verilog_token_factory.py
@@ -1,46 +1,52 @@
import spydrnet.parsers.verilog.verilog_tokens as vt
-class TokenFactory():
- def __init__(self):
- self.buffer = ''
- #only one of these should ever be true at any time.
+
+class TokenFactory:
+ def __init__(self):
+ self.buffer = ""
+ # only one of these should ever be true at any time.
self.single_line_comment = False
self.multi_line_comment = False
self.string = False
self.escaped_identifier = False
self.processor_directive = False
- self.last_character = "" #should not be relied on to always be the last character when tokens are ending
-
- def clear(self, character = ""):
+ self.last_character = "" # should not be relied on to always be the last character when tokens are ending
+
+ def clear(self, character=""):
self.buffer = character
def any_flag_set(self):
- return self.single_line_comment or self.multi_line_comment or self.string or self.escaped_identifier or self.processor_directive
+ return (
+ self.single_line_comment
+ or self.multi_line_comment
+ or self.string
+ or self.escaped_identifier
+ or self.processor_directive
+ )
def set_flags(self):
if len(self.buffer) <= 2 and not self.any_flag_set():
-
if self.buffer == vt.OPEN_LINE_COMMENT:
self.single_line_comment = True
-
+
elif self.buffer == vt.OPEN_BLOCK_COMMENT:
self.multi_line_comment = True
-
+
elif self.buffer == '"':
self.string = True
-
+
elif self.buffer == "\\":
self.escaped_identifier = True
-
+
elif self.buffer == "`":
self.processor_directive = True
def add_character(self, character):
- #tries to add the character to the token.
- #if the token is complete it will return and start the next token
- #if the token is incomplete it will add it and return none
+ # tries to add the character to the token.
+ # if the token is complete it will return and start the next token
+ # if the token is incomplete it will add it and return none
token_out = None
- #first thing, see if we need to return a token
+ # first thing, see if we need to return a token
if self.buffer in vt.SINGLE_CHARACTER_TOKENS:
token_out = self.buffer
self.clear()
@@ -50,7 +56,9 @@ def add_character(self, character):
self.clear()
self.single_line_comment = False
- elif self.multi_line_comment and self.last_character == "*" and character == "/":
+ elif (
+ self.multi_line_comment and self.last_character == "*" and character == "/"
+ ):
token_out = self.buffer + character
character = ""
self.clear()
@@ -73,29 +81,40 @@ def add_character(self, character):
self.processor_directive = False
elif character == vt.STAR and self.last_character == "/":
- pass #this will be a multi line comment but * is a breaker...
+ pass # this will be a multi line comment but * is a breaker...
- elif character in vt.BREAKER_TOKENS and not self.any_flag_set() and len(self.buffer) != 0:
+ elif (
+ character in vt.BREAKER_TOKENS
+ and not self.any_flag_set()
+ and len(self.buffer) != 0
+ ):
token_out = self.buffer
self.clear()
- elif character == vt.DOT and not self.any_flag_set() and len(self.buffer) != 0 and\
- not vt.is_numeric(self.buffer):
+ elif (
+ character == vt.DOT
+ and not self.any_flag_set()
+ and len(self.buffer) != 0
+ and not vt.is_numeric(self.buffer)
+ ):
token_out = self.buffer
self.clear()
-
if character not in vt.WHITESPACE:
self.buffer = self.buffer + character
- elif self.single_line_comment or self.multi_line_comment or self.string or self.processor_directive:
+ elif (
+ self.single_line_comment
+ or self.multi_line_comment
+ or self.string
+ or self.processor_directive
+ ):
self.buffer = self.buffer + character
self.last_character = character
-
+
last_multi_line_comment = self.multi_line_comment
self.set_flags()
if self.multi_line_comment and not last_multi_line_comment:
- self.last_character = "" #these lines help to ensure that /*/ isn't precieved as a complete comment.
-
+ self.last_character = "" # these lines help to ensure that /*/ isn't precieved as a complete comment.
return token_out
@@ -104,4 +123,4 @@ def flush(self):
self.clear()
if token_out == "":
return None
- return token_out
\ No newline at end of file
+ return token_out
diff --git a/spydrnet/parsers/verilog/verilog_tokens.py b/spydrnet/parsers/verilog/verilog_tokens.py
index ae612497..9a9fbc89 100644
--- a/spydrnet/parsers/verilog/verilog_tokens.py
+++ b/spydrnet/parsers/verilog/verilog_tokens.py
@@ -1,26 +1,74 @@
import spydrnet as sdn
-TAB = '\t'
-NEW_LINE ='\n'
-CARRIAGE_RETURN = '\r'
-SPACE = ' '
-FORM_FEED = '\f'
+TAB = "\t"
+NEW_LINE = "\n"
+CARRIAGE_RETURN = "\r"
+SPACE = " "
+FORM_FEED = "\f"
-NUMBERS = {'0','1','2','3','4','5','6','7','8','9'}
-LETTERS = {'a','b','c','d','e','f','g','h','i','j',\
- 'k','l','m','n','o','p','q','r','s','t','u','v',\
- 'w','x','y','z',\
- 'A','B','C','D','E','F','G','H',\
- 'I','J','K','L','M','N','O','P','Q','R','S','T',\
- 'U','V','W','X','Y','Z'}
+NUMBERS = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
+LETTERS = {
+ "a",
+ "b",
+ "c",
+ "d",
+ "e",
+ "f",
+ "g",
+ "h",
+ "i",
+ "j",
+ "k",
+ "l",
+ "m",
+ "n",
+ "o",
+ "p",
+ "q",
+ "r",
+ "s",
+ "t",
+ "u",
+ "v",
+ "w",
+ "x",
+ "y",
+ "z",
+ "A",
+ "B",
+ "C",
+ "D",
+ "E",
+ "F",
+ "G",
+ "H",
+ "I",
+ "J",
+ "K",
+ "L",
+ "M",
+ "N",
+ "O",
+ "P",
+ "Q",
+ "R",
+ "S",
+ "T",
+ "U",
+ "V",
+ "W",
+ "X",
+ "Y",
+ "Z",
+}
WHITESPACE = {SPACE, TAB, NEW_LINE, CARRIAGE_RETURN, FORM_FEED}
-OPEN_PARENTHESIS = '('
-CLOSE_PARENTHESIS = ')'
-STAR = '*'
-SEMI_COLON = ';'
+OPEN_PARENTHESIS = "("
+CLOSE_PARENTHESIS = ")"
+STAR = "*"
+SEMI_COLON = ";"
MODULE = "module"
INPUT = "input"
OUTPUT = "output"
@@ -46,82 +94,119 @@
IFDEF = "`ifdef"
DEFINE = "`define"
ENDIF = "`endif"
-ELSIF = '`elsif'
-TIMESCALE = '`timescale'
+ELSIF = "`elsif"
+TIMESCALE = "`timescale"
OPEN_BLOCK_COMMENT = "/*"
CLOSE_BLOCK_COMMENT = "*/"
OPEN_LINE_COMMENT = "//"
-PRIMITIVE = 'primitive'
-END_PRIMITIVE = 'endprimitive'
-FUNCTION = 'function'
-END_FUNCTION = 'endfunction'
-TASK = 'task'
-END_TASK = 'endtask'
-INTEGER = 'integer'
-TRI0 = 'tri0'
-TRI1 = 'tri1'
-DEFPARAM = 'defparam'
+PRIMITIVE = "primitive"
+END_PRIMITIVE = "endprimitive"
+FUNCTION = "function"
+END_FUNCTION = "endfunction"
+TASK = "task"
+END_TASK = "endtask"
+INTEGER = "integer"
+TRI0 = "tri0"
+TRI1 = "tri1"
+DEFPARAM = "defparam"
-#SET OF ALL THINGS THAT WILL END AN IDENTIFIER IF THEY ARE NOT ESCAPED.
-#elif ch in {'(', ')', '.', ',', ';', '[', ']', ':', "{", "}", "*", "#", "`"}:
-BREAKER_TOKENS = {SPACE, TAB, NEW_LINE, CARRIAGE_RETURN, FORM_FEED, OPEN_PARENTHESIS, CLOSE_PARENTHESIS,\
- COMMA, SEMI_COLON, OPEN_BRACKET, CLOSE_BRACKET, COLON, OPEN_BRACE, CLOSE_BRACE, STAR, OCTOTHORP,\
- EQUAL, "\\", "\"", "`"} #single quote should not be included here because of 1'b0 type of declarations (these should be one token)
+# SET OF ALL THINGS THAT WILL END AN IDENTIFIER IF THEY ARE NOT ESCAPED.
+# elif ch in {'(', ')', '.', ',', ';', '[', ']', ':', "{", "}", "*", "#", "`"}:
+BREAKER_TOKENS = {
+ SPACE,
+ TAB,
+ NEW_LINE,
+ CARRIAGE_RETURN,
+ FORM_FEED,
+ OPEN_PARENTHESIS,
+ CLOSE_PARENTHESIS,
+ COMMA,
+ SEMI_COLON,
+ OPEN_BRACKET,
+ CLOSE_BRACKET,
+ COLON,
+ OPEN_BRACE,
+ CLOSE_BRACE,
+ STAR,
+ OCTOTHORP,
+ EQUAL,
+ "\\",
+ '"',
+ "`",
+}
+# single quote should not be included here because of 1'b0 type of declarations (these should be one
+# token)
-SINGLE_CHARACTER_TOKENS = {OPEN_PARENTHESIS, CLOSE_PARENTHESIS, STAR, SEMI_COLON, DOT, OPEN_BRACKET,\
- CLOSE_BRACKET, OPEN_BRACE, CLOSE_BRACE, COLON, COMMA, COMMA, OCTOTHORP, SINGLE_QUOTE, EQUAL}
+SINGLE_CHARACTER_TOKENS = {
+ OPEN_PARENTHESIS,
+ CLOSE_PARENTHESIS,
+ STAR,
+ SEMI_COLON,
+ DOT,
+ OPEN_BRACKET,
+ CLOSE_BRACKET,
+ OPEN_BRACE,
+ CLOSE_BRACE,
+ COLON,
+ COMMA,
+ COMMA,
+ OCTOTHORP,
+ SINGLE_QUOTE,
+ EQUAL,
+}
PORT_DIRECTIONS = {INPUT, OUTPUT, INOUT}
ALL_VERILOG_TOKENS = {
- TAB,\
- NEW_LINE,\
- CARRIAGE_RETURN,\
- SPACE,\
- FORM_FEED,\
- OPEN_PARENTHESIS,\
- CLOSE_PARENTHESIS,\
- STAR,\
- SEMI_COLON,\
- MODULE,\
- INPUT,\
- OUTPUT,\
- INOUT,\
- WIRE,\
- REG,\
- DOT,\
- OPEN_BRACKET,\
- CLOSE_BRACKET,\
- OPEN_BRACE,\
- CLOSE_BRACE,\
- COLON,\
- COMMA,\
- OCTOTHORP,\
- END_MODULE,\
- PARAMETER,\
- SINGLE_QUOTE,\
- LOCAL_PARAM,\
- ASSIGN,\
- EQUAL,\
- CELL_DEFINE,\
- END_CELL_DEFINE,\
- IFDEF,\
- ENDIF,\
- ELSIF,\
- OPEN_BLOCK_COMMENT,\
- CLOSE_BLOCK_COMMENT,\
- OPEN_LINE_COMMENT,\
- INTEGER,\
- TRI0,\
- TRI1,\
- DEFPARAM
+ TAB,
+ NEW_LINE,
+ CARRIAGE_RETURN,
+ SPACE,
+ FORM_FEED,
+ OPEN_PARENTHESIS,
+ CLOSE_PARENTHESIS,
+ STAR,
+ SEMI_COLON,
+ MODULE,
+ INPUT,
+ OUTPUT,
+ INOUT,
+ WIRE,
+ REG,
+ DOT,
+ OPEN_BRACKET,
+ CLOSE_BRACKET,
+ OPEN_BRACE,
+ CLOSE_BRACE,
+ COLON,
+ COMMA,
+ OCTOTHORP,
+ END_MODULE,
+ PARAMETER,
+ SINGLE_QUOTE,
+ LOCAL_PARAM,
+ ASSIGN,
+ EQUAL,
+ CELL_DEFINE,
+ END_CELL_DEFINE,
+ IFDEF,
+ ENDIF,
+ ELSIF,
+ OPEN_BLOCK_COMMENT,
+ CLOSE_BLOCK_COMMENT,
+ OPEN_LINE_COMMENT,
+ INTEGER,
+ TRI0,
+ TRI1,
+ DEFPARAM,
}
+
def is_valid_identifier(token):
if token == "":
return False
- elif token[0] == '\\' and token[-1] == " ":
- for white in WHITESPACE: #there shouldn't be whitespace before the ending space
+ elif token[0] == "\\" and token[-1] == " ":
+ for white in WHITESPACE: # there shouldn't be whitespace before the ending space
if white in token[:-1]:
return False
return True
@@ -133,6 +218,7 @@ def is_valid_identifier(token):
return False
return True
+
def is_numeric(token):
if token == "":
return False
@@ -141,6 +227,7 @@ def is_numeric(token):
return False
return True
+
def string_to_port_direction(token):
if token == INPUT:
return sdn.Port.Direction.IN
@@ -150,4 +237,3 @@ def string_to_port_direction(token):
return sdn.Port.Direction.INOUT
else:
return sdn.Port.Direction.UNDEFINED
-
diff --git a/spydrnet/plugins/namespace_manager/__init__.py b/spydrnet/plugins/namespace_manager/__init__.py
index 14886945..e64b5f7b 100644
--- a/spydrnet/plugins/namespace_manager/__init__.py
+++ b/spydrnet/plugins/namespace_manager/__init__.py
@@ -1,3 +1,4 @@
+import weakref
from abc import ABC
from spydrnet.callback.callback_listener import CallbackListener
@@ -5,7 +6,6 @@
from spydrnet.plugins.namespace_manager.edif_namespace import EdifNamespace
from spydrnet.ir import Netlist, Library, Definition, Port, Cable, Instance
from spydrnet.global_state.global_service import register_lookup, deregister_lookup
-import weakref
def _load_policies():
@@ -16,7 +16,7 @@ def _load_policies():
class NamespaceManager(CallbackListener, ABC):
default = None
- policies = dict()
+ policies = {}
def __init__(self):
super().__init__()
@@ -88,20 +88,33 @@ def netlist_remove_library(self, netlist, library):
def dictionary_set(self, element, key, value):
if key == ".NS":
- if self.ignore_ns_change is False and (key not in element or element[key] != value):
+ if self.ignore_ns_change is False and (
+ key not in element or element[key] != value
+ ):
if self.get_parent(element) is not None:
- raise ValueError("Cannot change the namespace of a object already belonging to a parent")
+ raise ValueError(
+ "Cannot change the namespace of a object already belonging to a parent"
+ )
if value not in self.policies:
- raise ValueError('The namespace policy specified does not exist. Supported namespaces include: {}'.format(", ".join(self.policies)))
+ raise ValueError(
+ "The namespace policy specified does not exist. \
+ Supported namespaces include: {}".format(
+ ", ".join(self.policies)
+ )
+ )
target_namespace = self.policies[value]
if self.is_compliant(target_namespace, element) is False:
- raise ValueError("The current element is not compliant with the target namespace policy.")
+ raise ValueError(
+ "The current element is not compliant with the target namespace policy."
+ )
self.apply_namespace(value, target_namespace, element)
elif key in {".NAME", "EDIF.identifier"}:
if ".NS" in element:
target_policy = self.policies[element[".NS"]]
if target_policy.is_name_valid(key, value) is False:
- raise ValueError("Target name not valid for the current namespace policy.")
+ raise ValueError(
+ "Target name not valid for the current namespace policy."
+ )
parent = self.get_parent(element)
if parent and parent in self.namespaces:
@@ -115,7 +128,9 @@ def dictionary_delete(self, element, key):
if key == ".NS":
if self.ignore_ns_change is False:
if self.get_parent(element) is not None:
- raise ValueError("Cannot change the namespace of a object already belonging to a parent")
+ raise ValueError(
+ "Cannot change the namespace of a object already belonging to a parent"
+ )
if ".NS" in element:
self.drop_namespace(element)
elif key in {".NAME", "EDIF.identifier"}:
@@ -128,7 +143,9 @@ def dictionary_pop(self, element, key):
if key == ".NS":
if self.ignore_ns_change is False:
if self.get_parent(element) is not None:
- raise ValueError("Cannot change the namespace of a object already belonging to a parent")
+ raise ValueError(
+ "Cannot change the namespace of a object already belonging to a parent"
+ )
if ".NS" in element:
self.drop_namespace(element)
elif key in {".NAME", "EDIF.identifier"}:
@@ -143,7 +160,10 @@ def add(self, parent, child):
if key in child:
no_conflict = namespace.no_conflict(child, key, child[key])
if no_conflict is False:
- raise ValueError("Adding this element would result in a naming conflict. " + child[key])
+ raise ValueError(
+ "Adding this element would result in a naming conflict. "
+ + child[key]
+ )
if ".NS" in parent:
parent_namespace = parent[".NS"]
if ".NS" not in child or child[".NS"] != parent_namespace:
@@ -233,8 +253,10 @@ def _update_new_namespace(self, elements, namespace):
for element in elements:
if element.name:
namespace.update(element, ".NAME", element.name)
- if 'EDIF.identifier' in element:
- namespace.update(element, "EDIF.identifier", element['EDIF.identifier'])
+ if "EDIF.identifier" in element:
+ namespace.update(
+ element, "EDIF.identifier", element["EDIF.identifier"]
+ )
def drop_namespace(self, original_element):
self.ignore_ns_change = True
diff --git a/spydrnet/plugins/namespace_manager/default_namespace.py b/spydrnet/plugins/namespace_manager/default_namespace.py
index de73394f..4cb8caff 100644
--- a/spydrnet/plugins/namespace_manager/default_namespace.py
+++ b/spydrnet/plugins/namespace_manager/default_namespace.py
@@ -5,8 +5,8 @@ class DefaultNamespace:
@classmethod
def is_compliant(cls, element):
"""
- is_compliant means that the naming of the element is a valid name and that there are no namespace conflicts
- among its children
+ is_compliant means that the naming of the element is a valid name and that there are no
+ namespace conflicts among its children
:param element:
:return:
"""
@@ -84,7 +84,7 @@ def needs_namespace(cls, element):
return False
def __init__(self):
- self.namespaces = dict()
+ self.namespaces = {}
def no_conflict(self, element, key, value):
if key != ".NAME":
@@ -101,7 +101,7 @@ def update(self, element, key, value):
if key == ".NAME":
element_type = type(element)
if element_type not in self.namespaces:
- self.namespaces[element_type] = dict()
+ self.namespaces[element_type] = {}
namespace = self.namespaces[element_type]
if ".NAME" in element:
old_name = element[".NAME"]
diff --git a/spydrnet/plugins/namespace_manager/edif_namespace.py b/spydrnet/plugins/namespace_manager/edif_namespace.py
index 5548a5e5..e5c004a9 100644
--- a/spydrnet/plugins/namespace_manager/edif_namespace.py
+++ b/spydrnet/plugins/namespace_manager/edif_namespace.py
@@ -1,11 +1,9 @@
-from spydrnet.plugins.namespace_manager.default_namespace import DefaultNamespace
-from spydrnet.ir import Netlist, Library, Definition
import re
from spydrnet.plugins.namespace_manager.default_namespace import DefaultNamespace
+from spydrnet.ir import Netlist, Library, Definition
class EdifNamespace(DefaultNamespace):
-
@classmethod
def is_name_of_element_valid(cls, element):
"""
@@ -121,8 +119,8 @@ def no_name_conflicts(cls, element):
return True
def __init__(self):
- self.namespaces = dict()
- self.edif_namespaces = dict()
+ super().__init__()
+ self.edif_namespaces = {}
def no_conflict(self, element, key, value):
element_type = type(element)
@@ -145,7 +143,7 @@ def update(self, element, key, value):
element_type = type(element)
if key == ".NAME":
if element_type not in self.namespaces:
- self.namespaces[element_type] = dict()
+ self.namespaces[element_type] = {}
namespace = self.namespaces[element_type]
if ".NAME" in element:
old_name = element[".NAME"]
@@ -154,7 +152,7 @@ def update(self, element, key, value):
namespace[value] = element
elif key == "EDIF.identifier":
if element_type not in self.edif_namespaces:
- self.edif_namespaces[element_type] = dict()
+ self.edif_namespaces[element_type] = {}
namespace = self.edif_namespaces[element_type]
if "EDIF.identifier" in element:
old_name = element["EDIF.identifier"].lower()
diff --git a/spydrnet/release.py b/spydrnet/release.py
index 3abfcb70..c2919354 100644
--- a/spydrnet/release.py
+++ b/spydrnet/release.py
@@ -2,7 +2,7 @@
from pathlib import Path
# Version information
-name = 'spydrnet'
+name = "spydrnet"
version = "UNSPECIFIED"
release = "UNSPECIFIED"
date = "UNSPECIFIED"
@@ -12,47 +12,60 @@
dev = False
description = "Python package for analyzing and transforming netlists"
-license = 'BSD'
-authors = {'Keller': ('Andrew Keller', 'andrewmkeller@byu.edu'),
- 'Skouson': ('Dallin Skouson', 'dallinskouson@byu.edu'),
- 'Wirthlin': ('Michael Wirthlin', 'wirthlin@byu.edu')}
+license = "BSD"
+authors = {
+ "Keller": ("Andrew Keller", "andrewmkeller@byu.edu"),
+ "Skouson": ("Dallin Skouson", "dallinskouson@byu.edu"),
+ "Wirthlin": ("Michael Wirthlin", "wirthlin@byu.edu"),
+}
maintainer = "SpyDrNet Developers"
maintainer_email = "spydrnet-discuss@googlegroups.com"
-url = 'https://byuccl.github.io/spydrnet'
+url = "https://byuccl.github.io/spydrnet"
project_urls = {
"Bug Tracker": "https://github.com/byuccl/spydrnet/issues",
"Documentation": "https://byuccl.github.io/spydrnet/docs/stable",
"Source Code": "https://github.com/byuccl/spydrnet",
}
-platforms = ['Linux', 'Mac OSX', 'Windows', 'Unix']
-keywords = ['Netlist', 'Analysis', 'Transformation',
- 'netlist', 'FPGA', 'primitives', 'module',
- 'port', 'EDIF', 'Digital', 'Hardware',]
+platforms = ["Linux", "Mac OSX", "Windows", "Unix"]
+keywords = [
+ "Netlist",
+ "Analysis",
+ "Transformation",
+ "netlist",
+ "FPGA",
+ "primitives",
+ "module",
+ "port",
+ "EDIF",
+ "Digital",
+ "Hardware",
+]
classifiers = [
- "Development Status :: 5 - Production/Stable",
- "Intended Audience :: Developers",
- "Intended Audience :: Education",
- "Intended Audience :: Science/Research",
- "License :: OSI Approved :: BSD License",
- "Operating System :: OS Independent",
- "Programming Language :: Python :: 3",
- "Programming Language :: Python :: 3.6",
- "Programming Language :: Python :: 3.7",
- "Programming Language :: Python :: 3.8",
- "Programming Language :: Python :: 3.9",
- "Programming Language :: Python :: 3.10",
- "Programming Language :: Python :: 3 :: Only",
- "Topic :: Education",
- "Topic :: Scientific/Engineering",
- 'Topic :: Scientific/Engineering :: Information Analysis',
- "Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)",
- "Topic :: Software Development :: Libraries :: Python Modules"
- ]
+ "Development Status :: 5 - Production/Stable",
+ "Intended Audience :: Developers",
+ "Intended Audience :: Education",
+ "Intended Audience :: Science/Research",
+ "License :: OSI Approved :: BSD License",
+ "Operating System :: OS Independent",
+ "Programming Language :: Python :: 3",
+ "Programming Language :: Python :: 3.6",
+ "Programming Language :: Python :: 3.7",
+ "Programming Language :: Python :: 3.8",
+ "Programming Language :: Python :: 3.9",
+ "Programming Language :: Python :: 3.10",
+ "Programming Language :: Python :: 3 :: Only",
+ "Topic :: Education",
+ "Topic :: Scientific/Engineering",
+ "Topic :: Scientific/Engineering :: Information Analysis",
+ "Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)",
+ "Topic :: Software Development :: Libraries :: Python Modules",
+]
directory = Path(Path(__file__).absolute()).parent
version_filename = Path(directory, "VERSION")
+
def load_versionfile():
global release
global version
@@ -63,54 +76,61 @@ def load_versionfile():
second_period_index = _get_second_period_index(release)
version = release[:second_period_index]
date = fi.readline().strip()
-
+
def _get_second_period_index(string_value):
period_count = 0
for index, char in enumerate(string_value):
- if string_value[index] == '.':
+ if string_value[index] == ".":
period_count += 1
if period_count == 2:
return index
return len(string_value)
+
load_versionfile()
+
def update_versionfile():
import datetime
import time
import subprocess
-
+
global version
global date
-
- date_info = datetime.datetime.utcfromtimestamp(int(os.environ.get('SOURCE_DATE_EPOCH', time.time())))
+
+ date_info = datetime.datetime.utcfromtimestamp(
+ int(os.environ.get("SOURCE_DATE_EPOCH", time.time()))
+ )
date = time.asctime(date_info.timetuple())
- #check for git on path
+ # check for git on path
git_exists = False
- for path in os.environ['PATH'].split(os.pathsep):
- exe_file = Path(path, 'git')
+ for path in os.environ["PATH"].split(os.pathsep):
+ exe_file = Path(path, "git")
if Path(exe_file).is_file() and os.access(exe_file, os.X_OK):
git_exists = True
else:
- exe_file = Path(path, 'git.exe')
+ exe_file = Path(path, "git.exe")
if Path(exe_file).is_file() and os.access(exe_file, os.X_OK):
git_exists = True
-
+
if git_exists:
- git_subprocess = subprocess.Popen("git describe", shell=True, cwd=directory, stdout=subprocess.PIPE)
+ git_subprocess = subprocess.Popen(
+ "git describe", shell=True, cwd=directory, stdout=subprocess.PIPE
+ )
git_describe_output = git_subprocess.stdout.read().decode()
git_version = git_describe_output.strip()
- if git_version.startswith('v'):
+ if git_version.startswith("v"):
version_file = Path(directory, "VERSION")
- with open(version_file, 'w') as fh:
- fh.write(git_version + '\n')
- fh.write(date + '\n')
+ with open(version_file, "w") as fh:
+ fh.write(git_version + "\n")
+ fh.write(date + "\n")
version = git_version[1:]
-
+
return version
-
-if __name__ == '__main__':
- update_versionfile()
\ No newline at end of file
+
+
+if __name__ == "__main__":
+ update_versionfile()
diff --git a/spydrnet/shortcuts/getter.py b/spydrnet/shortcuts/getter.py
index 11efa16c..3c6e1b23 100644
--- a/spydrnet/shortcuts/getter.py
+++ b/spydrnet/shortcuts/getter.py
@@ -7,6 +7,7 @@ def get_netlists(self, *args, **kwargs):
Shortcut to :py:func:`~spydrnet.get_netlists`.
"""
from spydrnet.util import get_netlists
+
return get_netlists(self, *args, **kwargs)
def get_libraries(self, *args, **kwargs):
@@ -15,6 +16,7 @@ def get_libraries(self, *args, **kwargs):
Shortcut to :py:func:`~spydrnet.get_libraries`.
"""
from spydrnet.util import get_libraries
+
return get_libraries(self, *args, **kwargs)
def get_definitions(self, *args, **kwargs):
@@ -23,6 +25,7 @@ def get_definitions(self, *args, **kwargs):
Shortcut to :py:func:`~spydrnet.get_definitions`.
"""
from spydrnet.util import get_definitions
+
return get_definitions(self, *args, **kwargs)
def get_instances(self, *args, **kwargs):
@@ -31,6 +34,7 @@ def get_instances(self, *args, **kwargs):
Shortcut to :py:func:`~spydrnet.get_instances`.
"""
from spydrnet.util import get_instances
+
return get_instances(self, *args, **kwargs)
def get_ports(self, *args, **kwargs):
@@ -39,6 +43,7 @@ def get_ports(self, *args, **kwargs):
Shortcut to :py:func:`~spydrnet.get_ports`.
"""
from spydrnet.util import get_ports
+
return get_ports(self, *args, **kwargs)
def get_pins(self, *args, **kwargs):
@@ -47,6 +52,7 @@ def get_pins(self, *args, **kwargs):
Shortcut to :py:func:`~spydrnet.get_pins`.
"""
from spydrnet.util import get_pins
+
return get_pins(self, *args, **kwargs)
def get_cables(self, *args, **kwargs):
@@ -55,6 +61,7 @@ def get_cables(self, *args, **kwargs):
Shortcut to :py:func:`~spydrnet.get_cables`.
"""
from spydrnet.util import get_cables
+
return get_cables(self, *args, **kwargs)
def get_wires(self, *args, **kwargs):
@@ -63,6 +70,7 @@ def get_wires(self, *args, **kwargs):
Shortcut to :py:func:`~spydrnet.get_wires`.
"""
from spydrnet.util import get_wires
+
return get_wires(self, *args, **kwargs)
def get_hinstances(self, *args, **kwargs):
@@ -71,6 +79,7 @@ def get_hinstances(self, *args, **kwargs):
Shortcut to :py:func:`~spydrnet.get_hinstances`.
"""
from spydrnet.util import get_hinstances
+
return get_hinstances(self, *args, **kwargs)
def get_hports(self, *args, **kwargs):
@@ -79,6 +88,7 @@ def get_hports(self, *args, **kwargs):
Shortcut to :py:func:`~spydrnet.get_hports`.
"""
from spydrnet.util import get_hports
+
return get_hports(self, *args, **kwargs)
def get_hpins(self, *args, **kwargs):
@@ -87,6 +97,7 @@ def get_hpins(self, *args, **kwargs):
Shortcut to :py:func:`~spydrnet.get_hpins`.
"""
from spydrnet.util import get_hpins
+
return get_hpins(self, *args, **kwargs)
def get_hcables(self, *args, **kwargs):
@@ -95,6 +106,7 @@ def get_hcables(self, *args, **kwargs):
Shortcut to :py:func:`~spydrnet.get_hcables`.
"""
from spydrnet.util import get_hcables
+
return get_hcables(self, *args, **kwargs)
def get_hwires(self, *args, **kwargs):
@@ -103,4 +115,5 @@ def get_hwires(self, *args, **kwargs):
Shortcut to :py:func:`~spydrnet.get_hwires`.
"""
from spydrnet.util import get_hwires
+
return get_hwires(self, *args, **kwargs)
diff --git a/spydrnet/testing/__init__.py b/spydrnet/testing/__init__.py
index 9498b6f6..b98bd9c7 100644
--- a/spydrnet/testing/__init__.py
+++ b/spydrnet/testing/__init__.py
@@ -1,2 +1,2 @@
from spydrnet.testing.utils import *
-from spydrnet.testing.test import run
\ No newline at end of file
+from spydrnet.testing.test import run
diff --git a/spydrnet/testing/test.py b/spydrnet/testing/test.py
index 71ed66c3..3c7612a8 100644
--- a/spydrnet/testing/test.py
+++ b/spydrnet/testing/test.py
@@ -1,21 +1,21 @@
def run(verbosity=1, doctest=False):
"""Run SpyDrNet tests.
-
+
Parameters
----------
verbosity: integer, optional
Level of detail in test reports. Higher numbers provide more detail.
-
+
doctest: bool, optional
True to run doctests in code modules
"""
import pytest
- pytest_args = ['-l']
+ pytest_args = ["-l"]
if verbosity and int(verbosity) > 1:
- pytest_args += ["-" + "v"*(int(verbosity)-1)]
+ pytest_args += ["-" + "v" * (int(verbosity) - 1)]
if doctest:
pytest_args += ["--doctest-modules"]
@@ -27,8 +27,8 @@ def run(verbosity=1, doctest=False):
except SystemExit as exc:
code = exc.code
- return (code == 0)
+ return code == 0
if __name__ == "__main__":
- run()
\ No newline at end of file
+ run()
diff --git a/spydrnet/uniquify.py b/spydrnet/uniquify.py
index a7fd13da..18226eb9 100644
--- a/spydrnet/uniquify.py
+++ b/spydrnet/uniquify.py
@@ -1,11 +1,14 @@
# Copyright 2020 Dallin Skouson, Andrew Keller, Michael Wirthlin
from collections import deque
+
# from spydrnet.ir import *
-"""Code to make definitions unique throughout a netlist.
+"""
+Code to make definitions unique throughout a netlist.
expected parameters,
-uniqify -- Makes all definitions unique below the top instance. definitions that are not referenced below the top instance will not be unique.
+uniqify -- Makes all definitions unique below the top instance. definitions that are not referenced
+below the top instance will not be unique.
"""
@@ -29,9 +32,8 @@ def _make_instance_unique(instance):
name = instance.reference.name
unique_suffix = _get_unique_name_modifier()
new_def.name = name + unique_suffix
- if 'EDIF.identifier' in new_def:
- new_def['EDIF.identifier'] = new_def['EDIF.identifier'] + \
- unique_suffix
+ if "EDIF.identifier" in new_def:
+ new_def["EDIF.identifier"] = new_def["EDIF.identifier"] + unique_suffix
lib.add_definition(new_def, index + 1)
instance.reference = new_def
@@ -42,12 +44,18 @@ def _is_unique(instance):
def uniquify(netlist):
- """Make the instances in the netlist unique
- uniqification is done in place. Each instance will correspond to exactly one definition and each definition will correspond to exactly one instance with the exception of leaf cells.
- Leaf cells are can be instanced unlimited numbers of times. Any netlist elements that are not instantiated by the top instance will not be modified and may retain duplicate instances
- Currently there is no guarantee that the original definition names will be maintained, but it is guaranteed that they will be unique within the scope of all hardware that is below the top instance.
-
- Renaming is predictable. the string: _sdn_unique_# will be added to the end of the definition names.
+ """
+ Make the instances in the netlist unique
+ -----------------------------------------
+ Uniqification is done in place. Each instance will correspond to exactly one definition and each
+ definition will correspond to exactly one instance with the exception of leaf cells. Leaf cells
+ are can be instanced unlimited numbers of times. Any netlist elements that are not instantiated
+ by the top instance will not be modified and may retain duplicate instances Currently there is
+ no guarantee that the original definition names will be maintained, but it is guaranteed that
+ they will be unique within the scope of all hardware that is below the top instance.
+
+ Renaming is predictable. the string: _sdn_unique_# will be added to the end of the definition
+ names.
:param netlist: the netlist that will be uniquified
@@ -57,7 +65,8 @@ def uniquify(netlist):
# import pdb; pdb.set_trace()
# starting with top.
- # top must be unique below top. otherwise we have infinite harware recursion which is does not make much sense.
+ # top must be unique below top. otherwise we have infinite harware recursion which is does not
+ # make much sense.
instance_queue = deque()
top_instance = netlist.top_instance
diff --git a/spydrnet/util/architecture.py b/spydrnet/util/architecture.py
index db602ff7..d37946f2 100644
--- a/spydrnet/util/architecture.py
+++ b/spydrnet/util/architecture.py
@@ -1,10 +1,9 @@
-import os
+from pathlib import Path
import spydrnet as sdn
-base_dir = os.path.dirname(os.path.abspath(sdn.__file__))
-base_file_path = os.path.join(base_dir, 'support_files', 'architecture_libraries')
+base_file_path = Path(sdn.base_dir, "support_files", "architecture_libraries")
-XILINX_7SERIES = os.path.join(base_file_path, "xilinx_7series.v.zip")
-F4PGA_XILINX_7SERIES = os.path.join(base_file_path, "f4pga_xilinx_7series.v.zip")
-LATTICE_LIFCL = os.path.join(base_file_path, "lifcl.v.zip")
-YOSYS_CELLS = os.path.join(base_file_path, "yosys_internal_cells.v.zip")
\ No newline at end of file
+XILINX_7SERIES = Path(base_file_path).joinpath("xilinx_7series.v.zip")
+F4PGA_XILINX_7SERIES = Path(base_file_path).joinpath("f4pga_xilinx_7series.v.zip")
+LATTICE_LIFCL = Path(base_file_path).joinpath("lifcl.v.zip")
+YOSYS_CELLS = Path(base_file_path).joinpath("yosys_internal_cells.v.zip")
diff --git a/spydrnet/util/get_cables.py b/spydrnet/util/get_cables.py
index 70a65fc6..63b96576 100644
--- a/spydrnet/util/get_cables.py
+++ b/spydrnet/util/get_cables.py
@@ -1,5 +1,15 @@
-from spydrnet.ir import InnerPin, OuterPin, Wire, Netlist, Library, Definition, Cable, Element,\
- Instance, Port
+from spydrnet.ir import (
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition,
+ Cable,
+ Element,
+ Instance,
+ Port,
+)
from spydrnet.util.hierarchical_reference import HRef
from spydrnet.util.selection import Selection
from spydrnet.global_state.global_service import lookup
@@ -13,63 +23,82 @@ def get_cables(obj, *args, **kwargs):
Get cables *within* an object.
Parameters
- ----------
+ ----------
obj : object, Iterable - required
- The object or objects associated with this query. Queries return a collection objects associated with the
- provided object or objects that match the query criteria. For example, `sdn.get_cables(definition, ...)` would
- return all of the cables associated with the provided definition that match the additional criteria.
+ The object or objects associated with this query. Queries return a collection objects
+ associated with the provided object or objects that match the query criteria. For example,
+ `sdn.get_cables(definition, ...)` would return all of the cables associated with the
+ provided definition that match the additional criteria.
patterns : str, Iterable - optional, positional or named, default: wildcard
- The search patterns. Patterns can be a single string or an Iterable collection of strings. Patterns can be
- absolute or they can contain wildcards or regular expressions. If `patterns` is not provided, then it defaults
- to a wildcard. Patterns are queried against the object property value stored under a specified key. Fast lookups
- are only attempted on absolute patterns that are not regular expressions and contain no wildcards.
+ The search patterns. Patterns can be a single string or an Iterable collection of strings.
+ Patterns can be absolute or they can contain wildcards or regular expressions. If
+ `patterns` is not provided, then it defaults to a wildcard. Patterns are queried against
+ the object property value stored under a specified key. Fast lookups are only attempted on
+ absolute patterns that are not regular expressions and contain no wildcards.
key : str, optional, default: ".NAME"
- This is the key that controls which value is being searched.
+ This is the key that controls which value is being searched.
is_case : bool - optional, named, default: True
- Specify if patterns should be treated as case sensitive. Only applies to patterns. Does not alter fast lookup
- behavior (if namespace policy uses case insensitive indexing, this parameter will not prevent a fast lookup
- from returning a matching object even if the case is not an exact match).
+ Specify if patterns should be treated as case sensitive. Only applies to patterns. Does not
+ alter fast lookup behavior (if namespace policy uses case insensitive indexing, this
+ parameter will not prevent a fast lookup from returning a matching object even if the case
+ is not an exact match).
is_re: bool - optional, named, default: False
- Specify if patterns are regular expressions. If `False`, a pattern can still contain `*` and `?` wildcards. A
- `*` matches zero or more characters. A `?` matches upto a single character.
+ Specify if patterns are regular expressions. If `False`, a pattern can still contain `*`
+ and `?` wildcards. A `*` matches zero or more characters. A `?` matches upto a single
+ character.
selection : Selection.{INSIDE, OUTSIDE, BOTH, ALL}, default: INSIDE
- This parameter determines the wires that are returned based on the instance associated with the object that is
- being searched.
+ This parameter determines the wires that are returned based on the instance associated with
+ the object that is being searched.
recursive : bool - optional, default: False
- Specify if search should be recursive or not meaning that sub hierarchical instances within an instance are
- included or not.
+ Specify if search should be recursive or not meaning that sub hierarchical instances within
+ an instance are included or not.
filter : function
- This is a single input function that can be used to filter out unwanted virtual instances. If not specifed, all
- matching virtual instances are returned. Otherwise, virtual instances that cause the filter function to evaluate
- to true are the only items returned.
-
+ This is a single input function that can be used to filter out unwanted virtual instances.
+ If not specifed, all matching virtual instances are returned. Otherwise, virtual instances
+ that cause the filter function to evaluate to true are the only items returned.
+
Returns
-------
cables : generator
- The cables associated with a particular object or collection of objects.
-
+ The cables associated with a particular object or collection of objects.
+
"""
# Check argument list
- if len(args) == 1 and 'patterns' in kwargs:
+ if len(args) == 1 and "patterns" in kwargs:
raise TypeError("get_cables() got multiple values for argument 'patterns'")
- if len(args) > 1 or any(x not in {'patterns', 'key', 'filter', 'is_case', 'is_re', 'selection', 'recursive'}
- for x in kwargs):
+ if len(args) > 1 or any(
+ x
+ not in {
+ "patterns",
+ "key",
+ "filter",
+ "is_case",
+ "is_re",
+ "selection",
+ "recursive",
+ }
+ for x in kwargs
+ ):
raise TypeError("Unknown usage. Please see help for more information.")
# Default values
- selection = kwargs.get('selection', Selection.INSIDE)
+ selection = kwargs.get("selection", Selection.INSIDE)
if isinstance(selection, str):
if selection in Selection.__members__:
selection = Selection[selection]
if isinstance(selection, Selection) is False:
- raise TypeError("selection must be '{}'".format("', '".join(Selection.__members__.keys())))
+ raise TypeError(
+ "selection must be '{}'".format("', '".join(Selection.__members__.keys()))
+ )
- filter_func = kwargs.get('filter', lambda x: True)
- is_case = kwargs.get('is_case', True)
- is_re = kwargs.get('is_re', False)
- patterns = args[0] if len(args) == 1 else kwargs.get('patterns', ".*" if is_re else "*")
- key = kwargs.get('key', ".NAME")
- recursive = kwargs.get('recursive', False)
+ filter_func = kwargs.get("filter", lambda x: True)
+ is_case = kwargs.get("is_case", True)
+ is_re = kwargs.get("is_re", False)
+ patterns = (
+ args[0] if len(args) == 1 else kwargs.get("patterns", ".*" if is_re else "*")
+ )
+ key = kwargs.get("key", ".NAME")
+ recursive = kwargs.get("recursive", False)
if isinstance(obj, (Element, HRef)) is False:
try:
@@ -79,22 +108,41 @@ def get_cables(obj, *args, **kwargs):
else:
object_collection = [obj]
if all(isinstance(x, (Element, HRef)) for x in object_collection) is False:
- raise TypeError("get_cables() only supports netlists, libraries, and definitions, or a collection of these as "
- "the object searched")
+ raise TypeError(
+ "get_cables() only supports netlists, libraries, and definitions, or a collection of \
+ these as the object searched"
+ )
if isinstance(patterns, str):
patterns = (patterns,)
- return _get_cables(object_collection, patterns, key, is_case, is_re, selection, recursive, filter_func)
+ return _get_cables(
+ object_collection,
+ patterns,
+ key,
+ is_case,
+ is_re,
+ selection,
+ recursive,
+ filter_func,
+ )
-def _get_cables(object_collection, patterns, key, is_case, is_re, selection, recursive, filter_func):
- for result in filter(filter_func, _get_cables_raw(object_collection, patterns, key, is_case, is_re, selection,
- recursive)):
+def _get_cables(
+ object_collection, patterns, key, is_case, is_re, selection, recursive, filter_func
+):
+ for result in filter(
+ filter_func,
+ _get_cables_raw(
+ object_collection, patterns, key, is_case, is_re, selection, recursive
+ ),
+ ):
yield result
-def _get_cables_raw(object_collection, patterns, key, is_case, is_re, selection, recursive):
+def _get_cables_raw(
+ object_collection, patterns, key, is_case, is_re, selection, recursive
+):
found = set()
other_cables = set()
searched_wires = set()
@@ -111,8 +159,10 @@ def _get_cables_raw(object_collection, patterns, key, is_case, is_re, selection,
yield result
else:
for cable in obj.cables:
- value = cable[key] if key in cable else ''
- if cable not in found and _value_matches_pattern(value, pattern, is_case, is_re):
+ value = cable[key] if key in cable else ""
+ if cable not in found and _value_matches_pattern(
+ value, pattern, is_case, is_re
+ ):
found.add(cable)
yield cable
if recursive or selection == Selection.ALL:
@@ -212,13 +262,13 @@ def _get_cables_raw(object_collection, patterns, key, is_case, is_re, selection,
object_collection.append(obj.item)
if other_cables:
- namemap = dict()
+ namemap = {}
for other_cable in other_cables:
if other_cable not in found:
found.add(other_cable)
- name = other_cable[key] if key in other_cable else ''
+ name = other_cable[key] if key in other_cable else ""
if name not in namemap:
- namemap[name] = list()
+ namemap[name] = []
namemap[name].append(other_cable)
for pattern in patterns:
pattern_is_absolute = _is_pattern_absolute(pattern, is_case, is_re)
@@ -229,7 +279,7 @@ def _get_cables_raw(object_collection, patterns, key, is_case, is_re, selection,
for port in result:
yield port
else:
- names_to_remove = list()
+ names_to_remove = []
for name in namemap:
if _value_matches_pattern(name, pattern, is_case, is_re):
result = namemap[name]
diff --git a/spydrnet/util/get_definitions.py b/spydrnet/util/get_definitions.py
index b7359823..0fa646aa 100644
--- a/spydrnet/util/get_definitions.py
+++ b/spydrnet/util/get_definitions.py
@@ -1,5 +1,15 @@
-from spydrnet.ir import InnerPin, OuterPin, Wire, Netlist, Library, Definition, Element, Instance,\
- Port, Cable
+from spydrnet.ir import (
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition,
+ Element,
+ Instance,
+ Port,
+ Cable,
+)
from spydrnet.util.hierarchical_reference import HRef
from spydrnet.util.selection import Selection
from spydrnet.global_state.global_service import lookup
@@ -15,64 +25,86 @@ def get_definitions(obj, *args, **kwargs):
Parameters
----------
obj : object, Iterable - required
- The object or objects associated with this query. Queries return a collection objects associated with the
- provided object or objects that match the query criteria. For example, `sdn.get_definitions(library, ...)` would
- return all of the definitions associated with the provided library that match the additional criteria.
+ The object or objects associated with this query. Queries return a collection objects
+ associated with the provided object or objects that match the query criteria. For example,
+ `sdn.get_definitions(library, ...)` would return all of the definitions associated with the
+ provided library that match the additional criteria.
patterns : str, Iterable - optional, positional or named, default: wildcard
- The search patterns. Patterns can be a single string or an Iterable collection of strings. Patterns can be
- absolute or they can contain wildcards or regular expressions. If `patterns` is not provided, then it defaults
- to a wildcard. Patterns are queried against the object property value stored under a specified key. Fast lookups
- are only attempted on absolute patterns that are not regular expressions and contain no wildcards.
+ The search patterns. Patterns can be a single string or an Iterable collection of strings.
+ Patterns can be absolute or they can contain wildcards or regular expressions. If
+ `patterns` is not provided, then it defaults to a wildcard. Patterns are queried against
+ the object property value stored under a specified key. Fast lookups are only attempted on
+ absolute patterns that are not regular expressions and contain no wildcards.
key : str, optional, default: ".NAME"
- This is the key that controls which value is being searched.
+ This is the key that controls which value is being searched.
is_case : bool - optional, named, default: True
- Specify if patterns should be treated as case sensitive. Only applies to patterns. Does not alter fast lookup
- behavior (if namespace policy uses case insensitive indexing, this parameter will not prevent a fast lookup
- from returning a matching object even if the case is not an exact match).
+ Specify if patterns should be treated as case sensitive. Only applies to patterns. Does not
+ alter fast lookup behavior (if namespace policy uses case insensitive indexing, this
+ parameter will not prevent a fast lookup from returning a matching object even if the case
+ is not an exact match).
is_re: bool - optional, named, default: False
- Specify if patterns are regular expressions. If `False`, a pattern can still contain `*` and `?` wildcards. A
- `*` matches zero or more characters. A `?` matches upto a single character.
+ Specify if patterns are regular expressions. If `False`, a pattern can still contain `*`
+ and `?` wildcards. A `*` matches zero or more characters. A `?` matches upto a single
+ character.
recursive : bool - optional, default: False
- Specify if search should be recursive or not meaning that sub hierarchical instances within an instance are
- included or not.
+ Specify if search should be recursive or not meaning that sub hierarchical instances within
+ an instance are included or not.
selection : Selection.{INSIDE, OUTSIDE}, default: INSIDE
- This parameter determines the instances that are returned based on the definition that is being searched. This
- parameter only applies to objects that are definitions. If the selection is "INSIDE" (default), then the
- function will return all of the instances that are inside the definition (i.e., the definition's children) that
- match the remainder of the search criteria. If the selection is "OUTSIDE", then the function will return all of
- the instances of the provided definition that match the remainder of the search criteria.
+ This parameter determines the instances that are returned based on the definition that is
+ being searched. This parameter only applies to objects that are definitions. If the
+ selection is "INSIDE" (default), then the function will return all of the instances that
+ are inside the definition (i.e., the definition's children) that match the remainder of the
+ search criteria. If the selection is "OUTSIDE", then the function will return all of the
+ instances of the provided definition that match the remainder of the search criteria.
filter : function
- This is a single input function that can be used to filter out unwanted virtual instances. If not specifed, all
- matching virtual instances are returned. Otherwise, virtual instances that cause the filter function to evaluate
- to true are the only items returned.
-
+ This is a single input function that can be used to filter out unwanted virtual instances.
+ If not specifed, all matching virtual instances are returned. Otherwise, virtual instances
+ that cause the filter function to evaluate to true are the only items returned.
+
Returns
-------
definitions : generator
- The definitions associated with a particular object or collection of objects.
-
+ The definitions associated with a particular object or collection of objects.
+
"""
# Check argument list
- if len(args) == 1 and 'patterns' in kwargs:
+ if len(args) == 1 and "patterns" in kwargs:
raise TypeError("get_definitions() got multiple values for argument 'patterns'")
- if len(args) > 1 or any(x not in {'patterns', 'key', 'filter', 'is_case', 'is_re', 'selection', 'recursive'}
- for x in kwargs):
+ if len(args) > 1 or any(
+ x
+ not in {
+ "patterns",
+ "key",
+ "filter",
+ "is_case",
+ "is_re",
+ "selection",
+ "recursive",
+ }
+ for x in kwargs
+ ):
raise TypeError("Unknown usage. Please see help for more information.")
# Default values
- selection = kwargs.get('selection', Selection.INSIDE)
+ selection = kwargs.get("selection", Selection.INSIDE)
if isinstance(selection, str):
if selection in Selection.__members__:
selection = Selection[selection]
if selection not in {Selection.INSIDE, Selection.OUTSIDE}:
- raise TypeError("selection must be '{}'".format("', '".join([Selection.INSIDE.name, Selection.OUTSIDE.name])))
+ raise TypeError(
+ "selection must be '{}'".format(
+ "', '".join([Selection.INSIDE.name, Selection.OUTSIDE.name])
+ )
+ )
- filter_func = kwargs.get('filter', lambda x: True)
- is_case = kwargs.get('is_case', True)
- is_re = kwargs.get('is_re', False)
- patterns = args[0] if len(args) == 1 else kwargs.get('patterns', ".*" if is_re else "*")
- key = kwargs.get('key', ".NAME")
- recursive = kwargs.get('recursive', False)
+ filter_func = kwargs.get("filter", lambda x: True)
+ is_case = kwargs.get("is_case", True)
+ is_re = kwargs.get("is_re", False)
+ patterns = (
+ args[0] if len(args) == 1 else kwargs.get("patterns", ".*" if is_re else "*")
+ )
+ key = kwargs.get("key", ".NAME")
+ recursive = kwargs.get("recursive", False)
if isinstance(obj, (Element, HRef)) is False:
try:
@@ -82,22 +114,41 @@ def get_definitions(obj, *args, **kwargs):
else:
object_collection = [obj]
if all(isinstance(x, (Element, HRef)) for x in object_collection) is False:
- raise TypeError("get_definitions() only supports netlists and libraries or a collection of them as the object "
- "searched")
+ raise TypeError(
+ "get_definitions() only supports netlists and libraries or a collection of them as \
+ the object searched"
+ )
if isinstance(patterns, str):
patterns = (patterns,)
- return _get_definitions(object_collection, patterns, key, is_case, is_re, selection, recursive, filter_func)
+ return _get_definitions(
+ object_collection,
+ patterns,
+ key,
+ is_case,
+ is_re,
+ selection,
+ recursive,
+ filter_func,
+ )
-def _get_definitions(object_collection, patterns, key, is_case, is_re, selection, recursive, filter_func):
- for result in filter(filter_func, _get_definitions_raw(object_collection, patterns, key, is_case, is_re,
- selection, recursive)):
+def _get_definitions(
+ object_collection, patterns, key, is_case, is_re, selection, recursive, filter_func
+):
+ for result in filter(
+ filter_func,
+ _get_definitions_raw(
+ object_collection, patterns, key, is_case, is_re, selection, recursive
+ ),
+ ):
yield result
-def _get_definitions_raw(object_collection, patterns, key, is_case, is_re, selection, recursive):
+def _get_definitions_raw(
+ object_collection, patterns, key, is_case, is_re, selection, recursive
+):
found = set()
other_definitions = set()
while object_collection:
@@ -113,8 +164,10 @@ def _get_definitions_raw(object_collection, patterns, key, is_case, is_re, selec
yield result
else:
for definition in obj.definitions:
- value = definition[key] if key in definition else ''
- if definition not in found and _value_matches_pattern(value, pattern, is_case, is_re):
+ value = definition[key] if key in definition else ""
+ if definition not in found and _value_matches_pattern(
+ value, pattern, is_case, is_re
+ ):
found.add(definition)
yield definition
if recursive:
@@ -177,14 +230,14 @@ def _get_definitions_raw(object_collection, patterns, key, is_case, is_re, selec
object_collection.append(obj.item)
if other_definitions:
- namemap = dict()
+ namemap = {}
for other_definition in other_definitions:
if other_definition in found:
continue
found.add(other_definition)
- name = other_definition[key] if key in other_definition else ''
+ name = other_definition[key] if key in other_definition else ""
if name not in namemap:
- namemap[name] = list()
+ namemap[name] = []
namemap[name].append(other_definition)
for pattern in patterns:
pattern_is_absolute = _is_pattern_absolute(pattern, is_case, is_re)
@@ -194,7 +247,7 @@ def _get_definitions_raw(object_collection, patterns, key, is_case, is_re, selec
for definition in result:
yield definition
else:
- names_to_remove = list()
+ names_to_remove = []
for name in namemap:
if _value_matches_pattern(name, pattern, is_case, is_re):
result = namemap[name]
diff --git a/spydrnet/util/get_hcables.py b/spydrnet/util/get_hcables.py
index 5ca76cce..b30702f5 100644
--- a/spydrnet/util/get_hcables.py
+++ b/spydrnet/util/get_hcables.py
@@ -1,4 +1,15 @@
-from spydrnet import FirstClassElement, InnerPin, OuterPin, Wire, Netlist, Library, Definition, Instance, Port, Cable
+from spydrnet import (
+ FirstClassElement,
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition,
+ Instance,
+ Port,
+ Cable,
+)
from spydrnet.util.hierarchical_reference import HRef
from spydrnet.util.selection import Selection
from spydrnet.util.patterns import _is_pattern_absolute, _value_matches_pattern
@@ -13,57 +24,67 @@ def get_hcables(obj, *args, **kwargs):
Parameters
----------
obj : object, Iterable - required
- The object or objects associated with this query. Queries return a collection of objects associated with the
- provided object or objects that match the query criteria. For example, `sdn.get_instances(netlist, ...)` would
- return all of the instances *within* the provided definition that match the additional criteria.
+ The object or objects associated with this query. Queries return a collection of objects
+ associated with the provided object or objects that match the query criteria. For example,
+ `sdn.get_instances(netlist, ...)` would return all of the instances *within* the provided
+ definition that match the additional criteria.
patterns : str, Iterable - optional, positional or named, default: wildcard
- The search patterns. Patterns can be a single string or an Iterable collection of strings. Patterns can be
- absolute or they can contain wildcards or regular expressions. If `patterns` is not provided, then it defaults
- to a wildcard.
+ The search patterns. Patterns can be a single string or an Iterable collection of strings.
+ Patterns can be absolute or they can contain wildcards or regular expressions. If
+ `patterns` is not provided, then it defaults to a wildcard.
is_case : bool - optional, named, default: True
- Specify if patterns should be treated as case sensitive. Only applies to patterns. Does not alter fast lookup
- behavior (if namespace policy uses case insensitive indexing, this parameter will not prevent a fast lookup
- from returning a matching object even if the case is not an exact match).
+ Specify if patterns should be treated as case sensitive. Only applies to patterns. Does not
+ alter fast lookup behavior (if namespace policy uses case insensitive indexing, this
+ parameter will not prevent a fast lookup from returning a matching object even if the case
+ is not an exact match).
is_re: bool - optional, named, default: False
- Specify if patterns are regular expressions. If `False`, a pattern can still contain `*` and `?` wildcards. A
- `*` matches zero or more characters. A `?` matches upto a single character.
+ Specify if patterns are regular expressions. If `False`, a pattern can still contain `*`
+ and `?` wildcards. A `*` matches zero or more characters. A `?` matches upto a single
+ character.
selection : Selection.{INSIDE, OUTSIDE, BOTH, ALL}, default: INSIDE
- This parameter determines the wires that are returned based on the instance associated with the object that is
- being searched.
+ This parameter determines the wires that are returned based on the instance associated
+ with the object that is being searched.
recursive : bool - optional, default: False
- Specify if search should be recursive or not meaning that sub hierarchical instances within an instance are
- included or not.
+ Specify if search should be recursive or not meaning that sub hierarchical instances within
+ an instance are included or not.
filter : function
- This is a single input function that can be used to filter out unwanted virtual instances. If not specifed, all
- matching virtual instances are returned. Otherwise, virtual instances that cause the filter function to evaluate
- to true are the only items returned.
-
+ This is a single input function that can be used to filter out unwanted virtual instances.
+ If not specifed, all matching virtual instances are returned. Otherwise, virtual instances
+ that cause the filter function to evaluate to true are the only items returned.
+
Returns
-------
href_cables : generator
- The hierarchical references to cables associated with a particular object or collection of objects.
-
+ The hierarchical references to cables associated with a particular object or collection
+ of objects.
+
"""
# Check argument list
- if len(args) == 1 and 'patterns' in kwargs:
+ if len(args) == 1 and "patterns" in kwargs:
raise TypeError("get_hwires() got multiple values for argument 'patterns'")
- if len(args) > 1 or any(x not in {'patterns', 'selection', 'recursive', 'filter', 'is_case', 'is_re'} for x in
- kwargs):
+ if len(args) > 1 or any(
+ x not in {"patterns", "selection", "recursive", "filter", "is_case", "is_re"}
+ for x in kwargs
+ ):
raise TypeError("Unknown usage. Please see help for more information.")
# Default values
- selection = kwargs.get('selection', Selection.INSIDE)
+ selection = kwargs.get("selection", Selection.INSIDE)
if isinstance(selection, str):
if selection in Selection.__members__:
selection = Selection[selection]
if isinstance(selection, Selection) is False:
- raise TypeError("selection must be '{}'".format("', '".join(Selection.__members__.keys())))
+ raise TypeError(
+ "selection must be '{}'".format("', '".join(Selection.__members__.keys()))
+ )
- filter_func = kwargs.get('filter', lambda x: True)
- recursive = kwargs.get('recursive', False)
- is_case = kwargs.get('is_case', True)
- is_re = kwargs.get('is_re', False)
- patterns = args[0] if len(args) == 1 else kwargs.get('patterns', ".*" if is_re else "*")
+ filter_func = kwargs.get("filter", lambda x: True)
+ recursive = kwargs.get("recursive", False)
+ is_case = kwargs.get("is_case", True)
+ is_re = kwargs.get("is_re", False)
+ patterns = (
+ args[0] if len(args) == 1 else kwargs.get("patterns", ".*" if is_re else "*")
+ )
if isinstance(obj, (FirstClassElement, InnerPin, OuterPin, Wire)) is False:
try:
@@ -72,26 +93,43 @@ def get_hcables(obj, *args, **kwargs):
object_collection = [obj]
else:
object_collection = [obj]
- if all(isinstance(x, (HRef, FirstClassElement, InnerPin, OuterPin, Wire)) for x in object_collection) is False:
- raise TypeError("get_hwires() supports all netlist related objects and hierarchical references or a "
- "collection of theses as the object searched, unsupported object provided")
+ if (
+ all(
+ isinstance(x, (HRef, FirstClassElement, InnerPin, OuterPin, Wire))
+ for x in object_collection
+ )
+ is False
+ ):
+ raise TypeError(
+ "get_hwires() supports all netlist related objects and hierarchical references or a "
+ "collection of theses as the object searched, unsupported object provided"
+ )
if isinstance(patterns, str):
patterns = (patterns,)
assert isinstance(patterns, (FirstClassElement, InnerPin, OuterPin, Wire)) is False
- return _get_hcables(object_collection, selection, patterns, recursive, is_case, is_re, filter_func)
+ return _get_hcables(
+ object_collection, selection, patterns, recursive, is_case, is_re, filter_func
+ )
-def _get_hcables(object_collection, selection, patterns, recursive, is_case, is_re, filter_func):
- for result in filter(filter_func, _get_hcables_raw(object_collection, selection, patterns, recursive, is_case, is_re)):
+def _get_hcables(
+ object_collection, selection, patterns, recursive, is_case, is_re, filter_func
+):
+ for result in filter(
+ filter_func,
+ _get_hcables_raw(
+ object_collection, selection, patterns, recursive, is_case, is_re
+ ),
+ ):
yield result
def _get_hcables_raw(object_collection, selection, patterns, recursive, is_case, is_re):
in_namemap = set()
in_yield = set()
- namemap = dict()
+ namemap = {}
hpin_search = set()
bypass_namesearch = set()
while object_collection:
@@ -118,14 +156,18 @@ def _get_hcables_raw(object_collection, selection, patterns, recursive, is_case,
hcable = HRef.from_parent_and_item(obj, cable)
if hcable not in in_yield:
in_yield.add(hcable)
- yield(hcable)
+ yield (hcable)
# get internal cables recursively
if recursive or selection == Selection.ALL:
for child in reference.children:
href_child = HRef.from_parent_and_item(obj, child)
bypass_namesearch.add(href_child)
object_collection.append(href_child)
- if selection in {Selection.OUTSIDE, Selection.BOTH, Selection.ALL}:
+ if selection in {
+ Selection.OUTSIDE,
+ Selection.BOTH,
+ Selection.ALL,
+ }:
for port in reference.ports:
href_port = HRef.from_parent_and_item(obj, port)
for pin in port.pins:
@@ -150,11 +192,15 @@ def _get_hcables_raw(object_collection, selection, patterns, recursive, is_case,
href_parent_instance = href_parent_cable.parent
for pin in item.pins:
if isinstance(pin, OuterPin):
- href_inst = HRef.from_parent_and_item(href_parent_instance, pin.instance)
+ href_inst = HRef.from_parent_and_item(
+ href_parent_instance, pin.instance
+ )
inner_wire = pin.inner_pin.wire
if inner_wire:
inner_cable = inner_wire.cable
- href_cable = HRef.from_parent_and_item(href_inst, inner_cable)
+ href_cable = HRef.from_parent_and_item(
+ href_inst, inner_cable
+ )
if href_cable not in in_yield:
in_yield.add(href_cable)
yield href_cable
@@ -167,7 +213,9 @@ def _get_hcables_raw(object_collection, selection, patterns, recursive, is_case,
outer_wire = outer_pin.wire
if outer_wire:
outer_cable = outer_wire.cable
- href_cable = HRef.from_parent_and_item(href_parent, outer_cable)
+ href_cable = HRef.from_parent_and_item(
+ href_parent, outer_cable
+ )
if href_cable not in in_yield:
in_yield.add(href_cable)
yield href_cable
@@ -179,7 +227,9 @@ def _get_hcables_raw(object_collection, selection, patterns, recursive, is_case,
href_inst = href_cable.parent
for pin in item.pins:
if isinstance(pin, OuterPin):
- href_inst = HRef.from_parent_and_item(obj.parent, pin.instance)
+ href_inst = HRef.from_parent_and_item(
+ obj.parent, pin.instance
+ )
inner_pin = pin.inner_pin
port = inner_pin.port
href_port = HRef.from_parent_and_item(href_inst, port)
@@ -236,25 +286,27 @@ def _get_hcables_raw(object_collection, selection, patterns, recursive, is_case,
def _update_hcable_namemap(href_instance, recursive, found, namemap):
search_stack = [(href_instance, False)]
- name_stack = list()
+ name_stack = []
while search_stack:
href_instance, visited = search_stack.pop()
if visited:
name_stack.pop()
else:
search_stack.append((href_instance, True))
- name_stack.append(href_instance.item.name if href_instance.item.name else '')
+ name_stack.append(
+ href_instance.item.name if href_instance.item.name else ""
+ )
item = href_instance.item
reference = item.reference
if reference:
for cable in reference.cables:
hcable = HRef.from_parent_and_item(href_instance, cable)
- name_stack.append(cable.name if cable.name else '')
- cable_hname = '/'.join(name_stack[1:])
+ name_stack.append(cable.name if cable.name else "")
+ cable_hname = "/".join(name_stack[1:])
if hcable not in found:
found.add(hcable)
if cable_hname not in namemap:
- namemap[cable_hname] = list()
+ namemap[cable_hname] = []
namemap[cable_hname].append(hcable)
name_stack.pop()
if recursive:
@@ -274,26 +326,30 @@ def _get_hwires_from_hpins(hpin_search, selection):
if hwire_inside and hwire_inside not in found_hwires:
found_hwires.add(hwire_inside)
yield hwire_inside
- search_stack += (x for x in _get_hpins_from_hwire(hwire_inside) if x != hpin)
+ search_stack += (
+ x for x in _get_hpins_from_hwire(hwire_inside) if x != hpin
+ )
if selection in {Selection.OUTSIDE, Selection.BOTH, Selection.ALL}:
hwire_outside = _get_outer_hwire_from_hpin(hpin)
if hwire_outside and hwire_outside not in found_hwires:
found_hwires.add(hwire_outside)
yield hwire_outside
- search_stack += (x for x in _get_hpins_from_hwire(hwire_outside) if x != hpin)
+ search_stack += (
+ x for x in _get_hpins_from_hwire(hwire_outside) if x != hpin
+ )
def _get_inner_hwire_from_hpin(hpin):
- wire = hpin.item.wire
- if wire:
- cable = wire.cable
- if cable:
- hport = hpin.parent
- hinst = hport.parent
- hcable = HRef.from_parent_and_item(hinst, cable)
- hwire = HRef.from_parent_and_item(hcable, wire)
- return hwire
+ wire = hpin.item.wire
+ if wire:
+ cable = wire.cable
+ if cable:
+ hport = hpin.parent
+ hinst = hport.parent
+ hcable = HRef.from_parent_and_item(hinst, cable)
+ hwire = HRef.from_parent_and_item(hcable, wire)
+ return hwire
def _get_outer_hwire_from_hpin(hpin):
diff --git a/spydrnet/util/get_hinstances.py b/spydrnet/util/get_hinstances.py
index 1ee495cf..8e195b6c 100644
--- a/spydrnet/util/get_hinstances.py
+++ b/spydrnet/util/get_hinstances.py
@@ -1,4 +1,15 @@
-from spydrnet import FirstClassElement, InnerPin, OuterPin, Wire, Netlist, Library, Definition, Instance, Port, Cable
+from spydrnet import (
+ FirstClassElement,
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition,
+ Instance,
+ Port,
+ Cable,
+)
from spydrnet.util.hierarchical_reference import HRef
from spydrnet.util.patterns import _is_pattern_absolute, _value_matches_pattern
@@ -12,46 +23,54 @@ def get_hinstances(obj, *args, **kwargs):
Parameters
----------
obj : object, Iterable - required
- The object or objects associated with this query. Queries return a collection of objects associated with the
- provided object or objects that match the query criteria. For example, `sdn.get_instances(netlist, ...)` would
- return all of the instances *within* the provided definition that match the additional criteria.
+ The object or objects associated with this query. Queries return a collection of objects
+ associated with the provided object or objects that match the query criteria. For example,
+ `sdn.get_instances(netlist, ...)` would return all of the instances *within* the provided
+ definition that match the additional criteria.
patterns : str, Iterable - optional, positional or named, default: wildcard
- The search patterns. Patterns can be a single string or an Iterable collection of strings. Patterns can be
- absolute or they can contain wildcards or regular expressions. If `patterns` is not provided, then it defaults
- to a wildcard.
+ The search patterns. Patterns can be a single string or an Iterable collection of strings.
+ Patterns can be absolute or they can contain wildcards or regular expressions. If
+ `patterns` is not provided, then it defaults to a wildcard.
is_case : bool - optional, named, default: True
- Specify if patterns should be treated as case sensitive. Only applies to patterns. Does not alter fast lookup
- behavior (if namespace policy uses case insensitive indexing, this parameter will not prevent a fast lookup
- from returning a matching object even if the case is not an exact match).
+ Specify if patterns should be treated as case sensitive. Only applies to patterns. Does not
+ alter fast lookup behavior (if namespace policy uses case insensitive indexing, this
+ parameter will not prevent a fast lookup from returning a matching object even if the case
+ is not an exact match).
is_re: bool - optional, named, default: False
- Specify if patterns are regular expressions. If `False`, a pattern can still contain `*` and `?` wildcards. A
- `*` matches zero or more characters. A `?` matches upto a single character.
+ Specify if patterns are regular expressions. If `False`, a pattern can still contain `*`
+ and `?` wildcards. A `*` matches zero or more characters. A `?` matches upto a single
+ character.
recursive : bool - optional, default: False
- Specify if search should be recursive or not meaning that sub hierarchical instances within an instance are
- included or not.
+ Specify if search should be recursive or not meaning that sub hierarchical instances within
+ an instance are included or not.
filter : function
- This is a single input function that can be used to filter out unwanted virtual instances. If not specifed, all
- matching virtual instances are returned. Otherwise, virtual instances that cause the filter function to evaluate
- to true are the only items returned.
-
+ This is a single input function that can be used to filter out unwanted virtual instances.
+ If not specifed, all matching virtual instances are returned. Otherwise, virtual instances
+ that cause the filter function to evaluate to true are the only items returned.
+
Returns
-------
href_instances : generator
- The hierarchical references to instances associated with a particular object or collection of objects.
-
+ The hierarchical references to instances associated with a particular object or collection
+ of objects.
+
"""
# Check argument list
- if len(args) == 1 and 'patterns' in kwargs:
+ if len(args) == 1 and "patterns" in kwargs:
raise TypeError("get_hinstances() got multiple values for argument 'patterns'")
- if len(args) > 1 or any(x not in {'patterns', 'recursive', 'filter', 'is_case', 'is_re'} for x in kwargs):
+ if len(args) > 1 or any(
+ x not in {"patterns", "recursive", "filter", "is_case", "is_re"} for x in kwargs
+ ):
raise TypeError("Unknown usage. Please see help for more information.")
# Default values
- filter_func = kwargs.get('filter', lambda x: True)
- recursive = kwargs.get('recursive', False)
- is_case = kwargs.get('is_case', True)
- is_re = kwargs.get('is_re', False)
- patterns = args[0] if len(args) == 1 else kwargs.get('patterns', ".*" if is_re else "*")
+ filter_func = kwargs.get("filter", lambda x: True)
+ recursive = kwargs.get("recursive", False)
+ is_case = kwargs.get("is_case", True)
+ is_re = kwargs.get("is_re", False)
+ patterns = (
+ args[0] if len(args) == 1 else kwargs.get("patterns", ".*" if is_re else "*")
+ )
if isinstance(obj, (FirstClassElement, InnerPin, OuterPin, Wire)) is False:
try:
@@ -60,26 +79,39 @@ def get_hinstances(obj, *args, **kwargs):
object_collection = [obj]
else:
object_collection = [obj]
- if all(isinstance(x, (HRef, FirstClassElement, InnerPin, OuterPin, Wire)) for x in object_collection) is False:
- raise TypeError("get_hinstances() supports all netlist related objects and hierarchical references or a "
- "collection of theses as the object searched, unsupported object provided")
+ if (
+ all(
+ isinstance(x, (HRef, FirstClassElement, InnerPin, OuterPin, Wire))
+ for x in object_collection
+ )
+ is False
+ ):
+ raise TypeError(
+ "get_hinstances() supports all netlist related objects and hierarchical references or \
+ a collection of these as the object searched, unsupported object provided"
+ )
if isinstance(patterns, str):
patterns = (patterns,)
assert isinstance(patterns, (FirstClassElement, InnerPin, OuterPin, Wire)) is False
- return _get_instances(object_collection, patterns, recursive, is_case, is_re, filter_func)
+ return _get_instances(
+ object_collection, patterns, recursive, is_case, is_re, filter_func
+ )
def _get_instances(object_collection, patterns, recursive, is_case, is_re, filter_func):
- for result in filter(filter_func, _get_instances_raw(object_collection, patterns, recursive, is_case, is_re)):
+ for result in filter(
+ filter_func,
+ _get_instances_raw(object_collection, patterns, recursive, is_case, is_re),
+ ):
yield result
def _get_instances_raw(object_collection, patterns, recursive, is_case, is_re):
in_namemap = set()
in_yield = set()
- namemap = dict()
+ namemap = {}
instance_search = set()
while object_collection:
obj = object_collection.pop()
@@ -165,18 +197,18 @@ def _get_instances_raw(object_collection, patterns, recursive, is_case, is_re):
def _update_namemap(href, recursive, found, namemap):
currently_recursive = True
search_stack = [(href, False)]
- name_stack = list()
+ name_stack = []
while search_stack:
href, visited = search_stack.pop()
if visited:
name_stack.pop()
else:
search_stack.append((href, True))
- name_stack.append(href.item.name if href.item.name else '')
+ name_stack.append(href.item.name if href.item.name else "")
if len(name_stack) > 1:
- hname = '/'.join(name_stack[1:])
+ hname = "/".join(name_stack[1:])
if hname not in namemap:
- namemap[hname] = list()
+ namemap[hname] = []
namemap[hname].append(href)
if currently_recursive:
currently_recursive = recursive
diff --git a/spydrnet/util/get_hpins.py b/spydrnet/util/get_hpins.py
index ddccb946..b2046278 100644
--- a/spydrnet/util/get_hpins.py
+++ b/spydrnet/util/get_hpins.py
@@ -1,4 +1,15 @@
-from spydrnet import FirstClassElement, InnerPin, OuterPin, Wire, Netlist, Library, Definition, Instance, Port, Cable
+from spydrnet.ir import (
+ FirstClassElement,
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition,
+ Instance,
+ Port,
+ Cable,
+)
from spydrnet.util.hierarchical_reference import HRef
from spydrnet.util.patterns import _is_pattern_absolute, _value_matches_pattern
@@ -12,47 +23,54 @@ def get_hpins(obj, *args, **kwargs):
Parameters
----------
obj : object, Iterable - required
- The object or objects associated with this query. Queries return a collection of objects associated with the
- provided object or objects that match the query criteria. For example, `sdn.get_instances(netlist, ...)` would
- return all of the instances *within* the provided definition that match the additional criteria.
+ The object or objects associated with this query. Queries return a collection
+ of objects associated with the provided object or objects that match the query
+ criteria. For example, `sdn.get_instances(netlist, ...)` would return all of
+ the instances *within* the provided definition that match the additional criteria.
patterns : str, Iterable - optional, positional or named, default: wildcard
- The search patterns. Patterns can be a single string or an Iterable collection of strings. Patterns can be
- absolute or they can contain wildcards or regular expressions. If `patterns` is not provided, then it defaults
- to a wildcard.
+ The search patterns. Patterns can be a single string or an Iterable collection of
+ strings. Patterns can be absolute or they can contain wildcards or regular expressions.
+ If `patterns` is not provided, then it defaults to a wildcard.
recursive : bool - optional, default: False
- Specify if search should be recursive or not meaning that sub hierarchical pins within an instance are
- included or not.
+ Specify if search should be recursive or not meaning that sub hierarchical pins
+ within an instance are included or not.
is_case : bool - optional, named, default: True
- Specify if patterns should be treated as case sensitive. Only applies to patterns. Does not alter fast lookup
- behavior (if namespace policy uses case insensitive indexing, this parameter will not prevent a fast lookup
- from returning a matching object even if the case is not an exact match).
+ Specify if patterns should be treated as case sensitive. Only applies to patterns. Does
+ not alter fast lookup behavior (if namespace policy uses case insensitive indexing, this
+ parameter will not prevent a fast lookup from returning a matching object even if the
+ case is not an exact match).
is_re: bool - optional, named, default: False
- Specify if patterns are regular expressions. If `False`, a pattern can still contain `*` and `?` wildcards. A
- `*` matches zero or more characters. A `?` matches upto a single character.
+ Specify if patterns are regular expressions. If `False`, a pattern can still contain `*`
+ and `?` wildcards. A `*` matches zero or more characters. A `?` matches upto a single
+ character.
filter : function
- This is a single input function that can be used to filter out unwanted virtual instances. If not specifed, all
- matching virtual instances are returned. Otherwise, virtual instances that cause the filter function to evaluate
- to true are the only items returned.
-
+ This is a single input function that can be used to filter out unwanted virtual instances.
+ If not specifed, all matching virtual instances are returned. Otherwise, virtual instances
+ that cause the filter function to evaluate to true are the only items returned.
+
Returns
-------
href_pins : generator
- The hierarchical references to pins associated with a particular object or collection of objects.
-
+ The hierarchical references to pins associated with a particular object or collection
+ of objects.
+
"""
# Check argument list
- if len(args) == 1 and 'patterns' in kwargs:
+ if len(args) == 1 and "patterns" in kwargs:
raise TypeError("get_hwires() got multiple values for argument 'patterns'")
- if len(args) > 1 or any(x not in {'patterns', 'recursive', 'filter', 'is_case', 'is_re'} for x in
- kwargs):
+ if len(args) > 1 or any(
+ x not in {"patterns", "recursive", "filter", "is_case", "is_re"} for x in kwargs
+ ):
raise TypeError("Unknown usage. Please see help for more information.")
# Default values
- filter_func = kwargs.get('filter', lambda x: True)
- recursive = kwargs.get('recursive', False)
- is_case = kwargs.get('is_case', True)
- is_re = kwargs.get('is_re', False)
- patterns = args[0] if len(args) == 1 else kwargs.get('patterns', ".*" if is_re else "*")
+ filter_func = kwargs.get("filter", lambda x: True)
+ recursive = kwargs.get("recursive", False)
+ is_case = kwargs.get("is_case", True)
+ is_re = kwargs.get("is_re", False)
+ patterns = (
+ args[0] if len(args) == 1 else kwargs.get("patterns", ".*" if is_re else "*")
+ )
if isinstance(obj, (FirstClassElement, InnerPin, OuterPin, Wire)) is False:
try:
@@ -61,26 +79,39 @@ def get_hpins(obj, *args, **kwargs):
object_collection = [obj]
else:
object_collection = [obj]
- if all(isinstance(x, (HRef, FirstClassElement, InnerPin, OuterPin, Wire)) for x in object_collection) is False:
- raise TypeError("get_hwires() supports all netlist related objects and hierarchical references or a "
- "collection of theses as the object searched, unsupported object provided")
+ if (
+ all(
+ isinstance(x, (HRef, FirstClassElement, InnerPin, OuterPin, Wire))
+ for x in object_collection
+ )
+ is False
+ ):
+ raise TypeError(
+ "get_hwires() supports all netlist related objects and hierarchical references or a "
+ "collection of theses as the object searched, unsupported object provided"
+ )
if isinstance(patterns, str):
patterns = (patterns,)
assert isinstance(patterns, (FirstClassElement, InnerPin, OuterPin, Wire)) is False
- return _get_hpins(object_collection, patterns, recursive, is_case, is_re, filter_func)
+ return _get_hpins(
+ object_collection, patterns, recursive, is_case, is_re, filter_func
+ )
def _get_hpins(object_collection, patterns, recursive, is_case, is_re, filter_func):
- for result in filter(filter_func, _get_hpins_raw(object_collection, patterns, recursive, is_case, is_re)):
+ for result in filter(
+ filter_func,
+ _get_hpins_raw(object_collection, patterns, recursive, is_case, is_re),
+ ):
yield result
def _get_hpins_raw(object_collection, patterns, recursive, is_case, is_re):
in_namemap = set()
in_yield = set()
- namemap = dict()
+ namemap = {}
bypass_namesearch = set()
while object_collection:
obj = object_collection.pop()
@@ -107,7 +138,7 @@ def _get_hpins_raw(object_collection, patterns, recursive, is_case, is_re):
hpin = HRef.from_parent_and_item(hport, pin)
if hpin not in in_yield:
in_yield.add(hpin)
- yield(hpin)
+ yield hpin
# get internal cables recursively
if recursive:
for child in reference.children:
@@ -119,36 +150,44 @@ def _get_hpins_raw(object_collection, patterns, recursive, is_case, is_re):
hpin = HRef.from_parent_and_item(obj, pin)
if hpin not in in_yield:
in_yield.add(hpin)
- yield (hpin)
+ yield hpin
elif isinstance(item, Cable):
for wire in item.wires:
href_wire = HRef.from_parent_and_item(obj, wire)
object_collection.append(href_wire)
elif isinstance(item, Wire):
- href_parent_cable = obj.parent
- href_parent_instance = href_parent_cable.parent
- for pin in item.pins:
- if isinstance(pin, OuterPin):
- instance = pin.instance
- if instance:
- href_inst = HRef.from_parent_and_item(href_parent_instance, pin.instance)
- inner_pin = pin.inner_pin
- if inner_pin:
- inner_port = inner_pin.port
- if inner_port:
- href_port = HRef.from_parent_and_item(href_inst, inner_port)
- href_pin = HRef.from_parent_and_item(href_port, inner_pin)
- if href_pin not in in_yield:
- in_yield.add(href_pin)
- yield href_pin
- else:
- port = pin.port
- if port:
- href_port = HRef.from_parent_and_item(href_parent_instance, port)
- href_pin = HRef.from_parent_and_item(href_port, pin)
- if href_pin not in in_yield:
- in_yield.add(href_pin)
- yield href_pin
+ href_parent_cable = obj.parent
+ href_parent_instance = href_parent_cable.parent
+ for pin in item.pins:
+ if isinstance(pin, OuterPin):
+ instance = pin.instance
+ if instance:
+ href_inst = HRef.from_parent_and_item(
+ href_parent_instance, pin.instance
+ )
+ inner_pin = pin.inner_pin
+ if inner_pin:
+ inner_port = inner_pin.port
+ if inner_port:
+ href_port = HRef.from_parent_and_item(
+ href_inst, inner_port
+ )
+ href_pin = HRef.from_parent_and_item(
+ href_port, inner_pin
+ )
+ if href_pin not in in_yield:
+ in_yield.add(href_pin)
+ yield href_pin
+ else:
+ port = pin.port
+ if port:
+ href_port = HRef.from_parent_and_item(
+ href_parent_instance, port
+ )
+ href_pin = HRef.from_parent_and_item(href_port, pin)
+ if href_pin not in in_yield:
+ in_yield.add(href_pin)
+ yield href_pin
elif isinstance(item, InnerPin):
if obj not in in_yield:
in_yield.add(obj)
@@ -191,21 +230,23 @@ def _get_hpins_raw(object_collection, patterns, recursive, is_case, is_re):
def _update_hwire_namemap(href_instance, recursive, found, namemap):
search_stack = [(href_instance, False)]
- name_stack = list()
+ name_stack = []
while search_stack:
href_instance, visited = search_stack.pop()
if visited:
name_stack.pop()
else:
search_stack.append((href_instance, True))
- name_stack.append(href_instance.item.name if href_instance.item.name else '')
+ name_stack.append(
+ href_instance.item.name if href_instance.item.name else ""
+ )
item = href_instance.item
reference = item.reference
if reference:
for port in reference.ports:
hport = HRef.from_parent_and_item(href_instance, port)
- name_stack.append(port.name if port.name else '')
- port_hname = '/'.join(name_stack[1:])
+ name_stack.append(port.name if port.name else "")
+ port_hname = "/".join(name_stack[1:])
for pins_index, pin in enumerate(port.pins):
hpin = HRef.from_parent_and_item(hport, pin)
if hpin not in found:
@@ -213,9 +254,11 @@ def _update_hwire_namemap(href_instance, recursive, found, namemap):
if port.is_scalar:
hname = port_hname
else:
- hname = "{}[{}]".format(port_hname, port.lower_index + pins_index)
+ hname = "{}[{}]".format(
+ port_hname, port.lower_index + pins_index
+ )
if hname not in namemap:
- namemap[hname] = list()
+ namemap[hname] = []
namemap[hname].append(hpin)
name_stack.pop()
if recursive:
diff --git a/spydrnet/util/get_hports.py b/spydrnet/util/get_hports.py
index 8588c138..d6481d4a 100644
--- a/spydrnet/util/get_hports.py
+++ b/spydrnet/util/get_hports.py
@@ -1,4 +1,15 @@
-from spydrnet import FirstClassElement, InnerPin, OuterPin, Wire, Netlist, Library, Definition, Instance, Port, Cable
+from spydrnet.ir import (
+ FirstClassElement,
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition,
+ Instance,
+ Port,
+ Cable,
+)
from spydrnet.util.hierarchical_reference import HRef
from spydrnet.util.patterns import _is_pattern_absolute, _value_matches_pattern
@@ -12,47 +23,54 @@ def get_hports(obj, *args, **kwargs):
Parameters
----------
obj : object, Iterable - required
- The object or objects associated with this query. Queries return a collection of objects associated with the
- provided object or objects that match the query criteria. For example, `sdn.get_instances(netlist, ...)` would
- return all of the instances *within* the provided definition that match the additional criteria.
+ The object or objects associated with this query. Queries return a collection
+ of objects associated with the provided object or objects that match the query
+ criteria. For example, `sdn.get_instances(netlist, ...)` would return all of
+ the instances *within* the provided definition that match the additional criteria.
patterns : str, Iterable - optional, positional or named, default: wildcard
- The search patterns. Patterns can be a single string or an Iterable collection of strings. Patterns can be
- absolute or they can contain wildcards or regular expressions. If `patterns` is not provided, then it defaults
- to a wildcard.
+ The search patterns. Patterns can be a single string or an Iterable collection of
+ strings. Patterns can be absolute or they can contain wildcards or regular expressions.
+ If `patterns` is not provided, then it defaults to a wildcard.
recursive : bool - optional, default: False
- Specify if search should be recursive or not meaning that sub hierarchical pins within an instance are
- included or not.
+ Specify if search should be recursive or not meaning that sub hierarchical pins
+ within an instance are included or not.
is_case : bool - optional, named, default: True
- Specify if patterns should be treated as case sensitive. Only applies to patterns. Does not alter fast lookup
- behavior (if namespace policy uses case insensitive indexing, this parameter will not prevent a fast lookup
- from returning a matching object even if the case is not an exact match).
+ Specify if patterns should be treated as case sensitive. Only applies to patterns. Does
+ not alter fast lookup behavior (if namespace policy uses case insensitive indexing, this
+ parameter will not prevent a fast lookup from returning a matching object even if the
+ case is not an exact match).
is_re: bool - optional, named, default: False
- Specify if patterns are regular expressions. If `False`, a pattern can still contain `*` and `?` wildcards. A
- `*` matches zero or more characters. A `?` matches upto a single character.
+ Specify if patterns are regular expressions. If `False`, a pattern can still contain `*`
+ and `?` wildcards. A `*` matches zero or more characters. A `?` matches upto a single
+ character.
filter : function
- This is a single input function that can be used to filter out unwanted virtual instances. If not specifed, all
- matching virtual instances are returned. Otherwise, virtual instances that cause the filter function to evaluate
- to true are the only items returned.
-
+ This is a single input function that can be used to filter out unwanted virtual instances.
+ If not specifed, all matching virtual instances are returned. Otherwise, virtual instances
+ that cause the filter function to evaluate to true are the only items returned.
+
Returns
-------
href_ports : generator
- The hierarchical references to ports associated with a particular object or collection of objects.
-
+ The hierarchical references to ports associated with a particular object or collection
+ of objects.
+
"""
# Check argument list
- if len(args) == 1 and 'patterns' in kwargs:
+ if len(args) == 1 and "patterns" in kwargs:
raise TypeError("get_hports() got multiple values for argument 'patterns'")
- if len(args) > 1 or any(x not in {'patterns', 'recursive', 'filter', 'is_case', 'is_re'} for x in
- kwargs):
+ if len(args) > 1 or any(
+ x not in {"patterns", "recursive", "filter", "is_case", "is_re"} for x in kwargs
+ ):
raise TypeError("Unknown usage. Please see help for more information.")
# Default values
- filter_func = kwargs.get('filter', lambda x: True)
- recursive = kwargs.get('recursive', False)
- is_case = kwargs.get('is_case', True)
- is_re = kwargs.get('is_re', False)
- patterns = args[0] if len(args) == 1 else kwargs.get('patterns', ".*" if is_re else "*")
+ filter_func = kwargs.get("filter", lambda x: True)
+ recursive = kwargs.get("recursive", False)
+ is_case = kwargs.get("is_case", True)
+ is_re = kwargs.get("is_re", False)
+ patterns = (
+ args[0] if len(args) == 1 else kwargs.get("patterns", ".*" if is_re else "*")
+ )
if isinstance(obj, (FirstClassElement, InnerPin, OuterPin, Wire)) is False:
try:
@@ -61,26 +79,39 @@ def get_hports(obj, *args, **kwargs):
object_collection = [obj]
else:
object_collection = [obj]
- if all(isinstance(x, (HRef, FirstClassElement, InnerPin, OuterPin, Wire)) for x in object_collection) is False:
- raise TypeError("get_hports() supports all netlist related objects and hierarchical references or a "
- "collection of theses as the object searched, unsupported object provided")
+ if (
+ all(
+ isinstance(x, (HRef, FirstClassElement, InnerPin, OuterPin, Wire))
+ for x in object_collection
+ )
+ is False
+ ):
+ raise TypeError(
+ "get_hports() supports all netlist related objects and hierarchical references or a "
+ "collection of theses as the object searched, unsupported object provided"
+ )
if isinstance(patterns, str):
patterns = (patterns,)
assert isinstance(patterns, (FirstClassElement, InnerPin, OuterPin, Wire)) is False
- return _get_hports(object_collection, patterns, recursive, is_case, is_re, filter_func)
+ return _get_hports(
+ object_collection, patterns, recursive, is_case, is_re, filter_func
+ )
def _get_hports(object_collection, patterns, recursive, is_case, is_re, filter_func):
- for result in filter(filter_func, _get_hports_raw(object_collection, patterns, recursive, is_case, is_re)):
+ for result in filter(
+ filter_func,
+ _get_hports_raw(object_collection, patterns, recursive, is_case, is_re),
+ ):
yield result
def _get_hports_raw(object_collection, patterns, recursive, is_case, is_re):
in_namemap = set()
in_yield = set()
- namemap = dict()
+ namemap = {}
bypass_namesearch = set()
while object_collection:
obj = object_collection.pop()
@@ -105,7 +136,7 @@ def _get_hports_raw(object_collection, patterns, recursive, is_case, is_re):
hport = HRef.from_parent_and_item(obj, port)
if hport not in in_yield:
in_yield.add(hport)
- yield(hport)
+ yield (hport)
# get internal cables recursively
if recursive:
for child in reference.children:
@@ -121,28 +152,34 @@ def _get_hports_raw(object_collection, patterns, recursive, is_case, is_re):
href_wire = HRef.from_parent_and_item(obj, wire)
object_collection.append(href_wire)
elif isinstance(item, Wire):
- href_parent_cable = obj.parent
- href_parent_instance = href_parent_cable.parent
- for pin in item.pins:
- if isinstance(pin, OuterPin):
- instance = pin.instance
- if instance:
- href_inst = HRef.from_parent_and_item(href_parent_instance, pin.instance)
- inner_pin = pin.inner_pin
- if inner_pin:
- inner_port = inner_pin.port
- if inner_port:
- href_port = HRef.from_parent_and_item(href_inst, inner_port)
- if href_port not in in_yield:
- in_yield.add(href_port)
- yield href_port
- else:
- port = pin.port
- if port:
- href_port = HRef.from_parent_and_item(href_parent_instance, port)
- if href_port not in in_yield:
- in_yield.add(href_port)
- yield href_port
+ href_parent_cable = obj.parent
+ href_parent_instance = href_parent_cable.parent
+ for pin in item.pins:
+ if isinstance(pin, OuterPin):
+ instance = pin.instance
+ if instance:
+ href_inst = HRef.from_parent_and_item(
+ href_parent_instance, pin.instance
+ )
+ inner_pin = pin.inner_pin
+ if inner_pin:
+ inner_port = inner_pin.port
+ if inner_port:
+ href_port = HRef.from_parent_and_item(
+ href_inst, inner_port
+ )
+ if href_port not in in_yield:
+ in_yield.add(href_port)
+ yield href_port
+ else:
+ port = pin.port
+ if port:
+ href_port = HRef.from_parent_and_item(
+ href_parent_instance, port
+ )
+ if href_port not in in_yield:
+ in_yield.add(href_port)
+ yield href_port
elif isinstance(item, InnerPin):
hport = obj.parent
if hport not in in_yield:
@@ -186,25 +223,27 @@ def _get_hports_raw(object_collection, patterns, recursive, is_case, is_re):
def _update_hport_namemap(href_instance, recursive, found, namemap):
search_stack = [(href_instance, False)]
- name_stack = list()
+ name_stack = []
while search_stack:
href_instance, visited = search_stack.pop()
if visited:
name_stack.pop()
else:
search_stack.append((href_instance, True))
- name_stack.append(href_instance.item.name if href_instance.item.name else '')
+ name_stack.append(
+ href_instance.item.name if href_instance.item.name else ""
+ )
item = href_instance.item
reference = item.reference
if reference:
for port in reference.ports:
hport = HRef.from_parent_and_item(href_instance, port)
- name_stack.append(port.name if port.name else '')
- port_hname = '/'.join(name_stack[1:])
+ name_stack.append(port.name if port.name else "")
+ port_hname = "/".join(name_stack[1:])
if hport not in found:
found.add(hport)
if port_hname not in namemap:
- namemap[port_hname] = list()
+ namemap[port_hname] = []
namemap[port_hname].append(hport)
name_stack.pop()
if recursive:
diff --git a/spydrnet/util/get_hwires.py b/spydrnet/util/get_hwires.py
index f84c692a..c3147186 100644
--- a/spydrnet/util/get_hwires.py
+++ b/spydrnet/util/get_hwires.py
@@ -1,4 +1,15 @@
-from spydrnet import FirstClassElement, InnerPin, OuterPin, Wire, Netlist, Library, Definition, Instance, Port, Cable
+from spydrnet import (
+ FirstClassElement,
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition,
+ Instance,
+ Port,
+ Cable,
+)
from spydrnet.util.hierarchical_reference import HRef
from spydrnet.util.selection import Selection
from spydrnet.util.patterns import _is_pattern_absolute, _value_matches_pattern
@@ -13,57 +24,67 @@ def get_hwires(obj, *args, **kwargs):
Parameters
----------
obj : object, Iterable - required
- The object or objects associated with this query. Queries return a collection of objects associated with the
- provided object or objects that match the query criteria. For example, `sdn.get_instances(netlist, ...)` would
- return all of the instances *within* the provided definition that match the additional criteria.
+ The object or objects associated with this query. Queries return a collection
+ of objects associated with the provided object or objects that match the query criteria.
+ For example, `sdn.get_instances(netlist, ...)` would return all of the instances *within*
+ the provided definition that match the additional criteria.
patterns : str, Iterable - optional, positional or named, default: wildcard
- The search patterns. Patterns can be a single string or an Iterable collection of strings. Patterns can be
- absolute or they can contain wildcards or regular expressions. If `patterns` is not provided, then it defaults
- to a wildcard.
+ The search patterns. Patterns can be a single string or an Iterable collection of strings.
+ Patterns can be absolute or they can contain wildcards or regular expressions. If
+ `patterns` is not provided, then it defaults to a wildcard.
is_case : bool - optional, named, default: True
- Specify if patterns should be treated as case sensitive. Only applies to patterns. Does not alter fast lookup
- behavior (if namespace policy uses case insensitive indexing, this parameter will not prevent a fast lookup
- from returning a matching object even if the case is not an exact match).
+ Specify if patterns should be treated as case sensitive. Only applies to patterns. Does not
+ alter fast lookup behavior (if namespace policy uses case insensitive indexing, this
+ parameter will not prevent a fast from returning a matching object even if the case is not
+ an exact match).
is_re: bool - optional, named, default: False
- Specify if patterns are regular expressions. If `False`, a pattern can still contain `*` and `?` wildcards. A
- `*` matches zero or more characters. A `?` matches upto a single character.
+ Specify if patterns are regular expressions. If `False`, a pattern can still contain `*`
+ and `?` wildcards. A `*` matches zero or more characters. A `?` matches upto a single
+ character.
recursive : bool - optional, default: False
- Specify if search should be recursive or not meaning that sub hierarchical instances within an instance are
- included or not.
+ Specify if search should be recursive or not meaning that sub hierarchical instances within
+ an instance are included or not.
selection : Selection.{INSIDE, OUTSIDE, BOTH, ALL}, default: INSIDE
- This parameter determines the wires that are returned based on the instance associated with the object that is
- being searched.
+ This parameter determines the wires that are returned based on the instance associated with
+ the object that is being searched.
filter : function
- This is a single input function that can be used to filter out unwanted virtual instances. If not specifed, all
- matching virtual instances are returned. Otherwise, virtual instances that cause the filter function to evaluate
- to true are the only items returned.
-
+ This is a single input function that can be used to filter out unwanted virtual instances.
+ If not specifed, all matching virtual instances are returned. Otherwise, virtual instances
+ that cause the filter function to evaluate to true are the only items returned.
+
Returns
-------
href_wires : generator
- The hierarchical references to wires associated with a particular object or collection of objects.
-
+ The hierarchical references to wires associated with a particular object or collection
+ of objects.
+
"""
# Check argument list
- if len(args) == 1 and 'patterns' in kwargs:
+ if len(args) == 1 and "patterns" in kwargs:
raise TypeError("get_hwires() got multiple values for argument 'patterns'")
- if len(args) > 1 or any(x not in {'patterns', 'selection', 'recursive', 'filter', 'is_case', 'is_re'} for x in
- kwargs):
+ if len(args) > 1 or any(
+ x not in {"patterns", "selection", "recursive", "filter", "is_case", "is_re"}
+ for x in kwargs
+ ):
raise TypeError("Unknown usage. Please see help for more information.")
# Default values
- selection = kwargs.get('selection', Selection.INSIDE)
+ selection = kwargs.get("selection", Selection.INSIDE)
if isinstance(selection, str):
if selection in Selection.__members__:
selection = Selection[selection]
if isinstance(selection, Selection) is False:
- raise TypeError("selection must be '{}'".format("', '".join(Selection.__members__.keys())))
+ raise TypeError(
+ "selection must be '{}'".format("', '".join(Selection.__members__.keys()))
+ )
- filter_func = kwargs.get('filter', lambda x: True)
- recursive = kwargs.get('recursive', False)
- is_case = kwargs.get('is_case', True)
- is_re = kwargs.get('is_re', False)
- patterns = args[0] if len(args) == 1 else kwargs.get('patterns', ".*" if is_re else "*")
+ filter_func = kwargs.get("filter", lambda x: True)
+ recursive = kwargs.get("recursive", False)
+ is_case = kwargs.get("is_case", True)
+ is_re = kwargs.get("is_re", False)
+ patterns = (
+ args[0] if len(args) == 1 else kwargs.get("patterns", ".*" if is_re else "*")
+ )
if isinstance(obj, (FirstClassElement, InnerPin, OuterPin, Wire)) is False:
try:
@@ -72,26 +93,43 @@ def get_hwires(obj, *args, **kwargs):
object_collection = [obj]
else:
object_collection = [obj]
- if all(isinstance(x, (HRef, FirstClassElement, InnerPin, OuterPin, Wire)) for x in object_collection) is False:
- raise TypeError("get_hwires() supports all netlist related objects and hierarchical references or a "
- "collection of theses as the object searched, unsupported object provided")
+ if (
+ all(
+ isinstance(x, (HRef, FirstClassElement, InnerPin, OuterPin, Wire))
+ for x in object_collection
+ )
+ is False
+ ):
+ raise TypeError(
+ "get_hwires() supports all netlist related objects and hierarchical references or a "
+ "collection of theses as the object searched, unsupported object provided"
+ )
if isinstance(patterns, str):
patterns = (patterns,)
assert isinstance(patterns, (FirstClassElement, InnerPin, OuterPin, Wire)) is False
- return _get_hwires(object_collection, selection, patterns, recursive, is_case, is_re, filter_func)
+ return _get_hwires(
+ object_collection, selection, patterns, recursive, is_case, is_re, filter_func
+ )
-def _get_hwires(object_collection, selection, patterns, recursive, is_case, is_re, filter_func):
- for result in filter(filter_func, _get_hwires_raw(object_collection, selection, patterns, recursive, is_case, is_re)):
+def _get_hwires(
+ object_collection, selection, patterns, recursive, is_case, is_re, filter_func
+):
+ for result in filter(
+ filter_func,
+ _get_hwires_raw(
+ object_collection, selection, patterns, recursive, is_case, is_re
+ ),
+ ):
yield result
def _get_hwires_raw(object_collection, selection, patterns, recursive, is_case, is_re):
in_namemap = set()
in_yield = set()
- namemap = dict()
+ namemap = {}
hpin_search = set()
bypass_namesearch = set()
while object_collection:
@@ -120,14 +158,18 @@ def _get_hwires_raw(object_collection, selection, patterns, recursive, is_case,
hwire = HRef.from_parent_and_item(hcable, wire)
if hwire not in in_yield:
in_yield.add(hwire)
- yield(hwire)
+ yield (hwire)
# get internal cables recursively
if recursive or selection == Selection.ALL:
for child in reference.children:
href_child = HRef.from_parent_and_item(obj, child)
bypass_namesearch.add(href_child)
object_collection.append(href_child)
- if selection in {Selection.OUTSIDE, Selection.BOTH, Selection.ALL}:
+ if selection in {
+ Selection.OUTSIDE,
+ Selection.BOTH,
+ Selection.ALL,
+ }:
for port in reference.ports:
href_port = HRef.from_parent_and_item(obj, port)
for pin in port.pins:
@@ -151,12 +193,18 @@ def _get_hwires_raw(object_collection, selection, patterns, recursive, is_case,
href_parent_instance = href_parent_cable.parent
for pin in item.pins:
if isinstance(pin, OuterPin):
- href_inst = HRef.from_parent_and_item(href_parent_instance, pin.instance)
+ href_inst = HRef.from_parent_and_item(
+ href_parent_instance, pin.instance
+ )
inner_wire = pin.inner_pin.wire
if inner_wire:
inner_cable = inner_wire.cable
- href_cable = HRef.from_parent_and_item(href_inst, inner_cable)
- href_wire = HRef.from_parent_and_item(href_cable, inner_wire)
+ href_cable = HRef.from_parent_and_item(
+ href_inst, inner_cable
+ )
+ href_wire = HRef.from_parent_and_item(
+ href_cable, inner_wire
+ )
if href_wire not in in_yield:
in_yield.add(href_wire)
yield href_wire
@@ -169,8 +217,12 @@ def _get_hwires_raw(object_collection, selection, patterns, recursive, is_case,
outer_wire = outer_pin.wire
if outer_wire:
outer_cable = outer_wire.cable
- href_cable = HRef.from_parent_and_item(href_parent, outer_cable)
- href_wire = HRef.from_parent_and_item(href_cable, outer_wire)
+ href_cable = HRef.from_parent_and_item(
+ href_parent, outer_cable
+ )
+ href_wire = HRef.from_parent_and_item(
+ href_cable, outer_wire
+ )
if href_wire not in in_yield:
in_yield.add(href_wire)
yield href_wire
@@ -182,7 +234,9 @@ def _get_hwires_raw(object_collection, selection, patterns, recursive, is_case,
href_inst = href_cable.parent
for pin in item.pins:
if isinstance(pin, OuterPin):
- href_sub_inst = HRef.from_parent_and_item(obj.parent, pin.instance)
+ href_sub_inst = HRef.from_parent_and_item(
+ obj.parent, pin.instance
+ )
inner_pin = pin.inner_pin
port = inner_pin.port
href_port = HRef.from_parent_and_item(href_sub_inst, port)
@@ -238,21 +292,23 @@ def _get_hwires_raw(object_collection, selection, patterns, recursive, is_case,
def _update_hwire_namemap(href_instance, recursive, found, namemap):
search_stack = [(href_instance, False)]
- name_stack = list()
+ name_stack = []
while search_stack:
href_instance, visited = search_stack.pop()
if visited:
name_stack.pop()
else:
search_stack.append((href_instance, True))
- name_stack.append(href_instance.item.name if href_instance.item.name else '')
+ name_stack.append(
+ href_instance.item.name if href_instance.item.name else ""
+ )
item = href_instance.item
reference = item.reference
if reference:
for cable in reference.cables:
hcable = HRef.from_parent_and_item(href_instance, cable)
- name_stack.append(cable.name if cable.name else '')
- cable_hname = '/'.join(name_stack[1:])
+ name_stack.append(cable.name if cable.name else "")
+ cable_hname = "/".join(name_stack[1:])
for wire_index, wire in enumerate(cable.wires):
hwire = HRef.from_parent_and_item(hcable, wire)
if hwire not in found:
@@ -260,9 +316,11 @@ def _update_hwire_namemap(href_instance, recursive, found, namemap):
if cable.is_scalar:
hname = cable_hname
else:
- hname = "{}[{}]".format(cable_hname, cable.lower_index + wire_index)
+ hname = "{}[{}]".format(
+ cable_hname, cable.lower_index + wire_index
+ )
if hname not in namemap:
- namemap[hname] = list()
+ namemap[hname] = []
namemap[hname].append(hwire)
name_stack.pop()
if recursive:
@@ -283,7 +341,9 @@ def _get_hwires_from_hpins(hpin_search, selection):
found_hwires.add(hwire_inside)
yield hwire_inside
if selection is Selection.ALL:
- search_stack += (x for x in _get_hpins_from_hwire(hwire_inside) if x != hpin)
+ search_stack += (
+ x for x in _get_hpins_from_hwire(hwire_inside) if x != hpin
+ )
if selection in {Selection.OUTSIDE, Selection.BOTH, Selection.ALL}:
hwire_outside = _get_outer_hwire_from_hpin(hpin)
@@ -291,19 +351,21 @@ def _get_hwires_from_hpins(hpin_search, selection):
found_hwires.add(hwire_outside)
yield hwire_outside
if selection is Selection.ALL:
- search_stack += (x for x in _get_hpins_from_hwire(hwire_outside) if x != hpin)
+ search_stack += (
+ x for x in _get_hpins_from_hwire(hwire_outside) if x != hpin
+ )
def _get_inner_hwire_from_hpin(hpin):
- wire = hpin.item.wire
- if wire:
- cable = wire.cable
- if cable:
- hport = hpin.parent
- hinst = hport.parent
- hcable = HRef.from_parent_and_item(hinst, cable)
- hwire = HRef.from_parent_and_item(hcable, wire)
- return hwire
+ wire = hpin.item.wire
+ if wire:
+ cable = wire.cable
+ if cable:
+ hport = hpin.parent
+ hinst = hport.parent
+ hcable = HRef.from_parent_and_item(hinst, cable)
+ hwire = HRef.from_parent_and_item(hcable, wire)
+ return hwire
def _get_outer_hwire_from_hpin(hpin):
diff --git a/spydrnet/util/get_instances.py b/spydrnet/util/get_instances.py
index 8133be6b..d37b1a13 100644
--- a/spydrnet/util/get_instances.py
+++ b/spydrnet/util/get_instances.py
@@ -1,5 +1,16 @@
-from spydrnet import Element, FirstClassElement, InnerPin, OuterPin, Wire, Netlist, Library, Definition, Instance,\
- Port, Cable
+from spydrnet.ir import (
+ Element,
+ FirstClassElement,
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition,
+ Instance,
+ Port,
+ Cable,
+)
from spydrnet.global_state.global_service import lookup
from spydrnet.util.hierarchical_reference import HRef
from spydrnet.util.patterns import _is_pattern_absolute, _value_matches_pattern
@@ -15,64 +26,87 @@ def get_instances(obj, *args, **kwargs):
Parameters
----------
obj : object, Iterable - required
- The object or objects associated with this query. Queries return a collection objects associated with the
- provided object or objects that match the query criteria. For example, `sdn.get_instances(definition, ...)` would
- return all of the instances *within* the provided definition that match the additional criteria.
+ The object or objects associated with this query. Queries return a collection objects
+ associated with the provided object or objects that match the query criteria. For example,
+ `sdn.get_instances(definition, ...)` would return all of the instances *within* the
+ provided definition that match the additional criteria.
patterns : str, Iterable - optional, positional or named, default: wildcard
- The search patterns. Patterns can be a single string or an Iterable collection of strings. Patterns can be
- absolute or they can contain wildcards or regular expressions. If `patterns` is not provided, then it defaults
- to a wildcard. Patterns are queried against the object property value stored under a specified key. Fast lookups
- are only attempted on absolute patterns that are not regular expressions and contain no wildcards.
+ The search patterns. Patterns can be a single string or an Iterable collection of strings.
+ Patterns can be absolute or they can contain wildcards or regular expressions. If
+ `patterns` is not provided, then it defaults to a wildcard. Patterns are queried against
+ the object property value stored under a specified key. Fast lookups are only attempted on
+ absolute patterns that are not regular expressions and contain no wildcards.
key : str, optional, default: ".NAME"
This is the key that controls which value is being searched.
is_case : bool - optional, named, default: True
- Specify if patterns should be treated as case sensitive. Only applies to patterns. Does not alter fast lookup
- behavior (if namespace policy uses case insensitive indexing, this parameter will not prevent a fast lookup
- from returning a matching object even if the case is not an exact match).
+ Specify if patterns should be treated as case sensitive. Only applies to patterns. Does not
+ alter fast lookup behavior (if namespace policy uses case insensitive indexing, this
+ parameter will not prevent a fast lookup from returning a matching object even if the case
+ is not an exact match).
is_re: bool - optional, named, default: False
- Specify if patterns are regular expressions. If `False`, a pattern can still contain `*` and `?` wildcards. A
- `*` matches zero or more characters. A `?` matches upto a single character.
+ Specify if patterns are regular expressions. If `False`, a pattern can still contain `*`
+ and `?` wildcards. A `*` matches zero or more characters. A `?` matches upto a single
+ character.
selection : Selection.{INSIDE, OUTSIDE}, default: INSIDE
- This parameter determines the instances that are returned based on the definition or instance that is being
- searched. This parameter only applies to objects that are definitions. If the selection is "INSIDE" (default),
- then the function will return all of the instances that are inside the definition (i.e., the definition's
- children) that match the remainder of the search criteria. If the selection is "OUTSIDE", then the function will
- return all of the instances of the provided definition that match the remainder of the search criteria.
+ This parameter determines the instances that are returned based on the definition or
+ instance that is being searched. This parameter only applies to objects that are
+ definitions. If the selection is "INSIDE" (default), then the function will return all of
+ the instances that are inside the definition (i.e., the definition's children) that match
+ the remainder of the search criteria. If the selection is "OUTSIDE", then the function will
+ return all of the instances of the provided definition that match the remainder of the
+ search criteria.
recursive : bool - optional, default: False
- Specify if search should be recursive or not meaning that sub hierarchical instances within an instance are
- included or not.
+ Specify if search should be recursive or not meaning that sub hierarchical instances within
+ an instance are included or not.
filter : function
- This is a single input function that can be used to filter out unwanted virtual instances. If not specifed, all
- matching virtual instances are returned. Otherwise, virtual instances that cause the filter function to evaluate
- to true are the only items returned.
-
+ This is a single input function that can be used to filter out unwanted virtual instances.
+ If not specifed, all matching virtual instances are returned. Otherwise, virtual instances
+ that cause the filter function to evaluate to true are the only items returned.
+
Returns
-------
cables : generator
The cables associated with a particular object or collection of objects.
-
+
"""
# Check argument list
- if len(args) == 1 and 'patterns' in kwargs:
+ if len(args) == 1 and "patterns" in kwargs:
raise TypeError("get_cables() got multiple values for argument 'patterns'")
- if len(args) > 1 or any(x not in {'patterns', 'key', 'filter', 'is_case', 'is_re', 'selection', 'recursive'} for x
- in kwargs):
+ if len(args) > 1 or any(
+ x
+ not in {
+ "patterns",
+ "key",
+ "filter",
+ "is_case",
+ "is_re",
+ "selection",
+ "recursive",
+ }
+ for x in kwargs
+ ):
raise TypeError("Unknown usage. Please see help for more information.")
# Default values
- selection = kwargs.get('selection', Selection.INSIDE)
+ selection = kwargs.get("selection", Selection.INSIDE)
if isinstance(selection, str):
if selection in Selection.__members__:
selection = Selection[selection]
if selection not in {Selection.INSIDE, Selection.OUTSIDE}:
- raise TypeError("selection must be '{}'".format("', '".join([Selection.INSIDE.name, Selection.OUTSIDE.name])))
+ raise TypeError(
+ "selection must be '{}'".format(
+ "', '".join([Selection.INSIDE.name, Selection.OUTSIDE.name])
+ )
+ )
- filter_func = kwargs.get('filter', lambda x: True)
- is_case = kwargs.get('is_case', True)
- is_re = kwargs.get('is_re', False)
- patterns = args[0] if len(args) == 1 else kwargs.get('patterns', ".*" if is_re else "*")
- key = kwargs.get('key', ".NAME")
- recursive = kwargs.get('recursive', False)
+ filter_func = kwargs.get("filter", lambda x: True)
+ is_case = kwargs.get("is_case", True)
+ is_re = kwargs.get("is_re", False)
+ patterns = (
+ args[0] if len(args) == 1 else kwargs.get("patterns", ".*" if is_re else "*")
+ )
+ key = kwargs.get("key", ".NAME")
+ recursive = kwargs.get("recursive", False)
if isinstance(obj, (FirstClassElement, InnerPin, OuterPin, Wire)) is False:
try:
@@ -82,24 +116,43 @@ def get_instances(obj, *args, **kwargs):
else:
object_collection = [obj]
if all(isinstance(x, (Element, HRef)) for x in object_collection) is False:
- raise TypeError("get_instances() only supports netlists, libraries, and definitions, or a collection of these "
- "as the object searched")
+ raise TypeError(
+ "get_instances() only supports netlists, libraries, and definitions, or a collection \
+ of these as the object searched"
+ )
if isinstance(patterns, str):
patterns = (patterns,)
- return _get_instances(object_collection, patterns, key, is_case, is_re, selection, recursive, filter_func)
+ return _get_instances(
+ object_collection,
+ patterns,
+ key,
+ is_case,
+ is_re,
+ selection,
+ recursive,
+ filter_func,
+ )
-def _get_instances(object_collection, patterns, key, is_case, is_re, selection, recursive, filter_func):
- for result in filter(filter_func, _get_instances_raw(object_collection, patterns, key, is_case, is_re, selection,
- recursive)):
+def _get_instances(
+ object_collection, patterns, key, is_case, is_re, selection, recursive, filter_func
+):
+ for result in filter(
+ filter_func,
+ _get_instances_raw(
+ object_collection, patterns, key, is_case, is_re, selection, recursive
+ ),
+ ):
yield result
-def _get_instances_raw(object_collection, patterns, key, is_case, is_re, selection, recursive):
+def _get_instances_raw(
+ object_collection, patterns, key, is_case, is_re, selection, recursive
+):
found = set()
- other_instances = list()
+ other_instances = []
while object_collection:
obj = object_collection.pop()
if isinstance(obj, Definition):
@@ -114,8 +167,13 @@ def _get_instances_raw(object_collection, patterns, key, is_case, is_re, selecti
else:
for instance in obj.children:
if key in instance:
- value = instance[key] if key in instance else ''
- if _value_matches_pattern(value, pattern, is_case, is_re) and instance not in found:
+ value = instance[key] if key in instance else ""
+ if (
+ _value_matches_pattern(
+ value, pattern, is_case, is_re
+ )
+ and instance not in found
+ ):
found.add(instance)
yield instance
if recursive:
@@ -175,14 +233,14 @@ def _get_instances_raw(object_collection, patterns, key, is_case, is_re, selecti
object_collection.append(item)
if other_instances:
- namemap = dict()
+ namemap = {}
for other_instance in other_instances:
if other_instance in found:
continue
found.add(other_instance)
- name = other_instance[key] if key in other_instance else ''
+ name = other_instance[key] if key in other_instance else ""
if name not in namemap:
- namemap[name] = list()
+ namemap[name] = []
namemap[name].append(other_instance)
for pattern in patterns:
pattern_is_absolute = _is_pattern_absolute(pattern, is_case, is_re)
@@ -194,7 +252,7 @@ def _get_instances_raw(object_collection, patterns, key, is_case, is_re, selecti
else:
discard = set()
for instance in found:
- value = instance[key] if key in instance else ''
+ value = instance[key] if key in instance else ""
if _value_matches_pattern(value, pattern, is_case, is_re):
discard.add(instance)
yield instance
diff --git a/spydrnet/util/get_libraries.py b/spydrnet/util/get_libraries.py
index 800965b8..ce17f84a 100644
--- a/spydrnet/util/get_libraries.py
+++ b/spydrnet/util/get_libraries.py
@@ -1,5 +1,16 @@
-from spydrnet.ir import FirstClassElement, InnerPin, OuterPin, Wire, Netlist, Library, Element, Definition, Instance, \
- Port, Cable
+from spydrnet.ir import (
+ FirstClassElement,
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Element,
+ Definition,
+ Instance,
+ Port,
+ Cable,
+)
from spydrnet.util.hierarchical_reference import HRef
from spydrnet.util.selection import Selection
from spydrnet.global_state.global_service import lookup
@@ -15,64 +26,86 @@ def get_libraries(obj, *args, **kwargs):
Parameters
----------
obj : object, Iterable - required
- The object or objects associated with this query. Queries return a collection objects associated with the
- provided object or objects that match the query criteria. For example, `sdn.get_libraries(netlist, ...)` would
- return all of the libraries associated with the provided netlist that match the additional criteria.
+ The object or objects associated with this query. Queries return a collection objects
+ associated with the provided object or objects that match the query criteria. For example,
+ `sdn.get_libraries(netlist, ...)` would return all of the libraries associated with the
+ provided netlist that match the additional criteria.
patterns : str, Iterable - optional, positional or named, default: wildcard
- The search patterns. Patterns can be a single string or an Iterable collection of strings. Patterns can be
- absolute or they can contain wildcards or regular expressions. If `patterns` is not provided, then it defaults
- to a wildcard. Patterns are queried against the object property value stored under a specified key. Fast lookups
- are only attempted on absolute patterns that are not regular expressions and contain no wildcards.
+ The search patterns. Patterns can be a single string or an Iterable collection of strings.
+ Patterns can be absolute or they can contain wildcards or regular expressions. If
+ `patterns` is not provided, then it defaults to a wildcard. Patterns are queried against
+ the object property value stored under a specified key. Fast lookups are only attempted on
+ absolute patterns that are not regular expressions and contain no wildcards.
key : str, optional, default: ".NAME"
- This is the key that controls which value is being searched.
+ This is the key that controls which value is being searched.
is_case : bool - optional, named, default: True
- Specify if patterns should be treated as case sensitive. Only applies to patterns. Does not alter fast lookup
- behavior (if namespace policy uses case insensitive indexing, this parameter will not prevent a fast lookup
- from returning a matching object even if the case is not an exact match).
+ Specify if patterns should be treated as case sensitive. Only applies to patterns. Does not
+ alter fast lookup behavior (if namespace policy uses case insensitive indexing, this
+ parameter will not prevent a fast lookup from returning a matching object even if the case
+ is not an exact match).
is_re: bool - optional, named, default: False
- Specify if patterns are regular expressions. If `False`, a pattern can still contain `*` and `?` wildcards. A
- `*` matches zero or more characters. A `?` matches upto a single character.
+ Specify if patterns are regular expressions. If `False`, a pattern can still contain `*`
+ and `?` wildcards. A `*` matches zero or more characters. A `?` matches upto a single
+ character.
recursive : bool - optional, default: False
- Specify if search should be recursive or not meaning that sub hierarchical instances within an instance are
- included or not.
+ Specify if search should be recursive or not meaning that sub hierarchical instances within
+ an instance are included or not.
selection : Selection.{INSIDE, OUTSIDE}, default: INSIDE
- This parameter determines the instances that are returned based on the definition that is being searched. This
- parameter only applies to objects that are definitions. If the selection is "INSIDE" (default), then the
- function will return all of the instances that are inside the definition (i.e., the definition's children) that
- match the remainder of the search criteria. If the selection is "OUTSIDE", then the function will return all of
- the instances of the provided definition that match the remainder of the search criteria.
+ This parameter determines the instances that are returned based on the definition that is
+ being searched. This parameter only applies to objects that are definitions. If the
+ selection is "INSIDE" (default), then the function will return all of the instances that
+ are inside the definition (i.e., the definition's children) that match the remainder of the
+ search criteria. If the selection is "OUTSIDE", then the function will return all of the
+ instances of the provided definition that match the remainder of the search criteria.
filter : function
- This is a single input function that can be used to filter out unwanted virtual instances. If not specifed, all
- matching virtual instances are returned. Otherwise, virtual instances that cause the filter function to evaluate
- to true are the only items returned.
-
+ This is a single input function that can be used to filter out unwanted virtual instances.
+ If not specifed, all matching virtual instances are returned. Otherwise, virtual instances
+ that cause the filter function to evaluate to true are the only items returned.
+
Returns
-------
libraries : generator
- The libraries associated with a particular object
-
+ The libraries associated with a particular object
+
"""
# Check argument list
- if len(args) == 1 and 'patterns' in kwargs:
+ if len(args) == 1 and "patterns" in kwargs:
raise TypeError("get_libraries() got multiple values for argument 'patterns'")
- if len(args) > 1 or any(x not in {'patterns', 'key', 'filter', 'is_case', 'is_re', 'selection', 'recursive'}
- for x in kwargs):
+ if len(args) > 1 or any(
+ x
+ not in {
+ "patterns",
+ "key",
+ "filter",
+ "is_case",
+ "is_re",
+ "selection",
+ "recursive",
+ }
+ for x in kwargs
+ ):
raise TypeError("Unknown usage. Please see help for more information.")
# Default values
- selection = kwargs.get('selection', Selection.INSIDE)
+ selection = kwargs.get("selection", Selection.INSIDE)
if isinstance(selection, str):
if selection in Selection.__members__:
selection = Selection[selection]
if selection not in {Selection.INSIDE, Selection.OUTSIDE}:
- raise TypeError("selection must be '{}'".format("', '".join([Selection.INSIDE.name, Selection.OUTSIDE.name])))
+ raise TypeError(
+ "selection must be '{}'".format(
+ "', '".join([Selection.INSIDE.name, Selection.OUTSIDE.name])
+ )
+ )
- filter_func = kwargs.get('filter', lambda x: True)
- is_case = kwargs.get('is_case', True)
- is_re = kwargs.get('is_re', False)
- patterns = args[0] if len(args) == 1 else kwargs.get('patterns', ".*" if is_re else "*")
- key = kwargs.get('key', ".NAME")
- recursive = kwargs.get('recursive', False)
+ filter_func = kwargs.get("filter", lambda x: True)
+ is_case = kwargs.get("is_case", True)
+ is_re = kwargs.get("is_re", False)
+ patterns = (
+ args[0] if len(args) == 1 else kwargs.get("patterns", ".*" if is_re else "*")
+ )
+ key = kwargs.get("key", ".NAME")
+ recursive = kwargs.get("recursive", False)
if isinstance(obj, (FirstClassElement, InnerPin, OuterPin, Wire)) is False:
try:
@@ -82,22 +115,42 @@ def get_libraries(obj, *args, **kwargs):
else:
netlist_collection = [obj]
if all(isinstance(x, (Element, HRef)) for x in netlist_collection) is False:
- raise TypeError("get_libraries() supports all netlist elements and hierarchical references or a collection of "
- "theses as the object searched, unsupported object provided")
+ raise TypeError(
+ "get_libraries() supports all netlist elements and hierarchical references \
+ or a collection of "
+ "theses as the object searched, unsupported object provided"
+ )
if isinstance(patterns, str):
patterns = (patterns,)
- return _get_libraries(netlist_collection, patterns, key, is_case, is_re, selection, recursive, filter_func)
+ return _get_libraries(
+ netlist_collection,
+ patterns,
+ key,
+ is_case,
+ is_re,
+ selection,
+ recursive,
+ filter_func,
+ )
-def _get_libraries(netlist_collection, patterns, key, is_case, is_re, selection, recursive, filter_func):
- for result in filter(filter_func, _get_libraries_raw(netlist_collection, patterns, key, is_case, is_re, selection,
- recursive)):
+def _get_libraries(
+ netlist_collection, patterns, key, is_case, is_re, selection, recursive, filter_func
+):
+ for result in filter(
+ filter_func,
+ _get_libraries_raw(
+ netlist_collection, patterns, key, is_case, is_re, selection, recursive
+ ),
+ ):
yield result
-def _get_libraries_raw(object_collection, patterns, key, is_case, is_re, selection, recursive):
+def _get_libraries_raw(
+ object_collection, patterns, key, is_case, is_re, selection, recursive
+):
found = set()
other_libraries = set()
while object_collection:
@@ -112,8 +165,10 @@ def _get_libraries_raw(object_collection, patterns, key, is_case, is_re, selecti
yield result
else:
for library in obj.libraries:
- value = library[key] if key in library else ''
- if library not in found and _value_matches_pattern(value, pattern, is_case, is_re):
+ value = library[key] if key in library else ""
+ if library not in found and _value_matches_pattern(
+ value, pattern, is_case, is_re
+ ):
found.add(library)
yield library
elif isinstance(obj, Library):
@@ -193,14 +248,14 @@ def _get_libraries_raw(object_collection, patterns, key, is_case, is_re, selecti
object_collection.append(obj.item)
if other_libraries:
- namemap = dict()
+ namemap = {}
for other_instance in other_libraries:
if other_instance in found:
continue
found.add(other_instance)
- name = other_instance[key] if key in other_instance else ''
+ name = other_instance[key] if key in other_instance else ""
if name not in namemap:
- namemap[name] = list()
+ namemap[name] = []
namemap[name].append(other_instance)
for pattern in patterns:
pattern_is_absolute = _is_pattern_absolute(pattern, is_case, is_re)
@@ -212,7 +267,7 @@ def _get_libraries_raw(object_collection, patterns, key, is_case, is_re, selecti
else:
discard = set()
for instance in found:
- value = instance[key] if key in instance else ''
+ value = instance[key] if key in instance else ""
if _value_matches_pattern(value, pattern, is_case, is_re):
discard.add(instance)
yield instance
diff --git a/spydrnet/util/get_netlists.py b/spydrnet/util/get_netlists.py
index 9dc86d80..df9be367 100644
--- a/spydrnet/util/get_netlists.py
+++ b/spydrnet/util/get_netlists.py
@@ -1,5 +1,16 @@
-from spydrnet.ir import Element, FirstClassElement, InnerPin, OuterPin, Wire, Netlist, Library, Definition, Port, \
- Cable, Instance
+from spydrnet.ir import (
+ Element,
+ FirstClassElement,
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition,
+ Port,
+ Cable,
+ Instance,
+)
from spydrnet.util.hierarchical_reference import HRef
from spydrnet.util.patterns import _is_pattern_absolute, _value_matches_pattern
@@ -9,51 +20,58 @@ def get_netlists(obj, *args, **kwargs):
get_netlists(obj, ...)
Get netlists *within* an object.
-
+
Parameters
----------
obj : object, Iterable - required
- The object or objects associated with this query. Queries return a collection objects associated with the
- provided object or objects that match the query criteria. For example, `sdn.get_libraries(netlist, ...)` would
- return all of the libraries associated with the provided netlist that match the additional criteria.
-
+ The object or objects associated with this query. Queries return a collection objects
+ associated with the provided object or objects that match the query criteria. For example,
+ `sdn.get_libraries(netlist, ...)` would return all of the libraries associated with the
+ provided netlist that match the additional criteria.
patterns : str, Iterable - optional, positional or named, (default: wildcard)
- The search patterns. Patterns can be a single string or an Iterable collection of strings. Patterns can be
- absolute or they can contain wildcards or regular expressions. If `patterns` is not provided, then it defaults
- to a wildcard. Patterns are queried against the object property value stored under a specified key. Fast lookups
- are only attempted on absolute patterns that are not regular expressions and contain no wildcards.
+ The search patterns. Patterns can be a single string or an Iterable collection of strings.
+ Patterns can be absolute or they can contain wildcards or regular expressions. If
+ `patterns` is not provided, then it defaults to a wildcard. Patterns are queried against
+ the object property value stored under a specified key. Fast lookups are only attempted on
+ absolute patterns that are not regular expressions and contain no wildcards.
key : str, optional, (default: ".NAME")
- This is the key that controls which value is being searched.
+ This is the key that controls which value is being searched.
is_case : bool - optional, named, (default: True)
- Specify if patterns should be treated as case sensitive. Only applies to patterns. Does not alter fast lookup
- behavior (if namespace policy uses case insensitive indexing, this parameter will not prevent a fast lookup
- from returning a matching object even if the case is not an exact match).
+ Specify if patterns should be treated as case sensitive. Only applies to patterns. Does not
+ alter fast lookup behavior (if namespace policy uses case insensitive indexing, this
+ parameter will not prevent a fast lookup from returning a matching object even if the case
+ is not an exact match).
is_re: bool - optional, named, (default: False)
- Specify if patterns are regular expressions. If `False`, a pattern can still contain `*` and `?` wildcards. A
- `*` matches zero or more characters. A `?` matches upto a single character.
+ Specify if patterns are regular expressions. If `False`, a pattern can still contain `*`
+ and `?` wildcards. A `*` matches zero or more characters. A `?` matches upto a single
+ character.
filter : function
- This is a single input function that can be used to filter out unwanted virtual instances. If not specifed, all
- matching virtual instances are returned. Otherwise, virtual instances that cause the filter function to evaluate
- to true are the only items returned.
-
+ This is a single input function that can be used to filter out unwanted virtual instances.
+ If not specifed, all matching virtual instances are returned. Otherwise, virtual instances
+ that cause the filter function to evaluate to true are the only items returned.
+
Returns
-------
netlists : generator
- A generator associated with a particular object
-
+ A generator associated with a particular object
+
"""
# Check argument list
- if len(args) == 1 and 'patterns' in kwargs:
+ if len(args) == 1 and "patterns" in kwargs:
raise TypeError("get_netlists() got multiple values for argument 'patterns'")
- if len(args) > 1 or any(x not in {'patterns', 'key', 'filter', 'is_case', 'is_re'} for x in kwargs):
+ if len(args) > 1 or any(
+ x not in {"patterns", "key", "filter", "is_case", "is_re"} for x in kwargs
+ ):
raise TypeError("Unknown usage. Please see help for more information.")
# Default values
- filter_func = kwargs.get('filter', lambda x: True)
- is_case = kwargs.get('is_case', True)
- is_re = kwargs.get('is_re', False)
- patterns = args[0] if len(args) == 1 else kwargs.get('patterns', ".*" if is_re else "*")
- key = kwargs.get('key', ".NAME")
+ filter_func = kwargs.get("filter", lambda x: True)
+ is_case = kwargs.get("is_case", True)
+ is_re = kwargs.get("is_re", False)
+ patterns = (
+ args[0] if len(args) == 1 else kwargs.get("patterns", ".*" if is_re else "*")
+ )
+ key = kwargs.get("key", ".NAME")
if isinstance(obj, (FirstClassElement, InnerPin, OuterPin, Wire)) is False:
try:
@@ -63,8 +81,10 @@ def get_netlists(obj, *args, **kwargs):
else:
object_collection = [obj]
if all(isinstance(x, (Element, HRef)) for x in object_collection) is False:
- raise TypeError("get_netlists() supports netlist elements and hierarchical references or a collection of "
- "theses as the object searched, unsupported object provided")
+ raise TypeError(
+ "get_netlists() supports netlist elements and hierarchical references or a collection \
+ of these as the object searched, unsupported object provided"
+ )
if isinstance(patterns, str):
patterns = (patterns,)
@@ -73,13 +93,15 @@ def get_netlists(obj, *args, **kwargs):
def _get_netlists(object_collection, patterns, key, is_case, is_re, filter_func):
- for result in filter(filter_func, _get_netlists_raw(object_collection, patterns, key, is_case, is_re)):
+ for result in filter(
+ filter_func, _get_netlists_raw(object_collection, patterns, key, is_case, is_re)
+ ):
yield result
def _get_netlists_raw(object_collection, patterns, key, is_case, is_re):
found = set()
- namemap = dict()
+ namemap = {}
while object_collection:
obj = object_collection.pop()
if isinstance(obj, Netlist):
@@ -87,7 +109,7 @@ def _get_netlists_raw(object_collection, patterns, key, is_case, is_re):
found.add(obj)
name = obj.get(key, None)
if name not in namemap:
- namemap[name] = list()
+ namemap[name] = []
namemap[name].append(obj)
elif isinstance(obj, Library):
netlist = obj.netlist
@@ -139,7 +161,7 @@ def _get_netlists_raw(object_collection, patterns, key, is_case, is_re):
else:
yielded = set()
for netlist in found:
- value = netlist[key] if key in netlist else ''
+ value = netlist[key] if key in netlist else ""
if _value_matches_pattern(value, pattern, is_case, is_re):
yielded.add(netlist)
yield netlist
diff --git a/spydrnet/util/get_pins.py b/spydrnet/util/get_pins.py
index 3120bede..5c140871 100644
--- a/spydrnet/util/get_pins.py
+++ b/spydrnet/util/get_pins.py
@@ -1,5 +1,15 @@
-from spydrnet.ir import Element, InnerPin, OuterPin, Wire, Netlist, Library, Definition, Instance,\
- Port, Cable
+from spydrnet.ir import (
+ Element,
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition,
+ Instance,
+ Port,
+ Cable,
+)
from spydrnet.util.hierarchical_reference import HRef
from spydrnet.util.selection import Selection
@@ -13,36 +23,42 @@ def get_pins(obj, *args, **kwargs):
Parameters
----------
obj : object, Iterable - required
- The object or objects associated with this query. Queries return a collection objects associated with the
- provided object or objects that match the query criteria. For example, `sdn.get_ports(definition, ...)` would
- return all of the ports associated with the provided definition that match the additional criteria.
+ The object or objects associated with this query. Queries return a collection objects
+ associated with the provided object or objects that match the query criteria. For example,
+ `sdn.get_ports(definition, ...)` would return all of the ports associated with the provided
+ definition that match the additional criteria.
selection : Selection.{INSIDE, OUTSIDE}, default: INSIDE
- Controls the type of pin returned. Setting this parameter to "OUTSIDE" will return the outer pins of the objects
- queried. For cables, this returns the corresponding pin based on this parameter.
+ Controls the type of pin returned. Setting this parameter to "OUTSIDE" will return the
+ outer pins of the objects queried. For cables, this returns the corresponding pin based on
+ this parameter.
filter : function
- This is a single input function that can be used to filter out unwanted virtual instances. If not specifed, all
- matching virtual instances are returned. Otherwise, virtual instances that cause the filter function to evaluate
- to true are the only items returned.
-
+ This is a single input function that can be used to filter out unwanted virtual instances.
+ If not specifed, all matching virtual instances are returned. Otherwise, virtual instances
+ that cause the filter function to evaluate to true are the only items returned.
+
Returns
-------
pins : generator
The pins associated with a particular object or collection of objects.
-
+
"""
# Check argument list
- if len(args) > 0 or any(x not in {'filter', 'selection'} for x in kwargs):
+ if len(args) > 0 or any(x not in {"filter", "selection"} for x in kwargs):
raise TypeError("Unknown usage. Please see help for more information.")
# Default values
- selection = kwargs.get('selection', Selection.INSIDE)
+ selection = kwargs.get("selection", Selection.INSIDE)
if isinstance(selection, str):
if selection in Selection.__members__:
selection = Selection[selection]
if selection not in {Selection.INSIDE, Selection.OUTSIDE}:
- raise TypeError("selection must be '{}'".format("', '".join([Selection.INSIDE.name, Selection.OUTSIDE.name])))
+ raise TypeError(
+ "selection must be '{}'".format(
+ "', '".join([Selection.INSIDE.name, Selection.OUTSIDE.name])
+ )
+ )
- filter_func = kwargs.get('filter', lambda x: True)
+ filter_func = kwargs.get("filter", lambda x: True)
if isinstance(obj, (Element, HRef)) is False:
try:
@@ -52,8 +68,10 @@ def get_pins(obj, *args, **kwargs):
else:
object_collection = [obj]
if all(isinstance(x, (Element, HRef)) for x in object_collection) is False:
- raise TypeError("get_ports() supports netlist elements and hierarchical references, or a collection of "
- "these as the object searched")
+ raise TypeError(
+ "get_ports() supports netlist elements and hierarchical references, or a collection of "
+ "these as the object searched"
+ )
return _get_ports(object_collection, selection, filter_func)
diff --git a/spydrnet/util/get_ports.py b/spydrnet/util/get_ports.py
index 8f4006bc..50ae736b 100644
--- a/spydrnet/util/get_ports.py
+++ b/spydrnet/util/get_ports.py
@@ -1,5 +1,16 @@
-from spydrnet.ir import Element, FirstClassElement, InnerPin, OuterPin, Wire, Netlist, Library, Definition, Instance,\
- Port, Cable
+from spydrnet.ir import (
+ Element,
+ FirstClassElement,
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition,
+ Instance,
+ Port,
+ Cable,
+)
from spydrnet.util.hierarchical_reference import HRef
from spydrnet.global_state.global_service import lookup
from spydrnet.util.patterns import _is_pattern_absolute, _value_matches_pattern
@@ -14,46 +25,54 @@ def get_ports(obj, *args, **kwargs):
Parameters
----------
obj : object, Iterable - required
- The object or objects associated with this query. Queries return a collection objects associated with the
- provided object or objects that match the query criteria. For example, `sdn.get_ports(definition, ...)` would
- return all of the ports associated with the provided definition that match the additional criteria.
+ The object or objects associated with this query. Queries return a collection objects
+ associated with the provided object or objects that match the query criteria. For example,
+ `sdn.get_ports(definition, ...)` would return all of the ports associated with the provided
+ definition that match the additional criteria.
patterns : str, Iterable - optional, positional or named, default: wildcard
- The search patterns. Patterns can be a single string or an Iterable collection of strings. Patterns can be
- absolute or they can contain wildcards or regular expressions. If `patterns` is not provided, then it defaults
- to a wildcard. Patterns are queried against the object property value stored under a specified key. Fast lookups
- are only attempted on absolute patterns that are not regular expressions and contain no wildcards.
+ The search patterns. Patterns can be a single string or an Iterable collection of strings.
+ Patterns can be absolute or they can contain wildcards or regular expressions. If
+ `patterns` is not provided, then it defaults to a wildcard. Patterns are queried against
+ the object property value stored under a specified key. Fast lookups are only attempted on
+ absolute patterns that are not regular expressions and contain no wildcards.
key : str, optional, default: ".NAME"
- This is the key that controls which value is being searched.
+ This is the key that controls which value is being searched.
is_case : bool - optional, named, default: True
- Specify if patterns should be treated as case sensitive. Only applies to patterns. Does not alter fast lookup
- behavior (if namespace policy uses case insensitive indexing, this parameter will not prevent a fast lookup
- from returning a matching object even if the case is not an exact match).
+ Specify if patterns should be treated as case sensitive. Only applies to patterns. Does not
+ alter fast lookup behavior (if namespace policy uses case insensitive indexing, this
+ parameter will not prevent a fast lookup from returning a matching object even if the case
+ is not an exact match).
is_re: bool - optional, named, default: False
- Specify if patterns are regular expressions. If `False`, a pattern can still contain `*` and `?` wildcards. A
- `*` matches zero or more characters. A `?` matches upto a single character.
+ Specify if patterns are regular expressions. If `False`, a pattern can still contain `*`
+ and `?` wildcards. A `*` matches zero or more characters. A `?` matches upto a single
+ character.
filter : function
- This is a single input function that can be used to filter out unwanted virtual instances. If not specifed, all
- matching virtual instances are returned. Otherwise, virtual instances that cause the filter function to evaluate
- to true are the only items returned.
-
+ This is a single input function that can be used to filter out unwanted virtual instances.
+ If not specifed, all matching virtual instances are returned. Otherwise, virtual instances
+ that cause the filter function to evaluate to true are the only items returned.
+
Returns
-------
ports : generator
- The ports associated with a particular object or collection of objects.
-
+ The ports associated with a particular object or collection of objects.
+
"""
# Check argument list
- if len(args) == 1 and 'patterns' in kwargs:
+ if len(args) == 1 and "patterns" in kwargs:
raise TypeError("get_ports() got multiple values for argument 'patterns'")
- if len(args) > 1 or any(x not in {'patterns', 'key', 'filter', 'is_case', 'is_re'} for x in kwargs):
+ if len(args) > 1 or any(
+ x not in {"patterns", "key", "filter", "is_case", "is_re"} for x in kwargs
+ ):
raise TypeError("Unknown usage. Please see help for more information.")
# Default values
- filter_func = kwargs.get('filter', lambda x: True)
- is_case = kwargs.get('is_case', True)
- is_re = kwargs.get('is_re', False)
- patterns = args[0] if len(args) == 1 else kwargs.get('patterns', ".*" if is_re else "*")
- key = kwargs.get('key', ".NAME")
+ filter_func = kwargs.get("filter", lambda x: True)
+ is_case = kwargs.get("is_case", True)
+ is_re = kwargs.get("is_re", False)
+ patterns = (
+ args[0] if len(args) == 1 else kwargs.get("patterns", ".*" if is_re else "*")
+ )
+ key = kwargs.get("key", ".NAME")
if isinstance(obj, (FirstClassElement, InnerPin, OuterPin, Wire)) is False:
try:
@@ -63,8 +82,10 @@ def get_ports(obj, *args, **kwargs):
else:
object_collection = [obj]
if all(isinstance(x, (Element, HRef)) for x in object_collection) is False:
- raise TypeError("get_ports() supports netlist elements and hierarchical references, or a collection of "
- "these as the object searched")
+ raise TypeError(
+ "get_ports() supports netlist elements and hierarchical references, or a collection of "
+ "these as the object searched"
+ )
if isinstance(patterns, str):
patterns = (patterns,)
@@ -73,7 +94,9 @@ def get_ports(obj, *args, **kwargs):
def _get_ports(object_collection, patterns, key, is_case, is_re, filter_func):
- for result in filter(filter_func, _get_ports_raw(object_collection, patterns, key, is_case, is_re)):
+ for result in filter(
+ filter_func, _get_ports_raw(object_collection, patterns, key, is_case, is_re)
+ ):
yield result
@@ -92,8 +115,10 @@ def _get_ports_raw(object_collection, patterns, key, is_case, is_re):
yield result
else:
for port in obj.ports:
- value = port[key] if key in port else ''
- if port not in found and _value_matches_pattern(value, pattern, is_case, is_re):
+ value = port[key] if key in port else ""
+ if port not in found and _value_matches_pattern(
+ value, pattern, is_case, is_re
+ ):
found.add(port)
yield port
elif isinstance(obj, Netlist):
@@ -125,14 +150,14 @@ def _get_ports_raw(object_collection, patterns, key, is_case, is_re):
object_collection.append(obj.item)
if other_ports:
- namemap = dict()
+ namemap = {}
for other_port in other_ports:
if other_port in found:
continue
found.add(other_port)
- name = other_port[key] if key in other_port else ''
+ name = other_port[key] if key in other_port else ""
if name not in namemap:
- namemap[name] = list()
+ namemap[name] = []
namemap[name].append(other_port)
for pattern in patterns:
pattern_is_absolute = _is_pattern_absolute(pattern, is_case, is_re)
@@ -143,7 +168,7 @@ def _get_ports_raw(object_collection, patterns, key, is_case, is_re):
for port in result:
yield port
else:
- names_to_remove = list()
+ names_to_remove = []
for name in namemap:
if _value_matches_pattern(name, pattern, is_case, is_re):
result = namemap[name]
diff --git a/spydrnet/util/get_wires.py b/spydrnet/util/get_wires.py
index 6a07ef60..75c688bd 100644
--- a/spydrnet/util/get_wires.py
+++ b/spydrnet/util/get_wires.py
@@ -1,5 +1,15 @@
-from spydrnet import InnerPin, OuterPin, Wire, Netlist, Library, Definition, Instance, Port, Cable,\
- Element
+from spydrnet import (
+ InnerPin,
+ OuterPin,
+ Wire,
+ Netlist,
+ Library,
+ Definition,
+ Instance,
+ Port,
+ Cable,
+ Element,
+)
from spydrnet.util.hierarchical_reference import HRef
from spydrnet.util.selection import Selection
@@ -13,41 +23,45 @@ def get_wires(obj, *args, **kwargs):
Parameters
----------
obj : object, Iterable - required
- The object or objects associated with this query. Queries return a collection of objects associated with the
- provided object or objects that match the query criteria. For example, `sdn.get_instances(netlist, ...)` would
- return all of the instances *within* the provided definition that match the additional criteria.
+ The object or objects associated with this query. Queries return a collection of objects
+ associated with the provided object or objects that match the query criteria. For example,
+ `sdn.get_instances(netlist, ...)` would return all of the instances *within* the provided
+ definition that match the additional criteria.
recursive : bool - optional, default: False
- Specify if search should be recursive or not meaning that sub hierarchical instances within an instance are
- included or not.
+ Specify if search should be recursive or not meaning that sub hierarchical instances within
+ an instance are included or not.
selection : Selection.{INSIDE, OUTSIDE, BOTH, ALL}, default: INSIDE
- This parameter determines the wires that are returned based on the instance associated with the object that is
- being searched.
+ This parameter determines the wires that are returned based on the instance associated with
+ the object that is being searched.
filter : function
- This is a single input function that can be used to filter out unwanted virtual instances. If not specifed, all
- matching virtual instances are returned. Otherwise, virtual instances that cause the filter function to evaluate
- to true are the only items returned.
-
+ This is a single input function that can be used to filter out unwanted virtual instances.
+ If not specifed, all matching virtual instances are returned. Otherwise, virtual instances
+ that cause the filter function to evaluate to true are the only items returned.
+
Returns
-------
wires : generator
- The wires associated with a particular object or collection of objects.
-
+ The wires associated with a particular object or collection of objects.
+
"""
# Check argument list
- if len(args) > 0 or any(x not in {'selection', 'recursive', 'filter'} for x in
- kwargs):
+ if len(args) > 0 or any(
+ x not in {"selection", "recursive", "filter"} for x in kwargs
+ ):
raise TypeError("Unknown usage. Please see help for more information.")
# Default values
- selection = kwargs.get('selection', Selection.INSIDE)
+ selection = kwargs.get("selection", Selection.INSIDE)
if isinstance(selection, str):
if selection in Selection.__members__:
selection = Selection[selection]
if isinstance(selection, Selection) is False:
- raise TypeError("selection must be '{}'".format("', '".join(Selection.__members__.keys())))
+ raise TypeError(
+ "selection must be '{}'".format("', '".join(Selection.__members__.keys()))
+ )
- filter_func = kwargs.get('filter', lambda x: True)
- recursive = kwargs.get('recursive', False)
+ filter_func = kwargs.get("filter", lambda x: True)
+ recursive = kwargs.get("recursive", False)
if isinstance(obj, (Element, HRef)) is False:
try:
@@ -57,14 +71,18 @@ def get_wires(obj, *args, **kwargs):
else:
object_collection = [obj]
if all(isinstance(x, (HRef, Element)) for x in object_collection) is False:
- raise TypeError("get_hwires() supports all netlist related objects and hierarchical references or a "
- "collection of theses as the object searched, unsupported object provided")
+ raise TypeError(
+ "get_hwires() supports all netlist related objects and hierarchical references or a "
+ "collection of theses as the object searched, unsupported object provided"
+ )
return _get_wires(object_collection, selection, recursive, filter_func)
def _get_wires(object_collection, selection, recursive, filter_func):
- for result in filter(filter_func, _get_wires_raw(object_collection, selection, recursive)):
+ for result in filter(
+ filter_func, _get_wires_raw(object_collection, selection, recursive)
+ ):
yield result
diff --git a/spydrnet/util/hierarchical_reference.py b/spydrnet/util/hierarchical_reference.py
index 0f4167c3..cc783246 100644
--- a/spydrnet/util/hierarchical_reference.py
+++ b/spydrnet/util/hierarchical_reference.py
@@ -1,5 +1,5 @@
-import spydrnet.ir as ir
import weakref
+from spydrnet import ir
from spydrnet.shortcuts.getter import GetterShortcuts
@@ -9,19 +9,22 @@
class HRef(GetterShortcuts):
"""A hierarchical reference to a specific element in a netlist.
- Definitions can be instanced more than once (i.e., multiple instances can reference the same definition).
- When a definition is instanced more than once, it causes the contents of the definition to be shared. Therefore, any
- changes to a multi-instanced definition will be reflected in all instances of that definition. Similarly, any
- references to the contents of a multi-instanced definition refer to the contents of all of the instances and not to
- the contents of a specific instance. This sharing creates challenges for analyzing and transforming the netlist.
-
- Hierarchical references refer to a netlist element by hierarchical sequence. A hierarchical sequence begins with the
- the top-instance of netlist (see Netlist.top_instance). The sequence continues with children instances (parent to
- child) until the instance of interest is reached. The instance of interest is the final instance in the sequence.
- When the referenced element is an instance, the sequence terminates. When the referenced element is a port, pin,
- cable, or wire, the sequence continues with those elements until the desired element is specified (e.g., port;
- port, pin; cable; or cable, wire. In this way, hierarhical elements are uniquely referenced even though the contents
- of a definition may be shared.
+ Definitions can be instanced more than once (i.e., multiple instances can reference the same
+ definition). When a definition is instanced more than once, it causes the contents of the
+ definition to be shared. Therefore, any changes to a multi-instanced definition will be
+ reflected in all instances of that definition. Similarly, any references to the contents of a
+ multi-instanced definition refer to the contents of all of the instances and not to the contents
+ of a specific instance. This sharing creates challenges for analyzing and transforming the
+ netlist.
+
+ Hierarchical references refer to a netlist element by hierarchical sequence. A hierarchical
+ sequence begins with the the top-instance of netlist (see Netlist.top_instance). The sequence
+ continues with children instances (parent to child) until the instance of interest is reached.
+ The instance of interest is the final instance in the sequence. When the referenced element is
+ an instance, the sequence terminates. When the referenced element is a port, pin, cable, or
+ wire, the sequence continues with those elements until the desired element is specified (e.g.,
+ port; port, pin; cable; or cable, wire. In this way, hierarhical elements are uniquely
+ referenced even though the contents of a definition may be shared.
**Hierarchical Sequence Examples:**
@@ -36,54 +39,62 @@ class HRef(GetterShortcuts):
* Shared Sub-Instance Cable)
* ``[top_instance, sub_instance_A, sub_instance_C, cable]``
* ``[top_instance, sub_instance_B, sub_instance_C, cable]``
- * ``sub_instance_A`` and ``sub_instance_B`` are instances (or children) with the definition referenced by
- ``top_instance``.
- * ``sub_instance_A`` and ``sub_instance_B`` reference the same definition, which contains ``sub_instance_C``.
- * Even though ``cable`` is the same element in both sequences, each sequence uniquely references the cable
- inside ``sub_instance_A`` and ``sub_instance_B`` respectively.
+ * ``sub_instance_A`` and ``sub_instance_B`` are instances (or children) with the definition
+ referenced by ``top_instance``.
+ * ``sub_instance_A`` and ``sub_instance_B`` reference the same definition, which contains
+ ``sub_instance_C``.
+ * Even though ``cable`` is the same element in both sequences, each sequence uniquely
+ references the cable inside ``sub_instance_A`` and ``sub_instance_B`` respectively.
**Netlist Analysis and Transformation:**
- Hierarchical references provide unique handles on hierarchical elements. A unique handle allows for such elements to
- be considered individually even though two hierarchical may point to some of the same elements. This makes it
- possible, for example, to consider pin connectivity across hierarchy even though the actual pins may be the same.
+ Hierarchical references provide unique handles on hierarchical elements. A unique handle allows
+ for such elements to be considered individually even though two hierarchical may point to some
+ of the same elements. This makes it possible, for example, to consider pin connectivity across
+ hierarchy even though the actual pins may be the same.
- In some netlist tranformations, it may be desirable to modify the contents of a specific instance without modifying
- the contents of another instance that refers to the same definition. Hierarchical references make it possible to
- refer to an instance that should be changed. Once the definition is made unique (see spydrnet.uniquify), then any
- alterations will only affect the originally specified instance. Hierarchical instances also allow for uniqueness
- checking (see HRef.is_unique).
+ In some netlist tranformations, it may be desirable to modify the contents of a specific
+ instance without modifying the contents of another instance that refers to the same definition.
+ Hierarchical references make it possible to refer to an instance that should be changed. Once
+ the definition is made unique (see spydrnet.uniquify), then any alterations will only affect the
+ originally specified instance. Hierarchical instances also allow for uniqueness checking (see
+ HRef.is_unique).
**Hierarchical Reference Representation:**
- HRefs represent hierarchy as nodes in a hierarchical tree. The root node is an HRef to the top_instance of a netlist
- with no parent node. Each HRef contains a pointer to its parent HRef (``None`` in the case of the root HRef), a
- pointer to the element in the netlist that it references, and a hashcode generated from each referenced object.
+ HRefs represent hierarchy as nodes in a hierarchical tree. The root node is an HRef to the
+ top_instance of a netlist with no parent node. Each HRef contains a pointer to its parent HRef
+ (``None`` in the case of the root HRef), a pointer to the element in the netlist that it
+ references, and a hashcode generated from each referenced object.
- Storing the hashcode with the object saves on re-computation and allows for quick operations in containers that
- require Hashable objects. If the hashcode were not stored with the object, it would have to be recalculated for
- each hash-dependent operation, which could consume a large amount of computational resources depending on the
- hierarchical depth of the node. Parent and item pointers are immutable. The hashcode of a referenced item is also
- immutable. Therefore, the hashcode of a HRef should not change during its existence (even if a netlist
- transformation renders it invalid).
+ Storing the hashcode with the object saves on re-computation and allows for quick operations in
+ containers that require Hashable objects. If the hashcode were not stored with the object, it
+ would have to be recalculated for each hash-dependent operation, which could consume a large
+ amount of computational resources depending on the hierarchical depth of the node. Parent and
+ item pointers are immutable. The hashcode of a referenced item is also immutable. Therefore, the
+ hashcode of a HRef should not change during its existence (even if a netlist transformation
+ renders it invalid).
**Use of a Flyweight Pattern:**
- Due the the nature of hierarchical references, parent nodes can be referenced more than once. Rather than having
- multiple hierarchical nodes in memory that point to the same hierarchical parent, a flyweight can be used to save
- on memory. A flyweight pattern is used here to share hierarchical parent nodes. See `Flyweight pattern
+ Due the the nature of hierarchical references, parent nodes can be referenced more than once.
+ Rather than having multiple hierarchical nodes in memory that point to the same hierarchical
+ parent, a flyweight can be used to save on memory. A flyweight pattern is used here to share
+ hierarchical parent nodes. See `Flyweight pattern
`_.
**Lack of Parent to Child Pointers:**
- A parent to child pointer requires a lookup diction from each child item to each child hierarchical node. This
- approach could be taken, but it recreates much of the same information that is available in the original netlist. It
- was therefore decided to leverage the flyweight pattern rather than explicitly manage all of the necessary
- child-item to child-node relationships.
+ A parent to child pointer requires a lookup diction from each child item to each child
+ hierarchical node. This approach could be taken, but it recreates much of the same information
+ that is available in the original netlist. It was therefore decided to leverage the flyweight
+ pattern rather than explicitly manage all of the necessary child-item to child-node
+ relationships.
.. attribute:: item: the item of the object
.. attribute:: parent: the parent of the object
"""
+
@staticmethod
def get_all_hrefs_of_item(item):
"""Get all the href of the itsm
@@ -139,7 +150,8 @@ def get_all_hrefs_of_item(item):
@staticmethod
def get_all_hrefs_of_instances(instances, netlist=None):
"""
- Assuming all instances are vaild (meaning their reference belongs in a proper library inside a netlist).
+ Assuming all instances are vaild (meaning their reference belongs in a proper library inside
+ a netlist).
:param instances:
:param netlist:
:return:
@@ -220,11 +232,11 @@ def from_parent_and_item(parent, item):
href = HRef(item, parent)
if href in flyweight:
return flyweight[href]()
- else:
- flyweight[href] = weakref.ref(href)
- return href
- __slots__ = ['_hashcode', 'parent', 'item', '__weakref__']
+ flyweight[href] = weakref.ref(href)
+ return href
+
+ __slots__ = ["_hashcode", "parent", "item", "__weakref__"]
def __init__(self, item, parent=None):
"""Initialize the href
@@ -236,7 +248,7 @@ def __init__(self, item, parent=None):
parent - the parent obejct of this href
"""
- self._hashcode = hash(hash(parent)*31 + hash(item))
+ self._hashcode = hash(hash(parent) * 31 + hash(item))
self.parent = parent
self.item = item
@@ -261,8 +273,9 @@ def __eq__(self, other):
return False
def __repr__(self):
- return "<{} {} '{}' at 0x{:016X}>".format(self.__class__.__name__, self.item.__class__.__name__, self.name,
- id(self))
+ return "<{} {} '{}' at 0x{:016X}>".format(
+ self.__class__.__name__, self.item.__class__.__name__, self.name, id(self)
+ )
def __str__(self):
name = self.name
@@ -277,7 +290,7 @@ def is_unique(self):
if self.is_valid is False:
return False
href = self
- search_stack = list()
+ search_stack = []
instances = set()
while href:
item = href.item
@@ -285,8 +298,9 @@ def is_unique(self):
instances.add(item)
parent = item.parent
if parent and len(parent.references) > 1 and href.parent:
- search_stack += (x for x in parent.references if x !=
- href.parent.item)
+ search_stack += (
+ x for x in parent.references if x != href.parent.item
+ )
href = href.parent
while search_stack:
instance = search_stack.pop()
@@ -295,15 +309,12 @@ def is_unique(self):
for parent in reference.references:
if parent in instances:
return False
- else:
- search_stack.append(parent)
+ search_stack.append(parent)
return True
@property
def is_valid(self):
- """Checks if the href is valid
-
- """
+ """Checks if the href is valid"""
href = self
while href:
hparent = href.parent # href
@@ -366,11 +377,9 @@ def is_valid(self):
@property
def name(self):
- """Stores the name of the href
-
- """
- hseperator = '/'
- names = list()
+ """Stores the name of the href"""
+ hseperator = "/"
+ names = []
index = None
item = self.item
if isinstance(item, ir.Wire):
diff --git a/spydrnet/util/library.py b/spydrnet/util/library.py
deleted file mode 100644
index 73c63465..00000000
--- a/spydrnet/util/library.py
+++ /dev/null
@@ -1,194 +0,0 @@
-from spydrnet.ir import FirstClassElement
-from spydrnet.ir import Definition
-from spydrnet.ir.views.listview import ListView
-from spydrnet.global_state import global_callback
-from spydrnet.global_state.global_callback import _call_create_library
-from copy import deepcopy, copy, error
-
-
-class Library(FirstClassElement):
- """
- Represents a library object.
-
- Contains a pointer to parent netlist and definitions.
- """
- __slots__ = ['_netlist', '_definitions']
-
- def __init__(self, name = None, properties = None):
- """
- creates an empty object of type Library
-
- parameters
- ----------
-
- name - (str) the name of this instance
- properties - (dict) the dictionary which holds the properties
- """
- super().__init__()
- self._netlist = None
- self._definitions = list()
- _call_create_library(self)
- if name!= None:
- self.name = name
- if properties != None:
- assert isinstance(properties, dict), "properties must be a dictionary"
- for key in properties:
- self[key] = properties[key]
-
- @property
- def netlist(self):
- """
- get the netlist that contains this library
- """
- return self._netlist
-
- @property
- def definitions(self):
- """
- return a list of all the definitions that are included in this library
- """
- return ListView(self._definitions)
-
- @definitions.setter
- def definitions(self, value):
- """
- set the definitions to a new reordered set of definitions. This function cannot be used to add or remove
- definitions
-
- Parameters
- ----------
-
- value - (List containing Definition type objects) The reordered list
- """
- value_list = list(value)
- value_set = set(value_list)
- assert len(value_list) == len(value_set) and set(self._definitions) == value_set, \
- "Set of values do not match, this function can only reorder values, values must be unique"
- self._definitions = value_list
-
- def create_definition(self):
- """
- create a definition, add it to the library, and return the definition
- """
- definition = Definition()
- self.add_definition(definition)
- return definition
-
- def add_definition(self, definition, position=None):
- """
- add an existing definition to the library. The definition must not belong to a library including this one.
-
- parameters
- ----------
-
- definition - (Definition) the defintion to add to the library
-
- position - (int, default None) the index in the library list at which to add the definition
-
- """
- assert definition.library is not self, "Definition already included in library"
- assert definition.library is None, "Definition already belongs to a different library"
- global_callback._call_library_add_definition(self, definition)
- if position is not None:
- self._definitions.insert(position, definition)
- else:
- self._definitions.append(definition)
- definition._library = self
-
- def remove_definition(self, definition):
- """
- remove the given definition from the library
-
- parameters
- ----------
-
- definition - (Definition) the definition to be removed
- """
- assert definition.library == self, "definition is not included in library"
- self._remove_definition(definition)
- self._definitions.remove(definition)
-
- def remove_definitions_from(self, definitions):
- """
- remove a set of definitions from the library. all definitions provided must be in the library
-
- parameters
- ----------
-
- definitions - (Set of Definition type objects) the definitions to be removed
- """
- if isinstance(definitions, set):
- excluded_definitions = definitions
- else:
- excluded_definitions = set(definitions)
- assert all(x.library == self for x in excluded_definitions), "Some definitions to remove are not included in " \
- "the library "
- included_definitions = list()
- for definition in self._definitions:
- if definition not in excluded_definitions:
- included_definitions.append(definition)
- else:
- self._remove_definition(definition)
- self._definitions = included_definitions
-
- def _remove_definition(self, definition):
- """
- internal function to dissociate a definition from the library
- """
- global_callback._call_library_remove_definition(self, definition)
- definition._library = None
-
-
- def _clone_rip_and_replace(self, memo):
- '''remove from its current environment and place it into the new cloned environment with references held in the memo dictionary'''
- pass #this function will need to call rip and replace in library on each of the definitions when called from the netlist.
- for definition in self._definitions:
- definition._clone_rip_and_replace(memo)
-
- def _clone_rip(self, memo):
- '''remove from its current environmnet. This will remove all pin pointers and create a floating stand alone instance.'''
- # references lists of definitions need to be vacated except those that were cloned.
- for definition in self._definitions:
- new_references = set()
- for ref in definition._references:
- if ref in memo.values():
- new_references.add(ref)
- for instance in definition._children:
- instance._reference._references.add(instance)
-
- definition._references = new_references
-
-
- def _clone(self, memo):
- '''not api safe clone function
- clone leaving all references in tact.
- the element can then either be ripped or ripped and replaced'''
- assert self not in memo, "the object should not have been copied twice in this pass"
- c = Library()
- memo[self] = c
- c._netlist = None
- c._data = deepcopy(self._data)
-
- new_definitions = list()
- for definition in self._definitions:
- new_definitions.append(definition._clone(memo))
- c._definitions = new_definitions
-
- for definition in c._definitions:
- definition._library = c
- definition._clone_rip_and_replace(memo)
- return c
-
- def clone(self):
- '''
- Clone the library in an api safe manner.
- The following describes the structure of the returned object:
- * the instances that pointed to reference definitions within the library will have updated references
- * the instances that pointed to reference definitions outside the library will maintain their definitions
- * the references lists (of definitions) both inside and outsde the library will be updated to reflect the change
- * all definitions are cloned within the library.
- '''
- memo = dict()
- c = self._clone(memo)
- c._clone_rip(memo)
- return c
diff --git a/spydrnet/util/netlist_type.py b/spydrnet/util/netlist_type.py
index 020f63f6..88ff0e43 100644
--- a/spydrnet/util/netlist_type.py
+++ b/spydrnet/util/netlist_type.py
@@ -1,10 +1,12 @@
from enum import Enum
+
class NetlistType(Enum):
EDIF = 1
VERILOG = 2
EBLIF = 3
+
EDIF = NetlistType.EDIF
VERILOG = NetlistType.VERILOG
EBLIF = NetlistType.EBLIF
diff --git a/spydrnet/util/patterns.py b/spydrnet/util/patterns.py
index 0c5a582f..adeac790 100644
--- a/spydrnet/util/patterns.py
+++ b/spydrnet/util/patterns.py
@@ -24,4 +24,4 @@ def _value_matches_pattern(value, pattern, is_case, is_re):
elif is_case:
return fnmatch.fnmatchcase(value, pattern)
else:
- return fnmatch.fnmatch(value, pattern)
\ No newline at end of file
+ return fnmatch.fnmatch(value, pattern)
diff --git a/spydrnet/util/selection.py b/spydrnet/util/selection.py
index e78f93eb..c6603878 100644
--- a/spydrnet/util/selection.py
+++ b/spydrnet/util/selection.py
@@ -1,12 +1,14 @@
from enum import Enum
+
class Selection(Enum):
INSIDE = 1
OUTSIDE = 2
BOTH = 3
ALL = 4
+
INSIDE = Selection.INSIDE
OUTSIDE = Selection.OUTSIDE
BOTH = Selection.BOTH
-ALL = Selection.ALL
\ No newline at end of file
+ALL = Selection.ALL
diff --git a/spydrnet/util/tests/test_get_definitions.py b/spydrnet/util/tests/test_get_definitions.py
deleted file mode 100644
index eebf7553..00000000
--- a/spydrnet/util/tests/test_get_definitions.py
+++ /dev/null
@@ -1,169 +0,0 @@
-import unittest
-import spydrnet as sdn
-
-
-class TestGetDefinitions(unittest.TestCase):
- @classmethod
- def setUpClass(cls) -> None:
- cls.netlist = sdn.Netlist()
-
- leaf_library = cls.netlist.create_library()
- leaf_library.name = 'primitives'
-
- library = cls.netlist.create_library()
- library.name = 'work'
-
- leaf_def = leaf_library.create_definition()
- leaf_def.name = 'leaf'
- leaf_port = leaf_def.create_port()
- leaf_port.name = 'I'
- leaf_port.create_pins(1)
-
- bottom_def = library.create_definition()
- bottom_def.name = 'bottom'
- bottom_port = bottom_def.create_port()
- bottom_port.name = 'I'
- bottom_port.create_pins(1)
- leaf_inst = bottom_def.create_child()
- leaf_inst.reference = leaf_def
- bottom_cable = bottom_def.create_cable()
- bottom_cable.name = 'bottom_cable'
- bottom_wire = bottom_cable.create_wire()
- bottom_wire.connect_pin(bottom_port.pins[0])
- bottom_wire.connect_pin(leaf_inst.pins[leaf_port.pins[0]])
- cls.leaf_inst = leaf_inst
-
- bottom_floating_wire = bottom_cable.create_wire()
-
- middle_def = library.create_definition()
- middle_def.name = 'middle'
- middle_port = middle_def.create_port()
- middle_port.name = "I"
- middle_port.create_pin()
- bottom_inst = middle_def.create_child()
- bottom_inst.name = 'bottom'
- bottom_inst.reference = bottom_def
- middle_cable = middle_def.create_cable()
- middle_cable.name = "middle_cable"
- middle_wire = middle_cable.create_wire()
- middle_wire.connect_pin(middle_port.pins[0])
- middle_wire.connect_pin(bottom_inst.pins[bottom_port.pins[0]])
- cls.bottom_inst = bottom_inst
-
- middle_floating_wire = middle_cable.create_wire()
-
- top_def = library.create_definition()
- top_def.name = 'top'
- top_port = top_def.create_port()
- top_port.name = "I"
- top_port.create_pin()
- middle_inst = top_def.create_child()
- middle_inst.name = 'middle'
- middle_inst.reference = middle_def
- top_cable = top_def.create_cable()
- top_cable.name = "top_cable"
- top_wire = top_cable.create_wire()
- top_wire.connect_pin(top_port.pins[0])
- top_wire.connect_pin(middle_inst.pins[middle_port.pins[0]])
-
- top_floating_wire = top_cable.create_wire()
-
- top_instance = sdn.Instance()
- top_instance.name = 'top'
- top_instance.reference = top_def
- cls.netlist.top_instance = top_instance
-
- def test_parameter_checking(self):
- library = sdn.Library()
- definition = library.create_definition()
- definition.name = "MY_DEF"
- self.assertRaises(TypeError, sdn.get_definitions, library, "MY_DEF", patterns="MY_DEF")
- self.assertRaises(TypeError, sdn.get_definitions, library, "MY_DEF", unsupported_keyword=None)
- self.assertRaises(TypeError, sdn.get_definitions, library, "MY_DEF", selection="BOTH")
- self.assertRaises(TypeError, sdn.get_definitions, None, "MY_DEF")
- self.assertRaises(TypeError, sdn.get_definitions, [None, library], "MY_DEF")
-
- def test_collection(self):
- library = sdn.Library()
- definition = library.create_definition()
- definition.name = "MY_DEF"
- ports = list(sdn.get_definitions([library, library]))
- self.assertEqual(len(ports), 1)
-
- def test_get_definition_of_instances_outside(self):
- definition_query = list(sdn.get_definitions(self.netlist.libraries[0].definitions[0].references,
- selection="OUTSIDE"))
- self.assertTrue(len(definition_query) == 1 and definition_query[0] == self.bottom_inst.reference)
-
- def test_get_definition_of_instances_inside(self):
- definition_query = list(sdn.get_definitions(self.netlist.libraries[0].definitions[0].references,
- selection="INSIDE"))
- self.assertTrue(len(definition_query) == 1 and definition_query[0] == self.leaf_inst.reference)
-
- def test_get_definition_of_instances_recursive_down(self):
- definition_query = set(sdn.get_definitions(self.netlist.top_instance, recursive=True))
- self.assertTrue(len(definition_query) == 4)
-
- def test_get_definition_of_instances_recursive_up(self):
- definition_query = list(sdn.get_definitions(self.leaf_inst, selection="OUTSIDE", recursive=True))
- self.assertTrue(len(definition_query) == 3 and self.leaf_inst.reference not in definition_query)
-
- def test_get_definition_of_library(self):
- definition_query = list(sdn.get_definitions(self.netlist.libraries[1]))
- self.assertTrue(len(definition_query) == 3 and self.leaf_inst.reference not in definition_query)
-
- def test_get_definition_of_library_outside(self):
- definition_query = list(sdn.get_definitions(self.netlist.libraries[0], selection="OUTSIDE"))
- self.assertTrue(len(definition_query) == 1 and self.leaf_inst.reference not in definition_query)
-
- def test_get_definition_of_library_outside_recursive(self):
- definition_query = list(sdn.get_definitions(self.netlist.libraries[0], selection="OUTSIDE", recursive=True))
- self.assertTrue(len(definition_query) == 3 and self.leaf_inst.reference not in definition_query)
-
- def test_get_definition_of_library_recursive(self):
- definition_query = list(sdn.get_definitions(self.netlist.libraries[1], recursive=True))
- self.assertTrue(len(definition_query) == 4 and self.leaf_inst.reference in definition_query)
-
- def test_get_definition_of_library_recursive_absolute_pattern(self):
- definition_query = list(sdn.get_definitions(self.netlist.libraries[1], "leaf", recursive=True))
- self.assertTrue(len(definition_query) == 1 and self.leaf_inst.reference is definition_query[0])
-
- def test_get_definition_of_definition_inside(self):
- definition_query = list(sdn.get_definitions(self.netlist.libraries[1].definitions[0],
- selection="INSIDE"))
- self.assertTrue(len(definition_query) == 1 and definition_query[0] == self.netlist.libraries[0].definitions[0])
-
- def test_get_definition_of_definition_outside(self):
- definition_query = list(sdn.get_definitions(self.netlist.libraries[0].definitions[0],
- selection="OUTSIDE"))
- self.assertTrue(len(definition_query) == 1 and definition_query[0] == self.netlist.libraries[1].definitions[0])
-
- def test_get_definition_of_definition_inside_recursive(self):
- definition_query = list(sdn.get_definitions(self.netlist.top_instance.reference,
- selection="INSIDE", recursive=True))
- self.assertTrue(len(definition_query) == 3 and self.netlist.top_instance.reference not in definition_query)
-
- def test_get_definition_from_outer_pins(self):
- definition_query = list(sdn.get_definitions(self.leaf_inst.pins))
- self.assertTrue(len(definition_query) == 1 and definition_query[0] == self.leaf_inst.reference)
-
- def test_get_definition_from_inner_pins(self):
- definition_query = list(sdn.get_definitions(self.leaf_inst.reference.ports[0].pins[0]))
- self.assertTrue(len(definition_query) == 1 and definition_query[0] == self.leaf_inst.reference)
-
- def test_get_definition_from_wire(self):
- definition_query = list(sdn.get_definitions(self.netlist.top_instance.reference.cables[0].wires[0]))
- self.assertTrue(len(definition_query) == 1 and definition_query[0] == self.netlist.top_instance.reference)
-
- def test_get_definition_from_href(self):
- href = next(sdn.get_hinstances(self.netlist.top_instance))
- definition_query = list(sdn.get_definitions(href))
- self.assertTrue(len(definition_query) == 1 and definition_query[0] == self.netlist.top_instance.reference)
-
- def test_unique_query_return(self):
- definition_query = list(sdn.get_definitions([self.netlist.libraries[0], self.leaf_inst], "leaf"))
- self.assertTrue(len(definition_query) == 1 and definition_query[0] == self.leaf_inst.reference)
-
- def test_absolute_pattern_from_relative_query(self):
- definition_query = list(sdn.get_definitions(self.leaf_inst, "leaf"))
- self.assertTrue(len(definition_query) == 1 and definition_query[0] == self.leaf_inst.reference)
diff --git a/spydrnet/util/tests/test_get_libraries.py b/spydrnet/util/tests/test_get_libraries.py
deleted file mode 100644
index 3d2ccfa6..00000000
--- a/spydrnet/util/tests/test_get_libraries.py
+++ /dev/null
@@ -1,161 +0,0 @@
-import unittest
-import spydrnet as sdn
-
-
-class TestGetLibraries(unittest.TestCase):
- @classmethod
- def setUpClass(cls) -> None:
- cls.netlist = sdn.Netlist()
-
- leaf_library = cls.netlist.create_library()
- leaf_library.name = 'primitives'
-
- library = cls.netlist.create_library()
- library.name = 'work'
-
- leaf_def = leaf_library.create_definition()
- leaf_def.name = 'leaf'
- leaf_port = leaf_def.create_port()
- leaf_port.name = 'I'
- leaf_port.create_pins(1)
-
- bottom_def = library.create_definition()
- bottom_def.name = 'bottom'
- bottom_port = bottom_def.create_port()
- bottom_port.name = 'I'
- bottom_port.create_pins(1)
- leaf_inst = bottom_def.create_child()
- leaf_inst.reference = leaf_def
- bottom_cable = bottom_def.create_cable()
- bottom_cable.name = 'bottom_cable'
- bottom_wire = bottom_cable.create_wire()
- bottom_wire.connect_pin(bottom_port.pins[0])
- bottom_wire.connect_pin(leaf_inst.pins[leaf_port.pins[0]])
- cls.leaf_inst = leaf_inst
-
- bottom_floating_wire = bottom_cable.create_wire()
-
- middle_def = library.create_definition()
- middle_def.name = 'middle'
- middle_port = middle_def.create_port()
- middle_port.name = "I"
- middle_port.create_pin()
- bottom_inst = middle_def.create_child()
- bottom_inst.name = 'bottom'
- bottom_inst.reference = bottom_def
- middle_cable = middle_def.create_cable()
- middle_cable.name = "middle_cable"
- middle_wire = middle_cable.create_wire()
- middle_wire.connect_pin(middle_port.pins[0])
- middle_wire.connect_pin(bottom_inst.pins[bottom_port.pins[0]])
-
- middle_floating_wire = middle_cable.create_wire()
-
- top_def = library.create_definition()
- top_def.name = 'top'
- top_port = top_def.create_port()
- top_port.name = "I"
- top_port.create_pin()
- middle_inst = top_def.create_child()
- middle_inst.name = 'middle'
- middle_inst.reference = middle_def
- top_cable = top_def.create_cable()
- top_cable.name = "top_cable"
- top_wire = top_cable.create_wire()
- top_wire.connect_pin(top_port.pins[0])
- top_wire.connect_pin(middle_inst.pins[middle_port.pins[0]])
-
- top_floating_wire = top_cable.create_wire()
-
- top_instance = sdn.Instance()
- top_instance.name = 'top'
- top_instance.reference = top_def
- cls.netlist.top_instance = top_instance
-
- def test_parameter_checking(self):
- netlist = sdn.Netlist()
- library = netlist.create_library()
- library.name = "MY_LIB"
- self.assertRaises(TypeError, sdn.get_libraries, netlist, "MY_LIB", patterns="MY_LIB")
- self.assertRaises(TypeError, sdn.get_libraries, netlist, "MY_LIB", unsupported_keyword=None)
- self.assertRaises(TypeError, sdn.get_libraries, netlist, "MY_LIB", selection="BOTH")
- self.assertRaises(TypeError, sdn.get_libraries, None, "MY_LIB")
- self.assertRaises(TypeError, sdn.get_libraries, [None, netlist], "MY_LIB")
-
- def test_collection(self):
- netlist = sdn.Netlist()
- library = netlist.create_library()
- library.name = "MY_LIB"
- ports = list(sdn.get_libraries([netlist, netlist]))
- self.assertEqual(len(ports), 1)
-
- def test_get_library_of_instances_outside(self):
- library_query = list(sdn.get_libraries(self.netlist.libraries[0].definitions[0].references,
- selection="OUTSIDE"))
- self.assertTrue(len(library_query) == 1 and library_query[0] == self.netlist.libraries[1])
-
- def test_get_library_of_instances_inside(self):
- library_query = list(sdn.get_libraries(self.netlist.libraries[0].definitions[0].references,
- selection="INSIDE"))
- self.assertTrue(len(library_query) == 1 and library_query[0] == self.netlist.libraries[0])
-
- def test_get_library_of_instances_recursive_down(self):
- library_query = list(sdn.get_libraries(self.netlist.top_instance, recursive=True))
- self.assertTrue(len(library_query) == 2 and all(x in library_query for x in self.netlist.libraries))
-
- def test_get_library_of_instances_recursive_up(self):
- library_query = list(sdn.get_libraries(self.leaf_inst, selection="OUTSIDE", recursive=True))
- self.assertTrue(len(library_query) == 1 and library_query[0] is self.netlist.libraries[1])
-
- def test_get_library_of_library_recursive_down(self):
- library_query = list(sdn.get_libraries(self.netlist.libraries[1], selection="INSIDE", recursive=True))
- self.assertTrue(len(library_query) == 2 and all(x in library_query for x in self.netlist.libraries))
-
- def test_get_library_of_library_recursive_up(self):
- library_query = list(sdn.get_libraries(self.netlist.libraries[0], selection="OUTSIDE", recursive=True))
- self.assertTrue(len(library_query) == 1 and library_query[0] is self.netlist.libraries[1])
-
- def test_get_library_of_inside_inside(self):
- library_query = list(sdn.get_libraries(self.netlist.libraries[0].definitions[0],
- selection="INSIDE"))
- self.assertTrue(len(library_query) == 1 and library_query[0] == self.netlist.libraries[0])
-
- def test_get_library_of_inside_outside(self):
- library_query = list(sdn.get_libraries(self.netlist.libraries[0].definitions[0],
- selection="OUTSIDE"))
- self.assertTrue(len(library_query) == 1 and library_query[0] == self.netlist.libraries[1])
-
- def test_get_library_of_inside_outside_recursive(self):
- library_query = list(sdn.get_libraries(self.netlist.libraries[0].definitions[0],
- selection="OUTSIDE", recursive=True))
- self.assertTrue(len(library_query) == 1 and library_query[0] == self.netlist.libraries[1])
-
- def test_get_library_of_inside_inside_recursive(self):
- library_query = list(sdn.get_libraries(self.netlist.top_instance.reference,
- selection="INSIDE", recursive=True))
- self.assertTrue(len(library_query) == 2 and all(x in library_query for x in self.netlist.libraries))
-
- def test_get_library_from_outer_pins(self):
- library_query = list(sdn.get_libraries(self.leaf_inst.pins))
- self.assertTrue(len(library_query) == 1 and library_query[0] == self.netlist.libraries[0])
-
- def test_get_library_from_inner_pins(self):
- library_query = list(sdn.get_libraries(self.leaf_inst.reference.ports[0].pins[0]))
- self.assertTrue(len(library_query) == 1 and library_query[0] == self.netlist.libraries[0])
-
- def test_get_library_from_wire(self):
- library_query = list(sdn.get_libraries(self.netlist.top_instance.reference.cables[0].wires[0]))
- self.assertTrue(len(library_query) == 1 and library_query[0] == self.netlist.libraries[1])
-
- def test_get_library_from_href(self):
- href = next(sdn.get_hinstances(self.netlist.top_instance))
- library_query = list(sdn.get_libraries(href))
- self.assertTrue(len(library_query) == 1 and library_query[0] == self.netlist.libraries[1])
-
- def test_unique_query_return(self):
- library_query = list(sdn.get_libraries([self.netlist, self.netlist.top_instance], "work"))
- self.assertTrue(len(library_query) == 1 and library_query[0] == self.netlist.libraries[1])
-
- def test_absolute_pattern_from_relative_query(self):
- library_query = list(sdn.get_libraries(self.netlist.top_instance, "work"))
- self.assertTrue(len(library_query) == 1 and library_query[0] == self.netlist.libraries[1])
diff --git a/spydrnet/compare/tests/__init__.py b/tests/__init__.py
similarity index 100%
rename from spydrnet/compare/tests/__init__.py
rename to tests/__init__.py
diff --git a/spydrnet/composers/eblif/tests/__init__.py b/tests/spydrnet/__init__.py
similarity index 100%
rename from spydrnet/composers/eblif/tests/__init__.py
rename to tests/spydrnet/__init__.py
diff --git a/spydrnet/composers/edif/tests/__init__.py b/tests/spydrnet/compare/__init__.py
similarity index 100%
rename from spydrnet/composers/edif/tests/__init__.py
rename to tests/spydrnet/compare/__init__.py
diff --git a/spydrnet/composers/verilog/tests/__init__.py b/tests/spydrnet/compare/tests/__init__.py
similarity index 100%
rename from spydrnet/composers/verilog/tests/__init__.py
rename to tests/spydrnet/compare/tests/__init__.py
diff --git a/spydrnet/compare/tests/test_compare_netlists.py b/tests/spydrnet/compare/tests/test_compare_netlists.py
similarity index 60%
rename from spydrnet/compare/tests/test_compare_netlists.py
rename to tests/spydrnet/compare/tests/test_compare_netlists.py
index 35cd090e..7eb865c7 100644
--- a/spydrnet/compare/tests/test_compare_netlists.py
+++ b/tests/spydrnet/compare/tests/test_compare_netlists.py
@@ -1,8 +1,7 @@
import unittest
-import os
import tempfile
-import glob
import shutil
+from pathlib import Path
from spydrnet.compare.compare_netlists import Comparer
import spydrnet as sdn
@@ -11,52 +10,59 @@
class TestCompareNetlists(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
- cls.dir_of_edif_netlists = os.path.join(sdn.base_dir, "support_files", "EDIF_netlists")
- cls.dir_of_verilog_netlists = os.path.join(sdn.base_dir, "support_files", "verilog_netlists")
- cls.edif_files = sorted(glob.glob(os.path.join(cls.dir_of_edif_netlists, "*.edf.zip")), key=os.path.getsize)
- cls.verilog_files = sorted(glob.glob(os.path.join(cls.dir_of_verilog_netlists, "*.v.zip")), key = os.path.getsize)
+ cls.dir_of_edif_netlists = Path(sdn.example_netlists_path, "EDIF_netlists")
+ cls.dir_of_verilog_netlists = Path(
+ sdn.example_netlists_path, "verilog_netlists"
+ )
+ cls.edif_files = sorted(Path.glob(cls.dir_of_edif_netlists, "*.edf.zip"))
+ cls.verilog_files = sorted(Path.glob(cls.dir_of_verilog_netlists, "*.v.zip"))
@unittest.skip("Test takes a long time right now.")
def test_large_edif(self):
for ii, filename in enumerate(self.edif_files):
- if os.path.getsize(filename) <= 1024 * 10:
+ if Path(filename).stat().st_size <= 1024 * 10:
continue
self.compare_parser_and_composer(filename, ii, "edf")
def test_small_edif(self):
for ii, filename in enumerate(self.edif_files):
- if os.path.getsize(filename) > 1024 * 10:
+ if Path(filename).stat().st_size > 1024 * 10:
continue
self.compare_parser_and_composer(filename, ii, "edf")
@unittest.skip("Test takes a long time right now.")
def test_large_verilog(self):
for ii, filename in enumerate(self.verilog_files):
- if os.path.getsize(filename) <= 1024 * 10:
+ if Path(filename).stat().st_size <= 1024 * 10:
continue
self.compare_parser_and_composer(filename, ii, "v")
- #assert False
+ # assert False
def test_small_verilog(self):
for ii, filename in enumerate(self.verilog_files):
- if os.path.getsize(filename) > 1024 * 10:
+ if Path(filename).stat().st_size > 1024 * 10:
continue
self.compare_parser_and_composer(filename, ii, "v")
- #assert False
+ # assert False
- def compare_parser_and_composer(self,filename, ii, target_format_extension = None):
+ def compare_parser_and_composer(self, filename, ii, target_format_extension=None):
with self.subTest(i=ii):
- if os.path.exists("temp"):
+ if Path("temp").exists():
shutil.rmtree("temp")
print(filename)
with tempfile.TemporaryDirectory() as tempdirname:
try:
orig_netlist = sdn.parse(filename)
- basename_without_final_ext = os.path.splitext(os.path.basename(filename))[0]
+ basename_without_final_ext = Path(Path(filename).name).stem
if target_format_extension is None:
- composer_filename = os.path.join(tempdirname, basename_without_final_ext)
+ composer_filename = Path(
+ tempdirname, basename_without_final_ext
+ )
else:
- composer_filename = os.path.join(tempdirname, basename_without_final_ext + "." + target_format_extension)
+ composer_filename = Path(
+ tempdirname,
+ basename_without_final_ext + "." + target_format_extension,
+ )
orig_netlist.compose(composer_filename)
print(composer_filename)
composer_netlist = sdn.parse(composer_filename)
@@ -69,19 +75,21 @@ def compare_parser_and_composer(self,filename, ii, target_format_extension = Non
@unittest.skip("Test takes a long time right now.")
def test_large_verilog_to_edif(self):
for ii, filename in enumerate(self.verilog_files):
- if os.path.getsize(filename) <= 1024 * 10:
+ if Path(filename).stat().st_size <= 1024 * 10:
continue
self.compare_parser_and_composer(filename, ii, "edf")
- #assert False
+ # assert False
- @unittest.skip("currently not working properly for the number of cables on some examples please use with caution")
+ @unittest.skip(
+ "currently not working properly for the number of cables on some examples please use with caution"
+ )
def test_small_verilog_to_edif(self):
for ii, filename in enumerate(self.verilog_files):
- if os.path.getsize(filename) > 1024 * 10:
+ if Path(filename).stat().st_size > 1024 * 10:
continue
self.compare_parser_and_composer(filename, ii, "edf")
- #assert False
-
+ # assert False
+
def test_empty_netlists(self):
nl1 = sdn.ir.Netlist()
nl2 = sdn.ir.Netlist()
@@ -89,5 +97,5 @@ def test_empty_netlists(self):
comp.compare()
-if __name__ == '__main__':
+if __name__ == "__main__":
unittest.main()
diff --git a/spydrnet/compare/tests/test_composers.py b/tests/spydrnet/compare/tests/test_composers.py
similarity index 99%
rename from spydrnet/compare/tests/test_composers.py
rename to tests/spydrnet/compare/tests/test_composers.py
index 764af741..9328a309 100644
--- a/spydrnet/compare/tests/test_composers.py
+++ b/tests/spydrnet/compare/tests/test_composers.py
@@ -1,6 +1,7 @@
import unittest
import spydrnet as sdn
+
class TestComposers(unittest.TestCase):
def test_compose(self):
netlist = sdn.Netlist()
diff --git a/spydrnet/global_state/tests/__init__.py b/tests/spydrnet/composers/__init__.py
similarity index 100%
rename from spydrnet/global_state/tests/__init__.py
rename to tests/spydrnet/composers/__init__.py
diff --git a/spydrnet/ir/views/tests/__init__.py b/tests/spydrnet/composers/eblif/__init__.py
similarity index 100%
rename from spydrnet/ir/views/tests/__init__.py
rename to tests/spydrnet/composers/eblif/__init__.py
diff --git a/spydrnet/parsers/eblif/tests/__init__.py b/tests/spydrnet/composers/eblif/tests/__init__.py
similarity index 100%
rename from spydrnet/parsers/eblif/tests/__init__.py
rename to tests/spydrnet/composers/eblif/tests/__init__.py
diff --git a/tests/spydrnet/composers/eblif/tests/test_eblif_composer.py b/tests/spydrnet/composers/eblif/tests/test_eblif_composer.py
new file mode 100644
index 00000000..8374f8ed
--- /dev/null
+++ b/tests/spydrnet/composers/eblif/tests/test_eblif_composer.py
@@ -0,0 +1,75 @@
+import unittest
+import os
+import spydrnet as sdn
+from spydrnet import example_netlists_path
+from pathlib import Path
+
+"""
+Test the EBLIF composer. The best way I can think to do this is to parse a netlist, compose it, then parse it again to see if anything changed. It should all be the same
+"""
+
+
+class TestEBLIFComposer(unittest.TestCase):
+ def setUp(self):
+ self.netlist_1 = sdn.parse(
+ Path(example_netlists_path, "eblif_netlists", "toggle.eblif.zip")
+ )
+ self.definition_list = [
+ "INV",
+ "BUFG",
+ "FDRE",
+ "IBUF",
+ "OBUF",
+ "toggle",
+ "logic-gate_0",
+ ]
+ sdn.compose(self.netlist_1, "temp_for_composer_test.eblif")
+ sdn.compose(
+ self.netlist_1,
+ "temp_for_composer_test_no_blackbox.eblif",
+ write_blackbox=False,
+ )
+ self.netlist_2 = sdn.parse("temp_for_composer_test.eblif")
+ self.netlist_3 = sdn.parse("temp_for_composer_test_no_blackbox.eblif")
+ os.remove("temp_for_composer_test.eblif")
+ os.remove("temp_for_composer_test_no_blackbox.eblif")
+
+ def test_netlist_name(self):
+ self.assertEqual(self.netlist_1.name, self.netlist_2.name)
+
+ def test_top_instance(self):
+ self.assertEqual(
+ self.netlist_1.top_instance.name, self.netlist_2.top_instance.name
+ )
+
+ def test_instances(self):
+ instances_1 = list(instance.name for instance in self.netlist_1.get_instances())
+ instances_2 = list(instance.name for instance in self.netlist_2.get_instances())
+ instances_1.sort()
+ instances_2.sort()
+ self.assertEqual(instances_1, instances_2)
+ self.assertEqual(len(instances_1), len(instances_2))
+
+ def test_definitions(self):
+ definitions_1 = list(
+ definition.name for definition in self.netlist_1.get_definitions()
+ )
+ definitions_2 = list(
+ definition.name for definition in self.netlist_2.get_definitions()
+ )
+ definitions_1.sort()
+ definitions_2.sort()
+ self.assertEqual(definitions_1, definitions_2)
+ self.assertEqual(len(definitions_1), len(definitions_2))
+
+ def test_cables(self):
+ cables_1 = list(cable.name for cable in self.netlist_1.get_cables())
+ cables_2 = list(cable.name for cable in self.netlist_2.get_cables())
+ cables_1.sort()
+ cables_2.sort()
+ self.assertEqual(cables_1, cables_2)
+ self.assertEqual(len(cables_1), len(cables_2))
+
+ # TODO add wires and connections tests
+
+ # test the composing of each individual part
diff --git a/spydrnet/parsers/edif/tests/__init__.py b/tests/spydrnet/composers/edif/__init__.py
similarity index 100%
rename from spydrnet/parsers/edif/tests/__init__.py
rename to tests/spydrnet/composers/edif/__init__.py
diff --git a/spydrnet/parsers/tests/__init__.py b/tests/spydrnet/composers/edif/tests/__init__.py
similarity index 100%
rename from spydrnet/parsers/tests/__init__.py
rename to tests/spydrnet/composers/edif/tests/__init__.py
diff --git a/spydrnet/composers/edif/tests/test_edifify_names.py b/tests/spydrnet/composers/edif/tests/test_edifify_names.py
similarity index 72%
rename from spydrnet/composers/edif/tests/test_edifify_names.py
rename to tests/spydrnet/composers/edif/tests/test_edifify_names.py
index 1368e15b..4be21d2e 100644
--- a/spydrnet/composers/edif/tests/test_edifify_names.py
+++ b/tests/spydrnet/composers/edif/tests/test_edifify_names.py
@@ -4,10 +4,9 @@
class TestEdififyNames(unittest.TestCase):
-
def test_simple_conversion(self):
ed = EdififyNames()
- l = list()
+ l = []
i = sdn.Instance()
i.name = "name"
l = [i]
@@ -15,44 +14,43 @@ def test_simple_conversion(self):
def test_invalid_name(self):
ed = EdififyNames()
- l = list()
+ l = []
i = sdn.Instance()
i.name = "*this_is+an$*`id[0:3]"
l = [i]
- assert ed.make_valid(
- i, l) == "&_this_is_an___id_0_3_"
+ assert ed.make_valid(i, l) == "&_this_is_an___id_0_3_"
def test_duplicate_name(self):
ed = EdififyNames()
- l = list()
+ l = []
i = sdn.Instance()
- i.name = 'name'
+ i.name = "name"
i2 = sdn.Instance()
- i2.name = 'name'
+ i2.name = "name"
l = [i, i2]
assert ed.make_valid(i2, l) == "name_sdn_1_"
def test_duplicate_number_increment(self):
ed = EdififyNames()
- l = list()
+ l = []
i = sdn.Instance()
- i.name = 'name'
+ i.name = "name"
i_duplicate = sdn.Instance()
- i_duplicate.name = 'name'
+ i_duplicate.name = "name"
i2 = sdn.Instance()
- i2.name = 'name_sdn_1_'
+ i2.name = "name_sdn_1_"
l = [i, i2, i_duplicate]
assert ed.make_valid(i_duplicate, l) == "name_sdn_2_"
def test_length(self):
ed = EdififyNames()
- l = list()
+ l = []
test_str = ""
answer_str = ""
for _ in range(ed.name_length_target + 5):
- test_str = test_str + 'a'
+ test_str = test_str + "a"
for _ in range(ed.name_length_target):
- answer_str = answer_str + 'a'
+ answer_str = answer_str + "a"
i = sdn.Instance()
i.name = test_str
l = [i]
@@ -60,13 +58,13 @@ def test_length(self):
def test_length_2(self):
ed = EdififyNames()
- l = list()
+ l = []
test_str = "$"
answer_str = "&_"
for _ in range(ed.name_length_target + 5):
- test_str = test_str + 'a'
+ test_str = test_str + "a"
for _ in range(ed.name_length_target - 2):
- answer_str = answer_str + 'a'
+ answer_str = answer_str + "a"
i = sdn.Instance()
i.name = test_str
l = [i]
@@ -74,30 +72,30 @@ def test_length_2(self):
def test_length_3(self):
ed = EdififyNames()
- l = list()
+ l = []
instance_1 = sdn.Instance()
- name_1 = '&_'
+ name_1 = "&_"
for _ in range(ed.name_length_target - 2):
- name_1 = name_1 + 'a'
+ name_1 = name_1 + "a"
instance_1.name = name_1
instance_2 = sdn.Instance()
- name_2 = '&_'
+ name_2 = "&_"
for _ in range(ed.name_length_target - 9):
- name_2 = name_2 + 'a'
- name_2 = name_2 + '_sdn_1_'
+ name_2 = name_2 + "a"
+ name_2 = name_2 + "_sdn_1_"
instance_2.name = name_2
- test_str = '$'
- answer_str = '&_'
+ test_str = "$"
+ answer_str = "&_"
for _ in range(ed.name_length_target + 5):
- test_str = test_str + 'a'
+ test_str = test_str + "a"
for _ in range(ed.name_length_target - 9):
- answer_str = answer_str + 'a'
+ answer_str = answer_str + "a"
- answer_str = answer_str + '_sdn_2_'
+ answer_str = answer_str + "_sdn_2_"
instance_3 = sdn.Instance()
instance_3.name = test_str
diff --git a/spydrnet/composers/edif/tests/test_topological_sort.py b/tests/spydrnet/composers/edif/tests/test_topological_sort.py
similarity index 96%
rename from spydrnet/composers/edif/tests/test_topological_sort.py
rename to tests/spydrnet/composers/edif/tests/test_topological_sort.py
index 70eefa32..9c85d8ee 100644
--- a/spydrnet/composers/edif/tests/test_topological_sort.py
+++ b/tests/spydrnet/composers/edif/tests/test_topological_sort.py
@@ -4,9 +4,9 @@
class TestTopologicalSort(unittest.TestCase):
-
def test_top_sort(self):
ce = ComposeEdif()
+
def library_dependence(library):
depend_set = set()
for definition in library.definitions:
@@ -33,7 +33,7 @@ def library_dependence(library):
lib_b.name = "lib_b"
definition_b = lib_b.create_definition()
definition_b.name = "def_b"
-
+
instance_b = definition_b.create_child()
instance_b.name = "relies_on_lib_a"
instance_b.reference = definition_a
@@ -58,7 +58,7 @@ def library_dependence(library):
print("dependencies")
for lib in libraries:
- print(lib.name, end = "")
+ print(lib.name, end="")
print(" relies on")
for l in library_dependence(lib):
print("\t" + l.name)
@@ -73,4 +73,4 @@ def library_dependence(library):
for l in libraries:
found_libraries.add(l)
for l_dep in library_dependence(l):
- assert l_dep in found_libraries
\ No newline at end of file
+ assert l_dep in found_libraries
diff --git a/spydrnet/parsers/verilog/tests/__init__.py b/tests/spydrnet/composers/verilog/__init__.py
similarity index 100%
rename from spydrnet/parsers/verilog/tests/__init__.py
rename to tests/spydrnet/composers/verilog/__init__.py
diff --git a/spydrnet/plugins/namespace_manager/tests/__init__.py b/tests/spydrnet/composers/verilog/tests/__init__.py
similarity index 100%
rename from spydrnet/plugins/namespace_manager/tests/__init__.py
rename to tests/spydrnet/composers/verilog/tests/__init__.py
diff --git a/tests/spydrnet/composers/verilog/tests/test_composer.py b/tests/spydrnet/composers/verilog/tests/test_composer.py
new file mode 100644
index 00000000..488ee003
--- /dev/null
+++ b/tests/spydrnet/composers/verilog/tests/test_composer.py
@@ -0,0 +1,135 @@
+import unittest
+import spydrnet as sdn
+from spydrnet import composers
+from spydrnet import parsers
+import tempfile
+from pathlib import Path
+import zipfile
+
+
+class TestVerilogComposer(unittest.TestCase):
+ @classmethod
+ def setUpClass(cls) -> None:
+ cls.dir_of_verilog_netlists = Path(
+ sdn.example_netlists_path, "verilog_netlists"
+ )
+ cls.verilog_files = sorted(Path.glob(cls.dir_of_verilog_netlists, "*.v.zip"))
+
+ @unittest.skip("Test takes a long time right now.")
+ def test_large_verilog_compose(self):
+ i = 0
+ errors = 0
+ for ii, filepath in enumerate(self.verilog_files):
+ with self.subTest(i=ii):
+ if Path(filepath).stat().st_size <= 1024 * 10:
+ continue
+ if zipfile.is_zipfile(filepath):
+ with tempfile.TemporaryDirectory() as tempdirectory:
+ # try:
+ print(
+ "*********************"
+ + filepath.name
+ + "*********************"
+ )
+ # vp = sdn.parsers.verilog.parser.VerilogParser.from_filename(os.path.join(directory, filename))
+ # netlist = vp.parse()
+ netlist = parsers.parse(filepath)
+ composers.compose(
+ netlist,
+ Path(tempdirectory).joinpath(filepath.name + "-spydrnet.v"),
+ )
+ # comp.run(netlist,"temp2/"+filename[:len(filename)-6] + "-spydrnet.v")
+ # comp.run(netlist,os.path.join(tempdirectory, filename[:len(filename)-6] + "-spydrnet.v"))
+ i += 1
+ print("pass")
+ # except Exception as identifier:
+ # print("FAIL")
+ # print(identifier)
+ # errors += 1
+ else:
+ continue
+
+ print("processed", i, "errors", errors)
+
+ assert (
+ errors == 0
+ ), "there were errors while parsing and composing files. Please see the output."
+
+ def test_small_verilog_compose(self):
+ i = 0
+ errors = 0
+ for ii, filepath in enumerate(self.verilog_files):
+ with self.subTest(i=ii):
+ if filepath.stat().st_size > 1024 * 10:
+ continue
+ # if filename.endswith(".zip"):
+ if zipfile.is_zipfile(filepath):
+ with tempfile.TemporaryDirectory() as tempdirectory:
+ # try:
+ print(
+ "*********************"
+ + filepath.name
+ + "*********************"
+ )
+ # vp = sdn.parsers.verilog.parser.VerilogParser.from_filename(os.path.join(directory, filename))
+ # netlist = vp.parse()
+ netlist = parsers.parse(filepath)
+ composers.compose(
+ netlist,
+ Path(tempdirectory).joinpath(filepath.name + "-spydrnet.v"),
+ )
+ # comp.run(netlist,"temp2/"+filename[:len(filename)-6] + "-spydrnet.v")
+ # comp.run(netlist,os.path.join(tempdirectory, filename[:len(filename)-6] + "-spydrnet.v"))
+ i += 1
+ print("pass")
+ # except Exception as identifier:
+ # print("FAIL")
+ # print(identifier)
+ # errors += 1
+ else:
+ continue
+
+ print("processed", i, "errors", errors)
+
+ assert (
+ errors == 0
+ ), "there were errors while parsing and composing files. Please see the output."
+
+ def test_definition_list_option(self):
+ for filename in Path.glob(self.dir_of_verilog_netlists, "*4bitadder.v.zip"):
+ with tempfile.TemporaryDirectory() as tempdirectory:
+ netlist = parsers.parse(filename)
+ out_file = Path(tempdirectory, Path(filename).name + "-spydrnet.v")
+ composers.compose(netlist, out_file, definition_list=["adder"])
+
+ with open(out_file, "r") as fp:
+ lines = fp.readlines()
+ print(len(lines))
+ m = list(filter(lambda x: x.startswith("module"), lines))
+ self.assertGreater(len(m), 0, "Adder module not written")
+ self.assertLess(len(m), 2, "Failed to write only definition_list")
+ return
+ raise AssertionError(
+ "Adder design not found " + "definition_list options not tested,"
+ )
+
+ def test_write_blackbox_option(self):
+ for filename in Path.glob(self.dir_of_verilog_netlists, "*4bitadder.v.zip"):
+ print(filename)
+ with tempfile.TemporaryDirectory() as tempdirectory:
+ netlist = parsers.parse(filename)
+ out_file = Path(tempdirectory, Path(filename).name + "-spydrnet.v")
+ composers.compose(netlist, out_file, write_blackbox=False)
+
+ with open(out_file, "r") as fp:
+ lines = fp.readlines()
+ print(len(lines))
+ m = list(filter(lambda x: x.startswith("module"), lines))
+ self.assertGreater(len(m), 0, "Adder module not written")
+ self.assertLess(
+ len(m), 2, "Failed to write only definition_list" + "%s" % m
+ )
+ return
+ raise AssertionError(
+ "definition_list options not test," + "Adder design not found"
+ )
diff --git a/spydrnet/composers/verilog/tests/test_composer_unit.py b/tests/spydrnet/composers/verilog/tests/test_composer_unit.py
similarity index 78%
rename from spydrnet/composers/verilog/tests/test_composer_unit.py
rename to tests/spydrnet/composers/verilog/tests/test_composer_unit.py
index 2c808207..204a92fd 100644
--- a/spydrnet/composers/verilog/tests/test_composer_unit.py
+++ b/tests/spydrnet/composers/verilog/tests/test_composer_unit.py
@@ -1,8 +1,8 @@
-#Copyright 2021
-#Author Dallin Skouson
-#see the license for details
+# Copyright 2021
+# Author Dallin Skouson
+# see the license for details
#
-#Tests the verilog composers functions and output
+# Tests the verilog composers functions and output
from collections import OrderedDict
import unittest
@@ -11,12 +11,13 @@
from spydrnet.composers.verilog.composer import Composer
from collections import OrderedDict
-class TestVerilogComposerUnit(unittest.TestCase):
+class TestVerilogComposerUnit(unittest.TestCase):
class TestFile:
- '''represents a file (has a write function for the composer)
+ """represents a file (has a write function for the composer)
can be used as a drop in replacement for the composer file.write function
- saves all written stuff to a string'''
+ saves all written stuff to a string"""
+
def __init__(self):
self.written = ""
@@ -26,7 +27,7 @@ def write(self, text):
def clear(self):
self.written = ""
- def compare(self, text, should_match = True):
+ def compare(self, text, should_match=True):
self.written = self.written.lstrip()
if (text == self.written) == should_match:
return True
@@ -42,7 +43,6 @@ def compare(self, text, should_match = True):
print("\n")
return False
-
def initialize_tests(self):
composer = Composer()
composer.file = self.TestFile()
@@ -90,7 +90,6 @@ def initialize_instance_port_connections(self, instance, definition):
single_bit_cable.is_downto = True
single_bit_cable.create_wire()
-
multi_bit_port = ref_def.create_port()
multi_bit_port.is_downto = True
multi_bit_port.create_pins(4)
@@ -112,7 +111,6 @@ def initialize_instance_port_connections(self, instance, definition):
multi_bit_cable.name = "multi_bit_cable"
multi_bit_cable.is_downto = True
-
concatenated_port = ref_def.create_port()
concatenated_port.create_pins(4)
concatenated_port.name = "concatenated_port"
@@ -125,44 +123,90 @@ def initialize_instance_port_connections(self, instance, definition):
cable.name = "cc_" + str(i)
ccs.append(cable)
-
single_bit_cable.wires[0].connect_pin(instance.pins[single_bit_port.pins[0]])
for i in range(4):
multi_bit_cable.wires[i].connect_pin(instance.pins[multi_bit_port.pins[i]])
- multi_bit_cable.wires[i].connect_pin(instance.pins[multi_bit_port_offset.pins[i]])
+ multi_bit_cable.wires[i].connect_pin(
+ instance.pins[multi_bit_port_offset.pins[i]]
+ )
ccs[i].wires[0].connect_pin(instance.pins[concatenated_port.pins[i]])
for i in range(2):
multi_bit_cable.wires[i].connect_pin(instance.pins[partial_port.pins[i]])
- single_bit_expected = "." + single_bit_port.name + "(" + single_bit_cable.name + ")"
-
- multi_bit_expected = "." + multi_bit_port.name + "(" + multi_bit_cable.name + "[" + str(len(multi_bit_cable.wires) - 1 + multi_bit_cable.lower_index) + ":" + \
- str(multi_bit_cable.lower_index) + "]"")"
-
- offset_expected = "." + multi_bit_port_offset.name + "(" + multi_bit_cable.name + "[" + str(len(multi_bit_cable.wires) - 1 + multi_bit_cable.lower_index) + ":" + \
- str(multi_bit_cable.lower_index) + "]"")"
-
- partial_expected = "." + partial_port.name + "(" + multi_bit_cable.name + "[1:0])"
-
- concatenated_expected = "." + concatenated_port.name + "({" + ccs[3].name + ', ' + ccs[2].name + ', ' + ccs[1].name + ', ' + ccs[0].name + "})"
-
- return single_bit_port, single_bit_expected, \
- multi_bit_port, multi_bit_expected, \
- multi_bit_port_offset, offset_expected, \
- partial_port, partial_expected,\
- concatenated_port, concatenated_expected\
+ single_bit_expected = (
+ "." + single_bit_port.name + "(" + single_bit_cable.name + ")"
+ )
+
+ multi_bit_expected = (
+ "."
+ + multi_bit_port.name
+ + "("
+ + multi_bit_cable.name
+ + "["
+ + str(len(multi_bit_cable.wires) - 1 + multi_bit_cable.lower_index)
+ + ":"
+ + str(multi_bit_cable.lower_index)
+ + "]"
+ ")"
+ )
+
+ offset_expected = (
+ "."
+ + multi_bit_port_offset.name
+ + "("
+ + multi_bit_cable.name
+ + "["
+ + str(len(multi_bit_cable.wires) - 1 + multi_bit_cable.lower_index)
+ + ":"
+ + str(multi_bit_cable.lower_index)
+ + "]"
+ ")"
+ )
+
+ partial_expected = (
+ "." + partial_port.name + "(" + multi_bit_cable.name + "[1:0])"
+ )
+
+ concatenated_expected = (
+ "."
+ + concatenated_port.name
+ + "({"
+ + ccs[3].name
+ + ", "
+ + ccs[2].name
+ + ", "
+ + ccs[1].name
+ + ", "
+ + ccs[0].name
+ + "})"
+ )
+
+ return (
+ single_bit_port,
+ single_bit_expected,
+ multi_bit_port,
+ multi_bit_expected,
+ multi_bit_port_offset,
+ offset_expected,
+ partial_port,
+ partial_expected,
+ concatenated_port,
+ concatenated_expected,
+ )
def test_write_header(self):
composer = self.initialize_tests()
netlist = sdn.Netlist()
netlist.name = "Netlist_name"
composer._write_header(netlist)
- assert composer.file.compare("//Generated from netlist by SpyDrNet\n//netlist name: Netlist_name\n")
+ assert composer.file.compare(
+ "//Generated from netlist by SpyDrNet\n//netlist name: Netlist_name\n"
+ )
def test_write_brackets_single_bit(self):
- #def _write_brackets(self, bundle, low_index, high_index):
+ # def _write_brackets(self, bundle, low_index, high_index):
composer = self.initialize_tests()
port = sdn.Port()
@@ -202,10 +246,10 @@ def test_write_brackets_single_bit(self):
composer._write_brackets(cable, 0, 0)
assert composer.file.compare("")
composer.file.clear()
- #none of these should write because they are all single bit.
+ # none of these should write because they are all single bit.
def test_write_brackets_single_bit_offset(self):
- #def _write_brackets(self, bundle, low_index, high_index):
+ # def _write_brackets(self, bundle, low_index, high_index):
composer = self.initialize_tests()
port = sdn.Port()
@@ -248,7 +292,7 @@ def test_write_brackets_single_bit_offset(self):
composer._write_brackets(cable, 4, 4)
assert composer.file.compare("")
composer.file.clear()
- #none of these should write because they are all single bit.
+ # none of these should write because they are all single bit.
def test_write_brackets_multi_bit(self):
composer = self.initialize_tests()
@@ -262,9 +306,9 @@ def test_write_brackets_multi_bit(self):
port.name = port_name
cable.name = cable_name
- port.create_pins(4) #input [3:0] my_input;
+ port.create_pins(4) # input [3:0] my_input;
port.is_downto = True
- cable.create_wires(4) #wire [3:0] my_wire;
+ cable.create_wires(4) # wire [3:0] my_wire;
cable.is_downto = True
composer._write_brackets(port, None, None)
@@ -305,7 +349,6 @@ def test_write_brackets_multi_bit(self):
assert composer.file.compare("[2:1]")
composer.file.clear()
-
def test_write_brackets_multi_bit_offset(self):
composer = self.initialize_tests()
@@ -318,10 +361,10 @@ def test_write_brackets_multi_bit_offset(self):
port.name = port_name
cable.name = cable_name
- port.create_pins(4) #input [3:0] my_input;
+ port.create_pins(4) # input [3:0] my_input;
port.is_downto = True
port.lower_index = 4
- cable.create_wires(4) #wire [3:0] my_wire;
+ cable.create_wires(4) # wire [3:0] my_wire;
cable.is_downto = True
cable.lower_index = 4
@@ -364,16 +407,15 @@ def test_write_brackets_multi_bit_offset(self):
composer.file.clear()
def test_write_brackets_fail(self):
- pass #we should add some tests to test out of bounds on the brackets.
+ pass # we should add some tests to test out of bounds on the brackets.
def test_write_brackets_defining(self):
-
composer = self.initialize_tests()
def initialize_bundle(bundle, offset, width):
if isinstance(bundle, sdn.Port):
bundle.create_pins(width)
- else: #it's a cable
+ else: # it's a cable
bundle.create_wires(width)
bundle.is_downto = True
bundle.lower_index = offset
@@ -402,7 +444,7 @@ def initialize_bundle(bundle, offset, width):
def test_write_name(self):
composer = self.initialize_tests()
- o = sdn.Cable() #Type of this shouldn't really matter
+ o = sdn.Cable() # Type of this shouldn't really matter
valid_names = ["basic_name", "\\escaped ", "\\fads#@%!$!@#%$[0:4320] "]
for n in valid_names:
o.name = n
@@ -428,12 +470,18 @@ def test_write_instance_port(self):
instance = definition.create_child()
instance.name = "ports_test"
- single_bit_port, single_bit_expected, \
- multi_bit_port, multi_bit_expected, \
- multi_bit_port_offset, offset_expected, \
- partial_port, partial_expected, \
- concatenated_port, concatenated_expected\
- = self.initialize_instance_port_connections(instance, definition)
+ (
+ single_bit_port,
+ single_bit_expected,
+ multi_bit_port,
+ multi_bit_expected,
+ multi_bit_port_offset,
+ offset_expected,
+ partial_port,
+ partial_expected,
+ concatenated_port,
+ concatenated_expected,
+ ) = self.initialize_instance_port_connections(instance, definition)
composer._write_instance_port(instance, single_bit_port)
assert composer.file.compare(single_bit_expected)
@@ -458,11 +506,17 @@ def test_write_instance_port(self):
composer._write_instance_ports(instance)
expected = "(\n"
first = True
- expected_strs = [single_bit_expected, multi_bit_expected, offset_expected, partial_expected, concatenated_expected]
+ expected_strs = [
+ single_bit_expected,
+ multi_bit_expected,
+ offset_expected,
+ partial_expected,
+ concatenated_expected,
+ ]
for i in expected_strs:
if not first:
expected += ",\n"
- expected += " "
+ expected += " "
expected += i
first = False
expected += "\n );"
@@ -476,8 +530,8 @@ def test_write_instance_parameters(self):
ref_def = definition.library.create_definition()
instance.reference = ref_def
- expected1, expected2 =self.initialize_instance_parameters(instance)
- #instance["VERILOG.Parameters"]["no_value"] = None #always has value?
+ expected1, expected2 = self.initialize_instance_parameters(instance)
+ # instance["VERILOG.Parameters"]["no_value"] = None #always has value?
composer._write_instance_parameter("key", "value")
assert composer.file.compare(expected1)
@@ -487,7 +541,6 @@ def test_write_instance_parameters(self):
assert composer.file.compare(expected2)
composer.file.clear()
-
# composer._write_instance_parameter("no_value", None)
# expected3 = ".key()"
# assert composer.file.compare(expected2)
@@ -497,7 +550,6 @@ def test_write_instance_parameters(self):
expected = "#(\n " + expected1 + ",\n " + expected2 + "\n )\n"
assert composer.file.compare(expected)
-
def test_write_full_instance(self):
composer = self.initialize_tests()
definition = self.initialize_definition()
@@ -505,28 +557,50 @@ def test_write_full_instance(self):
instance.name = "instance_test"
expected1, expected2 = self.initialize_instance_parameters(instance)
- parameters_expected = "#(\n " + expected1 + ",\n " + expected2 + "\n )\n"
- single_bit_port, single_bit_expected, \
- multi_bit_port, multi_bit_expected, \
- multi_bit_port_offset, offset_expected, \
- partial_port, partial_expected, \
- concatenated_port, concatenated_expected\
- = self.initialize_instance_port_connections(instance, definition)
+ parameters_expected = (
+ "#(\n " + expected1 + ",\n " + expected2 + "\n )\n"
+ )
+ (
+ single_bit_port,
+ single_bit_expected,
+ multi_bit_port,
+ multi_bit_expected,
+ multi_bit_port_offset,
+ offset_expected,
+ partial_port,
+ partial_expected,
+ concatenated_port,
+ concatenated_expected,
+ ) = self.initialize_instance_port_connections(instance, definition)
port_expected = "\n (\n"
first = True
- expected_strs = [single_bit_expected, multi_bit_expected, offset_expected, partial_expected, concatenated_expected]
+ expected_strs = [
+ single_bit_expected,
+ multi_bit_expected,
+ offset_expected,
+ partial_expected,
+ concatenated_expected,
+ ]
for i in expected_strs:
if not first:
port_expected += ",\n"
- port_expected += " "
+ port_expected += " "
port_expected += i
first = False
port_expected += "\n );"
composer._write_module_body_instance(instance)
- expected = instance.reference.name + " " + parameters_expected + " " + instance.name + port_expected + "\n"
+ expected = (
+ instance.reference.name
+ + " "
+ + parameters_expected
+ + " "
+ + instance.name
+ + port_expected
+ + "\n"
+ )
assert composer.file.compare(expected)
def test_write_module_header(self):
@@ -548,7 +622,11 @@ def test_write_module_header(self):
port.direction = sdn.Port.Direction.IN
composer._write_module_header(definition)
- expected = "module " + definition.name + "\n#(\n parameter key = value,\n parameter no_default\n)(\n my_port,\n my_port2\n);\n\n"
+ expected = (
+ "module "
+ + definition.name
+ + "\n#(\n parameter key = value,\n parameter no_default\n)(\n my_port,\n my_port2\n);\n\n"
+ )
assert composer.file.compare(expected)
def test_write_module_ports_header_and_body_alias(self):
@@ -569,13 +647,16 @@ def test_write_module_ports_header_and_body_alias(self):
c2.wires[0].connect_pin(port_alias.pins[1])
composer._write_module_header_port(port_alias)
- assert composer.file.compare("." + port_alias.name + "({"+ c2.name + ", " + c1.name +"})")
+ assert composer.file.compare(
+ "." + port_alias.name + "({" + c2.name + ", " + c1.name + "})"
+ )
composer.file.clear()
composer._write_module_body_port(port_alias)
- assert composer.file.compare("input " + c1.name + ";\n " + "input " + c2.name + ";\n")
+ assert composer.file.compare(
+ "input " + c1.name + ";\n " + "input " + c2.name + ";\n"
+ )
composer.file.clear()
-
def test_write_module_ports_header_and_body_multi(self):
composer = self.initialize_tests()
definition = self.initialize_definition()
@@ -598,7 +679,6 @@ def test_write_module_ports_header_and_body_multi(self):
assert composer.file.compare("output [3:0]" + port_multi.name + ";\n")
composer.file.clear()
-
def test_write_module_ports_header_and_body_disconnect(self):
composer = self.initialize_tests()
definition = self.initialize_definition()
@@ -611,23 +691,21 @@ def test_write_module_ports_header_and_body_disconnect(self):
assert composer.file.compare(port_disconnect.name)
composer.file.clear()
composer._write_module_body_port(port_disconnect)
- assert composer.file.compare("inout " + port_disconnect.name + ';\n')
+ assert composer.file.compare("inout " + port_disconnect.name + ";\n")
composer.file.clear()
def test_write_module_body_cables(self):
composer = self.initialize_tests()
definition = self.initialize_definition()
- cable = definition.create_cable(name = "test_cable", is_downto = True)
+ cable = definition.create_cable(name="test_cable", is_downto=True)
cable.create_wires(4)
composer._write_module_body_cable(cable)
assert composer.file.compare("wire [3:0]" + cable.name + ";\n")
-
def test_assignment_single_bit(self):
pass
def test_assignment_multi_bit(self):
pass
-
diff --git a/spydrnet/plugins/tests/__init__.py b/tests/spydrnet/global_state/__init__.py
similarity index 100%
rename from spydrnet/plugins/tests/__init__.py
rename to tests/spydrnet/global_state/__init__.py
diff --git a/spydrnet/tests/__init__.py b/tests/spydrnet/global_state/tests/__init__.py
similarity index 100%
rename from spydrnet/tests/__init__.py
rename to tests/spydrnet/global_state/tests/__init__.py
diff --git a/tests/spydrnet/global_state/tests/test_global_callback.py b/tests/spydrnet/global_state/tests/test_global_callback.py
new file mode 100644
index 00000000..86e87bad
--- /dev/null
+++ b/tests/spydrnet/global_state/tests/test_global_callback.py
@@ -0,0 +1,231 @@
+import unittest
+
+import spydrnet.global_state.global_callback as gc
+from spydrnet.plugins import namespace_manager
+
+
+class TestGlobalCallback(unittest.TestCase):
+ @classmethod
+ def setUpClass(cls) -> None:
+ namespace_manager.deregister_all_listeners()
+
+ @classmethod
+ def tearDownClass(cls) -> None:
+ namespace_manager.register_all_listeners()
+
+ def setUp(self) -> None:
+ self.arg1 = 1
+ self.arg2 = 2
+ self.kwarg = 3
+ self.callcount = 0
+ self.callcount2 = 0
+
+ def mycall(self, a1, a2, ka=0):
+ self.callcount += 1
+ assert a1 is self.arg1
+ assert a2 is self.arg2
+ assert ka is self.kwarg
+
+ def mycall2(self, a1, a2, ka=0):
+ self.callcount2 += 1
+ assert a1 is self.arg1
+ assert a2 is self.arg2
+ assert ka is self.kwarg
+
+ def test_cable_add_wire(self):
+ self.call_for_each(
+ gc._container_cable_add_wire,
+ gc.register_cable_add_wire,
+ gc._call_cable_add_wire,
+ gc.deregister_cable_add_wire,
+ )
+
+ def test_cable_remove_wire(self):
+ self.call_for_each(
+ gc._container_cable_remove_wire,
+ gc.register_cable_remove_wire,
+ gc._call_cable_remove_wire,
+ gc.deregister_cable_remove_wire,
+ )
+
+ def test_definition_add_port(self):
+ self.call_for_each(
+ gc._container_definition_add_port,
+ gc.register_definition_add_port,
+ gc._call_definition_add_port,
+ gc.deregister_definition_add_port,
+ )
+
+ def test_definition_remove_port(self):
+ self.call_for_each(
+ gc._container_definition_remove_port,
+ gc.register_definition_remove_port,
+ gc._call_definition_remove_port,
+ gc.deregister_definition_remove_port,
+ )
+
+ def test_definition_add_child(self):
+ self.call_for_each(
+ gc._container_definition_add_child,
+ gc.register_definition_add_child,
+ gc._call_definition_add_child,
+ gc.deregister_definition_add_child,
+ )
+
+ def test_definition_remove_child(self):
+ self.call_for_each(
+ gc._container_definition_remove_child,
+ gc.register_definition_remove_child,
+ gc._call_definition_remove_child,
+ gc.deregister_definition_remove_child,
+ )
+
+ def test_definition_add_cable(self):
+ self.call_for_each(
+ gc._container_definition_add_cable,
+ gc.register_definition_add_cable,
+ gc._call_definition_add_cable,
+ gc.deregister_definition_add_cable,
+ )
+
+ def test_definition_remove_cable(self):
+ self.call_for_each(
+ gc._container_definition_remove_cable,
+ gc.register_definition_remove_cable,
+ gc._call_definition_remove_cable,
+ gc.deregister_definition_remove_cable,
+ )
+
+ def test_instance_reference(self):
+ self.call_for_each(
+ gc._container_instance_reference,
+ gc.register_instance_reference,
+ gc._call_instance_reference,
+ gc.deregister_instance_reference,
+ )
+
+ def test_library_add_definition(self):
+ self.call_for_each(
+ gc._container_library_add_definition,
+ gc.register_library_add_definition,
+ gc._call_library_add_definition,
+ gc.deregister_library_add_definition,
+ )
+
+ def test_library_remove_definition(self):
+ self.call_for_each(
+ gc._container_library_remove_definition,
+ gc.register_library_remove_definition,
+ gc._call_library_remove_definition,
+ gc.deregister_library_remove_definition,
+ )
+
+ def test_netlist_top_instance(self):
+ self.call_for_each(
+ gc._container_netlist_top_instance,
+ gc.register_netlist_top_instance,
+ gc._call_netlist_top_instance,
+ gc.deregister_netlist_top_instance,
+ )
+
+ def test_netlist_add_library(self):
+ self.call_for_each(
+ gc._container_netlist_add_library,
+ gc.register_netlist_add_library,
+ gc._call_netlist_add_library,
+ gc.deregister_netlist_add_library,
+ )
+
+ def test_netlist_remove_library(self):
+ self.call_for_each(
+ gc._container_netlist_remove_library,
+ gc.register_netlist_remove_library,
+ gc._call_netlist_remove_library,
+ gc.deregister_netlist_remove_library,
+ )
+
+ def test_port_add_pin(self):
+ self.call_for_each(
+ gc._container_port_add_pin,
+ gc.register_port_add_pin,
+ gc._call_port_add_pin,
+ gc.deregister_port_add_pin,
+ )
+
+ def test_port_remove_pin(self):
+ self.call_for_each(
+ gc._container_port_remove_pin,
+ gc.register_port_remove_pin,
+ gc._call_port_remove_pin,
+ gc.deregister_port_remove_pin,
+ )
+
+ def test_wire_connect_pin(self):
+ self.call_for_each(
+ gc._container_wire_connect_pin,
+ gc.register_wire_connect_pin,
+ gc._call_wire_connect_pin,
+ gc.deregister_wire_connect_pin,
+ )
+
+ def test_wire_disconnect_pin(self):
+ self.call_for_each(
+ gc._container_wire_disconnect_pin,
+ gc.register_wire_disconnect_pin,
+ gc._call_wire_disconnect_pin,
+ gc.deregister_wire_disconnect_pin,
+ )
+
+ def test_dictionary_delete(self):
+ self.call_for_each(
+ gc._container_dictionary_delete,
+ gc.register_dictionary_delete,
+ gc._call_dictionary_delete,
+ gc.deregister_dictionary_delete,
+ )
+
+ def test_dictionary_pop(self):
+ self.call_for_each(
+ gc._container_dictionary_pop,
+ gc.register_dictionary_pop,
+ gc._call_dictionary_pop,
+ gc.deregister_dictionary_pop,
+ )
+
+ def test_dictionary_add(self):
+ self.call_for_each(
+ gc._container_dictionary_set,
+ gc.register_dictionary_set,
+ gc._call_dictionary_set,
+ gc.deregister_dictionary_set,
+ )
+
+ def call_for_each(self, container, register, call, deregister):
+ """
+ general strategy:
+ check to make sure the _container is empty
+ register a function
+ check to make sure the function is registered
+ call the function with some parameters
+ check to make sure the function was called with the parameters
+ deregister the function
+ check to make sure the function was deregistered
+ call the function
+ check to make sure the funciton was not called
+ """
+ assert self.mycall not in container
+ assert self.mycall2 not in container
+ register(self.mycall)
+ assert self.mycall in container
+ register(self.mycall2)
+ assert self.mycall2 in container
+ call(self.arg1, self.arg2, ka=self.kwarg)
+ assert self.callcount == 1 and self.callcount2 == 1
+ deregister(self.mycall)
+ assert self.mycall not in container
+ call(self.arg1, self.arg2, ka=self.kwarg)
+ assert self.callcount2 == 2 and self.callcount == 1
+ deregister(self.mycall2)
+ assert self.mycall2 not in container
+ call(self.arg1, self.arg2, ka=self.kwarg)
+ assert self.callcount == 1 and self.callcount2 == 2
diff --git a/spydrnet/global_state/tests/test_global_service.py b/tests/spydrnet/global_state/tests/test_global_service.py
similarity index 84%
rename from spydrnet/global_state/tests/test_global_service.py
rename to tests/spydrnet/global_state/tests/test_global_service.py
index 4911ec0d..1e895f7f 100644
--- a/spydrnet/global_state/tests/test_global_service.py
+++ b/tests/spydrnet/global_state/tests/test_global_service.py
@@ -1,6 +1,7 @@
import unittest
import spydrnet as sdn
+
class TestGlobalServiceWithoutPlugins(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
@@ -13,6 +14,7 @@ def tearDownClass(cls) -> None:
def test_double_register_lookup(self):
from spydrnet.global_state.global_service import register_lookup
+
register_lookup("TEST", None)
self.assertRaises(ValueError, register_lookup, "TEST", None)
@@ -21,11 +23,13 @@ def test_lookup_library(self):
library_name = library.name
lib1 = next(self.netlist.get_libraries(library_name))
self.assertEqual(library, lib1)
- lib2 = next(self.netlist.get_libraries(library_name, key='EDIF.identifier'))
+ lib2 = next(self.netlist.get_libraries(library_name, key="EDIF.identifier"))
self.assertEqual(library, lib2)
lib3 = next(sdn.get_libraries(self.netlist, library_name))
self.assertEqual(library, lib3)
- lib4 = next(sdn.get_libraries(self.netlist, library_name, key='EDIF.identifier'))
+ lib4 = next(
+ sdn.get_libraries(self.netlist, library_name, key="EDIF.identifier")
+ )
self.assertEqual(library, lib4)
def test_lookup_definition(self):
@@ -34,19 +38,25 @@ def test_lookup_definition(self):
definition_name = definition.name
def1 = next(self.netlist.get_definitions(definition_name))
self.assertEqual(definition, def1)
- def2 = next(self.netlist.get_definitions(definition_name, key='EDIF.identifier'))
+ def2 = next(
+ self.netlist.get_definitions(definition_name, key="EDIF.identifier")
+ )
self.assertEqual(definition, def2)
def3 = next(sdn.get_definitions(self.netlist, definition_name))
self.assertEqual(definition, def3)
- def4 = next(sdn.get_definitions(self.netlist, definition_name, key='EDIF.identifier'))
+ def4 = next(
+ sdn.get_definitions(self.netlist, definition_name, key="EDIF.identifier")
+ )
self.assertEqual(definition, def4)
def5 = next(library.get_definitions(definition_name))
self.assertEqual(definition, def5)
- def6 = next(library.get_definitions(definition_name, key='EDIF.identifier'))
+ def6 = next(library.get_definitions(definition_name, key="EDIF.identifier"))
self.assertEqual(definition, def6)
def7 = next(sdn.get_definitions(library, definition_name))
self.assertEqual(definition, def7)
- def8 = next(sdn.get_definitions(library, definition_name, key='EDIF.identifier'))
+ def8 = next(
+ sdn.get_definitions(library, definition_name, key="EDIF.identifier")
+ )
self.assertEqual(definition, def8)
def test_lookup_port_cables_instances(self):
diff --git a/spydrnet/util/tests/__init__.py b/tests/spydrnet/ir/__init__.py
similarity index 100%
rename from spydrnet/util/tests/__init__.py
rename to tests/spydrnet/ir/__init__.py
diff --git a/spydrnet/ir/tests/__init__.py b/tests/spydrnet/ir/tests/__init__.py
similarity index 98%
rename from spydrnet/ir/tests/__init__.py
rename to tests/spydrnet/ir/tests/__init__.py
index 101786e3..a7223972 100644
--- a/spydrnet/ir/tests/__init__.py
+++ b/tests/spydrnet/ir/tests/__init__.py
@@ -1,4 +1,3 @@
from pathlib import Path
data_dir = Path(Path(Path(__file__).parent, "data")).absolute()
-
diff --git a/spydrnet/ir/tests/test_bundle.py b/tests/spydrnet/ir/tests/test_bundle.py
similarity index 73%
rename from spydrnet/ir/tests/test_bundle.py
rename to tests/spydrnet/ir/tests/test_bundle.py
index 0d4665df..6abd65a2 100644
--- a/spydrnet/ir/tests/test_bundle.py
+++ b/tests/spydrnet/ir/tests/test_bundle.py
@@ -10,10 +10,16 @@ def setUp(self) -> None:
self.bundle = Bundle()
def test_constructor(self):
- self.assertIsInstance(self.bundle, FirstClassElement, "Bundle is not an element.")
- self.assertTrue(self.bundle, "Constructor returns None type or empty collection.")
+ self.assertIsInstance(
+ self.bundle, FirstClassElement, "Bundle is not an element."
+ )
+ self.assertTrue(
+ self.bundle, "Constructor returns None type or empty collection."
+ )
bundle2 = Bundle()
- self.assertNotEqual(self.bundle, bundle2, "Unique objects are considered equal.")
+ self.assertNotEqual(
+ self.bundle, bundle2, "Unique objects are considered equal."
+ )
def test_definition(self):
self.assertIsNone(self.bundle.definition)
diff --git a/spydrnet/ir/tests/test_cable.py b/tests/spydrnet/ir/tests/test_cable.py
similarity index 96%
rename from spydrnet/ir/tests/test_cable.py
rename to tests/spydrnet/ir/tests/test_cable.py
index 3039f934..df8cbf21 100644
--- a/spydrnet/ir/tests/test_cable.py
+++ b/tests/spydrnet/ir/tests/test_cable.py
@@ -53,4 +53,4 @@ def test_scalar_false(self):
cable = sdn.Cable()
cable.create_wire()
cable.create_wire()
- self.assertTrue('is_scalar: False;' in cable.__str__())
+ self.assertTrue("is_scalar: False;" in cable.__str__())
diff --git a/spydrnet/ir/tests/test_definition.py b/tests/spydrnet/ir/tests/test_definition.py
similarity index 84%
rename from spydrnet/ir/tests/test_definition.py
rename to tests/spydrnet/ir/tests/test_definition.py
index 8fe4b007..a9df5f72 100644
--- a/spydrnet/ir/tests/test_definition.py
+++ b/tests/spydrnet/ir/tests/test_definition.py
@@ -9,10 +9,16 @@ def setUp(self):
self.definition = sdn.Definition()
def test_constructor(self):
- self.assertIsInstance(self.definition, FirstClassElement, "Definition is not an element.")
- self.assertTrue(self.definition, "Constructor returns None type or empty collection.")
+ self.assertIsInstance(
+ self.definition, FirstClassElement, "Definition is not an element."
+ )
+ self.assertTrue(
+ self.definition, "Constructor returns None type or empty collection."
+ )
definition2 = sdn.Definition()
- self.assertNotEqual(self.definition, definition2, "Unique objects are considered equal.")
+ self.assertNotEqual(
+ self.definition, definition2, "Unique objects are considered equal."
+ )
@unittest.expectedFailure
def test_assign_library(self):
@@ -49,7 +55,7 @@ def test_remove_port(self):
def test_remove_multiple_ports(self):
port = self.definition.create_port()
port_2 = self.definition.create_port()
- self.definition.remove_ports_from([port,port_2])
+ self.definition.remove_ports_from([port, port_2])
self.assertFalse(port in self.definition.ports)
self.assertFalse(port_2 in self.definition.ports)
self.assertIsNone(port.definition)
@@ -163,22 +169,31 @@ def test_remove_children_from(self):
self.assertEqual(instance_included.parent, self.definition)
def test_is_leaf(self):
- self.assertTrue(self.definition.is_leaf()), "Empty definition is not considered a leaf cell"
+ self.assertTrue(
+ self.definition.is_leaf()
+ ), "Empty definition is not considered a leaf cell"
self.definition.create_port()
- self.assertTrue(self.definition.is_leaf()), "Empty definition with a port is not considered a leaf cell"
+ self.assertTrue(
+ self.definition.is_leaf()
+ ), "Empty definition with a port is not considered a leaf cell"
self.definition.create_cable()
- self.assertFalse(self.definition.is_leaf()), "Definition with a cable is considered a leaf cell"
+ self.assertFalse(
+ self.definition.is_leaf()
+ ), "Definition with a cable is considered a leaf cell"
self.definition.remove_cables_from(self.definition.cables)
self.definition.create_child()
- self.assertFalse(self.definition.is_leaf()), "Definition with a child instance is considered a leaf cell"
+ self.assertFalse(
+ self.definition.is_leaf()
+ ), "Definition with a child instance is considered a leaf cell"
self.definition.create_cable()
- self.assertFalse(self.definition.is_leaf()), "Definition with a cable and child instance is considered a leaf" \
- " cell"
+ self.assertFalse(
+ self.definition.is_leaf()
+ ), "Definition with a cable and child instance is considered a leaf" " cell"
def test_library_name(self):
definition = sdn.Definition()
library = sdn.Library()
library.add_definition(definition)
- self.assertTrue('Library.name undefined' in definition.__str__())
- library.name = 'library'
- self.assertTrue('Library.name \'library\'' in definition.__str__())
+ self.assertTrue("Library.name undefined" in definition.__str__())
+ library.name = "library"
+ self.assertTrue("Library.name 'library'" in definition.__str__())
diff --git a/spydrnet/ir/tests/test_element.py b/tests/spydrnet/ir/tests/test_element.py
similarity index 74%
rename from spydrnet/ir/tests/test_element.py
rename to tests/spydrnet/ir/tests/test_element.py
index 0f05baae..729022d6 100644
--- a/spydrnet/ir/tests/test_element.py
+++ b/tests/spydrnet/ir/tests/test_element.py
@@ -14,15 +14,15 @@ def test_constructor(self):
self.assertNotEqual(element1, element2, "Unique objects are considered equal.")
def test_dictionary(self):
- self.assertFalse('NAME' in self.element)
- self.element['NAME'] = "TestName"
- self.assertTrue('NAME' in self.element)
+ self.assertFalse("NAME" in self.element)
+ self.element["NAME"] = "TestName"
+ self.assertTrue("NAME" in self.element)
for key in self.element:
self.assertEqual(self.element[key], "TestName")
- del self.element['NAME']
- self.assertFalse('NAME' in self.element)
- self.element['NAME'] = "DifferentName"
- name = self.element.pop('NAME')
+ del self.element["NAME"]
+ self.assertFalse("NAME" in self.element)
+ self.element["NAME"] = "DifferentName"
+ name = self.element.pop("NAME")
self.assertEqual(name, "DifferentName")
def test_name(self):
@@ -41,5 +41,5 @@ def test_del_name(self):
self.assertFalse(".NAME" in self.element)
def test_data_view(self):
- self.element['NAME'] = "TestName"
- self.assertEqual(self.element.data, {'NAME': 'TestName'})
+ self.element["NAME"] = "TestName"
+ self.assertEqual(self.element.data, {"NAME": "TestName"})
diff --git a/spydrnet/ir/tests/test_innerpin.py b/tests/spydrnet/ir/tests/test_innerpin.py
similarity index 94%
rename from spydrnet/ir/tests/test_innerpin.py
rename to tests/spydrnet/ir/tests/test_innerpin.py
index 2d5240f8..d582ae7e 100644
--- a/spydrnet/ir/tests/test_innerpin.py
+++ b/tests/spydrnet/ir/tests/test_innerpin.py
@@ -19,4 +19,4 @@ def test_port(self):
@unittest.expectedFailure
def test_port_set(self):
- self.pin.port = None
\ No newline at end of file
+ self.pin.port = None
diff --git a/spydrnet/ir/tests/test_instance.py b/tests/spydrnet/ir/tests/test_instance.py
similarity index 88%
rename from spydrnet/ir/tests/test_instance.py
rename to tests/spydrnet/ir/tests/test_instance.py
index ebf071e0..d5de7ea4 100644
--- a/spydrnet/ir/tests/test_instance.py
+++ b/tests/spydrnet/ir/tests/test_instance.py
@@ -9,9 +9,13 @@ def setUp(self) -> None:
self.instance = sdn.Instance()
def test_constructor(self):
- self.assertIsInstance(self.instance, FirstClassElement, "Instance should extend element")
+ self.assertIsInstance(
+ self.instance, FirstClassElement, "Instance should extend element"
+ )
instance2 = sdn.Instance()
- self.assertNotEqual(self.instance, instance2, "Unique objects are considered equal")
+ self.assertNotEqual(
+ self.instance, instance2, "Unique objects are considered equal"
+ )
def test_reference_assignment(self):
definition = sdn.Definition()
@@ -148,7 +152,7 @@ def test_reference_removal(self):
self.assertIsNone(outer_pin2.inner_pin)
def test_is_top_instance(self):
- netlist = sdn.load_example_netlist_by_name('toggle')
+ netlist = sdn.load_example_netlist_by_name("toggle")
self.assertTrue(netlist.top_instance.is_top_instance)
original_top_instance = netlist.top_instance
random_instance = next(netlist.get_instances())
@@ -160,14 +164,14 @@ def test_reference_name_is_none(self):
definition = sdn.Definition()
instance = sdn.Instance()
instance.reference = definition
- self.assertTrue('reference definition.name undefined' in instance.__str__())
+ self.assertTrue("reference definition.name undefined" in instance.__str__())
def test_reference_name_is_not_none(self):
- netlist = sdn.load_example_netlist_by_name('toggle')
- out_reg = next(netlist.get_instances('*out_reg*'))
+ netlist = sdn.load_example_netlist_by_name("toggle")
+ out_reg = next(netlist.get_instances("*out_reg*"))
instance = sdn.Instance()
instance.reference = out_reg.reference
- self.assertTrue('reference definition.name \'FDRE\'' in instance.__str__())
+ self.assertTrue("reference definition.name 'FDRE'" in instance.__str__())
def test_instance_parent_name_none(self):
definition = sdn.Definition()
@@ -176,26 +180,24 @@ def test_instance_parent_name_none(self):
self.assertTrue("parent definition.name undefined" in instance.__str__())
def test_instance_parent_name_is_not_none(self):
- netlist = sdn.load_example_netlist_by_name('toggle')
- out_reg = next(netlist.get_instances('*out_reg*'))
+ netlist = sdn.load_example_netlist_by_name("toggle")
+ out_reg = next(netlist.get_instances("*out_reg*"))
instance = sdn.Instance()
out_reg.reference.add_child(instance)
- self.assertTrue('parent definition.name \'FDRE\'' in instance.__str__())
+ self.assertTrue("parent definition.name 'FDRE'" in instance.__str__())
def test_instance_is_leaf_but_no_reference(self):
instance = sdn.Instance()
self.assertFalse(instance.is_leaf())
def test_instance_is_unique(self):
- definition = sdn.Definition(name='a_definition')
+ definition = sdn.Definition(name="a_definition")
instance_3 = sdn.Instance()
definition.add_child(instance_3)
- instance_1 = sdn.Instance(name='instance_1')
+ instance_1 = sdn.Instance(name="instance_1")
instance_1.reference = definition
self.assertTrue(instance_1.is_unique())
- instance_2 = sdn.Instance(name='instance_2')
+ instance_2 = sdn.Instance(name="instance_2")
instance_2.reference = definition
self.assertFalse(instance_1.is_unique())
self.assertFalse(instance_2.is_unique())
-
-
\ No newline at end of file
diff --git a/spydrnet/ir/tests/test_library.py b/tests/spydrnet/ir/tests/test_library.py
similarity index 84%
rename from spydrnet/ir/tests/test_library.py
rename to tests/spydrnet/ir/tests/test_library.py
index f44c2d2b..1f3a97a3 100644
--- a/spydrnet/ir/tests/test_library.py
+++ b/tests/spydrnet/ir/tests/test_library.py
@@ -9,10 +9,16 @@ def setUp(self):
self.library = sdn.Library()
def test_constructor(self):
- self.assertIsInstance(self.library, FirstClassElement, "Netlist is not an element.")
- self.assertTrue(self.library, "Constructor return None type or empty collection")
+ self.assertIsInstance(
+ self.library, FirstClassElement, "Netlist is not an element."
+ )
+ self.assertTrue(
+ self.library, "Constructor return None type or empty collection"
+ )
library2 = sdn.Netlist()
- self.assertNotEqual(self.library, library2, "Unique objects are considered equal.")
+ self.assertNotEqual(
+ self.library, library2, "Unique objects are considered equal."
+ )
def test_definitions_set(self):
definition1 = self.library.create_definition()
@@ -62,10 +68,10 @@ def test_remove_definitions_from(self):
def test_no_parent_netlist(self):
library = sdn.Library()
- self.assertTrue('parent netlist undefined' in library.__str__())
+ self.assertTrue("parent netlist undefined" in library.__str__())
def test_no_parent_netlist_name(self):
netlist = sdn.Netlist()
library = sdn.Library()
netlist.add_library(library)
- self.assertTrue('parent netlist.name undefined' in library.__str__())
+ self.assertTrue("parent netlist.name undefined" in library.__str__())
diff --git a/spydrnet/ir/tests/test_netlist.py b/tests/spydrnet/ir/tests/test_netlist.py
similarity index 87%
rename from spydrnet/ir/tests/test_netlist.py
rename to tests/spydrnet/ir/tests/test_netlist.py
index 506929f7..71056dd7 100644
--- a/spydrnet/ir/tests/test_netlist.py
+++ b/tests/spydrnet/ir/tests/test_netlist.py
@@ -4,15 +4,22 @@
from spydrnet.ir import FirstClassElement
from spydrnet.uniquify import uniquify
+
class TestNetlist(unittest.TestCase):
def setUp(self):
self.netlist = sdn.Netlist()
def test_constructor(self):
- self.assertIsInstance(self.netlist, FirstClassElement, "Netlist is not an element.")
- self.assertTrue(self.netlist, "Constructor return None type or empty collection")
+ self.assertIsInstance(
+ self.netlist, FirstClassElement, "Netlist is not an element."
+ )
+ self.assertTrue(
+ self.netlist, "Constructor return None type or empty collection"
+ )
netlist2 = sdn.Netlist()
- self.assertNotEqual(self.netlist, netlist2, "Unique objects are considered equal.")
+ self.assertNotEqual(
+ self.netlist, netlist2, "Unique objects are considered equal."
+ )
def test_libraries(self):
self.assertEqual(len(tuple(self.netlist.libraries)), 0)
@@ -78,8 +85,8 @@ def test_remove_libraries_from(self):
self.assertEqual(library_included.netlist, self.netlist)
def test_top_instance_name(self):
- netlist = sdn.load_example_netlist_by_name('toggle')
- self.assertTrue('top_instance.name \'toggle\'' in netlist.__str__())
+ netlist = sdn.load_example_netlist_by_name("toggle")
+ self.assertTrue("top_instance.name 'toggle'" in netlist.__str__())
def test_set_top_instance_using_instance(self):
netlist = sdn.Netlist()
@@ -94,7 +101,7 @@ def test_set_top_instance_using_definition(self):
self.assertTrue(netlist.top_instance.reference is definition)
def test_is_unique(self):
- example_name = 'unique_challenge'
+ example_name = "unique_challenge"
netlist = sdn.load_example_netlist_by_name(example_name)
self.assertFalse(netlist.is_unique())
uniquify(netlist)
diff --git a/spydrnet/ir/tests/test_outerpin.py b/tests/spydrnet/ir/tests/test_outerpin.py
similarity index 94%
rename from spydrnet/ir/tests/test_outerpin.py
rename to tests/spydrnet/ir/tests/test_outerpin.py
index 9fa93ee5..a9027bfe 100644
--- a/spydrnet/ir/tests/test_outerpin.py
+++ b/tests/spydrnet/ir/tests/test_outerpin.py
@@ -30,4 +30,4 @@ def test_hash(self):
instance = sdn.Instance()
outer_pin1 = sdn.OuterPin.from_instance_and_inner_pin(instance, inner_pin)
outer_pin2 = sdn.OuterPin.from_instance_and_inner_pin(instance, inner_pin)
- self.assertEqual(hash(outer_pin1), hash(outer_pin2))
\ No newline at end of file
+ self.assertEqual(hash(outer_pin1), hash(outer_pin2))
diff --git a/spydrnet/ir/tests/test_pin.py b/tests/spydrnet/ir/tests/test_pin.py
similarity index 90%
rename from spydrnet/ir/tests/test_pin.py
rename to tests/spydrnet/ir/tests/test_pin.py
index c49448b8..f73a43be 100644
--- a/spydrnet/ir/tests/test_pin.py
+++ b/tests/spydrnet/ir/tests/test_pin.py
@@ -23,4 +23,4 @@ def test_wire_set(self):
def test_no_wire(self):
pin = Pin()
- self.assertTrue('Wire connected undefined' in pin.__str__())
+ self.assertTrue("Wire connected undefined" in pin.__str__())
diff --git a/spydrnet/ir/tests/test_port.py b/tests/spydrnet/ir/tests/test_port.py
similarity index 97%
rename from spydrnet/ir/tests/test_port.py
rename to tests/spydrnet/ir/tests/test_port.py
index dff29640..43d3e857 100644
--- a/spydrnet/ir/tests/test_port.py
+++ b/tests/spydrnet/ir/tests/test_port.py
@@ -31,7 +31,7 @@ def test_direction(self):
for ii in range(4):
self.port.direction = ii
self.assertEqual(self.port.direction.value, ii)
- directions = ['undefined', 'in', 'out', 'inout']
+ directions = ["undefined", "in", "out", "inout"]
for direction in directions:
self.port.direction = direction
self.assertEqual(self.port.direction.name.lower(), direction.lower())
@@ -45,7 +45,7 @@ def test_direction_2(self):
@unittest.expectedFailure
def test_direction_set_bad_type(self):
- self.port.direction = list()
+ self.port.direction = []
def test_initialize_pins(self):
self.port.create_pins(2)
diff --git a/spydrnet/ir/tests/test_print.py b/tests/spydrnet/ir/tests/test_print.py
similarity index 77%
rename from spydrnet/ir/tests/test_print.py
rename to tests/spydrnet/ir/tests/test_print.py
index 9f3c73b5..1b7aa64f 100644
--- a/spydrnet/ir/tests/test_print.py
+++ b/tests/spydrnet/ir/tests/test_print.py
@@ -4,16 +4,15 @@
class TestPrint(unittest.TestCase):
-
- netlist = sdn.Netlist(name='netlist')
- cable = sdn.Cable(name='cable', is_downto=False)
+ netlist = sdn.Netlist(name="netlist")
+ cable = sdn.Cable(name="cable", is_downto=False)
instance = sdn.Instance()
print(netlist)
netlist.top_instance = instance
print(netlist)
print(cable)
print(instance)
- library = netlist.create_library(name='lib')
+ library = netlist.create_library(name="lib")
print(library)
definition = sdn.Definition()
print(definition)
diff --git a/tests/spydrnet/ir/tests/test_shortcuts.py b/tests/spydrnet/ir/tests/test_shortcuts.py
new file mode 100644
index 00000000..6f1264d7
--- /dev/null
+++ b/tests/spydrnet/ir/tests/test_shortcuts.py
@@ -0,0 +1,194 @@
+import unittest
+
+
+from spydrnet.ir import FirstClassElement
+from spydrnet.ir import Instance
+from spydrnet.ir import Definition
+from spydrnet.ir import Netlist
+from spydrnet.ir import Cable
+from spydrnet.ir import Wire
+from spydrnet.util.hierarchical_reference import HRef
+from spydrnet.ir import Library
+from spydrnet.ir import Port
+
+
+class TestShortcuts(unittest.TestCase):
+ def test_hRef_shortcut(self):
+ item = Instance("myCable")
+ def2 = Definition("Hello")
+ item.reference = def2
+ hr = HRef(item)
+ self.assertEqual(hr.item.name, item.name, "Href item shorcut error")
+
+ def test_netlist_top_instance_definition_shortcut(self):
+ top_definition = Definition("this is my name")
+ netlist = Netlist()
+ netlist.top_instance = top_definition
+ self.assertEqual(
+ netlist.top_instance.reference.name,
+ top_definition.name,
+ "Netlist's top instance's shorcut error",
+ )
+
+ def test_if_leaf_shortcut(self):
+ instance = Instance()
+ definition = Definition()
+ instance.reference = definition
+ self.assertEqual(
+ definition.is_leaf(), instance.is_leaf(), "is_leaf shortcut error"
+ )
+ definition.create_cable()
+ instance.reference = definition
+ self.assertEqual(
+ definition.is_leaf(), instance.is_leaf(), "is_leaf shortcut error"
+ )
+
+ def test_wire_index_shortcut(self):
+ cable = Cable()
+ cable.create_wires(3)
+ wire = Wire()
+ cable.add_wire(wire, 1)
+ self.assertEqual(
+ wire.cable.wires.index(wire), wire.index(), "wire index shorcut error"
+ )
+ self.assertEqual(wire.index(), 1, "wire index shorcut error")
+ wire2 = Wire()
+ cable.add_wire(wire2, 3)
+ self.assertEqual(
+ wire2.cable.wires.index(wire2), wire2.index(), "wire index shorcut error"
+ )
+ self.assertEqual(wire2.index(), 3, "wire index shorcut error")
+
+ def test_name_init_shortcut(self):
+ d = Definition("d_name")
+ self.assertEqual(d.name, "d_name", "Definition name init shorcut error")
+ l = Library("l_name")
+ self.assertEqual(l.name, "l_name", "Library name init shorcut error")
+ n = Netlist("n_name")
+ self.assertEqual(n.name, "n_name", "Netlist name init shorcut error")
+ i = Instance("i_name")
+ self.assertEqual(i.name, "i_name", "Instance name init shorcut error")
+ c = Cable("c_name")
+ self.assertEqual(c.name, "c_name", "Cable name init shorcut error")
+ p = Port("p_name")
+ self.assertEqual(p.name, "p_name", "Port name init shorcut error")
+
+ def test_cable_shortcut(self):
+ c = Cable("c_name", None, False, True, 2)
+ self.assertEqual(c.name, "c_name", "Cable name init shorcut error")
+ self.assertEqual(c.is_downto, False, "Cable is_downto init shorcut error")
+ self.assertEqual(c.is_scalar, True, "Cable is_scalar init shorcut error")
+ self.assertEqual(c.lower_index, 2, "Cable lower_index init shorcut error")
+
+ c2 = Cable(is_scalar=False)
+ self.assertEqual(c2.name, None, "Cable name init shorcut error")
+ self.assertEqual(c2.is_downto, True, "Cable is_downto init shorcut error")
+ self.assertEqual(c2.is_scalar, False, "Cable is_scalar init shorcut error")
+ self.assertEqual(c2.lower_index, 0, "Cable lower_index init shorcut error")
+
+ def test_port_shortcut(self):
+ p = Port("p_name", None, False, True, 4)
+
+ self.assertEqual(p.name, "p_name", "Port name init shorcut error")
+ self.assertEqual(p.is_downto, False, "Port is_downto init shorcut error")
+ self.assertEqual(p.is_scalar, True, "Port is_scalar init shorcut error")
+ self.assertEqual(p.lower_index, 4, "Port lower_index init shorcut error")
+
+ p2 = Port(is_downto=False)
+ self.assertEqual(p2.name, None, "Port name init shorcut error")
+ self.assertEqual(p2.is_downto, False, "Port is_downto init shorcut error")
+ self.assertEqual(p2.is_scalar, True, "Port is_scalar init shorcut error")
+ self.assertEqual(p2.lower_index, 0, "Port lower_index init shorcut error")
+
+ def test_properties_init_shortcut(self):
+ d = Definition("d_name", {"key1": 1, "key2": "value2"})
+ self.assertEqual(d["key1"], 1, "Definition properties init shorcut error")
+
+ l = Library("l_name", {"key1": "value1", "key2": "value2"})
+ self.assertEqual(l["key1"], "value1", "Library properties init shorcut error")
+
+ n = Netlist("n_name", {"key1": "value1", "key2": 63})
+ self.assertEqual(n["key2"], 63, "Netlist properties init shorcut error")
+
+ i = Instance("i_name", {"key1": "value1", "key2": "value2"})
+ self.assertEqual(i["key1"], "value1", "Instance properties init shorcut error")
+
+ c = Cable("c_name", {"key1": "value1", "key2": "value2"})
+ self.assertEqual(c["key2"], "value2", "Cable properties init shorcut error")
+
+ p = Port("p_name", {"key1": "value1", "key2": "value2"})
+ self.assertEqual(p["key1"], "value1", "Port properties init shorcut error")
+
+ def test_library_child_instance_creation(self):
+ l = Library("l_name", {"key1": "value1", "key2": "value2"})
+ self.assertEqual(l["key1"], "value1", "Library properties init shorcut error")
+
+ l.create_definition("l_d_name", {"key1": 50, "key2": "value2"})
+ self.assertEqual(
+ "l_d_name",
+ l.definitions[0].name,
+ "library's definition cretion shorcut error",
+ )
+ self.assertEqual(
+ l.definitions[0]["key1"], 50, "library's definition cretion shorcut error"
+ )
+
+ l2 = Library()
+ l2.create_definition(properties={"key1": 50, "key2": "value2"})
+ self.assertEqual(
+ l2.definitions[0]["key1"], 50, "library's definition cretion shorcut error"
+ )
+
+ def test_definition_child_instance_creation(self):
+ d = Definition("d_name", {"key1": 1, "key2": "value2"})
+ self.assertEqual(d["key1"], 1, "Definition properties init shorcut error")
+
+ d.create_port("p_name")
+ self.assertEqual(d.ports[0].name, "p_name", "Port name init shorcut error")
+ d.create_port(properties={"key1": "value1", "key2": "value2"})
+ self.assertEqual(
+ d.ports[1]["key1"], "value1", "Port properties init shorcut error"
+ )
+
+ d.create_port(properties={"key1": "value1", "key2": "value2"})
+ self.assertEqual(
+ d.ports[1]["key1"], "value1", "Port properties init shorcut error"
+ )
+
+ d.create_child("d_c_name", {"key1": 1, "key2": "value2"})
+ self.assertEqual(
+ d.children[0]["key1"], 1, "Definition properties init shorcut error"
+ )
+ self.assertEqual(d["key1"], 1, "Definition properties init shorcut error")
+
+ d.create_cable("c_name", None, False, True, 2)
+ self.assertEqual(d.cables[0].name, "c_name", "Cable name init shorcut error")
+ self.assertEqual(
+ d.cables[0].is_downto, False, "Cable is_downto init shorcut error"
+ )
+ self.assertEqual(
+ d.cables[0].is_scalar, True, "Cable is_scalar init shorcut error"
+ )
+ self.assertEqual(
+ d.cables[0].lower_index, 2, "Cable lower_index init shorcut error"
+ )
+
+ d.create_cable(is_scalar=False)
+ self.assertEqual(d.cables[1].name, None, "Cable name init shorcut error")
+ self.assertEqual(
+ d.cables[1].is_downto, True, "Cable is_downto init shorcut error"
+ )
+ self.assertEqual(
+ d.cables[1].is_scalar, False, "Cable is_scalar init shorcut error"
+ )
+ self.assertEqual(
+ d.cables[1].lower_index, 0, "Cable lower_index init shorcut error"
+ )
+
+ def test_netlist_child_instance_creation(self):
+ n = Netlist("n_name")
+ self.assertEqual(n.name, "n_name", "Netlist name init shorcut error")
+ n.create_library("l_name", {"key1": "value1", "key2": "value2"})
+ self.assertEqual(
+ n.libraries[0]["key1"], "value1", "Library properties init shorcut error"
+ )
diff --git a/spydrnet/ir/tests/test_wire.py b/tests/spydrnet/ir/tests/test_wire.py
similarity index 70%
rename from spydrnet/ir/tests/test_wire.py
rename to tests/spydrnet/ir/tests/test_wire.py
index 2d6752ce..a28d4e80 100644
--- a/spydrnet/ir/tests/test_wire.py
+++ b/tests/spydrnet/ir/tests/test_wire.py
@@ -4,6 +4,7 @@
from spydrnet.ir import FirstClassElement
from spydrnet.util.selection import Selection
+
class TestWire(unittest.TestCase):
def setUp(self):
self.definition_top = sdn.Definition()
@@ -19,16 +20,24 @@ def setUp(self):
self.instance.reference = self.definition_leaf
def test_constructor(self):
- self.assertFalse(isinstance(self.wire, FirstClassElement), "Wire should not extend element")
+ self.assertFalse(
+ isinstance(self.wire, FirstClassElement), "Wire should not extend element"
+ )
wire2 = sdn.Wire()
self.assertNotEqual(self.wire, wire2, "Unique items are considered equal")
def test_pins_assignement(self):
self.wire.connect_pin(self.instance.pins[self.pin1])
self.wire.connect_pin(self.instance.pins[self.pin2])
- self.assertEqual(self.wire.pins, [self.instance.pins[self.pin1], self.instance.pins[self.pin2]])
+ self.assertEqual(
+ self.wire.pins,
+ [self.instance.pins[self.pin1], self.instance.pins[self.pin2]],
+ )
self.wire.pins = [self.instance.pins[self.pin2], self.instance.pins[self.pin1]]
- self.assertEqual(self.wire.pins, [self.instance.pins[self.pin2], self.instance.pins[self.pin1]])
+ self.assertEqual(
+ self.wire.pins,
+ [self.instance.pins[self.pin2], self.instance.pins[self.pin1]],
+ )
def test_connect_and_disconnect_inner_port(self):
self.wire.connect_pin(self.inner_pin)
@@ -56,7 +65,10 @@ def test_connect_and_disconnect_outer_pin_by_reference(self):
self.assertTrue(self.pin1 in self.instance.pins)
def test_connect_and_disconnect_outer_pin_by_object(self):
- self.wire.connect_pin(sdn.OuterPin.from_instance_and_inner_pin(self.instance, self.pin2), position=0)
+ self.wire.connect_pin(
+ sdn.OuterPin.from_instance_and_inner_pin(self.instance, self.pin2),
+ position=0,
+ )
self.assertEqual(len(self.wire.pins), 1)
self.assertTrue(all(x is self.instance.pins[x] for x in self.wire.pins))
self.assertTrue(all(x.wire is self.wire for x in self.wire.pins))
@@ -73,34 +85,48 @@ def test_disconnect_pin_from(self):
self.wire.connect_pin(self.inner_pin)
self.wire.connect_pin(self.instance.pins[self.pin1])
self.wire.connect_pin(self.instance.pins[self.pin2])
- self.wire.disconnect_pins_from(iter((self.inner_pin, self.instance.pins[self.pin1])))
+ self.wire.disconnect_pins_from(
+ iter((self.inner_pin, self.instance.pins[self.pin1]))
+ )
self.wire.disconnect_pins_from({self.instance.pins[self.pin2]})
self.assertEqual(len(self.wire.pins), 0)
- self.assertTrue(self.pin1 in self.instance.pins and isinstance(self.instance.pins[self.pin1], sdn.OuterPin) and
- self.instance.pins[self.pin1].inner_pin == self.pin1)
+ self.assertTrue(
+ self.pin1 in self.instance.pins
+ and isinstance(self.instance.pins[self.pin1], sdn.OuterPin)
+ and self.instance.pins[self.pin1].inner_pin == self.pin1
+ )
self.assertIsNone(self.inner_pin.wire)
self.assertIsNone(self.instance.pins[self.pin1].wire)
self.assertIsNone(self.instance.pins[self.pin2].wire)
- self.assertTrue(self.pin1 in self.instance.pins and isinstance(self.instance.pins[self.pin2], sdn.OuterPin) and
- self.instance.pins[self.pin2].inner_pin == self.pin2)
+ self.assertTrue(
+ self.pin1 in self.instance.pins
+ and isinstance(self.instance.pins[self.pin2], sdn.OuterPin)
+ and self.instance.pins[self.pin2].inner_pin == self.pin2
+ )
def test_get_driver(self):
- netlist = sdn.load_example_netlist_by_name('toggle')
- instance = next(netlist.get_instances('out_reg'))
- input_pin = next(instance.get_pins(selection=Selection.OUTSIDE,filter=lambda x: x.inner_pin.port.direction is sdn.IN and 'D' in x.inner_pin.port.name))
+ netlist = sdn.load_example_netlist_by_name("toggle")
+ instance = next(netlist.get_instances("out_reg"))
+ input_pin = next(
+ instance.get_pins(
+ selection=Selection.OUTSIDE,
+ filter=lambda x: x.inner_pin.port.direction is sdn.IN
+ and "D" in x.inner_pin.port.name,
+ )
+ )
driver = list(x for x in input_pin.wire.get_driver())
self.assertTrue(len(driver) == 1)
- self.assertTrue('out_i_1' in driver[0].instance.name)
- self.assertEqual(driver[0].inner_pin.port.name, 'O')
+ self.assertTrue("out_i_1" in driver[0].instance.name)
+ self.assertEqual(driver[0].inner_pin.port.name, "O")
def test_get_driver_2(self):
- netlist = sdn.load_example_netlist_by_name('adder')
- instance = next(netlist.get_instances('a'))
- cable = next(instance.get_cables('a'))
+ netlist = sdn.load_example_netlist_by_name("adder")
+ instance = next(netlist.get_instances("a"))
+ cable = next(instance.get_cables("a"))
wire = cable.wires[0]
driver = list(x for x in wire.get_driver())
self.assertTrue(len(driver) == 1)
- self.assertTrue('a[8:0]' in driver[0].port.name)
+ self.assertTrue("a[8:0]" in driver[0].port.name)
@unittest.expectedFailure
def test_disconnect_inner_pin_from_outside_wire(self):
@@ -114,9 +140,9 @@ def test_disconnect_outer_pin_from_outside_wire(self):
def test_print_no_cable(self):
wire = sdn.Wire()
- self.assertTrue('Not contained by any Cable' in wire.__str__())
+ self.assertTrue("Not contained by any Cable" in wire.__str__())
def test_print_cable_name(self):
- cable = sdn.Cable('cable')
+ cable = sdn.Cable("cable")
wire = cable.create_wire()
self.assertTrue("Contained by Cable.name 'cable'" in wire.__str__())
diff --git a/spydrnet/parsers/eblif/tests/test_eblif_tokenizer.py b/tests/spydrnet/ir/views/__init__.py
similarity index 100%
rename from spydrnet/parsers/eblif/tests/test_eblif_tokenizer.py
rename to tests/spydrnet/ir/views/__init__.py
diff --git a/spydrnet/parsers/edif/tests/test_edif_construction.py b/tests/spydrnet/ir/views/tests/__init__.py
similarity index 100%
rename from spydrnet/parsers/edif/tests/test_edif_construction.py
rename to tests/spydrnet/ir/views/tests/__init__.py
diff --git a/spydrnet/ir/views/tests/test_dictview.py b/tests/spydrnet/ir/views/tests/test_dictview.py
similarity index 87%
rename from spydrnet/ir/views/tests/test_dictview.py
rename to tests/spydrnet/ir/views/tests/test_dictview.py
index 7b9e0b71..629f2a5f 100644
--- a/spydrnet/ir/views/tests/test_dictview.py
+++ b/tests/spydrnet/ir/views/tests/test_dictview.py
@@ -1,6 +1,7 @@
import unittest
from spydrnet.ir.views.dictview import DictView
+
class TestDictView(unittest.TestCase):
def setUp(self) -> None:
self.dict_1 = dict(map(lambda x: (x, str(x)), range(10)))
@@ -47,13 +48,18 @@ def test_iter(self):
def test_get(self):
for ii in range(11):
- self.assertTrue(self.dict_view_1.get(ii, '10') == str(ii))
+ self.assertTrue(self.dict_view_1.get(ii, "10") == str(ii))
def test_copy(self):
- self.assertEqual(dict(map(lambda x: (x, str(x)), range(10))), self.dict_view_1.copy())
+ self.assertEqual(
+ dict(map(lambda x: (x, str(x)), range(10))), self.dict_view_1.copy()
+ )
def test_fromkeys(self):
- self.assertEqual(self.dict_view_1.fromkeys(range(10), 5), dict(map(lambda x: (x, 5), range(10))))
+ self.assertEqual(
+ self.dict_view_1.fromkeys(range(10), 5),
+ dict(map(lambda x: (x, 5), range(10))),
+ )
def test_keys(self):
for ii, jj in zip(self.dict_view_1.keys(), range(10)):
diff --git a/spydrnet/ir/views/tests/test_listview.py b/tests/spydrnet/ir/views/tests/test_listview.py
similarity index 98%
rename from spydrnet/ir/views/tests/test_listview.py
rename to tests/spydrnet/ir/views/tests/test_listview.py
index 3d185082..2b5cddba 100644
--- a/spydrnet/ir/views/tests/test_listview.py
+++ b/tests/spydrnet/ir/views/tests/test_listview.py
@@ -16,7 +16,7 @@ def test_contains(self):
def test_comparison(self):
list_copy = list(range(10))
self.assertEqual(self.list_view, list_copy)
- empty_list = list()
+ empty_list = []
self.assertNotEqual(self.list_view, empty_list)
def test_iter(self):
diff --git a/tests/spydrnet/ir/views/tests/test_outerpinsview.py b/tests/spydrnet/ir/views/tests/test_outerpinsview.py
new file mode 100644
index 00000000..f75d79a9
--- /dev/null
+++ b/tests/spydrnet/ir/views/tests/test_outerpinsview.py
@@ -0,0 +1,58 @@
+import unittest
+import spydrnet as sdn
+
+
+class TestOuterPinsView(unittest.TestCase):
+ def setUp(self) -> None:
+ definition = sdn.Definition()
+ port = definition.create_port()
+ self.inner_pins = port.create_pins(10)
+ self.instance = sdn.Instance()
+ self.instance.reference = definition
+ self.outer_pins_view = self.instance.pins
+
+ def test_contains(self):
+ self.assertTrue(all(x in self.outer_pins_view for x in self.inner_pins))
+ self.assertTrue(
+ all(
+ sdn.OuterPin(self.instance, x) in self.outer_pins_view
+ for x in self.inner_pins
+ )
+ )
+
+ def test_equal(self):
+ self.assertEqual(
+ self.outer_pins_view,
+ dict(map(lambda x: (x, sdn.OuterPin(self.instance, x)), self.inner_pins)),
+ )
+
+ def test_getitem(self):
+ self.assertTrue(
+ all(
+ self.outer_pins_view[x] == sdn.OuterPin(self.instance, x)
+ for x in self.inner_pins
+ )
+ )
+ self.assertTrue(
+ all(
+ self.outer_pins_view[x]
+ is self.outer_pins_view[sdn.OuterPin(self.instance, x)]
+ for x in self.inner_pins
+ )
+ )
+
+ def test_iter(self):
+ self.assertTrue(all(isinstance(x, sdn.OuterPin) for x in self.outer_pins_view))
+
+ def test_len(self):
+ self.assertEqual(len(self.outer_pins_view), 10)
+
+ def test_get(self):
+ self.assertEqual(
+ self.outer_pins_view.get(self.inner_pins[0]),
+ sdn.OuterPin(self.instance, self.inner_pins[0]),
+ )
+ self.assertEqual(
+ self.outer_pins_view.get(sdn.OuterPin(self.instance, self.inner_pins[0])),
+ sdn.OuterPin(self.instance, self.inner_pins[0]),
+ )
diff --git a/spydrnet/ir/views/tests/test_setview.py b/tests/spydrnet/ir/views/tests/test_setview.py
similarity index 95%
rename from spydrnet/ir/views/tests/test_setview.py
rename to tests/spydrnet/ir/views/tests/test_setview.py
index 1e78a45a..bb9731a4 100644
--- a/spydrnet/ir/views/tests/test_setview.py
+++ b/tests/spydrnet/ir/views/tests/test_setview.py
@@ -94,8 +94,10 @@ def test_issuperset(self):
self.assertTrue(self.set_view.issuperset(set(range(5))))
def test_symmetric_difference(self):
- self.assertTrue(set(range(10)) ^ set(range(5, 20)), self.set_view.symmetric_difference(set(range(5, 20))))
+ self.assertTrue(
+ set(range(10)) ^ set(range(5, 20)),
+ self.set_view.symmetric_difference(set(range(5, 20))),
+ )
def test_union(self):
self.assertTrue(set(range(20)), self.set_view.union(set(range(10, 20))))
-
diff --git a/spydrnet/plugins/tests/test_hierarchical_reference_manager.py b/tests/spydrnet/parsers/__init__.py
similarity index 100%
rename from spydrnet/plugins/tests/test_hierarchical_reference_manager.py
rename to tests/spydrnet/parsers/__init__.py
diff --git a/tests/spydrnet/parsers/eblif/__init__.py b/tests/spydrnet/parsers/eblif/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/spydrnet/parsers/eblif/tests/__init__.py b/tests/spydrnet/parsers/eblif/tests/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/spydrnet/parsers/eblif/tests/test_eblif_parser.py b/tests/spydrnet/parsers/eblif/tests/test_eblif_parser.py
new file mode 100644
index 00000000..903296de
--- /dev/null
+++ b/tests/spydrnet/parsers/eblif/tests/test_eblif_parser.py
@@ -0,0 +1,99 @@
+import unittest
+import spydrnet as sdn
+from spydrnet import example_netlists_path
+from spydrnet.util.selection import Selection
+from pathlib import Path
+
+"""
+Test the EBLIFParser by parsing in a simple netlist and making sure that:
+ - Everything is there
+ - Everything is working together as a netlist as it should (to be sure things were created and placed in the netlist correctly)
+"""
+
+
+class TestEBLIFParser(unittest.TestCase):
+ def setUp(self):
+ self.netlist = sdn.parse(
+ Path(example_netlists_path, "eblif_netlists", "toggle.eblif.zip")
+ )
+ self.definition_list = [
+ "INV",
+ "BUFG",
+ "FDRE",
+ "IBUF",
+ "OBUF",
+ "toggle",
+ "logic-gate_0",
+ ]
+
+ def test_name(self):
+ self.assertEqual(self.netlist.name, "toggle")
+
+ def test_definitions(self):
+ count = 0
+ for definition in self.netlist.get_definitions():
+ self.assertTrue(
+ definition.name in self.definition_list,
+ definition.name + " not found in list",
+ )
+ count += 1
+ self.assertEqual(count, len(self.definition_list))
+
+ def test_instances(self):
+ self.assertEqual(self.netlist.top_instance.name, "toggle")
+ for instance in self.netlist.get_instances():
+ self.assertTrue(instance.reference.name in self.definition_list)
+ self.assertTrue(self.netlist_is_own_netlist(instance))
+ if "logic-gate_0" in instance.reference.name:
+ self.assertEqual(instance["EBLIF.type"], "EBLIF.names")
+ else:
+ self.assertEqual(instance["EBLIF.type"], "EBLIF.subckt")
+
+ def test_top_level_ports(self):
+ input_port_list = ["clk", "reset"]
+ output_port_list = ["out"]
+ for port in self.netlist.get_hports():
+ if port.item.direction is sdn.IN:
+ self.assertTrue(
+ port.item.name in input_port_list,
+ port.item.name + " is not in " + str(input_port_list),
+ )
+ self.assertTrue(self.netlist_is_own_netlist(port))
+ elif port.item.direction is sdn.OUT:
+ self.assertTrue(
+ port.item.name in output_port_list,
+ port.item.name + " is not in " + str(output_port_list),
+ )
+ self.assertTrue(self.netlist_is_own_netlist(port))
+
+ def test_cables(self):
+ count = 0
+ for cable in self.netlist.get_cables():
+ self.assertTrue(self.netlist_is_own_netlist(cable))
+ count += 1
+ self.assertEqual(count, 11)
+
+ def netlist_is_own_netlist(self, object):
+ netlist_list = list(x for x in object.get_netlists())
+ if self.netlist in netlist_list:
+ return True
+ return False
+
+ def test_flip_flop_connections(self):
+ instance = next(
+ self.netlist.get_instances(filter=lambda x: x.reference.name == "FDRE")
+ )
+ pin_connections = {"C": "clk"}
+ for input_pin in instance.get_pins(
+ selection=Selection.OUTSIDE,
+ filter=lambda x: x.inner_pin.port.direction is sdn.IN,
+ ):
+ self.assertTrue(
+ input_pin.wire is not None,
+ input_pin.inner_pin.port.name + " does not have a wire",
+ )
+ # driver_pin = next(pin for pin in input_pin.wire.pins)
+ # get the driver
+ # make sure it's the right driver
+
+ # TODO add wire and connections tests
diff --git a/tests/spydrnet/parsers/eblif/tests/test_eblif_tokenizer.py b/tests/spydrnet/parsers/eblif/tests/test_eblif_tokenizer.py
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/spydrnet/parsers/edif/__init__.py b/tests/spydrnet/parsers/edif/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/spydrnet/parsers/edif/tests/__init__.py b/tests/spydrnet/parsers/edif/tests/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/spydrnet/parsers/edif/tests/test_edif_construction.py b/tests/spydrnet/parsers/edif/tests/test_edif_construction.py
new file mode 100644
index 00000000..e69de29b
diff --git a/spydrnet/parsers/edif/tests/test_edif_parser.py b/tests/spydrnet/parsers/edif/tests/test_edif_parser.py
similarity index 81%
rename from spydrnet/parsers/edif/tests/test_edif_parser.py
rename to tests/spydrnet/parsers/edif/tests/test_edif_parser.py
index 960aae9c..3eafa925 100644
--- a/spydrnet/parsers/edif/tests/test_edif_parser.py
+++ b/tests/spydrnet/parsers/edif/tests/test_edif_parser.py
@@ -2,10 +2,7 @@
import spydrnet as sdn
from spydrnet.parsers.edif.parser import EdifParser
-from spydrnet import base_dir
-import os
import tempfile
-import glob
import shutil
from pathlib import Path
@@ -26,7 +23,7 @@ def test_multi_bit_add_out_of_order(self):
cable0.create_wire()
cable1.create_wire()
cable2.create_wire()
-
+
p0 = sdn.InnerPin()
p1 = sdn.InnerPin()
p2 = sdn.InnerPin()
@@ -41,20 +38,18 @@ def test_multi_bit_add_out_of_order(self):
ep.multibit_add_cable(definition, cable1)
assert len(definition.cables) == 1
- assert len (definition.cables[0].wires) == 3
+ assert len(definition.cables[0].wires) == 3
assert len(definition.cables[0].wires[0].pins) == 0
assert len(definition.cables[0].wires[1].pins) == 3
assert len(definition.cables[0].wires[2].pins) == 0
assert p0 in definition.cables[0].wires[1].pins
assert p1 in definition.cables[0].wires[1].pins
assert p2 in definition.cables[0].wires[1].pins
-
@classmethod
def setUpClass(cls) -> None:
- cls.dir_of_edif_netlists = Path(sdn.base_dir, "support_files", "EDIF_netlists")
- cls.edif_files = sorted(glob.glob(os.path.join(cls.dir_of_edif_netlists, "*.edf.zip")), key=os.path.getsize)
- # cls.edif_files = sorted(glob.glob(Path(cls.dir_of_edif_netlists, "*.edf.zip")), key=Path.stat().st_size)
+ cls.dir_of_edif_netlists = Path(sdn.example_netlists_path, "EDIF_netlists")
+ cls.edif_files = sorted(Path.glob(Path(cls.dir_of_edif_netlists), "*.edf.zip"))
@unittest.skip("Test takes a long time right now.")
def test_large_edif(self):
@@ -69,7 +64,7 @@ def test_small_edif_cables(self):
continue
self.ensure_cable_consistency(filename, ii, "edf")
- def ensure_cable_consistency(self,filename, ii, target_format_extension = None):
+ def ensure_cable_consistency(self, filename, ii, target_format_extension=None):
with self.subTest(i=ii):
if Path("temp").exists():
shutil.rmtree("temp")
@@ -82,5 +77,5 @@ def ensure_cable_consistency(self,filename, ii, target_format_extension = None):
assert c.definition is not None
-if __name__ == '__main__':
+if __name__ == "__main__":
unittest.main()
diff --git a/spydrnet/parsers/edif/tests/test_tokenizer.py b/tests/spydrnet/parsers/edif/tests/test_tokenizer.py
similarity index 82%
rename from spydrnet/parsers/edif/tests/test_tokenizer.py
rename to tests/spydrnet/parsers/edif/tests/test_tokenizer.py
index 23166ead..e6be817e 100644
--- a/spydrnet/parsers/edif/tests/test_tokenizer.py
+++ b/tests/spydrnet/parsers/edif/tests/test_tokenizer.py
@@ -1,23 +1,23 @@
import unittest
-import os
import io
import zipfile
import tempfile
from pathlib import Path
from spydrnet.parsers.edif.tokenizer import EdifTokenizer
-from spydrnet import base_dir
+from spydrnet import example_netlists_path
+
class TestEdifTokenizer(unittest.TestCase):
def test_no_constructor_of_zero_argument(self):
self.assertRaises(TypeError, EdifTokenizer)
def test_stream(self):
- dir_of_edif_netlists = Path(base_dir, "support_files", "EDIF_netlists")
+ dir_of_edif_netlists = Path(example_netlists_path, "EDIF_netlists")
test_file = Path(dir_of_edif_netlists, "n_bit_counter.edf.zip")
zip = zipfile.ZipFile(test_file)
file_name = Path(test_file).name
- file_name = file_name[:file_name.rindex(".")]
+ file_name = file_name[: file_name.rindex(".")]
stream = zip.open(file_name)
stream = io.TextIOWrapper(stream)
tokenizer = EdifTokenizer.from_stream(stream)
@@ -25,18 +25,19 @@ def test_stream(self):
self.assertEqual("(", next_token)
def test_open_zip_file(self):
- dir_of_edif_netlists = Path(base_dir, "support_files", "EDIF_netlists")
- test_file = os.path.join(dir_of_edif_netlists, "n_bit_counter.edf.zip")
- # test_file = Path(dir_of_edif_netlists, "n_bit_counter.edf.zip") # UnicodeDecodeError
+ dir_of_edif_netlists = Path(example_netlists_path, "EDIF_netlists")
+ test_file = Path(
+ dir_of_edif_netlists, "n_bit_counter.edf.zip"
+ ) # UnicodeDecodeError
tokenizer = EdifTokenizer.from_filename(test_file)
next_token = tokenizer.next()
self.assertEqual("(", next_token)
def test_open_file(self):
- dir_of_edif_netlists = Path(base_dir, "support_files", "EDIF_netlists")
+ dir_of_edif_netlists = Path(example_netlists_path, "EDIF_netlists")
test_file = Path(dir_of_edif_netlists, "n_bit_counter.edf.zip")
file_name = Path(test_file).name
- file_name = file_name[:file_name.rindex(".")]
+ file_name = file_name[: file_name.rindex(".")]
zip = zipfile.ZipFile(test_file)
with tempfile.TemporaryDirectory() as tempdir:
zip.extract(file_name, tempdir)
@@ -67,19 +68,19 @@ def test_paren_with_whitespace(self):
self.assertRaises(StopIteration, tokenizer.next)
def test_string_token(self):
- test_string = "\"This is a test string in EDIF\""
+ test_string = '"This is a test string in EDIF"'
tokenizer = EdifTokenizer.from_string(test_string)
next_token = tokenizer.next()
self.assertEqual(test_string, next_token)
self.assertRaises(StopIteration, tokenizer.next)
def test_multiline_string(self):
- test_string = "\"This is a test string in EDIF\n with a new line in it.\""
+ test_string = '"This is a test string in EDIF\n with a new line in it."'
tokenizer = EdifTokenizer.from_string(test_string)
next_token = tokenizer.next()
self.assertEqual(test_string.replace("\n", ""), next_token)
self.assertRaises(StopIteration, tokenizer.next)
-
+
def test_peek_and_token_equals(self):
test_id = "VALID_EDIF_ID"
tokenizer = EdifTokenizer.from_string(test_id)
@@ -96,7 +97,6 @@ def test_peek_and_token_equals(self):
class TestTokenTypes(unittest.TestCase):
-
def test_edif_identifier(self):
valid_ids = "&test a a9 a_ Alpha_Numeric_0123456789 &"
tokenizer = EdifTokenizer.from_string(valid_ids)
@@ -104,10 +104,10 @@ def test_edif_identifier(self):
tokenizer.next()
self.assertTrue(tokenizer.is_valid_identifier(), tokenizer.token)
- invalid_ids = "_ _idenitier_ 9alkjf too_long" + "0"*(256 - 7)
+ invalid_ids = "_ _idenitier_ 9alkjf too_long" + "0" * (256 - 7)
tokenizer = EdifTokenizer.from_string(invalid_ids)
while tokenizer.has_next():
tokenizer.next()
self.assertFalse(tokenizer.is_valid_identifier(), tokenizer.token)
- #TODO Special characters are weird. We should check them out.
+ # TODO Special characters are weird. We should check them out.
diff --git a/tests/spydrnet/parsers/primatives/__init__.py b/tests/spydrnet/parsers/primatives/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/spydrnet/parsers/primatives/tests/test_parse_primatives.py b/tests/spydrnet/parsers/primatives/tests/test_parse_primatives.py
similarity index 90%
rename from spydrnet/parsers/primatives/tests/test_parse_primatives.py
rename to tests/spydrnet/parsers/primatives/tests/test_parse_primatives.py
index 32b24c0e..3af79708 100644
--- a/spydrnet/parsers/primatives/tests/test_parse_primatives.py
+++ b/tests/spydrnet/parsers/primatives/tests/test_parse_primatives.py
@@ -3,5 +3,4 @@
class TestParsePrimatives(unittest.TestCase):
-
- None
\ No newline at end of file
+ None
diff --git a/tests/spydrnet/parsers/tests/__init__.py b/tests/spydrnet/parsers/tests/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/spydrnet/parsers/tests/test_parsers.py b/tests/spydrnet/parsers/tests/test_parsers.py
similarity index 79%
rename from spydrnet/parsers/tests/test_parsers.py
rename to tests/spydrnet/parsers/tests/test_parsers.py
index fcdf6906..1525688a 100644
--- a/spydrnet/parsers/tests/test_parsers.py
+++ b/tests/spydrnet/parsers/tests/test_parsers.py
@@ -10,11 +10,10 @@ def test_parse(self):
self.assertRaises(RuntimeError, sdn.parse, "fakefile.fakeext")
-
class TestParseWithArchitecture(unittest.TestCase):
def test_verilog(self):
netlist = sdn.load_example_netlist_by_name("b13", VERILOG)
- netlist.compose("b13.v", write_blackbox = False)
+ netlist.compose("b13.v", write_blackbox=False)
netlist_1 = sdn.parse("b13.v")
for definition in netlist_1.get_definitions():
@@ -22,25 +21,28 @@ def test_verilog(self):
for port in definition.get_ports():
self.assertEqual(port.direction, sdn.UNDEFINED)
- netlist_2 = sdn.parse("b13.v", XILINX_7SERIES)
+ netlist_2 = sdn.parse("b13.v", architecture=XILINX_7SERIES)
for definition in netlist_2.get_definitions():
if definition is not netlist_2.top_instance.reference:
for port in definition.get_ports():
self.assertNotEqual(port.direction, sdn.UNDEFINED, definition.name)
os.remove("b13.v")
-
+
def test_eblif(self):
netlist = sdn.load_example_netlist_by_name("toggle", EBLIF)
- netlist.compose("toggle.eblif", write_blackbox = False)
+ netlist.compose("toggle.eblif", write_blackbox=False)
netlist_1 = sdn.parse("toggle.eblif")
for definition in netlist_1.get_definitions():
- if definition is not netlist_1.top_instance.reference and "logic-gate" not in definition.name:
+ if (
+ definition is not netlist_1.top_instance.reference
+ and "logic-gate" not in definition.name
+ ):
for port in definition.get_ports():
self.assertEqual(port.direction, sdn.UNDEFINED, definition.name)
- netlist_2 = sdn.parse("toggle.eblif", XILINX_7SERIES)
+ netlist_2 = sdn.parse("toggle.eblif", architecture=XILINX_7SERIES)
for definition in netlist_2.get_definitions():
if definition is not netlist_2.top_instance.reference:
for port in definition.get_ports():
diff --git a/tests/spydrnet/parsers/verilog/__init__.py b/tests/spydrnet/parsers/verilog/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/spydrnet/parsers/verilog/tests/__init__.py b/tests/spydrnet/parsers/verilog/tests/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/spydrnet/parsers/verilog/tests/test_token_factory.py b/tests/spydrnet/parsers/verilog/tests/test_token_factory.py
similarity index 81%
rename from spydrnet/parsers/verilog/tests/test_token_factory.py
rename to tests/spydrnet/parsers/verilog/tests/test_token_factory.py
index 413a6de1..5a771df6 100644
--- a/spydrnet/parsers/verilog/tests/test_token_factory.py
+++ b/tests/spydrnet/parsers/verilog/tests/test_token_factory.py
@@ -4,7 +4,7 @@
# these code snippets may have copyright protection other than what the License file entails please use with caution
-very_simple = '''// Copyright 1986-2020 Xilinx, Inc. All Rights Reserved.
+very_simple = """// Copyright 1986-2020 Xilinx, Inc. All Rights Reserved.
// --------------------------------------------------------------------------------
// Tool Version: Vivado v.2020.2 (lin64) Build 3064766 Wed Nov 18 09:12:47 MST 2020
// Date : Wed Mar 17 14:51:06 2021
@@ -24,9 +24,9 @@
input [7:0]XP_IN;
-endmodule'''
+endmodule"""
-very_simple_multi_line = '''/* Copyright 1986-2020 Xilinx, Inc. All Rights Reserved.
+very_simple_multi_line = """/* Copyright 1986-2020 Xilinx, Inc. All Rights Reserved.
// --------------------------------------------------------------------------------
// Tool Version: Vivado v.2020.2 (lin64) Build 3064766 Wed Nov 18 09:12:47 MST 2020
// Date : Wed Mar 17 14:51:06 2021
@@ -47,9 +47,9 @@
input [7:0]XP_IN;
-endmodule'''
+endmodule"""
-port_remap = '''
+port_remap = """
(* STRUCTURAL_NETLIST = "yes" *)
module synth_th1_slaac
(.XP_IN({\^XP_IN [0],\^XP_IN [1],\^XP_IN [2],\^XP_IN [3],\^XP_IN [4],\^XP_IN [5],\^XP_IN [6],\^XP_IN [7]}));
@@ -59,9 +59,9 @@
wire [7:0]\^XP_IN ;
endmodule
-'''
+"""
-comments = '''
+comments = """
/*/ this should be
treated
as a single comment /*/
@@ -75,20 +75,19 @@
*/
-'''
+"""
-final_comments = '''
+final_comments = """
module synth_th1_slaac
(XP_IN);
input [7:0]XP_IN;
endmodule
//* Final design comments
-'''
+"""
class TestVerilogParser(unittest.TestCase):
-
def run_token_count(self, string):
tf = TokenFactory()
running_total = 0
@@ -103,13 +102,20 @@ def run_token_count(self, string):
return running_total
def test_counts(self):
- to_run = [(very_simple_multi_line, 24, "very_simple_multi_line"), (very_simple, 35, "very_simple"),
- (port_remap, 74, "port_remap"), (comments, 11, "comments"), (final_comments, 16, "port_remap")]
+ to_run = [
+ (very_simple_multi_line, 24, "very_simple_multi_line"),
+ (very_simple, 35, "very_simple"),
+ (port_remap, 74, "port_remap"),
+ (comments, 11, "comments"),
+ (final_comments, 16, "port_remap"),
+ ]
for p in to_run:
s, c, n = p
- assert c == self.run_token_count(
- s), "the number of expected tokens did not match up with the number parsed " + n
+ assert c == self.run_token_count(s), (
+ "the number of expected tokens did not match up with the number parsed "
+ + n
+ )
-if __name__ == '__main__':
+if __name__ == "__main__":
unittest.main()
diff --git a/spydrnet/parsers/verilog/tests/test_tokenizer.py b/tests/spydrnet/parsers/verilog/tests/test_tokenizer.py
similarity index 56%
rename from spydrnet/parsers/verilog/tests/test_tokenizer.py
rename to tests/spydrnet/parsers/verilog/tests/test_tokenizer.py
index d164a538..5ec2257b 100644
--- a/spydrnet/parsers/verilog/tests/test_tokenizer.py
+++ b/tests/spydrnet/parsers/verilog/tests/test_tokenizer.py
@@ -7,25 +7,26 @@
class TestVerilogTokenizer(unittest.TestCase):
-
-
def test_against_4bit_adder(self):
- directory = os.path.join(sdn.base_dir, "support_files", "verilog_netlists", "4bitadder.v.zip")
- # directory = Path(sdn.base_dir, "support_files", "verilog_netlists", "4bitadder.v.zip") # UnicodeDecodeError
-
+ directory = Path(sdn.example_netlists_path).joinpath(
+ "verilog_netlists", "4bitadder.v.zip"
+ )
+
tokenizer = VerilogTokenizer.from_filename(directory)
- while(tokenizer.has_next()):
- #print(tokenizer.next())
+ while tokenizer.has_next():
+ # print(tokenizer.next())
tokenizer.next()
def test_spaces(self):
- tokenizer = VerilogTokenizer.from_string("wire temp = 1'b1; if something == some2")
- while(tokenizer.has_next()):
- #print(tokenizer.next())
+ tokenizer = VerilogTokenizer.from_string(
+ "wire temp = 1'b1; if something == some2"
+ )
+ while tokenizer.has_next():
+ # print(tokenizer.next())
tokenizer.next()
tokenizer = VerilogTokenizer.from_string("wire temp=1'b1 ;if something==some2")
- while(tokenizer.has_next()):
- #print(tokenizer.next())
+ while tokenizer.has_next():
+ # print(tokenizer.next())
tokenizer.next()
def test_from_stream(self):
@@ -33,8 +34,8 @@ def test_from_stream(self):
tokenizer = VerilogTokenizer.from_stream(stream)
expected_tokens = ["module", "empty", "(", ")", ";", "endmodule"]
tokens = []
- while(tokenizer.has_next()):
+ while tokenizer.has_next():
tokens.append(tokenizer.next())
-
+
for i in range(len(expected_tokens)):
- assert expected_tokens[i] == tokens[i]
\ No newline at end of file
+ assert expected_tokens[i] == tokens[i]
diff --git a/spydrnet/parsers/verilog/tests/test_verilogParser.py b/tests/spydrnet/parsers/verilog/tests/test_verilogParser.py
similarity index 66%
rename from spydrnet/parsers/verilog/tests/test_verilogParser.py
rename to tests/spydrnet/parsers/verilog/tests/test_verilogParser.py
index 178e0bf2..c3cf57a0 100644
--- a/spydrnet/parsers/verilog/tests/test_verilogParser.py
+++ b/tests/spydrnet/parsers/verilog/tests/test_verilogParser.py
@@ -9,8 +9,8 @@
from spydrnet.util.selection import Selection
import os
-class TestVerilogParser(unittest.TestCase):
+class TestVerilogParser(unittest.TestCase):
class TestTokenizer:
def __init__(self, tokenlist):
self.tokens = tokenlist
@@ -28,7 +28,7 @@ def next(self):
token = self.tokens[self.index]
self.index += 1
return token
-
+
def peek(self):
token = self.tokens[self.index]
return token
@@ -38,13 +38,37 @@ def peek(self):
###################################################
def test_module_header_parameter_parsing(self):
- expected = dict()
+ expected = {}
expected["INIT"] = "1'h1"
expected["[1:0] INIT0"] = "2'h0"
expected["[0] INIT1"] = "1'b0"
- tokens = ["#", "(", "parameter", "INIT", "=", "1'h1", ",",\
- "parameter", "[", "1", ":", "0", "]", "INIT0", "=", "2'h0", ",",\
- "parameter", "[", "0", "]", "INIT1", "=", "1'b0", ")"]
+ tokens = [
+ "#",
+ "(",
+ "parameter",
+ "INIT",
+ "=",
+ "1'h1",
+ ",",
+ "parameter",
+ "[",
+ "1",
+ ":",
+ "0",
+ "]",
+ "INIT0",
+ "=",
+ "2'h0",
+ ",",
+ "parameter",
+ "[",
+ "0",
+ "]",
+ "INIT1",
+ "=",
+ "1'b0",
+ ")",
+ ]
tokenizer = self.TestTokenizer(tokens)
parser = VerilogParser()
@@ -53,17 +77,25 @@ def test_module_header_parameter_parsing(self):
parser.parse_module_header_parameters()
- assert "VERILOG.Parameters" in parser.current_definition, "expected parameters in the definition"
+ assert (
+ "VERILOG.Parameters" in parser.current_definition
+ ), "expected parameters in the definition"
parameters = parser.current_definition["VERILOG.Parameters"]
for k, v in expected.items():
- assert k in parameters, "expected to see " + k + " in the definition parameters"
- assert parameters[k] == v, "expected value of k to be " + v + " but got instead " + parameters[k]
-
+ assert k in parameters, (
+ "expected to see " + k + " in the definition parameters"
+ )
+ assert parameters[k] == v, (
+ "expected value of k to be " + v + " but got instead " + parameters[k]
+ )
+
for k, v in parameters.items():
- assert k in expected, "unexpected value " + k + " in the definition parameters"
-
+ assert k in expected, (
+ "unexpected value " + k + " in the definition parameters"
+ )
+
def test_module_header_port_name_only(self):
- #expected = [(direction, left, right, name)]
+ # expected = [(direction, left, right, name)]
expected = ["PORT0", "PORT1", "PORT2", "PORT3", "PORT4"]
tokens = ["("]
first_run = True
@@ -83,15 +115,25 @@ def test_module_header_port_name_only(self):
parser.parse_module_header_ports()
- assert len(parser.current_definition.ports) == len(expected), \
- "port count mismatch definition: " + str(len(parser.current_definition.ports)) + " expected: " + str(len(expected))
+ assert len(parser.current_definition.ports) == len(expected), (
+ "port count mismatch definition: "
+ + str(len(parser.current_definition.ports))
+ + " expected: "
+ + str(len(expected))
+ )
for i in range(len(expected)):
assert expected[i] == parser.current_definition.ports[i].name
def test_module_header_port_name_and_direction(self):
- #expected = [(direction, left, right, name)]
- expected = [("PORT0", "output"), ("PORT1", "input"), ("PORT2", "inout"), ("PORT3", "output"), ("PORT4", "input")]
+ # expected = [(direction, left, right, name)]
+ expected = [
+ ("PORT0", "output"),
+ ("PORT1", "input"),
+ ("PORT2", "inout"),
+ ("PORT3", "output"),
+ ("PORT4", "input"),
+ ]
tokens = ["("]
first_run = True
for p in expected:
@@ -112,20 +154,38 @@ def test_module_header_port_name_and_direction(self):
parser.parse_module_header_ports()
- assert len(parser.current_definition.ports) == len(expected), \
- "port count mismatch definition: " + str(len(parser.current_definition.ports)) + " expected: " + str(len(expected))
+ assert len(parser.current_definition.ports) == len(expected), (
+ "port count mismatch definition: "
+ + str(len(parser.current_definition.ports))
+ + " expected: "
+ + str(len(expected))
+ )
for i in range(len(expected)):
- assert expected[i][0] == parser.current_definition.ports[i].name,\
- "ports names don't match. Definition: " + parser.current_definition.ports[i].name + " expected " + expected[i][0]
+ assert expected[i][0] == parser.current_definition.ports[i].name, (
+ "ports names don't match. Definition: "
+ + parser.current_definition.ports[i].name
+ + " expected "
+ + expected[i][0]
+ )
expected_direction = vt.string_to_port_direction(expected[i][1])
definition_direction = parser.current_definition.ports[i].direction
- assert expected_direction == definition_direction, \
- "directions do not match up expected " + str(expected_direction) + " but got " + definition_direction
+ assert expected_direction == definition_direction, (
+ "directions do not match up expected "
+ + str(expected_direction)
+ + " but got "
+ + definition_direction
+ )
def test_module_heaader_port_name_and_index(self):
- #expected = [(direction, left, right, name)]
- expected = [("PORT0", "5" , "0"), ("PORT1", "8","-2"), ("PORT2", "0","0"), ("PORT3", "16","8"), ("PORT4", "3","0")]
+ # expected = [(direction, left, right, name)]
+ expected = [
+ ("PORT0", "5", "0"),
+ ("PORT1", "8", "-2"),
+ ("PORT2", "0", "0"),
+ ("PORT3", "16", "8"),
+ ("PORT4", "3", "0"),
+ ]
tokens = ["("]
first_run = True
for p in expected:
@@ -148,27 +208,49 @@ def test_module_heaader_port_name_and_index(self):
parser.parse_module_header_ports()
- assert len(parser.current_definition.ports) == len(expected), \
- "port count mismatch definition: " + str(len(parser.current_definition.ports)) + " expected: " + str(len(expected))
+ assert len(parser.current_definition.ports) == len(expected), (
+ "port count mismatch definition: "
+ + str(len(parser.current_definition.ports))
+ + " expected: "
+ + str(len(expected))
+ )
for i in range(len(expected)):
- assert expected[i][0] == parser.current_definition.ports[i].name,\
- "ports names don't match. Definition: " + parser.current_definition.ports[i].name + " expected " + expected[i][0]
+ assert expected[i][0] == parser.current_definition.ports[i].name, (
+ "ports names don't match. Definition: "
+ + parser.current_definition.ports[i].name
+ + " expected "
+ + expected[i][0]
+ )
expected_lower = min(int(expected[i][2]), int(expected[i][1]))
definition_lower = parser.current_definition.ports[i].lower_index
- expected_width = max(int(expected[i][2]), int(expected[i][1])) - expected_lower + 1
+ expected_width = (
+ max(int(expected[i][2]), int(expected[i][1])) - expected_lower + 1
+ )
definition_width = len(parser.current_definition.ports[i].pins)
- assert expected_lower == definition_lower, \
- "lower indicies do not match up expected " + str(expected_lower) + " but got " + str(definition_lower)
-
- assert expected_width == definition_width, \
- "widths do not match up expected " + str(expected_width) + " but got " + str(definition_width)
-
+ assert expected_lower == definition_lower, (
+ "lower indicies do not match up expected "
+ + str(expected_lower)
+ + " but got "
+ + str(definition_lower)
+ )
+
+ assert expected_width == definition_width, (
+ "widths do not match up expected "
+ + str(expected_width)
+ + " but got "
+ + str(definition_width)
+ )
def test_module_header_all_present(self):
- expected = [("PORT0", "5" , "0", "input"), ("PORT1", "8","-2", "output"), ("PORT2", "0","0", "inout"),\
- ("PORT3", "16","8", "input"), ("PORT4", "3","0", "output")]
+ expected = [
+ ("PORT0", "5", "0", "input"),
+ ("PORT1", "8", "-2", "output"),
+ ("PORT2", "0", "0", "inout"),
+ ("PORT3", "16", "8", "input"),
+ ("PORT4", "3", "0", "output"),
+ ]
tokens = ["("]
first_run = True
for p in expected:
@@ -192,39 +274,79 @@ def test_module_header_all_present(self):
parser.parse_module_header_ports()
- assert len(parser.current_definition.ports) == len(expected), \
- "port count mismatch definition: " + str(len(parser.current_definition.ports)) + " expected: " + str(len(expected))
+ assert len(parser.current_definition.ports) == len(expected), (
+ "port count mismatch definition: "
+ + str(len(parser.current_definition.ports))
+ + " expected: "
+ + str(len(expected))
+ )
for i in range(len(expected)):
- assert expected[i][0] == parser.current_definition.ports[i].name,\
- "ports names don't match. Definition: " + parser.current_definition.ports[i].name + " expected " + expected[i][0]
+ assert expected[i][0] == parser.current_definition.ports[i].name, (
+ "ports names don't match. Definition: "
+ + parser.current_definition.ports[i].name
+ + " expected "
+ + expected[i][0]
+ )
expected_lower = min(int(expected[i][2]), int(expected[i][1]))
definition_lower = parser.current_definition.ports[i].lower_index
- expected_width = max(int(expected[i][2]), int(expected[i][1])) - expected_lower + 1
+ expected_width = (
+ max(int(expected[i][2]), int(expected[i][1])) - expected_lower + 1
+ )
definition_width = len(parser.current_definition.ports[i].pins)
- assert expected_lower == definition_lower, \
- "lower indicies do not match up expected " + str(expected_lower) + " but got " + str(definition_lower)
-
- assert expected_width == definition_width, \
- "widths do not match up expected " + str(expected_width) + " but got " + str(definition_width)
+ assert expected_lower == definition_lower, (
+ "lower indicies do not match up expected "
+ + str(expected_lower)
+ + " but got "
+ + str(definition_lower)
+ )
+
+ assert expected_width == definition_width, (
+ "widths do not match up expected "
+ + str(expected_width)
+ + " but got "
+ + str(definition_width)
+ )
expected_direction = vt.string_to_port_direction(expected[i][3])
definition_direction = parser.current_definition.ports[i].direction
- assert expected_direction == definition_direction, \
- "directions do not match up expected " + str(expected_direction) + " but got " + definition_direction
+ assert expected_direction == definition_direction, (
+ "directions do not match up expected "
+ + str(expected_direction)
+ + " but got "
+ + definition_direction
+ )
def test_port_aliasing(self):
parser = VerilogParser()
- token_list = [".", "portName", "(", "{", "cable1", ",", "cable2", ",", "cable3", "}", ")"]
+ token_list = [
+ ".",
+ "portName",
+ "(",
+ "{",
+ "cable1",
+ ",",
+ "cable2",
+ ",",
+ "cable3",
+ "}",
+ ")",
+ ]
parser.tokenizer = self.TestTokenizer(token_list)
d = sdn.Definition()
parser.current_definition = d
parser.parse_module_header_port_alias()
- assert len(d.ports) == 1, "definition has the wrong number of ports, should have 1 has " + str(len(d.ports))
- assert d.ports[0].name == "portName", "port has the wrong name it should be portName but is " + d.ports[0].name
+ assert (
+ len(d.ports) == 1
+ ), "definition has the wrong number of ports, should have 1 has " + str(
+ len(d.ports)
+ )
+ assert d.ports[0].name == "portName", (
+ "port has the wrong name it should be portName but is " + d.ports[0].name
+ )
assert len(d.ports[0].pins) == 3
assert len(d.cables) == 3
names = [d.cables[0].name, d.cables[1].name, d.cables[2].name]
@@ -248,17 +370,33 @@ def test_port_aliasing_single(self):
assert d.cables[0].name == "cable1"
def test_non_zero_lower_port_index(self):
- '''this test based on an issue found while parsing riscv_multi_core.v in the support files
- to see the problem lines that caused this test see line 89 and line 41'''
+ """this test based on an issue found while parsing riscv_multi_core.v in the support files
+ to see the problem lines that caused this test see line 89 and line 41"""
parser = VerilogParser()
- token_list = ["module", "alu", "(", "instruction", ")", ";", "output", "[", "27", ":", "26", "]", "instruction", ";", "endmodule"]
+ token_list = [
+ "module",
+ "alu",
+ "(",
+ "instruction",
+ ")",
+ ";",
+ "output",
+ "[",
+ "27",
+ ":",
+ "26",
+ "]",
+ "instruction",
+ ";",
+ "endmodule",
+ ]
tokenizer = self.TestTokenizer(token_list)
parser.tokenizer = tokenizer
- parser.current_library = sdn.Library(name = "TestLibrary")
+ parser.current_library = sdn.Library(name="TestLibrary")
parser.netlist = sdn.Netlist()
parser.netlist.add_library(parser.current_library)
-
+
parser.parse_module()
assert len(parser.current_definition.ports) == 1
@@ -276,19 +414,35 @@ def test_non_zero_lower_port_index(self):
assert w.pins[0] in p.pins
def test_port_cable_resize_post_creation(self):
- '''we need a test that creates a port and then resizes it on definition
-
+ """we need a test that creates a port and then resizes it on definition
+
module something(port);
input [3:0] port;
- endmodule'''
+ endmodule"""
parser = VerilogParser()
- token_list = ["module", "alu", "(", "instruction", ")", ";", "output", "[", "3", ":", "0", "]", "instruction", ";", "endmodule"]
+ token_list = [
+ "module",
+ "alu",
+ "(",
+ "instruction",
+ ")",
+ ";",
+ "output",
+ "[",
+ "3",
+ ":",
+ "0",
+ "]",
+ "instruction",
+ ";",
+ "endmodule",
+ ]
tokenizer = self.TestTokenizer(token_list)
parser.tokenizer = tokenizer
- parser.current_library = sdn.Library(name = "TestLibrary")
+ parser.current_library = sdn.Library(name="TestLibrary")
parser.netlist = sdn.Netlist()
parser.netlist.add_library(parser.current_library)
-
+
parser.parse_module()
assert len(parser.current_definition.ports) == 1
@@ -306,17 +460,42 @@ def test_port_cable_resize_post_creation(self):
assert w.pins[0] in p.pins
def test_port_resize_on_aliased_port(self):
- '''example of this found in sha3_core.v on line 63176 or 63177 something to do with \\byte_num[0] '''
- tokens = ["module", "keccak", "(",\
- '.','byte_num','(','{','\\byte_num[2] ',',','\\byte_num[1] ', ',','\\byte_num[0] ','}',')',\
- ")", ";", "input", '\\byte_num[0] ', ';', 'input', '\\byte_num[1] ', ';', 'input', '\\byte_num[2] ',';', "endmodule"]
+ """example of this found in sha3_core.v on line 63176 or 63177 something to do with \\byte_num[0]"""
+ tokens = [
+ "module",
+ "keccak",
+ "(",
+ ".",
+ "byte_num",
+ "(",
+ "{",
+ "\\byte_num[2] ",
+ ",",
+ "\\byte_num[1] ",
+ ",",
+ "\\byte_num[0] ",
+ "}",
+ ")",
+ ")",
+ ";",
+ "input",
+ "\\byte_num[0] ",
+ ";",
+ "input",
+ "\\byte_num[1] ",
+ ";",
+ "input",
+ "\\byte_num[2] ",
+ ";",
+ "endmodule",
+ ]
tokenizer = self.TestTokenizer(tokens)
parser = VerilogParser()
parser.tokenizer = tokenizer
- parser.current_library = sdn.Library(name = "TestLibrary")
+ parser.current_library = sdn.Library(name="TestLibrary")
parser.netlist = sdn.Netlist()
parser.netlist.add_library(parser.current_library)
-
+
parser.parse_module()
assert len(parser.current_definition.ports) == 1
@@ -325,24 +504,21 @@ def test_port_resize_on_aliased_port(self):
for c in parser.current_definition.cables:
names.append(c.name)
assert len(c.wires) == 1
- assert '\\byte_num[2]' in names
- assert '\\byte_num[1]' in names
- assert '\\byte_num[0]' in names
- assert parser.current_definition.ports[0].name == 'byte_num'
-
-
+ assert "\\byte_num[2]" in names
+ assert "\\byte_num[1]" in names
+ assert "\\byte_num[0]" in names
+ assert parser.current_definition.ports[0].name == "byte_num"
def test_parse_empty_module_header(self):
- '''example in bram.v in the support files on line 18'''
+ """example in bram.v in the support files on line 18"""
tokens = ["(", ")", ";"]
tokenizer = self.TestTokenizer(tokens)
parser = VerilogParser()
parser.tokenizer = tokenizer
parser.current_definition = sdn.Definition
- parser.parse_module_header() #intent is to just make sure this does not crash
- #todo add some aserts to check to make sure the number of cables and ports is still 0
-
+ parser.parse_module_header() # intent is to just make sure this does not crash
+ # todo add some aserts to check to make sure the number of cables and ports is still 0
###################################################
##Array Slicing
@@ -356,8 +532,8 @@ def test_array_slicing_good_single(self):
parser = VerilogParser()
parser.tokenizer = tokenizer
left, right = parser.parse_brackets()
- assert(left == left_expected)
- assert(right == right_expected)
+ assert left == left_expected
+ assert right == right_expected
def test_array_slicing_good_both(self):
left_expected = 2334
@@ -367,8 +543,8 @@ def test_array_slicing_good_both(self):
parser = VerilogParser()
parser.tokenizer = tokenizer
left, right = parser.parse_brackets()
- assert(left == left_expected)
- assert(right == right_expected)
+ assert left == left_expected
+ assert right == right_expected
@unittest.expectedFailure
def test_array_slicing_bad_colon(self):
@@ -379,9 +555,9 @@ def test_array_slicing_bad_colon(self):
parser = VerilogParser()
parser.tokenizer = tokenizer
left, right = parser.parse_brackets()
- assert(left == left_expected)
- assert(right == right_expected)
-
+ assert left == left_expected
+ assert right == right_expected
+
@unittest.expectedFailure
def test_array_slicing_bad_ending(self):
left_expected = 2334
@@ -391,8 +567,8 @@ def test_array_slicing_bad_ending(self):
parser = VerilogParser()
parser.tokenizer = tokenizer
left, right = parser.parse_brackets()
- assert(left == left_expected)
- assert(right == right_expected)
+ assert left == left_expected
+ assert right == right_expected
@unittest.expectedFailure
def test_array_slicing_bad_non_numbers(self):
@@ -403,9 +579,8 @@ def test_array_slicing_bad_non_numbers(self):
parser = VerilogParser()
parser.tokenizer = tokenizer
left, right = parser.parse_brackets()
- assert(left == left_expected)
- assert(right == right_expected)
-
+ assert left == left_expected
+ assert right == right_expected
###################################################
##Cable Creation and modification
@@ -413,128 +588,159 @@ def test_array_slicing_bad_non_numbers(self):
def init_cable_creation(self):
parser = VerilogParser()
-
+
my_def = sdn.Definition()
my_def.name = "testing_definition"
c1 = my_def.create_cable()
- c1.name = "preexisting1" #[15:8]
+ c1.name = "preexisting1" # [15:8]
c1.create_wires(8)
c1.lower_index = 8
c2 = my_def.create_cable()
- c2.name = "preexisting2" #[15:0]
+ c2.name = "preexisting2" # [15:0]
c2.create_wires(16)
c3 = my_def.create_cable()
- c3.name = "preexisting3" #[19:16]
+ c3.name = "preexisting3" # [19:16]
c3.is_downto = False
c3.lower_index = 16
c3.create_wires(4)
-
+
parser.current_definition = my_def
return parser, c1, c2, c3
def add_to_cable_helper(self, tests, parser):
- #tests is a list of tuples that contain
- #name,left,right,type,cable,expected_lower,expected_width, expected_downto
+ # tests is a list of tuples that contain
+ # name,left,right,type,cable,expected_lower,expected_width, expected_downto
for entry in tests:
- name, left_index, right_index, var_type, cable, expected_lower, expected_width = entry
- expected_downto = cable.is_downto #the cable should not update it's downto once that has been decided.
+ (
+ name,
+ left_index,
+ right_index,
+ var_type,
+ cable,
+ expected_lower,
+ expected_width,
+ ) = entry
+ expected_downto = (
+ cable.is_downto
+ ) # the cable should not update it's downto once that has been decided.
c = parser.create_or_update_cable(name, left_index, right_index, var_type)
assert c is cable, "the cable is not the expected cable, " + name
- assert len(c.wires) == expected_width, "the cable is not the proper width, " + name
- assert c.lower_index == expected_lower, "the cable does not have the proper lower index, " + name
+ assert len(c.wires) == expected_width, (
+ "the cable is not the proper width, " + name
+ )
+ assert c.lower_index == expected_lower, (
+ "the cable does not have the proper lower index, " + name
+ )
assert c.is_downto == expected_downto, "the cable changed downto, " + name
-
def create_cable_helper(self, tests, parser):
- #tests is a list of tuples that contain
- #name,left,right,type,cable,expected_lower,expected_width, expected_downto
+ # tests is a list of tuples that contain
+ # name,left,right,type,cable,expected_lower,expected_width, expected_downto
start_size = len(parser.current_definition.cables)
count = 0
for entry in tests:
count += 1
- name, left_index, right_index, var_type, cable, expected_lower, expected_width, expected_downto = entry
+ (
+ name,
+ left_index,
+ right_index,
+ var_type,
+ cable,
+ expected_lower,
+ expected_width,
+ expected_downto,
+ ) = entry
c = parser.create_or_update_cable(name, left_index, right_index, var_type)
- assert len(c.wires) == expected_width, "the cable is not the proper width, " + name
- assert c.lower_index == expected_lower, "the cable does not have the proper lower index, " + name
+ assert len(c.wires) == expected_width, (
+ "the cable is not the proper width, " + name
+ )
+ assert c.lower_index == expected_lower, (
+ "the cable does not have the proper lower index, " + name
+ )
assert c.is_downto == expected_downto
- assert len(parser.current_definition.cables) == count + start_size, "the wrong number of cables were added"
-
+ assert (
+ len(parser.current_definition.cables) == count + start_size
+ ), "the wrong number of cables were added"
def test_add_to_front_of_cable(self):
parser, c1, c2, c3 = self.init_cable_creation()
-
- tests =\
- [("preexisting1", 15, 0, None, c1, 0, 16),\
- ("preexisting2", 0, -16, None, c2, -16, 32),\
- ("preexisting3", 17, 0, None, c3, 0, 20)]
- self.add_to_cable_helper(tests, parser)
+ tests = [
+ ("preexisting1", 15, 0, None, c1, 0, 16),
+ ("preexisting2", 0, -16, None, c2, -16, 32),
+ ("preexisting3", 17, 0, None, c3, 0, 20),
+ ]
+ self.add_to_cable_helper(tests, parser)
def test_add_to_back_of_cable(self):
parser, c1, c2, c3 = self.init_cable_creation()
-
- tests =\
- [("preexisting1", 31, 16, None, c1, 8, 24),\
- ("preexisting2", 31, 8, None, c2, 0, 32),\
- ("preexisting3", 63, 0, None, c3, 0, 64)]
- self.add_to_cable_helper(tests, parser)
+ tests = [
+ ("preexisting1", 31, 16, None, c1, 8, 24),
+ ("preexisting2", 31, 8, None, c2, 0, 32),
+ ("preexisting3", 63, 0, None, c3, 0, 64),
+ ]
+ self.add_to_cable_helper(tests, parser)
def test_create_cable(self):
parser, c1, c2, c3 = self.init_cable_creation()
-
- tests =\
- [("new_cable1", 31, 16, None, None, 16, 16, True),\
- ("new_cable2", 0, -7, None, None, -7, 8, True),\
- ("new_cable3", 63, 0, None, None, 0, 64, True)]
- self.create_cable_helper(tests, parser)
+ tests = [
+ ("new_cable1", 31, 16, None, None, 16, 16, True),
+ ("new_cable2", 0, -7, None, None, -7, 8, True),
+ ("new_cable3", 63, 0, None, None, 0, 64, True),
+ ]
+ self.create_cable_helper(tests, parser)
def test_create_cable_downto(self):
parser, c1, c2, c3 = self.init_cable_creation()
-
- tests =\
- [("new_cable1", 7, 0, None, None, 0, 8, True),\
- ("new_cable2", 0, 7, None, None, 0, 8, False)]
+
+ tests = [
+ ("new_cable1", 7, 0, None, None, 0, 8, True),
+ ("new_cable2", 0, 7, None, None, 0, 8, False),
+ ]
self.create_cable_helper(tests, parser)
def test_change_cable_type(self):
- pass #TODO
+ pass # TODO
def test_dont_change_cable(self):
parser, c1, c2, c3 = self.init_cable_creation()
-
- tests =\
- [("preexisting1", 15, 8, None, c1, 8, 8),\
- ("preexisting2", 15, 0, None, c2, 0, 16),\
- ("preexisting3", 19, 16, None, c3, 16, 4)]
+
+ tests = [
+ ("preexisting1", 15, 8, None, c1, 8, 8),
+ ("preexisting2", 15, 0, None, c2, 0, 16),
+ ("preexisting3", 19, 16, None, c3, 16, 4),
+ ]
self.add_to_cable_helper(tests, parser)
def test_single_index_cable(self):
parser, c1, c2, c3 = self.init_cable_creation()
- tests_create =\
- [("new_cable1", 31, None, None, None, 31, 1, True),\
- ("new_cable2", 0, None, None, None, 0, 1, True),\
- ("new_cable3", 63, None, None, None, 63, 1, True)]
+ tests_create = [
+ ("new_cable1", 31, None, None, None, 31, 1, True),
+ ("new_cable2", 0, None, None, None, 0, 1, True),
+ ("new_cable3", 63, None, None, None, 63, 1, True),
+ ]
self.create_cable_helper(tests_create, parser)
parser, c1, c2, c3 = self.init_cable_creation()
- tests_modify =\
- [("preexisting1", 0, None, None, c1, 0, 16),\
- ("preexisting2", 8, None, None, c2, 0, 16),\
- ("preexisting3", 0, None, None, c3, 0, 20)]
+ tests_modify = [
+ ("preexisting1", 0, None, None, c1, 0, 16),
+ ("preexisting2", 8, None, None, c2, 0, 16),
+ ("preexisting3", 0, None, None, c3, 0, 20),
+ ]
self.add_to_cable_helper(tests_modify, parser)
-
def test_change_cable_downto(self):
- #i don't think the cable downto-ness should ever change. this is tested in the add to cable helper
+ # i don't think the cable downto-ness should ever change. this is tested in the add to cable helper
parser, c1, c2, c3 = self.init_cable_creation()
-
- tests =\
- [("preexisting1", 15, 8, None, c1, 8, 8),\
- ("preexisting1", 8, 15, None, c1, 8, 8)]
+
+ tests = [
+ ("preexisting1", 15, 8, None, c1, 8, 8),
+ ("preexisting1", 8, 15, None, c1, 8, 8),
+ ]
self.add_to_cable_helper(tests, parser)
def test_cable_prepend_wires(self):
@@ -557,7 +763,7 @@ def test_cable_prepend_wires(self):
print(c1_wires)
print()
-
+
prepend_count = 8
parser.prepend_wires(c1, prepend_count)
@@ -568,7 +774,9 @@ def test_cable_prepend_wires(self):
assert len(c1.wires) == prepend_count + c1_width, "tried to add 8 wires to c1"
assert c1.lower_index == c1_lower - prepend_count
for wire in c1.wires[:prepend_count]:
- assert wire not in c1_wires, "a wire was in the wrong location for the prepend"
+ assert (
+ wire not in c1_wires
+ ), "a wire was in the wrong location for the prepend"
for wire in c1.wires[prepend_count:]:
assert wire in c1_wires, "a wire seems to have disappeared"
@@ -576,7 +784,9 @@ def test_cable_prepend_wires(self):
assert len(c2.wires) == prepend_count + c2_width, "tried to add 8 wires to c2"
assert c2.lower_index == c2_lower - prepend_count
for wire in c2.wires[:prepend_count]:
- assert wire not in c2_wires, "a wire was in the wrong location for the prepend"
+ assert (
+ wire not in c2_wires
+ ), "a wire was in the wrong location for the prepend"
for wire in c2.wires[prepend_count:]:
assert wire in c2_wires, "a wire seems to have disappeared"
@@ -584,7 +794,9 @@ def test_cable_prepend_wires(self):
assert len(c3.wires) == prepend_count + c3_width, "tried to add 8 wires to c3"
assert c3.lower_index == c3_lower - prepend_count
for wire in c3.wires[:prepend_count]:
- assert wire not in c3_wires, "a wire was in the wrong location for the prepend"
+ assert (
+ wire not in c3_wires
+ ), "a wire was in the wrong location for the prepend"
for wire in c3.wires[prepend_count:]:
assert wire in c3_wires, "a wire seems to have disappeared"
@@ -605,14 +817,16 @@ def test_cable_postpend_wires(self):
c3_wires = set()
for wire in c3.wires:
c3_wires.add(wire)
-
+
postpend_count = 8
parser.postpend_wires(c1, postpend_count)
assert len(c1.wires) == postpend_count + c1_width, "tried to add 8 wires to c1"
assert c1.lower_index == c1_lower
for wire in c1.wires[c1_width:]:
- assert wire not in c1_wires, "a wire was in the wrong location for the postpend"
+ assert (
+ wire not in c1_wires
+ ), "a wire was in the wrong location for the postpend"
for wire in c1.wires[:c1_width]:
assert wire in c1_wires, "a wire seems to have disappeared"
@@ -620,7 +834,9 @@ def test_cable_postpend_wires(self):
assert len(c2.wires) == postpend_count + c2_width, "tried to add 8 wires to c2"
assert c2.lower_index == c2_lower
for wire in c2.wires[c2_width:]:
- assert wire not in c2_wires, "a wire was in the wrong location for the postpend"
+ assert (
+ wire not in c2_wires
+ ), "a wire was in the wrong location for the postpend"
for wire in c2.wires[:c2_width]:
assert wire in c2_wires, "a wire seems to have disappeared"
@@ -628,29 +844,35 @@ def test_cable_postpend_wires(self):
assert len(c3.wires) == postpend_count + c3_width, "tried to add 8 wires to c3"
assert c3.lower_index == c3_lower
for wire in c3.wires[c3_width:]:
- assert wire not in c3_wires, "a wire was in the wrong location for the postpend"
+ assert (
+ wire not in c3_wires
+ ), "a wire was in the wrong location for the postpend"
for wire in c3.wires[:c3_width]:
assert wire in c3_wires, "a wire seems to have disappeared"
def test_populate_new_cable(self):
parser = VerilogParser()
-
- test_data = [("test_name", 2, 0, "wire"), ("\\escaped#$@_[213] ", 15,8,"wire"), ("some_name", 7,4,"reg")]
+
+ test_data = [
+ ("test_name", 2, 0, "wire"),
+ ("\\escaped#$@_[213] ", 15, 8, "wire"),
+ ("some_name", 7, 4, "reg"),
+ ]
for name, left, right, cable_type in test_data:
cable = sdn.Cable()
- parser.populate_new_cable(cable,name,left,right,cable_type)
+ parser.populate_new_cable(cable, name, left, right, cable_type)
assert cable.name == name
assert cable.is_downto == (left >= right)
assert cable["VERILOG.CableType"] == cable_type
- assert cable.lower_index == min(left,right)
+ assert cable.lower_index == min(left, right)
def test_parse_variable_instantiation(self):
pass
def test_parse_cable_concatenation(self):
parser = VerilogParser()
-
+
wire_names = ["wire1", "wire2", "wire3", "wire4"]
token_list = ["{"]
first = True
@@ -668,13 +890,27 @@ def test_parse_cable_concatenation(self):
wires = parser.parse_cable_concatenation()
- assert len(wires) == len(wire_names), "expected " + str(len(wire_names)) + " wires to be created instead got " + str(len(wires))
- assert len(parser.current_definition.cables) == len(wire_names), "expected " + str(len(wire_names)) + " cables to be created instead got " + str(len(parser.current_definition.cables))
+ assert len(wires) == len(wire_names), (
+ "expected "
+ + str(len(wire_names))
+ + " wires to be created instead got "
+ + str(len(wires))
+ )
+ assert len(parser.current_definition.cables) == len(wire_names), (
+ "expected "
+ + str(len(wire_names))
+ + " cables to be created instead got "
+ + str(len(parser.current_definition.cables))
+ )
for i in range(len(wire_names)):
- assert parser.current_definition.cables[i].name == wire_names[i], " the wires created do not have matching names"
- assert wires[i].cable.name == wire_names[i], "the wires returned are not in order."
-
+ assert (
+ parser.current_definition.cables[i].name == wire_names[i]
+ ), " the wires created do not have matching names"
+ assert (
+ wires[i].cable.name == wire_names[i]
+ ), "the wires returned are not in order."
+
############################################################################
##Instance instantiation
############################################################################
@@ -687,10 +923,12 @@ def test_parse_empty_port_map(self):
definition = sdn.Definition()
parser.current_definition = definition
parser.current_instance = definition.create_child()
- parser.current_instance.reference = parser.blackbox_holder.get_blackbox("definition_name")
-
+ parser.current_instance.reference = parser.blackbox_holder.get_blackbox(
+ "definition_name"
+ )
+
port_name = "port_name"
-
+
tokens = [".", port_name, "(", ")"]
tokenizer = self.TestTokenizer(tokens)
@@ -707,7 +945,22 @@ def test_parse_empty_port_map(self):
def test_parse_parameter_map(self):
parser = VerilogParser()
- tokens = ["#", "(", ".", "INIT", "(", "1'h123210", ")", ",", ".", "PARAM2", "(", "1'b0", ")", ")"]
+ tokens = [
+ "#",
+ "(",
+ ".",
+ "INIT",
+ "(",
+ "1'h123210",
+ ")",
+ ",",
+ ".",
+ "PARAM2",
+ "(",
+ "1'b0",
+ ")",
+ ")",
+ ]
tokenizer = self.TestTokenizer(tokens)
parser.tokenizer = tokenizer
@@ -716,7 +969,7 @@ def test_parse_parameter_map(self):
params = parser.parse_parameter_mapping()
assert len(params.keys()) == 2
- assert params['INIT'] == "1'h123210"
+ assert params["INIT"] == "1'h123210"
assert params["PARAM2"] == "1'b0"
def test_parse_port_map(self):
@@ -743,7 +996,9 @@ def test_parse_port_map(self):
parser.current_definition = sdn.Definition()
parser.current_instance = parser.current_definition.create_child()
- parser.current_instance.reference = parser.blackbox_holder.get_blackbox("definition1")
+ parser.current_instance.reference = parser.blackbox_holder.get_blackbox(
+ "definition1"
+ )
parser.parse_port_mapping()
@@ -753,33 +1008,31 @@ def test_parse_port_map(self):
for p in parser.current_instance.reference.ports:
assert len(p.pins) == 1
for c in parser.current_definition.cables:
- assert len(c.wires) ==1
+ assert len(c.wires) == 1
for i in range(len(port_names)):
assert parser.current_definition.cables[i].name == cable_names[i]
assert parser.current_instance.reference.ports[i].name == port_names[i]
for p in parser.current_definition.cables[i].wires[0].pins:
assert p in parser.current_instance.pins
-
def test_parse_parameter_map_single(self):
parser = VerilogParser()
- tokens = [".","INIT", "(", "1hABCD1230", ")"]
+ tokens = [".", "INIT", "(", "1hABCD1230", ")"]
tokenizer = self.TestTokenizer(tokens)
parser.tokenizer = tokenizer
- k,v = parser.parse_parameter_map_single()
+ k, v = parser.parse_parameter_map_single()
assert k == "INIT"
assert v == "1hABCD1230"
-
def test_parse_parameter_map_single_multi_token_value(self):
parser = VerilogParser()
- tokens = [".","INIT", "(", "200.000000", ")"]
+ tokens = [".", "INIT", "(", "200.000000", ")"]
tokenizer = self.TestTokenizer(tokens)
parser.tokenizer = tokenizer
- k,v = parser.parse_parameter_map_single()
+ k, v = parser.parse_parameter_map_single()
assert k == "INIT"
assert v == "200.000000"
@@ -790,7 +1043,9 @@ def test_parse_port_map_single(self):
definition = sdn.Definition()
parser.current_definition = definition
parser.current_instance = definition.create_child()
- parser.current_instance.reference = parser.blackbox_holder.get_blackbox("definition_name")
+ parser.current_instance.reference = parser.blackbox_holder.get_blackbox(
+ "definition_name"
+ )
cable = definition.create_cable()
cable_name = "cable_name"
cable_width = 4
@@ -835,8 +1090,8 @@ def test_parse_implicitly_mapped_ports(self):
instance = next(netlist.get_instances("my_inst"))
self.assertEqual(instance.name, "my_inst")
connections = ["clk_c", "VCC_net", "out"]
- for i in range(0,3):
- port = next(instance.get_ports("port_"+str(i)))
+ for i in range(0, 3):
+ port = next(instance.get_ports("port_" + str(i)))
self.assertEqual(len(port.pins), 1)
for pin in port.get_pins(selection=Selection.OUTSIDE):
self.assertEqual(pin.wire.cable.name, connections[i])
@@ -862,8 +1117,8 @@ def test_parse_empty_mapped_ports(self):
# my_inst has nothing attached
instance = next(netlist.get_instances("my_inst"))
self.assertEqual(instance.name, "my_inst")
- for i in range(0,3):
- port = next(instance.get_ports("port_"+str(i)))
+ for i in range(0, 3):
+ port = next(instance.get_ports("port_" + str(i)))
self.assertEqual(len(port.pins), 1)
for pin in port.get_pins(selection=Selection.OUTSIDE):
self.assertEqual(pin.wire, None)
@@ -871,8 +1126,8 @@ def test_parse_empty_mapped_ports(self):
# my_whitespace_inst has nothing attached and doesn't immediately have a closing paren
instance = next(netlist.get_instances("my_whitespace_inst"))
self.assertEqual(instance.name, "my_whitespace_inst")
- for i in range(0,3):
- port = next(instance.get_ports("port_"+str(i)))
+ for i in range(0, 3):
+ port = next(instance.get_ports("port_" + str(i)))
self.assertEqual(len(port.pins), 1)
for pin in port.get_pins(selection=Selection.OUTSIDE):
self.assertEqual(pin.wire, None)
@@ -885,130 +1140,175 @@ def test_parse_empty_mapped_ports(self):
def init_port_creation(self):
parser = VerilogParser()
-
+
my_def = sdn.Definition()
my_def.name = "testing_definition"
c1 = my_def.create_port()
- c1.name = "preexisting1" #[15:8]
+ c1.name = "preexisting1" # [15:8]
c1.create_pins(8)
c1.lower_index = 8
c2 = my_def.create_port()
- c2.name = "preexisting2" #[15:0]
+ c2.name = "preexisting2" # [15:0]
c2.create_pins(16)
c3 = my_def.create_port()
- c3.name = "preexisting3" #[19:16]
+ c3.name = "preexisting3" # [19:16]
c3.is_downto = False
c3.lower_index = 16
c3.create_pins(4)
-
+
parser.current_definition = my_def
return parser, c1, c2, c3
def add_to_port_helper(self, tests, parser):
- #tests is a list of tuples that contain
- #name,left,right,direction,port,expected_lower,expected_width, expected_downto
+ # tests is a list of tuples that contain
+ # name,left,right,direction,port,expected_lower,expected_width, expected_downto
for entry in tests:
- name, left_index, right_index, direction, port, expected_lower, expected_width = entry
- expected_downto = port.is_downto #the port should not update it's downto once that has been decided.
+ (
+ name,
+ left_index,
+ right_index,
+ direction,
+ port,
+ expected_lower,
+ expected_width,
+ ) = entry
+ expected_downto = (
+ port.is_downto
+ ) # the port should not update it's downto once that has been decided.
c = parser.create_or_update_port(name, left_index, right_index, direction)
assert c is port, "the port is not the expected port, " + name
- assert len(c.pins) == expected_width, "the port is not the proper width, " + name
- assert c.lower_index == expected_lower, "the port does not have the proper lower index, " + name
+ assert len(c.pins) == expected_width, (
+ "the port is not the proper width, " + name
+ )
+ assert c.lower_index == expected_lower, (
+ "the port does not have the proper lower index, " + name
+ )
assert c.is_downto == expected_downto, "the port changed downto, " + name
- assert c.direction == direction, "the port is no longer "+ direction+ " it is now "+ c.direction+ " " + name
-
+ assert c.direction == direction, (
+ "the port is no longer "
+ + direction
+ + " it is now "
+ + c.direction
+ + " "
+ + name
+ )
def create_port_helper(self, tests, parser):
- #tests is a list of tuples that contain
- #name,left,right,direction,port,expected_lower,expected_width, expected_downto
+ # tests is a list of tuples that contain
+ # name,left,right,direction,port,expected_lower,expected_width, expected_downto
start_size = len(parser.current_definition.ports)
count = 0
for entry in tests:
count += 1
- name, left_index, right_index, direction, port, expected_lower, expected_width, expected_downto = entry
+ (
+ name,
+ left_index,
+ right_index,
+ direction,
+ port,
+ expected_lower,
+ expected_width,
+ expected_downto,
+ ) = entry
c = parser.create_or_update_port(name, left_index, right_index, direction)
- assert len(c.pins) == expected_width, "the port is not the proper width, " + name
- assert c.lower_index == expected_lower, "the port does not have the proper lower index, " + name
+ assert len(c.pins) == expected_width, (
+ "the port is not the proper width, " + name
+ )
+ assert c.lower_index == expected_lower, (
+ "the port does not have the proper lower index, " + name
+ )
assert c.is_downto == expected_downto
- assert c.direction == direction, "the port is no longer " + direction + " it is now " + c.direction+ " " + name
- assert len(parser.current_definition.ports) == count + start_size, "the wrong number of ports were added"
-
+ assert c.direction == direction, (
+ "the port is no longer "
+ + direction
+ + " it is now "
+ + c.direction
+ + " "
+ + name
+ )
+ assert (
+ len(parser.current_definition.ports) == count + start_size
+ ), "the wrong number of ports were added"
def test_add_to_front_of_port(self):
parser, c1, c2, c3 = self.init_port_creation()
-
- tests =\
- [("preexisting1", 15, 0, sdn.Port.Direction.IN, c1, 0, 16),\
- ("preexisting2", 0, -16, sdn.Port.Direction.OUT, c2, -16, 32),\
- ("preexisting3", 17, 0, sdn.Port.Direction.INOUT, c3, 0, 20)]
- self.add_to_port_helper(tests, parser)
+ tests = [
+ ("preexisting1", 15, 0, sdn.Port.Direction.IN, c1, 0, 16),
+ ("preexisting2", 0, -16, sdn.Port.Direction.OUT, c2, -16, 32),
+ ("preexisting3", 17, 0, sdn.Port.Direction.INOUT, c3, 0, 20),
+ ]
+ self.add_to_port_helper(tests, parser)
def test_add_to_back_of_port(self):
parser, c1, c2, c3 = self.init_port_creation()
-
- tests =\
- [("preexisting1", 31, 16, sdn.Port.Direction.UNDEFINED, c1, 8, 24),\
- ("preexisting2", 31, 8, sdn.Port.Direction.IN, c2, 0, 32),\
- ("preexisting3", 63, 0, sdn.Port.Direction.OUT, c3, 0, 64)]
- self.add_to_port_helper(tests, parser)
+ tests = [
+ ("preexisting1", 31, 16, sdn.Port.Direction.UNDEFINED, c1, 8, 24),
+ ("preexisting2", 31, 8, sdn.Port.Direction.IN, c2, 0, 32),
+ ("preexisting3", 63, 0, sdn.Port.Direction.OUT, c3, 0, 64),
+ ]
+ self.add_to_port_helper(tests, parser)
def test_create_port(self):
parser, c1, c2, c3 = self.init_port_creation()
-
- tests =\
- [("new_port1", 31, 16, sdn.Port.Direction.IN, None, 16, 16, True),\
- ("new_port2", 0, -7, sdn.Port.Direction.INOUT, None, -7, 8, True),\
- ("new_port3", 63, 0, sdn.Port.Direction.UNDEFINED, None, 0, 64, True)]
- self.create_port_helper(tests, parser)
+ tests = [
+ ("new_port1", 31, 16, sdn.Port.Direction.IN, None, 16, 16, True),
+ ("new_port2", 0, -7, sdn.Port.Direction.INOUT, None, -7, 8, True),
+ ("new_port3", 63, 0, sdn.Port.Direction.UNDEFINED, None, 0, 64, True),
+ ]
+ self.create_port_helper(tests, parser)
def test_create_port_downto(self):
parser, c1, c2, c3 = self.init_port_creation()
-
- tests =\
- [("new_port1", 7, 0, sdn.Port.Direction.OUT, None, 0, 8, True),\
- ("new_port2", 0, 7, sdn.Port.Direction.INOUT, None, 0, 8, False)]
+
+ tests = [
+ ("new_port1", 7, 0, sdn.Port.Direction.OUT, None, 0, 8, True),
+ ("new_port2", 0, 7, sdn.Port.Direction.INOUT, None, 0, 8, False),
+ ]
self.create_port_helper(tests, parser)
def test_change_port_direction(self):
- pass #TODO not sure yet how I should deal with this.
+ pass # TODO not sure yet how I should deal with this.
def test_dont_change_port(self):
parser, c1, c2, c3 = self.init_port_creation()
-
- tests =\
- [("preexisting1", 15, 8, sdn.Port.Direction.OUT, c1, 8, 8),\
- ("preexisting2", 15, 0, sdn.Port.Direction.IN, c2, 0, 16),\
- ("preexisting3", 19, 16, sdn.Port.Direction.INOUT, c3, 16, 4)]
+
+ tests = [
+ ("preexisting1", 15, 8, sdn.Port.Direction.OUT, c1, 8, 8),
+ ("preexisting2", 15, 0, sdn.Port.Direction.IN, c2, 0, 16),
+ ("preexisting3", 19, 16, sdn.Port.Direction.INOUT, c3, 16, 4),
+ ]
self.add_to_port_helper(tests, parser)
def test_single_index_port(self):
parser, c1, c2, c3 = self.init_port_creation()
- tests_create =\
- [("new_port1", 31, None, sdn.Port.Direction.OUT, None, 31, 1, True),\
- ("new_port2", 0, None, sdn.Port.Direction.UNDEFINED, None, 0, 1, True),\
- ("new_port3", 63, None, sdn.Port.Direction.IN, None, 63, 1, True)]
+ tests_create = [
+ ("new_port1", 31, None, sdn.Port.Direction.OUT, None, 31, 1, True),
+ ("new_port2", 0, None, sdn.Port.Direction.UNDEFINED, None, 0, 1, True),
+ ("new_port3", 63, None, sdn.Port.Direction.IN, None, 63, 1, True),
+ ]
self.create_port_helper(tests_create, parser)
parser, c1, c2, c3 = self.init_port_creation()
- tests_modify =\
- [("preexisting1", 0, None, sdn.Port.Direction.INOUT, c1, 0, 16),\
- ("preexisting2", 8, None, sdn.Port.Direction.OUT, c2, 0, 16),\
- ("preexisting3", 0, None, sdn.Port.Direction.IN, c3, 0, 20)]
+ tests_modify = [
+ ("preexisting1", 0, None, sdn.Port.Direction.INOUT, c1, 0, 16),
+ ("preexisting2", 8, None, sdn.Port.Direction.OUT, c2, 0, 16),
+ ("preexisting3", 0, None, sdn.Port.Direction.IN, c3, 0, 20),
+ ]
self.add_to_port_helper(tests_modify, parser)
-
def test_change_port_downto(self):
- #i don't think the port downto-ness should ever change. this is tested in the add to port helper
+ # i don't think the port downto-ness should ever change. this is tested in the add to port helper
parser, c1, c2, c3 = self.init_port_creation()
-
- tests =\
- [("preexisting1", 15, 8, sdn.Port.Direction.UNDEFINED, c1, 8, 8),\
- ("preexisting1", 8, 15, sdn.Port.Direction.UNDEFINED, c1, 8, 8)]
+
+ tests = [
+ ("preexisting1", 15, 8, sdn.Port.Direction.UNDEFINED, c1, 8, 8),
+ ("preexisting1", 8, 15, sdn.Port.Direction.UNDEFINED, c1, 8, 8),
+ ]
self.add_to_port_helper(tests, parser)
def test_port_prepend_pins(self):
@@ -1031,7 +1331,7 @@ def test_port_prepend_pins(self):
print(c1_pins)
print()
-
+
prepend_count = 8
parser.prepend_pins(c1, prepend_count)
@@ -1079,14 +1379,16 @@ def test_port_postpend_pins(self):
c3_pins = set()
for pin in c3.pins:
c3_pins.add(pin)
-
+
postpend_count = 8
parser.postpend_pins(c1, postpend_count)
assert len(c1.pins) == postpend_count + c1_width, "tried to add 8 pins to c1"
assert c1.lower_index == c1_lower
for pin in c1.pins[c1_width:]:
- assert pin not in c1_pins, "a pin was in the wrong location for the postpend"
+ assert (
+ pin not in c1_pins
+ ), "a pin was in the wrong location for the postpend"
for pin in c1.pins[:c1_width]:
assert pin in c1_pins, "a pin seems to have disappeared"
@@ -1094,7 +1396,9 @@ def test_port_postpend_pins(self):
assert len(c2.pins) == postpend_count + c2_width, "tried to add 8 pins to c2"
assert c2.lower_index == c2_lower
for pin in c2.pins[c2_width:]:
- assert pin not in c2_pins, "a pin was in the wrong location for the postpend"
+ assert (
+ pin not in c2_pins
+ ), "a pin was in the wrong location for the postpend"
for pin in c2.pins[:c2_width]:
assert pin in c2_pins, "a pin seems to have disappeared"
@@ -1102,32 +1406,54 @@ def test_port_postpend_pins(self):
assert len(c3.pins) == postpend_count + c3_width, "tried to add 8 pins to c3"
assert c3.lower_index == c3_lower
for pin in c3.pins[c3_width:]:
- assert pin not in c3_pins, "a pin was in the wrong location for the postpend"
+ assert (
+ pin not in c3_pins
+ ), "a pin was in the wrong location for the postpend"
for pin in c3.pins[:c3_width]:
assert pin in c3_pins, "a pin seems to have disappeared"
def test_populate_new_port(self):
parser = VerilogParser()
-
- test_data = [("test_name", 2, 0, sdn.Port.Direction.IN), ("\\escaped#$@_[213] ", 15,8, sdn.Port.Direction.OUT), ("some_name", 7,4,sdn.Port.Direction.INOUT)]
+
+ test_data = [
+ ("test_name", 2, 0, sdn.Port.Direction.IN),
+ ("\\escaped#$@_[213] ", 15, 8, sdn.Port.Direction.OUT),
+ ("some_name", 7, 4, sdn.Port.Direction.INOUT),
+ ]
for name, left, right, direction in test_data:
port = sdn.Port()
- parser.populate_new_port(port,name,left,right,direction)
+ parser.populate_new_port(port, name, left, right, direction)
assert port.name == name
assert port.is_downto == (left >= right)
assert port.direction == direction
- assert port.lower_index == min(left,right)
+ assert port.lower_index == min(left, right)
def test_parse_port_declaration(self):
parser = VerilogParser()
count = 3
names = ["i", "o", "io"]
- token_list = ["input", names[0], ";", "output", "[", "3", ":", "0", "]", names[1], ";", "inout", "wire", names[2], ";"]
+ token_list = [
+ "input",
+ names[0],
+ ";",
+ "output",
+ "[",
+ "3",
+ ":",
+ "0",
+ "]",
+ names[1],
+ ";",
+ "inout",
+ "wire",
+ names[2],
+ ";",
+ ]
tokenizer = self.TestTokenizer(token_list)
parser.tokenizer = tokenizer
d = sdn.Definition()
-
+
parser.current_definition = d
for n in names:
@@ -1136,34 +1462,51 @@ def test_parse_port_declaration(self):
c.wires[0].connect_pin(p.pins[0])
for _ in range(count):
- parser.parse_port_declaration(dict())
-
+ parser.parse_port_declaration({})
@unittest.expectedFailure
def test_parse_port_declaration_failure(self):
parser = VerilogParser()
count = 3
names = ["i", "o", "io"]
- token_list = ["input", names[0], ";", "output", "[", "3", ":", "0", "]", names[1], ";", "inout", "wire", names[2], ";"]
+ token_list = [
+ "input",
+ names[0],
+ ";",
+ "output",
+ "[",
+ "3",
+ ":",
+ "0",
+ "]",
+ names[1],
+ ";",
+ "inout",
+ "wire",
+ names[2],
+ ";",
+ ]
tokenizer = self.TestTokenizer(token_list)
parser.tokenizer = tokenizer
d = sdn.Definition()
-
+
parser.current_definition = d
for n in names:
parser.create_or_update_port(n)
- #the ports are in the definition but not connected this should fail
+ # the ports are in the definition but not connected this should fail
for _ in range(count):
- parser.parse_port_declaration(properties = dict())
+ parser.parse_port_declaration(properties={})
def test_create_or_update_port_on_instance(self):
parser = VerilogParser()
parser.current_definition = sdn.Definition()
parser.current_instance = parser.current_definition.create_child()
- parser.current_instance.reference = parser.blackbox_holder.get_blackbox("definition1")
+ parser.current_instance.reference = parser.blackbox_holder.get_blackbox(
+ "definition1"
+ )
pins = parser.create_or_update_port_on_instance("port1", 1)
@@ -1177,8 +1520,9 @@ def test_create_or_update_port_on_instance(self):
############################################
def test_create_new_assignment_instance(self):
- '''make sure the name, and width make sense
- also take advantage of the setup to make sure the definition returned is the same for the same width'''
+ """make sure the name, and width make sense
+ also take advantage of the setup to make sure the definition returned is the same for the same width
+ """
parser = VerilogParser()
parser.netlist = sdn.Netlist()
parser.current_definition = sdn.Definition()
@@ -1189,7 +1533,7 @@ def test_create_new_assignment_instance(self):
assert instance.reference == parser.get_assignment_definition(width)
def test_create_new_assignment_definition(self):
- '''make sure the names, width and acutal connectivity make sense'''
+ """make sure the names, width and acutal connectivity make sense"""
parser = VerilogParser()
parser.netlist = sdn.Netlist()
parser.current_definition = sdn.Definition()
@@ -1201,22 +1545,19 @@ def test_create_new_assignment_definition(self):
assert len(definition.ports[1].pins) == width
assert len(definition.cables) == 0
-
-
def test_connect_assigned_wires(self):
- '''make sure the wires are actually connected to the instance and that the connectivity makes sense'''
+ """make sure the wires are actually connected to the instance and that the connectivity makes sense"""
parser = VerilogParser()
parser.netlist = sdn.Netlist()
parser.current_definition = sdn.Definition()
- o_cable = parser.current_definition.create_cable(name = "c1")
- i_cable = parser.current_definition.create_cable(name = "c2")
+ o_cable = parser.current_definition.create_cable(name="c1")
+ i_cable = parser.current_definition.create_cable(name="c2")
o_cable.create_wires(4)
i_cable.create_wires(4)
parser.connect_wires_for_assign(o_cable, 1, 0, i_cable, 3, 2)
-
def test_names_of_instances_are_different(self):
- '''make sure the names of multiple instances of the same width are different'''
+ """make sure the names of multiple instances of the same width are different"""
parser = VerilogParser()
parser.netlist = sdn.Netlist()
parser.current_definition = sdn.Definition()
@@ -1230,52 +1571,66 @@ def test_parse_assign(self):
parser = VerilogParser()
parser.netlist = sdn.Netlist()
parser.current_definition = sdn.Definition()
- tokens = ["assign", "cable1", "=", "cable2", ";", "assign", "SR2", "[", "2", "]", "=", "\\ ", ";"]
+ tokens = [
+ "assign",
+ "cable1",
+ "=",
+ "cable2",
+ ";",
+ "assign",
+ "SR2",
+ "[",
+ "2",
+ "]",
+ "=",
+ "\\ ",
+ ";",
+ ]
tokenizer = self.TestTokenizer(tokens)
parser.tokenizer = tokenizer
c1, o_left, o_right, c2, i_left, i_right = parser.parse_assign()
assert c1.name == "cable1"
assert c2.name == "cable2"
- assert o_left == None
- assert o_right == None
- assert i_left == None
- assert i_right == None
+ assert o_left is None
+ assert o_right is None
+ assert i_left is None
+ assert i_right is None
c1, o_left, o_right, c2, i_left, i_right = parser.parse_assign()
assert c1.name == "SR2"
assert c2.name == "\\"
assert o_left == 2
- assert o_right == None
- assert i_left == None
- assert i_right == None
+ assert o_right is None
+ assert i_left is None
+ assert i_right is None
############################################
##Parse star parameters
############################################
-
+
def test_parse_star_with_value(self):
- tokens = ['(', '*', 'key', '=', 'value', '*', ')']
+ tokens = ["(", "*", "key", "=", "value", "*", ")"]
tokenizer = self.TestTokenizer(tokens)
parser = VerilogParser()
parser.tokenizer = tokenizer
-
+
stars = parser.parse_star_property()
- for k,v in stars.items():
+ for k, v in stars.items():
assert k == "key"
assert v == "value"
def test_parser_star_without_value(self):
- tokens = ['(', '*', 'key', '*', ')']
+ tokens = ["(", "*", "key", "*", ")"]
tokenizer = self.TestTokenizer(tokens)
parser = VerilogParser()
parser.tokenizer = tokenizer
-
+
stars = parser.parse_star_property()
- for k,v in stars.items():
+ for k, v in stars.items():
assert k == "key"
assert v is None
def test_parser_star_list(self):
- '''example taken from a file that is not in our support files.
+ """example taken from a file that is not in our support files.
the construct in question is referenced in xilinx documentation
(* KEEP, DONT_TOUCH, BEL = "C6LUT" *)
additionally:
@@ -1283,23 +1638,51 @@ def test_parser_star_list(self):
and I presume that:
(* KEEP, DONT_TOUCH *)
would all be valid
- '''
- tokens = ["(", "*", "KEEP", ",", "DONT_TOUCH", ",", "BEL", "=", '"C6LUT"', "*", ")",\
- "(", "*", "BEL", "=", '"H6LUT"', ",", "RLOC", "=", '"X0Y0"', "*", ")",\
- "(", "*", "KEEP", ",", "DONT_TOUCH", "*", ")"]
-
+ """
+ tokens = [
+ "(",
+ "*",
+ "KEEP",
+ ",",
+ "DONT_TOUCH",
+ ",",
+ "BEL",
+ "=",
+ '"C6LUT"',
+ "*",
+ ")",
+ "(",
+ "*",
+ "BEL",
+ "=",
+ '"H6LUT"',
+ ",",
+ "RLOC",
+ "=",
+ '"X0Y0"',
+ "*",
+ ")",
+ "(",
+ "*",
+ "KEEP",
+ ",",
+ "DONT_TOUCH",
+ "*",
+ ")",
+ ]
+
tokenizer = self.TestTokenizer(tokens)
parser = VerilogParser()
parser.tokenizer = tokenizer
-
+
stars0 = parser.parse_star_property()
stars1 = parser.parse_star_property()
stars2 = parser.parse_star_property()
assert "KEEP" in stars0
- assert stars0["KEEP"] == None
+ assert stars0["KEEP"] is None
assert "DONT_TOUCH" in stars0
- assert stars0["DONT_TOUCH"] == None
+ assert stars0["DONT_TOUCH"] is None
assert "BEL" in stars0
assert stars0["BEL"] == '"C6LUT"'
@@ -1309,10 +1692,10 @@ def test_parser_star_list(self):
assert stars1["RLOC"] == '"X0Y0"'
assert "KEEP" in stars2
- assert stars2["KEEP"] == None
+ assert stars2["KEEP"] is None
assert "DONT_TOUCH" in stars2
- assert stars2["DONT_TOUCH"] == None
-
+ assert stars2["DONT_TOUCH"] is None
+
############################################
##test hierarchy
############################################
@@ -1344,7 +1727,7 @@ def test_hierarchy_fixing(self):
#################################################
## Other tests
#################################################
-
+
def test_partially_connected_ports(self):
# make sure partially connected ports connect pins on lower end of the port
# create a little netlist to use
@@ -1385,14 +1768,23 @@ def test_partially_connected_ports(self):
netlist = sdn.parse("test_netlist.v")
for inst in netlist.get_instances():
for port in inst.get_ports():
- pins = list(p for p in port.get_pins(selection=Selection.OUTSIDE, filter=lambda x: x.instance==inst))
+ pins = list(
+ p
+ for p in port.get_pins(
+ selection=Selection.OUTSIDE, filter=lambda x: x.instance == inst
+ )
+ )
pins.reverse()
if not all(p.wire for p in pins) and any(p.wire for p in pins):
wires = list(p.wire for p in pins if p.wire)
for i in range(len(wires)):
- assert pins[i].wire, "The wire is " + str(pins[i].wire + " but should be connected")
- for i in range(len(pins)-len(wires)):
- assert pins[len(wires)+i].wire is None, "The wire is " + str(pins[i].wire + " but should NOT be connected")
+ assert pins[i].wire, "The wire is " + str(
+ pins[i].wire + " but should be connected"
+ )
+ for i in range(len(pins) - len(wires)):
+ assert pins[len(wires) + i].wire is None, "The wire is " + str(
+ pins[i].wire + " but should NOT be connected"
+ )
os.remove("test_netlist.v")
@@ -1415,7 +1807,7 @@ def test_get_all_ports_from_wires(self):
groups = [[wire1, wire2, wire3], [wire1, wire2], [wire1], [wire3]]
expected_results = [[port1, port2], [port1, port2], [port1], []]
-
+
parser = VerilogParser()
for i in range(len(groups)):
@@ -1425,10 +1817,8 @@ def test_get_all_ports_from_wires(self):
assert r in expected_results[i]
for r in expected_results[i]:
assert r in actual_results
-
def test_get_wires_from_cable_helper(self):
-
parser = VerilogParser()
cable1 = sdn.Cable()
@@ -1439,29 +1829,41 @@ def test_get_wires_from_cable_helper(self):
cable2.create_wires(8)
cable2.lower_index = 0
- #add the cable.lower_index to all tests
+ # add the cable.lower_index to all tests
- tests = [(7,0), (0, None), (0,0), (1,None), (2,4)]
+ tests = [(7, 0), (0, None), (0, 0), (1, None), (2, 4)]
e11 = []
e21 = []
- for i in reversed(range(0,8)):
+ for i in reversed(range(0, 8)):
e11.append(cable1.wires[i])
e21.append(cable2.wires[i])
- expected1 = [e11, [cable1.wires[0]], [cable1.wires[0]], [cable1.wires[1]], cable1.wires[2:5]]
- expected2 = [e21, [cable2.wires[0]], [cable2.wires[0]], [cable2.wires[1]], cable2.wires[2:5]]
+ expected1 = [
+ e11,
+ [cable1.wires[0]],
+ [cable1.wires[0]],
+ [cable1.wires[1]],
+ cable1.wires[2:5],
+ ]
+ expected2 = [
+ e21,
+ [cable2.wires[0]],
+ [cable2.wires[0]],
+ [cable2.wires[1]],
+ cable2.wires[2:5],
+ ]
expected1[4].reverse()
expected2[4].reverse()
for i in range(len(tests)):
left1 = tests[i][0] + cable1.lower_index
- if tests[i][1] != None:
+ if tests[i][1] is not None:
right1 = tests[i][1] + cable1.lower_index
else:
right1 = None
left2 = tests[i][0] + cable2.lower_index
- if tests[i][1] != None:
+ if tests[i][1] is not None:
right2 = tests[i][1] + cable2.lower_index
else:
right2 = None
@@ -1471,7 +1873,9 @@ def test_get_wires_from_cable_helper(self):
for j in range(len(expected1[i])):
w11 = wires1[j]
w12 = expected1[i][j]
- assert w11 == w12, "the wires are not the same or not in the same order."
+ assert (
+ w11 == w12
+ ), "the wires are not the same or not in the same order."
w21 = wires2[j]
w22 = expected2[i][j]
assert w21 == w22, "the wires are not the same or not in the same order"
@@ -1503,5 +1907,5 @@ def test_constant_parsing(self):
self.assertEqual(cable.name, "\\", "Check const wire name")
-if __name__ == '__main__':
+if __name__ == "__main__":
unittest.main()
diff --git a/spydrnet/parsers/verilog/tests/test_verilog_tokens.py b/tests/spydrnet/parsers/verilog/tests/test_verilog_tokens.py
similarity index 68%
rename from spydrnet/parsers/verilog/tests/test_verilog_tokens.py
rename to tests/spydrnet/parsers/verilog/tests/test_verilog_tokens.py
index 29826c66..35bd7d82 100644
--- a/spydrnet/parsers/verilog/tests/test_verilog_tokens.py
+++ b/tests/spydrnet/parsers/verilog/tests/test_verilog_tokens.py
@@ -5,15 +5,19 @@
class TestVerilogTokens(unittest.TestCase):
-
-
def test_valid_identifier(self):
identifiers = ["valid", "_valid", "\\^[0]should_be_valid ", "_1293i123"]
for i in identifiers:
assert vt.is_valid_identifier(i)
def test_invalid_identifier(self):
- identifiers = ["not valid", "6invalid" "^[0]no_escape...", "\\space in escaped ", "", "!"]
+ identifiers = [
+ "not valid",
+ "6invalid" "^[0]no_escape...",
+ "\\space in escaped ",
+ "",
+ "!",
+ ]
for i in identifiers:
assert not vt.is_valid_identifier(i)
@@ -23,13 +27,18 @@ def test_valid_number(self):
assert vt.is_numeric(n)
def test_invalid_number(self):
- #we could change this so that a decimal point is still a valid number if needed.
+ # we could change this so that a decimal point is still a valid number if needed.
numbers = ["123123.12903", "\\*#@(&$#@*$", "123 3901", ""]
for n in numbers:
assert not vt.is_numeric(n)
def test_convert_string_to_direction(self):
strings = ["input", "output", "inout", "unknown"]
- values = [sdn.Port.Direction.IN, sdn.Port.Direction.OUT, sdn.Port.Direction.INOUT, sdn.Port.Direction.UNDEFINED]
+ values = [
+ sdn.Port.Direction.IN,
+ sdn.Port.Direction.OUT,
+ sdn.Port.Direction.INOUT,
+ sdn.Port.Direction.UNDEFINED,
+ ]
for i in range(len(strings)):
- assert vt.string_to_port_direction(strings[i]) == values[i]
\ No newline at end of file
+ assert vt.string_to_port_direction(strings[i]) == values[i]
diff --git a/tests/spydrnet/plugins/__init__.py b/tests/spydrnet/plugins/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/spydrnet/plugins/namespace_manager/__init__.py b/tests/spydrnet/plugins/namespace_manager/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/spydrnet/plugins/namespace_manager/tests/__init__.py b/tests/spydrnet/plugins/namespace_manager/tests/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/spydrnet/plugins/namespace_manager/tests/test_edif_namespace.py b/tests/spydrnet/plugins/namespace_manager/tests/test_edif_namespace.py
similarity index 66%
rename from spydrnet/plugins/namespace_manager/tests/test_edif_namespace.py
rename to tests/spydrnet/plugins/namespace_manager/tests/test_edif_namespace.py
index e3f69e5b..a60a7672 100644
--- a/spydrnet/plugins/namespace_manager/tests/test_edif_namespace.py
+++ b/tests/spydrnet/plugins/namespace_manager/tests/test_edif_namespace.py
@@ -4,6 +4,7 @@
class TestEdifNamespace(unittest.TestCase):
original_default = None
+
@classmethod
def setUpClass(cls) -> None:
cls.original_default = sdn.namespace_manager.default
@@ -31,165 +32,165 @@ def test_basic_setup(self):
netlist = self.gen_netlist()
lib1 = netlist.create_library()
lib2 = netlist.create_library()
- lib1['EDIF.identifier'] = "my_lib1"
- lib2['EDIF.identifier'] = "my_lib2"
+ lib1["EDIF.identifier"] = "my_lib1"
+ lib2["EDIF.identifier"] = "my_lib2"
def1 = lib1.create_definition()
- def1['EDIF.identifier'] = "d1"
+ def1["EDIF.identifier"] = "d1"
def2 = lib2.create_definition()
- def2['EDIF.identifier'] = "d1"
+ def2["EDIF.identifier"] = "d1"
def3 = lib1.create_definition()
- def3['EDIF.identifier'] = "my_lib1"
+ def3["EDIF.identifier"] = "my_lib1"
c1 = def1.create_cable()
p1 = def1.create_port()
i1 = def1.create_child()
c2 = def1.create_cable()
p2 = def1.create_port()
i2 = def1.create_child()
- c1['EDIF.identifier'] = "&1"
- i1['EDIF.identifier'] = "&1"
- p1['EDIF.identifier'] = "&1"
- c2['EDIF.identifier'] = "&2"
- i2['EDIF.identifier'] = "&2"
- p2['EDIF.identifier'] = "&2"
+ c1["EDIF.identifier"] = "&1"
+ i1["EDIF.identifier"] = "&1"
+ p1["EDIF.identifier"] = "&1"
+ c2["EDIF.identifier"] = "&2"
+ i2["EDIF.identifier"] = "&2"
+ p2["EDIF.identifier"] = "&2"
def test_dont_track_orphaned(self):
netlist = self.gen_netlist()
lib1 = sdn.Library()
lib2 = sdn.Library()
- lib1['EDIF.identifier'] = "my_lib1"
- lib2['EDIF.identifier'] = "my_lib1"
+ lib1["EDIF.identifier"] = "my_lib1"
+ lib2["EDIF.identifier"] = "my_lib1"
@unittest.expectedFailure
def test_duplicate_library_name(self):
netlist = self.gen_netlist()
lib1 = netlist.create_library()
lib2 = netlist.create_library()
- lib1['EDIF.identifier'] = "my_lib"
- lib2['EDIF.identifier'] = "my_lib"
+ lib1["EDIF.identifier"] = "my_lib"
+ lib2["EDIF.identifier"] = "my_lib"
@unittest.expectedFailure
def test_duplicate_definition_name(self):
lib1 = self.gen_library()
def1 = lib1.create_definition()
def2 = lib1.create_definition()
- def1['EDIF.identifier'] = "my_lib"
- def2['EDIF.identifier'] = "my_lib"
+ def1["EDIF.identifier"] = "my_lib"
+ def2["EDIF.identifier"] = "my_lib"
def test_duplicate_definition_elements(self):
def1 = self.gen_definition()
port = def1.create_port()
instance = def1.create_child()
cable = def1.create_cable()
- port['EDIF.identifier'] = "my_lib"
- instance['EDIF.identifier'] = "my_lib"
- cable['EDIF.identifier'] = "my_lib"
+ port["EDIF.identifier"] = "my_lib"
+ instance["EDIF.identifier"] = "my_lib"
+ cable["EDIF.identifier"] = "my_lib"
@unittest.expectedFailure
def test_duplicate_definition_ports(self):
def1 = self.gen_definition()
port = def1.create_port()
port2 = def1.create_port()
- port['EDIF.identifier'] = "my_lib"
- port2['EDIF.identifier'] = "my_lib"
+ port["EDIF.identifier"] = "my_lib"
+ port2["EDIF.identifier"] = "my_lib"
@unittest.expectedFailure
def test_duplicate_definition_cables(self):
def1 = self.gen_definition()
cable = def1.create_cable()
cable2 = def1.create_cable()
- cable['EDIF.identifier'] = "my_lib"
- cable2['EDIF.identifier'] = "my_lib"
+ cable["EDIF.identifier"] = "my_lib"
+ cable2["EDIF.identifier"] = "my_lib"
@unittest.expectedFailure
def test_duplicate_definition_children(self):
def1 = self.gen_definition()
instance = def1.create_child()
instance2 = def1.create_child()
- instance['EDIF.identifier'] = "my_lib"
- instance2['EDIF.identifier'] = "my_lib"
+ instance["EDIF.identifier"] = "my_lib"
+ instance2["EDIF.identifier"] = "my_lib"
def test_rename(self):
netlist = self.gen_netlist()
lib1 = netlist.create_library()
- lib1['EDIF.identifier'] = "my_lib1"
- lib1['EDIF.identifier'] = "my_lib2"
- lib1['EDIF.identifier'] = "my_lib1"
+ lib1["EDIF.identifier"] = "my_lib1"
+ lib1["EDIF.identifier"] = "my_lib2"
+ lib1["EDIF.identifier"] = "my_lib1"
lib2 = netlist.create_library()
- lib2['EDIF.identifier'] = "my_lib2"
+ lib2["EDIF.identifier"] = "my_lib2"
def1 = lib1.create_definition()
- def1['EDIF.identifier'] = "my_lib1"
- def1['EDIF.identifier'] = "my_lib2"
- def1['EDIF.identifier'] = "my_lib1"
+ def1["EDIF.identifier"] = "my_lib1"
+ def1["EDIF.identifier"] = "my_lib2"
+ def1["EDIF.identifier"] = "my_lib1"
def2 = lib1.create_definition()
- def2['EDIF.identifier'] = "my_lib2"
+ def2["EDIF.identifier"] = "my_lib2"
c = def1.create_cable()
- c['EDIF.identifier'] = "&1"
- c['EDIF.identifier'] = "&2"
- c['EDIF.identifier'] = "&1"
+ c["EDIF.identifier"] = "&1"
+ c["EDIF.identifier"] = "&2"
+ c["EDIF.identifier"] = "&1"
p = def1.create_port()
- p['EDIF.identifier'] = "&1"
- p['EDIF.identifier'] = "&2"
- p['EDIF.identifier'] = "&1"
+ p["EDIF.identifier"] = "&1"
+ p["EDIF.identifier"] = "&2"
+ p["EDIF.identifier"] = "&1"
i = def1.create_child()
- i['EDIF.identifier'] = "&1"
- i['EDIF.identifier'] = "&2"
- i['EDIF.identifier'] = "&1"
+ i["EDIF.identifier"] = "&1"
+ i["EDIF.identifier"] = "&2"
+ i["EDIF.identifier"] = "&1"
def test_remove(self):
netlist = self.gen_netlist()
lib1 = netlist.create_library()
- lib1['EDIF.identifier'] = "my_lib1"
+ lib1["EDIF.identifier"] = "my_lib1"
netlist.remove_library(lib1)
lib2 = netlist.create_library()
- lib2['EDIF.identifier'] = "my_lib1"
+ lib2["EDIF.identifier"] = "my_lib1"
def1 = lib2.create_definition()
- def1['EDIF.identifier'] = "my_lib1"
+ def1["EDIF.identifier"] = "my_lib1"
lib2.remove_definition(def1)
def2 = lib2.create_definition()
- def2['EDIF.identifier'] = "my_lib1"
+ def2["EDIF.identifier"] = "my_lib1"
c1 = def2.create_cable()
c2 = def2.create_cable()
p1 = def2.create_port()
p2 = def2.create_port()
i1 = def2.create_child()
i2 = def2.create_child()
- c1['EDIF.identifier'] = "&1"
+ c1["EDIF.identifier"] = "&1"
def2.remove_cable(c1)
- c2['EDIF.identifier'] = "&1"
- p1['EDIF.identifier'] = "&1"
+ c2["EDIF.identifier"] = "&1"
+ p1["EDIF.identifier"] = "&1"
def2.remove_port(p1)
- p2['EDIF.identifier'] = "&1"
- i1['EDIF.identifier'] = "&1"
+ p2["EDIF.identifier"] = "&1"
+ i1["EDIF.identifier"] = "&1"
def2.remove_child(i1)
- i2['EDIF.identifier'] = "&1"
+ i2["EDIF.identifier"] = "&1"
def test_orphaned_add(self):
netlist = self.gen_netlist()
lib1 = sdn.Library()
- lib1["EDIF.identifier"] = '&1'
+ lib1["EDIF.identifier"] = "&1"
netlist.add_library(lib1)
@unittest.expectedFailure
def test_orphaned_add_collision(self):
netlist = self.gen_netlist()
lib1 = sdn.Library()
- lib1["EDIF.identifier"] = '&1'
+ lib1["EDIF.identifier"] = "&1"
netlist.add_library(lib1)
lib2 = sdn.Library()
- lib2["EDIF.identifier"] = '&1'
+ lib2["EDIF.identifier"] = "&1"
netlist.add_library(lib2)
def test_remove_twice_library(self):
netlist = self.gen_netlist()
lib1 = netlist.create_library()
- lib1['EDIF.identifier'] = "my_lib1"
+ lib1["EDIF.identifier"] = "my_lib1"
netlist.remove_library(lib1)
self.assertRaises(Exception, netlist.remove_library, lib1)
def test_remove_twice_definition(self):
lib = self.gen_library()
d1 = lib.create_definition()
- d1['EDIF.identifier'] = "&1"
+ d1["EDIF.identifier"] = "&1"
lib.remove_definition(d1)
self.assertRaises(Exception, lib.remove_definition, d1)
@@ -227,30 +228,30 @@ def test_remove_tracked(self):
def test_pop_name(self):
netlist = self.gen_netlist()
lib1 = netlist.create_library()
- lib1['EDIF.identifier'] = "my_lib1"
- lib1.pop('EDIF.identifier')
+ lib1["EDIF.identifier"] = "my_lib1"
+ lib1.pop("EDIF.identifier")
lib2 = netlist.create_library()
- lib2['EDIF.identifier'] = "my_lib1"
+ lib2["EDIF.identifier"] = "my_lib1"
def1 = lib2.create_definition()
- def1['EDIF.identifier'] = "my_lib1"
- def1.pop('EDIF.identifier')
+ def1["EDIF.identifier"] = "my_lib1"
+ def1.pop("EDIF.identifier")
def2 = lib2.create_definition()
- def2['EDIF.identifier'] = "my_lib1"
+ def2["EDIF.identifier"] = "my_lib1"
c1 = def2.create_cable()
c2 = def2.create_cable()
p1 = def2.create_port()
p2 = def2.create_port()
i1 = def2.create_child()
i2 = def2.create_child()
- c1['EDIF.identifier'] = "&1"
- c1.pop('EDIF.identifier')
- c2['EDIF.identifier'] = "&1"
- p1['EDIF.identifier'] = "&1"
- p1.pop('EDIF.identifier')
- p2['EDIF.identifier'] = "&1"
- i1['EDIF.identifier'] = "&1"
- i1.pop('EDIF.identifier')
- i2['EDIF.identifier'] = "&1"
+ c1["EDIF.identifier"] = "&1"
+ c1.pop("EDIF.identifier")
+ c2["EDIF.identifier"] = "&1"
+ p1["EDIF.identifier"] = "&1"
+ p1.pop("EDIF.identifier")
+ p2["EDIF.identifier"] = "&1"
+ i1["EDIF.identifier"] = "&1"
+ i1.pop("EDIF.identifier")
+ i2["EDIF.identifier"] = "&1"
# TODO: rename an object
# TODO: orphan an object and see what happens
diff --git a/tests/spydrnet/plugins/tests/__init__.py b/tests/spydrnet/plugins/tests/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/spydrnet/plugins/tests/test_hierarchical_reference_manager.py b/tests/spydrnet/plugins/tests/test_hierarchical_reference_manager.py
new file mode 100644
index 00000000..e69de29b
diff --git a/spydrnet/plugins/tests/test_namespace_manager.py b/tests/spydrnet/plugins/tests/test_namespace_manager.py
similarity index 99%
rename from spydrnet/plugins/tests/test_namespace_manager.py
rename to tests/spydrnet/plugins/tests/test_namespace_manager.py
index d7b0ed8c..e7a6a976 100644
--- a/spydrnet/plugins/tests/test_namespace_manager.py
+++ b/tests/spydrnet/plugins/tests/test_namespace_manager.py
@@ -3,7 +3,6 @@
class TestNamespaceManager(unittest.TestCase):
-
def test_naming_after_assignments(self):
library = sdn.Library()
definition = library.create_definition()
diff --git a/tests/spydrnet/shortcuts/__init__.py b/tests/spydrnet/shortcuts/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/spydrnet/testing/__init__.py b/tests/spydrnet/testing/__init__.py
new file mode 100644
index 00000000..b98bd9c7
--- /dev/null
+++ b/tests/spydrnet/testing/__init__.py
@@ -0,0 +1,2 @@
+from spydrnet.testing.utils import *
+from spydrnet.testing.test import run
diff --git a/tests/spydrnet/testing/test.py b/tests/spydrnet/testing/test.py
new file mode 100644
index 00000000..3c7612a8
--- /dev/null
+++ b/tests/spydrnet/testing/test.py
@@ -0,0 +1,34 @@
+def run(verbosity=1, doctest=False):
+ """Run SpyDrNet tests.
+
+ Parameters
+ ----------
+ verbosity: integer, optional
+ Level of detail in test reports. Higher numbers provide more detail.
+
+ doctest: bool, optional
+ True to run doctests in code modules
+ """
+
+ import pytest
+
+ pytest_args = ["-l"]
+
+ if verbosity and int(verbosity) > 1:
+ pytest_args += ["-" + "v" * (int(verbosity) - 1)]
+
+ if doctest:
+ pytest_args += ["--doctest-modules"]
+
+ pytest_args += ["--pyargs", "spydrnet"]
+
+ try:
+ code = pytest.main(pytest_args)
+ except SystemExit as exc:
+ code = exc.code
+
+ return code == 0
+
+
+if __name__ == "__main__":
+ run()
diff --git a/tests/spydrnet/tests/__init__.py b/tests/spydrnet/tests/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/spydrnet/tests/test_clone.py b/tests/spydrnet/tests/test_clone.py
similarity index 90%
rename from spydrnet/tests/test_clone.py
rename to tests/spydrnet/tests/test_clone.py
index 98db6b0b..24a06952 100644
--- a/spydrnet/tests/test_clone.py
+++ b/tests/spydrnet/tests/test_clone.py
@@ -6,14 +6,13 @@
class TestClone(unittest.TestCase):
-
def _get_two_netlists(self):
- #create a test netlist
+ # create a test netlist
nl = self._create_netlist()
- #create my own backup of the test netlist (just create another that is identical)
+ # create my own backup of the test netlist (just create another that is identical)
nl2 = self._create_netlist()
-
- #both netlists are created and checkout as the same.
+
+ # both netlists are created and checkout as the same.
return nl, nl2
def _compare_netlists(self, n1, n2):
@@ -54,7 +53,6 @@ def _create_netlist(self):
ins3.reference = def4
return netlist
-
def create_and_clone_cable(self, wirecount, array, downto, index, key, value):
definition = Definition()
p1 = definition.create_cable()
@@ -69,7 +67,7 @@ def create_and_clone_cable(self, wirecount, array, downto, index, key, value):
assert p2.is_array == array
assert len(p2.wires) == wirecount
assert p2[key] == value
- assert p2.definition == None
+ assert p2.definition is None
for pin in p2.wires:
assert pin.cable is p2
assert len(pin.pins) == 0
@@ -90,7 +88,7 @@ def test_cable_not_array(self):
index = 0
key = "Name"
value = "myPortName"
- self.create_and_clone_cable(pincount, array, downto, index, key, value)
+ self.create_and_clone_cable(pincount, array, downto, index, key, value)
def test_cable_single_bit_array(self):
pincount = 1
@@ -99,7 +97,7 @@ def test_cable_single_bit_array(self):
index = 0
key = "garbage_key"
value = "garbage_value"
- self.create_and_clone_cable(pincount, array, downto, index, key, value)
+ self.create_and_clone_cable(pincount, array, downto, index, key, value)
def test_definition(self):
lib = Library()
@@ -112,7 +110,7 @@ def test_definition(self):
def2.create_port()
def2.create_cable()
def3 = clone(def2)
- assert def3.library == None
+ assert def3.library is None
assert len(def3.children) == len(def2.children)
assert len(def3.cables) == len(def2.cables)
assert len(def3.ports) == len(def2.ports)
@@ -129,9 +127,9 @@ def test_innerpin(self):
port = Port()
pin = port.create_pin()
pin2 = pin.clone()
- assert pin2.wire == None
- assert pin2.port == None
-
+ assert pin2.wire is None
+ assert pin2.port is None
+
def test_instance(self):
def1 = Definition()
def2 = Definition()
@@ -140,13 +138,12 @@ def test_instance(self):
child = def1.create_child()
child.reference = def2
inst2 = clone(child)
- assert inst2.parent == None
+ assert inst2.parent is None
assert inst2.reference is def2
assert set(inst2.pins.keys()).difference(set(child.pins.keys())) == set()
for v in inst2.pins.values():
assert v not in child.pins.values()
-
def test_library_instance_references(self):
lib1 = Library()
lib2 = Library()
@@ -158,7 +155,7 @@ def test_library_instance_references(self):
ins2.reference = def2
ins3.reference = def3
lib3 = clone(lib1)
- assert lib3.netlist == None
+ assert lib3.netlist is None
assert len(lib3.definitions) == len(lib1.definitions)
for d in lib3.definitions:
assert d not in lib1.definitions
@@ -175,7 +172,6 @@ def test_library_instance_references(self):
assert ins2 not in def2c.references
assert len(def3.references) == 2
-
def test_library_definition_references(self):
lib1 = Library()
lib2 = Library()
@@ -193,7 +189,7 @@ def check(self, r1, e):
return
assert e not in r1
- def not_among_all_references(self,r1, nl1):
+ def not_among_all_references(self, r1, nl1):
self.check(r1, nl1)
self.check(r1, nl1.top_instance)
for l in nl1.libraries:
@@ -217,7 +213,7 @@ def not_among_all_references(self,r1, nl1):
for pi in p.pins:
self.check(r1, pi)
- def add_all_references(self,r1, nl1):
+ def add_all_references(self, r1, nl1):
r1.add(nl1)
r1.add(nl1.top_instance)
for l in nl1.libraries:
@@ -245,7 +241,7 @@ def check_overlap_references(self, nl1, nl2):
r1 = set()
self.add_all_references(r1, nl1)
self.not_among_all_references(r1, nl2)
-
+
def test_netlist_several_lib(self):
netlist = Netlist()
lib1 = netlist.create_library()
@@ -278,7 +274,7 @@ def test_netlist_several_lib(self):
netlist2 = clone(netlist)
self._compare_netlists(netlist, netlist2)
self.check_overlap_references(netlist, netlist2)
-
+
def test_netlist_change_top_instance(self):
nl1 = Netlist()
lib1 = nl1.create_library()
@@ -290,7 +286,6 @@ def test_netlist_change_top_instance(self):
self._compare_netlists(nl1, nl2)
self.check_overlap_references(nl1, nl2)
-
def test_library_change_top_instace(self):
nl1 = Netlist()
nl2 = Netlist()
@@ -303,14 +298,13 @@ def test_library_change_top_instace(self):
nl2.add_library(lib2)
self._compare_netlists(nl1, nl2)
self.check_overlap_references(nl1, nl2)
-
-
+
def test_netlist(self):
nl1, nl2 = self._get_two_netlists()
nl3 = clone(nl1)
self._compare_netlists(nl1, nl3)
self._compare_netlists(nl1, nl2)
- #now check that no references overlap.
+ # now check that no references overlap.
self.check_overlap_references(nl1, nl3)
def test_netlist_empty_top_instance(self):
@@ -337,11 +331,13 @@ def test_outerpin(self):
op._wire = wire
op._inner_pin = inner
op2 = clone(op)
- assert op2.wire == None
- assert op2.instance == None
- assert op2.inner_pin == None
+ assert op2.wire is None
+ assert op2.instance is None
+ assert op2.inner_pin is None
- def create_and_clone_port(self, pincount, direction, array, downto, index, key, value):
+ def create_and_clone_port(
+ self, pincount, direction, array, downto, index, key, value
+ ):
definition = Definition()
p1 = definition.create_port()
p1[key] = value
@@ -357,10 +353,10 @@ def create_and_clone_port(self, pincount, direction, array, downto, index, key,
assert p2.direction == direction
assert len(p2.pins) == pincount
assert p2[key] == value
- assert p2.definition == None
+ assert p2.definition is None
for pin in p2.pins:
assert pin.port is p2
- assert pin.wire == None
+ assert pin.wire is None
def test_port_array(self):
pincount = 10
@@ -370,8 +366,10 @@ def test_port_array(self):
index = 5
key = "EDIF.identifier"
value = "myPort"
- self.create_and_clone_port(pincount, direction, array, downto, index, key, value)
-
+ self.create_and_clone_port(
+ pincount, direction, array, downto, index, key, value
+ )
+
def test_port_not_array(self):
pincount = 1
direction = Port.Direction.OUT
@@ -380,7 +378,9 @@ def test_port_not_array(self):
index = 0
key = "Name"
value = "myPortName"
- self.create_and_clone_port(pincount, direction, array, downto, index, key, value)
+ self.create_and_clone_port(
+ pincount, direction, array, downto, index, key, value
+ )
def test_port_single_bit_array(self):
pincount = 1
@@ -390,14 +390,16 @@ def test_port_single_bit_array(self):
index = 0
key = "garbage_key"
value = "garbage_value"
- self.create_and_clone_port(pincount, direction, array, downto, index, key, value)
+ self.create_and_clone_port(
+ pincount, direction, array, downto, index, key, value
+ )
def test_port_with_connectivity(self):
- pass #TODO
+ pass # TODO
def test_wire(self):
cable = Cable()
wire = cable.create_wire()
wire2 = clone(wire)
assert len(wire2.pins) == 0
- assert wire2.cable == None
\ No newline at end of file
+ assert wire2.cable is None
diff --git a/spydrnet/tests/test_example_netlist_functionality.py b/tests/spydrnet/tests/test_example_netlist_functionality.py
similarity index 67%
rename from spydrnet/tests/test_example_netlist_functionality.py
rename to tests/spydrnet/tests/test_example_netlist_functionality.py
index 8e5f90e9..41c6220b 100644
--- a/spydrnet/tests/test_example_netlist_functionality.py
+++ b/tests/spydrnet/tests/test_example_netlist_functionality.py
@@ -1,20 +1,19 @@
import unittest
import spydrnet as sdn
-import glob
-import os
from pathlib import Path
class TestExampleNetlistFunctionality(unittest.TestCase):
def test_example_netlist_names(self):
- filenames = glob.glob(os.path.join(sdn.base_dir, 'support_files', 'EDIF_netlists', '*'))
- # filenames = glob.glob(Path(sdn.base_dir, 'support_files', 'EDIF_netlists', '*')) # TypeError
-
+ filenames = list(
+ x for x in Path.glob(Path(sdn.example_netlists_path, "EDIF_netlists"), "*")
+ )
+
self.assertEqual(len(filenames), len(sdn.example_netlist_names))
filenames.sort()
for filename, example_name in zip(filenames, sdn.example_netlist_names):
basename = Path(filename).name
- example_name_golden = basename[:basename.index('.')]
+ example_name_golden = basename[: basename.index(".")]
self.assertEqual(example_name, example_name_golden)
def test_load_example_netlist_by_name(self):
diff --git a/spydrnet/tests/test_extend_classes.py b/tests/spydrnet/tests/test_extend_classes.py
similarity index 83%
rename from spydrnet/tests/test_extend_classes.py
rename to tests/spydrnet/tests/test_extend_classes.py
index 384cc012..2b94bbd8 100644
--- a/spydrnet/tests/test_extend_classes.py
+++ b/tests/spydrnet/tests/test_extend_classes.py
@@ -1,11 +1,13 @@
import unittest
-'''try importing it and extending the classes. Then make sure they're actually extended'''
+"""try importing it and extending the classes. Then make sure they're actually extended"""
+
class TestExtendingClasses(unittest.TestCase):
def test_import_and_extend(self):
from spydrnet.ir import FirstClassElement
from spydrnet.ir import Element
+
# spydrnet_extension should have been imported and used to extend classes
class1 = FirstClassElement()
self.assertTrue("first_class_extended" in dir(class1))
diff --git a/spydrnet/tests/test_flatten.py b/tests/spydrnet/tests/test_flatten.py
similarity index 81%
rename from spydrnet/tests/test_flatten.py
rename to tests/spydrnet/tests/test_flatten.py
index e01edded..72764729 100644
--- a/spydrnet/tests/test_flatten.py
+++ b/tests/spydrnet/tests/test_flatten.py
@@ -1,40 +1,40 @@
-
import unittest
import spydrnet as sdn
from spydrnet.ir import *
from spydrnet.flatten import flatten
from spydrnet.uniquify import uniquify
+
class TestUniquify(unittest.TestCase):
def create_netlist(self):
nl = Netlist()
lib = nl.create_library()
d1 = lib.create_definition()
- d1.name = ("d1")
+ d1.name = "d1"
d2 = lib.create_definition()
- d2.name = ("d2")
+ d2.name = "d2"
d3 = lib.create_definition()
- d3.name = ("d3")
+ d3.name = "d3"
i11 = d1.create_child()
- i11.name = ("i11")
+ i11.name = "i11"
i12 = d1.create_child()
- i12.name = ("i12")
+ i12.name = "i12"
i13 = d1.create_child()
- i13.name = ("i13")
+ i13.name = "i13"
i24 = d2.create_child()
- i24.name = ("i24")
+ i24.name = "i24"
i25 = d2.create_child()
- i25.name = ("i25")
+ i25.name = "i25"
i26 = d2.create_child()
- i26.name = ("i26")
+ i26.name = "i26"
i27 = d2.create_child()
d4 = lib.create_definition()
- d4.name = ("d4")
- i27.name = ("i27")
+ d4.name = "d4"
+ i27.name = "i27"
i38 = d3.create_child()
- i38.name = ("i38")
+ i38.name = "i38"
i39 = d3.create_child()
- i39.name = ("i39")
+ i39.name = "i39"
i11.reference = d3
i12.reference = d3
i13.reference = d3
@@ -46,10 +46,10 @@ def create_netlist(self):
i39.reference = d4
nl.top_instance = Instance()
nl.top_instance.reference = d2
- nl.top_instance.name = ("top_instance")
+ nl.top_instance.name = "top_instance"
return nl
- def create_mem_bus(self,top, proc, mem):
+ def create_mem_bus(self, top, proc, mem):
mem_width = 10
mem_write_out = proc.create_port()
mem_write_out.name = "mem_write_out"
@@ -88,7 +88,6 @@ def create_mem_bus(self,top, proc, mem):
return mem_write_out, mem_read_in
-
def create_proc(self, proc, mem_write, mem_read, core, cachel2):
mem_width = 10
core_i1 = proc.create_child()
@@ -105,13 +104,12 @@ def create_proc(self, proc, mem_write, mem_read, core, cachel2):
cachel2_i = proc.create_child()
cachel2_i.reference = cachel2
cachel2_i.name = "cachel2_i"
-
- mem_a_in = cachel2.create_port()
+
+ mem_a_in = cachel2.create_port()
mem_a_out = cachel2.create_port()
- mem_b_in = cachel2.create_port()
+ mem_b_in = cachel2.create_port()
mem_b_out = cachel2.create_port()
-
-
+
mem_a_in.create_pins(mem_width)
mem_a_out.create_pins(mem_width)
mem_b_in.create_pins(mem_width)
@@ -121,8 +119,7 @@ def create_proc(self, proc, mem_write, mem_read, core, cachel2):
mem_b_out.name = "mem_a_out"
mem_b_out.name = "mem_b_out"
mem_b_in.name = "mem_b_in"
-
-
+
ca1 = proc.create_cable()
ca2 = proc.create_cable()
cb1 = proc.create_cable()
@@ -139,14 +136,14 @@ def create_proc(self, proc, mem_write, mem_read, core, cachel2):
cb2.name = "cb2"
for i in range(mem_width):
- ca1.wires[i].connect_pin(core_i1.pins[mem_p.pins[i]])
- ca1.wires[i].connect_pin(cachel2_i.pins[mem_a_in.pins[i]])
- ca2.wires[i].connect_pin(mem_read.pins[i])
- ca2.wires[i].connect_pin(cachel2_i.pins[mem_a_out.pins[i]])
- cb1.wires[i].connect_pin(core_i2.pins[mem_p.pins[i]])
- cb1.wires[i].connect_pin(cachel2_i.pins[mem_b_in.pins[i]])
- cb2.wires[i].connect_pin(mem_write.pins[i])
- cb2.wires[i].connect_pin(cachel2_i.pins[mem_b_out.pins[i]])
+ ca1.wires[i].connect_pin(core_i1.pins[mem_p.pins[i]])
+ ca1.wires[i].connect_pin(cachel2_i.pins[mem_a_in.pins[i]])
+ ca2.wires[i].connect_pin(mem_read.pins[i])
+ ca2.wires[i].connect_pin(cachel2_i.pins[mem_a_out.pins[i]])
+ cb1.wires[i].connect_pin(core_i2.pins[mem_p.pins[i]])
+ cb1.wires[i].connect_pin(cachel2_i.pins[mem_b_in.pins[i]])
+ cb2.wires[i].connect_pin(mem_write.pins[i])
+ cb2.wires[i].connect_pin(cachel2_i.pins[mem_b_out.pins[i]])
return mem_p
@@ -154,7 +151,7 @@ def create_core(self, core, mem_p, alu, reg_file):
mem_width = 10
alu_i = core.create_child()
reg_file_i = core.create_child()
-
+
alu_i.reference = alu
alu_i.name = "alu_i"
reg_file_i.reference = reg_file
@@ -198,20 +195,17 @@ def create_netlist_with_wires(self):
nl.top_instance = Instance()
nl.top_instance.reference = top
-
- mem_write, mem_read= self.create_mem_bus(top, proc, mem)
+ mem_write, mem_read = self.create_mem_bus(top, proc, mem)
core_mem = self.create_proc(proc, mem_write, mem_read, core, cachel2)
self.create_core(core, core_mem, alu, reg_file)
- nl.top_instance.name = ("top_instance")
-
- #self.simple_recursive_netlist_visualizer(nl)
-
- return nl
+ nl.top_instance.name = "top_instance"
+ # self.simple_recursive_netlist_visualizer(nl)
+ return nl
# def simple_recursive_netlist_visualizer(self, netlist):
# #TODO put this code somewhere where people can use it to visualize simple netlists
@@ -225,14 +219,15 @@ def create_netlist_with_wires(self):
# def recurse(instance, depth):
# s = depth * "\t"
# print(s, instance.name, "(", instance.reference.name, ")")
- # for c in instance.reference.children:
+ # for c in instance.reference.children:
# recurse(c, depth + 1)
-
+
# recurse(top_instance, 0)
- def simple_cable_connection_visualizer(self,netlist):
+ def simple_cable_connection_visualizer(self, netlist):
top_instance = netlist.top_instance
- #display all the cables in the top instance with all of their connections next to it
+
+ # display all the cables in the top instance with all of their connections next to it
def recur(instance):
print(instance.name)
for c in instance.reference.cables:
@@ -240,7 +235,7 @@ def recur(instance):
if len(c.wires) > 0:
w = c.wires[0]
for p in w.pins:
- if isinstance(p,OuterPin):
+ if isinstance(p, OuterPin):
print("\t\t(instance): ", p.instance.name)
else:
print("\t\t(port): ", p.port.name)
@@ -249,8 +244,7 @@ def recur(instance):
recur(top_instance)
-
- def is_flat(self,nl):
+ def is_flat(self, nl):
ti = nl.top_instance
td = ti.reference
for i in td.children:
@@ -258,21 +252,20 @@ def is_flat(self,nl):
return False
return True
-
-
def test_flatten_instances(self):
nl = self.create_netlist()
uniquify(nl)
flatten(nl)
assert self.is_flat(nl)
-
def test_flatten_cables(self):
nl = self.create_netlist_with_wires()
self.simple_cable_connection_visualizer(nl)
-
+
uniquify(nl)
flatten(nl)
self.simple_cable_connection_visualizer(nl)
-
- assert self.is_flat(nl) #might be nice to add some tests for the connections here.
\ No newline at end of file
+
+ assert self.is_flat(
+ nl
+ ) # might be nice to add some tests for the connections here.
diff --git a/spydrnet/tests/test_uniquify.py b/tests/spydrnet/tests/test_uniquify.py
similarity index 83%
rename from spydrnet/tests/test_uniquify.py
rename to tests/spydrnet/tests/test_uniquify.py
index 3b4c44fe..013bff1a 100644
--- a/spydrnet/tests/test_uniquify.py
+++ b/tests/spydrnet/tests/test_uniquify.py
@@ -1,15 +1,15 @@
-
import unittest
from spydrnet import Netlist, Instance
from spydrnet.uniquify import uniquify
+
class TestUniquify(unittest.TestCase):
def create_netlist(self):
nl = Netlist()
lib = nl.create_library()
d1 = lib.create_definition()
d2 = lib.create_definition()
- d3 = lib.create_definition(name='instance_name')
+ d3 = lib.create_definition(name="instance_name")
i11 = d1.create_child()
i12 = d1.create_child()
i13 = d1.create_child()
@@ -34,7 +34,7 @@ def create_netlist(self):
return nl
def is_unique(self, netlist):
- #get all the definitions that are instanced below the top instance
+ # get all the definitions that are instanced below the top instance
top_inst = netlist.top_instance
top_def = top_inst.reference
inst = []
@@ -47,13 +47,13 @@ def is_unique(self, netlist):
inst.append(c)
index += 1
- #now we have a list of all the instances in the netlist make sure all references are unique to the netlist
+ # now we have a list of all the instances in the netlist make sure all references are unique to the netlist
refs = set()
for i in inst:
if i.reference.is_leaf():
continue
if i.reference in refs:
- return False #the instance references a previously referenced definition, instances are not unique
+ return False # the instance references a previously referenced definition, instances are not unique
refs.add(i.reference)
return True
@@ -72,7 +72,9 @@ def test_already_unique(self):
nl.top_instance = top
assert self.is_unique(nl), "netlist should be unique upon creation in this test"
uniquify(nl)
- assert self.is_unique(nl), "netlist should remain unique in this test. somehow uniquify made the netlist un-unique"
+ assert self.is_unique(
+ nl
+ ), "netlist should remain unique in this test. somehow uniquify made the netlist un-unique"
# def simple_recursive_netlist_visualizer(self, netlist):
# #TODO put this code somewhere where people can use it to visualize simple netlists
@@ -86,14 +88,13 @@ def test_already_unique(self):
# def recurse(instance, depth):
# s = depth * "\t"
# print(s, instance.name, "(", instance.reference.name, ")")
- # for c in instance.reference.children:
+ # for c in instance.reference.children:
# recurse(c, depth + 1)
-
- # recurse(top_instance, 0)
+ # recurse(top_instance, 0)
def test_uniquify_simple_with_names(self):
- '''simple test with 2 definitions.'''
+ """simple test with 2 definitions."""
nl = Netlist()
lib = nl.create_library()
d1 = lib.create_definition()
@@ -115,7 +116,9 @@ def test_uniquify_simple_with_names(self):
top.name = "top instance"
top.reference = d1
nl.top_instance = top
- assert not self.is_unique(nl), "initial netlist should not be unique in this test"
+ assert not self.is_unique(
+ nl
+ ), "initial netlist should not be unique in this test"
uniquify(nl)
assert self.is_unique(nl), "netlist should have been uniquified."
@@ -123,4 +126,4 @@ def test_uniquify(self):
nl = self.create_netlist()
assert not self.is_unique(nl), "our test netlist should not be unique"
uniquify(nl)
- assert self.is_unique(nl), "our netlist should have been uniquified"
\ No newline at end of file
+ assert self.is_unique(nl), "our netlist should have been uniquified"
diff --git a/spydrnet/tests/test_util.py b/tests/spydrnet/tests/test_util.py
similarity index 99%
rename from spydrnet/tests/test_util.py
rename to tests/spydrnet/tests/test_util.py
index 0d6e42ea..7edbe11b 100644
--- a/spydrnet/tests/test_util.py
+++ b/tests/spydrnet/tests/test_util.py
@@ -19,4 +19,3 @@ def test_multiple_objects(self):
netlist2 = sdn.Netlist()
library2 = netlist2.create_library()
get_libraries([netlist1, netlist2])
-
diff --git a/spydrnet/tests/test_verilog_to_edif.py b/tests/spydrnet/tests/test_verilog_to_edif.py
similarity index 84%
rename from spydrnet/tests/test_verilog_to_edif.py
rename to tests/spydrnet/tests/test_verilog_to_edif.py
index bab5c049..10ae7b44 100644
--- a/spydrnet/tests/test_verilog_to_edif.py
+++ b/tests/spydrnet/tests/test_verilog_to_edif.py
@@ -1,8 +1,5 @@
import unittest
-
-
class TestVerilogToEdif(unittest.TestCase):
-
- pass
\ No newline at end of file
+ pass
diff --git a/tests/spydrnet/util/__init__.py b/tests/spydrnet/util/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/spydrnet/util/tests/__init__.py b/tests/spydrnet/util/tests/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/spydrnet/util/tests/test_get_cables.py b/tests/spydrnet/util/tests/test_get_cables.py
similarity index 80%
rename from spydrnet/util/tests/test_get_cables.py
rename to tests/spydrnet/util/tests/test_get_cables.py
index 6c1c0a0a..5102d537 100644
--- a/spydrnet/util/tests/test_get_cables.py
+++ b/tests/spydrnet/util/tests/test_get_cables.py
@@ -8,26 +8,26 @@ def setUpClass(cls) -> None:
cls.netlist = sdn.Netlist()
leaf_library = cls.netlist.create_library()
- leaf_library.name = 'primitives'
+ leaf_library.name = "primitives"
library = cls.netlist.create_library()
- library.name = 'work'
+ library.name = "work"
leaf_def = leaf_library.create_definition()
- leaf_def.name = 'leaf'
+ leaf_def.name = "leaf"
leaf_port = leaf_def.create_port()
- leaf_port.name = 'I'
+ leaf_port.name = "I"
leaf_port.create_pins(1)
bottom_def = library.create_definition()
- bottom_def.name = 'bottom'
+ bottom_def.name = "bottom"
bottom_port = bottom_def.create_port()
- bottom_port.name = 'I'
+ bottom_port.name = "I"
bottom_port.create_pins(1)
leaf_inst = bottom_def.create_child()
leaf_inst.reference = leaf_def
bottom_cable = bottom_def.create_cable()
- bottom_cable.name = 'bottom_cable'
+ bottom_cable.name = "bottom_cable"
bottom_wire = bottom_cable.create_wire()
bottom_wire.connect_pin(bottom_port.pins[0])
bottom_wire.connect_pin(leaf_inst.pins[leaf_port.pins[0]])
@@ -36,12 +36,12 @@ def setUpClass(cls) -> None:
bottom_floating_wire = bottom_cable.create_wire()
middle_def = library.create_definition()
- middle_def.name = 'middle'
+ middle_def.name = "middle"
middle_port = middle_def.create_port()
middle_port.name = "I"
middle_port.create_pin()
bottom_inst = middle_def.create_child()
- bottom_inst.name = 'bottom'
+ bottom_inst.name = "bottom"
bottom_inst.reference = bottom_def
middle_cable = middle_def.create_cable()
middle_cable.name = "middle_cable"
@@ -53,12 +53,12 @@ def setUpClass(cls) -> None:
middle_floating_wire = middle_cable.create_wire()
top_def = library.create_definition()
- top_def.name = 'top'
+ top_def.name = "top"
top_port = top_def.create_port()
top_port.name = "I"
top_port.create_pin()
middle_inst = top_def.create_child()
- middle_inst.name = 'middle'
+ middle_inst.name = "middle"
middle_inst.reference = middle_def
top_cable = top_def.create_cable()
top_cable.name = "top_cable"
@@ -70,7 +70,7 @@ def setUpClass(cls) -> None:
top_floating_wire = top_cable.create_wire()
top_instance = sdn.Instance()
- top_instance.name = 'top'
+ top_instance.name = "top"
top_instance.reference = top_def
cls.netlist.top_instance = top_instance
@@ -78,9 +78,15 @@ def test_parameter_checking(self):
definition = sdn.Definition()
cable = definition.create_cable()
cable.name = "MY_CABLE"
- self.assertRaises(TypeError, sdn.get_cables, definition, "MY_CABLE", patterns="MY_CABLE")
- self.assertRaises(TypeError, sdn.get_cables, definition, "MY_CABLE", unsupported_keyword=None)
- self.assertRaises(TypeError, sdn.get_cables, definition, "MY_CABLE", selection=None)
+ self.assertRaises(
+ TypeError, sdn.get_cables, definition, "MY_CABLE", patterns="MY_CABLE"
+ )
+ self.assertRaises(
+ TypeError, sdn.get_cables, definition, "MY_CABLE", unsupported_keyword=None
+ )
+ self.assertRaises(
+ TypeError, sdn.get_cables, definition, "MY_CABLE", selection=None
+ )
self.assertRaises(TypeError, sdn.get_cables, None, "MY_CABLE")
self.assertRaises(TypeError, sdn.get_cables, [None, definition], "MY_CABLE")
@@ -138,17 +144,28 @@ def test_outer_pin(self):
self.assertEqual(len(search), 3)
def test_wire_inside(self):
- search = list(sdn.get_cables(self.netlist.top_instance.reference.cables[0].wires[0]))
+ search = list(
+ sdn.get_cables(self.netlist.top_instance.reference.cables[0].wires[0])
+ )
self.assertEqual(len(search), 1)
self.assertEqual(search[0].name, "top_cable")
def test_wire_outside(self):
- search = list(sdn.get_cables(self.netlist.top_instance.reference.cables[0].wires[0], selection="OUTSIDE"))
+ search = list(
+ sdn.get_cables(
+ self.netlist.top_instance.reference.cables[0].wires[0],
+ selection="OUTSIDE",
+ )
+ )
self.assertEqual(len(search), 1)
self.assertEqual(search[0].name, "middle_cable")
def test_wires_all(self):
- search = list(sdn.get_cables(self.netlist.top_instance.reference.cables[0].wires[0], selection="ALL"))
+ search = list(
+ sdn.get_cables(
+ self.netlist.top_instance.reference.cables[0].wires[0], selection="ALL"
+ )
+ )
self.assertEqual(len(search), 3)
def test_absolute_name_from_relative_reference(self):
diff --git a/tests/spydrnet/util/tests/test_get_definitions.py b/tests/spydrnet/util/tests/test_get_definitions.py
new file mode 100644
index 00000000..3732af91
--- /dev/null
+++ b/tests/spydrnet/util/tests/test_get_definitions.py
@@ -0,0 +1,260 @@
+import unittest
+import spydrnet as sdn
+
+
+class TestGetDefinitions(unittest.TestCase):
+ @classmethod
+ def setUpClass(cls) -> None:
+ cls.netlist = sdn.Netlist()
+
+ leaf_library = cls.netlist.create_library()
+ leaf_library.name = "primitives"
+
+ library = cls.netlist.create_library()
+ library.name = "work"
+
+ leaf_def = leaf_library.create_definition()
+ leaf_def.name = "leaf"
+ leaf_port = leaf_def.create_port()
+ leaf_port.name = "I"
+ leaf_port.create_pins(1)
+
+ bottom_def = library.create_definition()
+ bottom_def.name = "bottom"
+ bottom_port = bottom_def.create_port()
+ bottom_port.name = "I"
+ bottom_port.create_pins(1)
+ leaf_inst = bottom_def.create_child()
+ leaf_inst.reference = leaf_def
+ bottom_cable = bottom_def.create_cable()
+ bottom_cable.name = "bottom_cable"
+ bottom_wire = bottom_cable.create_wire()
+ bottom_wire.connect_pin(bottom_port.pins[0])
+ bottom_wire.connect_pin(leaf_inst.pins[leaf_port.pins[0]])
+ cls.leaf_inst = leaf_inst
+
+ bottom_floating_wire = bottom_cable.create_wire()
+
+ middle_def = library.create_definition()
+ middle_def.name = "middle"
+ middle_port = middle_def.create_port()
+ middle_port.name = "I"
+ middle_port.create_pin()
+ bottom_inst = middle_def.create_child()
+ bottom_inst.name = "bottom"
+ bottom_inst.reference = bottom_def
+ middle_cable = middle_def.create_cable()
+ middle_cable.name = "middle_cable"
+ middle_wire = middle_cable.create_wire()
+ middle_wire.connect_pin(middle_port.pins[0])
+ middle_wire.connect_pin(bottom_inst.pins[bottom_port.pins[0]])
+ cls.bottom_inst = bottom_inst
+
+ middle_floating_wire = middle_cable.create_wire()
+
+ top_def = library.create_definition()
+ top_def.name = "top"
+ top_port = top_def.create_port()
+ top_port.name = "I"
+ top_port.create_pin()
+ middle_inst = top_def.create_child()
+ middle_inst.name = "middle"
+ middle_inst.reference = middle_def
+ top_cable = top_def.create_cable()
+ top_cable.name = "top_cable"
+ top_wire = top_cable.create_wire()
+ top_wire.connect_pin(top_port.pins[0])
+ top_wire.connect_pin(middle_inst.pins[middle_port.pins[0]])
+
+ top_floating_wire = top_cable.create_wire()
+
+ top_instance = sdn.Instance()
+ top_instance.name = "top"
+ top_instance.reference = top_def
+ cls.netlist.top_instance = top_instance
+
+ def test_parameter_checking(self):
+ library = sdn.Library()
+ definition = library.create_definition()
+ definition.name = "MY_DEF"
+ self.assertRaises(
+ TypeError, sdn.get_definitions, library, "MY_DEF", patterns="MY_DEF"
+ )
+ self.assertRaises(
+ TypeError, sdn.get_definitions, library, "MY_DEF", unsupported_keyword=None
+ )
+ self.assertRaises(
+ TypeError, sdn.get_definitions, library, "MY_DEF", selection="BOTH"
+ )
+ self.assertRaises(TypeError, sdn.get_definitions, None, "MY_DEF")
+ self.assertRaises(TypeError, sdn.get_definitions, [None, library], "MY_DEF")
+
+ def test_collection(self):
+ library = sdn.Library()
+ definition = library.create_definition()
+ definition.name = "MY_DEF"
+ ports = list(sdn.get_definitions([library, library]))
+ self.assertEqual(len(ports), 1)
+
+ def test_get_definition_of_instances_outside(self):
+ definition_query = list(
+ sdn.get_definitions(
+ self.netlist.libraries[0].definitions[0].references, selection="OUTSIDE"
+ )
+ )
+ self.assertTrue(
+ len(definition_query) == 1
+ and definition_query[0] == self.bottom_inst.reference
+ )
+
+ def test_get_definition_of_instances_inside(self):
+ definition_query = list(
+ sdn.get_definitions(
+ self.netlist.libraries[0].definitions[0].references, selection="INSIDE"
+ )
+ )
+ self.assertTrue(
+ len(definition_query) == 1
+ and definition_query[0] == self.leaf_inst.reference
+ )
+
+ def test_get_definition_of_instances_recursive_down(self):
+ definition_query = set(
+ sdn.get_definitions(self.netlist.top_instance, recursive=True)
+ )
+ self.assertTrue(len(definition_query) == 4)
+
+ def test_get_definition_of_instances_recursive_up(self):
+ definition_query = list(
+ sdn.get_definitions(self.leaf_inst, selection="OUTSIDE", recursive=True)
+ )
+ self.assertTrue(
+ len(definition_query) == 3
+ and self.leaf_inst.reference not in definition_query
+ )
+
+ def test_get_definition_of_library(self):
+ definition_query = list(sdn.get_definitions(self.netlist.libraries[1]))
+ self.assertTrue(
+ len(definition_query) == 3
+ and self.leaf_inst.reference not in definition_query
+ )
+
+ def test_get_definition_of_library_outside(self):
+ definition_query = list(
+ sdn.get_definitions(self.netlist.libraries[0], selection="OUTSIDE")
+ )
+ self.assertTrue(
+ len(definition_query) == 1
+ and self.leaf_inst.reference not in definition_query
+ )
+
+ def test_get_definition_of_library_outside_recursive(self):
+ definition_query = list(
+ sdn.get_definitions(
+ self.netlist.libraries[0], selection="OUTSIDE", recursive=True
+ )
+ )
+ self.assertTrue(
+ len(definition_query) == 3
+ and self.leaf_inst.reference not in definition_query
+ )
+
+ def test_get_definition_of_library_recursive(self):
+ definition_query = list(
+ sdn.get_definitions(self.netlist.libraries[1], recursive=True)
+ )
+ self.assertTrue(
+ len(definition_query) == 4 and self.leaf_inst.reference in definition_query
+ )
+
+ def test_get_definition_of_library_recursive_absolute_pattern(self):
+ definition_query = list(
+ sdn.get_definitions(self.netlist.libraries[1], "leaf", recursive=True)
+ )
+ self.assertTrue(
+ len(definition_query) == 1
+ and self.leaf_inst.reference is definition_query[0]
+ )
+
+ def test_get_definition_of_definition_inside(self):
+ definition_query = list(
+ sdn.get_definitions(
+ self.netlist.libraries[1].definitions[0], selection="INSIDE"
+ )
+ )
+ self.assertTrue(
+ len(definition_query) == 1
+ and definition_query[0] == self.netlist.libraries[0].definitions[0]
+ )
+
+ def test_get_definition_of_definition_outside(self):
+ definition_query = list(
+ sdn.get_definitions(
+ self.netlist.libraries[0].definitions[0], selection="OUTSIDE"
+ )
+ )
+ self.assertTrue(
+ len(definition_query) == 1
+ and definition_query[0] == self.netlist.libraries[1].definitions[0]
+ )
+
+ def test_get_definition_of_definition_inside_recursive(self):
+ definition_query = list(
+ sdn.get_definitions(
+ self.netlist.top_instance.reference, selection="INSIDE", recursive=True
+ )
+ )
+ self.assertTrue(
+ len(definition_query) == 3
+ and self.netlist.top_instance.reference not in definition_query
+ )
+
+ def test_get_definition_from_outer_pins(self):
+ definition_query = list(sdn.get_definitions(self.leaf_inst.pins))
+ self.assertTrue(
+ len(definition_query) == 1
+ and definition_query[0] == self.leaf_inst.reference
+ )
+
+ def test_get_definition_from_inner_pins(self):
+ definition_query = list(
+ sdn.get_definitions(self.leaf_inst.reference.ports[0].pins[0])
+ )
+ self.assertTrue(
+ len(definition_query) == 1
+ and definition_query[0] == self.leaf_inst.reference
+ )
+
+ def test_get_definition_from_wire(self):
+ definition_query = list(
+ sdn.get_definitions(self.netlist.top_instance.reference.cables[0].wires[0])
+ )
+ self.assertTrue(
+ len(definition_query) == 1
+ and definition_query[0] == self.netlist.top_instance.reference
+ )
+
+ def test_get_definition_from_href(self):
+ href = next(sdn.get_hinstances(self.netlist.top_instance))
+ definition_query = list(sdn.get_definitions(href))
+ self.assertTrue(
+ len(definition_query) == 1
+ and definition_query[0] == self.netlist.top_instance.reference
+ )
+
+ def test_unique_query_return(self):
+ definition_query = list(
+ sdn.get_definitions([self.netlist.libraries[0], self.leaf_inst], "leaf")
+ )
+ self.assertTrue(
+ len(definition_query) == 1
+ and definition_query[0] == self.leaf_inst.reference
+ )
+
+ def test_absolute_pattern_from_relative_query(self):
+ definition_query = list(sdn.get_definitions(self.leaf_inst, "leaf"))
+ self.assertTrue(
+ len(definition_query) == 1
+ and definition_query[0] == self.leaf_inst.reference
+ )
diff --git a/spydrnet/util/tests/test_get_hcables.py b/tests/spydrnet/util/tests/test_get_hcables.py
similarity index 74%
rename from spydrnet/util/tests/test_get_hcables.py
rename to tests/spydrnet/util/tests/test_get_hcables.py
index 901036ec..186fbaa2 100644
--- a/spydrnet/util/tests/test_get_hcables.py
+++ b/tests/spydrnet/util/tests/test_get_hcables.py
@@ -7,29 +7,36 @@ class TestGetHCables(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
- cls.netlist = sdn.load_example_netlist_by_name('b13')
+ cls.netlist = sdn.load_example_netlist_by_name("b13")
def test_wild_card_search_on_netlist(self):
hrefs = list(sdn.get_hcables(self.netlist))
- self.assertTrue(len(hrefs) == 76 and all(
- isinstance(x.item, sdn.Cable) for x in hrefs))
+ self.assertTrue(
+ len(hrefs) == 76 and all(isinstance(x.item, sdn.Cable) for x in hrefs)
+ )
def test_absolute_search(self):
- href = next(self.netlist.get_hcables(''), None)
+ href = next(self.netlist.get_hcables(""), None)
self.assertIsNotNone(href)
self.assertIsInstance(href.item, sdn.Cable)
def test_regex_search(self):
- hrefs = list(sdn.get_hcables(
- self.netlist, '.*FSM_onehot.*', is_re=True))
- self.assertTrue(len(hrefs) == 8 and all(
- isinstance(x.item, sdn.Cable) for x in hrefs))
+ hrefs = list(sdn.get_hcables(self.netlist, ".*FSM_onehot.*", is_re=True))
+ self.assertTrue(
+ len(hrefs) == 8 and all(isinstance(x.item, sdn.Cable) for x in hrefs)
+ )
def test_parameters(self):
- self.assertRaises(TypeError, sdn.get_hcables, self.netlist,
- r'.*FSM_onehot.*', patterns=r".*FSM_onehot.*")
- self.assertRaises(TypeError, sdn.get_hcables,
- self.netlist, parameter_does_not_exit=True)
+ self.assertRaises(
+ TypeError,
+ sdn.get_hcables,
+ self.netlist,
+ r".*FSM_onehot.*",
+ patterns=r".*FSM_onehot.*",
+ )
+ self.assertRaises(
+ TypeError, sdn.get_hcables, self.netlist, parameter_does_not_exit=True
+ )
self.assertRaises(TypeError, sdn.get_hcables, object())
def test_get_hcables_of_pin(self):
@@ -52,6 +59,7 @@ def test_get_hcables_of_wire(self):
def test_get_hwire_of_invalid_reference(self):
from spydrnet.util.hierarchical_reference import HRef
+
invalid_href = HRef.from_parent_and_item(None, None)
hrefs = list(sdn.get_hcables(invalid_href))
self.assertTrue(len(hrefs) == 0)
@@ -64,6 +72,7 @@ def test_get_hcables_from_hrefs_of_cable_and_wire(self):
hrefs = list(sdn.get_hinstances(wire))
href_top = hrefs[0]
from spydrnet.util.hierarchical_reference import HRef
+
cable_href = HRef.from_parent_and_item(href_top, cable)
self.assertIsInstance(cable_href.item, sdn.Cable)
wire_href = HRef.from_parent_and_item(cable_href, wire)
@@ -81,6 +90,7 @@ def test_get_hcables_from_hrefs_of_port_and_pin(self):
href = hrefs[0]
self.assertIsInstance(href.item, sdn.Cable)
from spydrnet.util.hierarchical_reference import HRef
+
port_href = HRef.from_parent_and_item(href.parent, port)
href_result = next(sdn.get_hcables(port_href), None)
self.assertTrue(href_result is href)
@@ -91,19 +101,21 @@ def test_get_hcables_from_hrefs_of_port_and_pin(self):
def test_from_href_of_instance(self):
href = next(sdn.get_hinstances(self.netlist.top_instance))
hrefs = list(sdn.get_hcables(href))
- self.assertTrue(len(hrefs) == 76 and all(
- isinstance(x.item, sdn.Cable) for x in hrefs))
+ self.assertTrue(
+ len(hrefs) == 76 and all(isinstance(x.item, sdn.Cable) for x in hrefs)
+ )
def test_from_instance(self):
hrefs = list(sdn.get_hcables(self.netlist.top_instance))
- self.assertTrue(len(hrefs) == 76 and all(
- isinstance(x.item, sdn.Cable) for x in hrefs))
+ self.assertTrue(
+ len(hrefs) == 76 and all(isinstance(x.item, sdn.Cable) for x in hrefs)
+ )
def test_from_library(self):
- hrefs = list(sdn.get_hcables(
- self.netlist.libraries[0], selection=sdn.OUTSIDE))
- self.assertTrue(len(hrefs) == 76 and all(
- isinstance(x.item, sdn.Cable) for x in hrefs))
+ hrefs = list(sdn.get_hcables(self.netlist.libraries[0], selection=sdn.OUTSIDE))
+ self.assertTrue(
+ len(hrefs) == 76 and all(isinstance(x.item, sdn.Cable) for x in hrefs)
+ )
def test_from_wire_and_cable(self):
library = self.netlist.libraries[1]
@@ -111,11 +123,13 @@ def test_from_wire_and_cable(self):
cable = definition.cables[0]
wire = cable.wires[0]
hrefs = list(sdn.get_hcables(wire))
- self.assertTrue(len(hrefs) == 1 and all(
- isinstance(x.item, sdn.Cable) for x in hrefs))
+ self.assertTrue(
+ len(hrefs) == 1 and all(isinstance(x.item, sdn.Cable) for x in hrefs)
+ )
hrefs = list(sdn.get_hcables(cable))
- self.assertTrue(len(hrefs) == 1 and all(
- isinstance(x.item, sdn.Cable) for x in hrefs))
+ self.assertTrue(
+ len(hrefs) == 1 and all(isinstance(x.item, sdn.Cable) for x in hrefs)
+ )
def test_from_outerpin(self):
library = self.netlist.libraries[1]
@@ -123,12 +137,14 @@ def test_from_outerpin(self):
instance = definition.children[0]
outerpin = next(iter(instance.pins))
hrefs = list(sdn.get_hcables(outerpin, selection="OUTSIDE"))
- self.assertTrue(len(hrefs) == 1 and all(
- isinstance(x.item, sdn.Cable) for x in hrefs))
+ self.assertTrue(
+ len(hrefs) == 1 and all(isinstance(x.item, sdn.Cable) for x in hrefs)
+ )
def test_bad_selection_type(self):
- self.assertRaises(TypeError, self.netlist.get_hcables,
- selection="NOT_AN_OPTION")
+ self.assertRaises(
+ TypeError, self.netlist.get_hcables, selection="NOT_AN_OPTION"
+ )
self.assertRaises(TypeError, self.netlist.get_hcables, selection=None)
def test_of_bad_instance(self):
@@ -155,34 +171,36 @@ def test_through_hierarchy(self):
top_inst_href = next(sdn.get_hinstances(netlist.top_instance))
hrefs = list(sdn.get_hcables(top_inst_href, recursive=True))
- self.assertTrue(len(hrefs) == 1 and all(
- isinstance(x.item, sdn.Cable) for x in hrefs))
+ self.assertTrue(
+ len(hrefs) == 1 and all(isinstance(x.item, sdn.Cable) for x in hrefs)
+ )
hrefs = list(sdn.get_hcables(middle_inst))
- self.assertTrue(len(hrefs) == 1 and all(
- isinstance(x.item, sdn.Cable) for x in hrefs))
+ self.assertTrue(
+ len(hrefs) == 1 and all(isinstance(x.item, sdn.Cable) for x in hrefs)
+ )
def test_through_hierarchy_again(self):
netlist = sdn.Netlist()
library = netlist.create_library()
- library.name = 'work'
+ library.name = "work"
leaf_def = library.create_definition()
- leaf_def.name = 'leaf'
+ leaf_def.name = "leaf"
leaf_port = leaf_def.create_port()
- leaf_port.name = 'I'
+ leaf_port.name = "I"
leaf_port.create_pins(1)
bottom_def = library.create_definition()
- bottom_def.name = 'bottom'
+ bottom_def.name = "bottom"
bottom_port = bottom_def.create_port()
- bottom_port.name = 'I'
+ bottom_port.name = "I"
bottom_port.create_pins(1)
leaf_inst = bottom_def.create_child()
leaf_inst.reference = leaf_def
bottom_cable = bottom_def.create_cable()
- bottom_cable.name = 'bottom_cable'
+ bottom_cable.name = "bottom_cable"
bottom_wire = bottom_cable.create_wire()
bottom_wire.connect_pin(bottom_port.pins[0])
bottom_wire.connect_pin(leaf_inst.pins[leaf_port.pins[0]])
@@ -190,12 +208,12 @@ def test_through_hierarchy_again(self):
bottom_floating_wire = bottom_cable.create_wire()
middle_def = library.create_definition()
- middle_def.name = 'middle'
+ middle_def.name = "middle"
middle_port = middle_def.create_port()
middle_port.name = "I"
middle_port.create_pin()
bottom_inst = middle_def.create_child()
- bottom_inst.name = 'bottom'
+ bottom_inst.name = "bottom"
bottom_inst.reference = bottom_def
middle_cable = middle_def.create_cable()
middle_cable.name = "middle_cable"
@@ -206,12 +224,12 @@ def test_through_hierarchy_again(self):
middle_floating_wire = middle_cable.create_wire()
top_def = library.create_definition()
- top_def.name = 'top'
+ top_def.name = "top"
top_port = top_def.create_port()
top_port.name = "I"
top_port.create_pin()
middle_inst = top_def.create_child()
- middle_inst.name = 'middle'
+ middle_inst.name = "middle"
middle_inst.reference = middle_def
top_cable = top_def.create_cable()
top_cable.name = "top_cable"
@@ -222,7 +240,7 @@ def test_through_hierarchy_again(self):
top_floating_wire = top_cable.create_wire()
top_instance = sdn.Instance()
- top_instance.name = 'top'
+ top_instance.name = "top"
top_instance.reference = top_def
netlist.top_instance = top_instance
@@ -232,7 +250,7 @@ def test_through_hierarchy_again(self):
# look at wire_name
href = next(sdn.get_hcables(middle_floating_wire))
- self.assertTrue('middle/middle_cable[1]', href.name)
+ self.assertTrue("middle/middle_cable[1]", href.name)
hrefs = set(sdn.get_hcables(netlist.top_instance, recursive=True))
self.assertTrue(href in hrefs)
@@ -241,12 +259,19 @@ def test_through_hierarchy_again(self):
href_middle_wire = next(sdn.get_hcables(middle_cable.wires[0]))
href_bottom_wire = next(sdn.get_hcables(bottom_cable.wires[0]))
self.assertTrue(
- href_top_wire in hrefs and href_middle_wire not in hrefs and href_bottom_wire in hrefs)
+ href_top_wire in hrefs
+ and href_middle_wire not in hrefs
+ and href_bottom_wire in hrefs
+ )
hrefs = set(sdn.get_hcables(middle_cable, selection="ALL"))
href_middle_floating_wire = next(sdn.get_hcables(middle_floating_wire))
- self.assertTrue(href_top_wire in hrefs and href_middle_wire in hrefs and href_bottom_wire in hrefs and
- href_middle_floating_wire in hrefs)
+ self.assertTrue(
+ href_top_wire in hrefs
+ and href_middle_wire in hrefs
+ and href_bottom_wire in hrefs
+ and href_middle_floating_wire in hrefs
+ )
all_wires = set(netlist.get_hcables())
self.assertTrue(len(all_wires) == 1)
diff --git a/spydrnet/util/tests/test_get_hinstances.py b/tests/spydrnet/util/tests/test_get_hinstances.py
similarity index 88%
rename from spydrnet/util/tests/test_get_hinstances.py
rename to tests/spydrnet/util/tests/test_get_hinstances.py
index 0a374d55..744388d7 100644
--- a/spydrnet/util/tests/test_get_hinstances.py
+++ b/tests/spydrnet/util/tests/test_get_hinstances.py
@@ -4,21 +4,30 @@
class TestGetHInstances(unittest.TestCase):
netlist = None
+
@classmethod
def setUpClass(cls) -> None:
- cls.netlist = sdn.load_example_netlist_by_name('b13')
+ cls.netlist = sdn.load_example_netlist_by_name("b13")
def test_absolute_search(self):
- href = next(self.netlist.get_hinstances('tx_end_reg'), None)
+ href = next(self.netlist.get_hinstances("tx_end_reg"), None)
self.assertIsNotNone(href)
def test_regex_search(self):
- hrefs = list(sdn.get_hinstances(self.netlist, '.*FSM_onehot.*', is_re=True))
+ hrefs = list(sdn.get_hinstances(self.netlist, ".*FSM_onehot.*", is_re=True))
self.assertTrue(len(hrefs) == 24)
def test_parameters(self):
- self.assertRaises(TypeError, sdn.get_hinstances, self.netlist, r'.*FSM_onehot.*', patterns=r".*FSM_onehot.*")
- self.assertRaises(TypeError, sdn.get_hinstances, self.netlist, parameter_does_not_exit=True)
+ self.assertRaises(
+ TypeError,
+ sdn.get_hinstances,
+ self.netlist,
+ r".*FSM_onehot.*",
+ patterns=r".*FSM_onehot.*",
+ )
+ self.assertRaises(
+ TypeError, sdn.get_hinstances, self.netlist, parameter_does_not_exit=True
+ )
self.assertRaises(TypeError, sdn.get_hinstances, object())
def test_get_hinstances_of_pin(self):
@@ -39,6 +48,7 @@ def test_get_hinstances_of_wire(self):
def test_get_hinstance_of_invalid_reference(self):
from spydrnet.util.hierarchical_reference import HRef
+
invalid_href = HRef.from_parent_and_item(None, None)
hrefs = list(sdn.get_hinstances(invalid_href))
self.assertTrue(len(hrefs) == 0)
@@ -51,6 +61,7 @@ def test_get_hinstances_from_hrefs_of_cable_and_wire(self):
hrefs = list(sdn.get_hinstances(wire))
href_top = hrefs[0]
from spydrnet.util.hierarchical_reference import HRef
+
cable_href = HRef.from_parent_and_item(href_top, cable)
href_result = next(sdn.get_hinstances(cable_href), None)
self.assertTrue(href_result is href_top)
@@ -66,6 +77,7 @@ def test_get_hinstances_from_hrefs_of_port_and_pin(self):
hrefs = list(sdn.get_hinstances(pin))
href = hrefs[0]
from spydrnet.util.hierarchical_reference import HRef
+
port_href = HRef.from_parent_and_item(href, port)
href_result = next(sdn.get_hinstances(port_href), None)
self.assertTrue(href_result is href)
@@ -127,6 +139,6 @@ def test_through_hierarchy(self):
@unittest.skip("Test takes too long at this time.")
def test_recursive_memory_use(self):
- netlist = sdn.load_example_netlist_by_name('leon3mp_hierarchical')
+ netlist = sdn.load_example_netlist_by_name("leon3mp_hierarchical")
hrefs = list(sdn.get_hinstances(netlist))
self.assertTrue(len(hrefs) > 0)
diff --git a/spydrnet/util/tests/test_get_hpins.py b/tests/spydrnet/util/tests/test_get_hpins.py
similarity index 74%
rename from spydrnet/util/tests/test_get_hpins.py
rename to tests/spydrnet/util/tests/test_get_hpins.py
index 20e013bb..3cd2d1e1 100644
--- a/spydrnet/util/tests/test_get_hpins.py
+++ b/tests/spydrnet/util/tests/test_get_hpins.py
@@ -4,34 +4,49 @@
class TestGetHPins(unittest.TestCase):
netlist = None
+
@classmethod
def setUpClass(cls) -> None:
- cls.netlist = sdn.load_example_netlist_by_name('b13')
+ cls.netlist = sdn.load_example_netlist_by_name("b13")
def test_wild_card_search_on_netlist(self):
hrefs = list(sdn.get_hpins(self.netlist))
- self.assertTrue(len(hrefs) == 22 and all(isinstance(x.item, sdn.InnerPin) for x in hrefs))
+ self.assertTrue(
+ len(hrefs) == 22 and all(isinstance(x.item, sdn.InnerPin) for x in hrefs)
+ )
def test_wild_card_search_on_netlist_recursive(self):
hrefs = list(sdn.get_hpins(self.netlist, recursive=True))
- self.assertTrue(len(hrefs) == 510 and all(isinstance(x.item, sdn.InnerPin) for x in hrefs))
+ self.assertTrue(
+ len(hrefs) == 510 and all(isinstance(x.item, sdn.InnerPin) for x in hrefs)
+ )
def test_absolute_search_excluded(self):
- href = next(self.netlist.get_hpins('this_is_not_contained'), None)
+ href = next(self.netlist.get_hpins("this_is_not_contained"), None)
self.assertIsNone(href)
def test_absolute_search(self):
- href = next(self.netlist.get_hpins('clock'), None)
+ href = next(self.netlist.get_hpins("clock"), None)
self.assertIsNotNone(href)
self.assertIsInstance(href.item, sdn.InnerPin)
def test_regex_search(self):
- hrefs = list(sdn.get_hpins(self.netlist, '.*dAtA.*', is_re=True, is_case=False))
- self.assertTrue(len(hrefs) == 9 and all(isinstance(x.item, sdn.InnerPin) for x in hrefs))
+ hrefs = list(sdn.get_hpins(self.netlist, ".*dAtA.*", is_re=True, is_case=False))
+ self.assertTrue(
+ len(hrefs) == 9 and all(isinstance(x.item, sdn.InnerPin) for x in hrefs)
+ )
def test_parameters(self):
- self.assertRaises(TypeError, sdn.get_hpins, self.netlist, r'.*FSM_onehot.*', patterns=r".*FSM_onehot.*")
- self.assertRaises(TypeError, sdn.get_hpins, self.netlist, parameter_does_not_exit=True)
+ self.assertRaises(
+ TypeError,
+ sdn.get_hpins,
+ self.netlist,
+ r".*FSM_onehot.*",
+ patterns=r".*FSM_onehot.*",
+ )
+ self.assertRaises(
+ TypeError, sdn.get_hpins, self.netlist, parameter_does_not_exit=True
+ )
self.assertRaises(TypeError, sdn.get_hpins, object())
def test_get_hpins_of_pin(self):
@@ -54,6 +69,7 @@ def test_get_hpins_of_wire(self):
def test_get_hwire_of_invalid_reference(self):
from spydrnet.util.hierarchical_reference import HRef
+
invalid_href = HRef.from_parent_and_item(None, None)
hrefs = list(sdn.get_hpins(invalid_href))
self.assertTrue(len(hrefs) == 0)
@@ -86,6 +102,7 @@ def test_get_hpins_from_hrefs_of_port_and_pin(self):
hrefs = list(sdn.get_hinstances(pin))
href = hrefs[0]
from spydrnet.util.hierarchical_reference import HRef
+
port_href = HRef.from_parent_and_item(href, port)
pin_href = HRef.from_parent_and_item(port_href, pin)
href_result = next(sdn.get_hpins(port_href), None)
@@ -96,15 +113,21 @@ def test_get_hpins_from_hrefs_of_port_and_pin(self):
def test_from_href_of_instance(self):
href = next(sdn.get_hinstances(self.netlist.top_instance))
hrefs = list(sdn.get_hpins(href))
- self.assertTrue(len(hrefs) == 22 and all(isinstance(x.item, sdn.InnerPin) for x in hrefs))
+ self.assertTrue(
+ len(hrefs) == 22 and all(isinstance(x.item, sdn.InnerPin) for x in hrefs)
+ )
def test_from_instance(self):
hrefs = list(sdn.get_hpins(self.netlist.top_instance))
- self.assertTrue(len(hrefs) == 22 and all(isinstance(x.item, sdn.InnerPin) for x in hrefs))
+ self.assertTrue(
+ len(hrefs) == 22 and all(isinstance(x.item, sdn.InnerPin) for x in hrefs)
+ )
def test_from_library(self):
hrefs = list(sdn.get_hpins(self.netlist.libraries[0]))
- self.assertTrue(len(hrefs) == 488 and all(isinstance(x.item, sdn.InnerPin) for x in hrefs))
+ self.assertTrue(
+ len(hrefs) == 488 and all(isinstance(x.item, sdn.InnerPin) for x in hrefs)
+ )
def test_from_wire_and_cable(self):
library = self.netlist.libraries[1]
@@ -112,9 +135,13 @@ def test_from_wire_and_cable(self):
cable = definition.cables[0]
wire = cable.wires[0]
hrefs = list(sdn.get_hpins(wire))
- self.assertTrue(len(hrefs) == 2 and all(isinstance(x.item, sdn.InnerPin) for x in hrefs))
+ self.assertTrue(
+ len(hrefs) == 2 and all(isinstance(x.item, sdn.InnerPin) for x in hrefs)
+ )
hrefs = list(sdn.get_hpins(cable))
- self.assertTrue(len(hrefs) == 2 and all(isinstance(x.item, sdn.InnerPin) for x in hrefs))
+ self.assertTrue(
+ len(hrefs) == 2 and all(isinstance(x.item, sdn.InnerPin) for x in hrefs)
+ )
def test_from_outerpin(self):
library = self.netlist.libraries[1]
@@ -122,7 +149,9 @@ def test_from_outerpin(self):
instance = definition.children[0]
outerpin = next(iter(instance.pins))
hrefs = list(sdn.get_hpins(outerpin))
- self.assertTrue(len(hrefs) == 1 and all(isinstance(x.item, sdn.InnerPin) for x in hrefs))
+ self.assertTrue(
+ len(hrefs) == 1 and all(isinstance(x.item, sdn.InnerPin) for x in hrefs)
+ )
def test_bad_selection_type(self):
self.assertRaises(TypeError, self.netlist.get_hpins, selection="NOT_AN_OPTION")
@@ -136,24 +165,24 @@ def test_through_hierarchy_again(self):
netlist = sdn.Netlist()
library = netlist.create_library()
- library.name = 'work'
+ library.name = "work"
leaf_def = library.create_definition()
- leaf_def.name = 'leaf'
+ leaf_def.name = "leaf"
leaf_port = leaf_def.create_port()
- leaf_port.name = 'I'
+ leaf_port.name = "I"
leaf_port.create_pins(1)
bottom_def = library.create_definition()
- bottom_def.name = 'bottom'
+ bottom_def.name = "bottom"
bottom_port = bottom_def.create_port()
- bottom_port.name = 'I'
+ bottom_port.name = "I"
bottom_port.create_pins(1)
leaf_inst = bottom_def.create_child()
- leaf_inst.name = 'leaf'
+ leaf_inst.name = "leaf"
leaf_inst.reference = leaf_def
bottom_cable = bottom_def.create_cable()
- bottom_cable.name = 'bottom_cable'
+ bottom_cable.name = "bottom_cable"
bottom_wire = bottom_cable.create_wire()
bottom_wire.connect_pin(bottom_port.pins[0])
bottom_wire.connect_pin(leaf_inst.pins[leaf_port.pins[0]])
@@ -161,12 +190,12 @@ def test_through_hierarchy_again(self):
bottom_floating_wire = bottom_cable.create_wire()
middle_def = library.create_definition()
- middle_def.name = 'middle'
+ middle_def.name = "middle"
middle_port = middle_def.create_port()
middle_port.name = "I"
middle_port.create_pin()
bottom_inst = middle_def.create_child()
- bottom_inst.name = 'bottom'
+ bottom_inst.name = "bottom"
bottom_inst.reference = bottom_def
middle_cable = middle_def.create_cable()
middle_cable.name = "middle_cable"
@@ -177,12 +206,12 @@ def test_through_hierarchy_again(self):
middle_floating_wire = middle_cable.create_wire()
top_def = library.create_definition()
- top_def.name = 'top'
+ top_def.name = "top"
top_port = top_def.create_port()
top_port.name = "I"
top_port.create_pin()
middle_inst = top_def.create_child()
- middle_inst.name = 'middle'
+ middle_inst.name = "middle"
middle_inst.reference = middle_def
top_cable = top_def.create_cable()
top_cable.name = "top_cable"
@@ -193,13 +222,13 @@ def test_through_hierarchy_again(self):
top_floating_wire = top_cable.create_wire()
top_instance = sdn.Instance()
- top_instance.name = 'top'
+ top_instance.name = "top"
top_instance.reference = top_def
netlist.top_instance = top_instance
- #look at wire_name
- href = next(netlist.get_hpins('I'))
- self.assertTrue('clock', href.name)
+ # look at wire_name
+ href = next(netlist.get_hpins("I"))
+ self.assertTrue("clock", href.name)
hrefs = set(sdn.get_hpins(netlist.top_instance, recursive=True))
self.assertTrue(href in hrefs)
@@ -207,10 +236,18 @@ def test_through_hierarchy_again(self):
href_top_pin = next(sdn.get_hpins(top_port.pins[0]))
href_middle_pin = next(sdn.get_hpins(middle_port.pins[0]))
href_bottom_pin = next(sdn.get_hpins(bottom_port.pins[0]))
- self.assertTrue(href_top_pin not in hrefs and href_middle_pin in hrefs and href_bottom_pin in hrefs)
+ self.assertTrue(
+ href_top_pin not in hrefs
+ and href_middle_pin in hrefs
+ and href_bottom_pin in hrefs
+ )
hrefs = set(sdn.get_hpins(top_def, recursive=True))
- self.assertTrue(href_top_pin in hrefs and href_middle_pin in hrefs and href_bottom_pin in hrefs)
+ self.assertTrue(
+ href_top_pin in hrefs
+ and href_middle_pin in hrefs
+ and href_bottom_pin in hrefs
+ )
all_pins = set(netlist.get_hpins())
self.assertTrue(len(all_pins) == 1)
diff --git a/spydrnet/util/tests/test_get_hports.py b/tests/spydrnet/util/tests/test_get_hports.py
similarity index 74%
rename from spydrnet/util/tests/test_get_hports.py
rename to tests/spydrnet/util/tests/test_get_hports.py
index a43cacfa..38fe0f28 100644
--- a/spydrnet/util/tests/test_get_hports.py
+++ b/tests/spydrnet/util/tests/test_get_hports.py
@@ -4,34 +4,51 @@
class TestGetHPorts(unittest.TestCase):
netlist = None
+
@classmethod
def setUpClass(cls) -> None:
- cls.netlist = sdn.load_example_netlist_by_name('b13')
+ cls.netlist = sdn.load_example_netlist_by_name("b13")
def test_wild_card_search_on_netlist(self):
hrefs = list(sdn.get_hports(self.netlist))
- self.assertTrue(len(hrefs) == 12 and all(isinstance(x.item, sdn.Port) for x in hrefs))
+ self.assertTrue(
+ len(hrefs) == 12 and all(isinstance(x.item, sdn.Port) for x in hrefs)
+ )
def test_wild_card_search_on_netlist_recursive(self):
hrefs = list(sdn.get_hports(self.netlist, recursive=True))
- self.assertTrue(len(hrefs) == 500 and all(isinstance(x.item, sdn.Port) for x in hrefs))
+ self.assertTrue(
+ len(hrefs) == 500 and all(isinstance(x.item, sdn.Port) for x in hrefs)
+ )
def test_absolute_search_excluded(self):
- href = next(self.netlist.get_hports('this_is_not_contained'), None)
+ href = next(self.netlist.get_hports("this_is_not_contained"), None)
self.assertIsNone(href)
def test_absolute_search(self):
- href = next(self.netlist.get_hports('clock'), None)
+ href = next(self.netlist.get_hports("clock"), None)
self.assertIsNotNone(href)
self.assertIsInstance(href.item, sdn.Port)
def test_regex_search(self):
- hrefs = list(sdn.get_hports(self.netlist, '.*dAtA.*', is_re=True, is_case=False))
- self.assertTrue(len(hrefs) == 2 and all(isinstance(x.item, sdn.Port) for x in hrefs))
+ hrefs = list(
+ sdn.get_hports(self.netlist, ".*dAtA.*", is_re=True, is_case=False)
+ )
+ self.assertTrue(
+ len(hrefs) == 2 and all(isinstance(x.item, sdn.Port) for x in hrefs)
+ )
def test_parameters(self):
- self.assertRaises(TypeError, sdn.get_hports, self.netlist, r'.*FSM_onehot.*', patterns=r".*FSM_onehot.*")
- self.assertRaises(TypeError, sdn.get_hports, self.netlist, parameter_does_not_exit=True)
+ self.assertRaises(
+ TypeError,
+ sdn.get_hports,
+ self.netlist,
+ r".*FSM_onehot.*",
+ patterns=r".*FSM_onehot.*",
+ )
+ self.assertRaises(
+ TypeError, sdn.get_hports, self.netlist, parameter_does_not_exit=True
+ )
self.assertRaises(TypeError, sdn.get_hports, object())
def test_get_hports_of_pin(self):
@@ -54,6 +71,7 @@ def test_get_hports_of_wire(self):
def test_get_hwire_of_invalid_reference(self):
from spydrnet.util.hierarchical_reference import HRef
+
invalid_href = HRef.from_parent_and_item(None, None)
hrefs = list(sdn.get_hports(invalid_href))
self.assertTrue(len(hrefs) == 0)
@@ -86,6 +104,7 @@ def test_get_hports_from_hrefs_of_port_and_pin(self):
hrefs = list(sdn.get_hinstances(pin))
href = hrefs[0]
from spydrnet.util.hierarchical_reference import HRef
+
port_href = HRef.from_parent_and_item(href, port)
pin_href = HRef.from_parent_and_item(port_href, pin)
href_result = next(sdn.get_hports(port_href), None)
@@ -96,15 +115,21 @@ def test_get_hports_from_hrefs_of_port_and_pin(self):
def test_from_href_of_instance(self):
href = next(sdn.get_hinstances(self.netlist.top_instance))
hrefs = list(sdn.get_hports(href))
- self.assertTrue(len(hrefs) == 12 and all(isinstance(x.item, sdn.Port) for x in hrefs))
+ self.assertTrue(
+ len(hrefs) == 12 and all(isinstance(x.item, sdn.Port) for x in hrefs)
+ )
def test_from_instance(self):
hrefs = list(sdn.get_hports(self.netlist.top_instance))
- self.assertTrue(len(hrefs) == 12 and all(isinstance(x.item, sdn.Port) for x in hrefs))
+ self.assertTrue(
+ len(hrefs) == 12 and all(isinstance(x.item, sdn.Port) for x in hrefs)
+ )
def test_from_library(self):
hrefs = list(sdn.get_hports(self.netlist.libraries[0]))
- self.assertTrue(len(hrefs) == 488 and all(isinstance(x.item, sdn.Port) for x in hrefs))
+ self.assertTrue(
+ len(hrefs) == 488 and all(isinstance(x.item, sdn.Port) for x in hrefs)
+ )
def test_from_wire_and_cable(self):
library = self.netlist.libraries[1]
@@ -112,9 +137,13 @@ def test_from_wire_and_cable(self):
cable = definition.cables[0]
wire = cable.wires[0]
hrefs = list(sdn.get_hports(wire))
- self.assertTrue(len(hrefs) == 2 and all(isinstance(x.item, sdn.Port) for x in hrefs))
+ self.assertTrue(
+ len(hrefs) == 2 and all(isinstance(x.item, sdn.Port) for x in hrefs)
+ )
hrefs = list(sdn.get_hports(cable))
- self.assertTrue(len(hrefs) == 2 and all(isinstance(x.item, sdn.Port) for x in hrefs))
+ self.assertTrue(
+ len(hrefs) == 2 and all(isinstance(x.item, sdn.Port) for x in hrefs)
+ )
def test_from_outerpin(self):
library = self.netlist.libraries[1]
@@ -122,7 +151,9 @@ def test_from_outerpin(self):
instance = definition.children[0]
outerpin = next(iter(instance.pins))
hrefs = list(sdn.get_hports(outerpin))
- self.assertTrue(len(hrefs) == 1 and all(isinstance(x.item, sdn.Port) for x in hrefs))
+ self.assertTrue(
+ len(hrefs) == 1 and all(isinstance(x.item, sdn.Port) for x in hrefs)
+ )
def test_bad_selection_type(self):
self.assertRaises(TypeError, self.netlist.get_hports, selection="NOT_AN_OPTION")
@@ -136,24 +167,24 @@ def test_through_hierarchy_again(self):
netlist = sdn.Netlist()
library = netlist.create_library()
- library.name = 'work'
+ library.name = "work"
leaf_def = library.create_definition()
- leaf_def.name = 'leaf'
+ leaf_def.name = "leaf"
leaf_port = leaf_def.create_port()
- leaf_port.name = 'I'
+ leaf_port.name = "I"
leaf_port.create_pins(1)
bottom_def = library.create_definition()
- bottom_def.name = 'bottom'
+ bottom_def.name = "bottom"
bottom_port = bottom_def.create_port()
- bottom_port.name = 'I'
+ bottom_port.name = "I"
bottom_port.create_pins(1)
leaf_inst = bottom_def.create_child()
- leaf_inst.name = 'leaf'
+ leaf_inst.name = "leaf"
leaf_inst.reference = leaf_def
bottom_cable = bottom_def.create_cable()
- bottom_cable.name = 'bottom_cable'
+ bottom_cable.name = "bottom_cable"
bottom_wire = bottom_cable.create_wire()
bottom_wire.connect_pin(bottom_port.pins[0])
bottom_wire.connect_pin(leaf_inst.pins[leaf_port.pins[0]])
@@ -161,12 +192,12 @@ def test_through_hierarchy_again(self):
bottom_floating_wire = bottom_cable.create_wire()
middle_def = library.create_definition()
- middle_def.name = 'middle'
+ middle_def.name = "middle"
middle_port = middle_def.create_port()
middle_port.name = "I"
middle_port.create_pin()
bottom_inst = middle_def.create_child()
- bottom_inst.name = 'bottom'
+ bottom_inst.name = "bottom"
bottom_inst.reference = bottom_def
middle_cable = middle_def.create_cable()
middle_cable.name = "middle_cable"
@@ -177,12 +208,12 @@ def test_through_hierarchy_again(self):
middle_floating_wire = middle_cable.create_wire()
top_def = library.create_definition()
- top_def.name = 'top'
+ top_def.name = "top"
top_port = top_def.create_port()
top_port.name = "I"
top_port.create_pin()
middle_inst = top_def.create_child()
- middle_inst.name = 'middle'
+ middle_inst.name = "middle"
middle_inst.reference = middle_def
top_cable = top_def.create_cable()
top_cable.name = "top_cable"
@@ -193,13 +224,13 @@ def test_through_hierarchy_again(self):
top_floating_wire = top_cable.create_wire()
top_instance = sdn.Instance()
- top_instance.name = 'top'
+ top_instance.name = "top"
top_instance.reference = top_def
netlist.top_instance = top_instance
- #look at wire_name
- href = next(netlist.get_hports('I'))
- self.assertTrue('clock', href.name)
+ # look at wire_name
+ href = next(netlist.get_hports("I"))
+ self.assertTrue("clock", href.name)
hrefs = set(sdn.get_hports(netlist.top_instance, recursive=True))
self.assertTrue(href in hrefs)
@@ -207,10 +238,18 @@ def test_through_hierarchy_again(self):
href_top_pin = next(sdn.get_hports(top_port.pins[0]))
href_middle_pin = next(sdn.get_hports(middle_port.pins[0]))
href_bottom_pin = next(sdn.get_hports(bottom_port.pins[0]))
- self.assertTrue(href_top_pin not in hrefs and href_middle_pin in hrefs and href_bottom_pin in hrefs)
+ self.assertTrue(
+ href_top_pin not in hrefs
+ and href_middle_pin in hrefs
+ and href_bottom_pin in hrefs
+ )
hrefs = set(sdn.get_hports(top_def, recursive=True))
- self.assertTrue(href_top_pin in hrefs and href_middle_pin in hrefs and href_bottom_pin in hrefs)
+ self.assertTrue(
+ href_top_pin in hrefs
+ and href_middle_pin in hrefs
+ and href_bottom_pin in hrefs
+ )
all_pins = set(netlist.get_hports())
self.assertTrue(len(all_pins) == 1)
diff --git a/spydrnet/util/tests/test_get_hwires.py b/tests/spydrnet/util/tests/test_get_hwires.py
similarity index 76%
rename from spydrnet/util/tests/test_get_hwires.py
rename to tests/spydrnet/util/tests/test_get_hwires.py
index 51d24ec8..5146f22c 100644
--- a/spydrnet/util/tests/test_get_hwires.py
+++ b/tests/spydrnet/util/tests/test_get_hwires.py
@@ -7,26 +7,31 @@ class TestGetHWires(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
- cls.netlist = sdn.load_example_netlist_by_name('b13')
+ cls.netlist = sdn.load_example_netlist_by_name("b13")
def test_wild_card_search_on_netlist(self):
hrefs = list(sdn.get_hwires(self.netlist))
- assert (len(hrefs) > 0)
+ assert len(hrefs) > 0
def test_absolute_search(self):
- href = next(self.netlist.get_hwires(''), None)
+ href = next(self.netlist.get_hwires(""), None)
self.assertIsNotNone(href)
def test_regex_search(self):
- hrefs = list(sdn.get_hwires(
- self.netlist, '.*FSM_onehot.*', is_re=True))
- assert (len(hrefs) == 23)
+ hrefs = list(sdn.get_hwires(self.netlist, ".*FSM_onehot.*", is_re=True))
+ assert len(hrefs) == 23
def test_parameters(self):
- self.assertRaises(TypeError, sdn.get_hwires, self.netlist,
- r'.*FSM_onehot.*', patterns=r".*FSM_onehot.*")
- self.assertRaises(TypeError, sdn.get_hwires,
- self.netlist, parameter_does_not_exit=True)
+ self.assertRaises(
+ TypeError,
+ sdn.get_hwires,
+ self.netlist,
+ r".*FSM_onehot.*",
+ patterns=r".*FSM_onehot.*",
+ )
+ self.assertRaises(
+ TypeError, sdn.get_hwires, self.netlist, parameter_does_not_exit=True
+ )
self.assertRaises(TypeError, sdn.get_hwires, object())
def test_get_hwires_of_pin(self):
@@ -35,7 +40,7 @@ def test_get_hwires_of_pin(self):
port = definition.ports[0]
pin = port.pins[0]
hrefs = list(sdn.get_hwires(pin))
- assert (len(hrefs) == 1)
+ assert len(hrefs) == 1
def test_get_hwires_of_wire(self):
library = self.netlist.libraries[1]
@@ -43,13 +48,14 @@ def test_get_hwires_of_wire(self):
cable = definition.cables[0]
wire = cable.wires[0]
hrefs = list(sdn.get_hwires(wire))
- assert (len(hrefs) == 1)
+ assert len(hrefs) == 1
def test_get_hwire_of_invalid_reference(self):
from spydrnet.util.hierarchical_reference import HRef
+
invalid_href = HRef.from_parent_and_item(None, None)
hrefs = list(sdn.get_hwires(invalid_href))
- assert (len(hrefs) == 0)
+ assert len(hrefs) == 0
def test_get_hwires_from_hrefs_of_cable_and_wire(self):
library = self.netlist.libraries[1]
@@ -59,12 +65,13 @@ def test_get_hwires_from_hrefs_of_cable_and_wire(self):
hrefs = list(sdn.get_hinstances(wire))
href_top = hrefs[0]
from spydrnet.util.hierarchical_reference import HRef
+
cable_href = HRef.from_parent_and_item(href_top, cable)
wire_href = HRef.from_parent_and_item(cable_href, wire)
href_result = next(sdn.get_hwires(cable_href), None)
- assert (href_result is wire_href)
+ assert href_result is wire_href
href_result = next(sdn.get_hwires(wire_href), None)
- assert (href_result is wire_href)
+ assert href_result is wire_href
def test_get_hwires_from_hrefs_of_port_and_pin(self):
library = self.netlist.libraries[1]
@@ -74,26 +81,26 @@ def test_get_hwires_from_hrefs_of_port_and_pin(self):
hrefs = list(sdn.get_hwires(pin))
href = hrefs[0]
from spydrnet.util.hierarchical_reference import HRef
+
port_href = HRef.from_parent_and_item(href.parent.parent, port)
href_result = next(sdn.get_hwires(port_href), None)
- assert (href_result is href)
+ assert href_result is href
pin_href = HRef.from_parent_and_item(port_href, pin)
href_result = next(sdn.get_hwires(pin_href), None)
- assert (href_result is href)
+ assert href_result is href
def test_from_href_of_instance(self):
href = next(sdn.get_hinstances(self.netlist.top_instance))
hrefs = list(sdn.get_hwires(href))
- assert (len(hrefs) == 122)
+ assert len(hrefs) == 122
def test_from_instance(self):
hrefs = list(sdn.get_hwires(self.netlist.top_instance))
- assert (len(hrefs) == 122)
+ assert len(hrefs) == 122
def test_from_library(self):
- hrefs = list(sdn.get_hwires(
- self.netlist.libraries[0], selection=sdn.OUTSIDE))
- assert (len(hrefs) == 114)
+ hrefs = list(sdn.get_hwires(self.netlist.libraries[0], selection=sdn.OUTSIDE))
+ assert len(hrefs) == 114
def test_from_wire_and_cable(self):
library = self.netlist.libraries[1]
@@ -101,9 +108,9 @@ def test_from_wire_and_cable(self):
cable = definition.cables[0]
wire = cable.wires[0]
hrefs = list(sdn.get_hwires(wire))
- assert (len(hrefs) == 1)
+ assert len(hrefs) == 1
hrefs = list(sdn.get_hwires(cable))
- assert (len(hrefs) == 1)
+ assert len(hrefs) == 1
def test_from_outerpin(self):
library = self.netlist.libraries[1]
@@ -111,16 +118,15 @@ def test_from_outerpin(self):
instance = definition.children[0]
outerpin = next(iter(instance.pins))
hrefs = list(sdn.get_hwires(outerpin, selection="OUTSIDE"))
- assert (len(hrefs) == 1)
+ assert len(hrefs) == 1
def test_bad_selection_type(self):
- self.assertRaises(TypeError, self.netlist.get_hwires,
- selection="NOT_AN_OPTION")
+ self.assertRaises(TypeError, self.netlist.get_hwires, selection="NOT_AN_OPTION")
self.assertRaises(TypeError, self.netlist.get_hwires, selection=None)
def test_of_bad_instance(self):
hrefs = list(sdn.get_hwires(sdn.Instance()))
- assert (len(hrefs) == 0)
+ assert len(hrefs) == 0
def test_through_hierarchy(self):
netlist = sdn.Netlist()
@@ -142,32 +148,32 @@ def test_through_hierarchy(self):
top_inst_href = next(sdn.get_hinstances(netlist.top_instance))
hrefs = list(sdn.get_hwires(top_inst_href, recursive=True))
- assert (len(hrefs) == 1)
+ assert len(hrefs) == 1
hrefs = list(sdn.get_hwires(middle_inst))
- assert (len(hrefs) == 1)
+ assert len(hrefs) == 1
def test_through_hierarchy_again(self):
netlist = sdn.Netlist()
library = netlist.create_library()
- library.name = 'work'
+ library.name = "work"
leaf_def = library.create_definition()
- leaf_def.name = 'leaf'
+ leaf_def.name = "leaf"
leaf_port = leaf_def.create_port()
- leaf_port.name = 'I'
+ leaf_port.name = "I"
leaf_port.create_pins(1)
bottom_def = library.create_definition()
- bottom_def.name = 'bottom'
+ bottom_def.name = "bottom"
bottom_port = bottom_def.create_port()
- bottom_port.name = 'I'
+ bottom_port.name = "I"
bottom_port.create_pins(1)
leaf_inst = bottom_def.create_child()
leaf_inst.reference = leaf_def
bottom_cable = bottom_def.create_cable()
- bottom_cable.name = 'bottom_cable'
+ bottom_cable.name = "bottom_cable"
bottom_wire = bottom_cable.create_wire()
bottom_wire.connect_pin(bottom_port.pins[0])
bottom_wire.connect_pin(leaf_inst.pins[leaf_port.pins[0]])
@@ -175,12 +181,12 @@ def test_through_hierarchy_again(self):
bottom_floating_wire = bottom_cable.create_wire()
middle_def = library.create_definition()
- middle_def.name = 'middle'
+ middle_def.name = "middle"
middle_port = middle_def.create_port()
middle_port.name = "I"
middle_port.create_pin()
bottom_inst = middle_def.create_child()
- bottom_inst.name = 'bottom'
+ bottom_inst.name = "bottom"
bottom_inst.reference = bottom_def
middle_cable = middle_def.create_cable()
middle_cable.name = "middle_cable"
@@ -191,12 +197,12 @@ def test_through_hierarchy_again(self):
middle_floating_wire = middle_cable.create_wire()
top_def = library.create_definition()
- top_def.name = 'top'
+ top_def.name = "top"
top_port = top_def.create_port()
top_port.name = "I"
top_port.create_pin()
middle_inst = top_def.create_child()
- middle_inst.name = 'middle'
+ middle_inst.name = "middle"
middle_inst.reference = middle_def
top_cable = top_def.create_cable()
top_cable.name = "top_cable"
@@ -207,34 +213,41 @@ def test_through_hierarchy_again(self):
top_floating_wire = top_cable.create_wire()
top_instance = sdn.Instance()
- top_instance.name = 'top'
+ top_instance.name = "top"
top_instance.reference = top_def
netlist.top_instance = top_instance
href = next(sdn.get_hwires(top_floating_wire))
hrefs = set(sdn.get_hwires(netlist.top_instance))
- assert (href in hrefs)
+ assert href in hrefs
# look at wire_name
href = next(sdn.get_hwires(middle_floating_wire))
- assert ('middle/middle_cable[1]' == href.name)
+ assert "middle/middle_cable[1]" == href.name
hrefs = set(sdn.get_hwires(netlist.top_instance, recursive=True))
- assert (href in hrefs)
+ assert href in hrefs
hrefs = set(sdn.get_hwires(middle_cable, selection="OUTSIDE"))
href_top_wire = next(sdn.get_hwires(top_cable.wires[0]))
href_middle_wire = next(sdn.get_hwires(middle_cable.wires[0]))
href_bottom_wire = next(sdn.get_hwires(bottom_cable.wires[0]))
assert (
- href_top_wire in hrefs and href_middle_wire not in hrefs and href_bottom_wire in hrefs)
+ href_top_wire in hrefs
+ and href_middle_wire not in hrefs
+ and href_bottom_wire in hrefs
+ )
hrefs = set(sdn.get_hwires(middle_cable, selection="ALL"))
href_middle_floating_wire = next(sdn.get_hwires(middle_floating_wire))
- assert (href_top_wire in hrefs and href_middle_wire in hrefs and href_bottom_wire in hrefs and
- href_middle_floating_wire in hrefs)
+ assert (
+ href_top_wire in hrefs
+ and href_middle_wire in hrefs
+ and href_bottom_wire in hrefs
+ and href_middle_floating_wire in hrefs
+ )
all_wires = set(netlist.get_hwires())
- assert (len(all_wires) == 2)
+ assert len(all_wires) == 2
all_wires = set(netlist.get_hwires(recursive=True))
- assert (len(all_wires) == 6)
+ assert len(all_wires) == 6
diff --git a/spydrnet/util/tests/test_get_instances.py b/tests/spydrnet/util/tests/test_get_instances.py
similarity index 83%
rename from spydrnet/util/tests/test_get_instances.py
rename to tests/spydrnet/util/tests/test_get_instances.py
index 0e54403a..e0008804 100644
--- a/spydrnet/util/tests/test_get_instances.py
+++ b/tests/spydrnet/util/tests/test_get_instances.py
@@ -43,9 +43,19 @@ def test_parameter_checking(self):
definition = sdn.Definition()
instance = definition.create_child()
instance.name = "MY_INST"
- self.assertRaises(TypeError, sdn.get_instances, definition, "MY_INST", patterns="MY_INST")
- self.assertRaises(TypeError, sdn.get_instances, definition, "MY_INST", unsupported_keyword=None)
- self.assertRaises(TypeError, sdn.get_instances, definition, "MY_INST", selection=sdn.BOTH)
+ self.assertRaises(
+ TypeError, sdn.get_instances, definition, "MY_INST", patterns="MY_INST"
+ )
+ self.assertRaises(
+ TypeError,
+ sdn.get_instances,
+ definition,
+ "MY_INST",
+ unsupported_keyword=None,
+ )
+ self.assertRaises(
+ TypeError, sdn.get_instances, definition, "MY_INST", selection=sdn.BOTH
+ )
self.assertRaises(TypeError, sdn.get_instances, None, "MY_INST")
self.assertRaises(TypeError, sdn.get_instances, [None, definition], "MY_INST")
@@ -74,11 +84,15 @@ def test_get_instances_from_definition_recursive(self):
self.assertEqual(self.instance, instance1[0])
def test_from_definition_outside_recursive(self):
- instance1 = list(sdn.get_instances(self.definition, selection="OUTSIDE", recursive=True))
+ instance1 = list(
+ sdn.get_instances(self.definition, selection="OUTSIDE", recursive=True)
+ )
self.assertEqual(self.top_instance, instance1[0])
def test_from_leaf_definition_outside_recursive(self):
- instance1 = list(sdn.get_instances(self.leaf_definition, selection="OUTSIDE", recursive=True))
+ instance1 = list(
+ sdn.get_instances(self.leaf_definition, selection="OUTSIDE", recursive=True)
+ )
self.assertEqual(len(instance1), 2)
self.assertTrue(self.top_instance in instance1 and self.instance in instance1)
@@ -87,7 +101,9 @@ def test_from_instance_recursive(self):
self.assertEqual(self.instance, instance1)
def test_from_instance_outside_resursive(self):
- instance1 = list(sdn.get_instances(self.instance, selection="OUTSIDE", recursive=True))
+ instance1 = list(
+ sdn.get_instances(self.instance, selection="OUTSIDE", recursive=True)
+ )
self.assertEqual(self.top_instance, instance1[0])
def test_from_wire(self):
diff --git a/tests/spydrnet/util/tests/test_get_libraries.py b/tests/spydrnet/util/tests/test_get_libraries.py
new file mode 100644
index 00000000..0c05c4ab
--- /dev/null
+++ b/tests/spydrnet/util/tests/test_get_libraries.py
@@ -0,0 +1,240 @@
+import unittest
+import spydrnet as sdn
+
+
+class TestGetLibraries(unittest.TestCase):
+ @classmethod
+ def setUpClass(cls) -> None:
+ cls.netlist = sdn.Netlist()
+
+ leaf_library = cls.netlist.create_library()
+ leaf_library.name = "primitives"
+
+ library = cls.netlist.create_library()
+ library.name = "work"
+
+ leaf_def = leaf_library.create_definition()
+ leaf_def.name = "leaf"
+ leaf_port = leaf_def.create_port()
+ leaf_port.name = "I"
+ leaf_port.create_pins(1)
+
+ bottom_def = library.create_definition()
+ bottom_def.name = "bottom"
+ bottom_port = bottom_def.create_port()
+ bottom_port.name = "I"
+ bottom_port.create_pins(1)
+ leaf_inst = bottom_def.create_child()
+ leaf_inst.reference = leaf_def
+ bottom_cable = bottom_def.create_cable()
+ bottom_cable.name = "bottom_cable"
+ bottom_wire = bottom_cable.create_wire()
+ bottom_wire.connect_pin(bottom_port.pins[0])
+ bottom_wire.connect_pin(leaf_inst.pins[leaf_port.pins[0]])
+ cls.leaf_inst = leaf_inst
+
+ bottom_floating_wire = bottom_cable.create_wire()
+
+ middle_def = library.create_definition()
+ middle_def.name = "middle"
+ middle_port = middle_def.create_port()
+ middle_port.name = "I"
+ middle_port.create_pin()
+ bottom_inst = middle_def.create_child()
+ bottom_inst.name = "bottom"
+ bottom_inst.reference = bottom_def
+ middle_cable = middle_def.create_cable()
+ middle_cable.name = "middle_cable"
+ middle_wire = middle_cable.create_wire()
+ middle_wire.connect_pin(middle_port.pins[0])
+ middle_wire.connect_pin(bottom_inst.pins[bottom_port.pins[0]])
+
+ middle_floating_wire = middle_cable.create_wire()
+
+ top_def = library.create_definition()
+ top_def.name = "top"
+ top_port = top_def.create_port()
+ top_port.name = "I"
+ top_port.create_pin()
+ middle_inst = top_def.create_child()
+ middle_inst.name = "middle"
+ middle_inst.reference = middle_def
+ top_cable = top_def.create_cable()
+ top_cable.name = "top_cable"
+ top_wire = top_cable.create_wire()
+ top_wire.connect_pin(top_port.pins[0])
+ top_wire.connect_pin(middle_inst.pins[middle_port.pins[0]])
+
+ top_floating_wire = top_cable.create_wire()
+
+ top_instance = sdn.Instance()
+ top_instance.name = "top"
+ top_instance.reference = top_def
+ cls.netlist.top_instance = top_instance
+
+ def test_parameter_checking(self):
+ netlist = sdn.Netlist()
+ library = netlist.create_library()
+ library.name = "MY_LIB"
+ self.assertRaises(
+ TypeError, sdn.get_libraries, netlist, "MY_LIB", patterns="MY_LIB"
+ )
+ self.assertRaises(
+ TypeError, sdn.get_libraries, netlist, "MY_LIB", unsupported_keyword=None
+ )
+ self.assertRaises(
+ TypeError, sdn.get_libraries, netlist, "MY_LIB", selection="BOTH"
+ )
+ self.assertRaises(TypeError, sdn.get_libraries, None, "MY_LIB")
+ self.assertRaises(TypeError, sdn.get_libraries, [None, netlist], "MY_LIB")
+
+ def test_collection(self):
+ netlist = sdn.Netlist()
+ library = netlist.create_library()
+ library.name = "MY_LIB"
+ ports = list(sdn.get_libraries([netlist, netlist]))
+ self.assertEqual(len(ports), 1)
+
+ def test_get_library_of_instances_outside(self):
+ library_query = list(
+ sdn.get_libraries(
+ self.netlist.libraries[0].definitions[0].references, selection="OUTSIDE"
+ )
+ )
+ self.assertTrue(
+ len(library_query) == 1 and library_query[0] == self.netlist.libraries[1]
+ )
+
+ def test_get_library_of_instances_inside(self):
+ library_query = list(
+ sdn.get_libraries(
+ self.netlist.libraries[0].definitions[0].references, selection="INSIDE"
+ )
+ )
+ self.assertTrue(
+ len(library_query) == 1 and library_query[0] == self.netlist.libraries[0]
+ )
+
+ def test_get_library_of_instances_recursive_down(self):
+ library_query = list(
+ sdn.get_libraries(self.netlist.top_instance, recursive=True)
+ )
+ self.assertTrue(
+ len(library_query) == 2
+ and all(x in library_query for x in self.netlist.libraries)
+ )
+
+ def test_get_library_of_instances_recursive_up(self):
+ library_query = list(
+ sdn.get_libraries(self.leaf_inst, selection="OUTSIDE", recursive=True)
+ )
+ self.assertTrue(
+ len(library_query) == 1 and library_query[0] is self.netlist.libraries[1]
+ )
+
+ def test_get_library_of_library_recursive_down(self):
+ library_query = list(
+ sdn.get_libraries(
+ self.netlist.libraries[1], selection="INSIDE", recursive=True
+ )
+ )
+ self.assertTrue(
+ len(library_query) == 2
+ and all(x in library_query for x in self.netlist.libraries)
+ )
+
+ def test_get_library_of_library_recursive_up(self):
+ library_query = list(
+ sdn.get_libraries(
+ self.netlist.libraries[0], selection="OUTSIDE", recursive=True
+ )
+ )
+ self.assertTrue(
+ len(library_query) == 1 and library_query[0] is self.netlist.libraries[1]
+ )
+
+ def test_get_library_of_inside_inside(self):
+ library_query = list(
+ sdn.get_libraries(
+ self.netlist.libraries[0].definitions[0], selection="INSIDE"
+ )
+ )
+ self.assertTrue(
+ len(library_query) == 1 and library_query[0] == self.netlist.libraries[0]
+ )
+
+ def test_get_library_of_inside_outside(self):
+ library_query = list(
+ sdn.get_libraries(
+ self.netlist.libraries[0].definitions[0], selection="OUTSIDE"
+ )
+ )
+ self.assertTrue(
+ len(library_query) == 1 and library_query[0] == self.netlist.libraries[1]
+ )
+
+ def test_get_library_of_inside_outside_recursive(self):
+ library_query = list(
+ sdn.get_libraries(
+ self.netlist.libraries[0].definitions[0],
+ selection="OUTSIDE",
+ recursive=True,
+ )
+ )
+ self.assertTrue(
+ len(library_query) == 1 and library_query[0] == self.netlist.libraries[1]
+ )
+
+ def test_get_library_of_inside_inside_recursive(self):
+ library_query = list(
+ sdn.get_libraries(
+ self.netlist.top_instance.reference, selection="INSIDE", recursive=True
+ )
+ )
+ self.assertTrue(
+ len(library_query) == 2
+ and all(x in library_query for x in self.netlist.libraries)
+ )
+
+ def test_get_library_from_outer_pins(self):
+ library_query = list(sdn.get_libraries(self.leaf_inst.pins))
+ self.assertTrue(
+ len(library_query) == 1 and library_query[0] == self.netlist.libraries[0]
+ )
+
+ def test_get_library_from_inner_pins(self):
+ library_query = list(
+ sdn.get_libraries(self.leaf_inst.reference.ports[0].pins[0])
+ )
+ self.assertTrue(
+ len(library_query) == 1 and library_query[0] == self.netlist.libraries[0]
+ )
+
+ def test_get_library_from_wire(self):
+ library_query = list(
+ sdn.get_libraries(self.netlist.top_instance.reference.cables[0].wires[0])
+ )
+ self.assertTrue(
+ len(library_query) == 1 and library_query[0] == self.netlist.libraries[1]
+ )
+
+ def test_get_library_from_href(self):
+ href = next(sdn.get_hinstances(self.netlist.top_instance))
+ library_query = list(sdn.get_libraries(href))
+ self.assertTrue(
+ len(library_query) == 1 and library_query[0] == self.netlist.libraries[1]
+ )
+
+ def test_unique_query_return(self):
+ library_query = list(
+ sdn.get_libraries([self.netlist, self.netlist.top_instance], "work")
+ )
+ self.assertTrue(
+ len(library_query) == 1 and library_query[0] == self.netlist.libraries[1]
+ )
+
+ def test_absolute_pattern_from_relative_query(self):
+ library_query = list(sdn.get_libraries(self.netlist.top_instance, "work"))
+ self.assertTrue(
+ len(library_query) == 1 and library_query[0] == self.netlist.libraries[1]
+ )
diff --git a/spydrnet/util/tests/test_get_netlists.py b/tests/spydrnet/util/tests/test_get_netlists.py
similarity index 92%
rename from spydrnet/util/tests/test_get_netlists.py
rename to tests/spydrnet/util/tests/test_get_netlists.py
index 89dca6be..bca92af5 100644
--- a/spydrnet/util/tests/test_get_netlists.py
+++ b/tests/spydrnet/util/tests/test_get_netlists.py
@@ -7,8 +7,12 @@ def test_parameter_checking(self):
netlist = sdn.Netlist()
library = netlist.create_library()
library.name = "MY_LIB"
- self.assertRaises(TypeError, sdn.get_netlists, netlist, "MY_LIB", patterns="MY_LIB")
- self.assertRaises(TypeError, sdn.get_netlists, netlist, "MY_LIB", unsupported_keyword=None)
+ self.assertRaises(
+ TypeError, sdn.get_netlists, netlist, "MY_LIB", patterns="MY_LIB"
+ )
+ self.assertRaises(
+ TypeError, sdn.get_netlists, netlist, "MY_LIB", unsupported_keyword=None
+ )
self.assertRaises(TypeError, sdn.get_netlists, None, "MY_LIB")
self.assertRaises(TypeError, sdn.get_netlists, [None, netlist], "MY_LIB")
diff --git a/spydrnet/util/tests/test_get_pins.py b/tests/spydrnet/util/tests/test_get_pins.py
similarity index 100%
rename from spydrnet/util/tests/test_get_pins.py
rename to tests/spydrnet/util/tests/test_get_pins.py
diff --git a/spydrnet/util/tests/test_get_ports.py b/tests/spydrnet/util/tests/test_get_ports.py
similarity index 94%
rename from spydrnet/util/tests/test_get_ports.py
rename to tests/spydrnet/util/tests/test_get_ports.py
index 95edbdb5..6f3ac93d 100644
--- a/spydrnet/util/tests/test_get_ports.py
+++ b/tests/spydrnet/util/tests/test_get_ports.py
@@ -7,8 +7,12 @@ def test_parameter_checking(self):
definition = sdn.Definition()
port = definition.create_port()
port.name = "MY_PORT"
- self.assertRaises(TypeError, sdn.get_ports, definition, "MY_PORT", patterns="MY_PORT")
- self.assertRaises(TypeError, sdn.get_ports, definition, "MY_PORT", unsupported_keyword=None)
+ self.assertRaises(
+ TypeError, sdn.get_ports, definition, "MY_PORT", patterns="MY_PORT"
+ )
+ self.assertRaises(
+ TypeError, sdn.get_ports, definition, "MY_PORT", unsupported_keyword=None
+ )
self.assertRaises(TypeError, sdn.get_ports, None, "MY_PORT")
self.assertRaises(TypeError, sdn.get_ports, [None, definition], "MY_PORT")
diff --git a/spydrnet/util/tests/test_get_wires.py b/tests/spydrnet/util/tests/test_get_wires.py
similarity index 77%
rename from spydrnet/util/tests/test_get_wires.py
rename to tests/spydrnet/util/tests/test_get_wires.py
index cd3a02cf..1661aea1 100644
--- a/spydrnet/util/tests/test_get_wires.py
+++ b/tests/spydrnet/util/tests/test_get_wires.py
@@ -8,26 +8,26 @@ def setUpClass(cls) -> None:
cls.netlist = sdn.Netlist()
leaf_library = cls.netlist.create_library()
- leaf_library.name = 'primitives'
+ leaf_library.name = "primitives"
library = cls.netlist.create_library()
- library.name = 'work'
+ library.name = "work"
leaf_def = leaf_library.create_definition()
- leaf_def.name = 'leaf'
+ leaf_def.name = "leaf"
leaf_port = leaf_def.create_port()
- leaf_port.name = 'I'
+ leaf_port.name = "I"
leaf_port.create_pins(1)
bottom_def = library.create_definition()
- bottom_def.name = 'bottom'
+ bottom_def.name = "bottom"
bottom_port = bottom_def.create_port()
- bottom_port.name = 'I'
+ bottom_port.name = "I"
bottom_port.create_pins(1)
leaf_inst = bottom_def.create_child()
leaf_inst.reference = leaf_def
bottom_cable = bottom_def.create_cable()
- bottom_cable.name = 'bottom_cable'
+ bottom_cable.name = "bottom_cable"
bottom_wire = bottom_cable.create_wire()
bottom_wire.connect_pin(bottom_port.pins[0])
bottom_wire.connect_pin(leaf_inst.pins[leaf_port.pins[0]])
@@ -36,12 +36,12 @@ def setUpClass(cls) -> None:
bottom_floating_wire = bottom_cable.create_wire()
middle_def = library.create_definition()
- middle_def.name = 'middle'
+ middle_def.name = "middle"
middle_port = middle_def.create_port()
middle_port.name = "I"
middle_port.create_pin()
bottom_inst = middle_def.create_child()
- bottom_inst.name = 'bottom'
+ bottom_inst.name = "bottom"
bottom_inst.reference = bottom_def
middle_cable = middle_def.create_cable()
middle_cable.name = "middle_cable"
@@ -53,12 +53,12 @@ def setUpClass(cls) -> None:
middle_floating_wire = middle_cable.create_wire()
top_def = library.create_definition()
- top_def.name = 'top'
+ top_def.name = "top"
top_port = top_def.create_port()
top_port.name = "I"
top_port.create_pin()
middle_inst = top_def.create_child()
- middle_inst.name = 'middle'
+ middle_inst.name = "middle"
middle_inst.reference = middle_def
top_cable = top_def.create_cable()
top_cable.name = "top_cable"
@@ -70,7 +70,7 @@ def setUpClass(cls) -> None:
top_floating_wire = top_cable.create_wire()
top_instance = sdn.Instance()
- top_instance.name = 'top'
+ top_instance.name = "top"
top_instance.reference = top_def
cls.netlist.top_instance = top_instance
@@ -85,7 +85,9 @@ def test_parameter_checking(self):
self.assertRaises(TypeError, sdn.get_wires, [None, library])
def test_collection(self):
- wires = list(sdn.get_wires([self.netlist.libraries[1], self.netlist.libraries[1]]))
+ wires = list(
+ sdn.get_wires([self.netlist.libraries[1], self.netlist.libraries[1]])
+ )
self.assertEqual(len(wires), 6)
def test_inside(self):
@@ -97,7 +99,9 @@ def test_both(self):
self.assertEqual(len(wires), 2)
def test_outside(self):
- wires = list(sdn.get_wires(self.middle_inst, selection="OUTSIDE", recursive=True))
+ wires = list(
+ sdn.get_wires(self.middle_inst, selection="OUTSIDE", recursive=True)
+ )
self.assertEqual(len(wires), 1)
def test_wire_inside(self):
@@ -106,26 +110,42 @@ def test_wire_inside(self):
self.assertIs(wires[0], self.middle_inst.reference.cables[0].wires[0])
def test_wire_outside(self):
- wires = list(sdn.get_wires(self.middle_inst.reference.cables[0].wires[0], selection="OUTSIDE"))
+ wires = list(
+ sdn.get_wires(
+ self.middle_inst.reference.cables[0].wires[0], selection="OUTSIDE"
+ )
+ )
self.assertEqual(len(wires), 2)
self.assertTrue(self.middle_inst.reference.cables[0].wires[0] not in wires)
def test_port_outside(self):
- wires = list(sdn.get_wires(self.middle_inst.reference.ports[0], selection="OUTSIDE"))
+ wires = list(
+ sdn.get_wires(self.middle_inst.reference.ports[0], selection="OUTSIDE")
+ )
self.assertEqual(len(wires), 1)
- self.assertTrue(wires[0].cable.name == 'top_cable')
+ self.assertTrue(wires[0].cable.name == "top_cable")
def test_cable_outside(self):
- wires = list(sdn.get_wires(self.middle_inst.reference.cables[0], selection="OUTSIDE"))
+ wires = list(
+ sdn.get_wires(self.middle_inst.reference.cables[0], selection="OUTSIDE")
+ )
self.assertEqual(len(wires), 2)
- self.assertTrue(all(x not in wires for x in self.middle_inst.reference.cables[0].wires))
+ self.assertTrue(
+ all(x not in wires for x in self.middle_inst.reference.cables[0].wires)
+ )
def test_cable_all(self):
- wires = list(sdn.get_wires(self.netlist.top_instance.reference.cables[0].wires[0], selection="ALL"))
+ wires = list(
+ sdn.get_wires(
+ self.netlist.top_instance.reference.cables[0].wires[0], selection="ALL"
+ )
+ )
self.assertEqual(len(wires), 3)
def test_pin_all(self):
- wires = list(sdn.get_wires(self.middle_inst.reference.ports[0].pins[0], selection="ALL"))
+ wires = list(
+ sdn.get_wires(self.middle_inst.reference.ports[0].pins[0], selection="ALL")
+ )
self.assertEqual(len(wires), 3)
def test_pin_inside(self):
diff --git a/spydrnet/util/tests/test_hierarchical_reference.py b/tests/spydrnet/util/tests/test_hierarchical_reference.py
similarity index 99%
rename from spydrnet/util/tests/test_hierarchical_reference.py
rename to tests/spydrnet/util/tests/test_hierarchical_reference.py
index 75009eca..0d8970a0 100644
--- a/spydrnet/util/tests/test_hierarchical_reference.py
+++ b/tests/spydrnet/util/tests/test_hierarchical_reference.py
@@ -48,11 +48,13 @@ def test_flyweight(self):
href2 = HRef.from_parent_and_item(None, instance)
self.assertTrue(href1 is href2)
import weakref
+
w_href1 = weakref.ref(href1)
w_href2 = weakref.ref(href2)
href1 = None
href2 = None
import gc
+
gc.collect()
self.assertIsNone(w_href1())
self.assertIsNone(w_href2())
@@ -99,7 +101,7 @@ def test_href_valid(self):
self.assertFalse(href.is_valid)
port = sdn.Port()
- pin = sdn.InnerPin()
+ pin = sdn.InnerPin()
href = HRef.from_sequence([instance, port, pin])
self.assertFalse(href.is_valid)
@@ -183,7 +185,7 @@ def test_href_inst_name(self):
instance = sdn.Instance()
instance.name = "MY_INST"
href = HRef.from_parent_and_item(None, instance)
- self.assertEqual('', href.name)
+ self.assertEqual("", href.name)
def test_href_wire_name(self):
top = sdn.Instance()
diff --git a/spydrnet/util/tests/test_patterns.py b/tests/spydrnet/util/tests/test_patterns.py
similarity index 99%
rename from spydrnet/util/tests/test_patterns.py
rename to tests/spydrnet/util/tests/test_patterns.py
index 63db2681..106ad16c 100644
--- a/spydrnet/util/tests/test_patterns.py
+++ b/tests/spydrnet/util/tests/test_patterns.py
@@ -18,4 +18,3 @@ def test_value_matches_pattern(self):
def test_value_matches_pattern_bad_regex_expr(self):
self.assertFalse(_value_matches_pattern(None, "*", is_case=False, is_re=True))
-