Skip to main content
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

A ComponentDefinition is a reusable, immutable description of a component. There are two kinds: Both kinds have the same shape:
Definitions are frozen and hold no simulation state, so you can share one definition across any number of circuits and simulations.

Instances

When a circuit calls add(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 id unique within its component, such as "inputs.a" or "outputs.out"
  • a name and a direction ("input" or "output")
  • an owner, which is either an instance or the circuit being defined
  • a role that 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
Ports are structural references only. They never hold values.

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).
A part’s inputs (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 at root:
These ids are identical across runs, and they are the keys used by describe(), elaborate(), inspect() and trace().