当前位置:网站首页>Hamming code verification [simple and detailed]
Hamming code verification [simple and detailed]
2022-06-21 06:38:00 【Boyun V】
Haiming code
1. What is Hamming code :
A man named
Richard HanmingGrandpa is 1950 Test and error correction method proposed in , It has a Error correction ability .
2. The calculation method of Hamming code :
Set the binary code to be detected as
n position,Kby Detection bit ( Provide error correction ), in totaln+kA codeThe relationship satisfied by the middle detection bit : 2 k 2^{k} 2k>=(n+k+1) === This relationship is also to find different code lengths n The number of bits to be detected k
1. Coding rules of Hamming code
set up
kindividual Inspection position byPk,Pk-1...P1,
nindividual Data bits byDn-1,Dn-2,....D1,D0Corresponding Haiming code byHn+k,Hn+k+1,....H1
that Inspection position And Haiming code Location correspondence of :
(1)Pi In the second of Hamming code 2 i − 1 2^{i-1} 2i−1 Location , such as
P2, 2 2 − 1 2^{2-1} 22−1 Then the position of Hamming code is H 2 H_{_2} H2(2) Be careful : Any bit of Hamming code is checked by several check bits
The corresponding relationship among them :
VerifiedThe Hamming code ofSubscriptbe equal to All involvedCheck this bitOfInspection positionSum of subscripts
Check bitBy oneselfSelf verification
Eg: H 12 H_{12} H12, His subscript is 12, The corresponding is8+4( The above formula solves , To correspond to binary ) That is the first of Hamming code 8 And the 4 Inspection position
Examples of practical applications :
about 8 Data bits of bits , Hamming code verification requires 4 Check bits ( 2 k 2^k 2k>=n+k+1, 2 4 2^4 24>=8+4+1)
Make Data bits by : D 7 D_7 D7、 D 6 D_6 D6、 D 5 D_5 D5、 D 4 D_4 D4、 D 3 D_3 D3、 D 2 D_2 D2、 D 1 D_1 D1、 D 0 D_0 D0
Check bit by : P 4 P_4 P4、 P 3 P_3 P3、 P 2 P_2 P2、 P 1 P_1 P1、 P 4 P_4 P4
Formed Haiming code : H 12 H_{12} H12、 H 12 H_{12} H12、 H 11 H_{11} H11、 H 10 H_{10} H10… H 1 H_{1} H1
The specific process :
(1) determine D And P Position in Hamming code
| H 12 H_{12} H12 | H 11 H_{11} H11 | H 10 H_{10} H10 | H 9 H_{9} H9 | H 8 H_{8} H8 | H 7 H_{7} H7 | H 6 H_{6} H6 | H 5 H_{5} H5 | H 4 H_{4} H4 | H 3 H_{3} H3 | H 2 H_{2} H2 | H 1 H_{1} H1 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| D 7 D_7 D7 | D 6 D_6 D6 | D 5 D_5 D5 | D 4 D_4 D4 | P 4 P_{4} P4 | D 3 D_{3} D3 | D 2 D_{2} D2 | D 1 D_{1} D1 | P 3 P_{3} P3 | D 0 D_{0} D0 | P 2 P_{2} P2 | P 1 P_{1} P1 |
Be careful : In the middle of H 8 H_{8} H8, H 3 H_{3} H3
(2) Calculate the check bits
first
Inspection positionP 1 P_{1} P1 It's located in H 1 H_{1} H1 The location of , His inspection position is H 1 H_{1} H1, H 3 H_{3} H3, H 5 H_{5} H5, H 7 H_{7} H7, H 9 H_{9} H9, H 11 H_{11} H11 Namely Read one , One person awaythe second
Inspection positionP 2 P_{2} P2 It's located in H 2 H_{2} H2 The location of , His inspection position is H 2 H_{2} H2, H 3 H_{3} H3, H 6 H_{6} H6, H 7 H_{7} H7, H 10 H_{10} H10, H 11 H_{11} H11 Namely Read two , Partition 2 positionThird
Inspection positionP 3 P_{3} P3 It's located in H 4 H_{4} H4 The location of , His inspection position is H 4 H_{4} H4, H 5 H_{5} H5, H 6 H_{6} H6, H 7 H_{7} H7, H 9 H_{9} H9, H 12 H_{12} H12 Namely Read four , Four digits apartThe fourth one
Inspection positionP 4 P_{4} P4 It's located in H 8 H_{8} H8 The location of , His inspection position is H 8 H_{8} H8, H 9 H_{9} H9, H 10 H_{10} H10, H 11 H_{11} H11, H 12 H_{12} H12 Namely read 8 position , Partition 8 positionAnd so on ,
The first
nOf parity bits Hemingway yes : fromOneselfStart , read 2 n − 1 2^{n-1} 2n−1 position , Partition 2 n − 1 2^{n-1} 2n−1 position … Until the end
(3) The data corresponding to the check bit is Exclusive or operation
The general default is Even check , Sure
Find outEach check bit is responsible for detectingHemingway— use Odd check , The even check value of each check bitTake the oppositethat will do$$
&P1=D0⊕D1⊕D3⊕D4⊕D6 \
&P2=D0⊕D2⊕D3⊕D5⊕D6 \
&P3=D1⊕D2⊕D3⊕D7 \
&P4=D4⊕D5⊕D6⊕D7 \$$
(4) Check error
It is very simple to check the data using Hamming code ,
According to the above method , We can easily know which Hamming bit each check bit is responsible for detecting ,
Just XOR it .
$$
&G4=P4⊕D4⊕D5⊕D6⊕D7\
&G3=P3=D1⊕D2⊕D3⊕D7 \
&G2=D2⊕D2⊕D3⊕D5⊕D6 \
&G1=D1⊕D1⊕D3⊕D4⊕D6 \end
$$
(5) determine
1. Normal condition :
If the Even check , be
G4G3G2G1All for 0 Means data There is no mistake , Odd check It should be all 1, Otherwise, an error occurs .
2. Wrong situation
When something goes wrong , take
G4G3G2G1The value of is converted toDecimal systemYou know what happened Wrong place Such as
G4G3G2G1=0110, It indicates that theH6There is an error in the data of this location , As long as it is reversed, it can be corrected .
The end
Reference link : Haiming code ( Hamming code ) Detailed explanation 
边栏推荐
- TypeError: iter() returned non-iterator of type ‘xxx‘
- 【笔记自用】myeclipse连接MySQL数据库详细步骤
- Zongzi battle - guess who can win
- Contos7 installing SVN server
- 【JS】截取字符串
- Delphi10 FTP file name garbled
- 数据库有用户更改密码问题
- 数据可视化实战:数据处理
- 【基于栈的二叉树中序遍历】二叉树的中序遍历+栈,O(h)的空间复杂度
- Blasting with burp (ordinary blasting + verification code blasting)
猜你喜欢

小程序【第一期】

海明码校验【简单详细】

PyG教程(4):自定义数据集

Dragon Boat Festival - simple side navigation bar

Record the problem that Navicat connection PostgreSQL cannot display the corresponding table

scikit-learn中的Scaler

0-1背包问题 (暴力递归 / 动态规划)

Why should I use the source code of nametuple replace(‘,‘, ‘ ‘). Split() instead of split(‘,‘)
![[data mining] final review Chapter 5](/img/d1/0c16b881b018c2e29f028c2b937e17.png)
[data mining] final review Chapter 5

5254. 卖木头块 动态规划
随机推荐
Mysql database foundation: sub query
Xshell7 connects to the server remotely and suspends the process to keep the program running
智能需要身体吗
TypeError: iter() returned non-iterator of type ‘xxx‘
How powerful are spectral graph neural networks
机器学习之数据归一化(Feature Scaling)
154-Solana分发token
Leetcode 75 - three implementation methods of color classification [medium]
NOP法破解简易登录系统
MSF intranet penetration
DDD Practice Manual (4. aggregate aggregate)
Module 14 - 15: network application communication test
Introduction to 3D engine software wizard
[JDBC from starting to Real combat] JDBC Basic clearance tutoriel (Summary of the first part)
The framework and script of cognitive linguistics
[data mining] final review Chapter 1
异常的相关介绍
[MySQL] database multi table operation customs clearance tutorial (foreign key constraint, multi table joint query)
153-Solana创建PDA和存储
Zongzi battle - guess who can win