Approximate 4: 2 compressor, multiplier, calculation method of multiplier and chip

By doubling the output signal and adding new outputs in an approximate 4-1 compressor, designing an approximate 4:2 compressor, combined with a simplified encoding circuit, solves the problem of high power consumption in the existing technology and achieves an efficient multiplier design. , reducing area, power consumption and delay.

CN118535126APending Publication Date: 2024-08-23ANHUI UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410393495.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-04-02
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

When existing approximate 4:2 compressors handle complex computing tasks, it is difficult to reduce power consumption while maintaining high accuracy, resulting in excessive power consumption of terminal equipment and inability to effectively balance compression accuracy and power consumption.

Method used

By doubling the output signal weight of the approximate 4-1 compressor and adding a new output signal, an approximate 4:2 compressor is designed, combined with a simplified encoding circuit and compression circuit, and uses an OR gate approximation to process the partial product , reducing hardware overhead and errors.

Benefits of technology

Significantly reduces the average error of the approximate 4:2 compressor, improves the hardware performance of the multiplier, achieves a good compromise between accuracy and hardware performance, reduces area, power consumption and delay, and is suitable for computing with limited resources scene.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535126A
    Figure CN118535126A
Patent Text Reader

Abstract

The invention provides an approximate 4: 2 compressor, a multiplier, a calculation method of the multiplier and a chip, and belongs to the technical field of integrated circuits. According to the design method of the approximate 4: 2 compressor, an input signal of an approximate 4-1 compressor UCAC3 is kept unchanged; the weight of the output signal sum'of the approximate 4-1 compressor UCAC3 is doubled, the output signal sum after the weight is doubled is recorded as the output signal carry of the approximate 4: 2 compressor, then a new output signal sum is added for the approximate 4: 2 compressor, and the approximate 4: 2 compressor is obtained according to the approximate compression logic design. The precision and the hardware performance of the approximate multiplier provided by the invention are better compromised.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of integrated circuits, and in particular relates to an approximate 4:2 compressor, a multiplier, a calculation method of the multiplier and a chip. Background Art

[0002] As the demand for cloud computing and artificial intelligence applications grows, terminal devices need to handle more complex tasks and are more computationally intensive, which requires more efficient computing and storage with limited hardware resources. Moreover, terminal devices are usually powered by batteries. In mobile devices and the Internet of Things, the more computing resources are processed, the higher the power consumption of the terminal device. Therefore, optimizing power consumption has become an important challenge in terminal device design. Currently, a common way to optimize power consumption is approximate computing, because approximate computing can significantly reduce power consumption at the expense of a small amount of accuracy.

[0003] In the field of approximate computing, a multiplier is a relatively complex arithmetic logic unit. Common multipliers mainly include encoding circuits, compression circuits and addition circuits. The accuracy and power consumption of the compression circuit play a key role in the accuracy and power consumption of the multiplier. At present, commonly used compressors include approximate 4:2 compressors. Although the compression accuracy of existing approximate 4:2 compressors is relatively high and the power consumption is relatively low, with the continuous growth of cloud computing and artificial intelligence applications, more and more computing resources need to be processed, and the power consumption of terminal devices is also increasing. How to better balance the compression accuracy and power consumption of the 4:2 compressor has become a difficult problem. To this end, the present application provides an approximate 4:2 compressor, a multiplier, a calculation method of the multiplier and a chip. Summary of the invention

[0004] In order to make up for the deficiencies of the prior art, the present invention provides an approximate 4:2 compressor, a multiplier, a calculation method of the multiplier and a chip.

[0005] The technical solution of the present invention is:

[0006] A design method for an approximate 4:2 compressor comprises the following steps:

[0007] S1: construct an approximate compression logic, specifically: keep the input signal of the approximate 4-1 compressor UCAC3 unchanged, double the weight of the output signal sum' of the approximate 4-1 compressor UCAC3, record the output signal sum after the weight is doubled as the output signal carry of the approximate 4:2 compressor, and then add a new output signal sum to the approximate 4:2 compressor;

[0008] S2: Based on the approximate compression logic constructed in step S1, an approximate 4:2 compressor is designed.

[0009] An approximate 4:2 compressor, the approximate 4:2 compressor is obtained based on the above-mentioned design method of the approximate 4:2 compressor, the approximate 4:2 compressor comprises a two-input AND gate and a two-input OR gate; wherein two input signals of the approximate 4:2 compressor are input into the two-input OR gate for OR logic operation, and output a signal carry, and the remaining two input signals of the approximate 4:2 compressor are input into the two-input AND gate for AND logic operation, and output a signal sum; wherein the weight of carry is 2, and the weight of sum is 1.

[0010] A multiplier comprises an encoding circuit, a compression circuit and an adding circuit connected in sequence, wherein the compression circuit comprises the above-mentioned approximate 4:2 compressor.

[0011] Preferably, the encoding circuit includes twenty-four precise encoders, twelve approximate encoders, four sign compensation bit generation circuits, four inverters, a low-level port and a high-level port; the low-level port is also respectively connected to the sixth precise 4:2 compressor in the compression circuit and the second carry-forward adder in the addition circuit; the high-level port is also respectively connected to the half adder in the compression circuit and the sixth precise 4:2 compressor; wherein the four precise encoders are respectively connected to the inverters for outputting the partial product PP 38 The output end of the precise encoder is connected to the adding circuit, and the output ends of the remaining precise encoders, all approximate encoders, all sign compensation bit generating circuits and all inverters are connected in parallel as the output end of the encoding circuit, and the output end of the encoding circuit is connected to the input end of the compression circuit.

[0012] Preferably, the approximate encoder comprises an XOR gate, a two-input OR gate and a two-input AND gate, the outputs of the XOR gate and the two-input OR gate are respectively connected to two inputs of the two-input AND gate, and the output result of the two-input AND gate is the partial product.

[0013] Preferably, the sign compensation bit generation circuit comprises two inverters, two two-input AND gates and one two-input OR gate, wherein the input terminals of the two inverters are connected to b 2i Input signal and b 2i-1 Input signal, the output of the two inverters are connected to one of the inputs of the two two-input AND gates, and the other input of the two two-input AND gates is connected to b 2i+1 Input signal connections.

[0014] Preferably, the compression circuit includes a three-input OR gate, a two-input OR gate, two approximate 4:2 compressors, six precise 4:2 compressors, a full adder, and a half adder, wherein the output end carry of one approximate 4:2 compressor is connected to one of the input ends of another approximate 4:2 compressor, and among the six precise 4:2 compressors, the carry output end cout of the previous precise 4:2 compressor of two adjacent precise 4:2 compressors is connected to the carry input end cin of the next precise 4:2 compressor, and the carry output end cout of the sixth precise 4:2 compressor is connected to the carry input end cin of the full adder, and the output ends of a three-input OR gate, a two-input OR gate, two approximate 4:2 compressors, six precise 4:2 compressors, a full adder, and a half adder are connected in parallel as the output end of the compression circuit.

[0015] Preferably, the adding circuit comprises a half adder, a full adder and two carry-lookahead adders, and the output end of the compression circuit is connected to the input end of the adding circuit; in the adding circuit, the carry output end cout of the half adder is connected to the carry input end cin of the full adder, the carry output end cout of the full adder is connected to the carry input end cin of the first carry-lookahead adder, and the carry output end cout of the first carry-lookahead adder is connected to the carry input end cin of the second carry-lookahead adder; the output end of the adding circuit, the output ends of the three-input OR gate and the two-input OR gate in the compression circuit, the sum output ends of the two approximately 4:2 compressors in the compression circuit, and the two low-level output ends are connected in parallel as the output end of the multiplier, and the product output of the multiplier is 16 bits.

[0016] A chip comprises at least one multiplier as described above.

[0017] Preferably, the chip may be at least one of a CPU chip, a GPU chip, an NPU chip and a DSP chip.

[0018] An electronic device comprises the above chip.

[0019] Preferably, the electronic device is at least one of a robot, a computer, a printer, a scanner, a mobile phone, a navigator, a sensor, a camera, a video camera, a household appliance and a medical device.

[0020] A calculation method of a multiplier having the above-mentioned approximate 4:2 compressor comprises the following steps:

[0021] Step I: Generate partial products using the encoding circuit to obtain the partial product array:

[0022] Step II: compress the partial product array obtained in step I using a compression circuit to obtain a compressed signal;

[0023] Step III: Use the adding circuit to process the compressed signal to obtain the binary product.

[0024] Preferably, step I comprises the following steps: generating partial products using a precise encoder and an approximate encoder; generating sign compensation bits in a partial product array using a sign compensation bit generating circuit; and the partial products generated by the precise encoder and the approximate encoder and the sign compensation bits generated by the sign compensation circuit constitute the partial product array.

[0025] Preferably, in step I, using an exact encoder and an approximate encoder to generate partial products specifically comprises the following steps: the multiplier A and the multiplicand B are respectively recorded as:

[0026] A=a7a6…a1a0

[0027] B=b7b6…b1b0

[0028] P=A×B=P 15 P 14 P 13 …P2P1P0

[0029] The product P is written as:

[0030] Let any partial product be denoted as PP ij , where i indicates that the row where the partial product is located is the (i+1)th row, j indicates that the column where the partial product is located is the (j+1)th column, where the value range of i is [0,3], and the value range of j varies with i. Specifically, when i=0, the value range of j is [0,10]; when i=1,2,3, the value range of j is [0,9]; when i=0, the partial product PP 00 To PP 05 Using approximate encoder to generate, partial product PP 06 To PP 09 The accurate encoder is used to generate; when i = 1, the partial product PP 10 To PP 13 Using approximate encoder to generate, partial product PP 14 To PP 17 Generated using an accurate encoder; when i = 2, the partial product PP 20 To PP 21 Using approximate encoder to generate, partial product PP 22 To PP 27 Generated using an exact encoder.

[0031] Preferably, in step I, the logical expression of the sign compensation bit generation circuit is as shown in formula (3):

[0032]

[0033] In formula (3), i represents the row where the partial product is located, which is the (i+1)th row. The value range of i is [0,3]. 2i+1 represents the 2i+1th signal in the multiplicand B, They respectively represent the logical NOT operation results of the 2i-1th signal and the 2ith signal in the multiplicand B;

[0034] Preferably, the generation method of the sign compensation bit c0 in the present application is: directly using the b1 signal in the multiplicand B as the output of the sign compensation bit c0; the generation method of the sign compensation bit c1 is: b1 in the multiplicand B and b2 in the multiplicand B are respectively input into two inverters for logical negation operation, and then the outputs of the two inverters are respectively combined with b3 in the multiplicand B and input into two two-input AND gates for AND operation, and then, the outputs of the two two-input AND gates are subjected to the OR logic operation of the two-input OR gates to output the sign compensation bit c1; according to formula (3), the corresponding other signals are input to obtain the sign compensation bit c2 and the sign compensation bit c3.

[0035] The beneficial effects of the present invention are:

[0036] 1. The present invention doubles the weight of the output signal sum' of the approximate 4-1 compressor UCAC3, and records the output signal sum' after the weight is doubled as carry, which can greatly reduce the average error of the improved approximate 4-1 compressor. At the same time, the present application adds an output signal sum to the improved approximate 4-1 compressor, which can further improve the accuracy of the approximate 4-2 compressor. Moreover, the present application obtains the approximate 4:2 compressor of the present application based on the above approximate compression logic design;

[0037] 2. The present invention modifies the value of the Karnaugh map of the traditional precise Radix-4 Booth encoder so that the modified Karnaugh map becomes centrally symmetrical, thereby obtaining a simpler logic function, and then designs an approximate encoder with a simpler circuit structure. The application of this approximate encoder to the encoding circuit of the multiplier greatly improves the hardware performance of the encoding circuit, and then improves the overall hardware performance of the multiplier;

[0038] 3. The multiplier of the present invention uses truncation and OR gate approximation in the process of compressing the partial product array using the compression circuit. The common approximate multipliers in the prior art often truncate 4 or even 6 columns of partial products, which loses a lot of accuracy while obtaining good hardware performance. The present invention only truncates the two columns of partial products with the lowest weight, and uses OR gate approximation (i.e., the three-input OR gate and the two-input OR gate in the compression circuit) to approximate the partial products with slightly higher weights (i.e., the two columns of partial products adjacent to the two columns of partial products with the lowest weights that are truncated). This enables the present application to achieve lower hardware overhead while maintaining relatively high accuracy, achieving an excellent compromise between accuracy and hardware performance.

[0039] 4. The multiplier of the present invention has been verified through image processing application (the verification target image is a baboon image and the application method is Gaussian filtering). The peak signal-to-noise ratio PSNR obtained is greater than 30dB, the structural similarity index SSIM is greater than 0.99, and the image filtering result is excellent. This shows that the multiplier described in this application can be applied to computing scenarios that allow a certain error, have limited hardware resources, and have more computing and processing resources.

[0040] 5. Compared with the existing approximate multiplier, the NMED of the multiplier proposed in the present invention is increased by 7.5×10 -4 However, the multiplier proposed in the present invention saves 302.7 μm in area compared to the existing approximate multiplier. 2 , the power consumption is reduced by 19.6μW, the delay is reduced by 0.16ns, and the PDP is reduced by 42.89fJ; obviously, the approximate multiplier proposed in this application can better reduce the area overhead, power consumption and delay at the cost of a small amount of precision. This also shows that the accuracy and hardware performance (i.e., area, power consumption, delay and other performance) of the approximate multiplier proposed in this application have achieved a better compromise. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 This is a schematic diagram of the circuit structure of a 4:2 compressor in this application;

[0042] Figure 2 Schematic diagram of the circuit structure of the multiplier in this application;

[0043] Figure 3 This is a schematic diagram of the circuit structure of the precise encoder in this application;

[0044] Figure 4 This is a schematic diagram of the circuit structure of the approximate encoder in this application;

[0045] Figure 5 It is a structural schematic diagram of the sign compensation bit generation circuit in this application;

[0046] Figure 6 is a structural schematic diagram of a compression circuit;

[0047] Figure 7 is a schematic diagram of the structure of the adding circuit;

[0048] Figure 8 The partial product array diagram obtained for this application;

[0049] Fig. 9 The partial product reduction tree diagram obtained for this application;

[0050] Fig.10 The present invention provides an image obtained by performing Gaussian filtering on the original image using a Gaussian filter having an existing approximate multiplier and the multiplier described in the present application, wherein (a) is an image obtained by performing Gaussian filtering on the original image using a Gaussian filter having an existing approximate multiplier, and (b) is an image obtained by performing Gaussian filtering on the original image using a Gaussian filter having the multiplier described in the present application. DETAILED DESCRIPTION

[0051] A design method for an approximate 4:2 compressor comprises the following steps:

[0052] S1: construct an approximate compression logic, specifically: keep the input signal of the approximate 4-1 compressor UCAC3 unchanged, double the weight of the output signal sum' of the approximate 4-1 compressor UCAC3, record the output signal sum after the weight is doubled as the output signal carry of the approximate 4:2 compressor, and then add a new output signal sum to the approximate 4:2 compressor;

[0053] S2: Design an approximate 4:2 compressor according to the approximate compression logic constructed in step S1, wherein the approximate 4-1 compressor UCAC3 is the approximate 4-1 compressor UCAC3 disclosed in the existing paper “Design of Ultra-Low Power Consumption Approximate 4–2Compressors Based on the Compensation Characteristic”.

[0054] An approximate 4:2 compressor is obtained based on the above approximate compression logic design; the circuit structure of the approximate 4:2 compressor is as follows: Figure 1 As shown, it includes a two-input AND gate and a two-input OR gate; two of the input signals of the input approximate 4:2 compressor are input into the two-input OR gate for OR logic operation, and output signal carry, and the remaining two input signals of the input approximate 4:2 compressor are input into the two-input AND gate for AND logic operation, and output signal sum; wherein, the weight of carry is 2, and the weight of sum is 1.

[0055] In this application, the input signals of the four input ports of the approximate 4-1 compressor UCAC3 are x1, x2, x3 and x4 respectively, then the output signal of the existing approximate 4-1 compressor UCAC3 is sum=x2+x4, and the input and output weights are the same. The error of the approximate 4-1 compressor UCAC3 is defined as Error=sum-(x1+x2+x3+x4). Under the assumption that the input operands all obey independent uniform distribution, it is generally believed that the probability that a partial product of the approximate 4-1 compressor UCAC3 is 1 is 1 / 4, and the probability that it is 0 is 3 / 4, which is recorded as:

[0056] P(x i =1) = 1 / 4, P(x i =0)=3 / 4;

[0057] The probability that the input signal of the approximate 4-1 compressor UCAC3 is x1=x2=x3=x4=1 is: P(x1=x2=x3=x4=1)=(1 / 4) 4 =1 / 256;

[0058] The other combinations of input signals x1, x2, x3 and x4 of the approximate 4-1 compressor UCAC3 can be obtained by P(x i =1) = 1 / 4, P(x i =0)=3 / 4 is calculated.

[0059] Table 1 is the truth table of the approximate 4-1 compressor UCAC3, defining the average error ME: ME = ∑P × Error. From Table 1, the average error of the approximate 4-1 compressor UCAC3 can be calculated as: ME (UCAC3) = -144 / 256;

[0060] Table 1

[0061] x1 x2 x3 x4 sum Error 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 -1 0 0 1 1 1 -1 0 1 0 0 1 0 0 1 0 1 1 -1 0 1 1 0 1 -1 0 1 1 1 1 -2 1 0 0 0 0 -1 1 0 0 1 1 -1 1 0 1 0 0 -2 1 0 1 1 1 -2 1 1 0 0 1 -1 1 1 0 1 1 -2 1 1 1 0 1 -2 1 1 1 1 1 -3

[0062] It can be seen from Table 1 that the errors generated by the approximate 4-1 compressor UCAC3 when x1, x2, x3 and x4 are input with different partial product value combinations are all negative errors.

[0063] The design method of the approximate 4:2 compressor proposed in this application is based on the improvement of the above-mentioned approximate 4-1 compressor UCAC3. Specifically:

[0064] In order to reduce the error of the compressor and improve its accuracy, the present application doubles the weight of the output signal sum' while keeping the inputs x1, x2, x3 and x4 unchanged, and records the output signal sum' after the weight is doubled as carry. Based on the above approximate compression logic design, an improved approximate 4-1 compressor is obtained. In the improved approximate 4-1 compressor, carry = x2 + x4, and the weight of carry is 2; Table 2 is the truth table of the improved approximate 4-1 compressor.

[0065] Table 2

[0066]

[0067]

[0068] The average error of the improved approximate 4-1 compressor is calculated from Table 2: ME(MD4T1) = -32 / 256; Obviously, when the inputs x1, x2, x3 and x4 remain unchanged, doubling the weight of the output signal sum' of the approximate 4-1 compressor UCAC3, and recording the output signal sum' after the weight is doubled as carry, can greatly reduce the average error of the improved approximate 4-1 compressor, and therefore can also effectively improve the accuracy;

[0069] However, compared with the existing precise 4:2 compressor (from the document Design of Ultra-Low Power Consumption Approximate 4-2 Compressors Based on the Compensation Characteristic), the average error of the improved approximate 4-1 compressor is still relatively large. In order to further reduce the average error of the improved approximate 4-1 compressor, the present application adds an output item to the improved approximate 4-1 compressor, and the added output item is recorded as sum. The present application further designs an approximate 4:2 compressor based on the above approximate compression logic.

[0070] The approximate 4:2 compressor designed in the present application has four input ports, whose input signals are x1, x2, x3 and x4 respectively, and two output ports, whose output signals are carry and sum respectively; wherein two of the input signals of the approximate 4:2 compressor are input into a two-input OR gate for OR logic operation, and output signal carry, and the remaining two input signals of the approximate 4:2 compressor are input into a two-input AND gate for AND logic operation, and output signal sum; wherein the weight of carry is 2, and the weight of sum is 1; taking the input signals x2 and x4 being input into a two-input OR gate for OR logic operation and outputting signal carry, and the input signals x1 and x3 being input into a two-input AND gate for AND logic operation and outputting signal sum as an example, the logical expression of the approximate 4:2 compressor can be expressed as: carry=x2+x4; sum=x1x3;

[0071] Table 3 is the truth table of the above approximate 4:2 compressor.

[0072] Table 3

[0073] x1 x2 x3 x4 carry sum Error 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 1 0 0 0 -1 0 0 1 1 1 0 0 0 1 0 0 1 0 1 0 1 0 1 1 0 0 0 1 1 0 1 0 0 0 1 1 1 1 0 -1 1 0 0 0 0 0 -1 1 0 0 1 1 0 0 1 0 1 0 0 1 -1 1 0 1 1 1 1 0 1 1 0 0 1 0 0 1 1 0 1 1 0 -1 1 1 1 0 1 1 0 1 1 1 1 1 1 -1

[0074] It can be seen from Table 3 that the average error of the above-mentioned approximate 4:2 compressor is ME(NV4T2)=-16 / 256. Obviously, while keeping the input signal of the approximate 4-1 compressor UCAC3 unchanged, the weight of the output signal sum' of the approximate 4-1 compressor UCAC3 is doubled as the output signal carry of the approximate 4:2 compressor, and then a new output signal sum is added to the approximate 4:2 compressor, and the average error ME of the approximate 4:2 compressor obtained based on the above-mentioned approximate compression logic design reduces the average error (-144 / 256) of the approximate 4-1 compressor UCAC3 to -16 / 256. Obviously, the average error of the approximate 4:2 compressor described in the present application has been effectively reduced, and the accuracy has been greatly improved. In terms of hardware resource consumption, the approximate 4:2 compressor designed in the present application has only one more two-input AND gate compared to the existing approximate 4-1 compressor UCAC3.

[0075] A multiplier having the above-mentioned approximate 4:2 compressor, the circuit structure of the multiplier, such as Figure 2 As shown, the multiplier includes an encoding circuit, a compression circuit and an adding circuit connected in sequence;

[0076] The encoding circuit includes twenty-four precise encoders, twelve approximate encoders, four sign compensation bit generation circuits, four inverters, a low-level port and a high-level port; the low-level port is also connected to the sixth precise 4:2 compressor in the compression circuit and the second carry-forward adder in the addition circuit; the high-level port is also connected to the half adder in the compression circuit and the sixth precise 4:2 compressor; the four precise encoders are respectively connected to the inverters for outputting the partial product PP 38 The output end of the precise encoder is connected to the adding circuit, the output ends of the remaining precise encoders, all the approximate encoders, all the sign compensation bit generating circuits and all the inverters are connected in parallel as the output end of the encoding circuit, and the output end of the encoding circuit is connected to the input end of the compression circuit;

[0077] The accurate encoder is a prior art, and the accurate encoder is an accurate Radix-4 Booth encoder disclosed in the existing paper "Design of ApproximateRadix-4 Booth Multipliers for Error-Tolerant Computing," such as Figure 3 As shown; the logical expression of the precise encoder is shown in formula (1):

[0078]

[0079] In formula (1), represents an XOR gate, b 2i Indicates the 2i+1th digit in the multiplicand B, a j Indicates the j+1th bit in the multiplier A, PP ij represents the partial product of the exact encoder output;

[0080] The Karnaugh map of the precise encoder is shown in Table 4. In Table 4, b 2i+1 b 2i b 2i-1 Represents three adjacent binary bits in the multiplicand B, a j a j-1 Represents two adjacent binary bits in the multiplier A;

[0081] Table 4

[0082]

[0083] In this application, the circuit structure of the approximate encoder is as follows: Figure 4As shown, the approximate encoder includes an XOR gate, a two-input OR gate and a two-input AND gate. The output ends of the XOR gate and the two-input OR gate are respectively connected to the two input ends of the two-input AND gate. The output result of the two-input AND gate is the partial product. The approximate encoder proposed in this application is improved based on the above-mentioned precise encoder. The Karnaugh map of the approximate encoder proposed in this application is shown in Table 5.

[0084] Table 5

[0085]

[0086]

[0087] By comparing Table 4 and Table 5, it can be found that the a in the precise encoder Karnaugh map in this application j a j-1 b 2i+1 b 2i b 2i-1 =00111, a j a j-1 b 2i+1 b 2i b 2i-1 =01111 and a j a j-1 b 2i+1 b 2i b 2i-1 =10011 corresponds to a PP value of "0", and this application uses "1" to replace these "0"s in the Karnaugh map of the approximate encoder; a in the Karnaugh map of the precise encoder in this application j a j-1 b 2i+ 1b 2i b 2i-1 =00100, a j a j-1 b 2i+1 b 2i b 2i-1 =01011 and a j a j-1 b 2i+1 b 2i b 2i-1 =10100, the corresponding PP value is "1", and the present application replaces these "1"s with "0"s in the Karnaugh map of the approximate encoder. Therefore, the average error of the approximate encoder in the present application is 0.

[0088] This application constructs an approximate encoder based on the Karnaugh map proposed in Table 5, and the logical expression of the approximate encoder is shown in formula (2):

[0089]

[0090] In formula (2), represents an XOR gate, b 2i Indicates the 2i+1th digit in the multiplicand B, a j Indicates the j+1th bit in the multiplier A, PP ij represents the partial product of the exact encoder output;

[0091] The sign compensation bit generation circuit in this application, such as Figure 5 As shown, the sign compensation bit generation circuit includes two inverters, two two-input AND gates and a two-input OR gate, wherein the input terminals of the two inverters are connected to b 2i Input signal and b 2i-1 Input signal, the output of the two inverters are connected to one of the inputs of the two two-input AND gates, and the other input of the two two-input AND gates is connected to b 2i+1 Input signal connection;

[0092] In this application, the circuit structure diagram of the compression circuit is as follows: Figure 6 As shown, the compression circuit includes a three-input OR gate, a two-input OR gate, two approximate 4:2 compressors, six precise 4:2 compressors, a full adder, and a half adder, wherein an output terminal carry of one approximate 4:2 compressor is connected to one of the input terminals of another approximate 4:2 compressor, and among the six precise 4:2 compressors, a carry output terminal cout of the first precise 4:2 compressor of two adjacent precise 4:2 compressors is connected to a carry input terminal cin of the second precise 4:2 compressor, and a carry output terminal cout of the sixth precise 4:2 compressor is connected to a carry input terminal cin of the full adder, and the output terminals of a three-input OR gate, a two-input OR gate, two approximate 4:2 compressors, six precise 4:2 compressors, a full adder, and a half adder are connected in parallel as the output terminals of the compression circuit;

[0093] In this application, the circuit structure diagram of the adding circuit is as follows: Figure 7 As shown, the adding circuit includes a half adder, a full adder and two carry-lookahead adders, and the output end of the compression circuit is connected to the input end of the adding circuit. In the adding circuit, the carry output end cout of the half adder is connected to the carry input end cin of the full adder, the carry output end cout of the full adder is connected to the carry input end cin of the first carry-lookahead adder, the carry output end cout of the first carry-lookahead adder is connected to the carry input end cin of the second carry-lookahead adder, and the output end of the second carry-lookahead adder is the output end of the adding circuit; the output end of the adding circuit, the output end of the three-input or gate and the two-input or gate in the compression circuit, the sum output ends of the two approximately 4:2 compressors in the compression circuit, and the two low-level output ends are connected in parallel as the output end of the multiplier, and the product output of the multiplier is 16 bits.

[0094] A chip includes at least one of the above multipliers, wherein the chip can be at least one of a CPU chip, a GPU chip, an NPU chip and a DSP chip.

[0095] An electronic device, comprising the above chip, wherein the electronic device may be a robot, a computer, a printer, a scanner, a mobile phone, a navigator, a sensor, a camera, a video camera, a household appliance, a medical device, etc.

[0096] A calculation method of a multiplier having the above-mentioned approximate 4:2 compressor comprises the following steps:

[0097] Step I: Generate partial products using the encoding circuit to obtain the partial product array:

[0098] The specific steps include:

[0099] The multiplier A and the multiplicand B are respectively recorded as:

[0100] A=a7a6…a1a0

[0101] B=b7b6…b1b0

[0102] The product P is written as:

[0103] P=A×B=P 15 P 14 P 13 …P2P1P0

[0104] Let any partial product be denoted as PP ij , where i indicates that the row where the partial product is located is the (i+1)th row, and j indicates that the column where the partial product is located is the (j+1)th column. The value range of i is [0,3], and the value range of j varies with i. Specifically, when i=0, the value range of j is [0,10]; when i=1,2,3, the value range of j is [0,9].

[0105] When i=0, PP 00 To PP 05 Using an approximate encoder to generate, PP 06 To PP 09 It is generated by using an accurate encoder; where:

[0106] PP 06 To PP 09 The specific method of using the approximate encoder is: b of the multiplicand B 2i-1 The input signal is connected to the low level, and the b1 input signal of the multiplicand B is connected to the b of the approximate encoder. 2i+1 Input terminal, the b0 input signal of the multiplicand B is connected to the b of the approximate encoder 2iAt the same time, the a0 input signal of the multiplier A is connected to the a of the approximate encoder j The output of the approximate encoder is PP 00 ; Maintain the approximate encoder b 2i+1 , b 2i and b 2i-1 The input method of the input signal remains unchanged. The a1, a2, a3, a4 and a5 input signals of the multiplier A are connected to the a of the approximate encoder respectively. j The input end and the output end of the approximate encoder can output the partial product PP respectively. 01 PP 02 PP 03 PP 04 and PP 05 ;

[0107] PP 06 To PP 09 The specific method of using the precise encoder is: b of the multiplicand B 2i-1 The input signal is connected to the low level port, and the b1 input signal of the multiplicand B is connected to the b of the precision encoder. 2i+1 Input terminal, the b0 input signal of the multiplicand B is connected to the b 2i At the same time, the a5 input signal of the multiplier A is connected to the a of the precision encoder j-1 Input terminal, a6 input signal of multiplier A is connected to a of precision encoder j The output of the precision encoder can output the partial product PP 06 ; Maintain accurate encoder b 2i+1 , b 2i , b 2i-1 The input signal input method remains unchanged, the precision encoder {a j ,a j-1 The two input terminals are connected to the input signals {a7, a6}, {a7, a7} and {a7, a7} respectively, then the output terminal of the precise encoder can output the partial product PP respectively. 07 PP 08 and PP 09 ; and for j = 10 the partial product PP 0(10) is to convert part of the product PP 09 The result after inputting an inverter:

[0108] When i=1, PP 10 To PP 13 Using an approximate encoder to generate, PP 14 To PP 17 Generated using an accurate encoder; where:

[0109] PP 10To PP 13 The specific method of using the approximate encoder is as follows: First, the b3 input signal of the multiplicand B is connected to the b 2i+1 The input terminal, b2 input signal of multiplicand B, is connected to b of approximate encoder. 2i Input terminal, the b1 input signal of the multiplicand B is connected to the b of the approximate encoder 2i-1 At the same time, the a0 input signal of the multiplier A is connected to the a of the approximate encoder j The approximate encoder can output the partial product PP 10 ; Maintain the approximate encoder b 2i+1 , b 2i , b 2i-1 The input signal input method remains unchanged, approximating the encoder's a j The input terminals are connected to the a1, a2 and a3 input signals of the multiplier A respectively, and the output terminals of the approximate encoder can output PP 11 PP 12 and PP 13 ;

[0110] PP 14 To PP 17 The specific method of using the precise encoder is as follows: First, the b3 input signal of the multiplicand B is connected to the b 2i+1 Input terminal, the b2 input signal of the multiplicand B is connected to the b 2i Input terminal, the b1 input signal of the multiplicand B is connected to the b 2i-1 At the same time, the a3 input signal of the multiplier A is connected to the a of the precision encoder j-1 Input terminal, a4 input signal of multiplier A is connected to a of precision encoder j Input end, at this time, the output end of the precise encoder can output the partial product PP 14 ; Maintain accurate encoder b 2i+1 , b 2i , b 2i-1 The input signal input method remains unchanged, the precision encoder {a j ,a j-1 The two input terminals are connected to the {a5, a4}, {a6, a5} and {a7, a6} input signals of the multiplier A respectively, then the output terminal of the precise encoder can output PP 15 PP 16 and PP 17 ; and for PP 18 The generation of is: keep the b of the accurate encoder 2i+1 , b 2i , b 2i-1 The input signal input method remains unchanged, the precision encoder {a j,a j-1 The two input terminals are connected to the a7 input signal of the multiplier A, and the partial product output by the precision encoder is input into an inverter to obtain PP 18 For PP 19 The generation of PP 19 is always equal to 1, therefore, this application directly outputs the partial product PP through a high level port 19 .

[0111] When i=2, PP 20 To PP 21 Using an approximate encoder to generate, PP 22 To PP 27 Generated using an accurate encoder; where:

[0112] PP 20 To PP 21 The specific method of using the approximate encoder is as follows: First, the b5 input signal of the multiplicand B is connected to the b 2i+1 Input terminal, the b4 input signal of the multiplicand B is connected to the b of the approximate encoder 2i Input terminal, the b3 input signal of the multiplicand B is connected to the b of the approximate encoder 2i-1 At the same time, the a0 input signal of the multiplier A is connected to the a of the approximate encoder j The output of the approximate encoder can output the partial product PP 20 ; Maintain the approximate encoder b 2i+1 , b 2i , b 2i-1 The input signal input method remains unchanged, and the a1 input signal of the multiplier A is connected to the a of the approximate encoder. j The output of the approximate encoder is the partial product PP 21 ;

[0113] PP 22 To PP 27 The specific method of using the precise encoder is as follows: the b5 input signal of the multiplicand B is connected to the b 2i+1 Input terminal, the b4 input signal of the multiplicand B is connected to the b 2i Input terminal, the b3 input signal of the multiplicand B is connected to the b 2i-1 At the same time, the a1 input signal of the multiplier A is connected to the a of the precision encoder j-1 Input terminal, multiplier A a2 input signal connection will accurately encoder a j The output of the precision encoder can output the partial product PP 22 ; Maintain accurate encoder b 2i+1 , b 2i , b2i-1 The input signal input method remains unchanged, the precision encoder {a j ,a j-1 The two input terminals are connected to the input signals {a3, a2}, {a4, a3}, {a5, a4}, {a6, a5} and {a7, a6} respectively, then the output terminal of the precision encoder can output PP 23 PP 24 PP 25 PP 26 and PP 27 ; and the partial product PP 28 The way to generate is to keep the accurate encoder b 2i+1 , b 2i , b 2i-1 The input signal input method remains unchanged, the precision encoder {a j ,a j-1 The two input terminals are connected to the {a7, a7} input signal respectively, and the partial product of the output of the precision encoder is passed through an inverter to obtain PP 28 For PP 29 The generation of PP 29 is always equal to 1, therefore, this application directly outputs the partial product PP through a high level port 29 .

[0114] When i=3, PP 30 To PP 37 All are generated using precise encoders, where

[0115] PP 30 To PP 37 The specific method of using the precise encoder is: multiply the a of A by j-1 The input signal is connected to the low level port, and the b7 input signal of the multiplicand B is connected to the b of the precision encoder. 2i+1 Input terminal, the b6 input signal of the multiplicand B is connected to the b 2i Input terminal, the b5 input signal of the multiplicand B is connected to the b 2i-1 At the same time, the a0 input signal of the multiplier A is connected to the a of the precision encoder. j The output of the precision encoder can output the partial product PP 30 ; Maintain accurate encoder b 2i+1 , b 2i , b 2i-1 The input signal input method remains unchanged, the precision encoder {a j ,a j-1The two input terminals are connected to the input signals {a1, a0}, {a2, a1}, {a3, a2}, {a4, a3}, {a5, a4}, {a6, a5} and {a7, a6} respectively, then the output terminal of the precise encoder can output the partial product PP 31 PP 32 PP 33 PP 34 PP 35 PP 36 and PP 37 ; and the partial product PP 38 The way to generate is: keep the b of the accurate encoder 2i+1 , b 2i , b 2i-1 The input signal input method remains unchanged, the precision encoder {a j ,a j-1 The two input terminals input the input signal {a7, a7} respectively, and the partial product output by the precision encoder is then passed through an inverter to output the partial product PP 38 For PP 39 The generation of PP 39 is always equal to 1, therefore, this application directly outputs the partial product PP through a high level port 39 ;

[0116] The present application utilizes a sign compensation bit circuit to generate a sign compensation bit in a partial product array, wherein the sign compensation bit in the partial product array is as follows: Figure 8 As shown in the four triangles in the partial product array diagram, the present application numbers the sign compensation bits from high to low as c0, c1, c2 and c3; and the logical expression of the sign compensation bit generation circuit is shown in formula (3):

[0117]

[0118] In formula (3), i represents the row where the partial product is located, which is the (i+1)th row. The value range of i is [0,3]. 2i+1 represents the 2i+1th signal in the multiplicand B, They represent the logical NOT operation results of the 2i-1th signal and the 2ith signal in the multiplicand B respectively; in formula (3), the logical relationship between c0, c1, c2 and c3 and b1 to b7 in the multiplicand B can also be specifically shown in formula (4):

[0119] c0=b1

[0120]

[0121] In formula (4), b1, b3, b5 and b7 represent the signals in the multiplicand B, and Respectively represent the logical NOT operation results of b1, b2, b3, b4, b5 and b6;

[0122] As shown in formula (4), the generation method of the sign compensation bit c0 in the present application is: directly use the b1 signal in the multiplicand B as the output of the sign compensation bit c0; the generation method of the sign compensation bit c1 is: b1 in the multiplicand B and b2 in the multiplicand B are respectively input into two inverters for logical negation operation, and then the outputs of the two inverters are respectively combined with b3 in the multiplicand B and input into two two-input AND gates for AND operation, and then, the outputs of the two two-input AND gates are subjected to an OR logic operation of a two-input OR gate to output the sign compensation bit c1; and the generation method of the sign compensation bit c2 and the sign compensation bit c3 is the same as the generation method of the sign compensation bit c1, except that the signal input in the generation process of the sign compensation bit c2 and the sign compensation bit c3 is different from the signal input in the generation process of the sign compensation bit c1. The signal input in the generation process of the sign compensation bit c2 and the sign compensation bit c3 in the present application is shown in formula (4). Of course, the signal input in the generation process of the sign compensation bit c2 and the sign compensation bit c3 can also be obtained from formula (3).

[0123] Thus, the partial products and sign compensation bits generated above constitute a partial product array diagram, and the partial product array diagram, such as Figure 8 As shown, Figure 8 ●The black solid circle in the middle represents the partial product, ○ represents the sign extension bit, The gray solid circle represents the negation of the sign extension bit, ① represents the constant 1 inserted into the partial product array, and Δ represents the sign compensation bit.

[0124] Step II: Use the compression circuit to compress the partial product array obtained in step I to obtain the compressed signal:

[0125] The process of using the compression circuit to compress the partial product array obtained in step I is as follows: Fig. 9 From the Step 1 part of the partial product reduction tree diagram shown, it can be seen that the specific compression method is as follows:

[0126] Partial Product PP 02 and PP 10 The sign compensation bit c1 is input to the compression circuit through the three input terminals of the three-input OR gate, and the output terminal of the three-input OR gate outputs the result P2 in the binary product; the partial product PP 03 and PP 11 The two inputs of the two-input OR gate are respectively input to the compression circuit, and the output of the two-input OR gate is the P3 in the binary product; the partial product PP 04 PP 12 and PP 20The sign compensation bit c2 is input to the compression circuit through the four input terminals of the first approximate 4:2 compressor, and the output result of the sum output terminal of the first approximate 4:2 compressor is P4 in the binary product; the partial product PP 05 PP 13 and PP 21 The carry output result of the first approximate 4:2 compressor is input to the compression circuit through the four input terminals of the second approximate 4:2 compressor. The output result of the sum output terminal of the second approximate 4:2 compressor is P5 in the binary product. The carry output result of the output terminal of the second approximate 4:2 compressor is recorded as carry5. The partial product PP 06 PP 14 PP 22 and PP 30 The four input terminals of the first precise 4:2 compressor are respectively input to the compression circuit, the sign compensation bit c3 is input to the compression circuit via the carry input terminal cin of the first precise 4:2 compressor, the output result of the sum output terminal of the first precise 4:2 compressor is recorded as sum6, and the output result of the output terminal carry of the first precise 4:2 compressor is recorded as carry6; the partial product PP 07 PP 15 PP 23 and PP 31 The four input terminals of the second precise 4:2 compressor are input to the compression circuit, the carry output result cout of the first precise 4:2 compressor is input to the carry input terminal cin of the second precise 4:2 compressor, the output result of the sum output terminal of the second precise 4:2 compressor is recorded as sum7, and the output result of the output terminal carry of the second precise 4:2 compressor is recorded as carry7; the partial product PP 08 PP 16 PP 24 and PP 32 The four input terminals of the third precise 4:2 compressor are input to the compression circuit, the carry output result cout of the second precise 4:2 compressor is input to the carry input terminal cin of the third precise 4:2 compressor, the output result of the sum output terminal of the third precise 4:2 compressor is recorded as sum8, and the output result of the output terminal carry of the third precise 4:2 compressor is recorded as carry8; the partial product PP 09 PP 17 PP 25 and PP 33The four input terminals of the fourth precise 4:2 compressor are input to the compression circuit, the carry output result cout of the third precise 4:2 compressor is input to the carry input terminal cin of the fourth precise 4:2 compressor, the output result of the sum output terminal of the fourth precise 4:2 compressor is recorded as sum9, and the output result of the output terminal carry of the fourth precise 4:2 compressor is recorded as carry9; the partial product PP 0(10) PP 18 PP 26 and PP 34 The four input terminals of the fifth precise 4:2 compressor are input to the compression circuit, the carry output result cout of the fourth precise 4:2 compressor is input to the carry input terminal cin of the fifth precise 4:2 compressor, the output result of the sum output terminal of the fifth precise 4:2 compressor is recorded as sum10, and the output result of the output terminal carry of the fifth precise 4:2 compressor is recorded as carry10; the partial product PP 19 PP 27 PP 35 and a low level are input to the compression circuit via the four input terminals of the sixth precise 4:2 compressor, the carry output result cout of the fifth precise 4:2 compressor is input to the carry input terminal cin of the sixth precise 4:2 compressor, the output result of the sum output terminal of the sixth precise 4:2 compressor is recorded as sum11, and the output result of the output terminal carry of the sixth precise 4:2 compressor is recorded as carry11; the partial product PP 28 and PP 36 The two input terminals of the first full adder are input to the compression circuit, the carry output result cout of the sixth precise 4:2 compressor is input to the carry input terminal of the full adder, the output result of the sum output terminal of the full adder is recorded as sum12, and the output result of the cout output terminal of the full adder is recorded as cout12; the partial product PP 29 and PP 37 The two input ends of the half adder are input into the compression circuit, and the output result of the sum output end of the half adder is recorded as sum13, and the output result of the cout output end of the half adder is recorded as cout13; at this point, P2, P3, P4, P5, carry5, sum6, carry6, sum7, carry7, sum8, carry8, sum9, carry9, sum10, carry10, sum11, carry11, sum12, cout12, sum13 and cout13 constitute all the output signals of the compression circuit.

[0127] Step III: Use the adding circuit to process the compressed signal to obtain the binary product:

[0128] The process of generating binary products using an addition circuit, starting from Fig. 9 It can be seen from the Step 2 part of the partial product reduction tree diagram that it is specifically:

[0129] When sum6 and carry5 are input into the two input terminals of the half adder, the output result of the sum output terminal of the half adder is P6 in the binary product, and the carry output terminal cout of the half adder is connected to the cin input terminal of the full adder; when sum7 and carry6 are input into the two input terminals of the full adder, the output result of the sum output terminal of the full adder is P7 in the binary product, and the output result of the carry output terminal cout of the full adder is transmitted to the carry input terminal cin of the first carry-lookahead adder, and then, two 4-bit operand data are input into the first carry-lookahead adder, and the two 4-bit operands are {sum11,sum10,sum9,sum8} and {carry10,carry9,carry8,carry7} respectively. At this time, the 4-bit outputs of the first carry-lookahead adder are {P 11 ,P 10 ,P9,P8}, and then, the output result of the carry output terminal cout of the first carry-lookahead adder is transmitted to the cin input terminal of the second carry-lookahead adder, and then, two 4-bit operand data are input to the second carry-lookahead adder, and the two 4-bit operands are {PP 39 ,PP 38 ,sum13,sum12} and {“0”,cout13,cout12,carry11}, where “0” indicates that the input terminal is connected to the low-level port. At this time, the 4-bit outputs of the second carry-lookahead adder are {P 15 ,P 14 ,P 13 ,P 12}.

[0130] Finally, for the generation of P1 and P0, since the present invention uses the method of truncating the low-significant columns (the low-significant columns are the two rightmost columns in the partial product array) to simplify the circuit, P1 and P0 are always equal to 0, and two low levels are directly connected as the outputs of P1 and P0.

[0131] At this point, we can get the binary product P = A × B = P 15 P 14 P 13 …P2P1P0.

[0132] In order to facilitate the comparison of the hardware performance and accuracy of the multiplier described in the present invention and the existing approximate multiplier with equivalent accuracy (from the document "Design of Approximate Booth Multiplier for Fault-Tolerant Computing [J]". Microelectronics and Computers), this application specifically tests the two (i.e., the multiplier described in the present invention and the existing approximate multiplier with equivalent accuracy) in terms of area, power consumption, delay, PDP (product of power consumption and delay), normalized mean error distance NMED (normalized mean error distance NMED is a general evaluation parameter of approximate multiplier accuracy), etc. The test results are shown in Table 6.

[0133] Table 6

[0134]

[0135] It can be seen from Table 6 that compared with the existing approximate multiplier, the NMED of the multiplier proposed in the present invention is increased by 7.5×10 -4 However, the multiplier proposed in the present invention saves 302.7 μm in area compared to the existing approximate multiplier. 2 , the power consumption is reduced by 19.6μW, the delay is reduced by 0.16ns, and the PDP is reduced by 42.89fJ; in summary, the approximate multiplier proposed in this application can better reduce the area overhead, power consumption and delay at the cost of a small amount of precision. This also shows that the accuracy and hardware performance (i.e., area, power consumption, delay and other performance) of the approximate multiplier proposed in this application have achieved a better compromise.

[0136] In order to further verify the practicality of the multiplier described in the present invention in fault-tolerant applications, this application uses Gaussian filtering for image processing for verification. Gaussian filtering includes a large number of multiplication operations, and these multiplication operations are implemented by multipliers. Since the filtering process of the entire image includes a large number of multiplication operations and has good error tolerance, this application uses Gaussian filtering to verify the application of the multiplier. The specific operation of Gaussian filtering in this application is: use a Gaussian template to scan each pixel in the image, and use the weighted average grayscale value of the pixels in the neighborhood determined by the template to replace the value of the central pixel of the template.

[0137] For images processed by Gaussian filtering, the peak signal-to-noise ratio PSNR and the structural similarity index SSIM are used to evaluate the filtering results. The larger the peak signal-to-noise ratio PSNR, the smaller the image distortion, and the unit is decibel. Generally speaking, if the peak signal-to-noise ratio PSNR exceeds 30dB, the image processing result can be considered excellent; if the PSNR is close to 50dB, the processed image is very close to the original image, and the image processing result is considered to be excellent. The structural similarity index SSIM is a perceptual model that evaluates the quality of the processed image by comprehensively evaluating brightness, contrast and structure, which is more in line with the intuitive perception of the human eye. The value range of the structural similarity index is [0,1]. The larger the value, the better the quality of the processed image. Generally, we believe that the image processing result is excellent when SSIM is greater than 0.9. Among them, Table 7 is the experimental results of Gaussian filtering, Fig.10 The present invention provides an image obtained by performing Gaussian filtering on the original image using a Gaussian filter having an existing approximate multiplier and the multiplier described in the present application, wherein (a) is an image obtained by performing Gaussian filtering on the original image using a Gaussian filter having an existing approximate multiplier, and (b) is an image obtained by performing Gaussian filtering on the original image using a Gaussian filter having the multiplier described in the present application.

[0138] Table 7

[0139] Multiplier PSNR(dB) SSIM The multiplier described in this application 38.4 0.9962 Existing approximate multipliers 45.1 0.9939

[0140] It can be seen from Table 7 that the peak signal-to-noise ratio PSNR obtained by the multiplier obtained in the Gaussian filtering application of the present invention is lower than that of the existing approximate multiplier, but the structural similarity index SSIM is improved, and the image filtering result is still excellent. This also shows that the approximate multiplier designed in this application still maintains good accuracy under the huge hardware performance advantage, and is very suitable for computing scenarios that allow a certain error, have limited hardware resources and more computing processing resources.

Claims

1. A design method for an approximate 4:2 compressor, characterized in that: The steps include: S1: construct an approximate compression logic, specifically: keep the input signal of the approximate 4-1 compressor UCAC3 unchanged, double the weight of the output signal sum' of the approximate 4-1 compressor UCAC3, record the output signal sum after the weight is doubled as the output signal carry of the approximate 4:2 compressor, and then add a new output signal sum to the approximate 4:2 compressor; S2: Based on the approximate compression logic constructed in step S1, an approximate 4:2 compressor is designed.

2. An approximate 4:2 compressor, characterized in that: The approximate 4:2 compressor is obtained based on the design method of the approximate 4:2 compressor according to claim 1, and the approximate 4:2 compressor includes a two-input AND gate and a two-input OR gate; two of the input signals of the approximate 4:2 compressor are input into the two-input OR gate for OR logic operation, and output a signal carry, and the remaining two input signals of the approximate 4:2 compressor are input into the two-input AND gate for AND logic operation, and output a signal sum; wherein the weight of carry is 2, and the weight of sum is 1.

3. A multiplier, characterized in that: The invention comprises an encoding circuit, a compression circuit and an adding circuit which are connected in sequence, and the compression circuit comprises the approximate 4:2 compressor as claimed in claim 2.

4. The multiplier according to claim 3, characterized in that: The encoding circuit includes twenty-four precise encoders, twelve approximate encoders, four sign compensation bit generation circuits, four inverters, a low-level port and a high-level port; the low-level port is also connected to the sixth precise 4:2 compressor in the compression circuit and the second carry-forward adder in the addition circuit; the high-level port is also connected to the half adder in the compression circuit and the sixth precise 4:2 compressor; wherein the four precise encoders are respectively connected to the inverters for outputting partial product PP 38 The output end of the precise encoder is connected to the adding circuit, and the output ends of the remaining precise encoders, all approximate encoders, all sign compensation bit generating circuits and all inverters are connected in parallel as the output end of the encoding circuit, and the output end of the encoding circuit is connected to the input end of the compression circuit.

5. The multiplier according to claim 4, characterized in that: The approximate encoder includes an XOR gate, a two-input OR gate and a two-input AND gate. The output ends of the XOR gate and the two-input OR gate are respectively connected to two input ends of the two-input AND gate. The output result of the two-input AND gate is the partial product.

6. The multiplier according to claim 3, characterized in that: The compression circuit includes a three-input OR gate, a two-input OR gate, two approximate 4:2 compressors, six precise 4:2 compressors, a full adder, and a half adder, wherein the output end carry of one approximate 4:2 compressor is connected to one of the input ends of another approximate 4:2 compressor, and among the six precise 4:2 compressors, the carry output end cout of the first precise 4:2 compressor of two adjacent precise 4:2 compressors is connected to the carry input end cin of the second precise 4:2 compressor, and the carry output end cout of the sixth precise 4:2 compressor is connected to the carry input end cin of the full adder; the output ends of a three-input OR gate, a two-input OR gate, two approximate 4:2 compressors, six precise 4:2 compressors, a full adder, and a half adder are connected in parallel as the output ends of the compression circuit.

7. The multiplier according to claim 3, characterized in that: The adding circuit comprises a half adder, a full adder and two carry-lookahead adders, the output end of the compression circuit is connected to the input end of the adding circuit; in the adding circuit, the carry output end cout of the half adder is connected to the carry input end cin of the full adder, the carry output end cout of the full adder is connected to the carry input end cin of the first carry-lookahead adder, and the carry output end cout of the first carry-lookahead adder is connected to the carry input end cin of the second carry-lookahead adder; the output end of the adding circuit, the output ends of the three-input OR gate and the two-input OR gate in the compression circuit, the sum output ends of the two approximately 4:2 compressors in the compression circuit and the two low-level output ends are connected in parallel as the output end of the multiplier.

8. A chip, characterized in that: Comprising at least one multiplier as claimed in claims 3 to 7.

9. An electronic device, characterized in that: Comprising the chip as claimed in claim 8.

10. A calculation method of a multiplier, characterized in that: The steps include: Step I: Generate partial products using the encoding circuit to obtain the partial product array: Step II: compress the partial product array using a compression circuit to obtain a compressed signal; Step III: Use the adding circuit to process the compressed signal to obtain the binary product.