Prediction method for three input leading zeros

By encoding and selecting the three input numbers in the floating-point multiplication adder, the problem of lack of operand and data complement fusion in the existing technology is solved, and the efficiency of the three input leading zeros in the floating-point multiplication adder is achieved. Prediction improves computing performance.

CN114327359BActive Publication Date: 2024-11-12JIANGSU HUACHUANG MICROSYSTEM CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111486264.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-07
Publication Date
2024-11-12
Estimated Expiration
2041-12-07

AI Technical Summary

Technical Problem

The existing two-input leading zero algorithm lacks operands in the floating-point multiplication adder design, and cannot effectively predict the three-input leading zeros, especially in the addition operation, the data complement fusion leads to the prediction failure.

Method used

A prediction method with three input leading zeros is proposed. The intermediate variables D, E, G, H, M, N, Q are generated by encoding three binary numbers A, B, and C, and the positive and negative encoding formulas are used to use these variables. Calculate to obtain the positive prediction result F_pos and the negative prediction result F_neg, and select an appropriate encoding tree for leading zero detection based on the external selection signal.

Benefits of technology

The leading zero prediction of the three input operations in the floating-point multiplication adder is realized, which shortens the timing path and improves the operating frequency and performance of the floating-point multiplication adder.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114327359B_ABST
    Figure CN114327359B_ABST
Patent Text Reader

Abstract

The present invention discloses a prediction method for three-input leading zeros, comprising the following steps: S1, presetting three binary numbers as A, B, and C, encoding the three numbers A, B, and C to be predicted, and generating intermediate variables D, E, G, H, M, N, and Q; S2, inputting the intermediate variables D, E, G, H, M, N, and Q into the prediction coding formula, and obtaining the prediction results, F_pos and F_neg; S3, inputting F_pos and F_neg in S2 into the positive coding tree and the negative coding tree, respectively, and obtaining the number of leading zeros of the predicted number; S4, selecting the result according to an external selection signal. Advantages: The present invention can predict the leading zeros of the subtraction operation (A+B‑C) of three numbers, can be used in a floating-point multiplier and adder to parallelly operate with a compressor path, shorten the timing path, so as to increase the operating frequency of the floating-point multiplier and adder, and achieve high-performance operation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of chip design, in particular to a method for predicting leading zeros of three inputs of a floating-point multiplier-adder. Background Art

[0002] Floating-point multiplier and adder (the function of the floating-point multiplier and adder is to calculate the floating-point number A*B±C), two-input leading zero prediction (subtracting two binary numbers will produce a lot of zeros in the high bit. This algorithm predicts how many zeros are before the first one and then gives it to the subsequent module for shifting), leading zero detection (the input is a string of binary numbers, and the number of consecutive zeros before the first 1 of the binary number is directly output)

[0003] Existing technology and its defects: The existing technology is a two-input leading zero algorithm. When designing a floating-point multiplier, one operand is missing and the design requirements are not met. Therefore, the two-input leading zero prediction is improved and one operand is added to meet the design requirements. When the two-input leading zero algorithm is applied to a floating-point multiplier, at least one 3:2 compressor is required to compress the three operands into two operands before it can be used. Moreover, the leading zero algorithm is only for subtraction. When passing through a 3:2 compressor, the subtraction sign has already turned the data into a complement code and merged into the data, so the prediction algorithm cannot be used for prediction. Summary of the invention

[0004] The present invention proposes a method for predicting leading zeros of three inputs, and the technical solution adopted is:

[0005] A method for predicting leading zeros of three inputs comprises the following steps:

[0006] S1. Preset three binary numbers A, B, and C, encode the three numbers A, B, and C that need to be predicted, and generate intermediate variables D, E, G, H, M, N, and Q;

[0007] Where D = A & B & (~C)

[0008] E = (A & B & C) | ((A ^ B) & ~C)

[0009] G = ((~A) & (~B) & (~C)) | ((A ^ B) & C)

[0010] H = (~A) & (~B) & C

[0011] M = A ^ B ^ C

[0012] N = (A & B) | ((A ^ B) & (~C))

[0013] Q = ((~A) & (~B)) | ((A ^ B) & C);

[0014] S2, input the intermediate variables D, E, G, H, M, N and Q into the prediction coding formula to obtain the prediction results, F_pos and F_neg;

[0015] F_pos=[G i +D i ]D i+1 +M i G i+1 +[(G i +D i )E i+1 +M i H i+1 ]N i+2 ;

[0016] F_neg=[H i +E i ][H i+1 +G i+1 Q i+2 ] + G i E i+1 + [D i +G i ]D i+1 Q i+2 + D i E i+1 ;

[0017] Where i is the i-th bit of the binary number, F_pos is the positive prediction result, and F_neg is the negative prediction result;

[0018] S3, input F_pos and F_neg in S2 into the positive coding tree and the negative coding tree respectively, and obtain the number of leading zeros of the predicted number;

[0019] S4. Select the result according to the external selection signal.

[0020] Preferably, the external selection signal in S4 is the sign bit output by the addition circuit. When the sign bit is 0, it indicates that the addition result is positive, and the positive coding tree is selected; when the sign bit is 1, it indicates that the addition result is negative, and the negative coding tree is selected.

[0021] Compared with the prior art, the present invention has the following beneficial effects:

[0022] The method of the present invention can predict the leading zeros of the subtraction operation (A+BC) of three numbers, can be used in a floating-point multiplier and adder to perform parallel operations with a compressor path, shorten the timing path, thereby increasing the operating frequency of the floating-point multiplier and adder and achieving high-performance operations. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 It is a flowchart of the method of the present invention.

[0024] Figure 2 It is a model diagram of the method of the present invention. DETAILED DESCRIPTION

[0025] The technical solution of the present invention is described in detail below, but the protection scope of the present invention is not limited to the embodiments.

[0026] To make the content of the present invention more clearly understood, the following Figure 1 -Attached Figure 2 The specific implementation manner is further described.

[0027] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0028] The present invention provides a method for predicting leading zeros of three inputs, comprising the following steps:

[0029] S1. Preset three binary numbers A, B, and C, encode the three numbers A, B, and C that need to be predicted, and generate intermediate variables D, E, G, H, M, N, and Q;

[0030] Where D = A & B & (~C)

[0031] E = (A & B & C) | ((A ^ B) & ~C)

[0032] G = ((~A) & (~B) & (~C)) | ((A ^ B) & C)

[0033] H = (~A) & (~B) & C

[0034] M = A ^ B ^ C

[0035] N = (A & B) | ((A ^ B) & (~C))

[0036] Q = ((~A) & (~B)) | ((A ^ B) & C);

[0037] S2, input the intermediate variables D, E, G, H, M, N and Q into the prediction coding formula to obtain the prediction results, F_pos and F_neg;

[0038] F_pos=[Gi +D i ]D i+1 +M i G i+1 +[(G i +D i )E i+1 +M i H i+1 ]N i+2 ;

[0039] F_neg=[H i +E i ][H i+1 +G i+1 Q i+2 ] + G i E i+1 + [D i +G i ]D i+1 Q i+2 + D i E i+1 ;

[0040] Where i is the i-th bit of the binary number, F_pos is the positive prediction result, and F_neg is the negative prediction result;

[0041] S3, input F_pos and F_neg in S2 into the positive coding tree and the negative coding tree respectively, and obtain the number of leading zeros of the predicted number;

[0042] S4. Select the result according to the external selection signal.

[0043] In this method, the external selection signal in S4 is the sign bit output by the addition circuit. When the sign bit is 0, it indicates that the addition result is positive, and the positive coding tree is selected; when the sign bit is 1, it indicates that the addition result is negative, and the negative coding tree is selected.

[0044] In the method of this embodiment, three binary numbers A, B, and C are obtained, and intermediate variable results, D, E, G, H, M, N, and Q, are first generated. The intermediate variables are input into the positive coding formula and the negative coding formula (F_pos, F_neg) to obtain positive prediction results and negative prediction results. The positive and negative prediction results are input into the positive and negative coding trees for leading zero counting, and finally the result of the positive coding tree or the result of the negative coding tree is selected by an external selection signal. The external signal is the sign bit output by the addition circuit. When the sign bit is 0, it indicates that the addition result is positive, and the positive coding tree is selected. When the sign bit is 1, it indicates that the addition result is negative, and the negative coding tree is selected.

[0045] In the method of this embodiment, the intermediate variable results D, E, G, H, M, N, Q, the calculation formula of each intermediate variable is a known formula in the art, and is known to those skilled in the art. The intermediate variable represents the result of each bit of A+BC. After each bit of A+BC is calculated, there are four cases {2, 1, 0, -1}. D represents 2, E represents 1, G represents 0, H represents -1, M represents [1+(-1)], N represents [1+2], Q represents [0+(-1)], and + means or.

[0046] In the calculation formulas of each intermediate variable, & represents bitwise AND, ~ represents bitwise inversion, | represents bitwise OR, and ^ represents bitwise XOR; bitwise means operating on each bit of the binary number.

[0047] In the method of this embodiment, the structural forms such as "M i G i+1 ", written together means bitwise AND; the structural form that appears is "D i +G i " means bitwise OR.

[0048] In this embodiment, the positive prediction coding formula F_pos=[G i +D i ]D i+1 +M i G i+1 +[(G i +D i )E i+1 +M i H i+1 ]N i+2 ; Negative prediction coding formula F_neg=[H i +E i ][H i+1 +G i+1 Q i+2 ] + G i E i+1 + [D i +G i ]D i+1 Q i+2 + D i E i+1 ; The derivation process is as follows:

[0049] In the floating-point multiplier and adder, the data sum and carry of the first-beat multiplication and the shifted operand c are used in the second beat. In the second beat, sum + carry – c is calculated and then shifted. In order to improve performance, the leading zero prediction algorithm is used to predict the number of leading zeros in the result of the three-number operation and provide it for the subsequent shift. The predicted number of zeros has a one-bit error, and the one-bit error can be simply judged later.

[0050] The three binary numbers proposed in this embodiment are A, B, and C, respectively, and the prediction coding formula is derived for the form of A+BC or CAB.

[0051] Suppose the three operands are A, B, and C, W = A + BC, and each bit of W does not carry. Then each bit of W is W i (W i =a i +b i -c i ), there are four cases: 2, 1, 0, -1, so four intermediate variables are needed to represent it. The three operands A, B, and C are all binary numbers; among them, i is the i-th digit of the binary number.

[0052] Discussion on the positive and negative W scores:

[0053] When W≥0, the highest bit of W can only be 1 or 2; 2 indicates a carry.

[0054] 1. If W = 0 k 2(x)

[0055] (By default, there is a zero in front of W, so when actually calculating, a 0 must be added in front of operands A, B, and C)

[0056] X represents a digital string composed of any combination of 2, 1, 0, and -1. k represents k consecutive 0s.

[0057] (1) If x ≥ 0, there is no need to borrow forward. 2 moves forward one position, and the most significant bit is at the kth bit.

[0058] (2) If x<0, it is necessary to borrow forward, and the most significant bit is at the k+1th bit.

[0059] Because one-bit error is allowed, it is always assumed that the leading 1 appears at the kth bit, and the one-bit error is corrected by the subsequent module. Then the identification code with one-bit error is:

[0060] W i W i+1 =0 i 2 i+1

[0061] 2. If W=0 k 1(x)

[0062] (By default, there is a zero in front of W, so when actually calculating, a 0 must be added in front of operands A, B, and C)

[0063] The situation is complicated and needs to be discussed in categories:

[0064] (1) W = 0 k 12(x)

[0065] (a) If x does not borrow forward, the leading 1 is at the kth position.

[0066] (b) If x borrows forward, the leading 1 is at the k+1th position.

[0067] Then the identification code with one bit error is:

[0068] W i W i+1 =0 i 1 i+1 2 i+2

[0069] (2) W = 0 k 11(x)

[0070] x can have three situations: carry, no operation on the high bit, and borrow; when there is a carry, the leading 1 is located at the kth bit. When there is no operation on the high bit, the leading 1 is located at the k+1th bit. When there is a borrow, the leading 1 is located at the k+1th bit. In summary, the leading 1 is located at the kth bit or the k+1th bit.

[0071] Then the identification code with one bit error is:

[0072] W i W i+1 =0 i 1 i+1 1 i+2

[0073] (3) W = 0 k 10(x)

[0074] x can have three situations: carry, no operation on the high bit, and borrow. When there is a carry, the leading 1 is located at the k+1 position, when there is no operation on the high bit, the leading 1 is located at the k+1 position, and when there is a borrow, the leading 1 is located at the k+2 position.

[0075] Then the identification code with one bit error is:

[0076] W i W i+1 =1 i 0 i+1

[0077] (4) When W = 0 k 1(-1)(x)

[0078] (a) When x is 2, the -1 will be offset by carrying forward. When there is no borrowing, the leading 1 is located at the k+1 position. When borrowing forward, we only need to consider the limit case. If each subsequent digit is -1, then borrowing 1 forward can offset all the subsequent -1s, so the leading 1 is located at the k+2 position.

[0079] (b) When x is 1 and the value following it is carried forward, the -1 is offset and the leading 1 is located at the k+1th position. When the value following it does not carry forward or there is a borrow, the borrow is absorbed by the 1 of x, so the leading 1 is located at the k+2th position.

[0080] (c) When x is -1, W = 0 k 1(-1)(-1)x, case and W=0 k 1(-1)(x) is similar, because after simplification W=0 k 001(x), and W=0 k 01(x) is similar, and the results of the discussed situations are similar.

[0081] So expand this discussion to 0 k 1(-1) m 2(x), 0 k 1(-1) m 1(x), 0 k 1(-1) m 0(x) and 0 k 1(-1) m Four situations.

[0082] First, let's discuss the completeness of these four cases. When m is 1, it already includes the case where -1 is followed by 2, 1, and 0. When it is followed by -1, it can be followed by four more numbers. 2, 1, and 0 are already included in the first three cases. The only one that is not included is the case where (-1) loops to the end, so 0 is added. k 1(-1) m In this case, W=0 k All cases of 1(-1)(x) are listed.

[0083] i) When W=0 k 1(-1) m 2(x) hours

[0084] When x has a forward borrow, the leading 1 is located at k+m+1. When x does not have a forward borrow or has a forward carry, the leading 1 is located at k+1. When m is 1, the identification code is 1.i -1 i+1 2 i+2 ; When m>1, the identification code is -1 i -1 i+1 2 i+2 In summary, the identification code with one bit error is:

[0085] W i W i+1 =1 i -1 i+1 2 i+2 or -1 i -1 i+1 2 i+2

[0086] The detection code detects the first position. Although there is a value before W, it is ignored.

[0087] ii) When W=0 k 1(-1) m 1(x) hour

[0088] When x carries forward, the leading 1 is located at k+1. When x has no operation on the high bit or borrows forward, the leading 1 is located at k+m+1. In summary, the identification code with one bit error is:

[0089] W i W i+1 =1 i -1 i+1 1 i+2 or -1 i -1 i+1 1 i+2

[0090] iii) When W = 0 k 1(-1) m 0(x)

[0091] When x carries forward or does not operate on the high bit, the leading 1 is located at the k+m+1th position. When all bits of x are -1, it is sufficient to borrow one bit forward, so the leading 1 is located at the k+m+2th position. In summary, the identification code with one bit error is:

[0092] W i W i+1 =-1 i 0 i+1

[0093] iiii) When W = 0 k 1(-1) m hour

[0094] The result is that the last bit is 1, and the rest are 0. Add 0 to the end of the original data, and pass the identification code -1 i 0 i+1 Can be identified.

[0095] 3. When 0 k (-1)22(x) simplifies to 0 k 002(x), case and 0 k 2(x), the leading 1 is at position k+2 or k+3, and the identification code with one bit error is:

[0096] W i W i+1 =2 i 2 i+1

[0097] Note: Although the case and 0 k 2(x) are the same, but the identification codes are different and cannot be shared because 0 k The identification code of 2(x) uses the 0 digits before 2, which is the same as 0 k (-1)22(x) is different.

[0098] 4. When 0 k (-1)212(x) simplifies to 0 k 0012(x), case and 0 k 12(x) is similar, so the detection code is 2 i 1 i+ 12 i+2 .

[0099] 5. When 0 k (-1)211(x) simplifies to 0 k 0011(x), case and 0 k 11(x) is similar, so the detection code is 2 i 1 i+ 11 i+2 .

[0100] 6. When 0 k (-1)21(0,-1)(x) simplifies to 0 k 001(0,-1)(x), case and 0 k 10(x),0 k 1(-1)(x) is similar because 0 k 10(x),0 k 1(-1)(x) The detection code used does not involve 0 k 0 in, so the detection code can be shared, so 0 k (-1)21(0,-1)(x) does not require its own detection code.

[0101] 7. When 0 k When (-1)20(x), the binary carry will cancel out the -1 and simplify to 0 k 000(x), the result is the same as other cases, and the detection code is shared with other cases.

[0102] 8. When 0 k (-1)2(-1)(x) simplifies to 0 k 00(-1)(x), case and 0 k The situation of (-1)(x) is the same, so the detection code can be shared.

[0103] 9. When 0 k (-1)1 m 2(x), simplifies to 0 k 00 m 0(x), can share the detection code with other situations, the value before (x) is 2, and the detection code can also be shared with 0 k (-1)22(x),0 k (-1)212(x),0 k (-1)211(x) shared. In summary, the detection code can be shared.

[0104] (The detection code must ensure that the position of the first 1 is detected correctly and cannot conflict with the characters that should be ignored before the first 1 in other situations.)

[0105] From the above analysis, we can obtain the detection code rule table 1 for identifying the leading position when W≥0.

[0106] Table 1 Rules for identifying the leading position of the detection code when W≥0

[0107]

[0108] In Table 1, 0 k represents k 0s, (-1) m represents m -1, (x) represents any value that can be 2, 1, 0, -1 and there are any number of them, and the number is not zero.

[0109] In Table 1, the same detection code has no effect, because we only need to find the position of the leading 1. It should be noted that the number group that should be ignored in the front cannot be detected.

[0110] If the detection code satisfies one, it means the position of the leading one is found, so all the detection codes are simplified to:

[0111] F i =[0 i +2 i ]2 i+1 +[1 i+(-1) i ]0 i+1 +[(0 i +2 i )1 i+1 +[1 i +(-1) i ](-1) i+1 ][2 i+2 +1 i+2 ]

[0112] To further simplify, let D represent 2, E represent 1, G represent 0, H represent -1, M represent [1+(-1)], N represent [1+2], and Q represent [0+(-1)].

[0113] The final simplified result is:

[0114] F_pos=[G i +D i ]D i+1 +M i G i+1 +[(G i +D i )E i+1 +M i H i+1 ]N i+2 .

[0115] When W<0, for the convenience of discussion, W is negated and named U for discussion, U=CAB;

[0116] 1. When U=0 k 11(x), when x does not borrow forward, the leading 1 is at the k+1th position. When x is all -2, all -2s are carried forward to become -1, and the leading 1 is at the k+2th position. So the detection code with one bit error is Q=1 i 1 i+1 .

[0117] 2. When U=0 k When x is 10(0,1)(x), when x does not borrow forward, the leading 1 is at the k+1th position. When x is all -2, it only needs to borrow one bit from the next highest position, so the leading zero is at the k+2th position. Therefore, the detection code with one bit error is 1 i 0 i+1 0 i+2 or 1 i 0 i+1 1 i+2 .

[0118] 3. When 0 k 10(-1)(x) simplifies to 0 k011(x), 11(x) is the same as case 1, so the leading digit is at position k+2 or k+3, so the detection code is 0 i (-1) i+1 .

[0119] 4. When 0 k 10(-2) m (1,0)(x) simplifies to 0 k 0 m 10(1,0)(x), we will only discuss the limiting cases, the cases where (x) does not borrow and (x) is all -2 borrow. The leading position of other cases is included between the two limiting cases.

[0120] 4.1) When there is no borrow, the leading position is at k+m+1.

[0121] 4.2) When (x) is all -2, all borrows, only the edge case is discussed, U=0 k 10(-2) m 0(x), -2 is carried forward to -1, which simplifies to U=0 k 0 m 10(-1) j 0 and -1 can just borrow one bit from the higher bit, so the leading 1 is at the position k+m+2.

[0122] In summary, and considering the case where m is 1 or m>1, the detection code is (-2) i (-2) i+1 1 i+2 or (-2) i (-2) i+1 0 i+2 or 0 i (-2) i+1 1 i+2 or 0 i (-2) i+1 0 i+2 .

[0123] 5. When 0 k 10(-2) m (-1)(x), according to the discussion in Section 4.2 above, carry -2 forward, 10(-2) m The result of the combination is 0 m 10, so simplify the original expression to 0 k 0 m 10(-1)(x), further simplified to 0 k 0 m 011(x), the combination of 11(x) appears, which is the same as case 1, so the leading one is at k+m+2 or k+m+3. So the detection code is (-2)i (-1) i+1 .

[0124] 6. When 0 k 10(-2) m When , many 0s will be generated in the front, and there will be a 1 only in the second to last digit, and a 0 will be extended at the end of U. The detection code is (-2) i (-2) i+1 0 i +2.

[0125] 7. When 0 k 1(-1) m 1(x), simplifies to 0 k 0 m When 11(x), the combination 11(x) is generated, and the position of the leading 1 is consistent with case 1, so the detection code is (-1) i 1 i+1 .

[0126] 8. When 0 k 1(-1) m When 0(0,1)(x), the leading 1 is located at k+m+1 or k+m+2, so the detection code is (-1) i 0 i+1 0 i+2 or (-1) i 0 i+1 1 i+2 .

[0127] 9. When 0 k 1(-1) m When 0(-1)(x), the leading 1 is located at k+m+2 or k+m+3, so the detection code is 0 i (-1) i+1 .

[0128] 10. When 0 k 1(-1) m 0(-2) j When (1,0)(x), -2 is carried to -1 and simplified to 0 k 1(-1) m (-1) j 0(1,0)(x), the leading 1 is located at the k+m+j+1 or k+m+j+2 position. Since j may be 1 or greater than 1, the detection code for the leading 1 is (-2) i (-2) i+1 1 i+2 or (-2) i (-2) i+1 0 i+2 or 0 i(-2) i+1 1 i+2 or 0 i (-2) i+1 0 i+2 .

[0129] 11. When 0 k 1(-1) m 0(-2) j (-1)(x) simplifies to 0 k 1(-1) m (-1) j 0(-1)(x), simplifies to 0 k 0 m+j 10(-1)(x), when all x are -2, carry forward and simplify to 0 k 0 m+j 1(-1)0(-1) i 0, the leading 1 is located at k+m+j+3, when x does not borrow forward, the leading 1 is located at k+m+j+2, in summary, the detection code with one bit error is (-2) i (-1) i+1 .

[0130] 12. When 0 k 1(-1) m (-2)(x) simplifies to 0 k 0 m 1(-2)(x), shares the detection code with the following case.

[0131] 13. When 0 k 1(-2)(x) simplifies to 0 k 00(x), the value of x is {1,0,-1,-2};

[0132] i) When x is 1, the situation is the same as when W<0, and the detection code is shared with all cases of W<0.

[0133] ii) When x is 0, the situation is the same as in case 13, and the detection code is shared.

[0134] iii) When x=-2,-1, we discuss the inversion. When x=2, W is a positive number, and the following (x) can be {2,1,0,-1}, and the borrow of the following digits will not affect its positive number. When x=1, it can be followed by {2,1,0,-1}, and we discuss it in two cases. The "W is a positive number" mentioned here is, because U is the inversion of W, in this case, the carry of -2 and 1 are offset (formula), so when x is a negative number, U is a negative number, and the inversion of it is exactly W.

[0135] a) When x=1 is followed by {2,1,0}, the format is 1(2,1,0)(x), which does not affect W from being a positive number.

[0136] b) When x=1 is followed by -1, it is 1(-1)(x), which is simplified to 01(x). The format is converted back to 1(x). The possible values ​​of (x) are {2,1,0,-1}, so even when (x) is all -1, W is still positive, so it will not affect W being a positive number.

[0137] In summary, when U=0 k When 1(-2)(-2,-1)(x), U<0, that is, in binary calculation, -2 is carried forward to become -1, and 1 cancels out, and the sign of (-2, -1) determines the sign of U, so U is a negative number. When selecting the positive or negative coding tree, the result of the positive coding tree will be selected, so these two situations have no effect on the result.

[0138] From the above analysis, we can obtain the detection code rule table 2 for identifying the leading position when U<0.

[0139] Table 2 Detection code rules for identifying the leading position when U < 0

[0140]

[0141] In Table 2, U takes values ​​of 1, 0, -1, -2, and U>0. (0,1) in the table means that this bit can be 0 or 1.

[0142] The result after simplifying the detection code is:

[0143] F i =[(-1) i +1 i ][(-1) i+1 +0 i+1 [0 i+2 +(-1) i+2 ]]+0 i 1 i+1 +[2 i +0 i ]2 i+1 [(-1) i+2 +0 i+2 ]+2 i 1 i+1

[0144] To further simplify, let D represent 2, E represent 1, G represent 0, H represent -1, M represent [1+(-1)], N represent [1+2], and Q represent [0+(-1)].

[0145] The final simplified result is:

[0146] F_neg=[H i +E i ][H i+1 +G i+1 Q i+2 ]+G i E i+1 +[D i +G i ]D i+1 Q i+2 +D i E i+1

[0147] Since then, the intermediate result of the three-input leading zero prediction has been generated, and the leading zero detection is performed on the intermediate result to output the final leading zero result.

[0148] like Figure 1 and 2 As shown, in this embodiment, the positive coding tree and the negative coding tree are leading zero detection modules, which perform leading zero detection on the predicted results. The positive coding tree and the negative coding tree are modules known in the art and are known to those skilled in the art.

[0149] like Figure 1 and 2 As shown, A, B, and C are the three operands of A+BC, D, E, G, H, M, N, and Q are intermediate variables, and F_pos and F_neg are the generated prediction results.

[0150] Example 1

[0151] Add a 0 in front of the three numbers A, B, and C, and add two zeros at the end, and then input them into the intermediate variable calculation formula. (Because the detection code has a 0 in front by default, a 0 must be added in front. Because the detection code is three consecutive digits, to ensure that each digit is detected, two zeros must be added at the end)

[0152] A = {1'b0, 6'b111100, 2'b00}

[0153] B = {1'b0, 6'b110011, 2'b00}

[0154] C = {1'b0, 6'b101010, 2'b00}

[0155] D, E, G, H, M, N, and Q are all 9 bits.

[0156] D = A & B & (~C) / / 2

[0157] E = (A & B & C) | ((A ^ B) & ~C) / / 1

[0158] G = ((~A) & (~B) & (~C)) | ((A ^ B) & C) / / 0

[0159] H = (~A) & (~B) & C / / -1

[0160] M = A ^ B ^ C / / [1+(-1)]

[0161] N = (A & B) | ((A ^ B) & (~C)) / / [1+2]

[0162] Q = ((~A) & (~B)) | ((A ^ B) & C) / / [0+(-1)]

[0163] After obtaining the intermediate variable, send the intermediate variable into the positive and negative coding tree

[0164] F_pos=[G i +D i ]D i+1 +M i G i+1 +[(G i +D i )E i+1 +M i H i+1 ]N i+2

[0165] F_neg=[H i +E i ][H i+1 +G i+1 Q i+2 ]+G i E i+1 +[D i +G i ]D i+1 Q i+2 +D i E i+1

[0166] The predicted result is 7 digits without the two 0s at the end.

[0167] The prediction result is sent to the positive and negative coding trees to count the number of leading zeros. The positive and negative coding trees are selected through the sign bits of the addition of other modules to obtain the final result.

[0168] In this case, the result is positive, and the positive coding tree result F_pos is selected, and the leading position of the prediction result is correct.

[0169] The results in the table

[0170]

[0171] Example 2

[0172] Add a 0 in front of the three numbers A, B, and C, and add two zeros at the end, and then input them into the intermediate variable calculation formula. (Because the detection code has a 0 in front by default, a 0 must be added in front. Because the detection code is three consecutive digits, to ensure that each digit is detected, two zeros must be added at the end)

[0173] A = {1'b0, 6'b001100, 2'b00}

[0174] B = {1'b0, 6'b100011, 2'b00}

[0175] C = {1'b0, 6'b111010, 2'b00}

[0176] D, E, G, H, M, N, and Q are all 9 bits.

[0177] D = A & B & (~C) / / 2

[0178] E = (A & B & C) | ((A ^ B) & ~C) / / 1

[0179] G = ((~A) & (~B) & (~C)) | ((A ^ B) & C) / / 0

[0180] H = (~A) & (~B) & C / / -1

[0181] M = A ^ B ^ C / / [1+(-1)]

[0182] N = (A & B) | ((A ^ B) & (~C)) / / [1+2]

[0183] Q = ((~A) & (~B)) | ((A ^ B) & C) / / [0+(-1)]

[0184] After obtaining the intermediate variable, send the intermediate variable into the positive and negative coding tree

[0185] F_pos=[G i +D i ]D i+1 +M i G i+1 +[(G i +D i )E i+1 +M i H i+1]N i+2

[0186] F_neg=[H i +E i ][H i+1 +G i+1 Q i+2 ]+G i E i+1 +[D i +G i ]D i+1 Q i+2 +D i E i+1

[0187] The predicted result is 7 digits without the two 0s at the end.

[0188] The prediction result is sent to the positive and negative coding trees to count the number of leading zeros. The positive and negative coding trees are selected through the sign bits of the addition of other modules to obtain the final result.

[0189] In this case, the result is negative, so the negative coding tree result F_neg is selected. The result of the negative coding tree is the leading zero position of CAB, and the leading one position of the predicted result is the leading one position of the final result, which is correct.

[0190] The results in the table

[0191]

[0192] The parts not involved in the present invention are the same as the prior art or can be implemented by using the prior art.

[0193] As described above, although the present invention has been shown and described with reference to specific preferred embodiments, it should not be construed as limiting the present invention itself. Various changes in form and details may be made without departing from the spirit and scope of the present invention as defined in the appended claims.

Claims

1. A method for predicting leading zeros of three inputs, characterized in that: The steps include: S1. Preset three binary numbers A, B, and C, encode the three numbers A, B, and C that need to be predicted, and generate intermediate variables D, E, G, H, M, N, and Q; Where D = A & B & (~C) E = (A & B & C) | ((A ^ B) & ~C) G = ((~A) & (~B) & (~C)) | ((A ^ B) & C) H = (~A) & (~B) & C M = A ^ B ^ C N = (A & B) | ((A ^ B) & (~C)) Q = ((~A) & (~B)) | ((A ^ B) & C); S2, input the intermediate variables D, E, G, H, M, N and Q into the prediction coding formula to obtain the prediction results, F_pos and F_neg; F_pos=[G i +D i ]D i+1 +M i G i+1 +[(G i +D i )E i+1 +M i H i+1 ]N i+2 ; F_neg=[H i +E i ][H i+1 +G i+1 Q i+2 ] + G i E i+1 + [D i +G i ]D i+1 Q i+2 + D i E i+1 ; Where i is the i-th bit of the binary number, F_pos is the positive prediction result, and F_neg is the negative prediction result; S3, input F_pos and F_neg in S2 into the positive coding tree and the negative coding tree respectively, and obtain the number of leading zeros of the predicted number; S4, selecting a result according to an external selection signal; The external selection signal in S4 is the sign bit output by the addition circuit. When the sign bit is 0, it indicates that the addition result is positive, and the positive coding tree is selected; when the sign bit is 1, it indicates that the addition result is negative, and the negative coding tree is selected. In the floating-point multiplier and adder, the data sum and carry of the first-beat multiplication and the shifted operand c are used in the second beat. In the second beat, sum + carry – c is calculated and then shifted. In order to improve performance, the leading zero prediction algorithm is used to predict the number of leading zeros in the result of the three-number operation and provide it for the subsequent shift. The predicted number of zeros has a one-bit error, and the one-bit error can be simply judged later.