程序代碼錯誤檢測
錯誤檢測代碼 (Error Detecting Codes)
A group of bits is known as words, and these words move as an entity from one block to another in the digital system. While moving from one part to another within the system via transmission media, the bits within the word can get altered/distorted due to external factors, whom we call Noise. Because digital systems need to be accurate to the digit, an error can pose a serious threat. So, several error detecting methods are introduced to find these incorrect bits in the words, which can be corrected and after detection and should be retransmitted.
一組位稱為字,這些字作為一個實體從數字系統中的一個塊移動到另一個塊。 當通過傳輸介質從系統中的一個部分移動到另一部分時,該字中的位會由于外部因素(我們稱為“噪聲”)而發生更改/失真。 因為數字系統需要精確到數字,所以錯誤可能會構成嚴重威脅。 因此,引入了幾種錯誤檢測方法以在單詞中找到這些不正確的比特,這些錯誤比特可以被糾正并且在被檢測之后應當被重新發送。
平價 (Parity)
The simplest technique for detecting an error in a word is adding an extra bit in the group of bits, this extra bit is known as the parity bit.
檢測單詞錯誤的最簡單技術是在位組中添加一個額外的位,這個額外的位稱為奇偶校驗位。
There are two types of parity which we consider for error detection purposes which are ODD parity and EVEN parity. In odd parity, 0 or 1 parity bit is added to the group of bits such that the total number of 1 bit including the parity bit in word remains odd in number. Similarly, in even parity, 0 or 1 bit is added in the group of bits such that total no. of 1 bit including the parity bit in the word remains even in number.
為了錯誤檢測的目的,我們考慮兩種奇偶校驗,即ODD奇偶校驗和EVEN奇偶校驗 。 在奇數奇偶校驗中 ,將0或1個奇偶校驗位添加到位組中,以使包括字中的奇偶校驗位的1位總數保持奇數。 類似地,在偶數奇偶校驗中,將0或1位添加到位組中,以使總數為0。 包括該字中的奇偶校驗位的1位元的數量保持偶數。
Given below is a table which contains message bit of 4 bits and the parity bit in odd and even parity cases,
下表是一個包含4位消息位和奇偶校驗情況下奇偶校驗位的表,
Word of 4 bits | Parity Bit(Odd) | Word of 4 bits | Parity Bit(Even) |
---|---|---|---|
0000 | 1 | 0000 | 0 |
0001 | 0 | 0001 | 1 |
0010 | 0 | 0010 | 1 |
0011 | 1 | 0011 | 0 |
0100 | 0 | 0100 | 1 |
0101 | 1 | 0101 | 0 |
1100 | 1 | 1100 | 0 |
0111 | 0 | 0111 | 1 |
1000 | 0 | 1000 | 1 |
1001 | 1 | 1001 | 0 |
1010 | 0 | 1010 | 0 |
... | ... | ... | ... |
... | ... | ... | ... |
4位字 | 奇偶校驗位(奇數) | 4位字 | 奇偶校驗位(偶數) |
---|---|---|---|
0000 | 1個 | 0000 | 0 |
0001 | 0 | 0001 | 1個 |
0010 | 0 | 0010 | 1個 |
0011 | 1個 | 0011 | 0 |
0100 | 0 | 0100 | 1個 |
0101 | 1個 | 0101 | 0 |
1100 | 1個 | 1100 | 0 |
0111 | 0 | 0111 | 1個 |
1000 | 0 | 1000 | 1個 |
1001 | 1個 | 1001 | 0 |
1010 | 0 | 1010 | 0 |
... | ... | ... | ... |
... | ... | ... | ... |
A parity checker circuit is set up on the receiving side which generates an error whenever an odd number of 1's occurs in case of even parity and an even number of 1's occurs in case of odd parity system.
在接收側建立一個奇偶校驗器電路,每當偶數奇偶校驗出現奇數1時發生錯誤,而在奇偶校驗系統奇偶校驗發生時偶數1出現錯誤。
Generally, odd parity is used more often than even parity because even parity does not detect the situation where all 0's is created by a short circuit or other fault condition.
通常,奇數奇偶校驗比偶數奇偶校驗使用更多,因為偶數奇偶校驗無法檢測到短路或其他故障情況導致全0的情況。
Example 1: In even-parity system, which of the following words contain an error?
示例1:在偶數奇偶校驗系統中,以下哪個單詞包含錯誤?
0010100011
0010100011
1010001010
1010001010
0010000110
0010000110
Answer: In an even-parity system, total number of 1’s should be even. So,
答:在偶數奇偶校驗系統中,總數1應該是偶數。 所以,
0010100011, contains 4 one bit which is even. Thus, it has no errors.
0010100011 ,包含4個偶數位。 因此,它沒有錯誤。
1011101010, contains 6 one bit which is even. Thus, it has no errors.
1011101010 ,包含6個偶數位。 因此,它沒有錯誤。
0010000110, contains 3 one bit which is odd. Thus, this word has an error.
0010000110 ,包含3個奇數位。 因此,這個詞有錯誤。
Example 2: In odd-parity system, which of the following words contain an error?
示例2:在奇偶校驗系統中,以下哪個單詞包含錯誤?
1011101111
1011101111
1011000011
1011000011
1011110110
1011110110
Answer: In an odd-parity system, total number of 1’s should be odd. So,
答:在奇數奇偶校驗系統中,總數1應該是奇數。 所以,
1011101111, contains 8 one bit which is even. Thus, it has an error.
1011101111 ,包含8個偶數位。 因此,它有一個錯誤。
1011000011, contains 5 one bit which is odd. Thus, it has no errors.
1011000011 ,包含5個奇數位。 因此,它沒有錯誤。
1011110110, contains 7 one bit which is odd. Thus, it has no errors.
1011110110 ,包含7個奇數位。 因此,它沒有錯誤。
翻譯自: https://www.includehelp.com/basics/error-detecting-codes.aspx
程序代碼錯誤檢測