A Python-based HDL design prototyping framework for circuit simulation and verification
Project description
HDLproto
HDLproto is a lightweight, pre-RTL simulator that runs on pure Python. With zero external dependencies, it lets you quickly validate signal timing and control logic during the early design stages (from spec to architecture).
- Intuitive API: express HDL design rules directly using
@always_ff/@always_comband.r/.w - Event-driven safety: detect rule violations, multiple drivers, and non-convergent combinational logic via exceptions
- Easy to adopt: runs with Python only — great for learning, teaching, and rapid prototyping
About HDLproto (Concept and Scope)
HDLproto is a lightweight simulation framework for emulating HDL-style (Verilog/SystemVerilog) descriptions in Python.
It does not aim to strictly replicate HDL syntax but rather to provide a prototyping environment for concisely testing "hardware behavior models" like always_comb / always_ff and Wire / Reg within Python.
Target Goals
HDLproto is designed for the following use cases:
- Verifying CPU microarchitecture designs
- Checking the behavior of small-scale digital circuits
- Prototyping control units and Finite State Machines (FSMs)
- Validating ideas and organizing dataflow before full HDL design
- Understanding the behavior of
always_ff/always_combfor educational purposes
The primary goal is to enable users to easily express and verify "HDL-like behavior" using only Python.
What HDLproto is NOT (Unsupported Features)
- Code generation to Verilog / VHDL / SystemVerilog
- Logic synthesis for FPGAs / ASICs
- Timing analysis or logic optimization
- Implementation of large-scale RTL (thousands of signals)
HDLproto is strictly a simulation environment for prototyping and is not a tool for generating synthesizable RTL for FPGAs.
Key Features
- Build HDL-style modules and signals using only Python
- Faithfully simulates the behavior of
always_combandalways_ff - The simulator automatically handles
Wire/Regpropagation and stabilization loops - Automatically analyzes dependencies between modules and signals to run simulations
- Capable of simulating small-scale CPUs (like SAP-1 or a Z80 subset)
Intended Users
- Those who want to quickly prototype CPUs or digital circuits
- Those who want to verify dataflow or algorithms before starting HDL design
- Engineers and students who want to learn the concepts of hardware description languages
- Those who want to design with a hardware mindset, even without access to Verilog
- Those who want to experiment with circuits using the flexibility of Python
Installation
Installation from PyPI
pip install hdlproto
Install development version
git clone https://github.com/shntn/hdlproto.git
cd hdlproto
pip install -e .
Run without installation
git clone https://github.com/shntn/hdlproto.git
cd hdlproto
PYTHONPATH=. python3 example/ex_sap1.py
Requirements
- Python 3.10 or higher
Design Rules (Important)
@always_ff((Edge.POS, 'clk'), ...): Only non-blocking assignments toReg(writes via.r) are valid. Describes sequential logic sensitive to specified signal edges.@always_comb: Only writes toWire/Output(via.w) are valid. Writing toRegwill raise an exception.Simulator.clock()drives the clock signal specified inSimConfig. The clock signal must be received as anInputin the top module and defined as aWirein theTestBench.- Reset is treated as an input signal. Asynchronous reset is implemented by adding the reset signal to the
@always_fftrigger list (e.g.,@always_ff((Edge.POS, 'clk'), (Edge.POS, 'reset'))). Synchronous reset is described by writing the reset condition inside analways_ffblock that only triggers on the clock edge. - Convergence loop:
@always_combis re-evaluated until signals stabilize. Non-convergence raises an exception.
Included Samples
example/ex_module.py: A slightly richer introductory example.example/ex_sap1.py: A SAP-1 implementation, ideal for pre-RTL exercises.example/ex_exception.py: Scripts to reproduce exceptions (rule violations, conflicts).
License
- License: MIT License
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hdlproto-0.3.2.tar.gz.
File metadata
- Download URL: hdlproto-0.3.2.tar.gz
- Upload date:
- Size: 30.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.0rc1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05e7d29fa141e4c7038ab86956514a2b2acfb2af9e19bcfe4aa6a0650ce97d6c
|
|
| MD5 |
8cd34c7c551229a5e3c48f8c991e88fe
|
|
| BLAKE2b-256 |
bdc82691ab9a8441ce84abdfbb2d752bd7331b5e70d1da67a813784fb40e6d93
|
File details
Details for the file hdlproto-0.3.2-py3-none-any.whl.
File metadata
- Download URL: hdlproto-0.3.2-py3-none-any.whl
- Upload date:
- Size: 35.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.0rc1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5dffb01b57a535b99421ee7467eeb81c7829f992223c1d288f68c5f26db64334
|
|
| MD5 |
9a2ee58133770404113e8b5fd0bd7b24
|
|
| BLAKE2b-256 |
ef40996fcfd6c5896f792f02dc2742b605545f76bbd371fdb1afe3045b440c53
|