Skip to content

Repository files navigation

LogicGates.org

Free digital logic tools and reference: truth tables, Karnaugh maps, boolean algebra, circuit diagrams, and a logic gate simulator called Logic Nodes.

Try it: logicgates.org, no account, no install. Straight to the tools, or to the simulator.

The Logic Nodes editor with a circuit of gates, delays, and displays

Features

Simulation:

  • AND, OR, NOT, XOR, NOR, and NAND gates
  • Interval (clock), delay, counter, button, toggle, and display nodes for time-dependent circuits
  • Tick-based propagation, so feedback circuits (SR latches and friends) behave deterministically

Algebra:

  • Truth table generation from any circuit
  • Boolean expression generation, with optional simplification (requires a Wolfram Alpha App ID)
  • The reverse direction too: construct a circuit from a boolean expression or a filled-in truth table

Editor:

  • Custom nodes: package any circuit into a reusable component
  • Pan, zoom to cursor, undo/redo, copy/paste, layers, and a minimap (ctrl+m)
  • Keyboard shortcuts (ctrl+/ for the overview)
  • Save/load in the browser (localStorage, with autosave) and file import/export as JSON
  • Copy a selection to the clipboard as JSON that pastes onto someone else's canvas
  • Built-in examples open straight from a link, e.g. /simulator#example:Calculator
  • Built-in examples, including a working four bit calculator

The site

Most of the site is the reference and the tools; the editor is one page of it. Everything is statically prerendered from the same codebase:

  • Learn: a guided path from one gate to a four bit adder, plus references for the six gates, their symbols, flip-flops, common circuits and the laws of boolean algebra.
  • Tools: truth tables, boolean simplification, Karnaugh maps with don't cares, SOP/POS, NAND/NOR conversion, Gray code, and a circuit diagram generator that exports SVG, PNG, Verilog or VHDL. The truth table and circuit generators take several outputs at once (sum = a ^ b; carry = a & b), sharing inputs and any common gates. For logic class rather than circuits, there are also truth tables for logic statements (p → q, q ∴ p), which check tautologies, equivalence and argument validity.
  • Practice and a worksheet generator with an answer key, both driven by a seeded question generator, so a link reproduces the exact same questions with no account or database involved.

Every truth table, identity and gate count on those pages is generated by src/lib/boolean.ts and checked by a property-based test suite, so the published content cannot drift from the maths.

Development

pnpm install
pnpm dev      # start the dev server
pnpm build    # production build
pnpm test     # playwright tests
pnpm og       # regenerate the social cards (needs Chrome)
pnpm cards    # regenerate the gate reference images

The whole editor is hand-written: rendering happens on a canvas with no diagramming library, and only the menus use Svelte. The interesting parts (viewport culling, high-DPI handling, hitboxes, the tick system) live in src/nodesystem/. I wrote up the lessons from building it here: Hand-writing a canvas node editor in TypeScript.

About

Built by Sem, a freelance software developer. There's a short project page on my site as well. The site is LogicGates.org; Logic Nodes is the name of the canvas editor it ships.

Licensed under Apache 2.0.