Registry / pyslang

pyslang

JSON →
library11.0.0pypypi✓ verified 85d ago

pyslang provides Python bindings for the `slang` C++ library, a high-performance compiler for SystemVerilog. It enables Python applications to parse, elaborate, and perform advanced static analysis on SystemVerilog code. The current version is 10.0.0. `slang` has a regular release cadence, with major versions often introducing significant LRM compliance updates and performance improvements.

pip install pyslang
INSTALL
IMPORT
SIG · PYSLANG
P
pyslang
pythonv11.0.0
Install
1.9s avg
Import
Disk
40MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v11.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
build_error
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.9s · import 0.000s · 43MB
40MB installed
● package 40MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Bag
from pyslang import Bag
import slang
DiagnosticEngine
from pyslang import DiagnosticEngine
import slang
ConstantValue
from pyslang import ConstantValue
import slang

This quickstart demonstrates how to initialize the `slang` library, add SystemVerilog source code, trigger compilation, and check for any errors or warnings. The `slang` library is primarily a compiler and analysis tool.

import slang # 1. Create a library to manage SystemVerilog source files library = slang.Library() # 2. Add SystemVerilog source text. Multiple calls can add more files. # You can also add files from disk using library.addSourceFile('path/to/file.sv') sv_code = """ module MySimpleModule; initial begin $display("Hello from SystemVerilog in Python!"); end endmodule; """ library.addSourceText(sv_code, fileName='example.sv') # 3. Get the compiled representation (perform parsing and elaboration) compilation = library.getCompilation() # 4. Check for any diagnostics (errors or warnings) diagnostics = compilation.getDiagnostics() if diagnostics: print("Compilation completed with diagnostics:") for diag in diagnostics: print(diag.toString()) else: print("Compilation successful with no diagnostics.") # Further operations (e.g., accessing symbols) would go here. # For instance, finding the 'MySimpleModule' definition: # root = compilation.getRoot() # module = root.lookupName('MySimpleModule')
Debug
Known issues
gotchaThe PyPI package `pyslang` provides its functionality under the Python module name `slang`. Importing `pyslang` directly will result in a `ModuleNotFoundError`.
fix
Always use `import slang` or `from slang import ...` instead of `import pyslang`.
affects: All versions
breakingMajor versions (e.g., v7.0, v9.0, v10.0) frequently introduce stricter compliance with the SystemVerilog Language Reference Manual (LRM). Code that previously compiled silently might now generate errors or warnings due to enhanced LRM enforcement or new static analysis checks.
fix
Review the `pyslang` (and underlying `slang` C++ library) release notes for changes related to LRM compliance. Update your SystemVerilog source code to adhere to the latest LRM specifications or downgrade `pyslang` if necessary for legacy code.
affects: v7.0 (IEEE 1800-2023), v9.0 (dataflow analysis), v10.0 (assertion locals definite assignment), and subsequent major releases.
gotchaCompilation errors and warnings are not raised as Python exceptions but are returned as a list of `Diagnostic` objects via `compilation.getDiagnostics()`. Failing to check this list means you might unknowingly have an invalid design.
fix
After calling `library.getCompilation()`, always retrieve and iterate through `compilation.getDiagnostics()` to properly handle any issues. Explicitly print or log these diagnostics.
affects: All versions
breakingThe underlying `slang` C++ library is actively developed, and while core APIs like `Library()` and `addSourceText()` are stable, more advanced features or introspection APIs might see changes between major `pyslang` versions.
fix
Consult the official GitHub repository's release notes for `pyslang` and the `slang` C++ library before upgrading major versions, especially if using advanced features beyond basic compilation.
affects: All major version upgrades (e.g., v8.x to v9.x, v9.x to v10.x)
Upgrade
Version history
11.0.0latest on PyPI · released May 15, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
pyslang — pip install pyslang · libregistry