Dependable Memory: Soft Errors and Parity
A memory that works perfectly will still hand back a wrong bit now and then. One extra bit beside the data is enough to notice.
You Will Be Able To
- Explain what a soft error is, and why it is not a broken cell.
- Work out a parity bit, and check a word that was read back.
- Say which errors parity finds, which it misses, and where its bit is stored.
- Lesson
- S3.12
- Time
- 25 min
- Runs on
- Your browser
- Check
- 6 questions
A machine has run the same program for two years. One night a valve opens that the program never asked for. The program is unchanged, and every test of the memory passes. For a moment, one bit of one variable was different.
Before You Start
You need the SRAM of S3.15: words, a write, a read, and byte strobes.
You need the exclusive-OR gate, which says whether two bits differ.
| Question | |
|---|---|
| 1 | What is a soft error? |
| 2 | How is a parity bit worked out? |
| 3 | What does a parity check find, and what does it miss? |
| 4 | Where are the parity bits kept? |
| 5 | What can a chip do after a parity error? |
The Idea: Notice the Flip
A memory cell holds its bit with a tiny amount of charge. Now and then a particle from outside passes through the chip and leaves charge behind. If it lands on the wrong spot, a stored bit flips.
This is called a soft error. Soft, because nothing is damaged. The cell works, and the next write stores a good value again. No test of the memory will ever find the cell. A cell that is truly broken gives a hard error, and that is a different problem.
Soft errors are rare for one cell. A chip has millions of cells, and a product runs for years. So for some products they are certain to happen.
The simplest defence is one more bit for each word: a parity bit. At the write it is set so that the word and the bit together hold an even number of ones. This is even parity.
At every read, the ones are counted again. One flipped bit makes the count odd. That is a parity error. The memory cannot say which bit is wrong. It can say that the word is not to be trusted.
The parity bit is a check bit: a stored bit that carries no data and exists only to check the others. It lives in the same word as the data, in an extra column of the memory.
New Words
| Word | Meaning |
|---|---|
| Soft error | A stored bit that flips by itself, because a particle hit the chip. Nothing is damaged. |
| Hard error | A wrong bit from a cell that is broken. It comes back after every write. |
| Check bit | A stored bit that carries no data. It exists to check the data bits. |
| Parity bit | One check bit that makes the number of ones in a word even. |
| Even parity | The rule that data and parity bit together hold an even number of ones. |
| Parity error | A read that finds an odd number of ones. At least one bit has flipped. |
| Error injector | A way for a test to flip a stored bit on purpose. In the lab it is the task hit. |
One Picture: Count at the Write, Count Again at the Read
- Processor
- Control / FSM
- Memory
- Bus
- At the write: count
The data has four ones. That is even, so the parity bit is 0. With an odd count it would be 1.
- Stored side by side
The memory is one bit wider than the data. The parity bit is written by the same write, into the same word.
- A clean read
The read counts the ones of all nine bits. The count is even, as it was made to be. The data is accepted.
- A particle hits
Some time later one stored bit flips. Nothing is broken. The cell simply holds the other value now.
- The read after the hit
The count of ones is odd now. The check cannot say which bit flipped. It can say that this word must not be used.
Read the diagram as text
- Write: data 1011_0010
- Count the ones: four: even, so the bit is 0
- Stored word: 8 data bits and 1 parity bit
- Particle: flips one stored bit
- Count again: all nine bits
- Parity error: the count is odd
- Read data: the count is even
- Write → Count the ones: data
- Count the ones → Stored word: data and bit
- Particle → Stored word: flip
- Stored word → Count again: nine bits
- Count again → Read data: even
- Count again → Parity error: odd
Parity turns silent wrong data into a known error. It does not bring the right data back.
The Smallest Example, Worked by Hand
Two bytes are written, and each gets its parity bit. Then each takes a hit.
| Step | Data | Parity bit | Ones in all nine bits | The check says |
|---|---|---|---|---|
| write 1011_0010 | 1011_0010 | 0 | 4: even | |
| write 0000_0111 | 0000_0111 | 1 | 4: even | |
| bit 3 of the first byte flips | 1011_1010 | 0 | 5: odd | parity error |
| the parity bit of the second flips | 0000_0111 | 0 | 3: odd | parity error |
A flip of the parity bit itself is found too. The data is fine in that case, and the check cannot know that.
In hardware the count is a chain of exclusive-OR gates. The exclusive-OR of all bits is 1 exactly when the number of ones is odd. So the parity bit is the exclusive-OR of the data bits, and the check is the exclusive-OR of all nine.
Now the cost. A word of 32 bits with one parity bit is 33 bits wide. With one parity bit for each byte it is 36 bits wide. The SRAM of ap_soc has 16,384 words, so that choice adds 65,536 bits.
The Rules
Rule 1: A soft error flips a stored bit and damages nothing.
The next write of that word stores good bits again.
Rule 2: The parity bit is the exclusive-OR of the data bits.
Data and parity bit together then hold an even number of ones.
Rule 3: Every read checks all the bits, the parity bit too.
An odd count is a parity error.
Rule 4: Parity finds any odd number of flips, and misses any even number.
One flip is found. Two flips in one word pass.
Rule 5: Parity cannot repair.
It does not know which bit flipped. The right data must come from somewhere else.
Rule 6: The check bits live beside the data.
They are written by the same write, read by the same read, and hit by the same particles.
Sources for These Rules
The textbook "CMOS VLSI Design" by Weste and Harris, section 7.3.4, "Soft Errors". It describes random errors that do not recur. They were first traced to alpha particles, and today most come from neutrons of cosmic radiation.
The textbook "Computer Organization and Design" by Patterson and Hennessy, section 5.5. See the part on parity: one bit makes the count of ones even, one flipped bit is found, and two are not.
Even parity is a choice. Odd parity works the same way with the opposite bit.
Now Run It
The lab at the end of this page is test code. It has a memory of four words. A word is 9 bits wide: 8 data bits and a parity bit. The task hit is the error injector.
write 0 | data 10110010 | parity bit 0 | stored 0_10110010
write 1 | data 00000111 | parity bit 1 | stored 1_00000111
read 0 | stored 0_10110010 | the ones are even | data 10110010 accepted
read 1 | stored 1_00000111 | the ones are even | data 00000111 accepted
hit 0 | bit 3 flips | stored 0_10111010
read 0 | stored 0_10111010 | the ones are odd | parity error: the data is not used
hit 1 | bit 8 flips | stored 0_00000111
read 1 | stored 0_00000111 | the ones are odd | parity error: the data is not used
reads=4 parity_errors=2Rule 2 at work: rows 1 and 2. Four ones give a parity bit of 0. Three ones give 1.
Rule 3 at work: rows 3 and 4. Both words are read back with an even count, and are accepted.
Rules 3 and 4 at work: rows 5 and 6. One data bit flips, the count is odd, and the read refuses the data.
Rule 6 at work: rows 7 and 8. The particle hits the parity bit itself. The data is right, and the read still refuses it.
This lab stops at "the data is not used". What a chip does next depends on whether another copy exists. That is in At Scale, and in S3.28.
Why It Is Built This Way
| Design choice | The alternative | What the choice buys, and costs |
|---|---|---|
| A parity bit | No check at all | A flipped bit is noticed and not used. One more bit in every word, and a tree of gates in every read. |
| One bit for each byte | One bit for a whole word | A write of one byte renews only its own bit. Two flips in different bytes are both found. Four bits a word. |
| Check bits in the same word | A separate memory for them | One access reads both. A particle can hit them as well. |
| Detect only | Detect and repair | Very little logic. The data must be fetched again from somewhere, or the system must stop. |
The Trap: Two Flips in One Word
A team protects its SRAM with parity and calls the memory safe. One word is written and then left alone for a long time. It is hit twice before anyone reads it.
write 0 | data 10110010 | parity bit 0 | stored 0_10110010
hit 0 | bit 3 flips | stored 0_10111010
hit 0 | bit 6 flips | stored 0_11111010
read 0 | stored 0_11111010 | the ones are even | data 11111010 acceptedThe last row is the failure. The data is 1111_1010, and 1011_0010 was written. The count of ones is even again, so the read accepts it.
Parity did nothing wrong. Rule 4 says what it can see. Two flips in one word are rare, and they grow less rare the longer a word waits.
So parity fits memories that are rewritten often, or that hold copies. A memory that holds the only copy for a long time needs more: the next lesson.
At Scale
This section looks ahead. Every large memory is protected, and the kind of memory decides how.
After a parity error
A cache of code can drop the block and fetch it again. A memory with the only copy can only raise an alarm. Common practice.
Repair
A few more check bits can name the flipped bit, so that the read repairs it: the next lesson.
Height matters
There are far more neutrons at the height where aircraft fly than at sea level. Weste and Harris, section 7.3.4.
Wires too
A bit can also flip on its way over a bus. Buses can carry parity bits of their own: APB parity protection.
Try It
Run the lab. Check each parity bit by counting ones.
Add a second hit on word 0 before its last read. Predict the row.
Change the memory to odd parity. Which two lines change?
write 0 | data 10110010 | parity bit 0 | stored 0_10110010 write 1 | data 00000111 | parity bit 1 | stored 1_00000111 read 0 | stored 0_10110010 | the ones are even | data 10110010 accepted read 1 | stored 1_00000111 | the ones are even | data 00000111 accepted hit 0 | bit 3 flips | stored 0_10111010 read 0 | stored 0_10111010 | the ones are odd | parity error: the data is not used hit 1 | bit 8 flips | stored 0_00000111 read 1 | stored 0_00000111 | the ones are odd | parity error: the data is not used reads=4 parity_errors=2Check Yourself
Common Mistakes
Wrong Call a memory with parity error-free.
Two flips in one word leave the count even, and pass.
Fix Say what it finds: any odd number of flips in a word.
Wrong Leave the parity bit out of the check.
Then the check compares nothing. The stored bit is what makes the count even.
Fix Take the exclusive-OR of the data bits and the parity bit together.
Wrong Hunt for a broken cell after a soft error.
Nothing is broken. The next write heals the word.
Fix Count the errors. A cell that fails again and again is a hard error.
Remember
- A soft error is a flipped bit in a working cell. A product with much memory and long use will meet some.
- A parity bit makes the count of ones even. An odd count at a read is a parity error.
- Parity finds an odd number of flips and misses an even number. It cannot repair.
- Check bits are stored beside the data, in a wider word.