About FPAA

PyFPAA is a work bench to gain experience with hybrid computer programming. It can be used to create examples for the digital/hybrid extensions of the Analog Paradigm Model-1 analog computer (AP/M-1).

pyFPAA is a small Python3 code for compiling instructions for the AP/M-1 Hybrid Controller (HC), especially for the DPT (digital potentiometers), XBAR (crossbar switch) and the HC itself. The input is a quite extensive machine description together with a program (basically an analog circuit), both written in a minimalistic HDL in YAML representation. See the README file there as well as the doc directory for more details.

See also examples/fpaa-circuits for a number of example input for the pyFPAA compiler. There also exist basic test scripts within tests.

PyFPAA is a compiler for programmable analog computers (FPAAs). It was written by SvenK in Dec 2019 for quickly approaching a testing infrastructure for the XBAR module for the Analog Paradigm M-1 analog computer.

The script requires a (lengthy) machine description, which encodes the computational parts available and is quite similar to a machine library in VHDL. That file encodes especially the hard-wired vs. configurable parts of the machine. The actual program is then rather short and describes how the configurable computational parts are connected with each other. It also specifies constant coefficients which are set with digital potentiometers or other digital steering parameters.

The output of the code is the analog computer configuration, as required by hycon. This can be either

  • a single line of text, which are mostly hexadecimal encoded instructions together with command characters, all following the serial console protocol which the HybridController of the machine expects (http://analogparadigm.com/downloads/hc_handbook.pdf).

  • configuration tuples for hycon

  • or a direct API to hycon

In order to run this program, all you need is PyYAML to read the YAML files. If you want to draw circuit plots, you need matplotlib.

Command line interface

% python -m fpaa --help
usage: fpaa.py [-h] [-v] [-o OUTPUT.txt] [-p OUTPUT.pdf] (-A {XBAR-Only,AP-M1-Mini} | -a path/to/my/MACHINE.yml)
            CIRCUIT.yml

A circuit synthesizer for the HyConAVR.

positional arguments:
CIRCUIT.yml           The YAML file holding the circuit description

optional arguments:
-h, --help            show this help message and exit
-v, --verbose         increases log verbosity for each occurence.
-o OUTPUT.txt, --output OUTPUT.txt
                        Put output string into file (default is '-' and means stdout)
-p OUTPUT.pdf, --plot OUTPUT.pdf
                        Plot crossbar switch
-A {XBAR-Only,AP-M1-Mini}, --registered-arch {XBAR-Only,AP-M1-Mini}
                        Target machine architecture description: Any YAML file in directory
                        /home/sven/Analog/Forschungsauftrag/dda/fpaa is available as machine
-a path/to/my/MACHINE.yml, --arch path/to/my/MACHINE.yml
                        Target machine architecture description (any valid filename)

See fpaa.cli() for further details.

class fpaa.fpaa.Target(part, pin)
part

Alias for field number 0

pin

Alias for field number 1

fpaa.fpaa.load_from_yaml(circuit, arch)[source]

Expects arch and circuit to be strings.

fpaa.fpaa.synthesize(circuit, arch)[source]

Translate a circuit to a netlist for a given target architecture.

This routine is the heart of the FPAA compiler. It mainly

  • Allocates available hardware to the requested ones by the user circuits and allows for book keeping between the user named and architecture named computing components.

  • Ensures consistency of the resulting circuit (there are no dangling wires, no over-allocation, etc.)

There is a lot of info and debug output available if turned on via Python logging.

Expects arch and circuit to be nested data structures (dicts and lists holding strings and numbers), similar to their YAML representation. The documentation does not yet cover an in-depth description of these data structures, but there are tons of example YAML files which are straightforward to understand.

Returns wired_circuit, a list of computing components (which itself are again “PODs”, i.e. dicts with nested data structures).

fpaa.fpaa.normalize_potentiometer(value, resolution_bits=10)[source]

Map a real value [0..1] to Potentiometer value [0..1023]

fpaa.fpaa.compile_instructions(wired_circuit, arch)[source]

Compile a netlist (wired_circuit) to configuration instructions for setting up the analog computer hybrid controller.

This routine basically loops over the hardwired parts of the given architecture, i.e. built-in

  • potentiometers (DPT-24 and HC)

  • cross bar arrays (XBAR)

and configures them according to the given wired_circuit. This means that relevant allocated potentiometers will be set and the XBAR configuration bitmask will be computed from the hardware description provided by the circuit and the architecture.

Currently returns a list of instructions (tuples) which could be directly be written out to serial or passed to PyHyCon.

Note

This method will change in near time and talk directly to a PyHyCon instance.

fpaa.fpaa.plot_xbar(target_file, circuit_title, xbar_config=None, interactive_plotting=False)[source]

Draw an the allocation of a crossbar switch array (xbar) matrix.

xbar_config is a tuple with (cols,rows,boolean_matrix), and by default the last one from a global registry (last_seen_xbars) is taken, which is what you want.

fpaa.fpaa.cli()[source]

This module is callable via python -m fpaa or ./fpaa.py. It exposes the main functions on the command line which is especially helpful for debugging or interactively programming an analog computer from the command line.

Call --help for all possible command line options.