Composing circuits #
A program can be continued by a second program whose inputs are read from wires of the first.
Reading them from the outputs of a circuit gives sequential composition, Circuit.comp, which
evaluates to the composite of the two functions. Reading them from the original inputs gives
parallel composition on shared inputs, Circuit.append, whose outputs are those of the first
circuit followed by those of the second. In both cases the gate counts add.
For programs p : Program σ n g₁ and q : Program σ k g₂, with
feed : Fin k → Wire n g₁, map a wire of q to its wire in the combined program.
Inputs follow feed, and gate indices are shifted past the gates of p.
This is the wire map used by Program.append below.
Equations
Instances For
Continue p by q, reading the inputs of q from the wires feed of p.
Equations
- p.append feed Cslib.Circuits.Program.empty = p
- p.append feed (q_2.gate line) = (p.append feed q_2).gate (line.mapWires (Cslib.Circuits.Program.appendedWire feed))
Instances For
A wire of q carries, in the continued program, the value it has when q runs on the
values of the wires feeding it.
Feeding a circuit computing f into one computing g computes g ∘ f.
Circuits computing f and g, run side by side, compute their outputs together.
Feeding a circuit computing f on S into one computing g on the image of S computes
g ∘ f on S.
Circuits computing f and g on S, run side by side, compute their outputs together.