2 views

Uploaded by Isak Foshay

.

- Article NewSecurityConcept 0208
- Sol 10
- 901325_chapter 10
- ch10-SLIDE-[2]Data Communications and Networking By Behrouz A.Forouzan
- 05606257
- OGLGeomBench
- Section Overheads
- our.docx
- dfd and er
- UART Synopsys Carried Out by Gowrav
- Py Qt 5 Tutorial
- Format
- IP architecture
- Channel Report
- IDOC_AAE To File with all Configurations _ SCN.pdf
- RLC_LTE_36
- Chapter 3_digital Transmission Fundamentals
- Answers 4
- High Speed DP SRAM Datasheet
- 8_Bits

You are on page 1of 27

How to use them for error detection.

How to use them for single bit error correction.

Outline

• History

• Calculation

• Using Hamming codes for single bit error correction

• data bits

• parity bits

History: briefly

Cycle time in

seconds!!!

Richard Hamming worked at Bell Labs in the 1940s on the Bell Model V

computer, an electromechanical relay-based machine with cycle times in

seconds. Input was fed in on punched cards, which would invariably have read

errors. During weekdays, special code would find errors and flash lights so the

operators could correct the problem. During after-hours periods and on

weekends, when there were no operators, the machine simply moved on to

the next job.

Hamming worked on weekends, and grew increasingly frustrated with having

to restart his programs from scratch due to the unreliability of the card reader.

Over the next few years, he worked on the problem of error-correction,

developing an increasingly powerful array of algorithms. In 1950, he published

Punch card (not actual size).

what is now known as Hamming Code, which remains in use today in

applications such as ECC memory.

Credit to Wikipedia

R. Jesse Chaney 3 CS271 – Oregon State University

Calculation

There is a lot of theory behind how the Hamming codes work. There are

numerous books and web pages that describe the theory.

I’m going to go very light on the theory and just jump into the calculation and

use of Hamming codes to correct single bit errors.

That aside, though there a large number of examples Hamming Code use on

the internet, I never found a step-by-step example that quite fit with how we

have described Hamming Codes in this class.

Start with a number

We are going to start with a number. We’ll use 8-bit numbers (0-255)

for this example. We could use any number, but I’ll select:

154

it uses the left most bit in its 2-byte representation as a binary number.

Convert to binary

Next, we are going to convert the number 154 into its unsigned binary representation.

154 1 0 0 1 1 0 1 0

distinguish the bits in the left byte from the bits in the right byte, I’ve

colored them. All together, I’ll call these bits the data bits.

Don’t forget the (+ 1) part.

Now, we’ll introduce the location of the parity bits.

For 8 bits of data (2 bytes), the Hamming code must contain (log2 n) + 1 or parity bits. For

our example, 8 bits of data, that’s 4 parity bits.

A parity bit, or check bit, is a bit

added to a string of binary code

154 1 0 0 1 1 0 1 0 Data bits that indicates whether the

number of bits in the string with

the value 1 is even or odd.

Wikipedia

1 2 3 4 5 6 7 8 9 10 11 12

We number the bits for the now 12 bits (8 for data and 4 for parity) from left to right starting

at 1. The parity bits are assigned to the locations in the 12 bits based on the powers of 2: 20

= 1, 21 = 2, 22 = 4, 23 = 8. If we had more than 8 bits of data, this would continue. Correctly

placing the parity bits within the 12 bits is very important.

Parity bit 1

Now we’ll calculate the value for the first parity bit, bit position 1.

_ _ 1 _ 0 0 1 _ 1 0 1 0

1 2 3 4 5 6 7 8 9 10 11 12

even odd

Position 1: check 1 bit, skip 1 bit, _ _ 1 _ 0 0 1 _ 1 0 1 0 = 4 0 1

check 1 bit, skip 1 bit…

bits 1, 3, 5, 7, 9, 11, …

Now we’ll calculate the value for the first parity bit, bit position 1. Count all the data bits

from the list. In the example, the indicated data bits count to 4 (positions 3, 7, 9, and 11).

If we are interested in even parity, the parity bit (position 1) is set to a zero. If we are

interested in odd parity, then the parity bit (position 1) is set to a one.

R. Jesse Chaney 8 CS271 – Oregon State University

Parity bit 2

Now we’ll calculate the value for the second parity bit, bit position 2.

_ _ 1 _ 0 0 1 _ 1 0 1 0

1 2 3 4 5 6 7 8 9 10 11 12

even odd

Position 2: check 2 bits, skip 2 bits, _ _ 1 _ 0 0 1 _ 1 0 1 0 = 3 1 0

check 2 bits, skip 2 bits…

bits 2, 3, 6, 7, 10, and 11

Now we’ll calculate the value for the second parity bit, bit position 2. Count all the

data bits from the list. In the example, the indicated data bits count to 3 (positions 3,

7, and 11).

If we are interested in even parity, the parity bit (position 2) is set to a one. If we are

interested in odd parity, then the parity bit (position 2) is set to a zero.

R. Jesse Chaney 9 CS271 – Oregon State University

Parity bit 3

Now we’ll calculate the value for the third parity bit, bit position 4.

_ _ 1 _ 0 0 1 _ 1 0 1 0

1 2 3 4 5 6 7 8 9 10 11 12

even odd

Position 4: check 4 bits, skip 4 bits, _ _ 1 _ 0 0 1 _ 1 0 1 0 = 1 1 0

check 4 bits, skip 4 bits…

We run out of bits. If there were more than 12

bits 4, 5, 6, 7, 12 bits in our data, we’d keep adding.

Now we’ll calculate the value for the third parity bit, bit position 4. Count all the data

bits from the list. In the example, the indicated data bits count to a lonely 1 (position 7).

If we are interested in even parity, the parity bit (position 4) is set to a one. If we are

interested in odd parity, then the parity bit (position 4) is set to a zero.

Parity bit 4

We now calculate the value for the fourth parity bit (last in our example), bit position 8.

_ _ 1 _ 0 0 1 _ 1 0 1 0

1 2 3 4 5 6 7 8 9 10 11 12

even odd

Position 8: check 8 bits, skip 8 bits, _ _ 1 _ 0 0 1 _ 1 0 1 0 = 2 0 1

check 8 bits, skip 8 bits… Once again, we run out of bits long before we

bits 8, 9, 10, 11, 12, … get to 8. If there were more than 12 bits in our

data, we’d keep adding.

Now we’ll calculate the value for the fourth parity bit (the last one in this example), bit

position 8. Count all the data bits from the list. In the example, the indicated data bits

count to 2 (positions 9 and 11).

If we are interested in even parity, the parity bit (position 8) is set to a zero. If we are

interested in odd parity, then the parity bit (position 8) is set to a one.

R. Jesse Chaney 11 CS271 – Oregon State University

Pulling all the parity bits together

Now we’ll put all the parity bits together.

_ _ 1 _ 0 0 1 _ 1 0 1 0

1 2 3 4 5 6 7 8 9 10 11 12

Encoding a 32 bit number

Data bits 0 1 0 0 1 0 0 1 1 0 0 1 0 1 1 0 0 0 0 0 0 0 1 0 1 1 0 1 0 0 1 0

_ _ 0 _ 1 0 0 _ 1 0 0 1 1 0 0 _ 1 0 1 1 0 0 0 0 0 0 0 1 0 1 1 _ 0 1 0 0 1 0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38

Parity bits

Error correction

Now we’ve seen how to calculate a Hamming encoding, but what can we do with it?

We are going to take our example from before, the number 154, and introduce an

error into the stream. We’ll do 2 examples. The first will have an error in the data bits.

The second will have an error in the parity bits. For both examples, we’ll use even

parity encoding.

It is important to know that Hamming codes can only correct single bit errors. There

are other more powerful error correcting codes, but they require more bits and are

more complex.

Introduce an error in a data bit

To introduce the error, we’ll just toggle bit 12 from zero to one.

1 2 3 4 5 6 7 8 9 10 11 12

In reality errors can come from many sources. One that is mentioned often in the web

pages is from computer memory. Another source of errors is corruption that can come

from line noise over networks.

Though statistically, data errors are rare, you want to detect and correct when they do

occur and when they occur in clusters (such as memory or disk errors) you need to

detect and correct before you just have all garbage.

Parity bit 1

bit position 1?

0 1 1 1 0 0 1 0 1 0 1 1 Single error

check 1 bit, skip 1 bit, check 1 bit,

skip 1 bit, … 1 2 3 4 5 6 7 8 9 10 11 12

0 1 1 1 0 0 1 0 1 0 1 1 = 4 this is fine

Add all the values represented by the first parity bit, position 1. Count all the data bits

from the list. In the example, the indicated data bits count to 4 (positions 3, 7, 9, and

11). The value 4 is already even (for our even parity example). So, the single error

must not be within that group of bits.

Parity bit 2

parity bit position 2?

0 1 1 1 0 0 1 0 1 0 1 1 Single error

check 2 bits, skip 2 bits,

check 2 bits, skip 2 bits, … 1 2 3 4 5 6 7 8 9 10 11 12

0 1 1 1 0 0 1 0 1 0 1 1 = 4 this is fine

Add all the values represented by the second parity bit, position 2. Count all the data

bits from the list. In the example, the indicated data bits count to 4 (positions 2, 3, 7,

and 11). The value 4 is already even (for our even parity example). So, the single error

must not be within that group of bits.

Parity bit 3

parity bit position 4?

4 bits, skip 4 bits

1 2 3 4 5 6 7 8 9 10 11 12

0 1 1 1 0 0 1 0 1 0 1 1 = 3 this is wrong

Add all the values represented by the third parity bit, position 4. Count all the data

bits from the list. In the example, the indicated data bits count to 3 (positions 4, 7, and

12). The number 3 is not even (for our even parity example). So, one of the bits from

the parity bit 3 collection must be wrong.

Parity bit 4

for parity bit position 8?

0 1 1 1 0 0 1 0 1 0 1 1 Single error

check 8 bits, skip 8 bits,

1 2 3 4 5 6 7 8 9 10 11 12 check 8 bits, skip 8 bits

0 1 1 1 0 0 1 0 1 0 1 1 = 3 this is wrong

Add all the values represented by the fourth parity bit, position 8. Count all the data

bits from the list. In the example, the indicated data bits count to 3 (positions 9, 11,

and 12). The number 3 is not even (for our even parity example). So, one of the bits

from the parity bit 4 collection must be wrong.

Putting it together

sum of the parity bits. This is one of the simple

0 1 1 1 0 0 1 0 1 0 1 1 Single error beauties of the Hamming code.

1 2 3 4 5 6 7 8 9 10 11 12

0 1 1 1 0 0 1 0 1 0 1 1 = 3 this is wrong

0 1 1 1 0 0 1 0 1 0 1 1 = 3 this is wrong

Now that we’ve identified that there are 2 parity bits that are wrong (and which bits

Wrong parity bits

they are), how do we correct the error? We add the location of the wrong parity bits.

In this case: 4 + 8 = 12. It is bit 12 that is corrupted. So, instead of the received value

1, it should be a zero.

R. Jesse Chaney 20 CS271 – Oregon State University

Introduce an error in a parity bit

To introduce the error, we’ll just toggle bit 4 from zero to one.

1 2 3 4 5 6 7 8 9 10 11 12

Instead of corrupting a data bit, we’ll corrupt a parity bit for this example. We’ll

continue to use even parity.

Parity bit 1

position 1?

0 1 1 0 0 0 1 0 1 0 1 0 Single error check 1 bit, skip 1 bit, check 1 bit, skip 1 bit

1 2 3 4 5 6 7 8 9 10 11 12

0 1 1 0 0 0 1 0 1 0 1 0 = 4 this is fine

Add all the values represented by the first parity bit, position 1. Count all the data bits

from the list. In the example, the indicated data bits count to 4 (positions 3, 7, 9, and

11). The value 4 is already even (for our even parity example). So, the single error

must not be within that group of bits.

Parity bit 2

position 2?

bits

1 2 3 4 5 6 7 8 9 10 11 12

0 1 1 0 0 0 1 0 1 0 1 0 = 4 this is fine

Add all the values represented by the second parity bit, position 2. Count all the data

bits from the list. In the example, the indicated data bits count to 4 (positions 2, 3, 7,

and 11). The value 4 is already even (for our even parity example). So, the single error

must not be within that group of bits.

Parity bit 3

position 3?

bits

1 2 3 4 5 6 7 8 9 10 11 12

0 1 1 0 0 0 1 0 1 0 1 0 = 1 this is wrong

Add all the values represented by the third parity bit, position 4. Count all the data

bits from the list. In the example, the indicated data bits count to 3 (position 7). The

number 1 is not even (for our even parity example). So, one of the bits from the parity

bit 3 collection must be wrong.

Parity bit 4

position 4?

bits

1 2 3 4 5 6 7 8 9 10 11 12

0 1 1 0 0 0 1 0 1 0 1 0 = 2 this is fine

Add all the values represented by the fourth parity bit, position 8. Count all the data

bits from the list. In the example, the indicated data bits count to 2 (positions 9, 11).

The value 2 is already even (for our even parity example). So, the single error must not

be within this group of bits.

Putting it together

sum of the parity bits. This is one of the simple

0 1 1 0 0 0 1 0 1 0 1 0 Single error beauties of the Hamming code.

1 2 3 4 5 6 7 8 9 10 11 12

0 1 1 0 0 0 1 0 1 0 1 0 = 1 this is wrong

Now that we’ve identified that there is 1 parity bit that is wrong (and which bit it is),

Wrong parity bit

how do we fix the error? Like before, we add the location of the wrong parity bits. In

this example, it’s just 1 bit: 4. It is bit 4 that is corrupted. So, instead of the received

value zero, it should be a one.

R. Jesse Chaney 26 CS271 – Oregon State University

Conclusion

• We’ve gone through how to create Hamming Code encoded

data, and

• We’ve gone through how to use Hamming Code parity bits to

correct single bit errors in data.

- Article NewSecurityConcept 0208Uploaded byJohn Moore
- Sol 10Uploaded bysafuan_alcatra
- 901325_chapter 10Uploaded byDurre Shehwar
- ch10-SLIDE-[2]Data Communications and Networking By Behrouz A.ForouzanUploaded byXP2009
- 05606257Uploaded byFirman Nico Chandra
- OGLGeomBenchUploaded byiret
- Section OverheadsUploaded byRaj_Jai03
- our.docxUploaded byyeheyis abebe
- dfd and erUploaded byManoj Kumar Mohan
- UART Synopsys Carried Out by GowravUploaded bygowrav_hassan
- Py Qt 5 TutorialUploaded byandresbe.be8602
- FormatUploaded bySherwin Lacson
- IP architectureUploaded byhc
- Channel ReportUploaded byRafid Haider Shantonu
- IDOC_AAE To File with all Configurations _ SCN.pdfUploaded byJagadish Babu
- RLC_LTE_36Uploaded byDeepak Pengoria
- Chapter 3_digital Transmission FundamentalsUploaded byGeoffrey Alleyne
- Answers 4Uploaded byCarl Siga
- High Speed DP SRAM DatasheetUploaded byPavan Kumar
- 8_BitsUploaded bytarun06
- PresentationUploaded byShashikiran HP
- OIF-SPI4-2.01 : SPI 4.2 InterfaceUploaded byMela Chaar Dina Da
- Significant FiguresUploaded byసురేంద్ర కారంపూడి
- icstt-rm366_-en-pUploaded bySarath Chandran
- code to flowUploaded byash
- Difference SoureQualifier OracleUploaded bymailtopvvk
- Fault Tolerance in Campus Grids IRBUploaded byapi-26988490
- dilseUploaded byshreyp_2
- 1083100Uploaded byzakaria_neo2
- C1.1_Introduction_to_OSUploaded byMd Nazirul Azim Roslim

- The Pirates of Penzance LibrettoUploaded byGreg Kerestan
- The Pirates of Penzance LibrettoUploaded byIsak Foshay
- PGP Proposal Rubric.18-1.pdfUploaded byIsak Foshay
- Course ScheduleUploaded byIsak Foshay
- P6ACriteriaUploaded byIsak Foshay
- Prepare to Succeed U17 TemplateUploaded byIsak Foshay
- ENT322 OnSiteCourse Syllabus Spring2018Uploaded byIsak Foshay
- Prepare to Succeed U17 Template (1)Uploaded byIsak Foshay
- bier-lyd2Uploaded byhurla76
- Lecture 20Uploaded byIsak Foshay
- Lecture 21Uploaded byIsak Foshay
- Lecture 32Uploaded byIsak Foshay
- MachXO3 Family Data Sheet FPGA-DS-02032-20Uploaded byIsak Foshay
- AaaaUploaded byIsak Foshay
- Midterm Exam Study Guide ST314-3Uploaded byIsak Foshay

- Chapter FourUploaded byIdris Ali
- CADWorx Plant User GuideUploaded byHisbullah Kalanther Lebbe
- Sample Synopsis ProjectUploaded bysonabeta07
- old dan tucker lessonUploaded byapi-316167738
- Export Image to PDF Vb NetUploaded byBrian
- Demand-side Financing and Promotion of Maternal Health_what Has India Le...Uploaded bygspkishore7953
- Fog Ra Tirade Control Demedio Su SoUploaded byKarlis Silva Cárdenas
- Rockwell Lifting Solutions -OptiLift.pdfUploaded byMaria Jose
- 7. An approach toward wireless brain–computer interface system using EEG signals.pdfUploaded byAbdul Gafur Patowary
- Omegadex_1.9Uploaded byThiago Russo Nantes
- Reveiw Questions for Chapter1Uploaded byTariq Abdulaziz
- Levels of TranceUploaded byJitesh Manwani
- StoryAppChat_082811Uploaded byBrooks Jones
- Lectures 1 Rabiner speech processingUploaded byjtorresf
- Efficient INDIA Company Profile - Training & WorkshopsUploaded byRahul Verma
- lesson planUploaded byapi-316608836
- persuasive writing editingUploaded byapi-200889745
- Infor CRM 8.3 Compatibility Matrix - Apr2016 (4)Uploaded byMalay Mukherjee
- LARAVELUploaded byBen Khlifa Tlijani
- Management Level Course for Maritime Deck OfficersUploaded byjohnkevin.quilaton
- Slake Durability TestUploaded byEngr. Ikhwan Z.
- demographic.pdfUploaded byRoxii Mihaela Ivan
- 130606_Aktuelnosti 21-13 WEBUploaded byDragan Pejic
- State-Space Battery Modeling for Smart Battery Management System.pdfUploaded byJosé Perez
- Dfmea DataUploaded byvijaykhandge
- 02 Fiske, cap 1Uploaded byNelson Diaz
- lpi-coursewareUploaded byiria2006
- SandeepUploaded byGourav Verma
- A Study on Investors Attitude Towards Primary Market at ThoothukudiUploaded byarcherselevators
- Luminol Post LabUploaded byjoshkty27