程序代码错误检测_错误检测代码

程序代码错误检测

错误检测代码 (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奇偶校验 。 在奇数奇偶校验中 ,将01个奇偶校验位添加到位组中,以使包括字中的奇偶校验位的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 bitsParity Bit(Odd)Word of 4 bitsParity Bit(Even)
0000100000
0001000011
0010000101
0011100110
0100001001
0101101010
1100111000
0111001111
1000010001
1001110010
1010010100
............
............
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:在偶数奇偶校验系统中,以下哪个单词包含错误?

  1. 0010100011

    0010100011

  2. 1010001010

    1010001010

  3. 0010000110

    0010000110

Answer: In an even-parity system, total number of 1’s should be even. So,

答:在偶数奇偶校验系统中,总数1应该是偶数。 所以,

  1. 0010100011, contains 4 one bit which is even. Thus, it has no errors.

    0010100011 ,包含4个偶数位。 因此,它没有错误。

  2. 1011101010, contains 6 one bit which is even. Thus, it has no errors.

    1011101010 ,包含6个偶数位。 因此,它没有错误。

  3. 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:在奇偶校验系统中,以下哪个单词包含错误?

  1. 1011101111

    1011101111

  2. 1011000011

    1011000011

  3. 1011110110

    1011110110

Answer: In an odd-parity system, total number of 1’s should be odd. So,

答:在奇数奇偶校验系统中,总数1应该是奇数。 所以,

  1. 1011101111, contains 8 one bit which is even. Thus, it has an error.

    1011101111 ,包含8个偶数位。 因此,它有一个错误。

  2. 1011000011, contains 5 one bit which is odd. Thus, it has no errors.

    1011000011 ,包含5个奇数位。 因此,它没有错误。

  3. 1011110110, contains 7 one bit which is odd. Thus, it has no errors.

    1011110110 ,包含7个奇数位。 因此,它没有错误。

翻译自: https://www.includehelp.com/basics/error-detecting-codes.aspx

程序代码错误检测

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值