A tiny error-detection scheme: add ONE extra bit so the number of 1s follows a rule. If a single bit flips during transmission, the rule breaks — and we catch it.
Imagine sending a secret message made of yes/no lights (1s and 0s). You and your friend agree: "the number of lights that are ON should always be even." Before sending, you count your ON lights — if it's odd, you flip on ONE extra light so it becomes even. Your friend counts when it arrives. If they get an odd number, they know a light got messed up on the way — like a broken bulb flickering. It can't tell them which bulb, just that something's off. And if TWO bulbs break, the count stays even and it gets fooled — that's its weakness.
What logic gate naturally computes parity?
XOR — its output is 1 iff an odd number of inputs are 1.
Formula for an even-parity generator over data bits di?
P=d0⊕d1⊕⋯⊕dn−1 (XOR of all data bits).
Formula for an odd-parity generator?
P=d0⊕⋯⊕dn−1 (XNOR of all data bits).
How does a parity checker produce its error signal E?
XOR of ALL received bits including P: E=d0⊕⋯⊕dn−1⊕P.
In even parity, what value of E means an error?
E=1 (a correct even word gives E=0).
Why does a single bit flip get detected?
It changes the count of 1s by ±1, flipping the parity and thus flipping E.
Why are double-bit errors missed?
Two flips change the count by an even amount, restoring the original parity, so E is unchanged.
Can simple parity correct errors?
No — it only detects (odd numbers of errors); it can't locate the faulty bit.
Even-parity gen for data 101?
1⊕0⊕1=0, so P=0; word =1010.
Odd-parity gen for data 101?
XOR =0, complement =1, so P=1; word =1011.
Relationship between a generator and checker circuit?
Same XOR tree; the checker is just an (n+1)-input version that also XORs P.
Socho tum apne dost ko lights ki language me message bhej rahe ho — kuch lights ON (1) aur kuch OFF (0). Beech raaste me kabhi-kabhi noise ki wajah se koi light galti se flip ho jaati hai. Toh dost ko kaise pata chale ki message kharab aaya? Iske liye hum ek extra parity bit add karte hain. Rule simple: "total ON lights hamesha EVEN honi chahiye" (ya odd, jo convention chuno).
Yeh kaam XOR gate karta hai, kyunki XOR ka output tabhi 1 hota hai jab 1s ki ginti odd ho. Toh even-parity generator ka formula banta hai P=d0⊕d1⊕… — agar data me odd number of 1s hain toh P=1 lag jaata hai jisse total even ho jaaye. Odd parity ke liye bas ise ulta (XNOR) kar do.
Receiver side pe checker saare bits (data + P) ko phir se XOR karta hai. Even system me agar E=0 aaya matlab sab theek, aur E=1 matlab koi bit flip hua hai — ERROR! Kyun? Kyunki ek bit flip hone se 1s ki ginti ±1 badalti hai, parity ulat jaati hai, aur E change ho jaata hai.
Ek important baat — parity sirf detect karta hai, correct nahi. Aur agar DO bits ek saath flip ho jaayein toh ginti wapas even ho jaati hai aur parity fool ho jaata hai. Isiliye strong error-fixing ke liye Hamming codes use hote hain. Par cost-wise parity sabse sasta safety net hai — bas ek extra bit!