pysvinst
This Python library examines SystemVerilog files to determine what modules are defined and what modules are instantiated. The backend uses sv-parser, which has good support of SystemVerilog 2017.
Purpose
The Verilog language has contains features for defining configs and libraries. However, these features are not well-supported by open-source tools, and even some commercial synthesis tools. By extracting a list of modules defined and instantiated in a file, a user can work around this problem by constructing their own design hierarchy outside of Verilog, and then passing that list of files back into the simulator / synthesis tool.
Installation
This package can be installed via pip:
> pip install svinst
Alternatively, you can clone the repository and build the package yourself. This requires that Rust is installed.
> git clone https://github.com/sgherbst/pysvinst.git
> cd pysvinst
> pip install -e .
Usage
The main functionality of this package is provided through the function get_defs. In this first example, a list of module definitions is returned, each one containing a list module instantiations (if any) contained in that module definition.
>>> from svinst import get_defs
>>> defs = get_defs('tests/verilog/test.sv')
>>> _ = [print(str(def_)) for def_ in defs]
ModDef("A", [
])
ModDef("B", [
])
ModDef("C", [
ModInst("A", "I0"),
ModInst("B", "I1")
])
ModDef("D", [
ModInst("X", "I0"),
ModInst("Y", "I1")
])
It is also possible to add define variables and include directory paths, since both of these can change the modules that get defined and instantiated:
>>> get_defs('tests/verilog/inc_test.sv', includes=['tests/verilog'])
>>> get_defs('tests/verilog/def_test.sv',
defines={'MODULE_NAME': 'module_name_from_define', 'EXTRA_INSTANCE': None})
If there is a syntax error, an error message is printed and an Exception is raised.
>>> get_defs('tests/verilog/broken.sv')
parse failed: "tests/verilog/broken.sv"
tests/verilog/broken.sv:5:10
|
5 | endmodule
|
Finally, the user can get a full syntax tree for advanced processing, using the command get_syntax_tree. That command also allows the arguments includes and defines.
>>> from svinst import get_syntax_tree
>>> tree = get_syntax_tree('tests/verilog/simple.sv')
>>> _ = [print(elem) for elem in tree]
SyntaxNode("SourceText", [
SyntaxNode("Description", [
SyntaxNode("ModuleDeclaration", [
SyntaxNode("ModuleDeclarationAnsi", [
SyntaxNode("ModuleAnsiHeader", [
SyntaxNode("ModuleKeyword", [
SyntaxNode("Keyword", [
SyntaxToken("module", line=1)
])
]),
SyntaxNode("ModuleIdentifier", [
SyntaxNode("Identifier", [
SyntaxNode("SimpleIdentifier", [
SyntaxToken("A", line=1)
])
])
]),
SyntaxNode("Symbol", [
SyntaxToken(";", line=1)
])
]),
SyntaxNode("Keyword", [
SyntaxToken("endmodule", line=2)
])
])
])
])
])
Metadata
Release files for svinst 0.1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| svinst-0.1.9-cp38-cp38-macosx_10_14_x86_64.whl | CPython 3.8 | CPython 3.8 | macOS 10.14+ x86-64 | Details |
| svinst-0.1.9-cp37-cp37m-macosx_10_14_x86_64.whl | CPython 3.7 | CPython 3.7 pymalloc | macOS 10.14+ x86-64 | Details |
Total release size: 19.7 MB
Release files / svinst-0.1.9-cp38-cp38-macosx_10_14_x86_64.whl
| Download URL | svinst-0.1.9-cp38-cp38-macosx_10_14_x86_64.whl |
|---|---|
| Size | 9.8 MB |
| Tags | CPython 3.8 macOS 10.14+ x86-64 |
|
SHA-256 checksum How to use checksums |
6baebc3c5c3e05459f7daa3992e59366b7205e8da1c5bdc96a29c6be87aab624
|
|
BLAKE2b-256 checksum How to use checksums |
6a5ce98c888416ade224d3b900e1ac7555ace6c5506022232a1c2460a05897cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.9
|
Release files / svinst-0.1.9-cp37-cp37m-macosx_10_14_x86_64.whl
| Download URL | svinst-0.1.9-cp37-cp37m-macosx_10_14_x86_64.whl |
|---|---|
| Size | 9.8 MB |
| Tags | CPython 3.7 CPython 3.7 pymalloc macOS 10.14+ x86-64 |
|
SHA-256 checksum How to use checksums |
586e843c70e100c4f2c118b5e1166e3ece6e32e59b04883c42cd93116a0ba619
|
|
BLAKE2b-256 checksum How to use checksums |
27d674293b4850a9a554d543237e1794586c7bfa036755344f27f2e3047e9ba8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10
|
Security for svinst 0.1.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.