Sunday 8 July 2012

Parity Check


How they work: parity checks in computer memory


Computers have internal checks to ensure they are working correctly. This article covers checks using a scheme called parity bits to ensure that the computer’s memory is accurate. 
It is important for the computer to know of memory failures, to avoid operating on bad data. An undetected memory failure could be catastrophic. Memory is hardware and does fail from time to time. This article is the second in the series on memory. 
 
Parity’s purpose
Memory parity is what helps the computer system detect that its memory has failed. If there is a problem with memory and the value of memory changes, parity can detect the problem and stop the computer. 
 
How parity works
Recall that memory is organized in bytes, which is eight bits. I When memory is manufactured, an additional bit is added to each byte. This is called the parity bit. The actual size of each memory location is therefore nine bits, but the computer only uses eight of the nine bits for data. The parity bit is checked and never sent to the rest of the computer. 
 
Writing parity
Every time a memory address is written, the parity circuit checks each bit of the byte. It counts all 1 bits in the byte. The sum of the 1 bits results either in an even or odd number. 
 
To continue, we must know whether the designers of the memory used even or odd parity. The circuit will work either way. Let’s assume they used even parity. Stay with me; we’re almost there. 
 
The parity bit is then set to a 0 or a 1 depending on the following. 
 
·         If the sum of the 1 bits is an even number, the parity bit will be written as a 0. This keeps the parity even, or keeps the sum of all 1 bits an even number. 
·         If the sum of the 1 bits is an odd number, the parity bit will be written as a 1. This keeps the parity even, or keeps the sum of all 1 bits an even number. 
 
Reading parity
If you haven’t seen the purpose yet, keep reading. After parity is written, the sum of all the bits, including the parity bit, will be even. Then when the given address is read later, its parity is checked by summing all 1 bits including the parity bit. The result better be an even number, or there is a problem. 
 
Examples
Here are a couple of examples of memory values and their parity bits. 
 
 
Notice that the total sum of all bits for each memory value is always an even number.
 

No comments:

Post a Comment

Note: only a member of this blog may post a comment.