Serial communication data polarity recovery method for asymmetric K code encoding and decoding
Technical Field
The invention relates to the field of computer network technology and communication, in particular to a serial communication data polarity recovery method for asymmetric K code encoding and decoding.
Background
SERDES is a short term for SERializer/DESerializer, and is a Time Division Multiplexing (TDM) and point-to-point (P2P) serial communication technology, and SERDES is a general high-speed serial interface technology, and is widely used in network applications and the like. With the continuous development of the Serdes technology, higher requirements are put forward on an equalizer, a phase discriminator, jitter tolerance and data clock recovery capability. How to reduce the transmission error rate as much as possible and reduce the phase error of the recovered clock is one of the important indexes for evaluating the performance of Serdes.
However, limited by PMA (physical media adaptation layer) design performance, a clock recovered by CDR (clock data recovery) may generate a large phase shift, and if data is subjected to manchester encoding and decoding, since level transition occurs right in the middle of each symbol, a completely opposite sampling result may be obtained due to a difference in sampling position, which may cause inversion of data polarity. In addition, due to the chip technology, board-level PCB wiring, via holes and the like, the external high-speed differential data line of the PMA is reversely connected, and the phenomenon of data polarity inversion can also occur in the sampling result.
At present, the polarity calibration can be indirectly realized by utilizing the existing 8B/10B coding and decoding technology, namely, the coding and decoding processing is carried out by sending a specific sequence, the data polarity is judged by comparing and detecting the recovered data and the sent data, and in order to realize the real-time monitoring of the data polarity in practice, a specific data code group needs to be regularly inserted for inspection, so that the effective data bandwidth resource is occupied, the design complexity is further increased, the normal data transmission is interrupted, and the polarity detection calibration is difficult to continuously carry out. Therefore, a new technical means is continued, and the problem of data polarity can be solved in a simple and efficient manner.
Disclosure of Invention
In view of the above-mentioned shortcomings of the prior art, the present invention provides a serial communication data polarity recovery method for asymmetric K-code encoding and decoding to solve the above-mentioned technical problems.
The invention provides a serial communication data polarity recovery method for asymmetric K code encoding and decoding, which comprises the following steps:
preprocessing a data stream to be transmitted, wherein K codes are inserted into the data stream to be transmitted at intervals in the preprocessing;
8B/10B coding is carried out on the preprocessed data stream to obtain normal coded data;
mapping the K code into an asymmetric polarity code, forming a new data stream with the rest of the encoded data, and sending the new data stream to a receiving end;
and detecting the encoding polarity of the received data stream at the receiving end, judging whether the polarity of the received data stream is reversed or not according to the polarity detection result, and if so, adjusting the polarity of the data with the polarity reversal and recovering the data with the polarity reversal.
Further, the mapping the K code to an asymmetric polarity code includes: and replacing the symmetrical K code subjected to 8B/10B coding in the normal coding data with two asymmetrical polarity codes according to the 8B/10B coding polarity rule.
Further, the data stream to be sent includes an effective data stream and an idle data stream, the preprocessing includes inserting K codes into the idle data stream at intervals, and mapping the K codes into one of two asymmetric polarity codes after the data stream to be sent is subjected to 8B/10B coding.
Further, the current polarity of the asymmetric polarity code in the 8B/10B coded data is the same as the end polarity of the previous data code.
Further, the polarity adjustment includes bit-wise inverting the received data bits.
Further, the polarity detection includes:
performing polarity defining on the received data stream, the polarity defining comprising continuously detecting correctness of the asymmetric coding polarity,
if the polarities of the plurality of asymmetric codes detected continuously are correct, judging that the polarity of the serial communication data is correct, and keeping the polarity unadjusted;
if the polarity errors of a plurality of asymmetric codes are continuously detected, judging the polarity error of the serial communication data, and reversing the polarity of the serial communication data;
continuously detecting the correctness of the asymmetric polarity codes, recording the change quantity when detecting that the correctness is reversely changed,
if the change quantity exceeds a preset quantity threshold value, carrying out polarity definition again;
if the change quantity does not exceed the preset quantity threshold value, continuing to detect;
and if the polarity correctness is recovered, clearing the change number count.
The invention also provides a computer-readable storage medium, on which a computer program is stored, which program, when being executed by a processor, carries out the method of any one of the above.
The present invention also provides an electronic terminal, comprising: a processor and a memory;
the memory is adapted to store a computer program and the processor is adapted to execute the computer program stored by the memory to cause the terminal to perform the method as defined in any one of the above.
The invention has the beneficial effects that: according to the serial communication data polarity recovery method for asymmetric K code encoding and decoding, the K code is mapped into two asymmetric polarity codes, the data polarity problem is solved, the fault tolerance of a channel is improved, the data polarity check function is added on the basis of ensuring the original byte delimiting function, the polarity inversion caused by problems of PMA design, process problems, PCB wiring and the like in a high-speed Serdes data path can be effectively solved, the polarity error in the data path is effectively corrected, and the serial communication data polarity recovery method is particularly suitable for the conditions that the use requirement on control information is not high and all K code forms in standard 8/10 codes are not required to be used completely.
Drawings
Fig. 1 is a schematic diagram of a sending end and a receiving end processing procedure in a data polarity recovery method of asymmetric polarity encoding and decoding in an embodiment of the present invention.
Fig. 2 is a flowchart illustrating a data polarity recovery method of asymmetric polarity encoding and decoding according to an embodiment of the present invention.
Fig. 3 is a schematic diagram of a polarity encoding mapping principle of a data polarity recovery method of asymmetric polarity encoding and decoding according to an embodiment of the present invention.
Fig. 4 is a schematic diagram illustrating the detection and adjustment of the polarity of the data path in the data polarity recovery method of asymmetric polarity encoding and decoding according to the embodiment of the present invention.
Detailed Description
The embodiments of the present invention are described below with reference to specific embodiments, and other advantages and effects of the present invention will be easily understood by those skilled in the art from the disclosure of the present specification. The invention is capable of other and different embodiments and of being practiced or of being carried out in various ways, and its several details are capable of modification in various respects, all without departing from the spirit and scope of the present invention. It is to be noted that the features in the following embodiments and examples may be combined with each other without conflict.
It should be noted that the drawings provided in the following embodiments are only for illustrating the basic idea of the present invention, and the components related to the present invention are only shown in the drawings rather than drawn according to the number, shape and size of the components in actual implementation, and the type, quantity and proportion of the components in actual implementation may be changed freely, and the layout of the components may be more complicated.
The method for recovering the polarity of serial communication data of asymmetric K code encoding and decoding in the embodiment comprises the following steps:
preprocessing a data stream to be transmitted, wherein the preprocessing comprises inserting K codes into the data stream to be transmitted at intervals;
8B/10B coding is carried out on the preprocessed data stream to obtain normal coded data;
mapping the K code into an asymmetric polarity code, forming a new data stream with the rest of the encoded data, and sending the new data stream to a receiving end;
and performing polarity detection on the polarity code of the received data stream at the receiving end, judging whether polarity inversion exists in the received data stream according to a polarity detection result, and if so, performing polarity adjustment on the data with the polarity inversion, and recovering the data with the polarity inversion.
As shown in fig. 1 and 2, in this embodiment, K codes are inserted into a transmission data stream, 8B/10B coding is performed, normal data is generated into coded data, and the K code data is mapped into one of polarity codes a-and B +, forms a new data stream with the remaining coded data, and then performs specific coding or other data processing, and transmits the new data stream to a receiving end; the receiving end receives data, defines a boundary for the data stream, then performs polarity encoding detection, determines the current data polarity by continuously identifying the characteristics of polarity encoding in the data stream, adjusts the data as required, then performs 8B/10B decoding on the data, and further performs the decoded related data processing, wherein the data processing includes but is not limited to encoding and decoding technologies such as Manchester encoding and decoding, and the like, and the data processing can be easily obtained by the skilled person through the prior art, and the details are not repeated.
As shown in fig. 3, the K code in this embodiment is a subset of an 8B/10B code table, and includes a plurality of K code words, which are usually inserted into data encoding as characteristic code words for character delimitation before decoding, and symmetric code patterns are generated after encoding bytes in the subset according to the standard code table rule. In this embodiment, mapping the K code into an asymmetric polarity code includes: and replacing the symmetrical K code subjected to 8B/10B coding in the normal coding data with two asymmetrical polarity codes according to the 8B/10B coding polarity rule. In this embodiment, taking the K28.5 code as an example, after the code is normally encoded according to the standard code table rule K28.5 code (101_11100), symmetric code patterns 001111_1010 and 110000_0101 are generated, and the original symmetric code is mapped to two asymmetric polarity codes, i.e., a- (001111_0101) and B + (110000_ 1001). In the encoding process, because the embodiment only performs asymmetric mapping processing on the K28.5 code, replaces the symmetric encoding of the original code table, and does not additionally increase data bits and other characteristic encoding before and after the replacement, the data path bandwidth is not affected.
As shown in fig. 4, in the present embodiment, the DATA stream is composed of valid DATA/DATA and idle DATA/I, the definition of the valid DATA and the idle DATA complies with the Serdes protocol standard, and the preprocessing in the present embodiment includes inserting K code intervals into the idle DATA stream, and after the DATA stream to be transmitted is 8B/10B encoded, mapping the K code into one of two asymmetric polarity encodings without affecting the valid DATA. At the transmitting end, after the data is coded by 8B/10B, K codes generate one of A-or B +. At a receiving end, if the detection polarity code in the received data is detected to be A-or B +, the data sampling is normal, and the data polarity is not adjusted; if a bit-wise inversion code of polarity coding, namely A + or B-, is received at a receiving end, if continuous A + or B-is received at the receiving end, the polarity of the data is inverted, and bit-wise inversion processing needs to be carried out on the bits of the received data.
In this embodiment, the current polarity of the asymmetric polarity code in the 8B/10B encoded data is the same as the end polarity of the previous data code, and to ensure DC balance after encoding, the current polarity of the polarity code is the same as the end polarity of the previous data code, so that the sending polarity code a-or B + is selected according to the end polarity of the previous data, and the end polarity of the selected polarity code is consistent with the current polarity of the next data code. The selection of the terminal polarity of the data code at the transmitting end and the polarity codes A-and B + is to keep the numbers of the transmitted '0' and '1' basically consistent, and both belong to the category of the code polarity, which is different from the data polarity detection by extracting the asymmetric code value of the K code from the received data stream.
In this embodiment, specifically, the polarity detection includes:
performing polarity defining on the received data stream, the polarity defining comprising continuously detecting correctness of the asymmetric coding polarity,
if the polarities of the plurality of asymmetric codes detected continuously are correct, judging that the polarity of the serial communication data is correct, and keeping the polarity unadjusted;
if the polarity errors of a plurality of asymmetric codes are continuously detected, judging the polarity error of the serial communication data, and reversing the polarity of the serial communication data; polarity reversal changes, i.e. A-changes to A + or B + changes to B- (detected A + changes to B-, or A-changes to B +)
Continuously detecting the correctness of the asymmetric polarity codes, recording the change quantity when detecting that the correctness is reversely changed,
if the change quantity exceeds a preset quantity threshold value, carrying out polarity definition again;
if the change quantity does not exceed the preset quantity threshold value, continuing to detect;
and if the polarity correctness is recovered, clearing the change number count.
The polarity calibration can be indirectly realized by utilizing the existing 8B/10B coding and decoding technology, and data obtained by coding different effective data have asymmetry mutually according to the code table rule. Supposing that a group of data with a specific rule is sent, 8B/10B coding is carried out to obtain a string of specific code streams, the code streams are decoded after passing through a plurality of functional modules, and for normal received data, the data can be decoded into data which accords with an expected rule; for a bit-wise inverted data stream, we will get decoded data that is different from the expected rule. We can determine whether the data polarity is inverted according to two different decoding results. However, this method is complex to implement, and in practice, to implement real-time monitoring of data polarity, a specific data code group needs to be periodically inserted for inspection, which occupies effective data bandwidth resources and further increases design complexity. A self-development protocol is defined, only K code subsets in 8B/10B coding and decoding are improved, so that the problem of data polarity is solved, the original byte delimiting function is unchanged, and the fault-tolerant capability of a channel is improved.
The foregoing embodiments are merely illustrative of the principles and utilities of the present invention and are not intended to limit the invention. Any person skilled in the art can modify or change the above-mentioned embodiments without departing from the spirit and scope of the present invention. Accordingly, it is intended that all equivalent modifications or changes which can be made by those skilled in the art without departing from the spirit and technical spirit of the present invention be covered by the claims of the present invention.