Haiming code verification program design

Source: Internet
Author: User

Haiming code Verification Program Design 1. Requirement Analysis 1) Haiming code:
Input: a string of binary data
Output: the binary data string after the Hamming code is inserted. 2) hamming code error correction:
Input: a string of binary data strings containing Haiming Codes
Output: Check whether the binary string is correct by using the Haiming code. If any, correct the error bit and output the corrected binary string. 2. haiming code Verification Principle Analysis Here we only analyze the coding and Error Correction Algorithm of Haiming code from the perspective of programming implementation. The book uses the matrix multiplication method, however, the program execution efficiency of the matrix multiplication method is not high. Therefore, the following program implementation algorithms are obtained through searching on the Internet and summarizing them. 2.1 Analysis on the principles of Haiming code encoding
Encoding steps
1) Check the number of digits based on the information.
K-number of information digits
R-check bits
Find the minimum r that satisfies the inequality, that is, the check digit.
2) formula for calculating the checkpoint
650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php? Refimg = "+ this. src) 'alt =" "src =" http://img1.51cto.com/attachment/200906/200906161245166446680.bmp "border =" 0 "/>
Note:
The number of bits r n is 2 ^ n And the rest are filled by information spaces.
The number of digits and information bits start from 1, while the check bits start from 0.
Each information bit is written in the form of a Power Sum of 2 by the number of digits corresponding to the position.
For example, for I8, 12th bits 12 = 2 ^ 3 + 2 ^ 2, for I7, 11th bits 11 = 2 ^ 3 + 2 ^ 1 + 2 ^ 0, the tenth digit of I6 is 10 = 2 ^ 3 + 2 ^ 1, and the ninth digit 9 = 2 ^ 3 + 2 ^ 0 corresponding to I5 is always written to the third digit.
The checkpoint r n is composed of the power of the first digit and the information corresponding to the number of digits that contain 2 ^ n.
For example, r3 = I8 + I7 + I6 + I5
3) Check bit.
Calculate the check bits based on the calculation formula.
4) Find the Hamming Code
After filling in the table above, write the overseas clear code.
For example, write an overseas plaintext for a piece of information 1011.
Follow the steps above to answer the following questions:
1. 2 ^ r ≥ 4 + r + 1, and determine the check bit with 3 bits. 2 ^ 3 ≥ 4 + 3 + 1.
2. Follow the steps
650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php? Refimg = "+ this. src) 'alt =" "src =" http://img1.51cto.com/attachment/200906/200906161245166598158.bmp "border =" 0 "/>
7 = 2 ^ 2 + 2 ^ 1 + 2 ^ 0, 6 = 2 ^ 2 + 2 ^ 1, 5 = 2 ^ 2 + 2 ^ 0, 3 = 2 ^ 1 + 2 ^ 0,
R2 = I4 + I3 + I2
R1 = I4 + I3 + I1
R0 = I4 + I2 + I1
3. Based on the formula r2 = 0, r1 = 0, r0 = 1
4. Add a table
650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php? Refimg = "+ this. src) 'alt =" "src =" http://img1.51cto.com/attachment/200906/200906161245166648781.bmp "border =" 0 "/>
Dehai mingcode 1010101
2.2 Analysis of Haiming code correction principles
(1) based on the information bit and check bit Distribution Rules of The Haiming code, find the information bit and check bit of the received data.
650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php? Refimg = "+ this. src) 'alt =" "src =" http://img1.51cto.com/attachment/200906/200906161245166755384.bmp "border =" 0 "/>
If the encoded data is 1100 1001 0111, you can obtain the encoding information as follows: 1100 0011 1011; check bit.
(2) acceptor verifies the checkpoint
Sn = rn (verification) + rn (receiving)
(3) identify and correct the correction factor.
Sn Sn-1 Sn-2 ...... The binary value of S0 corresponds to the error, and the error is corrected. If 1001 is the ninth digit, change the ninth digit 1 to 0 (or 0 to 1. 3. Outline Design
Based on the above principles, we have made initial planning and design for the software: 1) to provide a friendly user interface, we use the Visual C ++ MFC framework to build applications, use a simple dialog box program, which contains two parts: the Hamming code encoding part and the Hamming code correction part.
2) because this program is only a verification program of the principles of the Haiming code, it only designs the code for the Haiming code with the longest 8-bit data and the verification of the Haiming code with the longest 12-bit.
3) from the above principle, we can see that the Hamming code encoding and error correction can be performed using the formula described above. Therefore, the data structure only needs to use a vector container to store the corresponding data, no other data structures are required. 4. Detailed Design
4.1 Data Structure Design
Defines five bool containers, namely, vector <bool>, which represent the input string register, Haiming encoding register, Haiming code check error register, Haiming code check error data register, and Haiming code check error check value register.
Where:
Input string register: used to store user input binary strings
Haiming encoding register: stores the binary string Haiming code check error register after the Haiming code check code is added: stores the binary string to be corrected
Haiming code check error data register: stores the data part of the binary string to be corrected
Haiming code check error check value register: stores the check code part of the binary string to be corrected
4.2 Module Division
 
Module function Overview:
1) Haiming code encoding
Input module: obtains the user's input binary string and determines whether the input is correct.
Register initialization module: converts user input strings into numbers in the form of 0 and 1 and stores the data in the input string registers in sequence, store the power of 2 to 0) as the storage verification code.
Verification code calculation module: calculates and stores the value of the verification code based on the encoding algorithm described above.
Display Module: converts the binary string in the Haiming encoding Register into a string for output.
2) hamming code correction
Input module: obtains the user's input binary string and determines whether the input is correct.
Register initialization module: converts user input strings into numbers in the form of 0 and 1 and stores them in the error detection register, based on whether the current position is 2 power, the binary string is divided into data and the verification code is stored in the error checking data register and error checking value register respectively.
Haiming code correction module: verifies the data based on the preceding Error Correction Algorithm and corrects the data.
Display Module: Convert the correct binary code in the check error Register into a string for output. 4.3 program flowchart 650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php? Refimg = "+ this. src) 'alt = "" src = "http://img1.51cto.com/attachment/200906/200906161245167028216.bmp" border = "0"/> 5. program 650) this. width = 650; "onclick = 'window. open ("http://blog.51cto.com/viewpic.php? Refimg = "+ this. src) 'alt =" "src =" http://img1.51cto.com/attachment/200906/200906161245167131295.bmp "border =" 0 "/>

This article from the "three shadows" blog, please be sure to keep this source http://ticktick.blog.51cto.com/823160/167482

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.