Hamming Code & SECDED ECC Memory Parity Bit Overhead Calculator

Find required ECC parity bits for 8-bit, 32-bit, 64-bit, or custom data words.

SECDED ECC Parity Bits Required 8 bits
Single-Error Hamming Bits (r) 7 bits
Total Encoded Codeword Length 72 bits
Code Rate Efficiency (m / n) 88.89 %
Inputs
Try:
bits
Number of payload data bits per word (m, e.g., 64 bits for DDR ECC).
Results & Graph
SECDED ECC Parity Bits Required
8 bits
Single-Error Hamming Bits (r)
7 bits
Total Encoded Codeword Length
72 bits
Code Rate Efficiency (m / n)
88.89 %

SECDED ECC Parity Bits Required

Graph 1 • How the inputs feed Hamming Code & ECC Bits
Hamming Code & SECDED ECC Memory Parity Bit Overhead Calculator • Custom Domain Schematic (Networking & Digital Systems) dataWordx₂Out Data Word Bits M: 64 bits SECDED ECC PARITY BITS REQ 8 bits • Single-Error Hamming B: 7 bits • Total Encoded Codeword: 72 bits Eq: Find smallest r where 2^r ≥ m +
Graph 2 • SECDED ECC Parity Bits Required as Data Word Bits M changes (40% to 160% of current)
0 bits 7.04 bits 14.08 bits 3.20 25.60bits 4.80 38.40bits 6.40 51.20bits 8 64bits 9.60 76.80bits 11.20 89.60bits 12.80 102.4bits
Graph 3 • Hamming Code & ECC Bits across a range of inputs Shows how SECDED ECC Parity Bits Required responds across ±30% scenario shifts.
0 bits 5.72 bits 11.44 bits 5.60 -30% 6.80 -15% 8 +0% 9.20 +15% 10.40 +30%
Summary: Protecting a 64-bit data word requires 7 Hamming bits + 1 overall parity bit = 8 SECDED bits (72-bit codeword, 88.89% code rate).
Summary: Protecting a 64-bit data word requires 7 Hamming bits + 1 overall parity bit = 8 SECDED bits (72-bit codeword, 88.89% code rate).
Interactive chart & math engine powered by CalculatorGraph

Formula: Hamming Code & ECC Bits Systems Engineering Formula

Find smallest r where 2r ≥ m + r + 1
SECDEDBits = r + 1
CodeRate = m / (m + r + 1)
Find smallest r where 2^r ≥ m + r + 1; SECDED_Bits = r + 1; CodeRate = m / (m + r + 1)
  • dataWordBitsM: Data Word Bits M (bits)

Frequently Asked Questions

Why do 64 and 96 data bits both need 8 SECDED bits?

Seven Hamming bits give 2^7 syndromes, enough for any data word up to 2^7 minus 8 bits once the 7 parity positions and the no error case are counted. Both 64 and 96 fall inside that range, so both need 7 Hamming bits and 8 SECDED bits. The wider word just uses the syndromes more fully, so its code rate rises from 88.89% to 92.31%.

Where do the parity bits go inside the codeword?

In the classic layout they sit at positions that are powers of two: 1, 2, 4, 8, 16, 32 and 64, counting from one. Data bits fill every other position. Parity bit 1 checks every position whose binary index has its lowest bit set, parity bit 2 the next bit up, and so on. The overall SECDED bit is usually added at position zero or at the end.

Can SECDED fix a double-bit error?

No. It can detect any double error but correct only a single one. When two bits flip, the decoder sees a non-zero syndrome with correct overall parity and flags the word as uncorrectable. Correcting two or more errors needs a stronger code, such as a BCH or Reed Solomon code, with more check bits than this page calculates.

Is Hamming(7,4) the same as the 4-bit result here?

Almost. Hamming(7,4) is the pure single error correcting code: 4 data bits and 3 parity bits in a 7-bit codeword. This page adds the overall parity bit, so for 4 data bits it reports 4 SECDED bits, an 8-bit codeword and a 50% rate. Without that extra bit the rate would be 4 out of 7, about 57%.

How do I protect a bus twice as wide as 64 bits?

Enter the full width, two times 64, as the data bits. The page will report 8 Hamming bits plus 1 overall bit, 9 in all, with a code rate of about 93.43%. Alternatively you can split it into two 64-bit halves, each with 8 SECDED bits. That costs 16 check bits instead of 9, but it can correct one error in each half rather than one in the whole line.

Does ECC memory slow a computer down?

Slightly, in most systems. The controller has to compute check bits on every write and check them on every read, which can add a small delay. The page does not model timing; it only counts bits. For servers and workstations the trade is normally considered worth it, because an undetected memory error can corrupt data or crash a long job without any clue to the cause.

Why do the parity bits grow so slowly compared with the data?

Each extra parity bit doubles the number of distinct syndromes, so it doubles the number of positions the code can identify. Going from 4 to 11 data bits needs one more parity bit, and so does going from 57 data bits to the r = 7 limit at 2^7 minus 8. Parity cost rises roughly with the base-two logarithm of the word length, which is why wide words are so much more efficient.

What does a code rate of 88.89% mean in practice?

It means 88.89% of the stored bits are your data and 11.11% are check bits. For a memory system, a module built to hold a given amount of usable data needs about 12.5% more raw storage. For a communications link, it means about 11% of the transmitted bits carry no new information and exist only to catch and fix errors.

Can I use this for error correction in data transmission?

You can use it to size a Hamming code for short frames, and some simple serial links and sensor protocols do exactly that. Most modern radio and network links use far stronger codes, such as convolutional, LDPC or Reed Solomon codes, because channel noise tends to cause bursts of errors. Hamming codes are best suited to rare, isolated bit flips.

What range of word sizes does the page accept?

Whole numbers of data bits, from 1 up to a cap of a few thousand. A fraction such as 12.5, a zero or a negative value returns an error rather than being rounded. At 1 bit the code needs 2 Hamming bits plus the overall bit, a 4-bit codeword at only 25% efficiency, which shows how badly tiny words pay for protection.

The 64-bit default and the 72-bit memory word

This calculator takes a single input, the number of data bits you want to protect, and tells you how many check bits a Hamming code needs. The default is a 64-bit word, and the answer is 8 SECDED bits: 7 Hamming parity bits plus 1 overall parity bit. The total codeword is 72 bits, and 88.89% of it is data.

That 72-bit figure will be familiar to anyone who has bought server memory. ECC memory modules carry 72 data lines instead of 64, and the extra eight are there for exactly this kind of single error correction, double error detection scheme. The default is a direct model of that design.

Put another way, protecting 64 bits costs 12.5% more storage than leaving them bare. Whether that is worth it depends on how much a silent bit flip would cost you, which is a decision the page leaves to you.

Solving 2^r ≥ m + r + 1 for 64 data bits

A Hamming code places r parity bits among the data bits. Each parity bit checks a different subset of positions, and when an error occurs the pattern of failed checks, called the syndrome, spells out the position of the bad bit in binary. With r check bits there are 2^r possible syndromes. One of them must mean no error, and each of the other m + r positions needs a syndrome of its own. That is where the condition 2^r ≥ m + r + 1 comes from.

For 64 data bits, try r = 6 first. 2^6 is 64, but the code needs 64 + 6 + 1, which is 71 distinct syndromes, so six is not enough. Try r = 7. 2^7 is twice 64, comfortably above the 64 + 7 + 1 = 72 required. So the smallest workable r is 7, matching the page.

The calculator then adds one more bit, the overall parity across the whole codeword, to reach 8. That extra bit is what turns a single error correcting code into SECDED.

What the extra SECDED bit buys

A plain Hamming code can correct any single flipped bit. Its weakness is two flipped bits: the syndrome then points at a third position that was fine, and the decoder confidently corrupts it while trying to fix things. The data comes out wrong with no warning.

The overall parity bit catches that case. If one bit has flipped, the overall parity is wrong and the syndrome is non-zero, so the decoder corrects the bit the syndrome names. If two bits have flipped, the overall parity comes out right again while the syndrome is still non-zero. That combination means a double error, and the decoder reports it as uncorrectable instead of making it worse.

In a memory system that report usually triggers a machine check or a logged fatal error. It is far better to stop than to carry on with silently altered data, which is why SECDED is the normal choice for memory rather than plain Hamming.

Decoding a single flipped bit step by step

It helps to see what the check bits actually do once a word is stored. Take the 64-bit default. When the word is written, the controller computes the 7 Hamming bits and the overall parity bit from the data and stores all 72 bits together. When the word is read back, it recomputes the 7 checks from what it reads and compares them with the stored ones.

If nothing has changed, every check agrees and the syndrome is zero. If one bit has flipped, some of the checks disagree, and reading the disagreeing checks as a 7-bit binary number gives the position of the flipped bit. Flipping that bit back restores the original data, and the overall parity confirms that only one bit was involved. The whole process is a handful of exclusive OR gates, which is why hardware can run it on every memory access.

The same logic covers errors in the check bits themselves. A flipped parity bit produces a syndrome pointing at its own position, so it gets corrected like any other bit. Nothing in the 72-bit word is unprotected.

The word sizes where a parity bit fits exactly

Because parity bits grow so slowly, there are sweet spots where the inequality is met exactly and no syndrome is wasted. With r = 3 you can protect up to 4 data bits; with r = 4, up to 11; with r = 5, up to 26; and with r = 6, up to 57. With r = 7 the limit is 2^7 minus 8, which leaves room for nearly twice the 64-bit default. Those are the classic perfect Hamming sizes.

Run them through the page and the efficiency jumps at each one. At 11 data bits the codeword is 16 bits with a 68.75% code rate. At 26 it is 32 bits and 81.25%. At 57 it is 64 bits with an 89.06% rate, slightly better than the 64-bit default. At that r = 7 limit the rate climbs to 93.75%.

One bit past each of those boundaries, the cost steps up. 12 data bits need five Hamming bits where 11 needed four. 58 data bits need seven where 57 needed six. If you are free to choose your word size, landing on or just under one of those perfect sizes gives the most protection for the least overhead.

Small words pay heavily: 8, 16 and 32 bits

Overhead falls as words get longer because the parity count grows with the logarithm of the data size. That is good news for wide memory buses and bad news for small ones.

Protecting a single 8-bit byte needs 4 Hamming bits plus the overall bit, 5 in all. The codeword is 13 bits and only 61.54% of it is data. A 16-bit word needs 6 check bits for a 22-bit codeword at 72.73%. A 32-bit word needs 7, a 39-bit codeword at 82.05%. The 64-bit default does much better at 88.89%, and the 96-bit preset, still with only 8 SECDED bits, reaches 92.31% over a 104-bit codeword.

This is why memory systems protect wide words rather than individual bytes. Applying SECDED to each byte of a 64-bit bus separately would need 40 check bits instead of 8. It also explains why a design that reads 32 bits at a time often groups two reads into one protected 64-bit word.

The 38-bit preset and odd-sized fields

Not every protected field is a power of two. Registers, packet headers and configuration words often have awkward widths, and the 38-bit preset is a good example. It needs 6 Hamming bits plus 1 overall bit, 7 in total, for a 45-bit codeword at 84.44%.

Check it by hand. With r = 5 you get 32 syndromes but need 38 + 5 + 1, which is 44, so five falls short. With r = 6 you get 64 syndromes against 45 needed, so six works. The page agrees.

When the field is a little over a boundary, consider whether a few bits can move elsewhere. Trimming a 58-bit field to 57 saves a whole Hamming bit. In silicon that is one less wire and one less column of storage across every row, which adds up in large memories.

Reading the code rate line correctly

The code rate is data bits divided by the total codeword, and on this page the total includes the SECDED bit. So the default rate is 64 divided by 72, 88.89%. If you plan to use plain single error correction without the overall parity bit, the codeword is one bit shorter and the rate is slightly higher, 64 out of 71 in the default case.

Overhead is simply the other side of the same coin. A rate of 88.89% means 11.11% of the stored bits are check bits, or, measured against the data, 12.5% extra. People quote both, so be clear which you mean when comparing schemes.

Rate also says nothing about strength. Two codes with the same rate can differ a great deal in what errors they survive. The Hamming family is tuned for isolated single flips and nothing more.

Burst errors, whole chips and inputs to avoid

SECDED assumes errors are rare and independent: one flipped bit in a word, occasionally two. That suits random soft errors from radiation. It does not suit a burst that wipes out several neighbouring bits, or a memory chip that fails outright and corrupts every bit it supplies. Server platforms address that with symbol based codes that can survive a whole failed chip, which this page does not model.

Real memory controllers also rarely use the textbook Hamming layout. They often use variants such as Hsiao codes, which keep the same number of check bits but arrange them for faster, more balanced hardware. The bit counts on this page still apply.

On inputs: the page accepts whole numbers of data bits from 1 up to a cap of a few thousand, and returns an error for anything else, including fractions and zero. Near the top of that range the overhead almost vanishes, with a code rate above 99%, though a single error correcting code over so wide a word would be a poor design, because the chance of two errors in one word grows with its length.