Polymorphic Blocks is an open-source, Python-based hardware description language (HDL) for printed circuit boards (PCBs). The goal is to make use of programming concepts and capabilities to increase design automation and re-use, instead of being just a representational change like 'schematics but in text'.
The overall focus is on supporting subcircuit libraries that are general enough to be used in many different applications, much like what makes software development so productive and approachable. While graphical schematic tools have varying degrees of support for re-use, from copy-paste to hierarchical schematics, the subcircuits are static and typically specialized to one application. Baked-in choices like component values, footprint, and part number selection may not meet requirements for a different application that might, for example, call for 1206 instead of 0402, or has different voltage rails.
Defining libraries as code enables that kind of logic, generating the subcircuit to fit the particular application. This also allows encoding datasheet and application note instructions as part of the library, ensuring that boards can be correct-by-construction where design gotchas can be automated. Further programming concepts like type hierarchies and interfaces enable abstract components like generic resistors to be used in generic subcircuit libraries, while allowing the system designer the option to specify the particular type of resistor.
We've been using this system to create a variety of boards of different complexities, examples range from a charlieplexed LED matrix to a USB source-measure unit. Do note that work continues on this project and APIs and libraries may change, though the core has largely stabilized.
This project started as an academic project, though with the goal of broader adoption. Check out our papers (all open-access):
- System overview, UIST'20
- Mixed block-diagram / textual code IDE, UIST'21
- Array ports and multi-packed devices, SCF'22
See the setup documentation, then work through the getting started tutorial.
Setup tl;dr: install the Python package from pip: pip install edg
, and optionally run the IDE plugin with block diagram visualizer.
This is functional and produces boards, but is still a continuing work-in-progress.
If you're looking for a mature PCB design tool that just works, this currently isn't it (yet). For a mature and open-source graphical schematic capture and board layout tool, check out KiCad. However, if you are interested in trying something new, we're happy to help you and answer questions.
Current development focuses on supporting intermediate-level PCB projects, ie those an advanced hobbyist would make. Typical systems would involve power conditioning circuits, a microcontroller, and supporting peripherals (possibly including analog blocks). There is no hard-coded architecture (a microcontroller is not needed), and pure analog boards are possible. The system should also be able to handle projects that are much more or much less complex, especially if supporting libraries exist.
Example boards, including layouts, are available in the examples/ directory, structured as unit tests and including board layouts:
- Blinky: all variations of blinky from the getting started tutorial.
- LED Matrix: a 6x5 LED matrix display made up of discrete charlieplexed LEDs with a ESP32-C3 WiFi + RISC-V microcontroller, and demonstrating a charlieplexing array generator and packed resistors.
- Simon: a Simon memory game implementation with a speaker and 12v illuminated dome buttons.
- SWD Debugger: an SWD (Serial Wire Debug) programmer / debugger that is partially firmware-compatible with ST-Link/V2 clones.
- BLE Multimeter: a BLE (Bluetooth Low Energy) compact (stick form factor) multimeter, supporting volts / ohms / diode / continuity test mode, for low voltage applications.
- USB Source-Measure Unit: a USB PD (type-C power delivery) source-measure unit -- which can both act as a DC power supply with configurable voltage and current, and as a DC load. More precisely, it's a digitally-controlled 2-quadrant (positive voltage, positive or negative current) power source.
If you're interested in collaborating or contributing, please reach out to us, and we do take pull requests. Ultimately, we'd like to see an open-source PCB HDL that increases design automation, reduces tedious work, and makes electronics more accessible to everyone.
See developing.md for developer documentation.
- What is EDG?:
Embedded Device Generation (or more generally Electronic Device Generation) was a prior version of this project that focused on algorithms and models for embedded device synthesis, though it lacked a user-facing component.
This project is a continuation of that work focusing on an end-to-end system, and for most of its development cycle has been called
edg
. But, for the purposes of writing research papers, naming collisions are confusing and bad, and we chose to keep the repo and paper name consistent.