Layout API¶
Tier: Stable Core
Build a rung from its circuit, and lay it out as CLICK's syntax check draws it.
laddercodec.lay_out ¶
Return circuit as CLICK's syntax check draws it, one Rung for each CLICK rung.
The list has more than one rung when outputs meet only at the rail. CLICK splits such a
circuit into one rung for each output, in order. The comment goes on the first rung.
Or legs and outputs are drawn from the top down in the order that the circuit gives.
If the circuit has another output, lay_out drops a NOP that the rail feeds with
no contact, and lays out the rest. CLICK's syntax check does the same.
lay_out draws any circuit that CLICK can hold, including the shapes that only CLICK's
syntax check refuses, such as a wire-only Or leg or a contact that feeds only a NOP.
To find those shapes, call laddercodec.check() on the rungs that it returns.
Raises :class:~laddercodec.LayoutError for a circuit that CLICK can't hold. The
error's code says why:
layout-too-tall: a rung needs more than 32 rows;layout-too-wide: a rung needs more than the 31 condition columns, A to AE;layout-cannot-draw: two cells or two wires would fall on one place in the drawing;layout-nop-split: outputs meet only at the rail, and one of them is aNOPbehind a contact, or all of them areNOPboxes;output-above-box-inputsorshared-input-net, withclick_idC000A: an output comes before or after a box whose pin is used, and it hangs off the net of that box's main input, or off a net that the main input's circuit runs through. The code isoutput-above-box-inputsfor an output before the box, andshared-input-netfor one after it.
laddercodec.Circuit
dataclass
¶
One rung's circuit: a :class:Branch from the rail, and the rung's comment.
The comment is Markdown text, as in Rung.comment, or None.
laddercodec.Branch
dataclass
¶
Conditions in series from a net, then the outputs that hang off their end.
conditions are terms in series. With none, the outputs hang off the net that the
branch starts from, which is the rail for a :class:Circuit's branch. outputs
are boxes and branches, drawn from the top down in the order given. A branch needs at
least one output.
laddercodec.Box
dataclass
¶
An output box: an Instruction, or "NOP", with the circuit of each pin it uses.
pins maps the name of a pin, such as ".reset", to the term that feeds it. The
names are those of instruction.pin_names() whose entry in pin_labels() is not
None. You may pass a dict. The box stores the pins as (name, term) pairs, in
the instruction's pin order. A pin that the instruction uses and that pins leaves
out is drawn with nothing wired to it. laddercodec.check() reports such a pin.
laddercodec.Series
dataclass
¶
Terms in series, from left to right.
Series(()), an empty Series, is a wire. It is allowed only as a leg of a
:class:Parallel, where it is a wire-only Or leg. CLICK holds such a leg, and its
syntax check refuses it. laddercodec.check() reports it. The finding is C0002 when
the wire is beside one contact. It is C0001 when the wire is beside contacts in series.
laddercodec.Parallel
dataclass
¶
Two or more legs in parallel, drawn from the top down in the order given.
A leg is a term. Series(()) as a leg is a wire-only Or leg. At least one leg is
not a wire.
laddercodec.Term
module-attribute
¶
A term of a circuit: a Contact, a CompareContact, a Series or a Parallel.