Lurker News
Hey HN! We are the founders of atopile. We’re building a tool to describe electronics with code. Here is a quick demo: https://youtu.be/7-Q0XVpfW3Y

Could you imagine the pain of building an entire software product using only assembly code? That’s about how we felt designing hardware. We don’t currently have good ways to describe what we need, reuse existing designs and compile that description down to a product.
We started atopile to fix this. atopile is an open-source language and toolchain to describe circuits with code. The compiler is here: https://github.com/atopile/atopile Docs are here: https://atopile.io/getting-started/ . For a detailed deep dive designing an ESP32 module, see this video: https://youtu.be/eMWRwZOajdQ
We realized this was a problem in our previous jobs. Narayan and I (Tim) had to manually, draw and export all our electronic circuit boards. This lasted until our friend Matt, a software engineer, showed us his development workflow. All his projects were built, tested, and merged automatically via GitHub. So we asked: Can we build the same for hardware?
We observed that the ability to abstract electronics effectively hinged on using a language to describe the requirements, so we came up with the “ato” language. In ato, you can break down circuits into modules, components and interfaces. You can nest and connect those blocks with each other. Here is an example with an RP2040 microcontroller:

  import RP2040Kit from "rp2040/RP2040Kit.ato"
  import LEDIndicatorBlue from "generics/leds.ato"
  import LDOReg3V3 from "regulators/regulators.ato"
  import USBCConn from "usb-connectors/usb-connectors.ato"

  module Blinky:
    micro_controller = new RP2040Kit
    led_indicator = new LEDIndicatorBlue
    voltage_regulator = new LDOReg3V3
    usb_c_connector = new USBCConn

    usb_c_connector.power ~ voltage_regulator.power_in
    voltage_regulator.power_out ~ micro_controller.power
    micro_controller.gpio13 ~ led_indicator.input
    micro_controller.power.gnd ~ led_indicator.gnd

    led_indicator.resistor.value = 100ohm +/- 10%

From there, the compiler produces a netlist that describes how the circuit is connected and selects jelly-bean components for you (https://atopile.io/blog/2024/01/31/cloud-components/). Our next focus will be to add layout reuse, mathematical relations between values and define circuits by traits (similar to Rusts’).

At the moment, atopile is intended to design all types of printed circuit boards (PCB) with low to medium complexity. The circuit complexity that the compiler can handle will steadily increase until it becomes suited for production usage. We often get asked if the compiler is meant for chip design rather than PCBs, but that is not the case. The language is exclusive to PCBs. At least for now..!
A big part of why the software community is so prolific is thanks to open source and open core technology. The ability to share software packages with each other and efficiently chain tools together has made the software world an awesome place for developers. As hardware engineers, we would love our field to benefit from this as well. That’s why we’ve made atopile’s core open source (Apache 2.0). We plan to generate revenue by selling entreprise targeted features, similar to GitLab.
We would love to have your thoughts on the compiler! What’s your story in electronics? What would you want us to build?

Comments (292) 77 threads

Earlier comments
fxtentacle3 replies#
Did you know that the KiCad file format for schematics and PCB layouts is text? And it kind of reads like source code? You can even check it into Git.

What stops electronics from becoming like programming is the routing. It's NP hard and even the big car companies haven't solved it yet, let alone any tool accessible to hobbyists and startups.
So you spend an hour designing the schematics, a few minutes placing the components, and then hours doing the routing by hand. If your product only replaces the first step, that'll save me at most 10% of the work.
If you want to make a crater in this industry, add an autorouter to KiCad and make it sophisticated enough to handle an ESP32 2-layer board without manual assistance. Altium is like $15k per year and cannot do it yet.

4b11b41 reply#
you can do this with the Freerouting plugin

it's non-trivial, you need to fiddle with parameters to encourage the autoroute towards certain behaviors. there are also some schematic patterns that lend towards better netlists and in turn better routing

fxtentacle1 reply#
In general, yes, but when I tried it, all free autorouters (and the paid one in Altium) failed to do the fan-out/escape of the ESP32's BGA.

I then built a little CLI tool which used bitmap images and ConvNets to do just that one fan-out, but then I lost interest in it as soon as the PCB was finished.

ranger_danger#
I really wonder why autorouters are so bad/slow still, I at least understand the high level concept of what it should be able to do, and I would think that with enough input parameters, this shouldn't be that hard of a problem to solve, especially with how easy it is to deploy tasks across lots of powerful machines for (relatively) cheap these days.
Timot05#
Autorouting would for sure be a valuable tool to add to EEs toolchains. The reason we focused on the language first is because it is critical to provide high quality information to autorouter for them to do a good job. And achieving that with a schematic is tough, as it only captures part of the information required to doing a good job laying out the circuit. A bunch of information is currently implicit.
pjc50#
Not just routing, but from a cursory reading of atopile I can't see how they've even addressed floorplanning?

The physical positioning of big components or IO is usually an important requirement that needs to be frozen early on, so that mechanical design on casework can proceed in parallel.

jhallenworld2 replies#
Why not use Verilog or SystemVerilog?

    module blinky
      (
      input v3v3,
      input gnd
      );

    wire led;

    wire led_r;

    rp2040 u1
      (
      .vcc (v3v3),
      .gnd (gnd),
      .gpioa15 (led)
      );

    resistor #(.VALUE("220"), .TOLERANCE("5%"), .PART("ERJH2CF1R10X"), .SIZE("1206")) r1
      (
      .a (led),
      .b (led_r)
      );

    led #(.PART("WP7113SURDK14V")) d1
      (
      .anode (v3v3),
      .cathode (led_r)
      );

   endmodule
Use Verilog parameters for all of the part information you might want, like links to digikey part number.. or bury them into modules with different names.

FWIW: Cadance "conceptHDL" is a schematic entry program which generates a Verilog netlist like this as its output (usually for board level simulation including ASICs and FPGAs). But if you're careful, Verilog could used directly as the input- the board-level schematic is pretty simple compared with the chip source code.
I'm sure there is a tool somewhere to convert this into an EDIF netlist for Kicad or whatever. [Icarus can do it: https://steveicarus.github.io/iverilog/targets/tgt-fpga.html ]
Also: this is not limited to digital: there is a variant of Verilog called Verilog-AMS specifically designed for analog simulation.
https://en.wikipedia.org/wiki/Verilog-AMS
In Verilog-AMS, you can define a simulation models of your components:

    module resistor
      (
      inout electrical a,
      inout electrical b
      );

    parameter real R = 1.0;

    analog
        V(a,b) <+ R * I(a,b);

    endmodule

    module capacitor
      (
      inout electrical p,
      inout electrical n
      );

    parameter real c = 0;

    analog
      I(p,n) <+ c*ddt(V(p, n));

    endmodule
So not only do you get a component, but you also can simulate the whole thing before fabrication to catch mistakes.
napowderly#
We had a look at a few options before doing our own. A few thoughts; Building a DSL allows us to keep it really simple to start, we tried using SKIDL ( a very cool python project) and found it was pretty easy to get your self in a weird spot, the language would let users do things like create a component and not hold a reference to it.

Units and tolerances are core to our language, the physical world is 'fuzzy' and having a good way to deal with those we think is pretty important.
We are also trying to make it as readable and friendly as possible, our expectation is our users will likely have some experience with python and perhaps a little C back in school, so making it clear and approachable is front of mind.
Very open to critiques on our choices! We still very much in development.

demondemidi2 replies#
I think a lot of young hackers just don't have the breadth of experience to know what has come before them, or what is in common use. OP has reinvented synthesis, but poorly.
mawildoer#
Not even quite synthesis yet! We're well aware there's quite a lot out there that's fairly analogous - but nothing that's quite translated to the space, despite a few efforts as pointed out above.

There's a few parts we think that are behind that, but one is similar to python's/Guido's "code is read more than it's written", so we're attempting to address that!

fennecbutt1 reply#
And if you want to go there (which you did), older hackers have too much experience and are therefore set in their ways and are incapable of innovation.
demondemidi#
“Go there”? This isn’t a battle. Both can be true. But experience is a fact.
mlsu2 replies#
One thing that surprised me when moving from mechanical CAD to EDA programs is the lack of "relations." I have not used the more professional tools, just KiCad, but it surprised me that there are not more variables, relations, constraints, subassemblies, for things like buck converters and these types of things. KiCad has 'netclasses' which let you set trace widths, but it's all manual, same with the design rules checker. Each vendor seems to have their own design manual for these things, which is nice to have but so tedious -- I have to read a PDF to know what size decoupling cap goes with this IC? Why is that information not encoded in the footprint somehow?

I understand that auto-routing is not a solved problem by any means, but there should be more efficient tools to make it easier. I shudder to imagine laying out some big LED matrix without more advanced tooling.

napowderly#
For sure, its a big benefit of using language, it is comparatively very fast and easy to define custom relationships of component values, trace widths etc that would quickly become untenable in a point and click tool. We think the path forward is to be able to encode the governing equations that you would get in say a buck controllers data sheet directly into our source code. That way from a user perspective you can define your circuit simply by importing modules, defining them (for example input voltage, output voltage and current) we can then solve the component values and pick them from our component database for you. One of our early users wrote a plugin to do LED arrays in an afternoon. Our compiler is all open so its pretty easy to add on custom scripts for whatever you might be wanting to do.
calvinmorrison4 replies#
look at OpenSCAD, it's a scripting language to generate models. I used this a lot to generate subpieces and build off of that. easy as saying Bolt("M5", 1.5) or something
ukd11 reply#
Ya OpenSCAD is great for in/cross project re-usable components.

The only issues I've had is how it outputs circular things for cutting - it does a series of polygons (configurable number), rather than an arc/circular - places like send-cut-send won't accept it, claiming it causes issues with their machines.

xnzakg1 reply#
Old issue, but annoying nonetheless. Less of a problem when outputting STL files (for printing) which only support polylines and not arcs/circles. Funnily enough, 3D printers nowadays support arcs natively in G-code, so some slicers support detecting rounded polylines and converting them back into circles or arcs.

Found a script[0] that does this for DXFs in a github issue[1].
[0]: https://github.com/nophead/Mendel90/blob/master/dxf.py [1]: https://github.com/openscad/openscad/issues/4605

Continue this thread — 1 reply

napowderly#
I have used it, I think its great. I am excited to see whole products defined in code.
dekhn#
I found OpenSCAD's 3d model representation to be very challenging for anything complicated. I used FreeCAD, which is scriptable, but also uses a brep representation instead of CSG, which IME works a jillion times better.
nerpderp822 replies#
As a regular OpenSCAD user, I wouldn't bring it up as a good solution for anything. It exists, you can solve problems with it, but it isn't a good design. It should just be a library in a real language.
bsza1 reply#
> It should just be a library in a real language

The last thing I want to worry about is having malware in an M5 bolt.

Continue this thread — 1 reply

jmgao#
I've found CadQuery to be a pretty good replacement for my purposes, but I haven't done anything complicated with it yet, just designing 3D printed/laser cut electronics enclosures.
fecal_henge1 reply#
Hi, EE here, but started my career as unskilled labor in a test lab. This is in contrast to my colleagues who are often physicists.

I love the graphical nature of Schematic design. It helps me visualise problems that my colleagues would admittedly rather code. I take a lot of care in my schematic layout, and it can help me make a good guess as to wether my circuit is planar or not. - usefull when you dont want to incurr the parasitics on a via somewhere.
I would also remark that there is no reason why design reuse would necessitate a text based caprure. We already have reuse though subsheet heirachy, ctrl c/ctrl c and to some degree reference designs.
The only other thing I would add is that a lot of people come from a hobbyist background, which means small volumes. For commercial contract manufacturing, drawing out the same old schematic features for voltage regulators doesnt add up to much NRE as a fraction of the project cost.

Timot05#
Well designed schematics are great. Especially if you are sharing them with your team as documentation.

The point we would like to move towards is one where atopile enables you to generate high quality documentation about your design in a similar fashion to a datasheet but not entangling the documentation with the source design, which is what a schematic forces you to do. There are some features we'd want to build that could enable that like a visualizer for important parts of a schematic, a fan out view of the consumed interfaces around a chip, the results of a spice simulation...

Load more comments