The most interesting aspect of Electric is its powerful facility for programming designs. Besides providing built-in interpreters for LISP, TCL, and Mathematica, Electric has a few constraint systems available in the database. One constraint system is based on linear inequalities of wire lengths, as Chapter 8 described in detail. The primary constraint system, unique to Electric, works both within the cell and incrementally, propagating changes upward in the hierarchy. This hierarchical-layout constraint system enables designers to work top-down in a graphical editor.
Although the hierarchical-layout constraint system was initially an integral part of the database, the need for multiple constraint solvers fostered a more modular scheme. Each constraint solver provides interface routines for the possible database changes: creation, deletion, and modification of nodes, ports, arcs, and cells. Additional interface routines must exist for initialization and special control directives, and to inform the constraint system that a batch of changes has been described and can be solved. With such a scheme, any constraint system can be incorporated in the database.
Hierarchical-layout constraints are always placed on wires in Electric. They set properties so that a change to a component on either end of the wire affects the component on the other end. In the absence of constraints, wires rotate and stretch as necessary to connect their two components whenever either moves. Thus the essential premise of Electric is that wires always remain properly connected through all changes to the database.
The first hierarchical-layout constraint is rigidity, which, when applied to a wire, causes the length to remain constant and fixes the orientation with respect to both components. If either component connected to a rigid wire moves, then both the wire and the other component move similarly. If a component rotates, then the wire rotates and the component on the other end spins about the end of the wire. It can be seen that a rigid wire essentially creates a single object out of the two components that it connects (see Fig. 11.5). To allow for unusual constraint situations, rigidity may be set or unset temporarily, which means that the property overrides the current constraint for the next change only.
FIGURE 11.5 The effect of rigid wires: (a) Original (b) Contact component rotated, unconstrained wire (c) Contact component rotated, rigid wire (d) Contact component moved right, rigid wire.
When a wire is not rigid, there are two other constraints that may apply: fixed-angle and slidable. The fixed-angle constraint forces a wire to remain at its current angle. If one component on a horizontal fixed-angle wire moves up, then the other will also. If that component moves to the left, however, the wire will simply stretch without affecting the other component. The rotation or mirroring of a component does not affect a fixed-angle wire unless the wire is attached off-center, in which case a slight translation occurs (see Fig. 11.6).
FIGURE 11.6 The effect of fixed-angle wires: (a) Original (b) Contact component rotated, fixed-angle wire (c) Contact component moved right, fixed-angle wire.
The other constraint that can be applied to nonrigid wires is the slidable factor, which affects components with nonpoint connection sites. When a connection has a positive area, the wire connecting to it can slide within that area. This means that small changes to the component may not affect the wire at all because the connection area still properly contains the end of the wire. The slidable constraint allows the wire to make these independent movements, whereas without this constraint both component and wire must move together. In Fig. 11.7, the 6 × 4 contact component has a port area that begins 1 unit in from its edge. The wire is thus connected in the middle of a 2-wide port and can slide by 1 in either direction. The figure also illustrates an AND gate the port of which is the entire left side (a 0 × 5 port). The wires remain connected at the same place because they are not slidable.
FIGURE 11.7 The effect of slidable wires: (a) Original (contact has connection area that is inset 1 from the top and bottom) (b) Contact component moved up by 1, slidable wire. (c) Original (d) AND moved up, fixed-angle nonslidable wires.
Most design environments allow slidability so that the wires can adjust to detailed changes of connection configuration. An example of the need to turn off this constraint is in schematic gates such as AND and OR, in which the inputs are all attached to one large connection on the side. If slidability is allowed, then small motions of the gate component will bunch the inputs together.
The most powerful of the hierarchical-layout constraints is one that relates hierarchical levels of a layout. All exported connection sites in a cell definition are bound to their actual connections on instances of the cell, higher up in the hierarchy. This means that, if a component in a cell has an exported connection and the component moves, then that connection moves and any wires attached on instances of the cell also move (see Fig. 11.8). This is a natural extension of the Electric philosophy that everything must remain connected after a change.
FIGURE 11.8 Propagation of hierarchical-layout constraints: (a) Original (b) Contact component in gate cell rotated, all three wires fixed-angle.
The order of constraint execution is critical to ensuring a proper solution and correct layout. Electric solves all constraints inside a cell before moving up the hierarchy to other cells. When the hierarchy is more complex than a simple tree organization, care must be taken to ensure proper traversal so that lower-level cells are solved before the higher-level ones. For example, if cell C in Fig. 11.9 is changed, then cell B must be reevaluated before cell A, even though both contain instances of cell C.
FIGURE 11.9 Nontree hierarchy must be traversed carefully.
Within a cell, the constraints are solved in two passes: first the rigid wires and then the nonrigid wires. This gives rigidity the priority it needs to work correctly. A time-stamp mechanism prevents constraint loops from running amok, by detecting reapplication of constraints and forcing a quiescing action. If a reapplied constraint is consistent with the layout, then no change is necessary and the loop terminates. Otherwise, there is an overconstrained situation and Electric jogs the wire, replacing it with three that properly connect. This scheme for propagation of constraints proceeds quickly and effectively in the domain of VLSI design.
When more powerful programmability is needed, the user can write a piece of LISP, TCL, or Mathematica to generate any layout. There was even a Prolog interpreter many years ago, but it fell into disuse. These language systems do not function incrementally, reacting to changes as they occur, but rather act like a standard imperative language that manipulates the database when executed. Interpretive code can create circuitry by invoking the Electric database to define new cells and place objects in cells. It is also possible for interpretive code to invoke the constraint system by setting wire properties and changing component locations. These capabilities are identical to those available in C programs linked with Electric, except that these languages run interpretively and thus provides a better development environment.