SlideShare a Scribd company logo
1 of 13
Hamming Code
Error Detecting and Correcting
Code
 Parity code
◦ Detect odd number of errors
◦ Cannot correct any errors
 Hamming Code
◦ Detect up to two simultaneous bit errors
◦ Correct single-bit errors
Hamming Code
 For each integer m > 2
◦ Code exists with m parity bits and 2m – m – 1
 Basically
◦ Parity bit for odd bits
◦ Parity bit for each two bits
◦ Parity bit for each four bits
◦ Parity bit for each eight bits
◦ Parity bit for each group of bits that are power of
2
 1, 2, 4, 8, 16, 32, …
Calculating Hamming Code
1. Mark all bit positions that are powers of two parity bit
1, 2, 4, 8, 16, 32, 64, etc
2. All other bit positions are for the data to be encoded
3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, etc.
3. Each parity bit calculates the parity for some of the bits in
the code word
The position of the parity bit determines the sequence of bits that it
alternately checks and skips
Position 1: check 1 bit, skip 1 bit, check 1 bit, skip 1 bit, etc.
(1,3,5,7,9,11,13,15,...)
Position 2: check 2 bits, skip 2 bits, check 2 bits, skip 2 bits, etc.
(2,3,6,7,10,11,14,15,...)
Position 4: check 4 bits, skip 4 bits, check 4 bits, skip 4 bits, etc.
(4,5,6,7,12,13,14,15,20,21,22,23,...)
Position 8: check 8 bits, skip 8 bits, check 8 bits, skip 8 bits, etc.
(8-15,24-31,40-47,...)
4. Set a parity bit to 1 if the total number of ones in the
positions it checks is odd. Set a parity bit to 0 if the total
number of ones in the positions it checks is even
Hamming Code Layout
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10 11
Pos 20=1 21=2 22=4 23=8
1 1 0 0 0
2 0 1 0 0
3 1 1 0 0
4 0 0 1 0
5 1 0 1 0
6 0 1 1 0
7 1 1 1 0
8 0 0 0 1
9 1 0 0 1
10 0 1 0 1
11 1 1 0 1
12 0 0 1 1
13 1 0 1 1
14 0 1 1 1
15 1 1 1 1
Even parity calculated for each bit position
P1 (1, 3, 5, 7, 9, 11, 13, 15)
P2 (2, 3, 6, 7, 10, 11, 14, 15)
P4 (4, 5, 6, 7, 12, 13, 14, 15)
P8(8, 9, 10, 11, 12, 13, 14, 15)
Hamming Code Layout
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 0 1 0 1 1 0 1 0 1 1
P1 P1 P1 P1 P1 P1 P1 P1
P2 P2 P2 P2 P2 P2 P2 P2
P4 P4 P4 P4 P4 P4 P4 P4
P8 P8 P8 P8 P8 P8 P8 P8
1 1 1 0 0 1 0 1 1 1 0 1 0 1 1
Even parity calculated for each bit position
P1 (1, 3, 5, 7, 9, 11, 13, 15)
P2 (2, 3, 6, 7, 10, 11, 14, 15)
P4 (4, 5, 6, 7, 12, 13, 14, 15)
P8(8, 9, 10, 11, 12, 13, 14, 15)
For code: 10101101011
P1 = 1
P2 = 1
P4 = 0
P8 = 1
Hamming Code (1 error)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 0 1 0 1 1 0 1 0 1 1
P1 P1 P1 P1 P1 P1 P1 P1
P2 P2 P2 P2 P2 P2 P2 P2
P4 P4 P4 P4 P4 P4 P4 P4
P8 P8 P8 P8 P8 P8 P8 P8
1 1 1 0 0 1 0 1 1 1 0 1 0 1 1
1 1 1 0 0 1 0 1 1 1 0 1 0 0 1
Even parity calculated for each bit position
P1 (1, 3, 5, 7, 9, 11, 13, 15)
P2 (2, 3, 6, 7, 10, 11, 14, 15)
P4 (4, 5, 6, 7, 12, 13, 14, 15)
P8(8, 9, 10, 11, 12, 13, 14, 15)
A S
P1 = 1 1
P2 = 1 0
P4 = 0 1
P8 = 1 0
Xmit
Rec
2, 4, and 8 incorrect
2 + 4 + 8 = 14
A = Actual Parity
S = Should be
Parity
Hamming Code (2 errors)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 0 1 0 1 1 0 1 0 1 1
P1 P1 P1 P1 P1 P1 P1 P1
P2 P2 P2 P2 P2 P2 P2 P2
P4 P4 P4 P4 P4 P4 P4 P4
P8 P8 P8 P8 P8 P8 P8 P8
1 1 1 0 0 1 0 1 1 1 0 1 0 1 1
1 1 1 0 0 1 0 1 0 1 0 1 0 0 1
Even parity calculated for each bit position
P1 (1, 3, 5, 7, 9, 11, 13, 15)
P2 (2, 3, 6, 7, 10, 11, 14, 15)
P4 (4, 5, 6, 7, 12, 13, 14, 15)
P8(8, 9, 10, 11, 12, 13, 14, 15)
A S
P1 = 1 0
P2 = 1 0
P4 = 0 1
P8 = 1 1
Xmit
Rec
1,2, and 4 incorrect
1 + 2 + 4 = 7
Fix 7, will still have parity problem
A = Actual Parity
S = Should be
Parity
Example
 A byte of data: 10011010
 Create the data word, leaving spaces for the parity bits:
_ _ 1 _ 0 0 1 _ 1 0 1 0
 Calculate the parity for each parity bit (a ? represents the bit
position being set):
◦ Position 1 checks bits 1,3,5,7,9,11:
? _ 1 _ 0 0 1 _ 1 0 1 0. Even parity so set position 1 to a 0:
0 _ 1 _ 0 0 1 _ 1 0 1 0
◦ Position 2 checks bits 2,3,6,7,10,11:
0 ? 1 _ 0 0 1 _ 1 0 1 0. Odd parity so set position 2 to a 1:
0 1 1 _ 0 0 1 _ 1 0 1 0
◦ Position 4 checks bits 4,5,6,7,12:
0 1 1 ? 0 0 1 _ 1 0 1 0. Odd parity so set position 4 to a 1:
0 1 1 1 0 0 1 _ 1 0 1 0
◦ Position 8 checks bits 8,9,10,11,12:
0 1 1 1 0 0 1 ? 1 0 1 0. Even parity so set position 8 to a 0:
0 1 1 1 0 0 1 0 1 0 1 0
◦ Code word: 011100101010
Finding and Fixing a Bad Bit
123456789012
 Transmitted word: 011100101010
 Received word: 011100101110
 Calculate the parity bits from received
word
SB A
◦ P1 (1, 3, 5, 7, 9, 11) = 0 0
1
◦ P2 (2, 3, 6, 7, 10, 11) = 0 1
2
◦ P4 (4, 5, 6, 7, 12) = 1 1 4
◦ P8 (8, 9, 10, 11, 12) = 1 0
8
 2 + 8 = 10
Finding and Fixing a Bad Bit
123456789012
 Transmitted word:
 Received word: 010101100011
 Calculate the parity bits from received
word
SB A
◦ P1 (1, 3, 5, 7, 9, 11) = 0 0
◦ P2 (2, 3, 6, 7, 10, 11) = 0 1
◦ P4 (4, 5, 6, 7, 12) = 0 1
◦ P8 (8, 9, 10, 11, 12) = 0 0
 Bit positions 2 & 4 are incorrect
2 + 4 = 6
 Correct code is 010100100011
Finding and Fixing a Bad Bit
123456789012
 Transmitted word:
 Received word: 111110001100
 Calculate the parity bits from received
word
SB A
◦ P1 (1, 3, 5, 7, 9, 11) = 0 1
◦ P2 (2, 3, 6, 7, 10, 11) = 1 1
◦ P4 (4, 5, 6, 7, 12) = 0 1
◦ P8 (8, 9, 10, 11, 12) = 0 0
 Bit positions 1 & 4 are incorrect
1 + 4 = 5
 Correct code is 111100001100
Finding and Fixing a Bad Bit
123456789012
 Transmitted word:
 Received word: 000010001010
 Calculate the parity bits from received
word
SB A
◦ P1 (1, 3, 5, 7, 9, 11) = 1 0
◦ P2 (2, 3, 6, 7, 10, 11) = 1 0
◦ P4 (4, 5, 6, 7, 12) = 1 0
◦ P8 (8, 9, 10, 11, 12) = 0 0
 Bit positions 1, 2 & 4 are incorrect
1 + 2 + 4 = 7
 Correct code is: 000010101010

More Related Content

Similar to 3288940.ppt

Ece175 computer programming for engineering applications homework assignment ...
Ece175 computer programming for engineering applications homework assignment ...Ece175 computer programming for engineering applications homework assignment ...
Ece175 computer programming for engineering applications homework assignment ...Song Love
 
Computer archi&mp
Computer archi&mpComputer archi&mp
Computer archi&mpMSc CST
 
Ncp computer appls num sys1 pramod
Ncp computer appls  num sys1 pramodNcp computer appls  num sys1 pramod
Ncp computer appls num sys1 pramodNCP
 
Unit 1 PDF.pptx
Unit 1 PDF.pptxUnit 1 PDF.pptx
Unit 1 PDF.pptxChandraV13
 
Ip 5 discrete mathematics
Ip 5 discrete mathematicsIp 5 discrete mathematics
Ip 5 discrete mathematicsMark Simon
 
unit-i-number-systems.pdf
unit-i-number-systems.pdfunit-i-number-systems.pdf
unit-i-number-systems.pdfRameshK531901
 
CDMA - USE WALSH TABLE TO GENERATE CHIP SEQUENCE
CDMA - USE WALSH TABLE TO GENERATE CHIP SEQUENCE CDMA - USE WALSH TABLE TO GENERATE CHIP SEQUENCE
CDMA - USE WALSH TABLE TO GENERATE CHIP SEQUENCE 0586umer
 
digital-electronics.pptx
digital-electronics.pptxdigital-electronics.pptx
digital-electronics.pptxsulekhasaxena2
 
Video lectures
Video lecturesVideo lectures
Video lecturesEdhole.com
 
Chapter 1 digital design.pptx
Chapter 1 digital design.pptxChapter 1 digital design.pptx
Chapter 1 digital design.pptxAliaaTarek5
 
Data types
Data typesData types
Data typesgavhays
 
The Data Link Layer
The Data Link LayerThe Data Link Layer
The Data Link Layerrobbbminson
 
Pertemuan 2 - Sistem Bilangan
Pertemuan 2 - Sistem BilanganPertemuan 2 - Sistem Bilangan
Pertemuan 2 - Sistem Bilanganahmad haidaroh
 

Similar to 3288940.ppt (20)

Ece175 computer programming for engineering applications homework assignment ...
Ece175 computer programming for engineering applications homework assignment ...Ece175 computer programming for engineering applications homework assignment ...
Ece175 computer programming for engineering applications homework assignment ...
 
Numbering Systems
Numbering SystemsNumbering Systems
Numbering Systems
 
Number System
Number SystemNumber System
Number System
 
Computer archi&mp
Computer archi&mpComputer archi&mp
Computer archi&mp
 
Binary
BinaryBinary
Binary
 
Ncp computer appls num sys1 pramod
Ncp computer appls  num sys1 pramodNcp computer appls  num sys1 pramod
Ncp computer appls num sys1 pramod
 
Unit 1 PDF.pptx
Unit 1 PDF.pptxUnit 1 PDF.pptx
Unit 1 PDF.pptx
 
Number system
Number systemNumber system
Number system
 
Ip 5 discrete mathematics
Ip 5 discrete mathematicsIp 5 discrete mathematics
Ip 5 discrete mathematics
 
W 9 numbering system
W 9 numbering systemW 9 numbering system
W 9 numbering system
 
W 9 numbering system
W 9 numbering systemW 9 numbering system
W 9 numbering system
 
unit-i-number-systems.pdf
unit-i-number-systems.pdfunit-i-number-systems.pdf
unit-i-number-systems.pdf
 
CDMA - USE WALSH TABLE TO GENERATE CHIP SEQUENCE
CDMA - USE WALSH TABLE TO GENERATE CHIP SEQUENCE CDMA - USE WALSH TABLE TO GENERATE CHIP SEQUENCE
CDMA - USE WALSH TABLE TO GENERATE CHIP SEQUENCE
 
digital-electronics.pptx
digital-electronics.pptxdigital-electronics.pptx
digital-electronics.pptx
 
Video lectures
Video lecturesVideo lectures
Video lectures
 
Mba ebooks
Mba ebooksMba ebooks
Mba ebooks
 
Chapter 1 digital design.pptx
Chapter 1 digital design.pptxChapter 1 digital design.pptx
Chapter 1 digital design.pptx
 
Data types
Data typesData types
Data types
 
The Data Link Layer
The Data Link LayerThe Data Link Layer
The Data Link Layer
 
Pertemuan 2 - Sistem Bilangan
Pertemuan 2 - Sistem BilanganPertemuan 2 - Sistem Bilangan
Pertemuan 2 - Sistem Bilangan
 

Recently uploaded

Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 

Recently uploaded (20)

Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 

3288940.ppt

  • 2. Error Detecting and Correcting Code  Parity code ◦ Detect odd number of errors ◦ Cannot correct any errors  Hamming Code ◦ Detect up to two simultaneous bit errors ◦ Correct single-bit errors
  • 3. Hamming Code  For each integer m > 2 ◦ Code exists with m parity bits and 2m – m – 1  Basically ◦ Parity bit for odd bits ◦ Parity bit for each two bits ◦ Parity bit for each four bits ◦ Parity bit for each eight bits ◦ Parity bit for each group of bits that are power of 2  1, 2, 4, 8, 16, 32, …
  • 4. Calculating Hamming Code 1. Mark all bit positions that are powers of two parity bit 1, 2, 4, 8, 16, 32, 64, etc 2. All other bit positions are for the data to be encoded 3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, etc. 3. Each parity bit calculates the parity for some of the bits in the code word The position of the parity bit determines the sequence of bits that it alternately checks and skips Position 1: check 1 bit, skip 1 bit, check 1 bit, skip 1 bit, etc. (1,3,5,7,9,11,13,15,...) Position 2: check 2 bits, skip 2 bits, check 2 bits, skip 2 bits, etc. (2,3,6,7,10,11,14,15,...) Position 4: check 4 bits, skip 4 bits, check 4 bits, skip 4 bits, etc. (4,5,6,7,12,13,14,15,20,21,22,23,...) Position 8: check 8 bits, skip 8 bits, check 8 bits, skip 8 bits, etc. (8-15,24-31,40-47,...) 4. Set a parity bit to 1 if the total number of ones in the positions it checks is odd. Set a parity bit to 0 if the total number of ones in the positions it checks is even
  • 5. Hamming Code Layout 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 2 3 4 5 6 7 8 9 10 11 Pos 20=1 21=2 22=4 23=8 1 1 0 0 0 2 0 1 0 0 3 1 1 0 0 4 0 0 1 0 5 1 0 1 0 6 0 1 1 0 7 1 1 1 0 8 0 0 0 1 9 1 0 0 1 10 0 1 0 1 11 1 1 0 1 12 0 0 1 1 13 1 0 1 1 14 0 1 1 1 15 1 1 1 1 Even parity calculated for each bit position P1 (1, 3, 5, 7, 9, 11, 13, 15) P2 (2, 3, 6, 7, 10, 11, 14, 15) P4 (4, 5, 6, 7, 12, 13, 14, 15) P8(8, 9, 10, 11, 12, 13, 14, 15)
  • 6. Hamming Code Layout 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 0 1 0 1 1 0 1 0 1 1 P1 P1 P1 P1 P1 P1 P1 P1 P2 P2 P2 P2 P2 P2 P2 P2 P4 P4 P4 P4 P4 P4 P4 P4 P8 P8 P8 P8 P8 P8 P8 P8 1 1 1 0 0 1 0 1 1 1 0 1 0 1 1 Even parity calculated for each bit position P1 (1, 3, 5, 7, 9, 11, 13, 15) P2 (2, 3, 6, 7, 10, 11, 14, 15) P4 (4, 5, 6, 7, 12, 13, 14, 15) P8(8, 9, 10, 11, 12, 13, 14, 15) For code: 10101101011 P1 = 1 P2 = 1 P4 = 0 P8 = 1
  • 7. Hamming Code (1 error) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 0 1 0 1 1 0 1 0 1 1 P1 P1 P1 P1 P1 P1 P1 P1 P2 P2 P2 P2 P2 P2 P2 P2 P4 P4 P4 P4 P4 P4 P4 P4 P8 P8 P8 P8 P8 P8 P8 P8 1 1 1 0 0 1 0 1 1 1 0 1 0 1 1 1 1 1 0 0 1 0 1 1 1 0 1 0 0 1 Even parity calculated for each bit position P1 (1, 3, 5, 7, 9, 11, 13, 15) P2 (2, 3, 6, 7, 10, 11, 14, 15) P4 (4, 5, 6, 7, 12, 13, 14, 15) P8(8, 9, 10, 11, 12, 13, 14, 15) A S P1 = 1 1 P2 = 1 0 P4 = 0 1 P8 = 1 0 Xmit Rec 2, 4, and 8 incorrect 2 + 4 + 8 = 14 A = Actual Parity S = Should be Parity
  • 8. Hamming Code (2 errors) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 0 1 0 1 1 0 1 0 1 1 P1 P1 P1 P1 P1 P1 P1 P1 P2 P2 P2 P2 P2 P2 P2 P2 P4 P4 P4 P4 P4 P4 P4 P4 P8 P8 P8 P8 P8 P8 P8 P8 1 1 1 0 0 1 0 1 1 1 0 1 0 1 1 1 1 1 0 0 1 0 1 0 1 0 1 0 0 1 Even parity calculated for each bit position P1 (1, 3, 5, 7, 9, 11, 13, 15) P2 (2, 3, 6, 7, 10, 11, 14, 15) P4 (4, 5, 6, 7, 12, 13, 14, 15) P8(8, 9, 10, 11, 12, 13, 14, 15) A S P1 = 1 0 P2 = 1 0 P4 = 0 1 P8 = 1 1 Xmit Rec 1,2, and 4 incorrect 1 + 2 + 4 = 7 Fix 7, will still have parity problem A = Actual Parity S = Should be Parity
  • 9. Example  A byte of data: 10011010  Create the data word, leaving spaces for the parity bits: _ _ 1 _ 0 0 1 _ 1 0 1 0  Calculate the parity for each parity bit (a ? represents the bit position being set): ◦ Position 1 checks bits 1,3,5,7,9,11: ? _ 1 _ 0 0 1 _ 1 0 1 0. Even parity so set position 1 to a 0: 0 _ 1 _ 0 0 1 _ 1 0 1 0 ◦ Position 2 checks bits 2,3,6,7,10,11: 0 ? 1 _ 0 0 1 _ 1 0 1 0. Odd parity so set position 2 to a 1: 0 1 1 _ 0 0 1 _ 1 0 1 0 ◦ Position 4 checks bits 4,5,6,7,12: 0 1 1 ? 0 0 1 _ 1 0 1 0. Odd parity so set position 4 to a 1: 0 1 1 1 0 0 1 _ 1 0 1 0 ◦ Position 8 checks bits 8,9,10,11,12: 0 1 1 1 0 0 1 ? 1 0 1 0. Even parity so set position 8 to a 0: 0 1 1 1 0 0 1 0 1 0 1 0 ◦ Code word: 011100101010
  • 10. Finding and Fixing a Bad Bit 123456789012  Transmitted word: 011100101010  Received word: 011100101110  Calculate the parity bits from received word SB A ◦ P1 (1, 3, 5, 7, 9, 11) = 0 0 1 ◦ P2 (2, 3, 6, 7, 10, 11) = 0 1 2 ◦ P4 (4, 5, 6, 7, 12) = 1 1 4 ◦ P8 (8, 9, 10, 11, 12) = 1 0 8  2 + 8 = 10
  • 11. Finding and Fixing a Bad Bit 123456789012  Transmitted word:  Received word: 010101100011  Calculate the parity bits from received word SB A ◦ P1 (1, 3, 5, 7, 9, 11) = 0 0 ◦ P2 (2, 3, 6, 7, 10, 11) = 0 1 ◦ P4 (4, 5, 6, 7, 12) = 0 1 ◦ P8 (8, 9, 10, 11, 12) = 0 0  Bit positions 2 & 4 are incorrect 2 + 4 = 6  Correct code is 010100100011
  • 12. Finding and Fixing a Bad Bit 123456789012  Transmitted word:  Received word: 111110001100  Calculate the parity bits from received word SB A ◦ P1 (1, 3, 5, 7, 9, 11) = 0 1 ◦ P2 (2, 3, 6, 7, 10, 11) = 1 1 ◦ P4 (4, 5, 6, 7, 12) = 0 1 ◦ P8 (8, 9, 10, 11, 12) = 0 0  Bit positions 1 & 4 are incorrect 1 + 4 = 5  Correct code is 111100001100
  • 13. Finding and Fixing a Bad Bit 123456789012  Transmitted word:  Received word: 000010001010  Calculate the parity bits from received word SB A ◦ P1 (1, 3, 5, 7, 9, 11) = 1 0 ◦ P2 (2, 3, 6, 7, 10, 11) = 1 0 ◦ P4 (4, 5, 6, 7, 12) = 1 0 ◦ P8 (8, 9, 10, 11, 12) = 0 0  Bit positions 1, 2 & 4 are incorrect 1 + 2 + 4 = 7  Correct code is: 000010101010