Next: Example Up: Compiling for Computational Origami Previous: The Architecture Specification

The Library Specification

Library routines are the only way that functions can actually be performed by the compiled code. There are no intrinsic functions in the language. Library routines must be written for every basic operation that needs to be performed. A library file consists of a series of routines. Each routine consists of a name, a set of input and output specifications, a size, and a rectangular array of flavors that define the implementation of the routine for a given architecture.

A sample library routine for a two-input AND element might be:


AND
INPUTS 0 1
OUTPUTS 0
SIZE 1 1
AND

In this example, the ``AND'' routine has two inputs that arrive at array coordinates 1 and 2. It has one output that is present on array coordinate 1, and is 1x1 nodes large. It consists of a single AND flavor. A slightly more sophisticated example is the ``ANDOR'' routine, which takes four one-bit inputs, and computes the expression result=OR(AND(in<0>, in<1>), AND(in<2>, in<3>)). The library definition for this routine is:


ANDOR
INPUTS 1 2 3 4
OUTPUTS 2
SIZE 2 2
AND AND
NOOP OR

The array representation for this routine is shown in Figure A.1. In this figure the array coordinates are more obvious. The inputs are positioned at coordinates 1, 2, 3, and 4, and the output is available at coordinate 2.

The coordinate locations in the INPUTS and OUTPUTS part of the specification define the locations for the function arguments and results in order. Thus if you rearrange the coordinates the function will look the same to the programmer, but will be placed and routed differently. This can be put to good use. For example, since AND is commutative, it is valid to swap the input signals. This could be more efficient for routing depending on how the source modules are arranged. To take advantage of this, more than one library routine with the same name can be specified in a file. The first one in the file is used by default, but the others could be used during optimization. The different modules must be the same size in order for this to work. For example, these two definitions for AND could be specified:


AND
INPUTS 1 2
OUTPUTS 1
SIZE 1 1
AND

AND
INPUTS 2 1
OUTPUTS 1
SIZE 1 1
AND



Next: Example Up: Compiling for Computational Origami Previous: The Architecture Specification


Robert French