How to build a parity generator and parity checker
An even parity generator outputs the bit P that makes the total number of 1s even, which for three data bits is P = D2 XOR D1 XOR D0. A parity checker XORs every received bit, data and parity together: E = D2 XOR D1 XOR D0 XOR P, and E = 1 means a single-bit error.
XOR of several bits is 1 exactly when an odd number of them are 1, so a chain of XOR gates both makes and checks parity. The sender appends P so the word has an even number of 1s; the receiver XORs the whole word, and any single flipped bit makes the count odd and lights E. This circuit has both halves: P is the generator's output for D2 D1 D0, and E is the checker for those data bits plus a received parity bit Pin. Set Pin equal to P and E stays 0; flip any one input and E becomes 1.
Open this circuit in the lab →
What you need
- 2× XOR: the generator: P = (D2 XOR D1) XOR D0
- 1× XOR: the checker: E = P XOR Pin (reusing the generator's XOR chain)
Step by step
- Place the data inputs
D2,D1,D0and a received-parity inputPin. - Generator: XOR D2 with D1, then XOR the result with D0. That is the even parity bit
P. - Checker: XOR P with Pin. If the received parity matches the data, the result is 0; otherwise it is 1. Probe it as
E. - Try it: set D2 D1 D0 = 101 (P = 0) and Pin = 0, so E = 0. Now flip D1 or Pin, simulating a bit damaged in transit: E becomes 1.
Even parity generator truth table
| D2 | D1 | D0 | Number of 1s | P |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 |
| 0 | 1 | 1 | 2 | 0 |
| 1 | 0 | 0 | 1 | 1 |
| 1 | 0 | 1 | 2 | 0 |
| 1 | 1 | 0 | 2 | 0 |
| 1 | 1 | 1 | 3 | 1 |
P is 1 exactly in the rows with an odd number of 1s, which brings the total (data plus P) to an even count. For odd parity, invert P. Parity catches any odd number of flipped bits but misses two flips, since the count stays even; Hamming codes add more parity bits to find and correct the error. All 16 combinations of D2 D1 D0 and Pin are checked before the page is built.
You can also read the full theory in the lesson on error detection and correction. Prefer to build it yourself from scratch? Open the digiwleea lab and place the gates on the canvas, or start from the logic gate simulator.
Build more parts from gates
Each of these is one step from a transistor to a working CPU. Build every gate from CMOS transistors and work all the way up in the free digiwleea lab, with the free theory reference alongside.
Open the parity generator and checker in the lab →Frequently asked
How do you design an even parity generator?
XOR all the data bits together: P = D2 XOR D1 XOR D0 for three bits. XOR is 1 when an odd number of its inputs are 1, so P adds the 1 needed to make the total even.
How does a parity checker work?
It XORs every received bit, including the parity bit. With even parity a correct word has an even number of 1s and the XOR is 0; if one bit was flipped the count is odd and the XOR is 1, flagging an error.
What is the difference between even and odd parity?
Even parity chooses P so the total number of 1s is even; odd parity makes it odd. The odd parity bit is simply the inverse of the even one (an XNOR chain instead of XOR).
Can parity detect all errors?
No. A single parity bit detects any odd number of flipped bits but not an even number, and it cannot tell which bit is wrong. Error-correcting codes such as Hamming codes use several parity bits to locate and fix single-bit errors.