4.1.15 · D3Memory Technologies

Worked examples — ECC and memory error correction

2,321 words11 min readBack to topic

This page is a drill hall. The parent note built the theory; here we run the machine on every kind of input it can face, so you never meet a case you haven't already seen worked.

Before we touch a single bit, one reminder of the whole trick: we number positions , put parity bits at power-of-two positions (), fill the rest with data, and each parity bit at position watches every position whose binary index has bit turned on. The magic payoff: when we recompute the parities on a received word, the list of "which checks failed", read as a binary number, is the address of the broken bit. (If any of those words feel new, re-read the parent's Hamming section — everything below leans on Hamming Code, Parity Bit, and Boolean Algebra / XOR.)


The scenario matrix

Every ECC exercise you will ever be handed lands in one of these cells. The worked examples below are labelled with the cell they cover, and together they fill the whole grid.

Cell Case class What is tricky about it Covered by
A Encode from scratch (all-parity fresh) placing bits, computing each parity Ex 1
B Decode, zero errors (degenerate input) syndrome must come out Ex 2
C Decode, single error in a data position syndrome = data-bit address Ex 3
D Decode, single error in a parity position syndrome points at a power-of-two slot Ex 4
E SECDED, double error (limiting failure of correction) syndrome but overall parity even Ex 5
F SECDED, error in the overall parity bit itself edge case: syndrome , overall parity wrong Ex 6
G Sizing / bound (word problem) choose for given ; real DIMM Ex 7
H Capability limits (exam twist) vs detect/correct counts Ex 8

Cells span: fresh encode, all three "where did the flip land" possibilities (data / parity / overall bit), the no-error degenerate case, the beyond-correction double-error case, a real-hardware sizing problem, and a distance-theory twist. That is the complete space.


Cell A — Encode from scratch

Figure — ECC and memory error correction

Cell B — Decode with zero errors (degenerate)


Cell C — Single error in a data position

Figure — ECC and memory error correction

Cell D — Single error in a parity position


Cell E — SECDED with a double error (beyond correction)

We now bolt on the overall parity bit = XOR of all codeword bits, giving (SECDED). This is the limiting case where "just correct the nearest word" would silently lie to us.

Figure — ECC and memory error correction

Cell F — Error in the overall parity bit itself


Cell G — Sizing a real code (word problem)


Cell H — Capability twist (exam-style)


Recall Quick self-test across the matrix

Received Hamming(7,4) word 1 1 1 0 1 0 1 with even parity — which position (if any) is wrong? ::: c1(1,3,5,7)==0, c2(2,3,6,7)==1, c4(4,5,6,7)==0 → syndrome → position 2 flipped (a parity bit). For data bits, minimum for SEC Hamming? ::: and , so . A code has . Detect? Correct? ::: Detect ; correct (plain SEC, the classic Hamming setting).


Related: Hamming Code · Parity Bit · Boolean Algebra / XOR · Cosmic Rays and Soft Errors · DRAM · Reed-Solomon Codes · Cache Coherence