Unknown values
Every signal in a new simulation starts as"X". External inputs stay unknown until you assign them with set(). Primitives decide how unknowns propagate. NAND, for example, follows this table:
A
0 on either input forces the output high, so the unknown on the other input doesn’t matter. In every other unknown case the result is unknown too.
The simulator never resolves "X" to 0 or 1 on its own. A latch that has never been set reports "X" on both outputs, which is the honest answer.
Numbers, not booleans
Signals are the numbers0 and 1, not JavaScript booleans, and the library never relies on truthiness. Compare with ===:
true, 2 or "x" where a signal is expected fails to type-check, and throws a SimulationError at runtime.
Helpers
wires exports a few small helpers for working with signals:
High-impedance (
Z) signals and multi-driver buses are out of scope for now. Each destination has exactly one driver.