Chapter 1 · Simulation

Logic Gates and Adders

← Chapter 1

Truth table

Click a row to set the inputs to it.

Logic Gates and Adders

Goal: See how the basic logic gates behave through their truth tables, and watch how gates combine into circuits that add binary numbers (half and full adders).

How to use it

  • Click the A, B (and Cin) input boxes on the left, or select them with Tab and press Space/Enter: the input flips 0 ↔ 1.
  • The wires are colour-coded: thick green = 1, thin grey = 0. Each wire also shows its value.
  • The truth table highlights the current input row; clicking a row sets the inputs to it.
  • Try it yourself: the gate outputs are hidden. Guess the output(s) as 0/1; the page checks your answer and keeps score. New question picks random inputs (and a random gate in single-gate mode).

Gates

GateRule
AND1 if both inputs are 1
OR1 if at least one input is 1
NOTinverts the input
XOR (exclusive OR)1 if the inputs differ
NANDinverse of AND: 0 if both inputs are 1
NORinverse of OR: 1 if both inputs are 0

Adders

The half adder adds two single bits: SUM = A XOR B (the digit), CARRY = A AND B (the carry). The result is written as two bits (CARRY, SUM): 1 + 1 = 10₂.

The full adder also takes the carry coming from the lower digit (Cin); it is built from two half adders and an OR gate: SUM = A XOR B XOR Cin, Cout = (A AND B) OR ((A XOR B) AND Cin). Full adders chained side by side add multi-bit numbers.

Related slides: Chapter 1.3 · Computers (Logic Gates, Half Adder).