CN102916781A - Calibration method and calibration device - Google Patents
Calibration method and calibration device Download PDFInfo
- Publication number
- CN102916781A CN102916781A CN2012104279448A CN201210427944A CN102916781A CN 102916781 A CN102916781 A CN 102916781A CN 2012104279448 A CN2012104279448 A CN 2012104279448A CN 201210427944 A CN201210427944 A CN 201210427944A CN 102916781 A CN102916781 A CN 102916781A
- Authority
- CN
- China
- Prior art keywords
- data
- crc
- crc value
- parallel data
- value
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Landscapes
- Error Detection And Correction (AREA)
- Detection And Correction Of Errors (AREA)
- Detection And Prevention Of Errors In Transmission (AREA)
Abstract
本发明实施例公开了一种校验方法及校验装置。该校验方法包括:接收并行数据,所述并行数据的字节数为X,所述并行数据的位宽为Y个字节,X为正整数,Y为正整数;采用循环冗余校验CRC电路对所述并行数据进行运算,获得第一CRC值;比较所述第一CRC值与第二CRC值是否相同,所述第二CRC值为对第一数据执行CRC获得的CRC值,所述第一数据为在第二数据的尾部添加M个字节的数据得到的数据,所述第二数据为在第三数据的尾部添加第三CRC值得到的数据,所述第三CRC值为所述第三数据的CRC值,M等于Y减去X除以Y的余数;若所述第一CRC值与所述第二CRC值相同,则确定所述并行数据通过CRC。该技术方案只需要一个CRC电路。相对于现有技术该技术方案所需的硬件资源较少。
The embodiment of the invention discloses a verification method and a verification device. The verification method includes: receiving parallel data, the number of bytes of the parallel data is X, the bit width of the parallel data is Y bytes, X is a positive integer, and Y is a positive integer; a cyclic redundancy check is adopted The CRC circuit operates on the parallel data to obtain a first CRC value; compares whether the first CRC value is the same as a second CRC value, and the second CRC value is a CRC value obtained by performing CRC on the first data, so The first data is data obtained by adding M bytes of data at the end of the second data, and the second data is obtained by adding a third CRC value at the end of the third data, and the third CRC value is The CRC value of the third data, M, is equal to the remainder of Y minus X divided by Y; if the first CRC value is the same as the second CRC value, it is determined that the parallel data passes the CRC. This technical solution requires only one CRC circuit. Compared with the prior art, this technical solution requires less hardware resources.
Description
技术领域technical field
本发明涉及数据处理技术领域,特别是涉及一种校验方法及校验装置。The invention relates to the technical field of data processing, in particular to a verification method and a verification device.
背景技术Background technique
CRC(Cyclic Redundancy Check,循环冗余校验)技术广泛应用于数据通信领域。CRC可以通过软件查表或者硬件实现。对高速数据进行CRC,一般通过硬件实现。CRC (Cyclic Redundancy Check) technology is widely used in the field of data communication. CRC can be implemented by software lookup table or hardware. Performing CRC on high-speed data is generally implemented by hardware.
现有技术中,通过硬件对位宽为多个字节的并行数据进行CRC时,需要多个CRC电路。举例来说,对于位宽为4个字节的并行数据进行CRC,需要1个字节对应的CRC电路、2个字节对应的CRC电路、3个字节对应的CRC电路以及4个字节对应的CRC电路。现有技术对位宽为多个字节的并行数据进行CRC需要的硬件资源较多。In the prior art, when CRC is performed on parallel data with a bit width of multiple bytes by hardware, multiple CRC circuits are required. For example, to perform CRC on parallel data with a bit width of 4 bytes, a CRC circuit corresponding to 1 byte, a CRC circuit corresponding to 2 bytes, a CRC circuit corresponding to 3 bytes, and a CRC circuit corresponding to 4 bytes are required. Corresponding CRC circuit. In the prior art, performing CRC on parallel data with a bit width of multiple bytes requires many hardware resources.
发明内容Contents of the invention
本发明实施例中提供了一种CRC校验方法及装置,能够减少所需的硬件资源。Embodiments of the present invention provide a CRC checking method and device, which can reduce required hardware resources.
为了解决上述技术问题,本发明实施例公开了如下技术方案:In order to solve the above technical problems, the embodiment of the present invention discloses the following technical solutions:
第一方面,提供一种校验方法,包括:In the first aspect, a verification method is provided, including:
接收并行数据,所述并行数据的字节数为X,所述并行数据的位宽为Y个字节,X为正整数,Y为正整数;Receiving parallel data, the number of bytes of the parallel data is X, the bit width of the parallel data is Y bytes, X is a positive integer, and Y is a positive integer;
采用CRC电路对所述并行数据进行运算,获得第一CRC值;using a CRC circuit to operate on the parallel data to obtain a first CRC value;
比较所述第一CRC值与第二CRC值是否相同,所述第二CRC值为对第一数据执行CRC获得的CRC值,所述第一数据为在第二数据的尾部添加M个字节的数据得到的数据,所述第二数据为在第三数据的尾部添加第三CRC值得到的数据,所述第三CRC值为所述第三数据的CRC值,M等于Y减去X除以Y的余数;Comparing whether the first CRC value is the same as the second CRC value, the second CRC value is a CRC value obtained by performing CRC on the first data, and the first data is to add M bytes at the end of the second data The data obtained from the data, the second data is the data obtained by adding the third CRC value at the end of the third data, the third CRC value is the CRC value of the third data, M is equal to Y minus X divided by Take the remainder of Y;
若所述第一CRC值与所述第二CRC值相同,则确定所述并行数据通过CRC。If the first CRC value is the same as the second CRC value, it is determined that the parallel data passes the CRC.
结合所述第一方面,在所述第一方面的第一种可能的实现方式中,所述采用所述CRC电路对所述并行数据进行运算包括:With reference to the first aspect, in a first possible implementation manner of the first aspect, using the CRC circuit to perform operations on the parallel data includes:
如果X除以Y的余数不等于0,则在所述并行数据的尾部添加第四数据,所述第四数据的长度为M个字节,得到新的并行数据;If the remainder of dividing X by Y is not equal to 0, add fourth data at the end of the parallel data, the length of the fourth data is M bytes, and obtain new parallel data;
采用所述CRC电路对所述新的并行数据进行运算。The CRC circuit is used to perform operations on the new parallel data.
结合所述第一方面,或所述第一方面的第一种可能的实现方式,在所述第一方面的第二种可能的实现方式中,所述采用所述CRC电路对所述并行数据进行运算包括:With reference to the first aspect, or the first possible implementation of the first aspect, in a second possible implementation of the first aspect, the parallel data Operations include:
如果X除以Y的余数等于0,则不在所述并行数据的尾部添加数据,采用所述CRC电路对所述并行数据进行运算。If the remainder of dividing X by Y is equal to 0, no data is added to the end of the parallel data, and the CRC circuit is used to perform operations on the parallel data.
结合所述第一方面,或所述第一方面的第一种可能的实现方式,或所述第一方面提供的第二种可能的实现方式,在所述第一方面提供的第三种可能的实现方式中,比较所述第一CRC值与所述第二CRC值是否相同之前,所述方法还包括:In combination with the first aspect, or the first possible implementation manner of the first aspect, or the second possible implementation manner provided in the first aspect, the third possibility provided in the first aspect In an implementation manner, before comparing whether the first CRC value is the same as the second CRC value, the method further includes:
分别在所述第二数据的尾部添加1至Y个字节的数据,得到Y个数据;respectively adding 1 to Y bytes of data at the end of the second data to obtain Y data;
分别对所述Y个数据执行CRC,得到Y个CRC值;performing CRC on the Y data respectively to obtain Y CRC values;
确定所述Y个CRC值中与所述Y个数据中通过在所述第二数据的尾部添加所述M个字节的数据得到的数据对应的CRC值为所述第二CRC值。Determining a CRC value among the Y CRC values corresponding to data obtained by adding the M bytes of data at the end of the second data among the Y data as the second CRC value.
第二方面,提供一种校验装置,包括:In a second aspect, a verification device is provided, including:
接收单元,用于接收并行数据,所述并行数据的字节数为X,所述并行数据的位宽为Y个字节,X为正整数,Y为正整数;The receiving unit is used to receive parallel data, the number of bytes of the parallel data is X, the bit width of the parallel data is Y bytes, X is a positive integer, and Y is a positive integer;
CRC电路,用于对所述接收单元接收的所述并行数据进行运算,获得第一CRC值;a CRC circuit, configured to perform operations on the parallel data received by the receiving unit to obtain a first CRC value;
比较单元,用于比较所述CRC电路生成的所述第一CRC值与第二CRC值是否相同,所述第二CRC值为对第一数据执行CRC获得的CRC值,所述第一数据为在第二数据的尾部添加M个字节的数据得到的数据,所述第二数据为在第三数据的尾部添加第三CRC值得到的数据,所述第三CRC值为所述第三数据的CRC值,M等于Y减去X除以Y的余数;A comparison unit, configured to compare whether the first CRC value generated by the CRC circuit is the same as a second CRC value, the second CRC value is a CRC value obtained by performing CRC on the first data, and the first data is Data obtained by adding M bytes of data at the end of the second data, the second data being data obtained by adding a third CRC value at the end of the third data, the third CRC value being the third data CRC value, M is equal to the remainder of Y minus X divided by Y;
第一确定单元,用于若所述比较单元的比较结果为所述第一CRC值与所述第二CRC值相同,则确定所述并行数据通过CRC。The first determination unit is configured to determine that the parallel data passes the CRC if the comparison result of the comparison unit is that the first CRC value is the same as the second CRC value.
结合所述第二方面,在所述第二方面的第一种可能的实现方式中,所述CRC电路具体用于:With reference to the second aspect, in a first possible implementation manner of the second aspect, the CRC circuit is specifically used for:
如果X除以Y的余数不等于0,则在所述并行数据的尾部添加第四数据,所述第四数据的长度为M个字节,得到新的并行数据;If the remainder of dividing X by Y is not equal to 0, add fourth data at the end of the parallel data, the length of the fourth data is M bytes, and obtain new parallel data;
对所述新的并行数据进行运算。Operations are performed on the new parallel data.
结合所述第二方面,或所述第二方面的第一种可能的实现方式,在所述第二方面的第二种可能的实现方式中,所述CRC电路具体用于:With reference to the second aspect, or the first possible implementation manner of the second aspect, in the second possible implementation manner of the second aspect, the CRC circuit is specifically used for:
如果X除以Y的余数等于0,则不在所述并行数据的尾部添加数据,对所述并行数据进行运算。If the remainder of dividing X by Y is equal to 0, no data is added to the end of the parallel data, and operations are performed on the parallel data.
结合所述第二方面,或所述第二方面的第一种可能的实现方式,或所述第二方面的第二种可能的实现方式,在所述第二方面的第三种可能的实现方式中,所述校验装置还包括:In combination with the second aspect, or the first possible implementation of the second aspect, or the second possible implementation of the second aspect, in the third possible implementation of the second aspect In the mode, the verification device also includes:
添加单元,用于分别在所述第二数据的尾部添加1至Y个字节的数据,得到Y个数据;an adding unit, configured to add 1 to Y bytes of data at the end of the second data respectively to obtain Y data;
计算单元,用于分别对所述添加单元生成的所述Y个数据执行CRC,得到Y个CRC值;a computing unit, configured to perform CRC on the Y pieces of data generated by the adding unit, respectively, to obtain Y CRC values;
第二确定单元,用于在所述比较单元比较所述第一CRC值与所述第二CRC值是否相同之前确定所述计算单元得到的所述Y个CRC值中与所述添加单元得到的所述Y个数据中通过在所述第二数据的尾部添加所述M个字节的数据得到的数据对应的CRC值为所述第二CRC值。A second determination unit, configured to determine whether the Y CRC values obtained by the calculation unit are the same as those obtained by the adding unit before the comparison unit compares whether the first CRC value is the same as the second CRC value The CRC value corresponding to the data obtained by adding the M bytes of data at the end of the second data among the Y data is the second CRC value.
第三方面,提供一种网络设备,所述网络设备包括所述第二方面,或所述第二方面的第一种可能的实现方式,或所述第二方面的第二种可能的实现方式,或所述第二方面的第三种可能的实现方式提供的校验装置。In a third aspect, a network device is provided, and the network device includes the second aspect, or the first possible implementation of the second aspect, or the second possible implementation of the second aspect , or the verification device provided in a third possible implementation manner of the second aspect.
上述技术方案中,通过比较所述并行数据的位宽对应的所述CRC电路生成的所述第一CRC值与所述第二CRC值是否相同,即可确定所述并行数据是否通过CRC。也就是说,上述技术方案只需要一个CRC电路。相对于现有技术中,对位宽为多个字节的并行数据进行CRC校验需要的多个CRC电路的技术方案,上述技术方案所需的硬件资源较少。In the above technical solution, by comparing whether the first CRC value generated by the CRC circuit corresponding to the bit width of the parallel data is the same as the second CRC value, it can be determined whether the parallel data passes the CRC. That is to say, the above technical solution only needs one CRC circuit. Compared with the technical solution in the prior art that requires multiple CRC circuits for CRC checking on parallel data with a bit width of multiple bytes, the above technical solution requires fewer hardware resources.
附图说明Description of drawings
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,对于本领域普通技术人员而言,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, for those of ordinary skill in the art, In other words, other drawings can also be obtained from these drawings on the premise of not paying creative work.
图1本发明实施例提供的一种校验方法流程图;Fig. 1 is a flow chart of a verification method provided by an embodiment of the present invention;
图2本发明实施例提供的一种对第二数据进行处理获得Y个数据的方法流程图;FIG. 2 is a flow chart of a method for processing second data to obtain Y data provided by an embodiment of the present invention;
图3为本发明实施例提供的一种校验装置的结构示意图;Fig. 3 is a schematic structural diagram of a verification device provided by an embodiment of the present invention;
图4为本发明实施例提供的一种校验装置的结构示意图。Fig. 4 is a schematic structural diagram of a verification device provided by an embodiment of the present invention.
具体实施方式Detailed ways
为了使本技术领域的人员更好地理解本发明实施例中的技术方案,并使本发明实施例的上述目的、特征和优点能够更加明显易懂,下面结合附图对本发明实施例中技术方案作进一步详细的说明。In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, and to make the above-mentioned purposes, features and advantages of the embodiments of the present invention more obvious and understandable, the following describes the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings For further detailed explanation.
图1为本发明实施例提供的一种校验方法的流程图。参见图1,所述方法包括:FIG. 1 is a flowchart of a verification method provided by an embodiment of the present invention. Referring to Figure 1, the method includes:
101,接收并行数据。101. Receive parallel data.
举例来说,101的执行主体可以是接收器。For example, the execution subject of 101 may be a receiver.
举例来说,所述并行数据可以通过如下方式得到:For example, the parallel data can be obtained as follows:
串并转换器对接收到的串行数据进行处理,转化为所述并行数据。The serial-to-parallel converter processes the received serial data and converts it into the parallel data.
所述并行数据的字节数为X,并行数据的位宽为Y个字节,其中,X为正整数,Y为正整数。举例来说,Y的取值可以是1、2或者3。The number of bytes of the parallel data is X, and the bit width of the parallel data is Y bytes, where X is a positive integer and Y is a positive integer. For example, the value of Y can be 1, 2 or 3.
102,采用CRC电路对所述并行数据进行运算,获得第一CRC值。102. Use a CRC circuit to perform operations on the parallel data to obtain a first CRC value.
举例来说,102的执行主体可以是硬件电路,例如ASIC(Application SpecificIntegrated Circuit,专用集成电路)或者FPGA(Field-Programmable Gate Array,现场可编程门阵列)。For example, the execution subject of 102 may be a hardware circuit, such as ASIC (Application Specific Integrated Circuit, application specific integrated circuit) or FPGA (Field-Programmable Gate Array, field programmable gate array).
本领域的技术人员可以理解,所述CRC电路是与所述并行数据的位宽相对应的电路。Those skilled in the art can understand that the CRC circuit is a circuit corresponding to the bit width of the parallel data.
103,比较所述第一CRC值与第二CRC值是否相同。103. Compare whether the first CRC value is the same as the second CRC value.
所述第二CRC值为对第一数据执行CRC获得的CRC值,所述第一数据为在第二数据的尾部添加M个字节的数据得到的数据,所述第二数据为在第三数据的尾部添加第三CRC值得到的数据,所述第三CRC值为所述第三数据的CRC值,M等于Y减去X除以Y的余数,即M=Y-MOD(X,Y)。MOD(X,Y)等于X除以Y的余数。所述M个字节的数据可以是常数,例如可以是M个字节的0或者M个字节的1。The second CRC value is a CRC value obtained by performing CRC on the first data, the first data is data obtained by adding M bytes of data at the end of the second data, and the second data is the data obtained by adding M bytes at the end of the second data. The data obtained by adding the third CRC value to the end of the data, the third CRC value is the CRC value of the third data, and M is equal to the remainder of Y minus X divided by Y, that is, M=Y-MOD(X, Y ). MOD(X,Y) is equal to the remainder of dividing X by Y. The M bytes of data may be constants, such as M bytes of 0 or M bytes of 1.
举例来说,103的执行主体可以是比较器。For example, the execution subject of 103 may be a comparator.
104,若所述第一CRC值与所述第二CRC值相同,则确定所述并行数据通过CRC。104. If the first CRC value is the same as the second CRC value, determine that the parallel data passes the CRC.
104的执行主体可以是中央处理器(central processing unit,CPU),也可以是网络处理器(network processor,NP)。例如,104的执行主体可以是所述NP的转发单元。举例来说,如果所述转发单元确定所述并行数据通过CRC,所述转发单元可以对所述并行数据进行转发。如果所述转发单元确定所述并行数据没有通过CRC,所述转发单元可以对所述并行数据进行丢弃。The execution subject of 104 may be a central processing unit (central processing unit, CPU), or a network processor (network processor, NP). For example, the execution subject of 104 may be the forwarding unit of the NP. For example, if the forwarding unit determines that the parallel data passes the CRC, the forwarding unit may forward the parallel data. If the forwarding unit determines that the parallel data does not pass the CRC, the forwarding unit may discard the parallel data.
本领域的技术人员可以理解,上述技术方案中,如果所述第三数据取不同的值,所述第二数据也必然取不同的值,所述第一数据也必然取不同的值,但是所述第二CRC值取相同的值。Those skilled in the art can understand that in the above technical solution, if the third data takes different values, the second data must also take different values, and the first data must also take different values, but the The second CRC value takes the same value.
例如,若第三数据为0x55,采用以太CRC32对该第三数据进行运算得到的所述第三CRC值为0xfb4a03c9,则在所述第三数据的尾部添加所述第三CRC值得到的数据为0x55fb4a03c9,也即所述第二数据为0x55fb4a03c9。在该第二数据尾部添加N个字节的数据得到所述第一数据。所述第一数据为0x55fb4a03c900。所述N个字节的数据为0x00。其中,N为1。则对该第一数据进行CRC计算,例如采用以太CRC32,获得的所述第一数据的CRC值为0x1df722c6。因此,所述第二CRC值为0x1df722c6。For example, if the third data is 0x55, the third CRC value obtained by using Ethernet CRC32 to operate on the third data is 0xfb4a03c9, then the data obtained by adding the third CRC value at the end of the third data is 0x55fb4a03c9, that is, the second data is 0x55fb4a03c9. Adding N bytes of data at the end of the second data to obtain the first data. The first data is 0x55fb4a03c900. The data of the N bytes is 0x00. Wherein, N is 1. Then, CRC calculation is performed on the first data, for example, using Ethernet CRC32, and the obtained CRC value of the first data is 0x1df722c6. Therefore, the second CRC value is 0x1df722c6.
若第三数据为0x55aa,采用以太CRC32对该第三数据进行运算得到的所述第三CRC值为0x18f116b0,则在所述第三数据的尾部添加所述第三CRC值得到的数据为0x55aa18f116b0,也即所述第二数据为0x55aa18f116b0。在该第二数据尾部也添加N个字节的数据得到所述第一数据。所述第一数据为0x55aa18f116b000,所述N个字节的数据为0x00。其中,N为1。则对该第一数据进行CRC计算,例如采用以太CRC32,获得的所述第一数据的CRC值也为0x1df722c6。因此,所述第二CRC值为0x1df722c6。If the third data is 0x55aa, the third CRC value obtained by using Ethernet CRC32 to operate on the third data is 0x18f116b0, then the data obtained by adding the third CRC value at the end of the third data is 0x55aa18f116b0, That is, the second data is 0x55aa18f116b0. N bytes of data are also added to the end of the second data to obtain the first data. The first data is 0x55aa18f116b000, and the N bytes of data are 0x00. Wherein, N is 1. Then perform CRC calculation on the first data, for example, using Ethernet CRC32, and the obtained CRC value of the first data is also 0x1df722c6. Therefore, the second CRC value is 0x1df722c6.
若第三数据为0x55aa55,采用以太CRC32对该第三数据进行运算得到的所述第三CRC值为0x51c4dfda,则在所述第三数据的尾部添加所述第三CRC值得到的数据为0x55aa5551c4dfda,也即所述第二数据为0x55aa5551c4dfda。在该第二数据尾部也添加N个字节的数据得到所述第一数据。所述第一数据为0x55aa5551c4dfda00,所述N个字节的数据为0x00。其中,N为1。则对该第一数据进行CRC计算,例如采用以太CRC32,获得的所述第一数据的CRC值也为0x1df722c6。因此,所述第二CRC值为0x1df722c6。If the third data is 0x55aa55, the third CRC value obtained by using Ethernet CRC32 to operate on the third data is 0x51c4dfda, then the data obtained by adding the third CRC value at the end of the third data is 0x55aa5551c4dfda, That is, the second data is 0x55aa5551c4dfda. N bytes of data are also added to the end of the second data to obtain the first data. The first data is 0x55aa5551c4dfda00, and the N bytes of data are 0x00. Wherein, N is 1. Then perform CRC calculation on the first data, for example, using Ethernet CRC32, and the obtained CRC value of the first data is also 0x1df722c6. Therefore, the second CRC value is 0x1df722c6.
根据上述描述可以看出,所述第二CRC值与M有关,与所述第三数据无关,与所述第二数据无关,与所述M个字节的取值无关。M的取值确定后,所述第二CRC值也确定。根据上述规律,在获得所述并行数据的第一CRC值后,若第一CRC值与所述第二CRC值相同,则可确定所述并行数据通过CRC。According to the above description, it can be seen that the second CRC value is related to M, has nothing to do with the third data, has nothing to do with the second data, and has nothing to do with the values of the M bytes. After the value of M is determined, the second CRC value is also determined. According to the above rules, after the first CRC value of the parallel data is obtained, if the first CRC value is the same as the second CRC value, it can be determined that the parallel data passes the CRC.
上述技术方案中,通过比较所述并行数据的位宽对应的所述CRC电路生成的所述第一CRC值与所述第二CRC值是否相同,即可确定所述并行数据是否通过CRC。也就是说,上述技术方案只需要一个CRC电路。相对于现有技术中,对位宽为多个字节的并行数据进行CRC校验需要的多个CRC电路的技术方案,上述技术方案所需的硬件资源较少。In the above technical solution, by comparing whether the first CRC value generated by the CRC circuit corresponding to the bit width of the parallel data is the same as the second CRC value, it can be determined whether the parallel data passes the CRC. That is to say, the above technical solution only needs one CRC circuit. Compared with the technical solution in the prior art that requires multiple CRC circuits for CRC checking on parallel data with a bit width of multiple bytes, the above technical solution requires fewer hardware resources.
可选的,图1所示的方法中,采用所述CRC电路对所述并行数据进行运算可以包括:Optionally, in the method shown in FIG. 1, using the CRC circuit to perform operations on the parallel data may include:
如果X除以Y的余数不等于0,则在所述并行数据的尾部添加第四数据,所述第四数据的长度为M个字节,得到新的并行数据;该第四数据可以是常数,例如可以是M个字节的0或者M个字节的1等。该第四数据的字节长度与第二数据尾部添加的数据的字节长度均为M个。If the remainder of dividing X by Y is not equal to 0, then add the fourth data at the end of the parallel data, the length of the fourth data is M bytes to obtain new parallel data; the fourth data can be a constant , for example, can be M bytes of 0 or M bytes of 1, etc. The byte length of the fourth data and the byte length of the data added at the end of the second data are both M.
采用所述CRC电路对所述新的并行数据进行运算。The CRC circuit is used to perform operations on the new parallel data.
可选的,图1所示的方法中,采用所述CRC电路对所述并行数据进行运算可以包括:Optionally, in the method shown in FIG. 1, using the CRC circuit to perform operations on the parallel data may include:
如果X除以Y的余数等于0,则不在所述并行数据的尾部添加数据,采用所述CRC电路对所述并行数据进行运算。If the remainder of dividing X by Y is equal to 0, no data is added to the end of the parallel data, and the CRC circuit is used to perform operations on the parallel data.
可选的,图1所示的方法中,比较所述第一CRC值与所述第二CRC值是否相同之前,该方法还可以包括:Optionally, in the method shown in FIG. 1, before comparing whether the first CRC value is the same as the second CRC value, the method may also include:
201,分别在所述第二数据的尾部添加1至Y个字节的数据,得到Y个数据。201. Add 1 to Y bytes of data to the end of the second data respectively to obtain Y data.
例如,若所述并行数据的位宽为8个字节,则在所述第二数据的尾部分别添加1至8个字节的数据,得到8个数据。在所述第二数据的尾部添加4个字节的数据得到的数据是所述8个数据中的一个数据。For example, if the bit width of the parallel data is 8 bytes, 1 to 8 bytes of data are respectively added to the end of the second data to obtain 8 data. The data obtained by adding 4 bytes of data at the end of the second data is one of the 8 pieces of data.
202,分别对所述Y个数据执行CRC,得到Y个CRC值。202. Perform CRC on the Y data respectively to obtain Y CRC values.
举例来说,在获得所述Y个CRC值后,可以将所述Y个CRC值进行存储,具体的,可以将添加的字节数及其对应的CRC值以列表的形式进行存储。For example, after the Y CRC values are obtained, the Y CRC values may be stored, specifically, the added bytes and their corresponding CRC values may be stored in a list form.
203,确定所述Y个CRC值中与所述Y个数据中通过在所述第二数据的尾部添加所述M个字节的数据得到的数据为对应的CRC值为所述第二CRC值。203. Determine that the CRC value corresponding to the Y CRC value and the Y data obtained by adding the M bytes of data at the end of the second data is the second CRC value .
举例来说,若所述并行数据的字节数为36,所述并行数据的位宽为8个字节,则根据公式M=Y-MOD(X,Y)可以确定M为4,则将所述8个数据中在所述第二数据尾部添加所述4个字节的数据得到的数据作为所述第一数据。所述第一数据对应的CRC值即为所述第二CRC值。For example, if the number of bytes of the parallel data is 36, and the bit width of the parallel data is 8 bytes, then it can be determined that M is 4 according to the formula M=Y-MOD(X,Y), then the Among the 8 pieces of data, data obtained by adding the 4 bytes of data at the end of the second data is used as the first data. The CRC value corresponding to the first data is the second CRC value.
关于201、202以及203,具体请参见图2。Regarding 201, 202 and 203, please refer to FIG. 2 for details.
图3为本发明实施例提供的一种校验装置的结构示意图。所述校验装置可以执行图1所示的方法。参见图3,所述校验装置包括:Fig. 3 is a schematic structural diagram of a verification device provided by an embodiment of the present invention. The checking device can execute the method shown in FIG. 1 . Referring to Fig. 3, the verification device includes:
接收单元301,用于接收并行数据,所述并行数据的字节数为X,所述并行数据的位宽为Y个字节,X为正整数,Y为正整数。The receiving
举例来说,所述接收单元301可以是接收器。For example, the receiving
举例来说,所述并行数据可以通过如下方式得到:For example, the parallel data can be obtained as follows:
串并转换器对接收到的串行数据进行处理,转化为所述并行数据。The serial-to-parallel converter processes the received serial data and converts it into the parallel data.
所述并行数据的字节数为X,并行数据的位宽为Y个字节,其中,X为正整数,Y为正整数。举例来说,Y的取值可以是1、2或者3。The number of bytes of the parallel data is X, and the bit width of the parallel data is Y bytes, where X is a positive integer and Y is a positive integer. For example, the value of Y can be 1, 2 or 3.
CRC电路302,用于对所述接收单元301接收的所述并行数据进行运算,获得第一CRC值。The
举例来说,所述CRC电路302可以是硬件电路。所述硬件电路可以是ASIC或者FPGA。For example, the
本领域的技术人员可以理解,所述CRC电路是与所述并行数据的位宽相对应的电路。Those skilled in the art can understand that the CRC circuit is a circuit corresponding to the bit width of the parallel data.
比较单元303,用于比较所述循环冗余校验电路302生成的所述第一CRC值与第二CRC值是否相同,所述第二CRC值为对第一数据执行CRC获得的CRC值,所述第一数据为在第二数据的尾部添加M个字节的数据得到的数据,所述第二数据为在第三数据的尾部添加第三CRC值得到的数据,所述第三CRC值为所述第三数据的CRC值,M等于Y减去X除以Y的余数。A comparing
所述第二CRC值为对第一数据执行CRC获得的CRC值,所述第一数据为在第二数据的尾部添加M个字节的数据得到的数据,所述第二数据为在第三数据的尾部添加第三CRC值得到的数据,所述第三CRC值为所述第三数据的CRC值,M等于Y减去X除以Y的余数,即M=Y-MOD(X,Y)。MOD(X,Y)等于X除以Y的余数。所述M个字节的数据可以是常数,例如可以是M个字节的0或者M个字节的1。The second CRC value is a CRC value obtained by performing CRC on the first data, the first data is data obtained by adding M bytes of data at the end of the second data, and the second data is the data obtained by adding M bytes at the end of the second data. The data obtained by adding the third CRC value to the end of the data, the third CRC value is the CRC value of the third data, and M is equal to the remainder of Y minus X divided by Y, that is, M=Y-MOD(X, Y ). MOD(X,Y) is equal to the remainder of dividing X by Y. The M bytes of data may be constants, such as M bytes of 0 or M bytes of 1.
举例来说,所述比较单元303可以是比较器。For example, the
第一确定单元304,用于若所述比较单元303的比较结果为所述第一CRC值与所述第二CRC值相同,则确定所述并行数据通过CRC。The first determining
所述第一确定单元304可以是CPU,也可以是NP。例如,所述第一确定单元304可以是所述NP的转发单元。举例来说,如果所述转发单元确定所述并行数据通过CRC,所述转发单元可以对所述并行数据进行转发。如果所述转发单元确定所述并行数据没有通过CRC,所述转发单元可以对所述并行数据进行丢弃。The
上述校验装置通过比较所述并行数据的位宽对应的所述CRC电路生成的所述第一CRC值与所述第二CRC值是否相同,即可确定所述并行数据是否通过CRC。也就是说,上述校验装置只需要一个CRC电路。相对于现有技术中,对位宽为多个字节的并行数据进行CRC校验需要的多个CRC电路的装置,上述校验装置所需的硬件资源较少。The verification device can determine whether the parallel data passes the CRC by comparing whether the first CRC value generated by the CRC circuit corresponding to the bit width of the parallel data is the same as the second CRC value. That is to say, the above checking device only needs one CRC circuit. Compared with the device in the prior art that requires multiple CRC circuits for performing CRC verification on parallel data with a bit width of multiple bytes, the verification device requires fewer hardware resources.
可选的,图3所示的校验装置中,所述CRC电路具体可以用于:如果X除以Y的余数不等于0,则在所述并行数据的尾部添加第四数据,所述第四数据的长度为M个字节,得到新的并行数据;对所述新的并行数据进行运算。Optionally, in the verification device shown in FIG. 3, the CRC circuit may be specifically configured to: if the remainder of dividing X by Y is not equal to 0, add fourth data at the end of the parallel data, and the first The length of the four data is M bytes, and new parallel data is obtained; and operation is performed on the new parallel data.
可选的,图3所示的校验装置中,所述CRC电路具体可以用于:如果X除以Y的余数等于0,则不在所述并行数据的尾部添加数据,对所述并行数据进行运算。Optionally, in the verification device shown in FIG. 3 , the CRC circuit can be specifically used for: if the remainder of dividing X by Y is equal to 0, then no data is added to the end of the parallel data, and the parallel data is performed operation.
可选的,图3所示的校验装置中,还可以包括:Optionally, in the verification device shown in Figure 3, it may also include:
添加单元405,用于分别在所述第二数据的尾部添加1至Y个字节的数据,得到Y个数据;Adding
计算单元406,用于分别对所述添加单元405生成的所述Y个数据执行CRC,得到Y个CRC值;A
第二确定单元407,用于在所述比较单元303比较所述第一CRC值与所述第二CRC值是否相同之前确定所述计算单元406得到的所述Y个CRC值中与所述添加单元405得到的所述Y个数据中通过在所述第二数据的尾部添加所述M个字节的数据得到的数据对应的CRC值为所述第二CRC值。The
举例来说,所述比较单元303可以根据所述第二确定单元407确定的所述第二CRC值比较所述第一CRC值与所述第二CRC值是否相同。For example, the comparing
关于所述添加单元405、所述计算单元406以及所述第二确定单元407,具体请参见图4。For details about the adding
本发明实施例还提供了一种网络设备,该网络设备包括图3所示的校验装置或者图4所示的校验装置。An embodiment of the present invention also provides a network device, which includes the verification device shown in FIG. 3 or the verification device shown in FIG. 4 .
举例来说,所述网络设备可以是路由器、交换机、宽带远程接入服务器(broadbandremote access server,BRAS)、防火墙或者负载均衡器。For example, the network device may be a router, a switch, a broadband remote access server (broadband remote access server, BRAS), a firewall or a load balancer.
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本发明的范围。Those skilled in the art can appreciate that the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed by hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be regarded as exceeding the scope of the present invention.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that for the convenience and brevity of the description, the specific working process of the above-described system, device and unit can refer to the corresponding process in the foregoing method embodiment, which will not be repeated here.
在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods may be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or May be integrated into another system, or some features may be ignored, or not implemented. In another point, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit.
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或处理器(processor)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。If the functions described above are realized in the form of software function units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the essence of the technical solution of the present invention or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including Several instructions are used to make a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor (processor) execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program codes. .
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应所述以权利要求的保护范围为准。The above is only a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Anyone skilled in the art can easily think of changes or substitutions within the technical scope disclosed in the present invention. Should be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims (9)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210427944.8A CN102916781B (en) | 2012-10-31 | 2012-10-31 | Calibration method and calibration device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210427944.8A CN102916781B (en) | 2012-10-31 | 2012-10-31 | Calibration method and calibration device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN102916781A true CN102916781A (en) | 2013-02-06 |
CN102916781B CN102916781B (en) | 2015-07-08 |
Family
ID=47615026
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201210427944.8A Expired - Fee Related CN102916781B (en) | 2012-10-31 | 2012-10-31 | Calibration method and calibration device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN102916781B (en) |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103701566A (en) * | 2013-12-18 | 2014-04-02 | 华为技术有限公司 | Check method and check device |
CN105790887A (en) * | 2014-12-26 | 2016-07-20 | 上海贝尔股份有限公司 | Method and device for generating parallel CRC values for packets |
CN107046541A (en) * | 2017-04-18 | 2017-08-15 | 深圳市法马新智能设备有限公司 | A kind of wireless receiving and dispatching encryption communication method and its device |
CN112269424A (en) * | 2020-11-19 | 2021-01-26 | 珠海零边界集成电路有限公司 | Chip clock frequency calibration method, device, equipment and medium |
CN112306741A (en) * | 2020-11-19 | 2021-02-02 | 山东云海国创云计算装备产业创新中心有限公司 | CRC (Cyclic redundancy check) method and related device |
CN114006678A (en) * | 2021-11-01 | 2022-02-01 | 合肥国科天迅科技有限公司 | Method for FC-AE equipment to quickly obtain received frame source |
CN114625561A (en) * | 2022-03-03 | 2022-06-14 | 杭州义益钛迪信息技术有限公司 | Data verification method, device, electronic device, and storage medium |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1933605A (en) * | 2005-09-12 | 2007-03-21 | 三星电子株式会社 | Cyclic redundancy check circuit and communication system having the same for multi-channel communication |
CN101527615A (en) * | 2009-04-07 | 2009-09-09 | 华为技术有限公司 | Implementation method of cyclic redundancy check (CRC) codes and device |
CN102394719A (en) * | 2011-09-21 | 2012-03-28 | 浙江铭道通信技术有限公司 | Multichannel HDLC data processing method based on FPGA |
-
2012
- 2012-10-31 CN CN201210427944.8A patent/CN102916781B/en not_active Expired - Fee Related
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1933605A (en) * | 2005-09-12 | 2007-03-21 | 三星电子株式会社 | Cyclic redundancy check circuit and communication system having the same for multi-channel communication |
CN101527615A (en) * | 2009-04-07 | 2009-09-09 | 华为技术有限公司 | Implementation method of cyclic redundancy check (CRC) codes and device |
CN102394719A (en) * | 2011-09-21 | 2012-03-28 | 浙江铭道通信技术有限公司 | Multichannel HDLC data processing method based on FPGA |
Cited By (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103701566A (en) * | 2013-12-18 | 2014-04-02 | 华为技术有限公司 | Check method and check device |
CN103701566B (en) * | 2013-12-18 | 2017-09-12 | 华为技术有限公司 | A kind of method of calibration and device |
CN105790887A (en) * | 2014-12-26 | 2016-07-20 | 上海贝尔股份有限公司 | Method and device for generating parallel CRC values for packets |
CN107046541A (en) * | 2017-04-18 | 2017-08-15 | 深圳市法马新智能设备有限公司 | A kind of wireless receiving and dispatching encryption communication method and its device |
CN107046541B (en) * | 2017-04-18 | 2023-02-03 | 深圳市法马新智能设备有限公司 | Wireless transceiving encryption communication method and device thereof |
CN112269424A (en) * | 2020-11-19 | 2021-01-26 | 珠海零边界集成电路有限公司 | Chip clock frequency calibration method, device, equipment and medium |
CN112306741A (en) * | 2020-11-19 | 2021-02-02 | 山东云海国创云计算装备产业创新中心有限公司 | CRC (Cyclic redundancy check) method and related device |
CN112306741B (en) * | 2020-11-19 | 2022-12-23 | 山东云海国创云计算装备产业创新中心有限公司 | CRC (Cyclic redundancy check) method and related device |
CN114006678A (en) * | 2021-11-01 | 2022-02-01 | 合肥国科天迅科技有限公司 | Method for FC-AE equipment to quickly obtain received frame source |
CN114006678B (en) * | 2021-11-01 | 2024-04-19 | 合肥华控天芯科技有限公司 | Method for quickly acquiring source of received frame by FC-AE equipment |
CN114625561A (en) * | 2022-03-03 | 2022-06-14 | 杭州义益钛迪信息技术有限公司 | Data verification method, device, electronic device, and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN102916781B (en) | 2015-07-08 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN102916781B (en) | Calibration method and calibration device | |
CN105528325B (en) | A kind of guard method and system of standard SPI protocol high-speed transfer | |
EP3607696A1 (en) | Digital signature systems and methods for network path trace | |
US20140198638A1 (en) | Low-latency lossless switch fabric for use in a data center | |
JP5673805B2 (en) | Network device, communication system, abnormal traffic detection method and program | |
CN113839964B (en) | Communication method and gateway device for gateway device | |
US20180143872A1 (en) | Cyclic redundancy check calculation for multiple blocks of a message | |
EP3065323B1 (en) | Transmission method and device based on management data input/output multi-source agreements | |
CN104579948A (en) | Method and device for message fragmentation processing | |
CN103873464B (en) | Message processing method and forwarding equipment | |
CN113452475B (en) | Data transmission method, device and related equipment | |
WO2014042966A1 (en) | Telemetry data routing | |
CN104579970A (en) | A policy matching method and device for IPv6 packets | |
US20170279639A1 (en) | Bridge port extender | |
US10447599B2 (en) | Packet forwarding method, system, and apparatus | |
CN108574490B (en) | Method and device for calculating Cyclic Redundancy Check (CRC) code | |
CN114070752B (en) | Test method, test device, electronic equipment and computer readable storage medium | |
CN104205745A (en) | Method and device for processing message | |
CN103888314B (en) | The method that finite state machine status are verified based on uio sequence method | |
CN109639555B (en) | Link layer message generation method, link layer message generation device and terminal device | |
CN107239361A (en) | Data processing equipment and data processing method | |
CN104184628A (en) | Looped network detection method in network, network equipment and looped network detection system | |
CN106411564B (en) | Apparatus and method for detecting Ethernet frame | |
CN114448565B (en) | Cyclic redundancy check calculation method, cyclic redundancy check calculation device, electronic equipment and storage medium | |
CN110868388B (en) | System and method for operating networked devices |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
TR01 | Transfer of patent right |
Effective date of registration: 20200616 Address after: Room 303-75, block a, Xidong Chuang Rong building, 78 Danshan Road, anzhen street, Xishan District, Wuxi City, Jiangsu Province Patentee after: Wuxi huinuowida IOT Technology Co.,Ltd. Address before: 625, room 269, Connaught platinum Plaza, No. 518101, Qianjin Road, Xin'an street, Shenzhen, Guangdong, Baoan District Patentee before: SHENZHEN SHANGGE INTELLECTUAL PROPERTY SERVICE Co.,Ltd. Effective date of registration: 20200616 Address after: 625, room 269, Connaught platinum Plaza, No. 518101, Qianjin Road, Xin'an street, Shenzhen, Guangdong, Baoan District Patentee after: SHENZHEN SHANGGE INTELLECTUAL PROPERTY SERVICE Co.,Ltd. Address before: 518129 Bantian HUAWEI headquarters office building, Longgang District, Guangdong, Shenzhen Patentee before: HUAWEI TECHNOLOGIES Co.,Ltd. |
|
TR01 | Transfer of patent right | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20150708 |
|
CF01 | Termination of patent right due to non-payment of annual fee |