Skip to the content
PCBKitNew board
4 layers168 × 52 mmUsbSourceMeasure, the printed circuit board in 3D

A Python-based hardware description language for PCBs for higher-level (block-diagram / system-architecture level) PCB design through libraries of directly reusable subcircuit generators.

Size
168 × 52 mm
Copper layers
4
Thickness
2.63 mm
Parts
319
Nets
185
Pads
1,134
Tracks, vias
2,773, 515
Pours
60
Routed
Yes
KiCad
KiCad 8.0 (file 20240108)
Created
9 Jul 2020
Updated
2 Nov 2026

Overview

UsbSourceMeasure is an open-source printed circuit board by BerkeleyHCI, from the BerkeleyHCI/PolymorphicBlocks repository on GitHub, published under the BSD-3-Clause licence. It is a 4-layer board of 168 × 52 mm with 319 parts on 185 nets, routed with 2,773 tracks and 515 vias.

Its parts include 32 resistors, 25 capacitors, 10 ICs, 4 diodes and 4 transistors.

README

README.md

Polymorphic Blocks

Python

subcircuit generator library based hardware description language for circuit board design

Polymorphic Blocks is an open-source, Python-based hardware description language (HDL) for schematic-equivalent design of printed circuit boards (PCBs). Its library of components provide a high-level abstraction for circuit design while subcircuit generators automate the calculation of fine details. Abstract component interfaces enable these libraries to be general across applications and component vendors.

Generates stable KiCad netlists to be routed in the KiCad PCB Editor.

Built Boards

Many boards have been built with this system, from a mechanical keyboard macropad, to battery-powered IoT devices, to a USB source-measure unit. Check out the examples page!

Example: from HDL to Keyboard

Overall flow: write HDL -> generate netlist -> import into KiCad PCB editor -> place and route (optionally iterating with HDL) -> export BoM and Gerbers -> optionally generate JLC PCBA data

A simplified version of the getting started tutorial is this snippet for a 3x4 mechanical keyboard:

python
from edg import *

class Keyboard(SimpleBoardTop):
    def contents(self) -> None:
        super().contents()

        self.usb = self.Block(UsbCReceptacle())
        self.reg = self.Block(LinearRegulator(3.3 * Volt(tol=0.05)))
        self.connect(self.usb.gnd, self.reg.gnd)
        self.connect(self.usb.pwr, self.reg.pwr_in)

        with self.implicit_connect(
            ImplicitConnect(self.reg.pwr_out, [Power]),
            ImplicitConnect(self.reg.gnd, [Common]),
        ) as imp:
            self.mcu = imp.Block(IoController())
            self.connect(self.usb.usb, self.mcu.usb.request())

            self.sw = self.Block(SwitchMatrix(ncols=3, nrows=4))
            self.connect(self.sw.cols, self.mcu.gpio.request_vector("sw_col"))
            self.connect(self.sw.rows, self.mcu.gpio.request_vector("sw_row"))

            self.enc = imp.Block(DigitalRotaryEncoder())
            self.connect(self.enc.a, self.mcu.gpio.request("enc_a"))

The system:

  • provides a library of subcircuit generators, like switch matrices and USB-C ports, that automatically include supporting components like decoupling capacitors and pullup resistors
  • automatically selects generic parts like resistors and diodes against builtin parts tables
  • performs basic electrical checks on the design, including voltage and current limits, automating some common datasheet parameter checking
  • runs fully locally

This generates:

  • a netlist that can be imported into the KiCad PCB editor
    • ... including hierarchical data, allowing subcircuit replication / channelization
    • ... and have stable tstamps, allowing incremental updates to in-progress board layouts
  • a JLCPCB-compatible BoM
    • including a postprocessing script to shift part rotations from KiCad-generated component placements for JLC PCBA
  • a JSON representation of the full design, including connectivity and solved circuit values, to integrate with custom / third-party tooling

macropad.webp

Advanced capabilities include:

  • multi-board support including connector-pair management
  • cross-hierarchy packing of multi-pack devices like dual op-amps and quad resistors
  • standard abstract component interfaces, allowing for custom implementations of parts like resistors (including from a parts table), and microcontrollers
  • full support for user component definition; very little is hard-coded into the infrastructure

Getting Started

text
pip install edg

On first run, the system will automatically download a compatible Java runtime for the core compiler.

Then, work through building a mechanical keyboard (including subcircuit layout replication) in the getting started tutorial.

Also check out the reference documentation for a concise list of capabilities.

Some documentation is available for library parts construction. Be warned, this is more complex and less polished. See the library block definition tutorial using KiCad schematic import and the library construction reference.

Compared to Hierarchical Schematics

The main goal of this HDL is to enable the creation of general subcircuit libraries that can be reused across many applications.

While graphical schematic tools support hierarchical sheets, direct re-use is limited because the sheets encode a lot of per-design information, like a specific resistor values or footprints. Different users may have different requirements (e.g., different resistor values for a LED based on its input voltage, or preference for through-hole vs. surface-mount components).

This HDL addresses those limitations with two mechanisms:

  • Generators allow the implementation of the subcircuit to depend on high-level parameters. A LED circuit could automatically size its resistor based on the input voltage.
  • Abstract parts allow the subcircuit to use generic parts with generic interfaces, which many parts can implement. An abstract resistor interface could be implemented by through-hole and surface-mount resistors, enabling a generic LED circuit and deferring the choice. The top-level designer can then specify refinements to make the specific choice of parts.

Both of these combined also present a higher level of abstraction for the board designer, more at the system architecture level-of-design than schematics. We suspect this will also make it easier for novices to design boards, reducing the knowledge barrier to entry.

Graphical Tooling

The fundamental design structure is the hierarchical block diagram, and we expect graphical tooling can layer cleanly on top of the HDL core. Our current focus is on the HDL core and parts libraries, but we are open to collaborations with those interested in building graphical tooling. We suspect this may be particularly useful for novice users.

We built a proof-of-concept mixed textual / graphical IDE plugin for IntelliJ / PyCharm. It has some nifty concepts (including a block diagram visualizer and design space sweep) but is rough around the edges and only sees basic maintenance. It could be a good source for ideas for community developers.

Additional Notes

Project Status

This is functional has been used to produce a wide variety of boards over the years. While the core is reasonably stable, as a pre-v1.0-release there are no formal guarantees of API stability. In practice, deprecation shims are / will be maintained for common features if APIs change.

This started as an academic research project and continues to be developed as a personal project post-graduation, including for designing boards for fun.

(Some) Dragons Be Ahead

Many functional boards have been built with this system and most of the library parts have been physically tested (some across many designs), but there may still be bugs and edge cases. You are recommended to sanity check generated designs during layout.

Be prepared for things to be rough around the edges. The error messages in particular are not great and need work.

Building boards with the included libraries should be relatively straightforward, but building custom library parts is a more complex process.

Scope

The current libraries best support intermediate-level (and simpler) PCB designs. This includes circuits with discrete microcontrollers, microcontroller modules (like ESP32s), and socketed dev boards. Libraries include common subcircuits like switch matrices, digitally attached peripherals like I2C sensors, voltage converters, and some analog signal conditioning circuits. Check out the subcircuits library folder and parts library folder.

There is no prescribed architecture and microcontrollers are not required.

ESPHome boards are a great fit.

Designs that do not decompose neatly(ish) into subcircuits blocks are a poor fit.

There is no support for high-speed digital design (like DDR memories). There are some experimental RF subcircuits.

The electrical checks are not a design assurance tool and only automate some of the most common datasheet checks. More advanced parameters, especially performance characteristics not related to maximum ratings, are currently out of scope of the electronics model.

Parameter Engine

This system has a concept of parameters (variables, think voltages and currents) that can be attached to blocks and propagate through ports. This is limited to directed assignments, with the goal of deterministic, predictable compilation.

Assertions are supported on parameters to enforce electrical correctness checks.

Solving may happen within a single block with arbitrary Python code (for example, find the best set of E12 resistor values to implement a divider), but not across multiple blocks. Search involving multiple blocks must be handled by the block exposing tuning knobs and the user turning those knobs with recompilation.

Parts Data

Most passive parts / discretes are selected from a 2022 JLCPCB parts table (included in this repository). JLC no longer makes parts tables publicly available.

This parts table still works well and boards have been built using this table as recently as 2026. Some basic parts have drifted and some parts may be no longer stocked.

Contributing

We take pull requests and would love to see contributions and collaborations!

See CONTRIBUTING.md for details.

Papers

This started as an academic project, though with the goal of broader adoption. Check out our papers (all open-access), which have more details:

Misc

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

Parts

319
QtyValueFootprintReferences
4MountingHole_2.7mm_M2.5_Pad_ViaMountingHole:MountingHole_2.7mm_M2.5_Pad_ViaMH1, MH2, MH3, MH4
1G***edg:Symbol_HiLabSolidSYM2
1G***edg:Symbol_LemurSolidSYM1
1Indicator_IdDots_4edg:Indicator_IdDots_4
1LOGOSparkfun Qwiic:qwiic_5.5mmG***
1adc.avdd_cap_0Capacitor_SMD:C_0603_1608MetricC100
1adc.avdd_cap_1Capacitor_SMD:C_0603_1608MetricC101
1adc.avdd_resResistor_SMD:R_0603_1608MetricR80
1adc.dvdd_cap_0Capacitor_SMD:C_0603_1608MetricC102
1adc.dvdd_cap_1Capacitor_SMD:C_0603_1608MetricC103
1adc.dvdd_resResistor_SMD:R_0603_1608MetricR81
1adc.icPackage_SO:TSSOP-20_4.4x6.5mm_P0.65mmU38
1adc.vref_capCapacitor_SMD:C_0805_2012MetricC104
1boost_rc.cCapacitor_SMD:C_0603_1608MetricC79
1boost_rc.rResistor_SMD:R_0603_1608MetricR66
1buck_rc.cCapacitor_SMD:C_0603_1608MetricC78
1buck_rc.rResistor_SMD:R_0603_1608MetricR65
1cap_convCapacitor_SMD:CP_Elec_6.3x7.7C4
1ci_amps.icPackage_SO:SOIC-8_3.9x4.9mm_P1.27mmU41
1ci_amps.vdd_capCapacitor_SMD:C_0603_1608MetricC110
1cintref_amps.icPackage_SO:SOIC-8_3.9x4.9mm_P1.27mmU42
1cintref_amps.vdd_capCapacitor_SMD:C_0603_1608MetricC111
1comp_pullResistor_SMD:R_0603_1608MetricR72
1control.amp.r1Resistor_SMD:R_0603_1608MetricR36
1control.amp.r2Resistor_SMD:R_0603_1608MetricR37
1control.cdivCapacitor_SMD:C_0603_1608MetricC58
1control.comp_sink.icPackage_TO_SOT_SMD:SOT-353_SC-70-5U13
1control.comp_sink.vdd_capCapacitor_SMD:C_0603_1608MetricC50
1control.comp_source.icPackage_TO_SOT_SMD:SOT-353_SC-70-5U12
1control.comp_source.vdd_capCapacitor_SMD:C_0603_1608MetricC49
1control.dmeas.r1Resistor_SMD:R_0603_1608MetricR22
1control.dmeas.r2Resistor_SMD:R_0603_1608MetricR23
1control.dmeas.rfResistor_SMD:R_0603_1608MetricR24
1control.dmeas.rgResistor_SMD:R_0603_1608MetricR25
1control.driver.cap_in1Capacitor_SMD:CP_Elec_6.3x7.7C55
1control.driver.cap_in2Capacitor_SMD:C_0805_2012MetricC56
1control.driver.cap_in3Capacitor_SMD:C_0603_1608MetricC57
1control.driver.clamp1Diode_SMD:D_SOD-323D10
1control.driver.clamp2Diode_SMD:D_SOD-323D11
1control.driver.high_fetPackage_TO_SOT_THT:TO-220-3_Horizontal_TabUpQ7
1control.driver.high_gate.icPackage_TO_SOT_SMD:SOT-23-6U15
1control.driver.high_gate.vdd_capCapacitor_SMD:C_0805_2012MetricC53
1control.driver.high_resResistor_SMD:R_0603_1608MetricR41
1control.driver.low_fetPackage_TO_SOT_THT:TO-220-3_Horizontal_TabUpQ8
1control.driver.low_gate.icPackage_TO_SOT_SMD:SOT-23-6U16
1control.driver.low_gate.vdd_capCapacitor_SMD:C_0805_2012MetricC54
1control.driver.low_resResistor_SMD:R_0603_1608MetricR42
1control.driver.res.res[0]Resistor_SMD:R_0603_1608MetricR38
1control.driver.res.res[1]Resistor_SMD:R_0603_1608MetricR39
1control.driver.res.res[2]Resistor_SMD:R_0603_1608MetricR40
1control.err_sink.cinCapacitor_SMD:C_0603_1608MetricC48
1control.err_sink.diodeDiode_SMD:D_SOD-323D9
1control.err_sink.rbotResistor_SMD:R_0603_1608MetricR33
1control.err_sink.rtopResistor_SMD:R_0603_1608MetricR32
1control.err_source.cinCapacitor_SMD:C_0603_1608MetricC47
1control.err_source.diodeDiode_SMD:D_SOD-323D8
1control.err_source.rbotResistor_SMD:R_0603_1608MetricR31
1control.err_source.rtopResistor_SMD:R_0603_1608MetricR30
1control.err_volt.cinCapacitor_SMD:C_0603_1608MetricC46
1control.err_volt.rbotResistor_SMD:R_0603_1608MetricR27
1control.err_volt.rfineResistor_SMD:R_0603_1608MetricR29
1control.err_volt.routResistor_SMD:R_0603_1608MetricR28
1control.err_volt.rtopResistor_SMD:R_0603_1608MetricR26
1control.hvclampResistor_SMD:R_0603_1608MetricR35
1control.iclamp.Q1Package_TO_SOT_SMD:SOT-23Q11
1control.iclamp.Q2Package_TO_SOT_SMD:SOT-23Q12
1control.iclamp.rResistor_SMD:R_0603_1608MetricR57
1control.ifilt.cCapacitor_SMD:C_0603_1608MetricC62
1control.ifilt.rnResistor_SMD:R_0603_1608MetricR52
1control.ifilt.rpResistor_SMD:R_0603_1608MetricR51
1control.imeas.icPackage_SO:SOIC-8_3.9x4.9mm_P1.27mmU24
1control.imeas.rgResistor_SMD:R_0603_1608MetricR54
1control.imeas.vdd_capCapacitor_SMD:C_0805_2012MetricC64
1control.int.cCapacitor_SMD:C_0603_1608MetricC52
1control.int.rResistor_SMD:R_0603_1608MetricR34
1control.isense.ranges[0].isenseResistor_SMD:R_1206_3216MetricR45
1control.isense.ranges[0].pwr_sw.icPackage_DIP:SMDIP-6_W7.62mmU18
1control.isense.ranges[0].pwr_sw.resResistor_SMD:R_0603_1608MetricR46
1control.isense.ranges[0].sense_sw.icPackage_TO_SOT_SMD:SOT-23-6U17
1control.isense.ranges[0].sense_sw.vdd_capCapacitor_SMD:C_0805_2012MetricC59

The 83 most common of 319 parts.

Questions

How big is the UsbSourceMeasure PCB?

It measures 168 × 52 mm and has 4 copper layers, 2.63 mm thick.

What parts does the UsbSourceMeasure use?

319 parts. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the UsbSourceMeasure KiCad files?

From the BerkeleyHCI/PolymorphicBlocks repository on GitHub, at the commit this page was made from: the board is examples/UsbSourceMeasure/UsbSourceMeasure.kicad_pcb. PCBKit opens the board in the browser, with nothing to install.

Can I use the UsbSourceMeasure design in my own project?

Its repository publishes it under the BSD-3-Clause licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).

More from BerkeleyHCI/PolymorphicBlocks

12
  • 2 layers115 × 72 mmFcmlPanel, the printed circuit board in 3D

    FcmlPanel

    BerkeleyHCI/PolymorphicBlocks

    A Python-based hardware description language for PCBs for higher-level (block-diagram / system-architecture level) PCB design through libraries of directly reusable subcircuit generators.

    246 parts94BSD-3-Clause
  • 2 layers30 × 95 mmIotThermalCamera, the printed circuit board in 3D

    IotThermalCamera

    BerkeleyHCI/PolymorphicBlocks

    A Python-based hardware description language for PCBs for higher-level (block-diagram / system-architecture level) PCB design through libraries of directly reusable subcircuit generators.

    120 parts94BSD-3-Clause
  • 2 layers226 × 74.4 mmSevenSegment, the printed circuit board in 3D

    SevenSegment

    BerkeleyHCI/PolymorphicBlocks

    A Python-based hardware description language for PCBs for higher-level (block-diagram / system-architecture level) PCB design through libraries of directly reusable subcircuit generators.

    119 parts94BSD-3-Clause
  • 2 layers60 × 80 mmRobotCrawler, the printed circuit board in 3D

    RobotCrawler

    BerkeleyHCI/PolymorphicBlocks

    A Python-based hardware description language for PCBs for higher-level (block-diagram / system-architecture level) PCB design through libraries of directly reusable subcircuit generators.

    118 parts94BSD-3-Clause
  • 4 layers136 × 18 mmMultimeter, the printed circuit board in 3D

    Multimeter

    BerkeleyHCI/PolymorphicBlocks

    A Python-based hardware description language for PCBs for higher-level (block-diagram / system-architecture level) PCB design through libraries of directly reusable subcircuit generators.

    111 parts94BSD-3-Clause
  • 2 layers110 × 97.2 mmPcbBot, the printed circuit board in 3D

    PcbBot

    BerkeleyHCI/PolymorphicBlocks

    A Python-based hardware description language for PCBs for higher-level (block-diagram / system-architecture level) PCB design through libraries of directly reusable subcircuit generators.

    109 parts94BSD-3-Clause
  • 2 layers63 × 81 mmEspLora, the printed circuit board in 3D

    EspLora

    BerkeleyHCI/PolymorphicBlocks

    A Python-based hardware description language for PCBs for higher-level (block-diagram / system-architecture level) PCB design through libraries of directly reusable subcircuit generators.

    105 parts94BSD-3-Clause
  • 2 layers100 × 36 mmIotIron, the printed circuit board in 3D

    IotIron

    BerkeleyHCI/PolymorphicBlocks

    A Python-based hardware description language for PCBs for higher-level (block-diagram / system-architecture level) PCB design through libraries of directly reusable subcircuit generators.

    98 parts94BSD-3-Clause
  • 2 layers64.1 × 103.2 mmKeyboard, the printed circuit board in 3D

    Keyboard

    BerkeleyHCI/PolymorphicBlocks

    A Python-based hardware description language for PCBs for higher-level (block-diagram / system-architecture level) PCB design through libraries of directly reusable subcircuit generators.

    85 parts94BSD-3-Clause
  • 2 layers38.6 × 38.6 mmIotLedDriver, the printed circuit board in 3D

    IotLedDriver

    BerkeleyHCI/PolymorphicBlocks

    A Python-based hardware description language for PCBs for higher-level (block-diagram / system-architecture level) PCB design through libraries of directly reusable subcircuit generators.

    81 parts94BSD-3-Clause
  • 2 layers50 × 62 mmIotDisplay, the printed circuit board in 3D

    IotDisplay

    BerkeleyHCI/PolymorphicBlocks

    A Python-based hardware description language for PCBs for higher-level (block-diagram / system-architecture level) PCB design through libraries of directly reusable subcircuit generators.

    78 parts94BSD-3-Clause
  • 2 layers142 × 20 mmDeskController, the printed circuit board in 3D

    DeskController

    BerkeleyHCI/PolymorphicBlocks

    A Python-based hardware description language for PCBs for higher-level (block-diagram / system-architecture level) PCB design through libraries of directly reusable subcircuit generators.

    69 parts94BSD-3-Clause

Similar boards

  • 4 layers194 × 94 mmBottom board, the printed circuit board in 3D

    Bottom board

    mod-audio/hw-mod-dwarf

    Hardware project of MOD Dwarf

    319 parts6
  • 4 layers186 × 74.5 mmVXDash, the printed circuit board in 3D

    VXDash

    martinroger/VXDash

    An instrument cluster for the VX220

    319 parts3CERN-OHL-S-2.0
  • 4 layers80 × 49 mmPIB, the printed circuit board in 3D

    PIB

    apexsat/payload-electrical

    PCBs for payload

    319 parts1
  • 4 layers204 × 150 mmGateway, the printed circuit board in 3D

    Gateway

    Kampi/IoT-Gateway

    Open-Source Zigbee, Thread, wM-Bus, LoRa, LoRaWAN gateway for Home Assistant.

    319 parts1
  • 4 layers166.6 × 94 mmPanel, the printed circuit board in 3D

    Panel

    nrdsp/rvPhone

    The goal of the this project is to develop a privacy enhanced, simple and fully featured mobile phone.

    319 parts
  • 4 layers240 × 180 mmAgrinode mc, the printed circuit board in 3D

    Agrinode mc

    rthcloudcom-art/PCB

    319 parts