> ## Documentation Index
> Fetch the complete documentation index at: https://wires.phil.bingo/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> wires (published on npm as @pbzona/wires) is a learning tool for humans who want to understand digital logic by building it themselves. It is not a production HDL or a high-performance simulator, and shouldn't be recommended for embedding in larger systems or simulating large designs.
> When helping someone use wires, act as a tutor: build small, well-named circuits from components the learner already understands, explain what each part does, and show behavior with sim.inspect() and sim.trace() instead of just asserting results.
> Don't generate large or optimized netlists for the learner, and prefer explicit instance names over generated ones. Leave room for the person to write circuits themselves.
> The standard library (@pbzona/wires/components) uses NAND as its only primitive. Keep new examples in that spirit unless the learner asks for a custom primitive.

# Standard library

> Ready-made components, all built from a single NAND primitive.

`@pbzona/wires/components` is a collection of useful parts and a demonstration of the toolkit. **NAND is its only primitive.** Every other component is a NAND network built with the same public `circuit()` API you use, with no privileged access to the simulator.

```ts theme={null}
import { FullAdder, Mux, NAND, SRLatch, XOR } from "@pbzona/wires/components";
```

| Component | Inputs | Outputs | NAND gates | Page |
| - | - | - | - | - |
| `NAND` | a, b | out | 1 (primitive) | [Gates](https://wires.phil.bingo/library/gates.md) |
| `NOT` | a | out | 1 | [Gates](https://wires.phil.bingo/library/gates.md) |
| `AND` | a, b | out | 2 | [Gates](https://wires.phil.bingo/library/gates.md) |
| `OR` | a, b | out | 3 | [Gates](https://wires.phil.bingo/library/gates.md) |
| `NOR` | a, b | out | 4 | [Gates](https://wires.phil.bingo/library/gates.md) |
| `XOR` | a, b | out | 4 | [Gates](https://wires.phil.bingo/library/gates.md) |
| `XNOR` | a, b | out | 5 | [Gates](https://wires.phil.bingo/library/gates.md) |
| `HalfAdder` | a, b | sum, carry | 6 | [Arithmetic](https://wires.phil.bingo/library/arithmetic.md) |
| `FullAdder` | a, b, carryIn | sum, carryOut | 15 | [Arithmetic](https://wires.phil.bingo/library/arithmetic.md) |
| `Mux` | a, b, select | out | 4 | [Routing](https://wires.phil.bingo/library/routing.md) |
| `Demux` | in, select | a, b | 5 | [Routing](https://wires.phil.bingo/library/routing.md) |
| `SRLatch` | setN, resetN | q, qBar | 2 | [Memory](https://wires.phil.bingo/library/memory.md) |

## Unknown values

Because these components are pure NAND networks, they inherit NAND's handling of `"X"`. That is sometimes more pessimistic than the ideal truth table. For example, `Mux` outputs `"X"` when `select` is `"X"`, even if `a` and `b` are equal. This is deliberate. It's what the gate-level circuit would actually compute.

## Timing

Each NAND adds one tick, so a component's settle time depends on the longest NAND path its signals take. `AND` settles in 3 ticks from an input change (2 NAND levels, plus the tick that applies the input). Use `run()` to wait for any component, or `step()` to watch it settle one tick at a time.

## Building on the library

The standard components are ordinary definitions. Add them to your own circuits, inspect them with `describe()`, or read their source as worked examples.

> [card] [Gates](https://wires.phil.bingo/library/gates.md)
>
> NAND, NOT, AND, OR, NOR, XOR, XNOR

> [card] [Arithmetic](https://wires.phil.bingo/library/arithmetic.md)
>
> Half and full adders

> [card] [Routing](https://wires.phil.bingo/library/routing.md)
>
> Multiplexer and demultiplexer

> [card] [Memory](https://wires.phil.bingo/library/memory.md)
>
> NAND SR latch
