Skip to main content

Converts a subset of python generator functions into synthesizable sequential SystemVerilog

Project description

Open In Colab pypi py versions pypi downloads pytest

python2verilog

  • This tool facilitates the conversion of select Python generator functions into synthesizable sequential SystemVerilog
  • Ideal for quickly translating higher-level "CPU code" into hardware descriptions for use on FPGAs, without needing to interface with or including a CPU in the design
  • Testbenches can be automatically generated if the user uses the function within their Python code or provides explicit test cases
from python2verilog import verilogify, Modes

@verilogify(mode=Modes.WRITE)
def hrange(base, limit, step):
    i = base
    while i < limit:
        yield i
        i += step
print(list(hrange(0, 10, 3)))

Specifications

Constrains on Python functions include:

Unsupported Python paradigms include but are not limited to the following:

  • Regular functions that use the return keyword, instead yield once
  • for loops, instead rewrite as a while loop
  • Global (nonlocal) variables, instead declare them within the function with minimal overhead
  • Keyword arguments, instead use positional arguments
  • Function calls, instead use the decorator on each of the subfunctions and manually connect together

Usage and Installation

Try it in Google Collab or check out examples/!

python3 -m pip install --upgrade pip

python3 -m pip install python2verilog

Tested Generations

You may find the output of the integration testing as a Github Artifact available for download.

For Developers

To setup pre-commit, run pre-commit install.

Github Issues are used for tracking.

Sphinx is used for the docs. Follow the sphinx workflow to generate a local copy.

Testing

Requirements

For most up-to-date information, refer to the pytest workflow or the packaging workflow.

A Ubuntu environment (WSL2 works too, make sure to have the repo on the Ubuntu partition, as os.mkfifo is used to avoid writing to disk)

Install required python libraries with python3 -m pip install -r tests/requirements.txt

For automatic Verilog simulation and testing, install Icarus Verilog and its dependencies with sudo apt-get install iverilog expected (uses the unbuffer in expected).

The online simulator EDA Playground can be used as a subsitute if you manually copy-paste the module and testbench files to it.

Creating A New Integration Test

To create a new test case and set up configs, run python3 tests/integration/new_test_case.py <test-name>.

Running Tests

To run tests, use python3 -m pytest --write.

Additional CLI flags can be found in tests/conftest.py.

Use git clean -dxf to remove gitignored and generated files.

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

python2verilog-0.2.3.tar.gz (51.4 kB view details)

Uploaded Source

Built Distribution

python2verilog-0.2.3-py3-none-any.whl (59.8 kB view details)

Uploaded Python 3

File details

Details for the file python2verilog-0.2.3.tar.gz.

File metadata

  • Download URL: python2verilog-0.2.3.tar.gz
  • Upload date:
  • Size: 51.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for python2verilog-0.2.3.tar.gz
Algorithm Hash digest
SHA256 ca99c8cbe592461422772b00a3af143ea82b22abd52a7e42da44214e7077f0ca
MD5 9ce7297b5ca4987e870c8c53db28c201
BLAKE2b-256 c1e528369217d22f9dd600379df3a8a34a165c52d12bb85d3a7a08ab4cf7ed06

See more details on using hashes here.

File details

Details for the file python2verilog-0.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for python2verilog-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 12d8a2e18ed2ab9fda2b5876fcbb40ff82028a2a843b7d44ef829c10389caf0c
MD5 75e70243a14b169eb972b3670d8987e4
BLAKE2b-256 0b4b26932aa38df3bee205f2f2989ec0a775a264d3aa95974b5312c35becf596

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 Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page