StudyFi Lab · Electrical engineering

Logic Gates

Logic Gates is a free interactive simulation from StudyFi Lab. It runs right in your browser, with no sign-up and nothing to install.

AND, OR, NOT, XOR and adders built from gates

Experiments

Logic gates

A logic gate turns the input signals 0 and 1 into one output. AND gives 1 only when both inputs are 1 (Q = A · B), OR when at least one is (Q = A + B), XOR when the inputs differ, and NOT flips its input. NAND and NOR are AND and OR with the output negated — that is the small circle on the symbol. The truth table lists every combination of inputs; the highlighted row is the one set by the switches.

Try this: Pick NAND and find the only combination of inputs that makes the LED go out.

Build a circuit

Put together your own circuit from switches, gates and LEDs. Every wire carries the signal from one output to one input; an output may drive several inputs, but an input listens to only one wire. Signals flow forward only — a wire that would lead a gate’s output back into its own input (a feedback loop) is refused. The truth table of the whole circuit updates as you wire.

Try this: Using NAND gates only, build NOT (join both inputs of one NAND) and then AND — NAND is universal.

Half adder

A half adder adds two one-bit numbers. The sum bit is S = A ⊕ B (XOR) and the carry is C = A · B (AND). For 1 + 1 the result is 10₂ = 2: the sum is 0 and a 1 is carried to the next place, just like carrying in written addition.

Try this: Switch both inputs to 1 and check that the LEDs C S show 10, which is two in binary.

Full adder

A full adder also takes the carry Cᵢₙ from the place below, so it adds three bits. It is made of two half adders: S = A ⊕ B ⊕ Cᵢₙ, and the carry Cₒᵤₜ = A · B + Cᵢₙ · (A ⊕ B) is 1 whenever at least two inputs are 1. Chaining full adders adds numbers of any length.

Try this: Set all three inputs to 1: 1 + 1 + 1 = 3 = 11₂, so both LEDs light up.

2-bit adder

Two 2-bit numbers A = A₁A₀ and B = B₁B₀ (0 to 3 each) are added just like in written addition. A half adder adds the lowest bits A₀ + B₀, and its carry goes into a full adder for the bits A₁ + B₁. The result S₂S₁S₀ has three bits because the largest sum, 3 + 3 = 6 = 110₂, needs one more place.

Try this: Set A = 3 and B = 1 and watch the carry ripple through: 11₂ + 01₂ = 100₂ = 4.

Combination lock

The LED lights for just one combination of the four switches. Inside, each switch goes into an AND gate either directly (the code wants a 1) or through a NOT (the code wants a 0); the AND gates give 1 only when all their inputs are 1. This is how a digital circuit recognises one exact pattern of bits.

Try this: Find the code by trial and error, then open the circuit: the NOT gates tell you which switches must be 0.

Frequently asked questions

What is Logic Gates?

Logic Gates is a free interactive simulation from StudyFi Lab. It runs right in your browser, with no sign-up and nothing to install. AND, OR, NOT, XOR and adders built from gates

Is Logic Gates free?

Yes. Logic Gates is completely free. It works in the browser on computers, tablets and phones, and you do not need an account.

What can I explore in Logic Gates?

Logic gates, Build a circuit, Half adder, Full adder, 2-bit adder, Combination lock.

What does the “Logic gates” experiment show?

A logic gate turns the input signals 0 and 1 into one output. AND gives 1 only when both inputs are 1 (Q = A · B), OR when at least one is (Q = A + B), XOR when the inputs differ, and NOT flips its input. NAND and NOR are AND and OR with the output negated — that is the small circle on the symbol. The truth table lists every combination of inputs; the highlighted row is the one set by the switches.

What does the “Build a circuit” experiment show?

Put together your own circuit from switches, gates and LEDs. Every wire carries the signal from one output to one input; an output may drive several inputs, but an input listens to only one wire. Signals flow forward only — a wire that would lead a gate’s output back into its own input (a feedback loop) is refused. The truth table of the whole circuit updates as you wire.

Studying for a test?

Upload your notes and StudyFi turns them into flashcards, tests and podcasts.

Try StudyFi free