﻿Introduction to Python:
    In 2011, a friend needed to determine the functioning of an undocumented camera chip.
    I used Python to make a GUI for the chip registers and interfaced it to C++
    routines for accessing the chip via ctypes. It's about the worst way possible
    to introduce yourself to Python.

Describe SKiDL and what type of problem you were trying to solve.
    Building an electronic system typically has four phases, similar to
    writing a program:
        - Planning: Define the goal, functionss and architecture.
        - Schematic: Select the circuit components and create the interconnections
          carrying the signals from one component's pin to another. The output from
          this phase is a netlist that lists each wire (or net) and which pins of
          which component are attached to it. This is like the intermediate code.
          This is where SKiDL plays.
        - Layout: The netlist is translated into a physical pattern of wire traces
          between chip packages on a circuit board. Many factors come in to play here:
          reducing the length of the wires between chips, packing the chips as tightly
          as possible, etc. This is similar to the detailed generation of machine 
          code from the intermediate code where you're concerned with reducing
          code size and eliminating accesses to slower off-chip memory.
        - The physical PCB is fabricated from the layout, components are mounted to 
          the board, and it's exercised with various electrical inputs and the
          outputs are monitored. This is probably the most similar phase to
          software development. And if you listen to the curse words that are used,
          then they're exactly the same.
        - Followed by assignment of blame, persecution of the innocent, etc.

    The schematics used to be drawn on drafting tables and the netlists were
    manually extracted and translated into PCBs using rubylith or black tape and
    exacto knives. But these have been supplanted by electronic design automation
    (EDA) software since the late 70's. And both schematic and layout software tools
    largely replicate the manual processes they replaced. And both types of tools
    are graphical in nature.

    But the graphical metaphor for schematics doesn't work any more, and probably
    hasn't worked since the 90's. Circuits used to be made from simple components:
    resistors, capacitors, transistors, small logic chips. All of these had
    easily recognized symbols with a few pins and a well-defined function and signal flow.
    As a result, the schematic could be understood by looking at the total signal
    flow from right-to-left and the simple functions that got applied along the way.
    To prove the value of the schematic, flip it 180-degrees and try to understand it.
    It can be done, but it takes about 10x as long. It's similar to trying to understand
    a program after removing all the syntax coloring and white space.

    But circuits aren't made from simple components any more. Modern processors,
    ASICs and FPGAs have over a thousand pins. And the signals can go into the pins,
    come out out of them, be analog or digital all at different times depending
    upon how the internals of the chip are programmed. Most components in schematics
    now appear as rectangular blobs with pins and there's no general signal flow.
    Rotate a modern schematic and it makes as much sense as before.

    People still try to use graphical schematic editors to design circuits with
    these big chips using multi-sheet, hierarchical schematics, but it requires
    endless fiddling with moving blocks around and adjusting wires. Combined with
    the fact that EDA software is the hell that bad GUIs are condemned to and it
    leads to bunches of errors caused by the tool itself.

    So maybe schematics don't work any more. And one day on kicad.info, somebody
    asked for a way to edit netlists directly without needing schematics. Now,
    that's like writing machine code directly, which is possible but not recommended.
    But having some type of textual way to enter a circuit that also managed
    some of the details seemed like a good idea to me.

    I figured somebody already had something like this. Sure enough, I found
    PHDL: a language developed at BYU around 2011. It's written in Java and has
    a lot of features for describing circuits compactly, but it's also rather
    restricted to that problem domain with its own special syntax (like so many EDA tools).
    It also seems to have been pretty quiet since 2012.

    So I liked the features of PHDL, but not its syntax or its Java implementation.
    But I also knew about MyHDL which is a digital hardware description language
    built on top of Python. It's an easily-installed package that hijacks the
    Python machinery so you can describe and simulate digital hardware and then
    output VHDL or Verilog code that can be compiled into an FPGA.
    
    So I took the good ideas from PHDL and reimplemented them as a Python package
    like MyHDL. That's SKiDL. It looks out for the circuitry details while letting
    you express the design using all the good features of Python. And as Python
    and its ecosystem improve, it also makes SKiDL better at designing circuits.
    And that's the main advantage of SKiDL: it taps into a much larger movement
    and rides along with it to get automatic improvements in a small, specialized
    domain.

Most of my experience designing circuits has been done using a graphical tool. 
If you are using Python for the entire layout does it become difficult to 
understand the overall circuit without the visual representation?
    For a large circuit, it becomes difficult to understand it no matter how its 
    described. But a large schematic usually involves multiple sheets and hierarchy.
    To get a feeling for how it fits together, you're moving up and down the
    hierarchy and across multiple sheets. With SKiDL, its a hierarchical set of
    program blocks and functions. We already have decades of experience understanding
    that kind of thing and how to structure it to make it easier to grasp.
    And SKiDL objects like netlists are active objects that you can query in
    interactive mode. So you can ask a pin on a chip what net it's connected to
    and what other pins are connected to that net. That's the main thing you check
    on a schematic: what's connected to what? And that has to be done manually,
    tracing across the pages to see where the net goes (even with intelligent highlighting).
    With SKiDL, you just ask the net.

Is there a way to generate a circuit diagram from the SKIDL code for a visual reference?
    There's probably existing tools for generating graphical depictions of a program.
    Or you might be able do something with graphviz. But my intuition formed from looking
    at the gate-level realizations of VHDL code tells me you'll just get a bunch of
    glop that offers no insight without a lot of effort. But even if you could get
    a good representation of the circuit (as good as a human could do it), then that's
    still not a good representation that's easy to understand for a large circuit
    for all the reasons I've discussed.

    The question to ask is: what information am I trying to get from a visual reference?

It seems that there is a substantial amount of electrical knowledge required 
to be able to design and build schematics in code. For someone who is more of a 
hobbyist or is just starting to work with circuit design are there any facilities 
of SKIDL to assist with that understanding?
    Actually, all you have to know in SKiDL is how to connect pins together, just
    like in a schematic editor. And you don't have to learn all the arcane techniques
    the schematic editor has for placing and moving components and wires.
    So it's probably easier to design a circuit in SKiDL than a schematic editor.

    However, there's a companion program called netlist_to_skidl that converts
    a netlist to a SKiDL program. So you can design schematics using the graphical
    editor and then convert them into SKiDL to see how they look. And those
    pieces of SKiDL code can also be re-used as sub-blocks in larger designs.

What does the testing and validation process of a generated circuit look like?
    
What does the internal architecture of SKIDL look like and what are some of the
biggest challenges that you have faced while building it?

For the generated netlist does SKIDL take into account voltage losses due to 
the lengths of the traces in the final PCB and does it have any facilities to 
optimize the overall layout for space and efficiency?
    No, those are usually issues addressed during the layout phase.
    A designer could insert some information about those issues into the SKiDL
    code that are passed along to the layout program, but it's up to the layout
    program to handle those issues.

Sometimes a circuit board is meant to be accessible for maintenance or even 
display purposes. Is it possible to specify the arrangement of components to 
make them more aesthetically pleasing or to space them so that they are easier 
to access physical interface ports (e.g. GPIO pins or I2C buses)?
    No, same answer: that's a job that's handled during the PCB layout phase.

What are some of the most interesting or surprising uses of SKIDL that you have seen?
    SKiDL has only been around since September. I'm the only one using it that
    I know of. I'm still adding new features and shaking it down.
