pysvlang
Python bindings for svlang, a pure-Rust IEEE 1800-2023 SystemVerilog front end: filelists, preprocessor, a lossless concrete syntax tree, elaboration, compiler checks and a word-level RTL netlist.
The wheels are self-contained native extensions built with PyO3 and maturin. There is no C++ build and nothing else to install; one abi3 wheel per platform works on every Python from 3.9 on.
pip install pysvlang
Status: alpha. The API below is the first slice (parse, diagnostics, tree walking, hierarchy, netlist summary) and may change before 1.0.
Use
import pysvlang
comp = pysvlang.Compilation(
["rtl/top.sv", "rtl/fifo.sv"],
include_dirs=["rtl/include"],
defines={"SYNTHESIS": None, "DEPTH": 16},
top=["top"],
params={"WIDTH": 32},
)
# Or simulator-style arguments, -f filelists included:
# comp = pysvlang.Compilation.from_args(["-f", "files.f", "-top", "top"])
for d in comp.diagnostics():
print(d) # rtl/top.sv:12:5: error: ...
for tree in comp.trees:
for mod in tree.root.find_all("ModuleDecl"):
print(mod.child("Name").bare_text, mod.location)
print("\n".join(comp.hierarchy()))
nl = comp.lower_netlist(top="top")
print(nl.top, len(nl.inputs), len(nl.states))
print(nl.dump())
The syntax tree is lossless: tree.file_text() rebuilds the source
byte for byte, and every Token carries its leading_trivia (whitespace,
comments, directives). Node kinds are strings such as "ModuleDecl" or
"ProceduralBlock"; pysvlang.SYNTAX_KINDS and pysvlang.TOKEN_KINDS list
them all, and asking for a kind that does not exist raises ValueError.
lower_netlist() raises pysvlang.LowerError when the design has errors or
uses constructs outside the synthesizable/formal subset. The exception's
diagnostics list says why, and unsupported tells the two cases apart.
nl.to_btor2() returns the netlist as a Btor2 transition system for
word-level model checkers, with a list of notes on anything left out:
text, notes = comp.lower_netlist().to_btor2()
open("top.btor2", "w").write(text) # then: ric3 check top.btor2 ic3
nl.to_aiger() gives the same model bit-blasted to AIGER, as bytes
(binary .aig) or, with binary=False, as text (.aag):
nl = comp.lower_netlist(blast_memories_up_to=1024) # AIGER has no memories
data, notes = nl.to_aiger()
open("top.aig", "wb").write(data) # then: ric3 check top.aig ic3
nl.to_yosys_json() writes the netlist for Yosys, as its word-level cells:
text, notes = nl.to_yosys_json()
open("top.json", "w").write(text) # then: yosys -p 'read_json top.json; synth; stat'
Immediate assertions become bad lines. For concurrent properties
(assert property, assume property, cover property), lower with
compile_properties=True: each one over bounded sequences becomes a check
that both exporters write, and the notes say how many were left out. A
concurrent assumption that could not be compiled raises SvlangError.
nl = comp.lower_netlist(
compile_properties=True,
skip_cycles=1,
precondition_covers=True,
witness_covers=True,
)
text, notes = nl.to_btor2(covers=True)
The netlist can also be read as objects. A Value is one node of its graph:
an input, a constant, a register's output or an operator over other values.
nl = comp.lower_netlist()
for reg in nl.registers():
print(reg.name, reg.width, reg.clock.name, reg.edge)
print(" next:", reg.next.op, [v.id for v in reg.next.operands()])
q = nl.output("q") # also nl.input(name), nl.signal("top.u0.sum")
adds = nl.find_ops("Add") # operator names are in pysvlang.NET_OPS
const = adds[0].operands()[1]
print(const.kind, const.bits, const.int) # Const 0001 1
nl.memories() gives the arrays that were kept as memories, with their
write ports. nl.checks() gives the assertions, assumptions and covers, and
nl.liveness() the obligations made from properties such as s_eventually.
comp.scope_tree() gives the elaborated hierarchy as Scope objects, each
with its signals and child scopes. All of these are read-only.
Parsing, checking and lowering release the GIL, so several compilations can run in threads at once.
Build from source
Only needed to work on the bindings. Needs Rust 1.85 or later and Python 3.9 or later.
cd crates/svlang-py
python -m venv .venv && . .venv/bin/activate
pip install maturin pytest
maturin develop --release
pytest tests
maturin build --release writes a wheel to target/wheels/.
Releasing
The Python workflow builds and tests the wheels on every change. Pushing a
release tag vX.Y.Z (or pysvlang-vX.Y.Z), where X.Y.Z is the workspace
version in the root Cargo.toml, also publishes the wheels and sdist to PyPI
through trusted publishing (repository mayurkubavat/svlang, workflow
python.yml, environment pypi).
License
Apache-2.0, like svlang.
Metadata
Release files for pysvlang 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pysvlang-0.3.0.tar.gz | 739.7 kB | With provenance | Details for pysvlang-0.3.0.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| pysvlang-0.3.0-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details for pysvlang-0.3.0-cp39-abi3-win_amd64.whl |
| pysvlang-0.3.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ x86-64 | Details for pysvlang-0.3.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
| pysvlang-0.3.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ ARM64 | Details for pysvlang-0.3.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
| pysvlang-0.3.0-cp39-abi3-macosx_11_0_arm64.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64 | Details for pysvlang-0.3.0-cp39-abi3-macosx_11_0_arm64.whl |
| pysvlang-0.3.0-cp39-abi3-macosx_10_12_x86_64.whl | CPython 3.9 | abi3 | macOS 10.12+ x86-64 | Details for pysvlang-0.3.0-cp39-abi3-macosx_10_12_x86_64.whl |
Total release size: 12.5 MB
Release files / pysvlang-0.3.0.tar.gz
| Download URL | pysvlang-0.3.0.tar.gz |
|---|---|
| Size | 739.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
99b2c29c9deb5568156849035532c81eca553dc23ae2427c4c3cfc48d68c01ed
|
|
BLAKE2b-256 checksum How to use checksums |
2aab3c0d8e55cf1eeb1940a15a6251feb23012020a2c12776092c896699a3152
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.
Transparency logRelease files / pysvlang-0.3.0-cp39-abi3-win_amd64.whl
| Download URL | pysvlang-0.3.0-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 2.5 MB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
010fde267dc1db29022df4cc28c5458b9ddaef2afbd4932382d98e24de46dd3a
|
|
BLAKE2b-256 checksum How to use checksums |
c7b38712f7518316086fc23be5d3e8a11681b516b33b2ae95beb12b799d5c0f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.
Transparency logRelease files / pysvlang-0.3.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | pysvlang-0.3.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 2.5 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
c70d5d5599b133b7045b1e921671face47080a216ca99eb96c4700fa484f7c9a
|
|
BLAKE2b-256 checksum How to use checksums |
372b28ab686f23fd7c7c7a6303e1be21b6491c6d5d780f899646b62e324971e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.
Transparency logRelease files / pysvlang-0.3.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | pysvlang-0.3.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
ddc98993bd99455caed18ffaf8fe5ab142bd095b90c9d8917fbeb0579beda46a
|
|
BLAKE2b-256 checksum How to use checksums |
d71d4cf6d6c032ff1dc85a8f9db76eaf3ab8315cd388b40f54dc47bbc68e0c8a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.
Transparency logRelease files / pysvlang-0.3.0-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | pysvlang-0.3.0-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
130b1f6e41a9f824753e033f6dcdb822513b3298032eca277316d7d7244ac0b4
|
|
BLAKE2b-256 checksum How to use checksums |
4eee74ff5f2f53b2de0ff61d1dda3938c082fe87e9f86652b97813e3d46a91bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.
Transparency logRelease files / pysvlang-0.3.0-cp39-abi3-macosx_10_12_x86_64.whl
| Download URL | pysvlang-0.3.0-cp39-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.9 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
b8b4818665586cc75c64d35f64bf916ac3affe0d0effd7f5ec87d1d7f864e92d
|
|
BLAKE2b-256 checksum How to use checksums |
0e4c9271a23da8faf35bbec73d26f3f87a025008e4d9c42f474ac20a82ec7d98
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.
Transparency logSecurity for pysvlang 0.3.0
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.
Full provenance
All 6 files in this release have been uploaded with provenance metadata.
Attestation for pysvlang-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.
Transparency logA 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.