Skip to main content

RTL-level Hardware Design and Simulation Toolkit

Project description

PyRTL

PyPI version Build Status Code Coverage Documentation Status Binder

PyRTL provides a collection of classes for Pythonic register-transfer level design, simulation, tracing, and testing suitable for teaching and research. Simplicity, usability, clarity, and extensibility rather than performance or optimization is the overarching goal. Features include:

  • Elaboration-through-execution, meaning all of Python can be used including introspection
  • Design, instantiate, and simulate all in one file and without leaving Python
  • Export to, or import from, common HDLs (BLIF-in, Verilog-out currently supported)
  • Examine execution with waveforms on the terminal or export to .vcd as projects scale
  • Elaboration, synthesis, and basic optimizations all included
  • Small and well-defined internal core structure means writing new transforms is easier
  • Batteries included means many useful components are already available and more are coming every week

What README would be complete without a screenshot? Below you can see the waveform rendered right on the terminal for a small state machine written in PyRTL.

Command-line waveform for PyRTL state machine

Tutorials and Documentation

Package Contents

If you are just getting started with PyRTL it is suggested that you start with the examples/ first to get a sense of the "thinking with PyRTLs" required to design hardware in this way. If you are looking for a deeper understanding, dive into the code for the object Block. It is the core data structure at the heart of PyRTL and defines its semantics at a high level -- everything is converted to or from the small, simple set of primitives defined there.

The package contains the following files and directories:

  • pyrtl/ The src directory for the module
  • pyrtl/rtllib/ Finished PyRTL libraries which are hopefully both useful and documented
  • examples/ A set of hardware design examples that show the main idea behind pyrtl
  • tests/ A set of unit tests for PyRTL which you can run with pytest
  • docs/ Location of the sphinx documentation

Testing requires the Python packages tox and pytest. Once installed a complete test of the system should be possible with the simple command tox and nothing more.

Contributing to PyRTL

Picking a first project

  • One of the earliest things you should submit is a unit test that hits some uncovered lines of code in PyRTL. For example, pick a PyrtlError that is not covered and add a unit test in tests/ that will hit it.
  • After you have that down check in the PyRTL Issues list for a feature that is marked as "beginner friendly".
  • Once you have that down, ask for access to the PyRTL-research repo where we keep a list of more advanced features and designs that could use more help!

Coding style

  • All major functionality should have unit tests covering and documenting their use
  • All public functions and methods should have useful docstrings
  • All code needs to conform to PEP8 conventions
  • No new root-level dependencies on external libs, import locally if required for special functions

Workflow

  • A useful reference for working with Git is this Git tutorial
  • A useful Git Fork workflow for working on this repo is found here
  • The development branch is the primary stable working branch (everyone is invited to submit pull requests)
  • Bugs and minor enhancements tracked directly through the issue tracker
  • When posting a bug please post a small chunk of code that captures the bug, e.g. Issue #56
  • When pushing a fix to a bug or enhancement please reference issue number in commit message, e.g. Fix to Issue #56

Documentation

  • All important functionality should have an executable example in examples/
  • All classes should have a block comment with high level description of the class
  • All functions should follow the following (Sphinx parsable) docstring format:
    """One Line Summary (< 80 chars) of the function, followed by period.
    
    :param param_name : Description of this parameter.
    :param param_name : Longer parameter descriptions take up a newline with four
        leading spaces like this.
    :return: Description of function's return value.
    
    A long description of what this function does. Talk about what the user
    should expect from this function and also what the users needs to do to use
    the function (this part is optional).
    
    """
    
    # Developer Notes (Optional):
    #
    # These would be anything that the user does not need to know in order to use
    # the functions.
    # These notes can include internal workings of the function, the logic behind
    # it, or how to extend it.
    
  • Sphinx parses Python type annotations, so put type information into annotations instead of docstrings.
  • The Sphinx-generated documentation is published to https://pyrtl.readthedocs.io/
  • PyRTL's Sphinx build process is documented in docs/README.md.
  • PyRTL's release process is documented in docs/release/README.md.

Using PyRTL

We love to hear from users about their projects, and if there are issues we will try our best to push fixes quickly. You can read more about how we have been using it in our research at UCSB both in simulation and on FPGAs in our PyRTL paper at FPL.

Related Projects

It is always important to point out that PyRTL builds on the ideas of several other related projects as we all share the common goal of trying to make hardware design a better experience! You can read more about those relationships on our PyRTL project web page.

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

pyrtl-0.11.2.tar.gz (484.5 kB view details)

Uploaded Source

Built Distribution

pyrtl-0.11.2-py3-none-any.whl (168.9 kB view details)

Uploaded Python 3

File details

Details for the file pyrtl-0.11.2.tar.gz.

File metadata

  • Download URL: pyrtl-0.11.2.tar.gz
  • Upload date:
  • Size: 484.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for pyrtl-0.11.2.tar.gz
Algorithm Hash digest
SHA256 5a43ed52aa3c651048968fa32748d79745b6b959e6bcd29925708a25cb77b750
MD5 251461721a2697d628c2d92bdefb0d85
BLAKE2b-256 0498e4136b91deba840afed325023c125939ac7e6dc0f18035ae4e4123674ce6

See more details on using hashes here.

File details

Details for the file pyrtl-0.11.2-py3-none-any.whl.

File metadata

  • Download URL: pyrtl-0.11.2-py3-none-any.whl
  • Upload date:
  • Size: 168.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for pyrtl-0.11.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9f8cf0751eeea3a3cd41cfd83f761de06f8bb4f82d2cc29c9f8ab861b702d3b7
MD5 754698e21e9911cec10e4b2148dc0501
BLAKE2b-256 73e7066c315d43c29f0a99224545f29d023facf2f11f7db3ee032dbba9c6ce3f

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