wires has one central idea: a primitive gate and a complex circuit expose the same interface. Anything you define can be used as a building block inside something else.
Component definitions
AComponentDefinition is a reusable, immutable description of a component. There are two kinds:
Both kinds have the same shape:
Instances
When a circuit callsadd(definition, name?, inputs?), it creates a ComponentInstance, which is one part made from that definition. Two parts made from the same definition are fully independent. They have different names, different hierarchical paths and separate signal values.
Ports
A port is a named terminal on a component. Each port has:- an
idunique within its component, such as"inputs.a"or"outputs.out" - a
nameand adirection("input"or"output") - an
owner, which is either an instance or the circuit being defined - a
rolethat says how the port can be used in the current circuit:"source"if it can drive a wire,"sink"if it can only be fed
Sources
Inside a circuit, signals flow from sources to the inputs of parts and to the circuit’s own outputs. A source is either:- one of the circuit’s own inputs (
inputs.a), or - an output of a part the circuit added (
g.outputs.out).
g.inputs.a) are never sources. You only ever say what feeds them. Using one as a source is a compile-time error, and the same check runs again at runtime.
Connections
A connection links one source to one input or output. Each wiring call in a builder reads destination ← source:- Fan-out is allowed. One source can feed any number of inputs.
- One driver per input. Giving an input or output a second source throws a
CircuitError. - Cycles are allowed. Feedback is how memory works. See Sequential logic.
Circuits and hierarchy
A circuit is a hierarchical graph of external ports, child instances and connections. Every element gets a stable hierarchical id rooted atroot:
describe(), elaborate(), inspect() and trace().