Skip to main content

pyslang - Language bindings for slang, SystemVerilog parsing and compilation library

build PyPI License: MIT Join the chat at https://gitter.im/MikePopoloski/slang

slang is a software library that provides various components for lexing, parsing, type checking, and elaborating SystemVerilog code. pyslang exposes that library to Python projects.

Full documentation is available on the website: https://sv-lang.com

Installation

pyslang can be installed like any other Python library, using (a recent version of) the Python package manager pip, on Linux, macOS, and Windows:

pip install pyslang

or, to update your installed version to the latest release:

pip install -U pyslang

or, to checkout and install a local build:

git clone https://github.com/MikePopoloski/pyslang.git
cd pyslang
git submodule update --init --recursive
pip install .

Example usage

Given a 'test.sv' source file:

module memory(
    address,
    data_in,
    data_out,
    read_write,
    chip_en
  );

  input wire [7:0] address, data_in;
  output reg [7:0] data_out;
  input wire read_write, chip_en;

  reg [7:0] mem [0:255];

  always @ (address or data_in or read_write or chip_en)
    if (read_write == 1 && chip_en == 1) begin
      mem[address] = data_in;
  end

  always @ (read_write or chip_en or address)
    if (read_write == 0 && chip_en)
      data_out = mem[address];
    else
      data_out = 0;

endmodule

We can use slang to load the syntax tree and inspect it:

import pyslang

tree = pyslang.SyntaxTree.fromFile('test.sv')
mod = tree.root.members[0]
print(mod.header.name.value)
print(mod.members[0].kind)
print(mod.members[1].header.dataType)
memory
SyntaxKind.PortDeclaration
reg [7:0]

We can also evaluate arbitrary SystemVerilog expressions:

session = pyslang.ScriptSession()
session.eval("logic bit_arr [16] = '{0:1, 1:1, 2:1, default:0};")
result = session.eval("bit_arr.sum with ( int'(item) );")
print(result)
3

Contact & Support

If you encounter a bug, have questions, or want to contribute, please get in touch by opening a GitHub issue or posting a message on Gitter.

Contributions are welcome, whether they be in the form of bug reports, comments, suggestions, documentation improvements, or full fledged new features via pull requests.

License

slang (and pyslang) is licensed under the MIT license:

Copyright (c) 2015-2022 Michael Popoloski

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Metadata

Release files for pyslang 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyslang 2.0.0
File Size Uploaded Provenance
pyslang-2.0.0.tar.gz 886.5 kB Without provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for pyslang 2.0.0
File
pyslang-2.0.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
pyslang-2.0.0-cp310-cp310-musllinux_1_1_x86_64.whl CPython 3.10 CPython 3.10 Linux musl 1.1+ x86-64 Details
pyslang-2.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details
pyslang-2.0.0-cp310-cp310-macosx_10_15_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.15+ x86-64 Details
pyslang-2.0.0-cp310-cp310-macosx_10_15_universal2.whl CPython 3.10 CPython 3.10 macOS 10.15+ universal2 (ARM64, x86-64) Details
pyslang-2.0.0-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
pyslang-2.0.0-cp39-cp39-musllinux_1_1_x86_64.whl CPython 3.9 CPython 3.9 Linux musl 1.1+ x86-64 Details
pyslang-2.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details
pyslang-2.0.0-cp39-cp39-macosx_10_15_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.15+ x86-64 Details
pyslang-2.0.0-cp39-cp39-macosx_10_15_universal2.whl CPython 3.9 CPython 3.9 macOS 10.15+ universal2 (ARM64, x86-64) Details
pyslang-2.0.0-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
pyslang-2.0.0-cp38-cp38-musllinux_1_1_x86_64.whl CPython 3.8 CPython 3.8 Linux musl 1.1+ x86-64 Details
pyslang-2.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-64 Details
pyslang-2.0.0-cp38-cp38-macosx_10_15_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.15+ x86-64 Details
pyslang-2.0.0-cp38-cp38-macosx_10_15_universal2.whl CPython 3.8 CPython 3.8 macOS 10.15+ universal2 (ARM64, x86-64) Details
pyslang-2.0.0-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
pyslang-2.0.0-cp37-cp37m-musllinux_1_1_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux musl 1.1+ x86-64 Details
pyslang-2.0.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64 Details
pyslang-2.0.0-cp37-cp37m-macosx_10_15_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.15+ x86-64 Details

Total release size: 58.5 MB

Release files / pyslang-2.0.0.tar.gz

Download URL pyslang-2.0.0.tar.gz
Size 886.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5ce7075209c47f68f501fb688750b8bcb7cd6eaccbfd2e68f34515a84c10a4df
BLAKE2b-256 checksum
How to use checksums
57e33965221baa336a721db9037b0ac0ca4e13a59a2e528dd3baf702b1f21336
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / pyslang-2.0.0-cp310-cp310-win_amd64.whl

Download URL pyslang-2.0.0-cp310-cp310-win_amd64.whl
Size 1.8 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
222a02f5bcbdb183f8e6539c90a61d0d96687e78dc6f822c38604a6f7c1ac4b3
BLAKE2b-256 checksum
How to use checksums
40502a9715344ef321aabd1d3a5a11cd235b1e12f6abf66a388881b294b9317d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / pyslang-2.0.0-cp310-cp310-musllinux_1_1_x86_64.whl

Download URL pyslang-2.0.0-cp310-cp310-musllinux_1_1_x86_64.whl
Size 3.2 MB
Tags CPython 3.10 Linux musl 1.1+ x86-64
SHA-256 checksum
How to use checksums
8131fb0b67803547e6416a91a9006766951e935deaadf21af6d951245cdc16ad
BLAKE2b-256 checksum
How to use checksums
45586e193514f66c71005c27150ff21199b355c90300aa4734cf9a3c7e9562c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / pyslang-2.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pyslang-2.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.9 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
3347bbca0d0c8fd62f4bbe30eb1f1ed0c1252e86ab6fd58a95544ef6d274b754
BLAKE2b-256 checksum
How to use checksums
18242066507e14a12fe5a44e8e6a235a92f09807b0b3e3ffb16999eaf1bf0e51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / pyslang-2.0.0-cp310-cp310-macosx_10_15_x86_64.whl

Download URL pyslang-2.0.0-cp310-cp310-macosx_10_15_x86_64.whl
Size 2.6 MB
Tags CPython 3.10 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
4b3120bed5cec1c5e28e5b2f93d7bb52980e87f18badc1df6c13b6ff6323aa66
BLAKE2b-256 checksum
How to use checksums
b08fb1a520834d9f4dee4728efd804f38e04156319785d9b24ff615fa4ac4ed4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / pyslang-2.0.0-cp310-cp310-macosx_10_15_universal2.whl

Download URL pyslang-2.0.0-cp310-cp310-macosx_10_15_universal2.whl
Size 5.0 MB
Tags CPython 3.10 macOS 10.15+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
6c330175e91dfb50a49be49bc68cc90fbb606cd99a8b040585ec4fc6f24f94ae
BLAKE2b-256 checksum
How to use checksums
f607232bd97d27178a752c30e40b5359838db056f641a798bc210d38c42fc578
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / pyslang-2.0.0-cp39-cp39-win_amd64.whl

Download URL pyslang-2.0.0-cp39-cp39-win_amd64.whl
Size 2.1 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
2b482e4c1c1cbf8a0828a093091ad5ece548438298945b323cedcc76227c8322
BLAKE2b-256 checksum
How to use checksums
f2b839d953138880b0edaedb7dc3708f766c369b6c05a5106d9c2f580211677a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / pyslang-2.0.0-cp39-cp39-musllinux_1_1_x86_64.whl

Download URL pyslang-2.0.0-cp39-cp39-musllinux_1_1_x86_64.whl
Size 3.2 MB
Tags CPython 3.9 Linux musl 1.1+ x86-64
SHA-256 checksum
How to use checksums
60d8a71cad23ad8f5949c26a713c6855efcbc5ed4632c47fabbed2adecdff1dd
BLAKE2b-256 checksum
How to use checksums
17cb7919a7f42a99ea7f5a735f82d9ea5b25e8db8a50d9cf40a1319bf86ae20d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / pyslang-2.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pyslang-2.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.9 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
d3933a024e41c1d2d1202f8a51a1126c4517c13e8003674942055dafc77470d5
BLAKE2b-256 checksum
How to use checksums
267a01af3ff7b1c4514c7f583793583b6e469d05cd59dd242e93c6b06a478e84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / pyslang-2.0.0-cp39-cp39-macosx_10_15_x86_64.whl

Download URL pyslang-2.0.0-cp39-cp39-macosx_10_15_x86_64.whl
Size 2.6 MB
Tags CPython 3.9 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
49f47cdd0b3079a5649e7639a67c556909912ac70532ec674c374547a3eb7467
BLAKE2b-256 checksum
How to use checksums
66c664890daa84f6b93f6b14809accad663c008e8200bdad0e8b066ca8caded3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / pyslang-2.0.0-cp39-cp39-macosx_10_15_universal2.whl

Download URL pyslang-2.0.0-cp39-cp39-macosx_10_15_universal2.whl
Size 5.0 MB
Tags CPython 3.9 macOS 10.15+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
dc38538621fe8ca311521644c7b85c94c658a8d91045ec60d7ef910abe30cc02
BLAKE2b-256 checksum
How to use checksums
02217f0222702cde83e69791e5736e82206430ef51d96e8156310b6c87ef4a64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / pyslang-2.0.0-cp38-cp38-win_amd64.whl

Download URL pyslang-2.0.0-cp38-cp38-win_amd64.whl
Size 1.8 MB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
c5d98aa114aac5b1d6e60cad79f9d89f6d2d981333e4f2a956ff32201fe7eecf
BLAKE2b-256 checksum
How to use checksums
4ec1b65efe53a8c7231cd1a54362cf9e7277b3f56e8f9db260749da4e3f220c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / pyslang-2.0.0-cp38-cp38-musllinux_1_1_x86_64.whl

Download URL pyslang-2.0.0-cp38-cp38-musllinux_1_1_x86_64.whl
Size 3.2 MB
Tags CPython 3.8 Linux musl 1.1+ x86-64
SHA-256 checksum
How to use checksums
7fb4b2c303542f7c3f1599a2bf2013a8949cd37bd2dc711688b394c8a6b49b01
BLAKE2b-256 checksum
How to use checksums
b26b7ad244ba80c9d89aea710a283b48960c60b613c90359f1266ea496f171d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / pyslang-2.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pyslang-2.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.9 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
ad101227efa6fdf53c84fcaa01ff064d001676b309c36c57b09697be022d97c1
BLAKE2b-256 checksum
How to use checksums
94a824b6bd81affef6282713adf2b1e9c07adfec03d44ab305913acc4a9bd014
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / pyslang-2.0.0-cp38-cp38-macosx_10_15_x86_64.whl

Download URL pyslang-2.0.0-cp38-cp38-macosx_10_15_x86_64.whl
Size 2.6 MB
Tags CPython 3.8 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
65e1891f5fc4cd6a4644e4736de3b90c7e8230d004a4976501059adca8a4dec1
BLAKE2b-256 checksum
How to use checksums
569db925180b0607f909bc7480a1b07c021750d6c931273608e0c91f35372eda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / pyslang-2.0.0-cp38-cp38-macosx_10_15_universal2.whl

Download URL pyslang-2.0.0-cp38-cp38-macosx_10_15_universal2.whl
Size 5.0 MB
Tags CPython 3.8 macOS 10.15+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
d4dee40666cdae4ed269fcf48daea69c94ab3b36199f09ff093cc5b45441c8b1
BLAKE2b-256 checksum
How to use checksums
4a70c82f4688b0e7bbd4c81fc40aa27119b4b68865f379c9eff37d4cace9ae99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / pyslang-2.0.0-cp37-cp37m-win_amd64.whl

Download URL pyslang-2.0.0-cp37-cp37m-win_amd64.whl
Size 1.8 MB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
7561620acac20f9c6b50198c3c5ac3c16015b4e5b1d99aa527db9e35d8762bd5
BLAKE2b-256 checksum
How to use checksums
86e747d841e0ae25a9c1ae40a323e028b4f75a3dfc1e516a8fd3e21d8da4ace1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / pyslang-2.0.0-cp37-cp37m-musllinux_1_1_x86_64.whl

Download URL pyslang-2.0.0-cp37-cp37m-musllinux_1_1_x86_64.whl
Size 3.2 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux musl 1.1+ x86-64
SHA-256 checksum
How to use checksums
5ac117e8ab3d06aaafc216949ede2f38f3d700800b916611626260896a667c20
BLAKE2b-256 checksum
How to use checksums
14e7fade552245f2a4eb7302332b6ff3e5179ad9ea60bc7f13c03271c5566b33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / pyslang-2.0.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pyslang-2.0.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.0 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
0154494b79f43de64b6e2048b12daccb5c79263d4e1428f609870cd9d238b21a
BLAKE2b-256 checksum
How to use checksums
4126bc4d71a28e8f1ba062059267c6b836fb49d3908d00e2186c7ab0e540da9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / pyslang-2.0.0-cp37-cp37m-macosx_10_15_x86_64.whl

Download URL pyslang-2.0.0-cp37-cp37m-macosx_10_15_x86_64.whl
Size 2.6 MB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
e492696e4582136f7b8ca3505f3e6911755b9dc0fada3f67937a6772aaca8e4d
BLAKE2b-256 checksum
How to use checksums
3d71e517ab9652895fc6483f56facf4ea879bc9a2dcfa062195e1b502b53b4f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Security for pyslang 2.0.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.

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page