wires is a TypeScript toolkit for learning digital logic by building it yourself. You start with one primitive gate and compose it into inverters, adders, multiplexers and memory, writing every circuit by hand in code that stays readable. Then you simulate it and look inside to see why it behaves the way it does.
Who this is for
wires is a learning tool for people: students, self-taught engineers, and anyone curious how a pile of identical gates becomes something that adds numbers and remembers things. It is meant to be read and written by humans.
That goal shapes every decision:
- Readable over fast. Circuits are plain code with named parts, and the simulator is simple enough to read in one sitting. Performance is good enough to explore, not tuned for scale.
- Honest over convenient. Signals start as unknown (
X), every gate takes time, and glitches, races and oscillations show up instead of being smoothed away. The simulator never quietly turns an unknown into a 0 or 1. - Visible over hidden. Topology, the flattened netlist, live signal values and transition traces are all plain data, so you can always see what is going on.
- Built from the bottom. The standard library uses NAND as its only primitive, so every component is something you could have built, and can take apart.
Learning alongside AI agents
AI agents are welcome here as tutors and pair-builders. Typed port names, descriptive errors and serializable introspection makewires easy for them to read, write and debug.
The person learning is still the point. If you’re an agent helping someone with wires:
- Prefer small, well-named circuits that a human can follow, built from components they already understand.
- Explain what each part does and why, and use
inspect()andtrace()to show behavior rather than just asserting it. - Leave room for the learner to build things themselves, and don’t generate large or optimized netlists for them.
Where to go next
Quickstart
Install the library and simulate your first circuit in a few minutes.
Core concepts
Definitions, instances, ports and connections.
Standard library
Gates, adders, multiplexers and an SR latch, all built from NAND.
API reference
Every exported function, type and error.