Converts a subset of python generator functions into synthesizable sequential SystemVerilog
Project description
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
@verilogify
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:
- Supports only
if
andwhile
blocks - Supports only signed integral input/output and operations
- Must be a generator function
- Must be a pure function
Unsupported Python paradigms include but are not limited to the following:
- Regular functions that use the
return
keyword, insteadyield
once for
loops, instead rewrite as awhile
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.
Running Tests
To run tests, use python3 -m pytest
.
CLI arguments for test configuration can be found in tests/conftest.py.
Use git clean -dxf
to remove gitignored and generated files.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file python2verilog-0.4.1.tar.gz
.
File metadata
- Download URL: python2verilog-0.4.1.tar.gz
- Upload date:
- Size: 57.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5e0da4b0e9feffc4f3628c14c2a9cf92a146ce107cd2635db3d30e7116990e4 |
|
MD5 | 9d931e9100922f17c191ea1b09a6b7ed |
|
BLAKE2b-256 | 3d43cedfccbd815769875ca40b11c4eecc272acad121cc8f9926d5a176cf8703 |
File details
Details for the file python2verilog-0.4.1-py3-none-any.whl
.
File metadata
- Download URL: python2verilog-0.4.1-py3-none-any.whl
- Upload date:
- Size: 66.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82a86eb931409eaa3deaa9229f9555b3c6838e1f06f3f7b699bd9595fbe155e3 |
|
MD5 | 320319483992f354bf0c6f3b2878b92e |
|
BLAKE2b-256 | a07423b2798f1f38b0cbb39a19c32d0793deaa753a7b15a5083db6d4aa8a572e |