Raising the Level of Circuit Board Design with Programming Techniques

Richard Lin
ACM UIST
Published in
5 min readOct 20, 2020

Electronics are all around us, and play a huge role in our modern lives. Moreover, in recent years, the design and construction of these devices is much more accessible to those without formal training, thanks to the availability of technical knowledge and a growing maker community. Examples range anywhere from fun side projects like LED cubes to the serious and practical like citizen science tools.

Example circuit boards made in our system

As almost all electronics involve printed circuit boards (PCBs), design software (such as KiCad, which is open source, as well as countless commercial packages) plays a huge role in the process. However, our previous study of PCB designers, published at CHI 2019, found that the schematic capture (circuit drawing) and board layout supported by these tools are only one part of the overall device design process. In particular, we identified the system architecture (block diagram) stage as promising: high-level and enjoyable to work with, while capturing much of the design intent of the final circuit.

Supporting System Architecture Design

System architecture sketch (left) vs. full schematic (right)

We designed our system, to support working at this system architecture level while retaining control over the low-level details. Our fundamental model involves extending the hierarchical block diagram (think of a circuit schematic, except that blocks can stand-in for subcircuits) with generators and block polymorphism. At the top level, the blocks defined in our tool would be similar to that drawn on a system diagram.

Example hierarchical block diagram: the IndicatorLed block is defined as a subcircuit containing LED and resistor (sub)blocks.

To enable system-level design, these blocks (with their subcircuit implementations) can be pulled in from libraries. However, defining their subcircuits programmatically (in code) as generators is what actually enables re-usable and high-level blocks. Where static subcircuits, like supported in modern schematic editors, might have set parts choices and be limited to specific applications, a generator block can choose those parts based on its environment. Furthermore, they can also work with high-level parameters and automatically generate low-level component values, for example automatically sizing the components in a buck converter to achieve a specified output voltage. This encapsulates the knowledge of experts in a way that is reusable and accessible to novices.

Example type hierarchy of step-down voltage converters.

System-level diagrams also allow a degree of ambiguity by the use of abstract or generic blocks like “USB port” or “voltage regulator”. We support the same idea by defining a type hierarchy (like in programming languages) of parts, where abstract super-types define interfaces and concrete sub-types define implementations. In our system, a device designer might ask for a “buck converter”, then make the refinement choice of specific chip from a list of alternatives. The ability to make these refinements anywhere in the block hierarchy (for example, choosing surface-mount or through-hole resistors for the voltage divider block in the buck converter block) retains the low-level control afforded by schematic editors while providing the design automation gains from a high-level, library-based approach.

Design HDL and System

# Example HDL corresponding to the above hierarchical block diagramself.mcu = self.Block(MagicMcu())
self.led = self.Block(IndicatorLed())
self.connect(self.mcu.digital[0], self.led.io)
self.connect(self.mcu.gnd, self.led.gnd)

We implemented this design system as a hardware description language (HDL), as code is needed to implement generators. As shown in the example, the language is Python-based (it’s actually implemented as a Python library), and its primitives correspond to a block diagram containing block and ports declarations, and the connections between them. The full power of Python can be used to construct these, including for loops for step-and-repeat and arbitrary math for component sizing. Generator libraries are constructed with the same abstractions, allowing users to build and extend libraries instead of being limited to a set of built-in blocks.

Visualization and refinement GUI, rendering the example HDL

A supplemental visualization and refinement GUI provides visibility into the design with an automatically laid out block diagram rendering, and allows interactive control over refinements. Abstract blocks are highlighted, and refinements can be selected from a list of available options.

As shown with the devices at the top of this post, our system can produce practically useful and working boards. Libraries keep the device design high-level and provide significant design automation, such as by generating analog blocks (like voltage converters), selecting parts (like choosing E12 resistors for a voltage divider), and providing subcircuits (like microcontrollers).

We’ve open-sourced our system on GitHub, so you can try it out (but be warned: it’s definitely rough around the edges and is not a production-ready tool — though we appreciate feedback and contributions). It replaces the schematic capture phase of an end-to-end board design flow, and exports netlists to KiCad for board layout.

Onwards and Forwards

While our current system demonstrates, through examples and user feedback, that high-level and library-based board design is possible through generators and block polymorphism, we see this as merely a starting point. Feedback from users and our experience building devices have provided us with plans for future work, including improving the electronics model, supporting more expressive primitives (like port-arrays), and exploring hybrid blocks-and-code editors that provide a more familiar interface.

In the larger picture, what we’d like to see is the best aspects of software engineering — a vibrant open-source community sharing libraries and code, supported by expressive and usable design tools and languages — applied to hardware design, and in a way that provides something for everyone: enable the experts to design more efficiently, while expanding the reach of novices in building custom and personalized devices.

About the Authors

Richard Lin
Rohit Ramesh
Connie Chi
Nikhil Jain
Ryan Nuqui
Prabal Dutta
Björn Hartmann

Citation

Richard Lin, Rohit Ramesh, Connie Chi, Nikhil Jain, Ryan Nuqui, Prabal Dutta, and Björn Hartmann. 2020. Polymorphic Blocks: Unifying High-level Specification and Low-level Control for Circuit Board Design. In Proceedings of the 33rd Annual ACM Symposium on User Interface Software and Technology (UIST ‘20). Association for Computing Machinery, New York, NY, USA, 529–540. DOI:https://doi.org/10.1145/3379337.3415860

--

--