For faster navigation, this Iframe is preloading the Wikiwand page for 奇偶校验位.

奇偶校验位

此条目没有列出任何参考或来源。 (2013年10月15日)维基百科所有的内容都应该可供查证。请协助补充可靠来源改善这篇条目。无法查证的内容可能会因为异议提出而被移除。

奇偶校验位(英语:Parity bit)或校验位元check bit)是一个表示给定位数的二进制数中1的个数是奇数还是偶数二进制数。奇偶校验位是最简单的错误检测码

7位数据
(1的个数)
带有校验位的字节
偶校验位 奇校验位
0000000(0) 00000000 00000001
1010001(3) 10100011 10100010
1101001(4) 11010010 11010011
1111111(7) 11111111 11111110

类型

[编辑]

奇偶校验位有两种类型:偶校验位奇校验位

偶校验位来说,如果一组给定数据位中1的个数是奇数,补一个bit为1,使得总的1的个数是偶数。例:0000001, 补一个bit为1, 00000011。

奇校验位来说,如果给定一组数据位中1的个数是奇数,补一个bit为0,使得总的1的个数是奇数。例:0000001, 补一个bit为0, 00000010。

偶校验实际上是循环冗余校验的一个特例,通过多项式 x + 1 得到1位CRC

错误检测

[编辑]

如果传输过程中包括校验位在内的奇数个数据位发生改变,那么奇偶校验位将出错表示传输过程有错误发生。因此,奇偶校验位是一种错误检测码,但是由于没有办法确定哪一位出错,所以它不能进行错误校正。发生错误时必须扔掉全部的数据,然后从头开始传输数据。在杂讯很多的介质上成功传输数据可能要花费很长的时间,甚至根本无法实现。但是奇偶校验位也有它的优点,它是使用一位数据能够达到的最好的校验码,并且它仅仅需要一些异或门就能够生成。参见汉明码中关于其它错误校正码的描述。

使用

[编辑]

由于它很简单,所以奇偶校验位用于许多电脑硬件中,遇到麻烦时能够重新操作或者通过简单的错误检测就能起到很大作用的场合。例如SCSI总线使用奇偶校验位检测传输错误,许多微处理器的指令高速缓存中也包括奇偶校验位保护。因为指令缓存数据是主内存数据的副本,所以在发现错误的时候能够抛弃错误数据并且重新取回数据。

串行通讯中,常用的格式是7个数据位、1个校验位、1到2个停止位。这种格式用方便的8位字节巧妙地适应了所有的7位ASCII字符。也可以用其它的格式表示,8位数据加上1个校验位可以传输任意的8位字节数据。

在串行通讯中,奇偶校验位通常是由UART这样的接口硬件生成、校验的,在接收方,通过接口硬件中的寄存器的状态位传给CPU以及操作系统。错误数据的恢复通常是通过重新发送数据,这个过程通常由如操作系统输入输出程序这样的软件处理的。

奇偶校验块

[编辑]

一些容错式磁盘阵列(RAID)使用奇偶校验块实现冗余。如果阵列中的一块磁碟出现故障,工作磁碟中的数据块与奇偶校验块一起来重建丢失的数据。

下面的图表每列表示一个磁碟,假设A1 = 00000111、A2 = 00000101以及A3 = 00000000。A1、A2、A3 异或得到的Ap等于00000010。如果第二个磁碟出现故障,A2将不能被访问,但是可以通过A1、A3与Ap的异或进行重建:

A1 XOR A3 XOR Ap = 00000101

       冗余磁盘阵列
 A1        A2        A3
 Ap        B1        B2
 Bp        C1        C2
 C3        C4        Cp

[注 1]

注释

[编辑]
  1. ^ 数据块是格式A#,奇偶校验块是Ap。
{{bottomLinkPreText}} {{bottomLinkText}}
奇偶校验位
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?