Skip to main content

Python HDL that simulates and generates Verilog from the same source

Project description

VeriPy

Python HDL that simulates and generates Verilog from the same source.

Write your hardware modules once in Python. VeriPy lets you simulate them natively, emit synthesizable Verilog, and verify that both paths produce identical results — all from a single description.

Quick Example

@module (recommended)

from veripy import module, Input, Output, Register
from veripy.context import comb, posedge

@module
def counter(width=8):
    clock   = Input()
    reset   = Input()
    enable  = Input()
    count   = Output(width)
    cnt     = Register(width)

    @comb
    def drive_output():
        count = cnt

    @posedge(clock)
    def increment():
        if reset:
            cnt = 0
        elif enable:
            cnt = cnt + 1

Class-based

from veripy import Module, Input, Output, Register

class Counter(Module):
    def __init__(self, width=8):
        self.clock   = Input()
        self.reset   = Input()
        self.enable  = Input()
        self.count   = Output(width)
        self.cnt     = Register(width)
        super().__init__()

        @self.comb
        def drive_output():
            self.count = self.cnt

        @self.posedge(self.clock)
        def increment():
            if self.reset:
                self.cnt = 0
            elif self.enable:
                self.cnt = self.cnt + 1

Both APIs produce identical simulation results and Verilog output. Use whichever you prefer — @module is more concise, the class-based API gives full control over __init__.

c = counter(width=4)       # or Counter(width=4)
c.enable.set(1)
c.reset.set(1)
c.tick()
c.reset.set(0)
for _ in range(5):
    c.tick()
print(c.count)              # 5
print(c.to_verilog())       # synthesizable Verilog

Installation

Requires Python 3.10+ and Icarus Verilog for build verification and dual-path testing.

pip install -e .

CLI

veripy build <file.py>              # emit Verilog (compile-checked via iverilog)
veripy build <file.py> -o out/      # write .v files to a directory
veripy build <file.py> -p width=4   # pass parameters
veripy test [path] [-v]             # dual-path test suite
veripy import <file.v>              # convert Verilog → VeriPy Python
veripy import rtl/ -o src/          # convert entire project
veripy lint <file.py>               # static checks

Features

  • Dual-path testing — one test verifies both Python sim and generated Verilog (docs)
  • Signal typesInput, Output, Register, Signal, Mem, bit slicing, concatenation (docs)
  • Sub-modules — hierarchical composition with automatic port wiring (docs)
  • FSM sugar — declarative state machines (docs)
  • Formal propertiesassert_always, cover (docs)
  • Pipelines — explicit stage boundaries with automatic registers (docs)
  • Timing constraints — SDC output co-located with logic (docs)
  • Interface bundles — reusable signal groups (docs)
  • Verilog import — convert existing RTL to VeriPy (docs)
  • Lint — undriven outputs, multi-driven signals, missing reset, unused signals, CDC violations (docs)
  • CDC primitivesSynchronizer, AsyncFIFO with gray-code pointers (docs)
  • Event-driven simulationSimEngine with proper Verilog scheduling (docs)

Documentation

  • Guide@module tutorial: signals, logic blocks, parameters, sub-modules, FSM, pipelines, formal, timing, interfaces
  • Class-based API — the Module base class for advanced use cases
  • Signals — signal types, operations, slicing, memory arrays
  • Testing — dual-path testing, SimEngine, VCD waveforms
  • Verilog — import, export, emission, lint

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

veripy_hdl-0.1.0.tar.gz (58.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

veripy_hdl-0.1.0-py3-none-any.whl (43.2 kB view details)

Uploaded Python 3

File details

Details for the file veripy_hdl-0.1.0.tar.gz.

File metadata

  • Download URL: veripy_hdl-0.1.0.tar.gz
  • Upload date:
  • Size: 58.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for veripy_hdl-0.1.0.tar.gz
Algorithm Hash digest
SHA256 caeda973eb03b4d4b4aecc7fc718d3646473abd934af2939cab1257be2fea4bb
MD5 41ef50d9e2f9ebed1fe5994178345c47
BLAKE2b-256 6e0b89c01ab8c632c4ecaacc69f056e955e0c0808434400338b6e02af457fb29

See more details on using hashes here.

Provenance

The following attestation bundles were made for veripy_hdl-0.1.0.tar.gz:

Publisher: publish.yml on dannygale/veripy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file veripy_hdl-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: veripy_hdl-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 43.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for veripy_hdl-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d9ee4fe40083631a18f954674f37ff39a913ad4ce13d1bd2fc5d460e256c5ef9
MD5 8734dc273d310345617aa3bf93e62dc5
BLAKE2b-256 5794c33cb59763c3fa138c8f22649d854aac47182ec8b5ea4a92ced168836252

See more details on using hashes here.

Provenance

The following attestation bundles were made for veripy_hdl-0.1.0-py3-none-any.whl:

Publisher: publish.yml on dannygale/veripy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page