Why Codes Exist
November 14, 202649 min readbeginner
One flipped bit can turn 100 into 228. This chapter measures how often bits flip, builds the repetition code and its majority voter by hand, proves what they buy and what they cost, and tours the codes inside real systems.
Every bit a computer stores or sends is a physical thing, such as a small charge on a capacitor, a voltage on a wire, a pulse of light in a fiber or the phase of a radio wave. Physical things get disturbed. A particle from space passes through a memory chip and knocks a stored 0 into a 1. Noise in a receiver pushes a voltage across the threshold that separates 0 from 1. The machine has no way of noticing. It reads the wrong bit with exactly the same confidence as the right one, and carries on.
An error correction code is the defense. Before a message is stored or sent, a few extra bits are computed from it and attached. The extra bits carry no new information. They are redundancy, chosen so that a damaged message can be recognized as damaged and, given enough redundancy, repaired. Claude Shannon proved in 1948 that reliable communication over a noisy channel is possible at all [1], and Richard Hamming published his single-error-correcting codes two years later [2]. Every phone, disk, memory module and spacecraft built since depends on what followed.
This chapter builds the idea from nothing. It starts with what one flipped bit costs, measures how often flips happen, and sets up the simplest model of a noisy channel. It then builds the simplest code there is, which sends every bit three times and decodes by majority vote, and proves exactly how much reliability that buys and how much it costs. A single parity bit shows the cheaper alternative of detecting errors rather than correcting them, and the chapter closes with a tour of the codes inside memory, networks, radio and spacecraft. Every number in the chapter is recomputed by a short Python program, ch01_why_codes_exist.py, kept in the python/ folder of the book's companion repository, ecc-book-lab, on GitHub. To run it, download the repository from that page, either with git clone https://github.com/anirbanchakraborty-dev/ecc-book-lab or as a ZIP file, and run python3 python/ch01_why_codes_exist.py from its top folder. The program needs nothing beyond Python 3.10, prints each value beside the one the text states, and stops with an error at the first disagreement. The two charts are drawn by ch01_charts.py in the same folder.
01.One Flipped Bit
Start with one byte, 01100100. Reading it as an unsigned binary number means adding up the place values of the positions that hold a 1. Numbering the bits from 0 at the right to 7 at the left, bit is worth , and this byte has ones in bits 6, 5 and 2, so it is .
Now flip one bit. If bit 0, the rightmost, flips from 0 to 1, the byte becomes 01100101 and the value becomes 101. The error is one part in a hundred, the kind of mistake a reading might survive. If instead bit 7 flips, the byte becomes 11100100. Read as unsigned, that is , more than double the true value. Read as a signed number in two's complement, the format nearly every processor uses for integers, bit 7 is the sign bit and is worth rather than , so the same pattern is . One flip has turned a positive hundred into a negative number.
The lesson of Figure 1 is that the cost of an error depends on where it lands, and the hardware has no idea where that is. The same flip that nudges a pixel's brightness by one level can, in another byte, change the sign of an account balance, send a pointer to a random address, or turn one machine instruction into another. A memory cannot store some bits more carefully than others, because it does not know which bits matter. The protection has to cover every bit equally, and it has to be cheap enough to pay on every bit.
02.Where Flips Come From
Flips have physical causes, and the first ones to worry computer designers were found in the late 1970s. Timothy May and Murray Woods traced random errors in dynamic memory to alpha particles emitted by trace radioactive elements in the chip's own packaging [3]. An alpha particle crossing the silicon frees a trail of electric charge, and if enough of it collects on a storage node, the stored value changes. In the same year James Ziegler and William Lanford showed that cosmic rays reaching the ground could do the same [4]. These are soft errors. Nothing is damaged, and writing the bit again repairs it, but whatever read the wrong value has already used it.
Field data show how common this is. A study of the memory in Google's server fleet found that more than 8% of DIMMs, the small boards that carry memory chips, saw at least one error per year, at rates of 25,000 to 70,000 errors per billion device hours per megabit [5].
Eight percent sounds small until it is multiplied out. Suppose a server holds 16 DIMMs and, as a simplifying assumption, each one independently has an 8% chance of an error in a year. The chance that one particular DIMM stays clean all year is . Because the DIMMs are assumed independent, the chance that all 16 stay clean is the product of their separate chances, , and the chance that at least one errs is
Nearly three servers in four would see a memory error within a year. Real errors are not independent, so the figure illustrates the arithmetic rather than predicting any machine. The step itself, one minus the chance of none, appears again and again in this book, because the chance of none is a product of independent chances and the chance of at least one is not.
Memory is only one source. On a wire or a fiber, thermal noise in the receiver, interference from neighboring signals and the loss of signal strength over distance all push a received voltage toward the wrong side of the decision threshold. In flash storage, the charge that represents a bit leaks away over time and is disturbed when neighboring cells are read and written. In radio, the signal fades as the receiver moves. The causes differ, but each ends the same way, with a bit that reads back wrong.
03.How Often Errors Happen
Engineers summarize a link or a storage device by its bit error rate, the long-run fraction of bits that come out wrong. High-speed serial links are commonly specified at a bit error rate of , one wrong bit in a trillion. That sounds like perfection. Multiply it by the speed of the link and it is not.
Take a link running at 8 gigabits per second, so bits every second, with a bit error rate of . The expected number of errors per second is the number of bits times the chance that each is wrong, . That is 28.8 errors an hour and 691.2 errors a day. A link that is wrong once in a trillion bits is wrong hundreds of times a day.
Now ask a different question. A file of one terabyte, bytes or bits, is read across the same link. What is the chance that at least one bit is wrong? Each bit is right with probability , where , and if errors strike independently, all bits are right with probability . So
Evaluating that directly is awkward, because is so close to 1 that an ordinary calculator rounds it to exactly 1. Two inequalities pin the answer down instead, and both are worth proving because they return throughout the book.
Proof. Let . Then . The derivative of , which measures its slope, is . For , , so and is rising. For , , so and is falling. The function falls until and rises after it, so its smallest value is . Therefore for every , which is the claim.
Proof. By induction on , which means proving the claim for and then showing that whenever it holds for some it also holds for , so that it climbs to every whole number. For both sides equal 1. Now suppose . Multiplying both sides by , which is not negative and so does not reverse the inequality, gives
where the last step drops the term , which is never negative.
Proof. . Bernoulli's inequality with gives , so . The exponential bound with gives , and raising both sides of an inequality between non-negative numbers to the same power keeps it true, so and .
For the terabyte, . The upper bound says , which is true and useless, since no probability exceeds 1. The lower bound says , and the exact value agrees with it to better than one part in a billion. Reading a terabyte across a link that errs once in a trillion bits is almost certain to deliver at least one wrong bit.
For a single 4 KiB page of memory, 4,096 bytes of 8 bits each or bits, . Now the two bounds squeeze together, and to five significant figures. The two cases give the rule of thumb used throughout reliability work. When is small, the chance of any error is about . When is large, an error is close to certain.
A link or a disk can be built better, with cleaner signals, better shielding or more charge per cell, but every improvement costs power, area or money, and none of them gets to zero. Codes take the other route. They accept that bits will flip and arrange for the flips to be caught.
04.A Model of a Noisy Channel
To reason about codes, the messy physics needs a simple model. The simplest, and the one this Part uses throughout, is the binary symmetric channel.
The word symmetric means that a 0 is as likely to become a 1 as a 1 is to become a 0, the two crossing arrows of Figure 2. Real channels are not always so even-handed, and the chapter Channels, Signals and Likelihoods builds models that are not. The binary symmetric channel still captures the two facts that matter first. Errors happen at some rate , and they strike bits independently, so a long message suffers about errors per bit, scattered at random.
When bits cross the channel, the difference between what was sent and what arrived can be written as an error pattern , a string of bits with a 1 wherever a bit was flipped. If 000 is sent and 010 arrives, the error pattern is 010. The number of ones in a pattern is its weight, written , and it counts how many bits were flipped. Because flips are independent, the probability of one particular pattern of weight is a product with one factor per bit, for each of the flipped bits and for each of the untouched ones.
Many patterns share a weight. The number of ways to choose which of the positions are flipped is the binomial coefficient
read " choose ", where and . The formula comes from counting. There are choices for the first flipped position, for the second, and so on down to for the last, which makes ordered choices. Each set of positions has been counted once for every order in which it could have been picked, which is times, and dividing by leaves the number of sets. Table 1 works the case on a channel with .
Table 1. Error patterns on three bits through a binary symmetric channel with
| Weight | Patterns | One pattern, | All patterns of weight | |
|---|---|---|---|---|
| 0 | 000 | 1 | 0.729 | 0.729 |
| 1 | 001, 010, 100 | 3 | 0.081 | 0.243 |
| 2 | 011, 101, 110 | 3 | 0.009 | 0.027 |
| 3 | 111 | 1 | 0.001 | 0.001 |
Source: computed from the pattern probability above and reproduced by ch01_why_codes_exist.py.
The last column adds to , as it must, since some pattern always occurs. It also shows the fact that makes decoding possible. One flip is far more likely than two, and two far more likely than three.
Proof. Divide the two pattern probabilities.
When , , so the ratio is less than 1, and each extra flip makes a pattern less likely.
So on a channel that is right more often than wrong, the best guess about what was sent is whichever allowed message differs from what arrived in the fewest positions. Every decoder in this book is built on that sentence.
05.The Repetition Code
Here is the simplest code that can repair an error. Send every bit three times, so a 0 goes out as 000 and a 1 as 111. The receiver looks at each block of three and takes a vote, and whichever value appears at least twice wins. The code is called the repetition code of length three, written .
Follow one message through the whole chain in Figure 3. The source has four bits to send, 1011. The encoder triples each one and sends 111 000 111 111, twelve bits in all. The channel flips four of them, and 101 000 100 110 arrives. The decoder votes block by block. The block 101 holds two ones, so it decodes to 1. The block 000 decodes to 0. The block 100 holds one 1 and two zeros, so it decodes to 0. The block 110 decodes to 1. The delivered message is 1001.
Compare 1001 with the 1011 that was sent. Three of the four bits came through. The first block took one flip and the vote corrected it. The second took none. The fourth took one and was corrected. The third block took two flips, which outvoted its one surviving correct copy, and the decoder confidently delivered the wrong bit. That one example shows the whole behavior of the code. One flip in a block is always repaired, and two or more always win the vote.
Some vocabulary makes this precise. The two strings the encoder can produce, 000 and 111, are the codewords. The string the decoder sees is the received word, and it can be any of the eight 3-bit strings. Decoding means mapping each received word back to a codeword, and from there to a message bit.
Figure 4 draws all eight 3-bit words, with a line between any two at distance 1, so that moving along one line is one flip. The codewords 000 and 111 sit at opposite ends, three flips apart. Every other word is one flip from one codeword and two flips from the other, and the vote sends it to the near one. The four words 000, 001, 010 and 100 decode to 0, and the four words 111, 110, 101 and 011 decode to 1.
Proof. Let hold ones. It differs from 000 in exactly those positions, so , and it differs from 111 in the other positions, so . The word is nearer to 000 exactly when , that is when , and since is a whole number this means . The vote decodes to 0 exactly when at most one of the three bits is a 1, which is the same condition. The two rules agree on every word, and since and are never equal, there is never a tie.
Put this together with the earlier theorem. Nearest means fewest flips, and fewest flips means the most likely error pattern when , so the vote always picks the codeword that most likely explains what arrived, provided 0 and 1 are sent equally often. The chapter Channels, Signals and Likelihoods proves that this choice also gives the smallest possible probability of decoding wrongly.
06.The Majority Voter in Hardware
A vote is easy to build in logic. Call the three received copies , and . Write for AND , which is 1 only when both are 1, and for OR, which is 1 when at least one input is 1. Then the majority function is
Proof. If at least two inputs are 1, that pair is one of the three pairs , or , so its AND term is 1, and an OR with any input at 1 gives 1. If at most one input is 1, every pair contains at least one 0, so all three AND terms are 0 and so is their OR.
Table 2 checks the formula on all eight inputs, which is a second proof, since eight rows cover every case.
Table 2. The majority function on every input
| Ones among the inputs | |||||||
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 |
| 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 |
| 0 | 1 | 1 | 0 | 1 | 0 | 1 | 2 |
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
| 1 | 0 | 1 | 0 | 0 | 1 | 1 | 2 |
| 1 | 1 | 0 | 1 | 0 | 0 | 1 | 2 |
| 1 | 1 | 1 | 1 | 1 | 1 | 1 | 3 |
Source: each row follows from the definitions of AND and OR, and ch01_why_codes_exist.py checks all eight.
In gates, the formula is three two-input AND gates feeding one three-input OR gate, drawn on the right of Figure 5. A signal passes through two gates on its way to the output, so the vote costs two gate delays whatever the inputs.
The same circuit protects computation as well as data. Build three copies of a module, give them the same input, and vote on their outputs. If one copy fails, the other two outvote it. This arrangement, on the left of the figure, is called triple modular redundancy, and it is the hardware form of . John von Neumann studied it in 1956 as a way to build reliable machines from unreliable parts, and showed that repeated majority voting can make a whole computation as reliable as wanted, provided each component fails with a probability below a threshold [6].
The price is plain. Triple modular redundancy needs three times the hardware and three times the power, plus the voter, and the voter becomes a single part whose own failure no vote can catch. It is used where a wrong answer costs far more than the extra silicon.
07.What the Repetition Code Buys
A single flip in a block is repaired, and two or more are not. On , that is enough to compute the decoded error probability exactly.
Proof. The decoder is wrong exactly when two or three of the three copies are flipped. All three flipped is one pattern, 111, with probability . Exactly two flipped is patterns, 011, 101 and 110, each with probability . The two cases cannot happen together, so their probabilities add.
Table 3. What the repetition code buys at three channel qualities
| Crossover | Error without a code | Error with | Improvement |
|---|---|---|---|
| 0.1 | 0.1 | 0.028 | 3.6 times |
| 0.01 | 0.01 | 33.6 times | |
| 0.001 | 0.001 | 333.6 times |
Source: computed from the key equation and reproduced by ch01_why_codes_exist.py.
Table 3 shows the improvement growing as the channel gets better. For small the term is negligible beside , so and the improvement is about . Each factor of ten in channel quality buys a factor of a hundred in decoded quality. That squaring is the signature of a code that corrects one error. To fail, it needs two independent errors in the same block, and two rare events together are rarer still.
Proof. Subtract and factor.
Multiplying out confirms the factoring. For all three factors are positive, so . At the last factor is zero and the code changes nothing, and for the last factor is negative and the code makes matters worse.
The failure above one half is less strange than it looks. A channel that flips more than half of its bits is more often wrong than right, and a receiver that simply inverts every bit it gets turns it into a channel with crossover , which is below one half. The channel at exactly is the truly hopeless one. Its output is a fair coin toss whatever went in, so it carries no information at all, and no code can help.
Figure 6 plots the decoded error of no code, and on logarithmic axes, where a power of becomes a straight line whose slope is the power. The uncoded line has slope 1, has slope 2 because , and has slope 3, for a reason the next section derives. All three meet at .
08.The Price of Reliability
The repetition code is not free. To deliver one message bit it sends three, so a channel carries a third as much information per second, a disk stores a third as much data, and every delivered bit costs three times the energy. The measure of this cost is the code rate.
More copies buy more reliability. With copies, and odd so that the vote cannot tie, majority decoding fails exactly when more than half the copies are flipped. Adding up the probability of every losing weight, as in the proof for , gives
For the sum has three terms, for three, four and five flips, and expanding them gives
At this is , about thirty times better than at the same , for a rate of instead of . The leading term is why has slope 3 in Figure 6. As grows the sum becomes unwieldy, but a simple bound shows where it is heading.
Proof. Take any term of the sum in Equation 5, which has . Split its probability as
Multiplying out the right side confirms the split, since the powers of add to and the powers of to . Because , the fraction is less than 1, and it is raised to a positive power, so the second factor is at most 1. Every term is therefore at most . Widening the sum to include every from 0 to only makes it larger, so
The sum of all the binomial coefficients is because it counts every subset of the positions, and each position is either in a subset or out of it, two choices made times. The last step writes as .
At , , whose square root is , so the bound is and each additional pair of copies cuts it by a factor of 0.36. The error falls exponentially in . That is the good news. The bad news is the rate, , which falls to zero just as surely. Table 4 shows the trade on a channel with .
Table 4. Rate and decoded error of the repetition codes on a channel with
| Code | Rate | Decoded error |
|---|---|---|
| , no code | 1 | 0.1 |
| 0.3333 | 0.028 | |
| 0.2 | ||
| 0.1429 | ||
| 0.1111 | ||
| 0.0909 | ||
| 0.0667 | ||
| 0.04 |
Source: computed from the sum for and reproduced by ch01_why_codes_exist.py.
Figure 7 draws the same trade. To reach about one error in six million bits, the repetition code needs 25 copies and runs at a twenty-fifth of the channel's raw speed.
Is that trade a law of nature? In 1948 Shannon proved that it is not [1]. Every channel has a capacity , a rate measured in bits per use of the channel, and for any rate below there exist codes whose error probability is as small as anyone wants. Error can be driven toward zero without driving the rate toward zero. For the binary symmetric channel the capacity is
where is the binary entropy function, a measure of how unpredictable the channel's flips are. At , , so . Shannon's theorem says that codes exist which run this channel at a rate of one half and still deliver as few errors as wanted, where the repetition code had to slow to a rate of to reach one error in six million.
This chapter does not prove the theorem. The chapters Information and Entropy and Capacity and Shannon's Theorem build the entropy function from first principles and prove it, and most of the rest of the book is the story of codes that close the distance between the repetition codes and the capacity line in Figure 7. That distance is the reason coding theory exists as a subject.
09.Detecting Instead of Correcting
Correcting errors is expensive. Detecting them can be very cheap. Add one bit to a block of data, chosen so that the total number of ones is even. That bit is the parity bit, and the block with it attached is a codeword of the single parity-check code. The 7-bit block 1011001 already holds four ones, an even number, so its parity bit is 0 and the codeword is 10110010. The receiver counts the ones in what arrives. An even count passes, and an odd count means something is wrong.
Proof. Each flipped bit changes the number of ones by exactly one, up or down, so it changes the count from even to odd or from odd to even. A codeword starts with an even count. After flips the count has changed between even and odd times, so it is odd when is odd and even when is even. The checker sees an odd count, and raises the alarm, exactly when is odd.
The rate of the -bit parity code is , which is for , far better than the of . In exchange it corrects nothing, because an odd count says that some bit is wrong without saying which, and it is blind to every even number of flips.
In hardware, counting ones and asking whether the count is even is a job for the exclusive-OR gate. The XOR of two bits, written , is 1 when they differ and 0 when they agree. It is binary addition with the carry thrown away, so , which is why it is also called addition modulo 2. The XOR of a whole string of bits is 1 exactly when the string holds an odd number of ones. To see why, combine the bits in one at a time. The running result starts at 0, a 0 bit leaves it alone, and a 1 bit toggles it, so it toggles once for every 1 and ends at 1 exactly when the number of ones is odd.
How often does parity miss? On , an -bit word slips through undetected when its error pattern has even, nonzero weight. Adding up those weights one by one is tedious for large , but a short argument gives a closed form.
Proof. The binomial theorem says that for any numbers and ,
It holds because multiplying out copies of means choosing either or from each copy, and the choices that take from exactly copies number , each contributing . Put and . The left side is , and the right side is the total probability of every weight, which can be split as , where collects the even weights and the odd ones. Now put and . The left side is , and on the right every odd-weight term changes sign while every even-weight term stays the same, so the sum is . Adding the two equations gives
The even weights include , the case of no error at all, whose probability is . Removing it leaves exactly the undetected errors, which is the formula.
Take , seven data bits and one parity bit, on a channel with . The probability that the word holds any error at all is . The probability of an undetected error is , and almost all of it, , comes from the weight-2 patterns alone. So about 3.41% of the corrupted words slip through, and parity catches the other 96.6%. The misses are dominated by double flips, which is why parity works best where errors are rare and isolated, and why it fails on channels where errors arrive in bursts, a problem that later Parts answer with stronger checks.
The parity tree
To compute the parity of many bits at once, hardware arranges XOR gates in a tree. Figure 8 checks the 8-bit codeword 10110010. Four gates combine the bits in pairs, two gates combine those results, and one final gate produces the parity, 0, which says the word holds an even number of ones and passes the check.
Proof. Each two-input gate takes two signals and produces one, so it reduces the number of signals still to be combined by exactly one. Starting from signals and finishing with one takes reductions, so gates, however the tree is arranged. For the depth, a tree with levels of two-input gates can combine at most inputs, because each level at most doubles the number of inputs that can reach the output. Combining inputs therefore needs , that is , and since is a whole number, . Pairing the signals at every level, with any odd one passed down unpaired, leaves signals after levels, which first reaches 1 when , so the paired tree meets the bound exactly.
For 8 inputs that is 7 gates in 3 levels, as in the figure. For a 64-bit word it is 63 gates in 6 levels, so the parity of a whole 64-bit word settles in six gate delays. The number of gates grows in step with the width, but the delay grows only with its logarithm, which is why a parity check is cheap enough to sit on every memory read.
Parity as a spare disk
Parity has a second use that turns detection into correction. Suppose the position of a bad bit is known, because the device that held it has reported a failure. A lost bit whose position is known is an erasure, and a single parity bit can fill in one erasure, since the missing bit must be whichever value makes the count of ones even.
Disk arrays use exactly this. Figure 9 shows three data disks D1, D2 and D3 holding 1011, 0110 and 1100, and a parity disk P that holds their bitwise XOR,
Working column by column, the first bits are 1, 0 and 1, which hold two ones, so the first parity bit is 0. The second and third columns also hold two ones each, and the last column, 1, 0 and 0, holds one, so the last parity bit is 1. When D2 fails, its contents are rebuilt from the survivors.
which is D2 exactly. The reason is that XOR cancels itself. For any bit string , is all zeros and , and XORs can be taken in any order, so in every surviving disk appears twice and cancels, leaving .
The same parity bit that could only detect one error can correct one erasure. Knowing where the damage is makes it far easier to repair, a fact that returns in force with Reed–Solomon codes, which correct twice as many erasures as errors.
10.Detect and Resend, or Correct
A detected error still has to be dealt with. If the receiver can talk back to the sender, the simplest answer is to ask for the data again. This is automatic repeat request, or ARQ. The receiver checks each frame, a block of bits sent as one unit, and when the check fails it asks for the frame to be sent again. Many network and bus protocols work this way.
How much does resending cost? Suppose a frame arrives clean with probability , and attempts succeed or fail independently. Let be the expected number of transmissions per frame. The first attempt is always made. With probability it succeeds and the count stops at 1. With probability it fails, and the process starts over having already spent one transmission. So
and collecting the terms in gives , so and .
Take a 1000-bit frame on a channel with . It arrives clean with probability , so on average transmissions are needed, about 10.5% more than a perfect channel would need. The calculation assumes that the check catches every corrupted frame. It does not quite, as the parity calculation showed, which is why real protocols use checks far stronger than a single parity bit.
ARQ needs two things that a channel does not always offer. It needs a path back to the sender, and it needs time for the round trip. A spacecraft billions of kilometers away waits hours for a reply. A broadcast has no single sender to ask. A disk that stored a bit wrongly years ago cannot be asked what it meant to store, because reading it again returns the same wrong bit. In those cases the receiver must repair errors itself, from redundancy sent in advance, which is forward error correction, or FEC.
Modern systems often combine the two. PCI Express 6.0 corrects the common errors in each flit, its fixed-size unit of transfer, with a light forward error correcting code, and catches the rarer ones with a cyclic redundancy check and a retry [7]. The chapter Error-Control Strategies and Performance compares the strategies properly, including what each one does to delay.
11.Where Codes Live
Codes are everywhere a bit can be damaged, which is everywhere. Table 5 lists some of the systems this book visits, and every code in it is built and analyzed in a later Part.
Table 5. Codes in deployed systems
| System | Code | What the code does |
|---|---|---|
| Server memory | SEC-DED Hsiao code, 64 data bits stored in 72 | Corrects any single flipped bit in a word and detects any double |
| QR codes | Reed–Solomon, at levels L, M, Q and H | Restores about 7, 15, 25 or 30 percent of the codewords of a damaged symbol |
| Ethernet | CRC-32 on every frame, RS(544,514) on fast links | Detects corrupted frames and corrects symbol errors on the line |
| PCI Express 6.0 | Light FEC on each flit, plus CRC and retry | Corrects the common errors at once and resends the rest |
| 5G mobile radio | LDPC codes for data, polar codes for control | Carries data at rates close to the capacity limit |
| Deep-space links | CCSDS convolutional, Reed–Solomon, turbo and LDPC codes | Recovers faint signals across interplanetary distances |
| Quantum computers | Surface codes | Protects fragile quantum states from continual noise |
Source: Hsiao [8], ISO/IEC 18004 [9] and DENSO WAVE [10], IEEE 802.3 [11], PCI-SIG [7], 3GPP TS 38.212 [12], CCSDS 131.0-B-5 [13], Fowler and colleagues [14].
The table runs from the simplest ideas of this chapter to the frontier. The memory code refines the Hamming codes of Part II. The CRC is a cyclic code built on polynomial arithmetic. Reed–Solomon codes [15] rest on finite fields. LDPC and polar codes come from the modern theory of codes on graphs and of channel polarization, and surface codes carry the whole subject into quantum mechanics. Each one is a different answer to the trade this chapter met in its simplest form, how much reliability a given amount of redundancy can buy, and how cheaply hardware can deliver it.
12.Looking Ahead
This chapter used probability informally, multiplying the chances of independent events and adding the chances of events that exclude each other. The next chapter, Probability for Coding, makes those rules precise and adds the tools the rest of Part I needs, among them random variables, expectation and the binomial distribution behind every table above. Channels, Signals and Likelihoods replaces the binary symmetric channel with the noisy voltages it stands for, and shows how a receiver turns a voltage into a bit and a measure of confidence in it.
Information and Entropy defines the entropy function that appeared in the capacity formula, and the two chapters after it, Source Coding and Prefix Codes and Compression in Practice, show what entropy means for squeezing redundancy out of data before a channel code puts redundancy back in. Capacity and Shannon's Theorem then proves the result previewed here. Distance, Detection and Correction turns the Hamming distance of the cube picture into the single number that decides what any code can detect and correct, and Error-Control Strategies and Performance compares detection, correction and retransmission properly. The Part ends with a case study of codes in deployed systems, a project that builds a channel simulator, and a lab that runs the companion repository's parity checker as hardware in simulation.
Two textbooks cover this ground at greater length, Lin and Costello [16] and MacKay [17], whose first chapter also starts from the repetition code. The reader who has worked through this chapter can now compute the chance of an error over any number of bits, decode the repetition code by hand and by circuit, prove its error probability, and explain why parity detects odd numbers of errors and misses even ones.
13.Worked Examples
14.Exercises
References
- [1]Shannon, Claude E. (1948). “A Mathematical Theory of Communication.” Bell System Technical Journal, 27(3), pp. 379–423. The paper concludes in the October issue, volume 27, number 4, pages 623 to 656. doi:10.1002/j.1538-7305.1948.tb01338.x
- [2]Hamming, Richard W. (1950). “Error Detecting and Error Correcting Codes.” Bell System Technical Journal, 29(2), pp. 147–160. doi:10.1002/j.1538-7305.1950.tb00463.x
- [3]May, T. C. and Woods, M. H. (1979). “Alpha-Particle-Induced Soft Errors in Dynamic Memories.” IEEE Transactions on Electron Devices, 26(1), pp. 2–9. doi:10.1109/T-ED.1979.19370
- [4]Ziegler, J. F. and Lanford, W. A. (1979). “Effect of Cosmic Rays on Computer Memories.” Science, 206(4420), pp. 776–788. doi:10.1126/science.206.4420.776
- [5]Schroeder, Bianca and Pinheiro, Eduardo and Weber, Wolf-Dietrich (2009). “DRAM Errors in the Wild: A Large-Scale Field Study.” In Proceedings of the Eleventh International Joint Conference on Measurement and Modeling of Computer Systems (SIGMETRICS '09), pp. 193–204. doi:10.1145/1555349.1555372
- [6]von Neumann, John (1956). “Probabilistic Logics and the Synthesis of Reliable Organisms from Unreliable Components.” In Automata Studies, pp. 43–98. doi:10.1515/9781400882618-003
- [7]PCI-SIG (2022). “PCI Express Base Specification, Revision 6.0.” https://pcisig.com/specifications
- [8]Hsiao, M. Y. (1970). “A Class of Optimal Minimum Odd-weight-column SEC-DED Codes.” IBM Journal of Research and Development, 14(4), pp. 395–401. doi:10.1147/rd.144.0395
- [9]ISO/IEC (2015). “Information Technology, Automatic Identification and Data Capture Techniques, QR Code Bar Code Symbology Specification.” ISO/IEC 18004:2015. https://www.iso.org/standard/62021.html
- [10]DENSO WAVE “Error Correction Feature.” QRcode.com. Read 2026-11-13. https://www.qrcode.com/en/about/error_correction.html
- [11]IEEE (2022). “IEEE Standard for Ethernet.” IEEE Std 802.3-2022. IEEE. doi:10.1109/IEEESTD.2022.9844436
- [12]3GPP (2017). “NR; Multiplexing and Channel Coding.” 3GPP Technical Specification 38.212. First issued in Release 15; later releases revise it. https://www.3gpp.org/dynareport/38212.htm
- [13]Consultative Committee for Space Data Systems “TM Synchronization and Channel Coding.” CCSDS 131.0-B-5, Blue Book. Issue 5. https://public.ccsds.org/Pubs/131x0b5.pdf
- [14]Fowler, Austin G. and Mariantoni, Matteo and Martinis, John M. and Cleland, Andrew N. (2012). “Surface Codes: Towards Practical Large-Scale Quantum Computation.” Physical Review A, 86(3), pp. 032324. doi:10.1103/PhysRevA.86.032324
- [15]Reed, Irving S. and Solomon, Gustave (1960). “Polynomial Codes over Certain Finite Fields.” Journal of the Society for Industrial and Applied Mathematics, 8(2), pp. 300–304. doi:10.1137/0108018
- [16]Lin, Shu and Costello, Jr., Daniel J. (2004). “Error Control Coding: Fundamentals and Applications.” 2nd edition. Pearson Prentice Hall.
- [17]MacKay, David J. C. (2003). “Information Theory, Inference, and Learning Algorithms.” Cambridge University Press. The author's site offers the whole book free to read on screen. https://www.inference.org.uk/itila/book.html
— Anirban
Hardware–software at the seam where compilers meet microcode.