Skip to main content

A Python to VHDL compiler

Project description

CoHDL

CoHDL is a hardware description language embedded in Python. It translates a subset of Python into synthesizable VHDL.


examples/introduction

You can find an introduction and many examples in this documentation repository.

features

At its core CoHDLs language model is very similar to VHDL. Designs are made up of signals and variables built from types like Bit and BitVector. There are concurrent contexts, for expressions that would appear in the architecture scope of VHDL entities and sequential contexts equivalent to VHDL processes.

Code that uses only basic features also found in VHDL (if-statements, signal/variable assignments, arithmetic operators and so on) essentially looks like VHDL written in Python syntax. On top of that CoHDL supplies many additional features

coroutines

The initial motivation for CoHDL was to explore how well coroutines, found in many modern programming languages, translate to the domain of hardware description languages.

CoHDL turns Pythons async/await style coroutines into VHDL state machines. This process is completely deterministic and allows clock accurate modeling of sequential processes. The main advantage over explicit state machine implementations is, that coroutines are reusable.

Common sequences such as AXI transactions can be defined once and instantiated whenever needed.

supported Python subset

The following is an incomplete list of Python constructs supported in synthesizable contexts

  • statements
    • if
    • for
    • if expressions
    • generator expressions
    • most operators
  • functions
    • arbitrary argument types
    • default arguments
    • keyword arguments
    • variadic arguments
    • compile time recursion
    • compile time evaluated builtin functions
  • classes
    • member access
    • methods
    • operator overloading
    • inheritance
    • overriding methods
  • python container types
    • list
    • dict
  • coroutines

meta programming

Since CoHDL is embedded in Python, it is possible to run arbitrary code before and after the compilation. This can be used to load configuration files or run external programs like simulators or synthesis tools on the generated VHDL.

For a working example of this checkout cohdl_xil. It generates Makefile projects for CoHDL designs targeting Xilinx FPGAs.


getting started

CoHDL requires Python3.10 or higher and has no further dependencies. You can install it by running

python3 -m pip install cohdl

in a terminal window. You should then be able to run the code snippets, found in the introduction repository and implement own designs.

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

cohdl-0.2.2.tar.gz (193.3 kB view details)

Uploaded Source

Built Distribution

cohdl-0.2.2-py3-none-any.whl (228.7 kB view details)

Uploaded Python 3

File details

Details for the file cohdl-0.2.2.tar.gz.

File metadata

  • Download URL: cohdl-0.2.2.tar.gz
  • Upload date:
  • Size: 193.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.4

File hashes

Hashes for cohdl-0.2.2.tar.gz
Algorithm Hash digest
SHA256 7a45235620f427f47f84ac1ebc3c03a44418ca772c1c829038f43bbff80b36ce
MD5 0a5ffab62cb24302eebbf918f7c203d0
BLAKE2b-256 0e8c6b51f1bc7c0692024f66ff56eb7a447e7927eaaa488042c1599c0fda2452

See more details on using hashes here.

File details

Details for the file cohdl-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: cohdl-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 228.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.4

File hashes

Hashes for cohdl-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 065ea439aa53002e2732a99744e6fa77f0a3ef138b087776ae6135e89a039f98
MD5 d1ad574c7f0e3f5c82a32a8680484a22
BLAKE2b-256 ea27d98f948ca8f59ee101144498c173d490f5c58f3580174d6865e98f0f670d

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