Multiplication method, device, computer equipment and storage medium

By constructing a partial product array and performing Boolean function operations and reducing the tree structure, the problems of large multiplier area and power consumption are solved, achieving efficient construction and resource saving of the multiplier.

CN116360730BActive Publication Date: 2026-11-24TSINGHUA UNIVERSITY
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211545429.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-05
Publication Date
2026-11-24
Estimated Expiration
2042-12-05

AI Technical Summary

Technical Problem

Traditional encoding methods for multipliers result in large multiplier area and power consumption, and existing technologies struggle to effectively reduce these aspects.

Method used

By constructing a partial product array and performing Boolean function operations and reducing the tree structure, the number of rows in the multiplier is reduced, and the adders corresponding to the reduced simple elements are determined, thus constructing the target multiplier.

Benefits of technology

This reduces the area and power consumption of the multiplier, decreases the number of adders used, and enables efficient construction of the multiplier.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116360730B_ABST
    Figure CN116360730B_ABST
Patent Text Reader

Abstract

This application relates to a method, apparatus, computer device, storage medium, and computer program product for constructing a multiplier. The method includes: obtaining a partial product array based on a first upper limit number of bits of first sample operational data, a second upper limit number of bits of second sample operational data, and a preset encoding algorithm. The partial product array is optimized using a preset row optimization strategy to obtain a target partial product with fewer rows. Furthermore, reduced simple elements are determined according to a preset reduction tree structure, and the adders corresponding to these reduced simple elements are determined to construct the target multiplier. This method can reduce the area and power consumption of the multiplier.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of integrated circuit design technology, and in particular to a method, apparatus, computer device, storage medium, and computer program product for constructing a multiplier. Background Technology

[0002] With the development of integrated circuit design, multiplier design technology has emerged. In digital circuit systems, the multiplier is an indispensable hardware device, and its foundation is composed of more basic adders. Digital signal processing and convolution operations are essentially multiplexing of multiplication operations. Therefore, when using digital circuit systems for signal processing, various types of multipliers are often used.

[0003] In traditional technologies, multipliers typically use a 4-radix modified Poltz coding method, which produces a complex partial product array. As a result, multipliers require more adders, leading to larger multiplier area and higher power consumption. Summary of the Invention

[0004] Therefore, it is necessary to provide a method, apparatus, computer device, computer-readable storage medium, and computer program product for constructing a multiplier that can reduce the area and power consumption of the multiplier, in order to address the above-mentioned technical problems.

[0005] Firstly, this application provides a method for constructing a multiplier. The method includes:

[0006] Construct a partial product array based on the first upper limit number of bits of the first sample operation data, the second upper limit number of bits of the second sample operation data, and a preset encoding algorithm;

[0007] Based on a preset row optimization strategy, the partial product array is subjected to row optimization processing through Boolean function operations to obtain a target partial product array; the number of rows in the target partial product array is less than the number of rows in the partial product array.

[0008] Based on a preset reduction tree structure, multiple reduced simple elements corresponding to the target partial product array are determined, and the adder corresponding to each reduced simple element is determined.

[0009] Construct the target multiplier based on the adders corresponding to each of the reduced simple elements.

[0010] In one embodiment, constructing a partial product array based on the first upper limit number of bits of the first sample operation data, the second upper limit number of bits of the second sample operation data, and a preset encoding algorithm includes:

[0011] Based on the first sample operation data and the preset encoding algorithm, determine the target number of bits after encoding corresponding to the first upper limit number of bits of the first sample operation data;

[0012] Based on the target number of bits and the second upper limit number of bits of the second sample operation data, a partial product array is constructed.

[0013] In one embodiment, the step of optimizing the partial product array using Boolean function operations based on a preset optimization strategy to obtain the target partial product array includes:

[0014] Perform a Boolean function operation on the minterm of each row of the partial product array and the two's complement term of each row of the partial product array to obtain a second partial product array; each term of the partial product array is a Boolean expression.

[0015] Perform a Boolean function operation between the target item of the target row of the partial product array and the item corresponding to the sign bit of the first row in the second partial product array to obtain the target partial product array.

[0016] In one embodiment, the step of dividing the target partial product array into multiple reduced simple elements based on a preset reduced tree structure and determining the adder corresponding to each reduced simple element includes:

[0017] Based on the preset reduction tree structure, the target partial product array is divided into multiple reduced simple elements and multiple residual summation terms;

[0018] Based on the allocation strategy of the first processing unit, a corresponding adder is allocated to each of the reduced simple elements;

[0019] The target partial product array is summed by the adders corresponding to the reduced simple elements in the array structure of the target partial product array to obtain the target partial product array for the next stage; and the step of dividing the target partial product array into multiple reduced simple elements and multiple residual summation terms based on the preset reduction tree structure is executed until the number of rows of the obtained target partial product array meets the preset row number condition.

[0020] Based on the second processing unit allocation strategy, each of the reduced simple elements in the target partial product array that meets the preset row number condition is assigned a corresponding adder.

[0021] In one embodiment, the step of dividing the target partial product array into multiple reduced simple elements and multiple residual summation terms based on the preset reduction tree structure includes:

[0022] Based on the preset reduction tree structure and the number of array rows of the target partial product array, target summation terms that satisfy the preset reduction element partitioning conditions are determined, the target partial product array is divided into multiple reduction elements, and multiple summation terms that do not satisfy the preset reduction element partitioning conditions are taken as multiple remaining summation terms, and the type of each reduction element is determined; the type of the reduction element includes a first reduction element type and a second reduction element type;

[0023] The allocation strategy based on the first processing unit, which assigns corresponding adders to each of the reduced simple elements, includes:

[0024] For each reduction element, based on the correspondence between the type of the reduction element and the type of adder, the target adder type corresponding to the type of the reduction element is determined, and an adder of the target adder type is assigned to the reduction element.

[0025] In one embodiment, constructing the target multiplier based on the adders corresponding to each of the reduced simple elements includes:

[0026] A program is written according to the preset encoding algorithm and mapped to the target standard unit library as the first standard unit; the target standard unit includes an adder.

[0027] The first program corresponding to the preset encoding algorithm is mapped to the first standard unit contained in the target standard unit library to obtain the first processing unit; the preset encoding method is the NR4SD encoding and decoding method;

[0028] The second program corresponding to the Boolean function operation is mapped to the second standard unit contained in the target standard unit library to obtain the second processing unit;

[0029] The target multiplier is constructed based on the adders corresponding to each of the reduced simple elements in the first processing unit, the second processing unit, and the target standard unit library.

[0030] Secondly, this application also provides a device for constructing a multiplier. The device includes:

[0031] The first construction module is used to construct a partial product array based on the first upper limit number of bits of the first sample operation data, the second upper limit number of bits of the second sample operation data, and a preset encoding algorithm;

[0032] An optimization module is used to perform row optimization processing on the partial product array based on a preset row optimization strategy and through Boolean function operations to obtain a target partial product array; the number of rows in the target partial product array is less than the number of rows in the partial product array.

[0033] The determination module is used to determine multiple reduced simple elements corresponding to the target partial product array based on a preset reduced simple tree structure, and to determine the adder corresponding to each reduced simple element;

[0034] The second construction module is used to construct a target multiplier based on the adders corresponding to each of the reduced simple elements.

[0035] In one embodiment, the first building module is specifically used for:

[0036] Based on the first sample operation data and the preset encoding algorithm, determine the target number of bits after encoding corresponding to the first upper limit number of bits of the first sample operation data;

[0037] Based on the target number of bits and the second upper limit number of bits of the second sample operation data, a partial product array is constructed.

[0038] In one embodiment, the optimization module is specifically used for:

[0039] Perform a Boolean function operation between the minterm of each row of the partial product array and the complement term of each row of the partial product array to obtain a second partial product array; each term of the partial product array is a Boolean expression.

[0040] Perform a Boolean function operation between the target item of the target row of the partial product array and the item corresponding to the sign bit of the first row in the second partial product array to obtain the target partial product array.

[0041] In one embodiment, the determining module is specifically used for:

[0042] Based on the preset reduction tree structure, the terms of the target partial product array are divided into multiple reduced simple elements and multiple residual summation terms;

[0043] Based on the allocation strategy of the first processing unit, a corresponding adder is allocated to each of the reduced simple elements;

[0044] The terms of the target partial product array are summed using the adders corresponding to the reduced simple elements in the array structure of the target partial product array to obtain the target partial product array for the next stage; and the step of dividing the target partial product array into multiple reduced simple elements and multiple remaining summation terms based on the preset reduced tree structure is executed until the number of rows of the obtained target partial product array meets the preset number of rows condition.

[0045] Based on the second processing unit allocation strategy, each reduced simple element in the target partial product array that satisfies the preset row number condition is assigned a corresponding adder.

[0046] In one embodiment, the first determining module is further configured to:

[0047] Based on the preset reduction tree structure and the number of array rows of the target partial product array, target summation terms that satisfy the preset reduction element partitioning conditions are determined, the target partial product array is divided into multiple reduction elements, and the type of each reduction element is determined; summation terms that do not satisfy the preset reduction element partitioning conditions are taken as the remaining summation terms; wherein, the type of the reduction element includes a first reduction element type and a second reduction element type;

[0048] For each reduction element, based on the correspondence between the type of the reduction element and the type of adder, the target adder type corresponding to the type of the reduction element is determined, and an adder of the target adder type is assigned to the reduction element.

[0049] In one embodiment, the second building module is specifically used for:

[0050] The first program corresponding to the preset encoding algorithm is mapped to the first standard unit contained in the target standard unit library to obtain the first processing unit; the preset encoding method is the NR4SD encoding and decoding method;

[0051] The second program corresponding to the Boolean function operation is mapped to the second standard unit contained in the target standard unit library to obtain the second processing unit;

[0052] The target multiplier is constructed based on the adders corresponding to each of the reduced simple elements in the first processing unit, the second processing unit, and the target standard unit library.

[0053] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:

[0054] Construct a partial product array based on the first upper limit number of bits of the first sample operation data, the second upper limit number of bits of the second sample operation data, and a preset encoding algorithm;

[0055] Based on a preset row optimization strategy, the partial product array is subjected to row optimization processing through Boolean function operations to obtain a target partial product array; the number of rows in the target partial product array is less than the number of rows in the partial product array.

[0056] Based on a preset reduction tree structure, multiple reduced simple elements corresponding to the target partial product array are determined, and the adder corresponding to each reduced simple element is determined.

[0057] Construct the target multiplier based on the adders corresponding to each of the reduced simple elements.

[0058] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:

[0059] Construct a partial product array based on the first upper limit number of bits of the first sample operation data, the second upper limit number of bits of the second sample operation data, and a preset encoding algorithm;

[0060] Based on a preset row optimization strategy, the partial product array is subjected to row optimization processing through Boolean function operations to obtain a target partial product array; the number of rows in the target partial product array is less than the number of rows in the partial product array.

[0061] Based on a preset reduction tree structure, multiple reduced simple elements corresponding to the target partial product array are determined, and the adder corresponding to each reduced simple element is determined.

[0062] Construct the target multiplier based on the adders corresponding to each of the reduced simple elements.

[0063] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:

[0064] Construct a partial product array based on the first upper limit number of bits of the first sample operation data, the second upper limit number of bits of the second sample operation data, and a preset encoding algorithm;

[0065] Based on a preset row optimization strategy, the partial product array is subjected to row optimization processing through Boolean function operations to obtain a target partial product array; the number of rows in the target partial product array is less than the number of rows in the partial product array.

[0066] Based on a preset reduction tree structure, multiple reduced simple elements corresponding to the target partial product array are determined, and the adder corresponding to each reduced simple element is determined.

[0067] Construct the target multiplier based on the adders corresponding to each of the reduced simple elements.

[0068] The aforementioned method, apparatus, computer device, storage medium, and computer program product for constructing a multiplier obtain a partial product array based on the first upper limit bit width of the first sample operation data, the second upper limit bit width of the second sample operation data, and a preset encoding algorithm. By optimizing the partial product array using a preset row optimization strategy, a target partial product with fewer rows can be obtained. Furthermore, reduced simple elements are determined according to a preset reduction tree structure, and the adders corresponding to these reduced simple elements are identified to construct the target multiplier. In this scheme, by optimizing and reducing the partial product array, the number of rows in the partial product array can be reduced, thereby reducing the complexity of the partial product array and consequently reducing the number of adders used. This achieves the effects of reducing the area and power consumption of the multiplier. Attached Figure Description

[0069] Figure 1 This is a flowchart illustrating the method for constructing a multiplier in one embodiment;

[0070] Figure 2 This is a schematic diagram illustrating the process of constructing a partial product array in one embodiment;

[0071] Figure 3 This is a schematic diagram of a partial product array in one embodiment;

[0072] Figure 4 This is a flowchart illustrating the process of obtaining the target partial product in one embodiment;

[0073] Figure 5 This is a schematic diagram of the second part of the product array in one embodiment;

[0074] Figure 6 This is a schematic diagram of a target partial product array in one embodiment;

[0075] Figure 7 This is a flowchart illustrating the process of determining the simplified elements and the adders corresponding to each simplified element in one embodiment.

[0076] Figure 8 This is a flowchart illustrating the process of dividing a target partial product array into multiple reduced simple elements and multiple residual summation terms in one embodiment;

[0077] Figure 9 This is a schematic diagram of a reduced tree structure in one embodiment;

[0078] Figure 10 This is a schematic diagram of the process for obtaining the target multiplier in one embodiment;

[0079] Figure 11 This is a structural block diagram of a multiplier construction device in one embodiment;

[0080] Figure 12This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0081] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0082] In one embodiment, such as Figure 1 As shown, a method for constructing a multiplier is provided. This embodiment uses the application of this method to a terminal as an example for illustration. It can be understood that this method can also be applied to a server, and can also be applied to a system including a terminal and a server, and can be implemented through the interaction between the terminal and the server.

[0083] In this embodiment, the method includes the following steps:

[0084] Step 102: Construct a partial product array based on the first upper limit number of bits of the first sample operation data, the second upper limit number of bits of the second sample operation data, and the preset encoding algorithm.

[0085] In this embodiment, both the first sample operation data and the second sample operation data are binary numbers. The first sample operation data and the second sample operation data can be default data, data configured by technicians, or random data. This embodiment does not limit the data in this regard. The first sample operation data can be the multiplier, and the second sample operation data can be the multiplicand. The first upper limit number of bits and the second upper limit number of bits are preset upper limit numbers of the multiplier input data. The first upper limit number of bits and the second upper limit number of bits can be the same or different. This embodiment uses 16 bits for both the first upper limit number of bits and the second upper limit number of bits as an example. The first upper limit number of bits and the second upper limit number of bits are not limited.

[0086] In this embodiment, the terminal acquires first sample operation data and second sample operation data. Then, the terminal performs a multiplication operation on the first sample operation data and the second sample operation data according to a preset encoding algorithm, the first upper limit number of bits of the first sample operation data, and the second upper limit number of bits of the second sample operation data. Finally, a partial product array is constructed based on the operation result.

[0087] Step 104: Based on the preset row optimization strategy, perform row optimization processing on the partial product array through Boolean function operations to obtain the target partial product array.

[0088] In this case, the number of rows in the target partial product array is less than the number of rows in the partial product array.

[0089] In this embodiment, the terminal, based on a preset row optimization strategy, performs Boolean addition on the terms in the partial product to obtain a partial product array after addition. The terminal then uses this partial product array as the target partial product array.

[0090] Because the terminal generates a carry by performing Boolean addition on the terms in the partial product, which reduces the number of terms in the current partial product array, the number of rows in the partial product array will be reduced after the Boolean addition operation.

[0091] Step 106: Based on the preset reduction tree structure, determine the multiple reduction elements corresponding to the target partial product array, and determine the adder corresponding to each reduction element.

[0092] The approximate element is the smallest unit used to allocate adders. The target partial product array contains multiple terms. The approximate element is the result of partitioning the terms in the target partial product array. Each approximate element contains at least one term from the target partial product array.

[0093] In this embodiment, the terminal may pre-store a reduction tree algorithm, and then construct a preset reduction tree structure based on the algorithm. Based on the preset reduction tree structure, the terminal determines multiple reduced simple elements corresponding to the target partial product array. Then, based on the type of each reduced simple element, the terminal determines the type of adder corresponding to that simple element.

[0094] The specific reduction tree algorithm can be as follows: The terminal determines whether the number of rows in the target partial product array is greater than the first preset number of rows (e.g., the preset number of rows is 3). When the number of rows in the target partial product array is greater than the first preset number of rows, for any column in the target partial product array, if the number of items in the column is greater than or equal to the first preset number (e.g., the first preset number is 3), the terminal divides the items contained in the column according to the first preset number, obtaining at least one group containing the first preset number of items. Each group is input into a full adder for addition calculation. For the remaining items in the column, if the number of remaining items in the column is the second preset number (e.g., the second preset number is 2), the terminal inputs these remaining items in the column into a half adder for addition calculation. If the number of remaining items in the column is the third preset number (e.g., the third preset number is 1), the terminal does not process the remaining items in the column. When the number of items in the column is equal to the second preset number, and if allocating a half adder to the column can increase the number of items in the left column to the first preset number, the terminal inputs the items in the column into a half adder for addition operation.

[0095] The terminal uses the calculation results of the addition operation performed by the full adder and the half adder as the target partial product array for the next stage. The terms of the target partial product array for the next stage correspond to the positions of the terms that were added.

[0096] When the terminal determines that the number of rows in the target partial product is less than the first preset number of rows, for any column in the target partial product array, if the number of items in the column is equal to the third preset number (e.g., the third preset number is 1), and inputting the items in the column into the half adder cannot increase the number of items in the left column, then the terminal does not process the items in the column. If it can increase the number of items in the left column, then the terminal inputs the items in the column into the half adder for addition. If the number of items in the column is equal to the second preset number, and the right column of the column does not include an adder, then the terminal inputs the items in the column into the half adder. If the right column of the column includes an adder, then the items in the column are input into the full adder for addition. When the adder completes the addition operation, the reduction process ends.

[0097] Based on the above processing, when moving from the previous target partial product array structure to the next target partial product array structure, if both target partial product array structures have adders in the same column, then the number of terms in the column of the next target partial product must be less than the number of terms in the column of the previous target partial product.

[0098] Step 108: Construct the target multiplier based on the adders of each simplified element.

[0099] In this embodiment, the terminal constructs the target multiplier based on the arrangement order of the adders corresponding to each reduced simple element in the reduced tree structure, the preset encoding method, and the preset row optimization strategy.

[0100] In the above method for constructing a multiplier, a partial product array is obtained based on the first upper limit number of bits of the first sample operation data, the second upper limit number of bits of the second sample operation data, and a preset encoding algorithm. By optimizing the partial product array using a preset row optimization strategy, a target partial product with fewer rows can be obtained. Furthermore, reduced simple elements are determined according to a preset reduction tree structure, and the adders corresponding to these reduced simple elements are identified to construct the target multiplier. In this scheme, by optimizing and reducing the partial product array, the number of rows in the partial product array can be reduced, thereby reducing the complexity of the partial product array and consequently reducing the number of adders used. This achieves the effects of reducing the area and power consumption of the multiplier.

[0101] In one embodiment, such as Figure 2 As shown, step 102 includes:

[0102] Step 202: Based on the first sample operation data and the preset encoding algorithm, determine the target number of bits after encoding corresponding to the first upper limit number of bits.

[0103] In this embodiment of the application, the terminal may pre-store the upper limit number of bits of the first sample operation data, and the terminal determines the target number of bits after encoding corresponding to the first upper limit number of bits according to the preset encoding algorithm.

[0104] Specifically, the terminal processes the first sample operation data according to the NR4SD-encoding and decoding method in Table 1, converting the three-bit binary number in the first sample data into data in the dataset {-2, -1, 0, 1} of the NR4SD-encoding method.

[0105] Table 1

[0106]

[0107] Here, 2's complement represents the method of representing signed numbers in binary, also known as two's complement; b2j+1 represents the odd-numbered term of the multiplier (i.e., the 2j+1th term of the multiplier); b2j represents the even-numbered term of the multiplier (i.e., the 2jth term of the multiplier); c2j represents the result of the operation obtained by combining the b2j+1 and b2j terms; c2j+2 represents the result of the operation obtained by combining the b2j+1, b2j, and c2j terms; Digit This represents the first sample computational data obtained after NR4SD encoding.

[0108] Step 204: Construct a partial product array based on the target number of bits and the second upper limit number of bits.

[0109] In this embodiment, the terminal, based on a preset encoding algorithm, multiplies the first sample operation data and the second sample operation data according to the target number of bits and the second upper limit number of bits, to obtain a multi-row partial product. Then, the terminal constructs a partial product array based on the multi-row partial products, as shown in the example below. Figure 3 As shown.

[0110] In this embodiment, by using a preset encoding algorithm based on the NR4SD encoding and decoding method, three bits can be converted into one bit, thereby reducing the first upper limit of the first sample operation data and achieving the effect of reducing the number of rows in the partial product array.

[0111] In one embodiment, such as Figure 4 As shown, step 104 includes:

[0112] Step 402: Perform Boolean function operations on the minterms of each row of the partial product array and the complement terms of each row of the partial product array to obtain the second partial product array.

[0113] Each item in the partial product array is a Boolean expression.

[0114] In this embodiment, the terminal performs Boolean addition on the minterms and complements of each row of the partial product array. Specifically, the terminal performs Boolean addition on the Boolean expressions of the minterms and complements of each row of the partial product array to obtain a second partial product array, as shown in the example below. Figure 5 As shown.

[0115] in, Figure 5 a0-a15 represent 16-bit wide binary multiplicands, b0-b15 represent 16-bit wide binary multipliers, ai represents the i-th multiplicand, and bi represents the i-th multiplier. This application example illustrates that both the first sample operation data and the second sample operation data are 16-bit binary numbers, and the number of bits in the first sample operation data and the second sample operation data is not limited.

[0116] The terminal reduces the number of rows in the partial product array by performing Boolean addition on the Boolean expressions of the minterms and the complement terms of each row of the partial product.

[0117] Step 404: Perform a Boolean function operation on the target item of the target row of the partial product array and the item corresponding to the sign bit of the first row in the second partial product array to obtain the target partial product array.

[0118] Among them, the sign bit is Figure 6 The first three terms in the first row of the middle parti-matrix array.

[0119] In this embodiment, the terminal performs a Boolean addition operation on the items contained in the bottom row of the second partial product array and the items corresponding to the sign bits of the first row in the second partial product array to obtain the target partial product array, as shown in the example below. Figure 6 As shown.

[0120] In this embodiment, the terminal performs Boolean addition on the Boolean expression of the minterm of each row of the partial product and the Boolean expression of the complement term of each row of the partial product. Then, the terminal performs Boolean addition on the term corresponding to the sign bit of the first row in the second partial product array. This reduces the number of rows in the partial product array, which is beneficial for reducing the number of adders when allocating adders in the subsequent reduction tree structure.

[0121] In one embodiment, such as Figure 7 As shown, step 106 includes:

[0122] Step 702: Based on the preset reduction tree structure, the target partial product array is divided into multiple reduced simple elements and multiple residual summation terms.

[0123] In this embodiment of the application, the terminal may pre-select and store a preset reduction tree structure. The terminal divides the terms of the target partial product array into multiple reduced simple elements and multiple residual summation terms according to the preset reduction tree structure.

[0124] Step 704: Based on the allocation strategy of the first processing unit, assign the corresponding adder to each simplified element.

[0125] In this embodiment of the application, the terminal may pre-store a first processing unit allocation strategy, and allocate corresponding adders to each simplified element according to the first processing unit allocation strategy.

[0126] Specifically, based on the array structure of the target partial product array, the terminal determines whether the number of terms in each column of the array structure is greater than or equal to a first preset number, for example, the first preset number can be 3. If the number of terms in the column is greater than the first preset number, the terminal uses the input of the first preset number of terms in each column as the first reduced simple element, and the input of the second preset number of terms in each column as the second reduced simple element, for example, the second preset number can be 2. Then, the terminal assigns a corresponding adder to each reduced simple element. Specifically, the terminal assigns one adder to the first reduced simple element and one half-adder to the second reduced simple element.

[0127] Optionally, any hardware device with adder functionality can be used in this application, and the embodiments of this application do not limit this.

[0128] Step 706: Summing is performed on the terms of the target partial product array using the adders corresponding to each reduced simple element in the array structure of the target partial product array to obtain the target partial product array for the next stage; and the target partial product array is divided into multiple reduced simple elements and multiple remaining summation terms based on a preset reduction tree structure until the number of rows of the obtained target partial product array meets the preset row number condition.

[0129] The preset row count condition is that the target partial product array for the next stage has no more than two rows.

[0130] In this embodiment, the terminal performs addition on the terms in each reduced simple element of the target partial product array using adders corresponding to those elements in the array structure, to obtain the next-stage target partial product array. Then, the terminal determines whether the next-stage target partial product array obtained after addition satisfies a preset row count condition. If it does not, the terminal continues to divide the target partial product array into multiple reduced simple elements and multiple residual summation terms, and then performs addition operations on the multiple reduced simple elements using their corresponding adders until the next-stage target partial product array satisfies the preset row count condition. If the terminal determines that the next-stage target partial product array obtained after addition satisfies the preset row count condition, the terminal ends the step of performing addition on the terms in each reduced simple element using adders corresponding to those elements in the array structure of the target partial product array.

[0131] Step 708: Based on the second processing unit allocation strategy, assign the corresponding adders to each reduced simple element in the target partial product array that satisfies the preset row number condition.

[0132] In this embodiment of the application, the terminal may pre-store a second processing unit allocation strategy. The terminal divides the target partial product array into multiple simplified elements according to the second processing unit allocation strategy, wherein the simplified element type is a third simplified element type and a fourth simplified element type.

[0133] Specifically, based on the array structure of the target partial product array, the terminal determines whether the number of terms in each column of the array structure is greater than or equal to a third preset number. If the number of terms in the column is equal to the third preset number, the terminal, in a top-to-bottom order, uses the input of the third preset number of terms in each column of the target partial product array as the third reduction element and the input of the fourth preset number of terms in each column as the fourth reduction element. Then, the terminal determines the remaining number of terms in that column. The terminal then assigns a corresponding adder to each reduction element. Specifically, the terminal assigns a full adder to the third reduction element and a half adder to the fourth reduction element. If the number of terms in the column is less than the third preset number, the step of assigning the corresponding adder to the reduction element ends. In one example, the third preset number can be 2 and the fourth preset number can be 1.

[0134] In this embodiment, the terms in the target partial product are divided into multiple reduced simple elements by the allocation strategy of the first processing unit. The reduced simple elements are then added by the adders corresponding to the multiple reduced simple elements until the target partial product of the next stage that satisfies the preset row number condition is obtained. Then, the terms in the target partial product are divided into multiple reduced simple elements by the allocation strategy of the second processing unit. The reduced simple elements are then added by the adders corresponding to the multiple reduced simple elements, and the processing result of the target multiplier can be obtained. Based on the reduction tree structure, the use of adders can be reduced, thereby reducing the number of adders.

[0135] In one embodiment, such as Figure 8 As shown, step 702 includes:

[0136] Step 802: Based on the preset reduction tree structure and the number of array rows of the target partial product array, determine the target summation terms that satisfy the preset reduction element partitioning conditions, divide the target partial product array into multiple reduction elements, and take the multiple summation terms that do not satisfy the preset reduction element partitioning conditions as multiple residual summation terms, and determine the type of each reduction element.

[0137] The types of the primitives include a first primitive type and a second primitive type; the first primitive corresponds to a full adder and the second primitive corresponds to a half adder.

[0138] In this embodiment, the terminal takes the items in the target partial product array as summation items. Then, according to the preset reduction tree structure and preset reduction element partitioning conditions, the terminal takes the summation items in the target partial product array that satisfy the preset reduction element partitioning conditions as target summation items. Then, the terminal partitions the target summation items of the target partial product array into multiple reduction elements, wherein the reduction element type is a first reduction element type and a second reduction element type. Then, the terminal takes the summation items that do not satisfy the preset reduction element partitioning conditions as the remaining summation items.

[0139] Step 804: For each reduction element, determine the target adder type corresponding to the type of the reduction element based on the correspondence between the type of the reduction element and the type of adder, and assign an adder of the target adder type to the reduction element.

[0140] In this embodiment, the terminal determines the target adder type corresponding to the type of the reduced simple element based on the correspondence between the types of reduced simple elements and adder types. Specifically, the terminal assigns a full adder to the first reduced simple element, a half adder to the second reduced simple element, a full adder to the third reduced simple element, and a full adder to the fourth reduced simple element, as shown in the reduction tree structure. Figure 9 As shown.

[0141] in, Figure 9 In the reduced tree structure, a rectangular structure represents a full adder, and an elliptical structure represents a half adder.

[0142] In this embodiment, the adder type corresponding to each reduction element is determined by a preset reduction tree structure, which can assign adders to each reduction element, making it easier to perform addition processing on the reduction elements in the future.

[0143] In one embodiment, such as Figure 10 As shown, step 108 includes:

[0144] Step 1002: Map the first program corresponding to the preset encoding algorithm to the first standard unit contained in the target standard unit library to obtain the first processing unit.

[0145] The default encoding method is NR4SD encoding / decoding method.

[0146] In this embodiment of the application, the terminal may pre-store a first program written according to the NR4SD-encoding and decoding method, and then the terminal maps the first program to the first standard unit contained in the first standard unit in the target standard unit as the first processing unit.

[0147] Step 1004: Map the second program corresponding to the Boolean function operation to the second standard unit contained in the target standard unit library to obtain the second processing unit.

[0148] In this embodiment, the terminal may pre-store a second program written based on Boolean addition. Then, the terminal maps the second program to a second standard unit in the target standard unit library, as a second processing unit.

[0149] Step 1006: Construct the target multiplier based on the adders corresponding to each reduced simple element in the first processing unit, the second processing unit, and the target standard unit library.

[0150] In this embodiment, the first processing unit and the second processing unit in the target standard unit library are mapped to form a first processing unit device and a second processing unit device. The terminal connects the first processing unit device, the second processing unit device, and the adders corresponding to each reduced simple element to form a target multiplier.

[0151] The arrangement of adders corresponding to each reduced simple element within the multipliers can be correlated with the distribution of adders corresponding to each reduced simple element in the reduced simple tree structure. For example, the arrangement of adders within the multipliers can correspond one-to-one with the distribution of adders corresponding to each reduced simple element in the reduced simple tree structure.

[0152] In this embodiment, by mapping the first program and the second program into standard units and connecting each standard unit and each adder, the hardware device of the target multiplier can be obtained.

[0153] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0154] Based on the same inventive concept, this application also provides a multiplier construction apparatus for implementing the multiplier construction method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more embodiments of the multiplier construction apparatus provided below can be found in the limitations of the multiplier construction method described above, and will not be repeated here.

[0155] In one embodiment, such as Figure 11 As shown, a multiplier construction apparatus 1100 is provided, comprising: a first construction module 1102, an optimization module 1104, a determination module 1106, and a second construction module 1108, wherein:

[0156] The first construction module 1102 is used to construct a partial product array based on the first upper limit number of bits of the first sample operation data, the second upper limit number of bits of the second sample operation data, and a preset encoding algorithm.

[0157] The optimization module 1104 is used to perform row optimization processing on the partial product array based on a preset row optimization strategy and through Boolean function operations to obtain a target partial product array; the number of rows in the target partial product array is less than the number of rows in the partial product array.

[0158] The determination module 1106 is used to determine multiple reduced simple elements corresponding to the target partial product array based on a preset reduced tree structure, and to determine the adder corresponding to each reduced simple element.

[0159] The second construction module 1108 is used to construct a target multiplier based on the adders corresponding to each of the simplified simple elements.

[0160] In one embodiment, the first construction module 1102 is specifically used for:

[0161] Based on the first sample operation data and the preset encoding algorithm, determine the target number of bits after encoding corresponding to the first upper limit number of bits of the first sample operation data;

[0162] Based on the target number of bits and the second upper limit number of bits of the second sample operation data, a partial product array is constructed.

[0163] In one embodiment, the optimization module 1104 is specifically used for:

[0164] Perform a Boolean function operation on the minterm of each row of the partial product array and the complement term of each row of the partial product array to obtain a second partial product array, where each term of the partial product array is a Boolean expression;

[0165] Perform a Boolean function operation between the target item of the target row of the partial product array and the item corresponding to the sign bit of the first row in the second partial product array to obtain the target partial product array.

[0166] In one embodiment, the determining module 1106 is specifically used for:

[0167] Based on the preset reduction tree structure, the terms of the target partial product array are divided into multiple reduced simple elements and multiple residual summation terms;

[0168] Based on the allocation strategy of the first processing unit, a corresponding adder is allocated to each of the reduced simple elements;

[0169] The terms of the target partial product array are summed using the adders corresponding to the reduced simple elements in the array structure of the target partial product array to obtain the target partial product array for the next stage; and the step of dividing the target partial product array into multiple reduced simple elements and multiple remaining summation terms based on the preset reduced tree structure is executed until the number of rows of the obtained target partial product array meets the preset number of rows condition.

[0170] Based on the second processing unit allocation strategy, each reduced simple element in the target partial product array that satisfies the preset row number condition is assigned a corresponding adder.

[0171] In one embodiment, the determining module 1106 is further configured to:

[0172] Based on the preset reduction tree structure and the number of array rows of the target partial product array, target summation terms that satisfy the preset reduction element partitioning conditions are determined, the target partial product array is divided into multiple reduction elements, and multiple summation terms that do not satisfy the preset reduction element partitioning conditions are taken as multiple remaining summation terms, and the type of each reduction element is determined; the type of the reduction element includes a first reduction element type and a second reduction element type;

[0173] For each reduction element, based on the correspondence between the type of the reduction element and the type of adder, the target adder type corresponding to the type of the reduction element is determined, and an adder of the target adder type is assigned to the reduction element.

[0174] In one embodiment, the second building module 1108 is specifically used for:

[0175] The first program corresponding to the preset encoding algorithm is mapped to the first standard unit contained in the target standard unit library to obtain the first processing unit; the preset encoding method is the NR4SD encoding and decoding method;

[0176] The second program corresponding to the Boolean function operation is mapped to the second standard unit contained in the target standard unit library to obtain the second processing unit;

[0177] The target multiplier is constructed based on the adders corresponding to each of the reduced simple elements in the first processing unit, the second processing unit, and the target standard unit library.

[0178] Each module in the aforementioned multiplier construction device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.

[0179] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 12As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When executed by the processor, the computer program implements a method for constructing a multiplier. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.

[0180] Those skilled in the art will understand that Figure 12 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0181] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.

[0182] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in the above method embodiments.

[0183] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0184] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data shall comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0185] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0186] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0187] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A method for constructing a multiplier, characterized in that, The method includes: Construct a partial product array based on the first upper limit number of bits of the first sample operation data, the second upper limit number of bits of the second sample operation data, and a preset encoding algorithm; Based on a preset row optimization strategy, the partial product array is subjected to row optimization processing through Boolean function operations to obtain a target partial product array; the number of rows in the target partial product array is less than the number of rows in the partial product array; iterative summation is performed through adders corresponding to each reduced simple element until the number of rows in the obtained target partial product array does not exceed two. Based on a preset reduction tree structure, multiple reduced simple elements corresponding to the target partial product array are determined, and the adder corresponding to each reduced simple element is determined. Construct the target multiplier based on the adders corresponding to each of the reduced simple elements; Specifically, for any column in the target partial product array, if the number of items in the column is greater than or equal to a first preset number, the items contained in the column are divided according to the first preset data and full adders are assigned to perform addition calculations; if the number of remaining items in the column is equal to a second preset number, the remaining items are assigned to half adders for addition calculations; if the number of remaining items in the column is equal to a third preset number, no processing is performed.

2. The method according to claim 1, characterized in that, The step of constructing a partial product array based on the first upper limit number of bits of the first sample operation data, the second upper limit number of bits of the second sample operation data, and a preset encoding algorithm includes: Based on the first sample operation data and the preset encoding algorithm, determine the target number of bits after encoding corresponding to the first upper limit number of bits of the first sample operation data; Based on the target number of bits and the second upper limit number of bits of the second sample operation data, a partial product array is constructed.

3. The method according to claim 1, characterized in that, The process of performing row optimization on the partial product array based on a preset row optimization strategy, using Boolean function operations to obtain the target partial product array, includes: Perform a Boolean function operation between the minterm of each row of the partial product array and the complement term of each row of the partial product array to obtain a second partial product array; each term of the partial product array is a Boolean expression. Perform a Boolean function operation between the target item of the target row of the partial product array and the item corresponding to the sign bit of the first row in the second partial product array to obtain the target partial product array.

4. The method according to claim 1, characterized in that, The method of dividing the target partial product array into multiple reduced simple elements based on a preset reduction tree structure and determining the adder corresponding to each reduced simple element includes: Based on the preset reduction tree structure, the terms of the target partial product array are divided into multiple reduced simple elements and multiple residual summation terms; Based on the allocation strategy of the first processing unit, a corresponding adder is allocated to each of the reduced simple elements; The terms of the target partial product array are summed using the adders corresponding to the reduced simple elements in the array structure of the target partial product array to obtain the target partial product array for the next stage; and the step of dividing the target partial product array into multiple reduced simple elements and multiple remaining summation terms based on the preset reduced tree structure is executed until the number of rows of the obtained target partial product array meets the preset number of rows condition. Based on the second processing unit allocation strategy, each reduced simple element in the target partial product array that satisfies the preset row number condition is assigned a corresponding adder.

5. The method according to claim 4, characterized in that, The method based on the preset reduction tree structure divides the target partial product array into multiple reduced simple elements and multiple residual summation terms, including: Based on the preset reduction tree structure and the number of array rows of the target partial product array, target summation terms that satisfy the preset reduction element partitioning conditions are determined, the target partial product array is divided into multiple reduction elements, and the type of each reduction element is determined; summation terms that do not satisfy the preset reduction element partitioning conditions are taken as the remaining summation terms; wherein, the type of the reduction element includes a first reduction element type and a second reduction element type; The allocation strategy based on the first processing unit, which assigns corresponding adders to each of the reduced simple elements, includes: For each reduction element, based on the correspondence between the type of the reduction element and the type of adder, the target adder type corresponding to the type of the reduction element is determined, and an adder of the target adder type is assigned to the reduction element.

6. The method according to claim 1, characterized in that, The construction of the target multiplier based on the adders corresponding to each of the reduced simple elements includes: The first program corresponding to the preset encoding algorithm is mapped to the first standard unit contained in the target standard unit library to obtain the first processing unit; the preset encoding algorithm is the NR4SD encoding and decoding method; The second program corresponding to the Boolean function operation is mapped to the second standard unit contained in the target standard unit library to obtain the second processing unit; The target multiplier is constructed based on the adders corresponding to each of the reduced simple elements in the first processing unit, the second processing unit, and the target standard unit library.

7. A device for constructing a multiplier, characterized in that, The device includes: The first construction module is used to construct a partial product array based on the first upper limit number of bits of the first sample operation data, the second upper limit number of bits of the second sample operation data, and a preset encoding algorithm; An optimization module is used to perform row optimization processing on the partial product array based on a preset row optimization strategy and through Boolean function operations to obtain a target partial product array; the number of rows of the target partial product array is less than the number of rows of the partial product array; iterative summation is performed through adders corresponding to each reduced simple element until the number of rows of the obtained target partial product array does not exceed two. The determination module is used to determine multiple reduced simple elements corresponding to the target partial product array based on a preset reduced simple tree structure, and to determine the adder corresponding to each reduced simple element; The second construction module is used to construct a target multiplier based on the adders corresponding to each of the reduced simple elements; Specifically, for any column in the target partial product array, if the number of items in the column is greater than or equal to a first preset number, the items contained in the column are divided according to the first preset data and full adders are assigned to perform addition calculations; if the number of remaining items in the column is equal to a second preset number, the remaining items are assigned to half adders for addition calculations; if the number of remaining items in the column is equal to a third preset number, no processing is performed.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Parallel multiplier and working method thereof

    CN112860219A