Is there a better way not by writing netlist files. something like:

Define Battery1 As a Battery
Define Resistor1 As a Resistor

Connect Battery1 First Terminal to Resistor1 Second Terminal
Connect Resistor1 First Terminal to Battery1 Second Terminal


I find the answers pretty helpful. It will be great if there is a way to simulate the circuit produced by the code.

  • 5
    \$\begingroup\$ FWIW, your example code looks like a netlist to me. It just defines a couple of parts (with presumably a library telling the tool how many terminals each one has) and then says which terminals are connected to each other. If you used it a bit you might even find it's easier to be able to name nodes and connect terminals to nodes rather than to other terminals. \$\endgroup\$
    – The Photon
    Commented Oct 29, 2017 at 15:58
  • 4
    \$\begingroup\$ There is a wide gulf between "is it possible" and "is it useful", for many subjects. \$\endgroup\$ Commented Oct 29, 2017 at 18:54
  • 3
    \$\begingroup\$ I think you might be looking at HDL. While they mostly describe digital circuits they are not technically limited to such (I think Verilog have some support for them). As noted by @ThePhoton what you have shown looks like a netlist, which is what they usually compile to. \$\endgroup\$ Commented Oct 29, 2017 at 23:20
  • 2
    \$\begingroup\$ The reason it takes time to think about the best way to draw it is that you have to have a good understanding of the circuit, and how to make its function clear to people looking at the drawing. None of that is stuff that computers are good at, so asking a computer to do it for you is asking for trouble. \$\endgroup\$
    – The Photon
    Commented Oct 30, 2017 at 1:04
  • 1
    \$\begingroup\$ If you're thinking you'll just use this description as input to the pcb layout tool, so it doesn't have to be used by a human reader, then what will you use as documentation for someone (you) troubleshooting the circuit after it's built, or modifying the design later. If you use schematic entry, you are essentially writing the documentation and using that as input to the layout tool. Now you know your layout will actually match the documentation. \$\endgroup\$
    – The Photon
    Commented Oct 30, 2017 at 1:08

8 Answers 8


If you are familiar with \$\LaTeX\$, you can use circuitikz to draw nice circuits by writing code.

enter image description here

More Examples

  • 4
    \$\begingroup\$ To add to this - as others have said drawing a good schematic requires some human intuition. However If you are drawing lots of similar circuits then using laTeX and circuitikz will allow you to construct a template layout and customise it with specifics.It is an approach I use in producing course materials. \$\endgroup\$
    – John
    Commented Oct 30, 2017 at 7:40
  • 2
    \$\begingroup\$ The missing space between the number and the unit looks terrible. \$\endgroup\$
    – user64795
    Commented Oct 30, 2017 at 18:37
  • \$\begingroup\$ @Loong You can always put space between numbers and units if you want. \ or \,can add space in latex math environment \$\endgroup\$
    – nidhin
    Commented Oct 30, 2017 at 18:39
  • 1
    \$\begingroup\$ @Loong That's apparently a localization issue. As an American, it always seems bizarre to have random extra space between numbers and units. \$\endgroup\$ Commented Oct 31, 2017 at 7:02
  • 1
    \$\begingroup\$ @chrylis That's not a localisation issue, it's ISO 80000 specified and should be exclusively used. \$\endgroup\$
    – awjlogan
    Commented Oct 31, 2017 at 15:25

Check out SKiDL (https://github.com/xesscorp/skidl), this is along the lines you're thinking.

Edit (as req'd): SKiDL allows procedural description of all circuits (rather than just digital), instead of graphically entering your schematic. The netlist output can then be imported into layout software. It will also perform ERC checks, and is extensible. This means, for e.g., that you could write a filter once and then reuse it in different projects rather than drawing each time. Written in Python, with all the support that comes along with that.

  • \$\begingroup\$ Added a little more info. \$\endgroup\$
    – awjlogan
    Commented Oct 30, 2017 at 15:39
  • \$\begingroup\$ Other Python schematic drawing options are SchemDraw and lcapy. \$\endgroup\$
    – johnthagen
    Commented Oct 20, 2019 at 12:13

Many programs can draw a schematic. None that I know of can draw a good schematic: One that emphasizes the most important information, and arranges the circuit in a clear and easy to understand way.

If you're just looking for a hardware description language (no graphical schematic output), VHDL and Verilog are widely used to define (digital) circuits to be implemented in ICs, and can also be used for board-level design.

  • 1
    \$\begingroup\$ Verilog-A can be used to describe and model/simulate analog circuits, as well, though I'm not aware of any non-commercial simulators. \$\endgroup\$
    – Shamtam
    Commented Oct 30, 2017 at 13:49
  • \$\begingroup\$ I've designed some boards where it was easier to describe interconnections programmatically than with a schematic; I used a program to generate a netlist and then loaded it into PCB software. If a schematic editor could import a netlist and show a ratsnest for connections that hadn't yet had "real" wires or explicit net labels drawn, that could be helpful in such cases, at least for the parts of the schematic where real wires made more sense than "air wires". \$\endgroup\$
    – supercat
    Commented Oct 30, 2017 at 16:35
  • \$\begingroup\$ @Shamtam, I've used Veriolog A, but only as a simulation language. Are there systems that can synthesize a circuit from a Verilog A description? \$\endgroup\$
    – The Photon
    Commented Oct 30, 2017 at 16:36
  • \$\begingroup\$ @ThePhoton Not that I'm aware. I suppose my usage of the term "describe" could be misleading in that sense. \$\endgroup\$
    – Shamtam
    Commented Oct 30, 2017 at 17:22
  • \$\begingroup\$ @Shamtam, I wouldn't worry about the word. It is a hardware description language after all. It just describes the function rather than the implementation. \$\endgroup\$
    – The Photon
    Commented Oct 30, 2017 at 17:23

Your example looks a lot like modelica, an object oriented language for simulation based on creating blocks and connecting ports between the blocks.

An example using the electrical components library (from maplesoft.com),

encapsulated model ChuaCircuit "Chua's circuit, ns, V, A"
  import Modelica.Electrical.Analog.Basic;
  import Modelica.Electrical.Analog.Examples.Utilities;
  import Modelica.Icons;
  extends Icons.Example;

  Basic.Inductor L(L=18);
  Basic.Resistor Ro(R=12.5e-3);
  Basic.Conductor G(G=0.565);
  Basic.Capacitor C1(C=10, v(start=4));
  Basic.Capacitor C2(C=100);
  Utilities.NonlinearResistor Nr(
    Ga(min=-1) = -0.757576,
    Gb(min=-1) = -0.409091,
  Basic.Ground Gnd;
  connect(L.p, G.p);
  connect(G.n, Nr.p);
  connect(Nr.n, Gnd.p);
  connect(C1.p, G.n);
  connect(L.n, Ro.p);
  connect(G.p, C2.p);
  connect(C1.n, Gnd.p);
  connect(C2.n, Gnd.p);
  connect(Ro.n, Gnd.p);
end ChuaCircuit;

Although you can generate a schematic from the model, normally this is done in a GUI that annotates the components with position and orientation information.


Cirkuit is an editor to convert a simple text description to a circuit diagram. It provides a set of M4 macros for electric symbols.

It can be used together with circuitikz which was suggested by nidhin. circuitikz uses the more modern pgf/TikZ graphic system. The stackexchange community has very active users of cirkuitikz, but there are more solutions in TeX.

Source: https://ece.uwaterloo.ca/~aplevich/Circuit_macros/html/quick.png

Picture from https://ece.uwaterloo.ca/~aplevich/Circuit_macros/html/examples.html.


PSTricks is another library for TeX users. It can even do complicated mathematical calculation such as differential equations.


enter image description here


Yes.You can use HDLs to describe your circuit through code.You can use verilator,Xilinx or any other softwares or you can use the https://www.edaplayground.com/ (which works online without having to install anything on your PC).


See Schemdraw, which allows you to draw circuits using Python.

with schemdraw.Drawing():

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.