Booth multiplier based on symbol extension and operation method
By adopting the booth2 algorithm based on sign extension and the multiplier design of the improved Wallace tree structure in the processor, the problems of long operation cycle and high power consumption of the multiplier are solved, the performance and efficiency of the multiplier are improved, and signed and calculation of unsigned numbers.
Patent Information
- Application Number
- CN202410539149.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-30
- Publication Date
- 2024-08-23
AI Technical Summary
Multipliers in existing processors have long operation cycles, slow operation speeds, low performance, and high power consumption. Especially in RISC-V processors, it is difficult to meet the demand for multiplication computing power in the embedded field.
The multiplier design uses the booth2 algorithm based on sign extension and the improved Wallace tree structure, and reduces carry and bit flipping through the partial product generation module, sign extension module, Wallace tree module, interpolation module and carry-ahead adder module. Improve computing efficiency and reduce power consumption.
It significantly improves the execution cycle and operation speed of multiplication instructions, reduces the area and power consumption of the multiplier, enhances the performance of the multiplier, and supports the calculation of signed and unsigned numbers.
Smart Images

Figure CN118535127A
Abstract
Description
Technical Field
[0002] The invention relates to the technical field of processor chips, and in particular to a booth multiplier design based on sign extension. Background Art
[0003] The new hot spot in the chip industry - RISC-V architecture. Compared with X86 and ARM architectures, RISC-V architecture has won attention for its streamlined instruction set and openness. It has shown great potential in power consumption, compatibility and ecosystem construction. It is gradually breaking traditional boundaries and is widely used in embedded systems, the Internet of Things, the power industry, ICT and robotics.
[0004] In the design of the processor, the multiplier is the core of the operation, and its performance restricts the operation speed of the entire processor. Therefore, in the embedded field, for scenarios with high requirements for multiplication computing power, such as convolution operations of neural networks, it is necessary to study how to optimize the performance and power consumption of the multiplier in the processor. The multiplication operation generally consists of three steps: partial product generation, partial product compression, and final result addition. At present, the main designs of multipliers include booth coding and Wallace tree structure. Therefore, how to improve the operation speed of the processor without increasing the power consumption of the processor and improve the performance of the multiplier in the RISC-V processor is a technical problem that needs to be solved urgently. Summary of the invention
[0005] The present invention provides a booth multiplier design to solve the common problems of long operation cycle, slow operation speed, low performance and high power consumption of multipliers in existing processors. The present invention can effectively improve the execution cycle of multiplication instructions, improve the operation speed of multiplication instructions, reduce area and power consumption, and significantly enhance the performance of the multiplier.
[0006] The present invention provides a multiplier optimization design based on sign extension, booth2 algorithm and improved Wallace tree structure, which reduces a large number of carries and bit flips generated during accumulation for the continuous bit 1 generated by negative sign extension, saves resources and reduces power consumption. The Wallace tree structure is improved, and a symmetrical structure of alternating 3-2 compressors and 4-2 compressors is adopted to reduce the structural level, shorten the delay of the critical path, reduce the instruction execution cycle and delay, and improve the operation efficiency of the multiplier.
[0007] The technical solution of the present invention comprises a partial product generation module, a sign extension module, a Wallace tree module, an insertion module and a carry look-ahead adder module.
[0008] Partial product generation module: a module connected to the input data, composed of a booth encoder, used to perform preliminary decoding operations on the input multiplier and multiplicand to obtain the corresponding partial product. Specifically, it includes: assuming that the input A is the multiplicand and B is the multiplier, according to the booth2 encoding rules, after completing the preliminary decoding operation, the partial product obtained has three cases: 0, 1A, and 2A.
[0009] Sign extension module: connected to the partial product generation module, used to perform sign extension on the partial product and add an additional partial product to support calculation of both signed and unsigned numbers, thereby obtaining the extended partial product.
[0010] The sign extension module performs corresponding addition on the partial product according to the partial product operation condition, and then performs extension processing on the sign bit according to the positive and negative signs of the partial product to obtain the extended partial product, specifically including: Let ai and bi represent the partial products of the i-th row that need to be compensated by +2 / +1 respectively, and i is an integer from 0 to 16. The +2 / +1 part of the partial products of the i-th row is compensated in the i+1th row. Therefore, the partial products of the 32-bit multiplier require a total of 32 / 2+1=17 items.
[0011] Assuming that all the partial products are negative numbers, the front part of the sign bit extension is all 1 at this time, first add all the sign bits extended in the upper left corner, that is, by adding 1 vertically, the carry method is simplified.
[0012] Assuming that one of the partial products is not a negative number, the operation of adding 1 at the end of the partial product will convert the consecutive 1s back to consecutive 0s. In fact, the addition of 1 at the end only occurs when the multiplier and the negative number are multiplied, that is, when the booth code is 101, 110. At this time, it is only necessary to add a 1 to the bit before the sign bit of the partial product to convert the row into a sign extension for the case of a positive number.
[0013] When E is 0, it indicates that the partial product is positive; when E is 1, it indicates that the partial product is negative. When calculating unsigned multiplication, the partial product of signed multiplication can be reused, and only the last bit of the multiplier needs to be compensated. The method is +2 B n-1 2 n-1 , n is an integer from 0 to 32, that is, when performing the addition compensation of a / b, if B
[31] is 1, it is also necessary to shift A left by n bits.
[0014] Wallace tree module: connected to the sign extension module, used to compress the extended partial products to obtain compressed partial products.
[0015] The Wallace tree module includes a first 3-2 compressor and a second 3-2 compressor, a first 4-2 compressor and a second 4-2 compressor. Specifically, the first 3-2 compressor is connected to the symbol extension module and the first 4-2 compressor respectively, and the second 3-2 compressor is used to perform a second-level 3-2 compression process on the first-level 4-2 compression processing result; the first 4-2 compressor is used to perform a first-level 4-2 compression process on the first-level 3-2 compression processing result, and the second 4-2 compressor is used to perform a second-level 4-2 compression process on the second-level 3-2 compression processing result, and the second 4-2 compressor is also connected to the interpolation module.
[0016] Interpolation module: connected to the Wallace tree module, used to complete an interpolation before adding the compressed partial products, store the processing results, and maintain the value of the processing results in the absence of a clock signal until the next control signal arrives to ensure the overall timing.
[0017] Carry-lookahead adder module: connected to the insertion module, used to perform addition operation on the data after the insertion, and the sum is the final multiplication result.
[0018] Optionally, the carry-lookahead adder module adopts a strategy of pre-generating carries, generates all possible carries by cascading logic gates, and directly obtains carries by looking up a table when needed. This method of pre-generating carries can greatly reduce the delay of the adder, improve the performance of the adder, and perform addition calculation and output on the output results of the interpolation module, thereby obtaining the final operation result of the booth multiplier.
[0019] The present invention also provides a method for operating a booth multiplier, the method comprising the following steps: (1) Perform preliminary decoding operations on the input multiplier and multiplicand to obtain the corresponding partial products.
[0020] (2) According to different situations of the partial products, sign extension is performed and corresponding addition compensation operations are performed, and an additional partial product is added to support calculation of both unsigned numbers and signed numbers, thereby obtaining an extended partial product.
[0021] (3) The expanded partial product is subjected to 3-2 compression processing and 4-2 compression processing step by step to obtain a compressed partial product.
[0022] (4) The compressed partial product is stored until the next control signal arrives and then the compression processing result is output.
[0023] (5) Calculate the sum of the compression processing results, which is the final multiplication result.
[0024] Technical features and beneficial effects of the present invention: (1) The present invention provides a new calculation scheme based on the existing improved booth multiplier optimization design. First, the partial products are padded, the sign bit of each partial product is extended, and the partial products are simplified according to the positive and negative numbers of the partial products. The booth2 encoding based on sign extension is adopted, and it is not necessary to extend all the sign bits, which greatly reduces the number of sign bit extensions, reduces the carry and flip caused by extending a large number of consecutive 1s, and reduces the use of resources to a certain extent. Secondly, if it is necessary to perform an addition operation according to the partial product situation, the addition operation generates a corresponding addition signal, which is placed in the addition tree and added together with the remaining partial products. Finally, in order to support the multiplication calculation of signed and unsigned numbers at the same time, the partial products of signed multiplication are reused, and the last bit of the multiplier is compensated, that is, while performing the addition compensation, the last row of partial products is modified to support the calculation of signed multiplication and unsigned multiplication at the same time.
[0025] (2) Compared with the traditional booth multiplier, the present invention significantly reduces the number of adders used in the Wallace tree structure, significantly increases the reusability of adders, reduces the compression structure level, and effectively improves the parallelism of the accumulation operation. A tree structure that alternates between 3-2 compressors and 4-2 compressors is adopted. The compression structure is symmetrical, and the carry of the two numbers is separated from the result and does not depend on the carry of the previous bit, so the timing is better. The critical path delay is less, which improves the compression efficiency and saves area.
[0026] (3) The core technology of the present invention is to improve the compressor and compression structure by processing the sign extension of partial products and adding an additional partial product operation, thereby improving the overall performance of the multiplier and reducing the area of the multiplier. The sign extension of the partial product is performed according to the different classification conditions of the partial product, the addition operation of the partial product operation is compensated to the tail of the next partial product, and an additional row of partial products is added to support the multiplication calculation of signed and unsigned numbers at the same time, improve the traditional compressor structure, and improve its structural hierarchy in the basic Wallace tree structure, improve the compression efficiency, enhance the overall operation performance of the multiplier, save the circuit area of the multiplier and reduce power consumption. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 A schematic diagram of a specific structure of an embodiment of the present invention; Figure 2 A schematic diagram of partial product sign expansion in an embodiment of the present invention; Figure 3 Schematic diagram of the Wallace tree structure in an embodiment of the present invention. DETAILED DESCRIPTION
[0028] The present invention is further described in detail below with reference to the accompanying drawings and specific embodiments to facilitate a better understanding of the technical solution of the present invention.
[0029] Figure 1 A specific structural diagram of a booth multiplier design based on sign extension provided in this embodiment, from Figure 1 It can be seen that the present invention mainly includes a partial product generation module, a sign extension module, a Wallace tree module, an insertion module and a carry look-ahead adder module.
[0030] The partial product generation module is a module connected to the input data, which is composed of a booth encoder and is used to perform preliminary decoding operations on the input 32-bit multiplier and multiplicand to obtain the corresponding partial products. The sign extension module is connected to the partial product generation module and is used to perform sign extension on the partial product and add an additional partial product to support the calculation of signed and unsigned numbers at the same time, thereby obtaining the extended partial product. The Wallace tree module is connected to the sign extension module and is used to perform compression calculation on the extended partial product to obtain the compressed partial product. The interpolation module is connected to the Wallace tree module and is used to perform an interpolation before adding the compressed partial product to ensure the overall timing. The carry look-ahead adder module is connected to the interpolation module and is used to perform addition operations on the interpolated data, and the sum is the final multiplication result.
[0031] And from Figure 1 It can also be seen intuitively that the Wallace tree module includes a first 3-2 compressor and a second 3-2 compressor, a first 4-2 compressor and a second 4-2 compressor, combined with Figure 3 It is not difficult to see that the first 3-2 compressor in the Wallace tree module is respectively connected to the symbol compensation module and the first 4-2 compressor, and the second 3-2 compressor is used to perform second-level 3-2 compression processing on the first-level 4-2 compression processing result; the first 4-2 compressor is used to perform first-level 4-2 compression processing on the first-level 3-2 compression processing result, and the second 4-2 compressor is used to perform second-level 4-2 compression processing on the second-level 3-2 compression processing result, and the second 4-2 compressor is also connected to the interpolation module.
[0032] In addition, this embodiment also provides an operation method of a booth multiplier based on sign compensation. Figure 2 , the operation method of the booth multiplier is described in detail, which specifically includes the following steps: The basic booth1 coding cannot really optimize the hardware multiplier circuit because the number of partial products is not reduced. Therefore, booth2 coding is proposed based on booth1 coding. The number of partial products generated by this encoder is further reduced, thereby achieving the purpose of reducing hardware adders and significantly reducing the circuit delay and power consumption.
[0033] Assume that the input A is the multiplicand and B is the multiplier. According to the booth2 encoding rule, after completing the preliminary decoding operation, the partial product obtained has three cases: 0, 1A, and 2A.
[0034] Table 1: booth2 encoding rules table <![CDATA[ B i+1 B i B i-1 ]]> <![CDATA[-2 B i+1 +B i +B i-1 ]]> Partial Product Operation 000 +0 0 001 +1 1A 010 +1 1A 011 +2 2A 100 -2 -2A 101 -1 -1A 110 -1 -1A 111 -0 0 Compared with booth1 encoding, booth2 encoding can effectively reduce the number of partial products. However, booth2 encoding still has negative coefficients, so the impact of negative partial products on compression needs to be considered. During compression, because the number of bits of the partial products is different, sign extension is required to fill the number of bits. If the partial product is negative, the sign bit is filled with 1, which will generate a large number of carries and bit flips during accumulation calculations, thereby increasing the power consumption and area of the multiplier.
[0035] Table 2: Improved booth2 encoding rules table <![CDATA[ B i+1 B i B i-1 ]]> operate illustrate 000 +0 Set to 0 001 <![CDATA[+[A] 补 ]]> Keep it the same 010 <![CDATA[+[A] 补 ]]> Keep it the same 011 <![CDATA[+2[A] 补 ]]> A shifts left one position 100 <![CDATA[-2[A] 补 ]]> Invert A, shift it left one bit, and add 2 101 <![CDATA[-[A] 补 ]]> A is negated and 1 is added 110 <![CDATA[-[A] 补 ]]> A is negated and 1 is added 111 -0 Set to 0 In this embodiment, the overall computing performance of the multiplier is improved by extending the sign bit of the partial product and adding additional partial products.
[0036] according to Figure 2 , the specific steps of the sign extension module are as follows: Let ai and bi represent the partial products of the i-th row that need to be compensated by +2 / +1 respectively, and i is an integer from 0 to 16. The +2 / +1 part of the partial products of the i-th row is compensated in the i+1th row. Therefore, the partial products of the 32-bit multiplier require a total of 32 / 2+1=17 items.
[0037] Assuming that all the partial products are negative numbers, the front part of the sign bit extension is all 1 at this time, first add all the sign bits extended in the upper left corner, that is, by adding 1 vertically, the carry method is simplified.
[0038] Assuming that one of the partial products is not a negative number, the operation of adding 1 at the end of the partial product will convert the consecutive 1s back to consecutive 0s. In fact, the addition of 1 at the end only occurs when the multiplier and the negative number are multiplied, that is, when the booth code is 101, 110. At this time, it is only necessary to add a 1 to the bit before the sign bit of the partial product to convert the row into a sign extension for the case of a positive number.
[0039] When E is 0, it indicates that the partial product is a positive number; when E is 1, it indicates that the partial product is a negative number. When calculating unsigned multiplication, the partial product of signed multiplication can be reused, and only the last bit of the multiplier needs to be compensated.
[0040] In addition, the Wallace tree module includes a first 3-2 compressor and a second 3-2 compressor, a first 4-2 compressor and a second 4-2 compressor, specifically including: The first 3-2 compressor is connected to the symbol compensation module and the first 4-2 compressor respectively, and the second 3-2 compressor is used to perform second-level 3-2 compression processing on the first-level 4-2 compression processing result; the first 4-2 compressor is used to perform first-level 4-2 compression processing on the first-level 3-2 compression processing result, and the second 4-2 compressor is used to perform second-level 4-2 compression processing on the second-level 3-2 compression processing result, and the second 4-2 compressor is also connected to the interpolation module.
[0041] The interpolation module is used to store the processing result and maintain the value of the processing result in the absence of a clock signal until the next control signal arrives, so as to ensure the overall timing.
[0042] The carry-lookahead adder module adopts a strategy of pre-generating carries, generating all possible carries through cascading logic gates, and directly looking up the table to obtain the carries when needed. This method of pre-generating carries can greatly reduce the delay of the adder, improve the performance of the adder, and perform addition calculation and output on the output results of the interpolation module, thereby obtaining the final operation result of the booth multiplier.
Claims
1. A booth multiplier based on sign extension, include: A partial product generation module, a sign extension module, a Wallace tree module, an insertion module and a carry lookahead adder module; the partial product generation module is composed of a booth encoder and connected to input data; the sign extension module is connected to the partial product generation module, the Wallace tree module is connected to the sign extension module, the insertion module is connected to the Wallace tree module, and the carry lookahead adder module is connected to the insertion module; it is characterized in that: The sign extension module performs corresponding addition on the partial product according to the partial product operation condition, and then performs extension processing on the sign bit according to the positive and negative signs of the partial product to obtain the extended partial product, specifically including: Let ai and bi represent the partial products of the i-th row that need to be compensated by +2 / +1, respectively, i is an integer from 0 to 16, and the +2 / +1 part of the partial products of the i-th row is compensated in the i+1 row; When all partial products are negative, the sign bit extension front part is all 1, first add all the sign bits extended in the upper left corner, that is, add 1 vertically to simplify the carry method; When one of the terms in the partial product is not negative, the operation of adding 1 to the end of the partial product will turn the consecutive 1s back into consecutive 0s. At this time, you only need to add a 1 to the bit before the sign bit of the partial product to convert the row into a sign extension for the case of a positive number. When E is 0, it indicates that the partial product is positive, and when E is 1, it indicates that the partial product is negative. When calculating unsigned multiplication, it is allowed to reuse the partial product of signed multiplication, and only the last bit of the multiplier needs to be compensated. The Wallace tree module specifically includes: a first 3-2 compressor connected to the sign extension module and the first 4-2 compressor respectively; a second 3-2 compressor used to perform a second-level 3-2 compression process on the first-level 4-2 compression processing result; the first 4-2 compressor used to perform a first-level 4-2 compression process on the first-level 3-2 compression processing result, and the second 4-2 compressor used to perform a second-level 4-2 compression process on the second-level 3-2 compression processing result, and the second 4-2 compressor is also connected to the interpolation module.
2. The booth multiplier according to claim 1, It is characterized in that The carry-lookahead adder module adopts a strategy of pre-generating carries, generates all possible carries through cascading logic gates, and directly looks up a table to obtain the carry when needed.
3. A method of operation based on sign extension booth multiplier, It is characterized in that The method comprises: Perform preliminary decoding operations on the input multiplier and multiplicand to obtain the corresponding partial products; Performing sign extension according to different situations of the partial products, and performing corresponding addition compensation operations, and then adding an additional partial product to support calculation of unsigned numbers and signed numbers at the same time, to obtain an extended partial product; The expanded partial product is subjected to 3-2 compression processing and 4-2 compression processing step by step to obtain a compressed partial product; storing the compressed partial product until the next control signal arrives and then outputting the compression processing result; The sum of the compression processing results is calculated, and the sum is the final multiplication result.
