Cross-clock domain data transmission method, device, equipment and medium

By filtering suitable Grey code combinations in cross-clock domain data transmission, the problem of using Grey codes on any range of natural numbers in the prior art is solved, and higher data transmission reliability is achieved.

CN119892301AActive Publication Date: 2025-04-25SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510122721.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-24
Publication Date
2025-04-25
Estimated Expiration
2045-01-24

AI Technical Summary

Technical Problem

In data transmission across clock domains, it is difficult for the prior art to use Gray codes to transform on natural numbers in any range, resulting in circuit state errors or input errors.

Method used

By determining the numerical range of data to be transmitted, if it is a non-integer power of 2, it is judged as an even or an odd value, and filter out the corresponding number of grey codes from the binary code represented by the smallest binary digits to obtain the target grey code combination.

Benefits of technology

It realizes the use of Gray code to transform on natural numbers in any range, improving the reliability of data transmission across clock domains, and avoiding circuit state errors or input errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119892301A_ABST
    Figure CN119892301A_ABST
Patent Text Reader

Abstract

The invention discloses a cross-clock domain data transmission method and device, equipment and a medium, relates to the technical field of computers, is applied to a data sending end, and comprises the following steps: determining a corresponding numerical range after to-be-transmitted data is converted into a target natural number; if the numerical range is the non-integer power of 2, judging whether the numerical range is an even value or not; if the binary code is an even number, determining a minimum binary number capable of covering the numerical range, and screening out a corresponding number of Gray codes corresponding to the even number from binary codes represented by the minimum binary number to obtain a target Gray code combination; if the number of the binary codes is the odd number, determining a minimum binary number capable of covering two times of the value range, and screening out a corresponding number of Gray codes corresponding to two times of the odd number from the binary codes represented by the minimum binary number to obtain a target Gray code combination; and coding the target natural number based on the target Gray code combination so as to convert the target natural number into a corresponding Gray code and transmit the Gray code to a data receiving end.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method, device, equipment and medium for cross-clock domain data transmission. Background Art

[0002] In the encoding of a set of numbers, if any two adjacent codes differ by only one binary digit, this encoding is called Gray Code. In addition, since the maximum number and the minimum number differ by only one digit, that is, "connected end to end", it is also called cyclic code or reflection code. In digital systems, natural numbers are often required to change in a certain order. For example, if the 8421 code is used to count in increments according to natural numbers, all four bits must change when the number 0111 changes to 1000. In actual circuits, the change of 4 bits cannot occur absolutely at the same time, so other codes may appear briefly in the count, such as 1100, 1111, etc. In a cross-clock domain system, this may cause circuit state errors or input errors, and the use of Gray code can avoid such errors.

[0003] However, the normal Gray code transformation requires that the range of natural numbers must be an integer power of 2 to meet the use requirements of the Gray code. When the natural number does not meet the integer power of 2, the Gray code cannot be connected from beginning to end due to the missing range and cannot be used.

[0004] In summary, how to improve the application range of Gray code in data transmission across clock domains so that any range of natural numbers can be transformed using Gray code is a problem that needs to be solved at present. Summary of the invention

[0005] In view of this, the purpose of the present invention is to provide a method, device, equipment and medium for cross-clock domain data transmission, which can increase the scope of use of Gray code in cross-clock domain data transmission, so that any range of natural numbers can be transformed using Gray code. The specific scheme is as follows:

[0006] In a first aspect, the present application discloses a method for cross-clock domain data transmission, comprising:

[0007] Determine the corresponding numerical range after the data to be transmitted is converted into a target natural number;

[0008] If the value range is a non-integer power of 2, determine whether the value range is an even value;

[0009] If the numerical range is an even value, determine the minimum binary digit that can cover the numerical range, and select the corresponding number of Gray codes corresponding to the even value from the binary code represented by the minimum binary digit to obtain the target Gray code combination;

[0010] If the numerical range is an odd value, determine the minimum binary digit that can cover twice the numerical range, and select the corresponding number of Gray codes corresponding to twice the odd value from the binary code represented by the minimum binary digit to obtain the target Gray code combination;

[0011] The target natural number is encoded based on the target Gray code combination, so as to convert the target natural number into a corresponding Gray code and then transmit it to the data receiving end.

[0012] Optionally, the target natural number is encoded based on a target Gray code combination, including:

[0013] If the value range of the target natural number is an even value, a first mapping relationship is established between each target value in the target natural number and each Gray code in the target Gray code combination;

[0014] Based on the first mapping relationship, each target value in the target natural number is encoded using each Gray code in the target Gray code combination.

[0015] Optionally, the target natural number is encoded based on a target Gray code combination, including:

[0016] If the value range of the target natural number is an odd value, then the Gray codes in the target Gray code combination are obtained in sequence, and the Gray codes are evenly divided into a first Gray code combination and a second Gray code combination in an arrangement from front to back;

[0017] In a multi-round transmission process of a target natural number, a first use round corresponding to a first Gray code combination and a second use round corresponding to a second Gray code combination are determined based on a cyclic alternation method; wherein the first Gray code combination is used in a first round of data transmission;

[0018] Determine a current Gray code combination corresponding to a current transmission round based on the first use round and the second use round; wherein the current Gray code combination is any one of the first Gray code combination and the second Gray code combination;

[0019] Establishing a second mapping relationship between each target value in the target natural number and each Gray code in the current Gray code combination;

[0020] Based on the second mapping relationship, each target value in the target natural number is encoded using each Gray code in the current Gray code combination.

[0021] Optionally, the cross-clock domain data transmission method of the present application further includes:

[0022] If the numerical range is an integer power of 2, the target binary digit number corresponding to the numerical range is determined, and each target binary code corresponding to the target binary digit number is obtained in ascending order of the numerical value;

[0023] Each target binary code is converted into a corresponding Gray code in sequence according to a preset binary code conversion method to obtain a target Gray code combination, and then the process jumps to a step of encoding a target natural number based on the target Gray code combination.

[0024] Optionally, converting each target binary code into a corresponding Gray code in sequence according to a preset binary code conversion method includes:

[0025] For any target binary code, starting from the lowest bit of the target binary code, each target bit is XORed with the adjacent bit on the left in turn, and the XOR result is used as the value of the target bit corresponding to the Gray code, and the highest bit of the target binary code remains unchanged.

[0026] Optionally, the cross-clock domain data transmission method of the present application further includes:

[0027] A Gray code lookup table is established in advance; wherein the Gray code lookup table records at least one Gray code combination corresponding to each value range covered by different binary digits;

[0028] Accordingly, a corresponding number of Gray codes corresponding to even values ​​are selected from the binary code represented by the minimum binary digit to obtain the target Gray code combination, including:

[0029] Filter out a target Gray code combination corresponding to an even value from a Gray code lookup table;

[0030] Accordingly, a corresponding number of Gray codes corresponding to twice the odd value is selected from the binary code represented by the minimum binary digit to obtain the target Gray code combination, including:

[0031] A target Gray code combination corresponding to twice the odd value is screened out from the Gray code lookup table.

[0032] Optionally, after the target natural number is converted into a corresponding Gray code and transmitted to the data receiving end, the method further includes:

[0033] A target Gray code combination is obtained based on the received Gray code by the data receiving end, and a target numerical range corresponding to the target Gray code combination is obtained from a Gray code lookup table, so as to restore a target natural number based on the target numerical range.

[0034] In a second aspect, the present application discloses a cross-clock domain data transmission device, which is applied to a data sending end, comprising:

[0035] A numerical range determination module is used to determine the corresponding numerical range after the data to be transmitted is converted into a target natural number;

[0036] A judging module, used for judging whether the numerical range is an even value if the numerical range is a non-integer power of 2;

[0037] A first determination module is used to determine the minimum number of binary digits that can cover the numerical range if the numerical range is an even value, and select a corresponding number of Gray codes corresponding to the even value from the binary code represented by the minimum number of binary digits to obtain a target Gray code combination;

[0038] A second determination module is used to determine the minimum binary digit that can cover twice the numerical range if the numerical range is an odd value, and select a corresponding number of Gray codes corresponding to twice the odd value from the binary code represented by the minimum binary digit to obtain a target Gray code combination;

[0039] The encoding module is used to encode the target natural number based on the target Gray code combination, so as to convert the target natural number into the corresponding Gray code and transmit it to the data receiving end.

[0040] In a third aspect, the present application discloses an electronic device, comprising:

[0041] Memory, used to store computer programs;

[0042] The processor is used to execute a computer program to implement the steps of the cross-clock domain data transmission method disclosed above.

[0043] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the steps of the aforementioned cross-clock domain data transmission method disclosed above are implemented.

[0044] It can be seen that the present application determines the corresponding numerical range after the data to be transmitted is converted into the target natural number through the data sending end; if the numerical range is a non-integer power of 2, it is determined whether the numerical range is an even value; if the numerical range is an even value, the minimum binary bit number that can cover the numerical range is determined, and the corresponding number of Gray codes corresponding to the even value is screened out from the binary code represented by the minimum binary bit number to obtain the target Gray code combination; if the numerical range is an odd value, the minimum binary bit number that can cover twice the numerical range is determined, and the corresponding number of Gray codes corresponding to twice the odd value is screened out from the binary code represented by the minimum binary bit number to obtain the target Gray code combination; the target natural number is encoded based on the target Gray code combination, so as to convert the target natural number into the corresponding Gray code and transmit it to the data receiving end.

[0045] Beneficial effect: The present application first converts the data to be transmitted into a target natural number and determines the corresponding numerical range. If the numerical range is a non-integer power of 2, it further determines whether the numerical range is an even value or an odd value. If the numerical range is an even value, first determine the minimum binary digit that can cover the numerical range, and then filter out the corresponding number of Gray codes corresponding to the even value from the binary code represented by the minimum binary digit, so as to obtain the target Gray code combination; if the numerical range is an odd value, it is necessary to determine the minimum binary digit that can cover twice the numerical range, and then filter out the corresponding number of Gray codes corresponding to twice the odd value from the binary code represented by the minimum binary digit, so as to obtain the target Gray code combination, that is, when the range of the target natural number is an odd value, then take twice the numerical range to find the Gray code. Finally, after determining the target Gray code combination, the target natural number is encoded based on the target Gray code combination, so as to convert the target natural number into the corresponding Gray code and then transmit it to the data receiving end. In this way, any range of natural numbers can be transformed using Gray code to perform conversion and processing across clock domains, thereby breaking the limitations of normal Gray code transformation. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0047] Figure 1 A flow chart of a cross-clock domain data transmission method disclosed in this application;

[0048] Figure 2 This is a first specific mapping relationship diagram between Gray code and natural numbers disclosed in this application;

[0049] Figure 3 A mapping relationship diagram between the second specific Gray code and natural numbers disclosed in this application;

[0050] Figure 4 A mapping relationship diagram between the third specific Gray code and natural numbers disclosed in this application;

[0051] Figure 5 This is a schematic diagram of the structure of a cross-clock domain data transmission device disclosed in this application;

[0052] Figure 6 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION

[0053] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0054] The current Gray code conversion requires that the range of natural numbers must be an integer power of 2 to meet the use requirements of Gray code. When the natural number does not meet the integer power of 2, the Gray code cannot be connected at the beginning and the end due to the lack of range and cannot be used. To this end, the embodiment of the present application discloses a method, device, equipment and medium for cross-clock domain data transmission, which can increase the use range of Gray code in cross-clock domain data transmission, so that any range of natural numbers can be converted using Gray code.

[0055] See also Figure 1 As shown, an embodiment of the present application discloses a method for cross-clock domain data transmission, which is applied to a data sending end. The method includes:

[0056] Step S11: Determine the corresponding numerical range after the data to be transmitted is converted into a target natural number.

[0057] In this embodiment, it is understandable that in a digital communication system, data often needs to be transmitted between different clock domains. Assume that there is a sensor network, and the data collected by the sensor, such as ambient temperature, humidity and other values, needs to be transmitted to the central processing unit for analysis and processing, while the sensor and the central processing unit may be in different clock domains.

[0058] When transmitting, the data to be transmitted must first be converted into a target natural number and the corresponding numerical range must be determined. For example, in a temperature monitoring system, if the measurement range of the temperature sensor used is -20°C to 50°C, after quantization and conversion to a natural number, the numerical range corresponding to this temperature is the range of the natural number to be processed. Assuming the quantization accuracy is 1°C, the corresponding numerical range after conversion to a natural number can be 0 to 70.

[0059] Step S12: If the value range is a non-integer power of 2, determine whether the value range is an even value.

[0060] In this embodiment, it is further determined whether the numerical range is a non-integer power of 2, that is, whether the numerical range is 2, 4, 8, 16, 32, 64, etc. If the numerical range is a non-integer power of 2, it is further determined whether the numerical range is an even value or an odd value.

[0061] In addition, the above-mentioned cross-clock domain data transmission method also includes: if the numerical range is an integer power of 2, then determining the target binary bit number corresponding to the numerical range, and obtaining each target binary code corresponding to the target binary bit number in order from small to large; converting each target binary code into a corresponding Gray code in turn according to a preset binary code conversion method to obtain a target Gray code combination, and then jumping to the step of encoding the target natural number based on the target Gray code combination.

[0062] In this embodiment, if the numerical range is an integer power of 2, the target binary bit number corresponding to the numerical range is directly determined. For example, assuming that the numerical range is 8, the corresponding target binary bit number is 3, that is, three binary numbers are required to represent it. Then, the target binary codes corresponding to the target binary bit number are obtained in order from small to large, that is, 000, 001, 010, 011, 100, 101, 110, 111, and then the target binary codes are converted into corresponding Gray codes in turn according to the preset binary code conversion method, so as to obtain the target Gray code combination, and then the step of encoding the target natural number based on the target Gray code combination is performed.

[0063] In a specific implementation, each target binary code is converted into a corresponding Gray code in sequence according to a preset binary code conversion method, including: for any target binary code, starting from the lowest bit of the target binary code, each target bit is sequentially XORed with the adjacent bit on the left, and the XOR result is used as the value of the target bit corresponding to the Gray code, and the highest bit of the target binary code remains unchanged. That is, the conversion method is to start from the lowest bit (i.e., the rightmost bit) of the binary code, sequentially XOR each bit with the adjacent bit on the left, and use the result of the operation as the value of the corresponding Gray code bit, while keeping the leftmost high bit unchanged. For example, for 000, starting from the right, the first bit and the second bit are XORed to 0, the second bit and the third bit are XORed to 0, and the third bit remains unchanged, thus obtaining 000; for 001, the first bit and the second bit on the right are XORed to 1, the second bit and the third bit are XORed to 0, and the third bit remains unchanged, thus obtaining 001; and so on, for a three-digit binary number, the corresponding target Gray code combinations are 000, 001, 011, 010, 110, 111, 101, 100.

[0064] Step S13: If the numerical range is an even value, determine the minimum binary digit that can cover the numerical range, and select a corresponding number of Gray codes corresponding to the even value from the binary code represented by the minimum binary digit to obtain the target Gray code combination.

[0065] In this embodiment, when the numerical range is a non-integer power of 2, if the numerical range is an even value, the minimum binary digit that can cover the numerical range is first determined, and then the corresponding number of Gray codes corresponding to the even value is screened out from the binary code represented by the minimum binary digit, thereby obtaining the target Gray code combination. For example, assuming that the numerical range is 6, corresponding to the natural numbers 0 to 5, since 4<6<8, at least 3 binary digits are required to represent it, that is, the minimum binary digit that can cover the numerical range 6 is 3. Then it is necessary to screen out the corresponding number of Gray codes corresponding to the even value from the binary code represented by the minimum binary digit to obtain the target Gray code combination. Specifically, the selected Gray codes can be 000, 001, 011, 010, 110, 100 in sequence, but the Gray code that meets the requirements is not unique, and can also be 000, 001, 101, 111, 110, 100.

[0066] In addition, assuming that the corresponding natural numbers 0 to 9 have a numerical range of 10, the minimum number of binary bits that can cover the numerical range is 4. In this case, the selectable Gray codes are 0000, 0010, 0110, 0111, 0101, 1101, 1111, 1110, 1010, 1000. Similarly, the Gray code that meets the requirements is not unique, and can also be 0000, 0001, 0011, 0111, 0101, 1101, 1111, 1110, 1010, 1000.

[0067] Therefore, the above method also includes: pre-establishing a Gray code lookup table; wherein the Gray code lookup table records at least one Gray code combination corresponding to each numerical range covered by different binary digits; accordingly, a corresponding number of Gray codes corresponding to even values ​​are screened out from the binary code represented by the minimum binary digit to obtain a target Gray code combination, including: screening out a target Gray code combination corresponding to an even value from the Gray code lookup table. It can be understood that since the correspondence between Gray code and binary does not conform to the normal conversion between natural numbers and Gray code, and there is no fixed rule, the normal conversion method cannot be used for conversion encoding. In order to more quickly determine the target Gray code combination corresponding to the numerical range, a Gray code lookup table can be pre-established, and at least one Gray code combination corresponding to each numerical range covered by different binary digits is recorded in the Gray code lookup table. In this way, after determining the numerical range, assuming that the numerical range is an even number, the target Gray code combination corresponding to the even value can be screened out from the Gray code lookup table.

[0068] In addition to using the Gray code lookup table to record the Gray code combinations corresponding to different numerical ranges, the lookup table can also be used to directly record the Gray code values ​​corresponding to natural numbers, that is, to directly obtain the mapping relationship between Gray code and natural numbers. For example, if the natural number range is 0 to 15, the Gray code corresponding to each natural number is calculated by the Gray code generation rule, such as 0 corresponds to 0000, 1 corresponds to 0001, 2 corresponds to 0011, etc., and these corresponding relationships are stored in the lookup table. The lookup table can be implemented using data structures such as arrays and hash tables to facilitate quick queries. In hardware implementation, ROM (read-only memory) can be used to store the lookup table content to ensure the stability and fast readability of data during system operation. In addition, it can also be implemented through a series of conditional judgments or simple mapping rules in the program or hardware logic. For example, for a small and regular natural number range, such as 0 to 7, the mapping can be achieved through a simple if-else statement or a combinational circuit in the hardware logic. When the input is 0, 000 is directly output; when the input is 1, 001 is output, etc. In some specific simple scenarios, the code or circuit implementation is relatively concise.

[0069] Step S14: If the numerical range is an odd value, determine the minimum binary digit that can cover twice the numerical range, and select a corresponding number of Gray codes corresponding to twice the odd value from the binary code represented by the minimum binary digit to obtain the target Gray code combination.

[0070] In this embodiment, due to the characteristics of Gray code, Gray code values ​​that meet the requirements can only be found when the numerical range of natural numbers is an even number. When the numerical range of natural numbers is an odd number, Gray code values ​​that meet the requirements cannot be found. Therefore, when the numerical range of natural numbers is an odd number, twice the numerical range is used to search for Gray code values. Assuming that the corresponding natural numbers are 0 to 4, Gray code values ​​are searched from 0 to 9. Therefore, in the case where the numerical range is a non-integer power of 2, if the numerical range is an odd value, it is necessary to determine the minimum binary digit that can cover twice the numerical range, and then select the corresponding number of Gray codes corresponding to twice the odd value from the binary code represented by the minimum binary digit to obtain the target Gray code combination, that is, when the range of the target natural number is an odd value, twice the numerical range is used to search for Gray codes.

[0071] Accordingly, a corresponding number of Gray codes corresponding to twice the odd value is selected from the binary code represented by the minimum binary digit to obtain a target Gray code combination, including: selecting a target Gray code combination corresponding to twice the odd value from a Gray code lookup table. Similarly, after determining the numerical range, assuming that the numerical range is an odd number, a target Gray code combination corresponding to twice the odd value can be selected from the Gray code lookup table.

[0072] Step S15: encoding the target natural number based on the target Gray code combination, so as to convert the target natural number into a corresponding Gray code and transmit it to the data receiving end.

[0073] In this embodiment, after determining the target Gray code combination, the target natural number is encoded based on the target Gray code combination, so that the target natural number is converted into the corresponding Gray code and then transmitted to the data receiving end. In this way, any range of natural numbers can be transformed using Gray code to perform cross-clock domain conversion and processing, thereby breaking the limitations of normal Gray code transformation.

[0074] In a specific implementation, encoding a target natural number based on a target Gray code combination includes: if the numerical range of the target natural number is an even value, then establishing a first mapping relationship between each target numerical value in the target natural number and each Gray code in the target Gray code combination; based on the first mapping relationship, encoding each target numerical value in the target natural number using each Gray code in the target Gray code combination. That is, in the case where the numerical range of the target natural number is an even value, then establishing a first mapping relationship between each target numerical value in the target natural number and each Gray code in the target Gray code combination, such as Figure 2 and Figure 3 As shown, Gray codes 000, 001, 011, 010, 110, 100 map natural numbers 0 to 5 in sequence, and Gray codes 0000, 0010, 0110, 0111, 0101, 1101, 1111, 1110, 1010, 1000 map natural numbers 0 to 9 in sequence, so that each target value in the target natural number is encoded using each Gray code in the target Gray code combination based on the first mapping relationship.

[0075] In another specific embodiment, encoding a target natural number based on a target Gray code combination includes: if the numerical range of the target natural number is an odd value, then obtaining each Gray code in the target Gray code combination in turn, and evenly dividing each Gray code into a first Gray code combination and a second Gray code combination in an arrangement from front to back; in a multi-round transmission process of the target natural number, determining a first use round corresponding to the first Gray code combination and a second use round corresponding to the second Gray code combination based on a cyclic alternating manner; wherein the first Gray code combination is used in the first round of data transmission; based on the first use round and the second use round, determining a current Gray code combination corresponding to the current transmission round; wherein the current Gray code combination is any one of the first Gray code combination and the second Gray code combination; establishing a second mapping relationship between each target numerical value in the target natural number and each Gray code in the current Gray code combination; and encoding each target numerical value in the target natural number using each Gray code in the current Gray code combination based on the second mapping relationship.

[0076] That is, when the numerical range of the target natural number is an odd value, each Gray code in the target Gray code combination is obtained in turn, and each Gray code is evenly divided into the first Gray code combination and the second Gray code combination in an arrangement from front to back. Taking the numerical range of the target natural number as 5 as an example, the corresponding target Gray code combination is searched according to 10 (that is, natural numbers 0 to 9), assuming that it is 0000, 0010, 0110, 0111, 0101, 1101, 1111, 1110, 1010, 1000, then the first five Gray code values ​​are used as the first Gray code combination, and the last five Gray code values ​​are used as the second Gray code combination. Then, during the multi-round transmission of the target natural number, the first round of use corresponding to the first Gray code combination and the second round of use corresponding to the second Gray code combination are determined based on a cyclic alternating manner; wherein, it is stipulated that the first Gray code combination is used during the first round of data transmission, then the first round of use corresponding to the first Gray code combination is 1, 3, 5, ...; the second round of use corresponding to the second Gray code combination is 2, 4, 6, ...; then the current Gray code combination corresponding to the current transmission round is determined based on the first round of use and the second round of use. And establish a second mapping relationship between each target value in the target natural number and each Gray code in the current Gray code combination, so as to encode each target value in the target natural number using each Gray code in the current Gray code combination based on the second mapping relationship. That is, when the natural number changes, the first round 0 to 4 is mapped to the first Gray code combination, the second round 0 to 4 is mapped to the second Gray code combination, the third round 0 to 4 is mapped to the first Gray code combination, and the fourth round 0 to 4 is mapped to the second Gray code combination, and so on. Figure 4 shown.

[0077] Furthermore, after the target natural number is converted into the corresponding Gray code and transmitted to the data receiving end, it also includes: obtaining the target Gray code combination based on the received Gray code by the data receiving end, and obtaining the target numerical range corresponding to the target Gray code combination from the Gray code lookup table, so as to restore the target natural number based on the target numerical range. That is, in the present application, after the data receiving end obtains the target Gray code combination based on the received Gray code, it obtains the target numerical range corresponding to the target Gray code combination from the Gray code lookup table, and then restores the target natural number based on the target numerical range.

[0078] It can be seen that the present application first converts the data to be transmitted into a target natural number, and determines the corresponding numerical range. If the numerical range is a non-integer power of 2, it is further determined whether the numerical range is an even value or an odd value. If the numerical range is an even value, the minimum binary digit that can cover the numerical range is first determined, and then the corresponding number of Gray codes corresponding to the even value is screened out from the binary code represented by the minimum binary digit, so as to obtain the target Gray code combination; if the numerical range is an odd value, it is necessary to determine the minimum binary digit that can cover twice the numerical range, and then the corresponding number of Gray codes corresponding to twice the odd value is screened out from the binary code represented by the minimum binary digit, so as to obtain the target Gray code combination, that is, when the range of the target natural number is an odd value, twice the numerical range is taken to find the Gray code. Finally, after determining the target Gray code combination, the target natural number is encoded based on the target Gray code combination, so as to convert the target natural number into the corresponding Gray code and then transmit it to the data receiving end. In this way, the Gray code can be used to transform the natural numbers of any range to perform the conversion and processing across the clock domain, thereby breaking the limitation of the normal Gray code transformation.

[0079] See also Figure 5 As shown, an embodiment of the present application discloses a cross-clock domain data transmission device, which is applied to a data sending end, and the device includes:

[0080] A numerical range determination module 11 is used to determine the corresponding numerical range after the data to be transmitted is converted into a target natural number;

[0081] A judging module 12, for judging whether the numerical range is an even value if the numerical range is a non-integer power of 2;

[0082] The first determination module 13 is used to determine the minimum binary digit that can cover the numerical range if the numerical range is an even value, and select a corresponding number of Gray codes corresponding to the even value from the binary code represented by the minimum binary digit to obtain a target Gray code combination;

[0083] The second determination module 14 is used to determine the minimum binary digit that can cover twice the numerical range if the numerical range is an odd value, and select a corresponding number of Gray codes corresponding to twice the odd value from the binary code represented by the minimum binary digit to obtain a target Gray code combination;

[0084] The encoding module 15 is used to encode the target natural number based on the target Gray code combination, so as to convert the target natural number into a corresponding Gray code and transmit it to the data receiving end.

[0085] It can be seen that the present application first converts the data to be transmitted into a target natural number, and determines the corresponding numerical range. If the numerical range is a non-integer power of 2, it is further determined whether the numerical range is an even value or an odd value. If the numerical range is an even value, the minimum binary digit that can cover the numerical range is first determined, and then the corresponding number of Gray codes corresponding to the even value is screened out from the binary code represented by the minimum binary digit, so as to obtain the target Gray code combination; if the numerical range is an odd value, it is necessary to determine the minimum binary digit that can cover twice the numerical range, and then the corresponding number of Gray codes corresponding to twice the odd value is screened out from the binary code represented by the minimum binary digit, so as to obtain the target Gray code combination, that is, when the range of the target natural number is an odd value, twice the numerical range is taken to find the Gray code. Finally, after determining the target Gray code combination, the target natural number is encoded based on the target Gray code combination, so as to convert the target natural number into the corresponding Gray code and then transmit it to the data receiving end. In this way, the Gray code can be used to transform the natural numbers of any range to perform the conversion and processing across the clock domain, thereby breaking the limitation of the normal Gray code transformation.

[0086] Since the embodiments of the apparatus part correspond to the embodiments of the method part, the embodiments of the apparatus part refer to the description of the embodiments of the method part, which will not be described here. In addition, the invention has the same beneficial effects as the above-mentioned cross-clock domain data transmission method.

[0087] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Specifically, it may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. Among them, the memory 22 is used to store a computer program, and the computer program is loaded and executed by the processor 21 to implement the relevant steps in the cross-clock domain data transmission method performed by the electronic device disclosed in any of the aforementioned embodiments.

[0088] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.

[0089] Among them, the processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 can be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 21 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 21 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 21 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.

[0090] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon include an operating system 221, a computer program 222 and data 223, etc. The storage method can be temporary storage or permanent storage.

[0091] Among them, the operating system 221 is used to manage and control the hardware devices and computer programs 222 on the electronic device 20, so as to realize the operation and processing of the massive data 223 in the memory 22 by the processor 21, which can be Windows, Unix, Linux, etc. In addition to including a computer program that can be used to complete the cross-clock domain data transmission method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks. In addition to data transmitted from an external device received by the electronic device, the data 223 can also include data collected by its own input and output interface 25, etc.

[0092] Furthermore, an embodiment of the present application also discloses a computer-readable storage medium, in which a computer program is stored. When the computer program is loaded and executed by a processor, the method steps performed in the cross-clock domain data transmission process disclosed in any of the aforementioned embodiments are implemented.

[0093] Furthermore, an embodiment of the present application also discloses a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of the cross-clock domain data transmission method disclosed in any of the aforementioned embodiments.

[0094] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0095] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0096] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0097] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0098] The above is a detailed introduction to a cross-clock domain data transmission method, device, equipment and storage medium provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A method for transmitting data across clock domains, characterized in that: Applied to the data sending end, including: Determine the corresponding numerical range after the data to be transmitted is converted into a target natural number; If the numerical range is a non-integer power of 2, determining whether the numerical range is an even value; If the numerical range is an even value, determining the minimum binary digit that can cover the numerical range, and selecting a corresponding number of Gray codes corresponding to the even value from the binary code represented by the minimum binary digit to obtain a target Gray code combination; If the numerical range is an odd value, determining the minimum binary digit that can cover twice the numerical range, and selecting a corresponding number of Gray codes corresponding to twice the odd value from the binary code represented by the minimum binary digit to obtain a target Gray code combination; The target natural number is encoded based on the target Gray code combination, so as to convert the target natural number into a corresponding Gray code and then transmit it to a data receiving end.

2. The cross-clock domain data transmission method according to claim 1, characterized in that: The encoding of the target natural number based on the target Gray code combination includes: If the value range of the target natural number is an even value, a first mapping relationship is established between each target value in the target natural number and each Gray code in the target Gray code combination; Based on the first mapping relationship, each target value in the target natural number is encoded using each Gray code in the target Gray code combination.

3. The cross-clock domain data transmission method according to claim 1, characterized in that: The encoding of the target natural number based on the target Gray code combination includes: If the numerical range of the target natural number is an odd value, then obtaining the Gray codes in the target Gray code combination in sequence, and evenly dividing the Gray codes into a first Gray code combination and a second Gray code combination in an arrangement from front to back; During the multi-round transmission of the target natural number, a first use round corresponding to the first Gray code combination and a second use round corresponding to the second Gray code combination are determined based on a cyclic alternation method; wherein the first Gray code combination is used during the first round of data transmission; Determine a current Gray code combination corresponding to a current transmission round based on the first use round and the second use round; wherein the current Gray code combination is any one of the first Gray code combination and the second Gray code combination; Establishing a second mapping relationship between each target value in the target natural number and each Gray code in the current Gray code combination; Based on the second mapping relationship, each target value in the target natural number is encoded using each Gray code in the current Gray code combination.

4. The cross-clock domain data transmission method according to claim 1, characterized in that: Also includes: If the numerical range is an integer power of 2, determine the target binary digit number corresponding to the numerical range, and obtain each target binary code corresponding to the target binary digit number in ascending order of numerical values; Each of the target binary codes is converted into a corresponding Gray code in sequence according to a preset binary code conversion method to obtain a target Gray code combination, and then the process jumps to the step of encoding the target natural number based on the target Gray code combination.

5. The method for cross-clock domain data transmission according to claim 4, characterized in that: The step of converting each of the target binary codes into a corresponding Gray code in sequence according to a preset binary code conversion method includes: For any of the target binary codes, starting from the lowest bit of the target binary code, each target bit is XORed with the adjacent bit on the left in turn, and the XOR result is used as the value of the target bit corresponding to the Gray code, and the highest bit of the target binary code remains unchanged.

6. The cross-clock domain data transmission method according to any one of claims 1 to 5, characterized in that: Also includes: Pre-establishing a Gray code lookup table; wherein the Gray code lookup table records at least one Gray code combination corresponding to each value range covered by different binary digits; Accordingly, the step of selecting a corresponding number of Gray codes corresponding to the even value from the binary code represented by the minimum binary bit number to obtain a target Gray code combination includes: Filtering out a target Gray code combination corresponding to the even value from the Gray code lookup table; Accordingly, the step of selecting a corresponding number of Gray codes corresponding to twice the odd value from the binary code represented by the minimum binary bit number to obtain a target Gray code combination includes: A target Gray code combination corresponding to twice the odd value is screened out from the Gray code lookup table.

7. The method for cross-clock domain data transmission according to claim 6, characterized in that: After the target natural number is converted into a corresponding Gray code and then transmitted to the data receiving end, the method further includes: The target Gray code combination is obtained by the data receiving end based on the received Gray code, and a target numerical range corresponding to the target Gray code combination is acquired from the Gray code lookup table, so as to restore the target natural number based on the target numerical range.

8. A cross-clock domain data transmission device, characterized in that: Applied to the data sending end, including: A numerical range determination module is used to determine the corresponding numerical range after the data to be transmitted is converted into a target natural number; A judging module, configured to judge whether the numerical range is an even value if the numerical range is a non-integer power of 2; A first determination module is used to determine the minimum binary digit that can cover the numerical range if the numerical range is an even value, and select a corresponding number of Gray codes corresponding to the even value from the binary code represented by the minimum binary digit to obtain a target Gray code combination; A second determination module is used for determining, if the numerical range is an odd value, a minimum binary digit that can cover twice the numerical range, and selecting a corresponding number of Gray codes corresponding to twice the odd value from the binary code represented by the minimum binary digit to obtain a target Gray code combination; The encoding module is used to encode the target natural number based on the target Gray code combination, so as to convert the target natural number into a corresponding Gray code and transmit it to a data receiving end.

9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the steps of the cross-clock domain data transmission method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: Used to store computer programs; wherein, when the computer program is executed by a processor, the steps of the cross-clock domain data transmission method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Method and system for realizing asynchronous first in first out (FIFO) of any depth

    CN102495713A

  • Method and apparatus for generating gray code for any even count value to enable efficient pointer exchange mechanisms in asynchronous FIFO'S

    US20040001014A1

  • Circuit and method for gray code to binary conversion

    US6809666B1

  • Method for establishing a gray code and related counter circuit

    US6836525B1