Skip to main content

Python bindings for slang, a library for compiling SystemVerilog

Project description

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

build 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

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyslang-1.0.109.tar.gz (1.5 MB view details)

Uploaded Source

Built Distributions

pyslang-1.0.109-cp310-cp310-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.10 Windows x86-64

pyslang-1.0.109-cp310-cp310-musllinux_1_1_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

pyslang-1.0.109-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pyslang-1.0.109-cp310-cp310-macosx_10_15_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.10 macOS 10.15+ x86-64

pyslang-1.0.109-cp310-cp310-macosx_10_15_universal2.whl (4.4 MB view details)

Uploaded CPython 3.10 macOS 10.15+ universal2 (ARM64, x86-64)

pyslang-1.0.109-cp39-cp39-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.9 Windows x86-64

pyslang-1.0.109-cp39-cp39-musllinux_1_1_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

pyslang-1.0.109-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pyslang-1.0.109-cp39-cp39-macosx_10_15_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.9 macOS 10.15+ x86-64

pyslang-1.0.109-cp39-cp39-macosx_10_15_universal2.whl (4.4 MB view details)

Uploaded CPython 3.9 macOS 10.15+ universal2 (ARM64, x86-64)

pyslang-1.0.109-cp38-cp38-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.8 Windows x86-64

pyslang-1.0.109-cp38-cp38-musllinux_1_1_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

pyslang-1.0.109-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pyslang-1.0.109-cp38-cp38-macosx_10_15_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.8 macOS 10.15+ x86-64

pyslang-1.0.109-cp38-cp38-macosx_10_15_universal2.whl (4.4 MB view details)

Uploaded CPython 3.8 macOS 10.15+ universal2 (ARM64, x86-64)

pyslang-1.0.109-cp37-cp37m-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.7m Windows x86-64

pyslang-1.0.109-cp37-cp37m-musllinux_1_1_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.7m musllinux: musl 1.1+ x86-64

pyslang-1.0.109-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

pyslang-1.0.109-cp37-cp37m-macosx_10_15_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.7m macOS 10.15+ x86-64

File details

Details for the file pyslang-1.0.109.tar.gz.

File metadata

  • Download URL: pyslang-1.0.109.tar.gz
  • Upload date:
  • Size: 1.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for pyslang-1.0.109.tar.gz
Algorithm Hash digest
SHA256 68f4da755ecf7cc6136303d91ad4f945ec806255713a6395da1072bc80e80ccc
MD5 ba8c478337b495730d47b05d797595bb
BLAKE2b-256 ac1e91cdba9bfd8fd08021bcc6d89b1912aea0df95657855bbac68afcbc7e4b1

See more details on using hashes here.

File details

Details for the file pyslang-1.0.109-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pyslang-1.0.109-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 3743494e7eba0a1d2621f82e4c04182e6fa8578c11bf51dfb0c726e3d5df1c1f
MD5 4cb394d98e07a8ae8d49014860d6f04d
BLAKE2b-256 443afb533449d45888a8e42018947fa799c1f35b291ac8fd5e609f2c7ddb93c8

See more details on using hashes here.

File details

Details for the file pyslang-1.0.109-cp310-cp310-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for pyslang-1.0.109-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 7bc400448ca9cbde6ad9fff3f853faa41dbe1fe7c1ff5684abb3a5cc5babe78f
MD5 17c076ad560aea3224e426dadb3e8220
BLAKE2b-256 69ff485b2ca474cd600860e9ade43b2ac7993944273d08ecf87d4875b770c97a

See more details on using hashes here.

File details

Details for the file pyslang-1.0.109-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyslang-1.0.109-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4fa1dac5501e389ed9ebb5b0430f5932c7c7d7cdba151a468a1482ba758355cb
MD5 6eef574cf926713406b544676af289dc
BLAKE2b-256 6baf0c503097d7e2cd1055b0cb236bb927c51addd082bd2f13b50d71e9f73201

See more details on using hashes here.

File details

Details for the file pyslang-1.0.109-cp310-cp310-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for pyslang-1.0.109-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 31bd67e06bebd691cd9604028f534a4e0104926dc7a0dc3c5df4bec961d57a8f
MD5 2a9f262d230dfeada346b2dab5778a75
BLAKE2b-256 2e3391f4e91a5b21d4fec8cb2c3d63426c6a4d7b5a02d52ea0d4a76f38f187e9

See more details on using hashes here.

File details

Details for the file pyslang-1.0.109-cp310-cp310-macosx_10_15_universal2.whl.

File metadata

File hashes

Hashes for pyslang-1.0.109-cp310-cp310-macosx_10_15_universal2.whl
Algorithm Hash digest
SHA256 13f0243dce6a6a79c9420366c8d5b9cdeb9890320b34900742fe48b11e899590
MD5 a12e48e64d10824d6b5252b46921bd4b
BLAKE2b-256 cd7e638b38cd376acef65fbe1e5fe6866f24da176653cacf7ae68ed778eb8245

See more details on using hashes here.

File details

Details for the file pyslang-1.0.109-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: pyslang-1.0.109-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for pyslang-1.0.109-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 d6398f8edc04f8c1d00957a465cbc33534fa8a89ada71eff83a6703461c7f420
MD5 8aab03677a34be7afd4be3b36e6ea414
BLAKE2b-256 89a562ecb695db673bc6f4bf50c26504b3c6fedd0cd44d3a39c36e60e779cf21

See more details on using hashes here.

File details

Details for the file pyslang-1.0.109-cp39-cp39-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for pyslang-1.0.109-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 552dc2f45a8d7ef4c643d04cb44b19e0d29f89dd554167385c86a47d28e29a02
MD5 85a7ffc90409f3f645106b0c2afdb144
BLAKE2b-256 f0a8759a0dfa2815d901df66965336bf6cb6d138d3aec8b91e33c4503e355be2

See more details on using hashes here.

File details

Details for the file pyslang-1.0.109-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyslang-1.0.109-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ccd78885ec59d30422e0e2d2e4b0ff7c04aed03a12e957427ecb04f051dd59e8
MD5 21c5d96575cbba96fcbfb7e5dccba224
BLAKE2b-256 828b5d3f06fcbfc2aac6ad87d4f00be01bfd52c641b48586c34d08b86542666b

See more details on using hashes here.

File details

Details for the file pyslang-1.0.109-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for pyslang-1.0.109-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 1f0974177f11ecaeb57450e0f8b6e41739ba743a915136abdb9e5f9c0ac9a782
MD5 cefd6c86ddc632cf9228321d74500be8
BLAKE2b-256 c2b7ce2d3f285c64a1cf4479f1ebb03370754134f50694ce9a8bf651f2e48642

See more details on using hashes here.

File details

Details for the file pyslang-1.0.109-cp39-cp39-macosx_10_15_universal2.whl.

File metadata

File hashes

Hashes for pyslang-1.0.109-cp39-cp39-macosx_10_15_universal2.whl
Algorithm Hash digest
SHA256 e2977e2fb804c1967b3b6bfcf46e862f3e46f000a1ca0b29c9700718108e5f47
MD5 1be8cc33c01283e09a858ea70dd73246
BLAKE2b-256 16f4695a1364a10a613dcd1bcaaef59a18dc0ea660ee4616105fb49cb102e2f5

See more details on using hashes here.

File details

Details for the file pyslang-1.0.109-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: pyslang-1.0.109-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for pyslang-1.0.109-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 67073fe1b37704a6c86ddfb1d119dbc541daebf56a2fcf855800cb7e9a12edf0
MD5 79d848b5b1d22f2e22391cfff41c3a8c
BLAKE2b-256 23d2b3e8ff45e93b4db64a23970b5479c0e3000080cd2208bfa1b52cec3eff0f

See more details on using hashes here.

File details

Details for the file pyslang-1.0.109-cp38-cp38-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for pyslang-1.0.109-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 743e711bbc53ab52f9ea1cfc81d85a650ef97ac8a818dfb8fb70fafdb816705e
MD5 e33a88f59d4364c072829da816405228
BLAKE2b-256 47939098e41a571d988cbe2274f96da3849e631a3933405c94ef1cb9ccd2196e

See more details on using hashes here.

File details

Details for the file pyslang-1.0.109-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyslang-1.0.109-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0e3bbd09f6b0428fa46d54a0aea12416ba2fd9f9901c2f7b56a2fc111a13651e
MD5 2cf8a030000d08f0274fcab60a4ba6dc
BLAKE2b-256 6b598a43cfa28b1b50426d87d63d4737dd15799c495e60cefa8bc40c1b9e9c52

See more details on using hashes here.

File details

Details for the file pyslang-1.0.109-cp38-cp38-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for pyslang-1.0.109-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 4e2cec4cc2c36832b77c2f628cb5d107a407d7ef198b38719a04ed9888678852
MD5 c710755b8a8a964b9eda22dda6af8a46
BLAKE2b-256 39f5bc2e1b36fc16c6c433380e6a147c2e86a2392e40d329dcf4eabcce76c347

See more details on using hashes here.

File details

Details for the file pyslang-1.0.109-cp38-cp38-macosx_10_15_universal2.whl.

File metadata

File hashes

Hashes for pyslang-1.0.109-cp38-cp38-macosx_10_15_universal2.whl
Algorithm Hash digest
SHA256 8c6efb89f9a619885e018e878842ac44a7d82662fdb9055ae11df178c03abc37
MD5 998631eb671a7740e2d1097f2bf1a3ec
BLAKE2b-256 194d972501f7920b16e5337dfba1a5e6f115735b12d0f11a70b09097c18bdd7e

See more details on using hashes here.

File details

Details for the file pyslang-1.0.109-cp37-cp37m-win_amd64.whl.

File metadata

File hashes

Hashes for pyslang-1.0.109-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 2458cc4a7b9152bf5fe4b1eb993670d8e6da1a7c58f6e09a13d5a5ac34f7caf9
MD5 adedbe2b3e091ce644a0a1fcab813c87
BLAKE2b-256 74afb621f3e9a51f37556a84d079f09fe18995bf1b2083637eb969ec5cc24adf

See more details on using hashes here.

File details

Details for the file pyslang-1.0.109-cp37-cp37m-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for pyslang-1.0.109-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 74e225e54a302034eac140ab2cd5287203d9c1571cef49e8d3f1bb5a5802d0a1
MD5 66aaf930df976d4bc99c8d31648c96f3
BLAKE2b-256 0220f91ef70e22cb97cdb34a5ef6aa43bb7354bfbe56c94494ba70ba81210b0f

See more details on using hashes here.

File details

Details for the file pyslang-1.0.109-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyslang-1.0.109-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f06a56e25dbedbeeacb027f655505808dbce0859d9a62b10e42d5a180a9df506
MD5 8630c9cdc85233eccc96cb5875cf4f2d
BLAKE2b-256 cd4b5b9f562e265403ffcb60621c5ade5807f9a8d214692be0202f3bf422b7d3

See more details on using hashes here.

File details

Details for the file pyslang-1.0.109-cp37-cp37m-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for pyslang-1.0.109-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 ef9cabb7da5fbec10b1ff35132836092bd7e2e9fb49e6f0c8280e6ed7f1b832e
MD5 dfcf49eeb7ddfbcc4bb43d9e98c3ca7f
BLAKE2b-256 ecf32fda669f79bc915f54ac28e003a364087823d9d0cb85495fa03b14438220

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page