3.3.10 · D4Combinational Circuits

Exercises — Parity generators - checkers

3,687 words17 min readBack to topic

Ten problems climbing from "can you spot a parity bit?" to "design and reason about a multi-word scheme." Every problem has a full worked solution hidden in a collapsible callout — cover it, solve, then reveal. Prerequisite tools: XOR and XNOR gates and the parent Parity Generators / Checkers.

Before we begin, three shared conventions we lean on the whole way down.

Figure s01 below draws exactly this: four bits () light up yellow for a and blue for a ; the pink box on the right is the running XOR answer . Three yellow squares (three 1s) means an odd count, so the XOR box reads .

Figure — Parity generators - checkers

Level 1 — Recognition

Can you read a parity word and count correctly?

Exercise 1.1 (L1)

A 4-bit data word is sent with an even-parity bit appended. What is the full 5-bit transmitted word?

Recall Solution 1.1

WHAT we do: count the 1s in the data, then choose to make the total even. Step 1: Data has three 1s (count , which is odd). Step 2: Even parity wants an even total. We have odd → we must add one more 1, so . Step 3: Transmitted word . Total 1s (even). ✓ Answer: .

Exercise 1.2 (L1)

Same data , but now using odd parity. What is ?

Recall Solution 1.2

WHY different: odd parity wants the total count of 1s to be odd. Data already has three 1s (odd). Adding a 1 would make it even — bad. So keeps the total at (odd). ✓ Answer: , word .


Level 2 — Application

Turn the XOR formula into a mechanical procedure.

Exercise 2.1 (L2)

Using the even-parity generator , compute for data .

Recall Solution 2.1

WHAT we do: XOR the bits one pair at a time. Step by step: ; then ; then . WHY we may go strictly left to right: XOR is associative, meaning — the way we bracket the operations never changes the result. So we are free to collapse the chain one pair at a time from the left; any other grouping (or even a different order, since XOR is also commutative) lands on the same . That is precisely why a hardware XOR tree and a left-to-right hand calculation agree. Answer: . Check: data has two 1s, so total already even — no extra 1 needed. ✓

Exercise 2.2 (L2)

An odd-parity generator handles data . Give using the XNOR rule .

Recall Solution 2.2

Step 1 — inner XOR (this is our named quantity , the XOR of all data bits): . Left to right: ; ; . So . Step 2 — invert (that's the "N" in XNOR): . WHY invert? says data already has an odd count of 1s. Odd parity wants odd total, so we add nothing: . ✓ Answer: , word (three 1s, odd). ✓

Exercise 2.3 (L2)

A parity checker in an even-parity system receives (four data bits then ). Compute the error flag and state the verdict.

Recall Solution 2.3

WHAT the checker does: XOR everything including . ; ; ; . So . Verdict: in an even-parity system means OK, means ERROR. Here error detected. (Sanity: the received word has three 1s — odd — but even parity demands an even count. Broken. ✓) Answer: , error flagged.


Level 3 — Analysis

Reason about what parity catches and misses.

Exercise 3.1 (L3)

Even-parity system. The sender starts from the 4-bit data , appends the correct even-parity bit, and transmits the valid 5-bit word. During transit, the bits at positions and both flip. Does the checker catch this double error? Compute before and after the flips.

Recall Solution 3.1

Step 1 — build the valid word the sender actually transmits. Data (bits ), which has two 1s. Even parity of two 1s needs . So the transmitted word is . Confirm it is valid by running the checker on it: Step 2 — apply the two stated flips. Flip () and flip (). The word becomes . Now run the checker on the received word: , , , ? Let us redo carefully, one pair at a time: ; ; ; . So .

Careful recount (this is the crux of the exercise). The received word has three 1s — that is odd, so . But we flipped two bits; shouldn't parity be restored? It is restored only when the two flips change the count of 1s by an even net amount. Here adds a 1 and removes a 1 — net change , an even change. So the count of 1s should be unchanged at two, not three. Re-examine the flipped word: starting from (bits ), setting gives and setting leaves at (it was already !).

The trap this exposes. In the bit is already , so "flip " turns it into a , not a : . Reapplying correctly: and give . ; ; ; . Step 3 — verdict. says "OK", yet two bits are wrong. The double error is NOT caught. WHY: here both flips were , each adding a 1, so the count of 1s changed by (from two 1s to four 1s) — an even change. Even changes preserve parity, so returns to its "good" value . Parity detects only an odd number of errors; any even number of flips is invisible.

Exercise 3.2 (L3)

For a 4-data-bit even-parity code (5-bit words total), how many of the possible 5-bit patterns are valid even-parity words? What fraction is that, and what does it mean for undetected-error probability?

Recall Solution 3.2

Step 1: A valid word is any 4-bit data value with its forced parity bit. There are data values, each giving exactly one valid 5-bit word. So 16 valid words. Step 2: Fraction . Exactly half of all 5-bit patterns have even parity. WHY: for each of the 16 data patterns the parity bit is determined, so we never double-count and never skip — precisely half the space is "legal." Meaning: if an error lands you on any other legal codeword, it's invisible. Since legal words are spread out at "distance 2" (you need flips to move between them), single flips always land on an illegal word (caught), but some double flips land on a legal one (missed). Answer: 16 valid words, fraction .


Level 4 — Synthesis

Build and combine parity structures.

Exercise 4.1 (L4)

You must generate even parity for 8 data bits but you only own 2-input XOR gates. Design the tree: how many gates, and what is the minimum number of gate-delays (levels) from data to ?

Recall Solution 4.1

WHAT we need: XOR of built from 2-input pieces. Gate count: XORing bits with 2-input gates always costs gates (each gate reduces the count of live values by one; start with 8, end with 1). So gates. Delay (levels): pair them in a balanced tree, not a chain. Level 1: 4 gates → four partial results. Level 2: 2 gates → two results. Level 3: 1 gate → final . So levels. WHY a tree, not a chain: a straight chain of 7 gates has 7 levels of delay; the balanced tree cuts that to 3 while using the same 7 gates. Same hardware, faster answer. Answer: 7 two-input XOR gates, 3 levels of delay.

Figure s02 draws this balanced tree: the eight blue input dots () feed four yellow XOR gates on level 1, whose outputs feed two pink gates on level 2, which feed one final gate producing . Count the gate boxes (7) and the horizontal rows of gates (3 levels) directly off the picture.

Figure — Parity generators - checkers

Exercise 4.2 (L4)

A memory stores 4-bit words with even parity. You want to compute the parity bit and also have the raw XOR chain reusable as a checker later. Show that the generator and checker are the same circuit, using data end-to-end.

Recall Solution 4.2

Generate: , so . Stored word . Check (read back a clean word ): feed all 5 bits into the same style of XOR tree, now with one extra input for : → OK. ✓ The identity: the checker is literally an -input parity computation. Notice . Since we chose during generation, for any clean word — the algebra guarantees a valid word always checks clean. Answer: same XOR tree; generator uses inputs, checker uses , and whenever untouched.


Level 5 — Mastery

Push to the edges: degenerate inputs, layered parity, limits.

Exercise 5.1 (L5)

Degenerate cases. For even parity, what is when (a) the data is all zeros ()? (b) the data is a single bit (, value )? (c) (no data bits at all)?

Recall Solution 5.1

(a) : count of 1s , which is even. . So . The all-zero word is a valid even word — parity's "resting state." ✓ (b) , data : = XOR of one bit = the bit itself = . So ; word (two 1s, even). A single-bit-plus-parity code just duplicates the bit for even parity. (c) : XOR of no bits is the identity element (the "empty" parity). So . Gate-count convention for the empty tree (clearing up ""): the formula " two-input XOR gates" describes a tree that combines values. When or there is nothing to combine, so you build zero gates — you never build a negative number of gates. The clean way to say it is: the number of 2-input gates is , i.e. gates for and for . For the output is the conventional empty-XOR value ; for the output is just the lone bit wired straight through. So "" is shorthand valid for combining steps, floored at zero for the degenerate ends. Answer: (a) ; (b) ; (c) .

Exercise 5.2 (L5)

2-D parity (a taste of Hamming Codes). Arrange 4 data bits in a grid, add an even-parity bit per row (), per column (), and one corner bit that is the parity of the whole grid (equivalently the parity of the parities). For data

compute and the corner , then show that a single bit flip can be located (not just detected).

Recall Solution 5.2

Row parities (even, XOR across each row): . . Column parities (XOR down each column): . . Corner parity — the parity of the entire grid. It can be read three equivalent ways, and they must agree: , and also , and also . All three give . ✓ WHY matters: it guards the parity bits themselves. If noise flips one of the row/column parity bits (not a data bit), the corner check vs vs stops agreeing, telling you the fault is in the parity layer, not the data.

Now locate a single data flip. Suppose noise flips () in transit; the receiver holds the corrupted grid but still has the original parity bits that were transmitted alongside. The receiver recomputes each row and column parity from the bits it received and compares to the parity bits it was sent:

  • Recomputed . Sent . Match → row 0 is clean.
  • Recomputed . Sent . Mismatchrow 1 fails.
  • Recomputed . Sent . Match → column 0 is clean.
  • Recomputed . Sent . Mismatchcolumn 1 fails.

Read off the address. Exactly one row failed (row 1) and exactly one column failed (column 1). Their intersection is the single grid cell that belongs to both the failing row and the failing column: row 1 ∩ column 1 . That crossing cell is the flipped bit. Correct it: invert back from to , restoring the original grid. Re-checking now gives every row and column parity matching again, and the corner agrees — confirming a single data flip (not a parity-bit flip) and that it is fully repaired. WHY this beats 1-D parity: a single parity flag told us only that an error existed. Two independent coordinates — which row broke and which column broke — form an address, and the unique cell at their crossing pins the exact bit. The corner is the extra sanity check that the parity bits themselves were not the thing that got hit. This "intersection locates the error" idea is exactly the seed that grows into Hamming Codes. Answer: ; after flipping , row 1 and column 1 are the only failures and their intersection is cell , correctly locating (and thus allowing correction of) the flipped bit.

Figure s03 shows the grid after has flipped: row 1 and column 1 are marked FAIL, and their dashed intersection box points at as the located error.

Figure — Parity generators - checkers

Exercise 5.3 (L5)

Limiting behaviour. As the number of data bits under a fixed independent per-bit flip probability , argue qualitatively what happens to the chance that simple parity misses an error. Reason with words and pictures only — no formulas.

Recall Solution 5.3

Setup: parity misses exactly when an even, nonzero number of bits flip. Reasoning (in words): with more bits the expected number of flips grows — a longer word simply offers more places for noise to strike. Once a word typically suffers several flips, whether that total is odd or even becomes essentially a coin toss: half the time even (missed), half the time odd (caught). So as the word gets very long, the chance of an undetected error creeps up toward roughly one-half. Picture it: imagine tossing a fair coin once per flipped bit and asking "is the number of heads even?" — with many tosses that answer is near 50/50, and parity is blind to exactly the "even" half. Conclusion: single-bit parity is a short-word, low-noise tool. For long messages it degrades toward near-useless (miss chance near one-half), which is exactly why real systems move to Checksums and CRC and multi-bit Hamming Codes. Answer: the miss probability rises toward about one-half as ; parity does not scale to long messages.


Connections

  • XOR and XNOR gates — every exercise is chained XOR/XNOR under the hood.
  • Parity Generators / Checkers — the parent concept these problems drill.
  • Combinational Circuits — all these circuits are memoryless.
  • Hamming Codes — the 2-D "locate-by-intersection" idea (Ex 5.2) generalises here.
  • Error Detection and Correction & Checksums and CRC — where you go when parity's limits (Ex 5.3) bite.
  • Adders & Multiplexers — other XOR-heavy combinational blocks worth comparing.

Active Recall

Recall Quick self-quiz

Even-parity for ? ::: (three 1s → add one → total four). Checker for received (even system)? ::: → error. Gates and delay levels to XOR 8 bits with 2-input gates? ::: 7 gates, 3 levels. How does 2-D parity locate a bad bit? ::: The failing row and failing column intersect at it. What extra bit guards the row/column parities themselves? ::: The corner parity = parity of the whole grid. As , the miss probability of simple parity tends to? ::: About one-half.