LogicGates.org Open the simulatorSimulator

Learn digital logic from zero

A course in 35 short lessons, from a single wire to a machine that counts and decides. Each lesson explains one idea in plain words, gives you something to click, and ends with a quiz. Nothing here needs anything that comes later.

Start: What a bit is

How it works

Read

Each lesson is a few minutes of reading written for someone who has never seen this before. New words are explained in the sentence they first appear, and the "Why?" boxes are there when you want the reason, not just the rule.

Click

Every lesson has a live circuit in it: a gate you can drive, a latch you can set and reset, a counter you can clock. Watching the wires change colour is worth more than reading the truth table twice.

Check

Five right in a row on the quiz and the lesson gets a tick on the roadmap. A wrong answer shows a hint and lets you retry the same question. The questions are generated, so you can always come back for more.

1 Bits and binary numbers

Everything a computer does is done with wires that are on or off. Here is how that becomes numbers.

  1. What a bit is One wire, two values, and why that is enough to build on. 8 min
  2. Counting in binary Counting with only two digits, and reading a binary number without thinking. 12 min
  3. Bytes, hex and bit width Bits in fours and eights, hex as a shorthand for nibbles, and what happens past the biggest value. 12 min
  4. How bits become letters, colours and codes The same byte as a number, a letter, two decimal digits or a flag: a code decides. 12 min

2 The seven gates

A gate is a tiny machine with one rule. Seven of them are all you need.

  1. What a logic gate is Inputs in, one output out, and a table that says everything there is to say about it. 10 min
  2. AND and OR The two gates you use most: "both" and "at least one". 10 min
  3. NOT, and joining gates together The gate that flips a bit, and what happens when one gate feeds another. 12 min
  4. XOR, the odd one out One or the other but not both, and why that is how computers add. 10 min
  5. NAND, NOR and XNOR Three gates with a NOT built in, and why one of them is enough to build a computer. 12 min
  6. Reading a circuit diagram The seven symbols, which way the signals flow, and how to work a drawing out wire by wire. 12 min

3 Boolean algebra

Writing a circuit down as an expression, and rearranging it with a few laws.

  1. Writing a circuit as an expression Three notations for the same circuit, the order operators are applied in, and going between words and symbols. 12 min
  2. The basic laws Seven small rules that are always true, each proved by a truth table you can click through. 14 min
  3. Distributing and absorbing Multiplying out brackets both ways, and the law that deletes a whole term. 14 min
  4. De Morgan's laws How a NOT moves through a bracket: negate every term and swap the operator. 14 min
  5. Simplifying step by step A method for making an expression smaller, with two worked derivations and a way to check the answer. 16 min

4 Making circuits smaller

Any truth table can become a circuit; these methods make it the smallest one.

  1. From truth table to expression One AND term per row that is 1, all ORed together: a circuit for any table, and why it is too big. 12 min
  2. Karnaugh maps The truth table folded so that neighbours touch, and loops of 1s that turn into short terms. 14 min
  3. Four-variable maps and don't cares The 4 by 4 map with its wrapping corners, and rows that never happen, which you may fill however helps. 14 min
  4. How a computer minimises The Quine-McCluskey method: the map's merging rule as a procedure that works for any number of inputs. 12 min

5 Building circuits that compute

Adders, subtractors, selectors and decoders, built from what you know.

  1. The half adder Adding two bits has four cases, and two gates you already know cover them. 10 min
  2. The full adder A third input for the carry coming in, which is what lets adders be chained. 12 min
  3. Adding whole numbers Chain full adders and the carry ripples along: a four bit adder, traced column by column. 14 min
  4. Negative numbers and subtraction Two's complement: make the top bit negative and the same adder subtracts. 15 min
  5. Multiplexers, decoders and comparators Three more circuits that are nothing but truth tables: pick an input, light one line, compare two numbers. 13 min
  6. Driving a seven-segment display Four bits in, seven bars out: seven truth tables that share their inputs, with six rows nobody cares about. 13 min

6 Memory

Feed a gate back into itself and the circuit starts to remember.

  1. Circuits that remember Loop an output back to an input and the circuit gets a past. 10 min
  2. The SR latch Two NOR gates holding each other up: one bit of memory you can set and reset. 14 min
  3. Clocks and edges A steady tick, the instants it changes, and why everything moves on the same one. 12 min
  4. Flip-flops A latch that only listens on the clock edge: D, T and JK, with their tables and timing. 14 min

7 Counting and state machines

Flip-flops in a row become registers, counters and controllers.

  1. Registers and shift registers Line up D flip-flops on one clock and you can hold a whole number, or slide it along one bit at a time. 14 min
  2. Counters Chain toggling flip-flops and their outputs count in binary all by themselves. 15 min
  3. Gray code A way of counting where only one bit changes at a time, and why that avoids a nasty glitch. 12 min
  4. State machines A set of states, a rule for moving between them, and outputs: the pattern behind every controller. 15 min
  5. Designing a state machine From a state diagram to gates and flip-flops, the same way every time. 16 min

8 The final project

Put it all together and build something that was not on this site.

  1. Build a four-bit calculator A guided build in the simulator: adder chips, subtraction, a digit on the display, and where to go next. 45 min

Questions

Do I need any electronics or maths to start?

No. The course starts from a light switch and works entirely with 1s and 0s: a wire is either high or low, and gates turn some highs and lows into others. You never need volts, resistors or transistors, and the only arithmetic is counting. Every new word is explained where it first appears.

What order should I learn digital logic in?

Bits, then the gates and truth tables, then boolean algebra, then how to make a circuit smaller with Karnaugh maps, then the circuits that compute: adders, multiplexers and decoders. Only then memory, with the SR latch and flip-flops, and finally counters, registers and state machines. That is the order of the eight stages here, and each one uses only what came before it.

How does a lesson count as done?

Every lesson ends with a quiz of generated questions. Five right in a row and the lesson gets a tick on the roadmap. A wrong answer shows a hint and lets you try the same question again. You can also mark a lesson as already known, which gives it a hollow tick until you pass the quiz. Progress is saved in your browser only; there are no accounts.

How long does it take?

The lessons add up to about undefined hours of reading and practice. Most people take the early stages in an evening or two each and slow down at memory and state machines, where timing is new. There is no clock: the roadmap keeps your place, and every lesson can be reopened for more practice at any time.

Is this the same as the reference pages?

No. The reference pages, such as the gates, the flip-flops and the boolean algebra laws, are for looking things up and go into more depth than a lesson does. Each lesson links to the reference pages that go deeper on its topic, and the tools on the site are the same ones the lessons point you at.