Select Page

PL Perspectives

Perspectives on computing and technology from and for those with an interest in programming languages.

An analog computer is any computing platform which leverages the physics of the underlying substrate to implement computation. Under this computing paradigm, the physical properties of the computational substrate correspond to variables in the computation. To execute a program on an analog computer, the hardware must be configured such that the device physics matches (is analogous to) the behavior of the program.

Modern analog computers are attractive computational targets which have the potential to deliver significant performance and energy improvements over conventional digital hardware. Many modern analog computers are reconfigurable and may be digitally reprogrammed to implement a variety of computations.  In a series of blog posts, we will discuss some of the challenges with using analog computers and show how programming languages and compilers techniques can help. This first post will provide an overview of how analog computation works and highlight the challenges that programming language technology can help to address. To make things concrete, we will describe how an important subclass of computations (dynamical systems) can be implemented on a specific analog device (the HCDCv2).

Example Computation: A Spring-Mass System

A dynamical system is a continuously evolving system composed of one or more state variables whose trajectories evolve over time. Dynamical systems are broadly used, mathematical constructs which appear in many disciplines including biology, chemistry, physics, robotics, and electrical engineering. These systems can be used to process sensor information, control motors and other actuators, and study physical phenomena. We will be focusing on simulating dynamical systems which are made up of ordinary differential equations in this series of posts. 

 

Consider the spring-mass system pictured above. This system is made up of a 2~kg mass attached to a spring with a 0.5~ kg/s^2 force constant. The mass is initially 10 meters away from its resting position and is stationary (the velocity is 0~m/s ). 

We can model the dynamics of the above system with a dynamical system (lower left corner) composed of two state variables which capture the velocity (v) and the position (p) of the mass over time. The initial values of v and p capture the initial state of the system. 

We are interested in running an experiment where we release the mass and observe its position and velocity for 20 seconds. We can simulate this experiment by executing this dynamical system for 20 units of simulation time. The plots on the right hand side of the image show the simulated trajectories of the mass’s position and velocity over time.

Differential Equation-Solving Analog Devices

A differential equation-solving analog device is a type of reconfigurable analog device which uses the analog behavior of transistors to perform dynamical system simulation. These devices are attractive computational targets because they consume very little energy and have predictable performance characteristics — in fact, we can calculate the time required to perform the dynamical system simulation at compile-time. Such devices are great at computing on analog signals in real-time with very little energy. 

Internally, these devices contain collections of digitally configurable analog blocks which may be routed together with digitally programmable interconnects to form a variety of analog circuits. To run a dynamical system on such a device, it must be programmed to implement an analog circuit whose physics matches the dynamics of the target dynamical system. The analog currents and voltages within this circuit implement continuously evolving state variables from the dynamical system. The computation is then run by powering on the device and observing the evolution of the currents and voltages of interest over time. 

In this article, we will be targeting HCDCv2; a differential equation-solving analog device developed by researchers in Columbia and manufactured by Sendyne Corporation.

Solving the Mass-Spring System with an Analog Device

The diagram below presents a candidate configuration for the HCDCv2 which implements the mass-spring dynamical system introduced above. 

The configuration uses several kinds of analog blocks. The MUL and INT blocks perform multiplication and integration. The COPY, TIN, TOUT, and OBS blocks are special-purpose blocks which are not used for computation. The COPY block produces multiple copies of an analog current. This is necessary because analog currents cannot safely be routed to more than one port. The TIN and TOUT blocks route signals between blocks which cannot be directly connected together through a digitally settable connection. The OBS block makes a signal externally accessible. In the above circuit, the OBS block forwards the signal implementing the position of the oscillating mass to the oscilloscope. 

Each block has a digitally settable operating mode which controls the function implemented by the block (green box) and a set of digitally settable fields (yellow callouts).  For example, the INT block integrates x when in mm mode but integrates 0.1 \cdot x when in hm mode. The MUL block implements c \cdot x, where c is a digitally settable field, when in mm mode. We summarize all the functions implemented by the blocks below. Refer to  this table for a complete list of block modes and behaviors.

The COPY, TIN, TOUT, and OBS blocks are special-use blocks which do not only perform computation. The COPY block produces multiple copies of an analog current. This is necessary because analog currents cannot safely be routed to more than one port. The TIN and TOUT blocks route signals between blocks which cannot be directly connected together through a digitally settable connection. The OBS block makes a signal externally accessible. In the above circuit, the OBS block forwards the signal implementing the position of the oscillating mass to the oscilloscope.  

The right hand side of the figure shows the lab setup and the analog signal collected from the oscilloscope. If we compare this analog signal to the expected position of the mass over time (bottom right), we find that it closely tracks the expected trajectory. This execution consumes 0.32~\mu J of energy.

Execution Time: All integration in the circuit is performed with respect to hardware time (t_{hw}). In the HCDCv2, one unit of hardware time corresponds to 7.93~\mu s of wall-clock time. This mapping between hardware time and wall-clock time enables us to compute exactly how much time any computation will take. For example, the above circuit executes 20 simulation time units in 20 \cdot 7.93=158~\mu s of wall clock time.

Circuit Validation: In this circuit, the trajectories of the analog currents moving through the wires labeled P and V match the trajectories of the position and velocity of the mass in the mass-spring system.  We can see this by comparing the dynamics of the the analog currents at P and V with the dynamics of the spring-mass system:

On the left, we present the symbolic expressions governing the behavior of the analog currents P and V over time. In these expressions, digitally settable field values are in orange and the labeled signals we are analyzing are written in blue. On the right, we present the dynamics of the position and velocity from the mass-spring system. We can see that while these differential equations don’t syntactically match up, they are semantically equivalent.

Programming Challenges

Electrical differential-equation solving analog devices like the HCDC are challenging to directly program for several reasons:

  • Highly parametric, specialized blocks: To conserve space, the offered electrical analog blocks are highly parametric and often non-trivial. Computational blocks include blocks which implement sets of differential equations and relations, blocks which implement variants of multiplication, and blocks which both scale and integrate a signal. Some computations are not performed with dedicated blocks (e.g. addition) while some blocks don’t perform computation (e.g. copiers).
  • Restrictive routing environment: Because wires carrying analog signals affect one another when placed close together, there are a limited number of programmable interconnects on the device. Analog blocks which are far apart on such devices are much harder to connect together than co-located blocks.
  • Physical limitations and low-level physical behaviors: The analog blocks in these devices impose frequency, current, and voltage range limitations on the incoming signals and have unique noise, error, and gain characteristics which must be taken into consideration when programming the device. All of these characteristics may change depending on how the analog block in question is programmed.

Due to these issues, even implementing our simple spring-mass system was non-trivial. 

PL Technology to the Rescue!

Stay tuned … in the next blog post we’ll see how programming languages and compilation technology can bridge this gap between the original differential equations and the analog circuits that must implement them faithfully on a differential equation-solving analog device.

Bio:  Sara Achour is a PhD candidate at the Computer Science and Artificial Intelligence Laboratory at Massachusetts Institute of Technology (CSAIL MIT). She will be joining Stanford’s Computer Science department as an Assistant Professor starting Summer 2021.

Appendix: Description of HCDCv2 Blocks

Multiplier (MUL) Block

MUL

port z port z

mm

c \cdot x mh 10 \cdot c \cdot x
hm 0.1 \cdot c \cdot x hh

c \cdot x

mmm

0.5 \cdot x \cdot y hmm

0.05 \cdot x \cdot y

mhm 0.05 \cdot x \cdot y mmh

5 \cdot x \cdot y

Integrator (INT) Block
INT ∫z z(0)
mm \int x 2 \cdot z0
hm \int 0.1 \cdot x 2 \cdot z0
mh \int 10 \cdot x 20 \cdot z0
hh \int x 20 \cdot z0
unCurrent Copier (FAN) Block
FAN port z port w
pp x x
pn x -x
np -x x
nn -x -x
Other Blocks (TIN, TOUT, OBS)
Other Blocks port z
TIN x
TOUT x
OBS 0.6*k

Disclaimer: These posts are written by individual contributors to share their thoughts on the SIGPLAN blog for the benefit of the community. Any views or opinions represented in this blog are personal, belong solely to the blog author and do not represent those of ACM SIGPLAN or its parent organization, ACM.