Skip to main content

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.11 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.

Metadata

Release files for cohdl 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cohdl 0.2.4
File Size Uploaded
cohdl-0.2.4.tar.gz 209.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cohdl 0.2.4
File Interpreter ABI Platform
cohdl-0.2.4-py3-none-any.whl Python 3 none any Details

Total release size: 478.3 kB

Release files / cohdl-0.2.4.tar.gz

Download URL cohdl-0.2.4.tar.gz
Size 209.0 kB
Tags Source
SHA-256 checksum
How to use checksums
881816b6943fd3f945d2eea4e0814302cd9392c783add5508adc6228f723059c
BLAKE2b-256 checksum
How to use checksums
edf84a0f9051c66d4379b43c2af8f4defaca88fbd38f3aea88dd9f1844984c21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.6

Release files / cohdl-0.2.4-py3-none-any.whl

Download URL cohdl-0.2.4-py3-none-any.whl
Size 269.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ff381c0cead059601d63cd84bec9593aed9688e27f36aa2dd8071b5383d186eb
BLAKE2b-256 checksum
How to use checksums
e135c165e66a9f9ad7baa965794c3ac87904c8cbc98a316b543472360e514635
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.6

Release history Release notifications | RSS feed

This release

0.2.4 This release

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page