Lesson
13 of 26
Translate

Logic Gates & Boolean Algebra

AND, OR, NOT, NAND, NOR, XOR, XNOR logic gates with truth tables, Boolean algebra basics, and their role in digital circuits for UPSSSC AGTA.

What are Logic Gates?

Logic gates are the building blocks of every digital circuit inside a computer. They are tiny electronic circuits that take one or more binary inputs (0 or 1) and produce a single binary output based on a specific logical rule.

Every operation a computer performs — from adding numbers to displaying images — is built from combinations of these simple gates. Your CPU contains billions of logic gates working together.


AND
OR
NOT
NAND
NOR
XOR

Gate symbols — NAND (amber) is a Universal Gate

The 7 Basic Logic Gates

1. AND Gate

The AND gate outputs 1 only when ALL inputs are 1. Think of it as: “Both conditions must be true.”

Symbol: A · B (or AB)

ABOutput (A·B)
000
010
100
111

Real-life analogy: A car starts only when BOTH the key is inserted AND the brake is pressed. Both conditions must be true.


2. OR Gate

The OR gate outputs 1 when ANY input is 1. Think of it as: “At least one condition must be true.”

Symbol: A + B

ABOutput (A+B)
000
011
101
111

Real-life analogy: A room light turns on if Switch A OR Switch B (or both) are pressed.


3. NOT Gate (Inverter)

The NOT gate has only one input and it reverses (inverts) it. If input is 1, output is 0. If input is 0, output is 1. Also called an Inverter.

Symbol: Ā (A bar) or A’

AOutput (Ā)
01
10

Real-life analogy: A “Do Not Disturb” sign — when it’s ON, entry is OFF; when it’s OFF, entry is ON.


4. NAND Gate (NOT + AND)

The NAND gate is the opposite of AND. It outputs 0 only when ALL inputs are 1. Otherwise, it outputs 1.

Symbol: (A·B)’ or AB with a bar

ABOutput
001
011
101
110

NAND is called a “Universal Gate” because any other gate (AND, OR, NOT) can be built using only NAND gates.


5. NOR Gate (NOT + OR)

The NOR gate is the opposite of OR. It outputs 1 only when ALL inputs are 0. If any input is 1, output is 0.

Symbol: (A+B)’ or A+B with a bar

ABOutput
001
010
100
110

NOR is also a “Universal Gate” — any gate can be built using only NOR gates.


6. XOR Gate (Exclusive OR)

The XOR gate outputs 1 when inputs are DIFFERENT. If both inputs are the same (both 0 or both 1), output is 0.

Symbol: A ⊕ B

ABOutput (A⊕B)
000
011
101
110

Used in: Binary addition (half adder, full adder circuits), error detection, parity checking.


7. XNOR Gate (Exclusive NOR)

The XNOR gate is the opposite of XOR. It outputs 1 when inputs are SAME.

Symbol: A ⊙ B

ABOutput
001
010
100
111

Used in: Equality comparison — checking if two values are the same.


Quick Comparison Table

GateInputsOutput = 1 WhenUniversal?
AND2+ALL inputs are 1No
OR2+ANY input is 1No
NOT1Input is 0 (inverts)No
NAND2+NOT all inputs are 1Yes
NOR2+ALL inputs are 0Yes
XOR2Inputs are DIFFERENTNo
XNOR2Inputs are SAMENo

Boolean Algebra Basics

Boolean algebra is the mathematics of logic gates, using only two values: 0 (False) and 1 (True). It was developed by George Boole in the 19th century.

Basic Laws

LawAND FormOR Form
IdentityA · 1 = AA + 0 = A
NullA · 0 = 0A + 1 = 1
ComplementA · Ā = 0A + Ā = 1
IdempotentA · A = AA + A = A
Double Negation(Ā)’ = A(Ā)’ = A

De Morgan’s Theorems

Two important theorems for simplifying logic circuits:

  1. (A · B)’ = Ā + B̄ — NOT of AND = OR of NOTs
  2. (A + B)’ = Ā · B̄ — NOT of OR = AND of NOTs

These theorems prove why NAND and NOR are universal gates — they can create any other gate.


Why NAND & NOR are Universal Gates

NAND and NOR are called Universal Gates because any other logic gate can be constructed using only NAND gates (or only NOR gates):

Gate to BuildUsing NAND OnlyUsing NOR Only
NOTConnect both inputs of NAND togetherConnect both inputs of NOR together
ANDNAND followed by NOT (another NAND)Three NOR gates
ORNOT each input, then NANDNOR followed by NOT (another NOR)

This is why NAND gates are the most commonly used gates in IC (Integrated Circuit) design — entire processors can be built from NAND gates alone.


Boolean Algebra — Additional Laws

LawExpressionMeaning
CommutativeA + B = B + A; A · B = B · AOrder does not matter
Associative(A+B)+C = A+(B+C); (A·B)·C = A·(B·C)Grouping does not matter
DistributiveA·(B+C) = A·B + A·CMultiply over addition
AbsorptionA + A·B = A; A·(A+B) = ASimplification rule

De Morgan’s Theorems (Restated Clearly)

  • Theorem 1: NOT(A AND B) = NOT A OR NOT B → (A·B)’ = A’ + B’
  • Theorem 2: NOT(A OR B) = NOT A AND NOT B → (A+B)’ = A’ · B’

Memory trick: “Break the bar, change the sign” — when you remove the NOT bar over a group, change AND to OR (or OR to AND) and NOT each variable.


Combinational Circuits — Adders

Half Adder

A Half Adder adds two single-bit binary numbers and produces a Sum and a Carry.

Input AInput BSum (A⊕B)Carry (A·B)
0000
0110
1010
1101
  • Sum = XOR gate (A ⊕ B)
  • Carry = AND gate (A · B)

Full Adder

A Full Adder adds three bits — two inputs (A, B) plus a Carry-In from a previous addition. It produces a Sum and a Carry-Out.

  • Built using two Half Adders and an OR gate
  • Multiple Full Adders are chained together to add multi-bit binary numbers (e.g., 8-bit addition)

Sequential Circuits — Flip-Flops

A Flip-Flop is the basic memory storage element in digital circuits. It stores one bit of data (0 or 1) and retains the value until changed.

TypeFull NameKey Feature
SRSet-ResetTwo inputs (Set, Reset); invalid state when both are 1
JKJK Flip-FlopImproved SR — no invalid state; toggles when both inputs are 1
DData/DelaySingle data input — output follows input on clock edge
TToggleToggles output on each clock pulse when input is 1

Flip-flops are used in registers, counters, and memory units inside the CPU.


Key Takeaways

  • Logic gates are building blocks of digital circuits — take binary inputs, give binary output
  • 7 basic gates: AND, OR, NOT, NAND, NOR, XOR, XNOR
  • AND = all 1s needed; OR = any 1 needed; NOT = inverts input (single input)
  • NAND and NOR are Universal Gates — can build any other gate from them alone (used in IC design)
  • XOR = different inputs give 1; XNOR = same inputs give 1
  • Boolean algebra by George Boole — math of 0s and 1s
  • Boolean laws: Commutative, Associative, Distributive, Identity, Null, Complement, Idempotent, Absorption
  • De Morgan’s Theorem 1: (A·B)’ = A’ + B’ — NOT of AND = OR of NOTs
  • De Morgan’s Theorem 2: (A+B)’ = A’ · B’ — NOT of OR = AND of NOTs
  • Memory trick: “Break the bar, change the sign”
  • Half Adder: adds 2 bits — Sum = XOR (A⊕B), Carry = AND (A·B)
  • Full Adder: adds 3 bits (A, B, Carry-In) — built from 2 Half Adders + OR gate
  • Flip-Flops = basic memory storage (1 bit): SR (invalid when both 1), JK (no invalid, toggles), D (follows input), T (toggles on clock)
  • Flip-flops used in registers, counters, and memory units inside CPU

Summary Cheat Sheet

ConceptKey Details
ANDOutput 1 only when ALL inputs = 1 (A·B)
OROutput 1 when ANY input = 1 (A+B)
NOTInverts: 0→1, 1→0 (single input, Inverter)
NANDOpposite of AND — Universal Gate
NOROpposite of OR — Universal Gate
XOROutput 1 when inputs are DIFFERENT (A⊕B)
XNOROutput 1 when inputs are SAME (A⊙B)
Universal GatesNAND and NOR — can build any other gate from them alone
Boolean AlgebraMath of logic (0 and 1) — George Boole
Commutative LawA+B = B+A; A·B = B·A — order doesn’t matter
Associative Law(A+B)+C = A+(B+C) — grouping doesn’t matter
Distributive LawA·(B+C) = A·B + A·C
Identity LawA·1 = A; A+0 = A
Complement LawA·A’ = 0; A+A’ = 1
De Morgan’s 1(A·B)’ = A’ + B’ — break bar, change AND to OR
De Morgan’s 2(A+B)’ = A’ · B’ — break bar, change OR to AND
Half Adder2-bit addition: Sum = XOR, Carry = AND
Full Adder3-bit addition (A, B, Carry-In): 2 Half Adders + OR gate
SR Flip-FlopSet-Reset — invalid state when both inputs = 1
JK Flip-FlopImproved SR — no invalid state, toggles when both = 1
D Flip-FlopData/Delay — output follows input on clock edge
T Flip-FlopToggle — output toggles on each clock pulse
Flip-Flop UseRegisters, counters, memory units in CPU
BitSingle 0 or 1 — processed by gates

Knowledge Check

Take a dynamically generated quiz based on the material you just read to test your understanding and get personalized feedback.

Lesson Doubts

Ask questions, get expert answers

Lesson Doubts is a Pro feature.Upgrade