The Extra Bits Beside a Memory Word

A memory controller can infer which bit changed by comparing several checks over the same data. The extra bits let it correct some errors, signal others and recognize the limits of what it knows.

Rear view of a Samsung DDR4 registered ECC memory module
In this story 5 sections

A row of dark components follows the length of the circuit board in the photograph. Along the lower edge a strip of contacts is interrupted by a notch. Small printed numbers and traces are hard to see against the green. It looks recognizably like a memory module. The file's description identifies it as an eight gigabyte Samsung DDR4 registered module with error-correcting code support, commonly shortened to ECC. The detail that makes the module relevant here is not something a camera can show directly. Some of the information it helps store is there to check other information later.

Imagine a computer writing a small group of bits to memory. When it reads the group again, most of the time it sees the values it wrote. If one changes, the device could check the group against a separate copy, provided it had such a copy and knew which one to trust. ECC takes another approach. In a common arrangement there are enough additional bits to answer carefully chosen questions about the word. Their answers did not have to be learned from another complete copy. The controller calculated them from the original write. When the word comes back, a pattern of agreement and disagreement can reveal more than the simple fact that something went wrong.

One question can reveal that a group changed

Start with a row of four bits whose values are one, zero, one and one. It contains three ones. A simple even parity scheme stores an additional one, making the total number of ones even when all five positions are counted. The act of recording parity gives the reader a test to perform. If the third position has changed from one to zero, the overall count is now odd. The row no longer satisfies the test. The reader can detect that something is wrong without having the original four data bits in another place.

But stop there and there is no evidence isolating the third position. Any single bit in that row, including the check bit itself, would change the total from even to odd if it changed its value. A second change would take an odd count back to an even one; a single parity question would miss those two changes. A small extra record can be very useful even though the conclusions it supports are limited. Asking whether the total is even answers exactly one question. It does not supply clues about which of several positions have the wrong value.

A paper comparison brings the difficulty out. A clerk tallies the number of folders in a drawer on Friday and returns to find one fewer on Monday. The tally gives good reason to look for a missing folder. It cannot name the missing file. If one original folder left and another appeared, the total might match exactly. It would take additional records, arranged differently, to distinguish those outcomes. In memory there is a compact way to arrange additional checks so that the location of a small change leaves a recognizably different pattern.

Several questions can narrow it down

Suppose different questions apply to overlapping subsets of positions. One particular bit might be included in the first and second questions but not the third. Another might be in the first and third, but not the second. A third might appear in all three. If one bit has changed, the reader can compare which tests fail individually. One and two fail together in the first case. One and three fail in the second. All three fail in the last. Assign different patterns of participation to different positions and a single changed value has a telltale signature. The check positions need protection as well; a real scheme has to account for them and for the size of the whole group.

This is a way to understand checks based on the family of Hamming codes without tracing a particular controller's implementation. The reader can infer both whether the current bits satisfy the rules and what one-position change could restore agreement if a single bit was affected. Under that assumption it knows which binary value to flip back. It can supply the recovered result to the operation that asked for it. There is no need for the program to know or manage the check bits in an ordinary protected memory read.

The care needed is in the assumption. Two simultaneous changes can make a pattern that an unqualified test would assign to some other position. A common design deliberately adds enough information to distinguish single errors it can correct from double errors it can detect. It is often called single-error correction and double-error detection. That label describes a guarantee for a defined group of bits and error pattern. It is no guarantee of correcting arbitrary damage, and there are other codes with different guarantees. A successful case is best understood precisely: given a particular protected group and a change within the code's correction ability, the checker can recover the intended data.

The word and its checks travel together

At the point of writing data, the checking logic computes the redundant information and stores it with its group. At the point of reading, it checks the received values for consistency. In a familiar example a path handling a group of sixty-four data bits can carry additional check bits as well. That extra storage is overhead from the application's point of view. The application did not ask to save a slightly longer number, and it does not become entitled to use the check positions to store part of a different variable. They have a job assigned by the memory system.

This is one reason the memory controller and the surrounding platform matter. A module can provide a path for extra bits while the platform determines whether the checking scheme is supported and active. The module in the photo is specifically registered, a property related to how signals reach the memory devices and distinct from protecting stored data with a code. A close view of a board can be evidence for the name of the type pictured. Counting packages on it without reading its specifications and the platform information is a poor way to establish whether a particular computer actually corrects any data.

Do not confuse the external relationship with checks that may occur inside newer memory chips. An internal scheme can improve the reliability of values held inside the chip. Its reach and reporting are not necessarily the same as protection from the memory controller to a module and back. Before treating two products as equivalent because both use the word ECC, ask which section is covered and what happens when a check finds an error it cannot correct. The region matters because a correct internal read cannot retrospectively vouch for a value damaged somewhere else along a longer path.

Corrected and uncorrectable give the operator different information

Suppose a system reads a group whose one misread bit falls within the code's correction ability. Its program can receive the value it expected. The system may additionally record a correction so that a person maintaining it has evidence something happened. A single correction on an isolated occasion is a different observation from frequent corrections associated with one part of a system. The records can help somebody investigate a pattern without asking application users to identify which number in their own work might have been affected.

If an error is detected but cannot be corrected, the situation changes. The record does not provide enough information to recover the original word with the stated guarantee. A system can respond by reporting an error or interrupting work in accordance with its design. It need not pretend that a damaged word is valid. The response tells the maintainer about a detected failure, rather than what the correct answer must have been. Looking at an event log without distinguishing the categories can make a successfully recovered read seem as consequential as one for which no answer was safe to give.

The checking code also has a boundary in time. It is calculated from the value the system writes. If a program sends the wrong number in the first place, the check can be perfectly valid for that wrong number. Likewise, when a correct value leaves the protected memory path, whatever uses it next has its own responsibility for what happens to it. Reliability comes from knowing what one layer can check and using other checks for the layers it cannot reach.

What is hidden in the extra space

Look back at the compact board. For someone comparing capacity, a check bit looks like space that could have been devoted to another byte of usable memory. For someone investigating the result of a read, it may be the difference between being able to locate a change and having no independent evidence to go on. The designer has set aside room for questions whose answers can be tested later.

That is useful precisely because the questions are narrow. One parity test can expose a mismatch; several related tests can locate a defined kind of change. A broader code can distinguish more cases at a greater cost in extra information and logic. The most important label beside the memory capacity is therefore less a grand assurance of perfect data than a description of the errors the system can actually recognize, and in some cases repair.

Further reading