Logic Gates & Digital Circuits

Interactive boolean logic — click inputs to toggle 0/1 and watch outputs update live

Boolean Algebra Laws

A AND 0 = 0   A AND 1 = A   A OR 0 = A   A OR 1 = 1
NOT(NOT A) = A   NOT(A AND B) = NOT A OR NOT B (De Morgan)
NOT(A OR B) = NOT A AND NOT B (De Morgan)   A XOR A = 0

Circuit Builder

Place gates, connect them with wires, and watch signals propagate. Click a palette item, then click the canvas to place. Click two nodes to connect. Toggle input nodes by clicking them.

Examples:

Gates

INPUT
OUTPUT
AND
OR
NOT
NAND
NOR
XOR
XNOR

Truth Table Generator

Enter a boolean expression using AND, OR, NOT, XOR, NAND, NOR. Variables: A, B, C, D (up to 4). The truth table, SOP form, and Karnaugh map are generated automatically.

Truth Table

SOP Expression

Karnaugh Map

Adders & ALU

Half Adder

A half adder adds two 1-bit inputs. Sum = A XOR B, Carry = A AND B. It has no carry-in, so it can only add the least-significant bit.

A
0
B
0
Sum
0
Carry
0

Full Adder

A full adder adds three bits: A, B, and a Carry-In. Sum = A XOR B XOR Cin, Carry = (A AND B) OR (Cin AND (A XOR B)). Full adders chain together to add multi-bit numbers.

A
0
B
0
Cin
0
Sum
0
Cout
0

4-Bit Ripple Carry Adder

Four full adders chained: each carry-out feeds the carry-in of the next stage. Enter two 4-bit numbers and watch the carry ripple through all four stages.

About ALUs

An Arithmetic Logic Unit (ALU) is the computational core of a CPU. It performs:


Arithmetic: ADD, SUBTRACT, INCREMENT, DECREMENT, NEGATE

Logic: AND, OR, NOT, XOR, NAND, NOR

Comparison: EQUAL, LESS-THAN, GREATER-THAN (sets flags)

Shift: LEFT SHIFT (×2), RIGHT SHIFT (÷2), ROTATE


A control signal (opcode) tells the ALU which operation to perform. The ALU outputs a result and status flags (zero, carry, overflow, sign).