Multiplier, data processing method, device and chip

By introducing a judgment circuit, data register, correction encoding circuit and correction compression circuit into the multiplier, the problem of high power consumption of traditional multipliers when processing sparse data is solved, achieving more efficient multiplication operations and lower power consumption.

CN113031915BActive Publication Date: 2024-10-15SHANGHAI CAMBRICON INFORMATION TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN201911349756.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-12-24
Publication Date
2024-10-15
Estimated Expiration
2040-04-03

AI Technical Summary

Technical Problem

Traditional multipliers require complex sparse number selection circuits when processing sparse data, resulting in high power consumption.

Method used

A multiplier is designed, including a judgment circuit, a data register, a correction encoding circuit and a correction compression circuit. The judgment circuit determines whether the data is all 0 data, reducing invalid storage and processing. The correction encoding circuit and the correction compression circuit are used for data encoding. and accumulation to reduce power consumption.

Benefits of technology

It effectively reduces the power consumption and occupied area of ​​the multiplier, and improves the processing efficiency, especially the multiplication capability when processing a variety of different bit width data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113031915B_ABST
    Figure CN113031915B_ABST
Patent Text Reader

Abstract

The present application provides a multiplier, a data processing method, a device and a chip. The multiplier includes: a judgment circuit, a data register, a correction coding circuit and a correction compression circuit; the output end of the judgment circuit is connected to the input end of the data register, the output end of the data register is connected to the input end of the correction coding circuit, and the output end of the correction coding circuit is connected to the input end of the correction compression circuit; the multiplier can determine whether the received data is all-0 data through the judgment circuit. If it is all-0 data, the data does not need to be stored in the data register to reduce the number of flips of the data register, and the multiplier does not need a complex sparse number selection circuit, and only needs to obtain valid data through the judgment circuit, so that the multiplier only needs to process valid data, reducing the amount of invalid operations, thereby reducing the 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 computer technology, and in particular to a multiplier, a data processing method, an apparatus, and a chip. Background Art

[0002] With the continuous development of digital electronics technology, the rapid development of various artificial intelligence (AI) chips has placed increasingly higher demands on high-performance deep learning processors. Deep learning algorithms, as one of the most widely used algorithms in intelligent chips, typically involve multiplication operations, and performing multiplication using a multiplier is a common operation in deep learning algorithms.

[0003] In traditional techniques, multiplication operations involving sparse data are typically performed by filtering zero-valued data in sparse neural networks. Due to the non-uniformity of sparse data, traditional multipliers incorporate complex sparse selection circuits to organize the scattered sparse data. However, the presence of these complex sparse selection circuits results in high power consumption for the multiplier. Summary of the Invention

[0004] Therefore, it is necessary to provide a multiplier, a data processing method, an apparatus, and a chip to address the aforementioned technical problems.

[0005] This application provides a multiplier, which includes: a judgment circuit, a data register, a correction encoding circuit, and a correction compression circuit; the output terminal of the judgment circuit is connected to the input terminal of the data register, the output terminal of the data register is connected to the input terminal of the correction encoding circuit, and the output terminal of the correction encoding circuit is connected to the input terminal of the correction compression circuit.

[0006] The judgment circuit is used to determine whether the received data contains all zeros, and outputs a data gating signal according to the judgment result. The data register is used to select the data to receive according to the data gating signal and store the data.

[0007] In one embodiment, the correction encoding circuit is used to encode the data stored in the data register to obtain a partial product after sign bit extension, and to obtain a target encoded partial product based on the partial product after sign bit extension. The correction compression circuit is used to accumulate the target encoded partial product to obtain the multiplication result.

[0008] The correction encoding circuit includes a first input terminal for receiving an input function selection mode signal; the correction compression circuit includes a first input terminal for receiving the input function selection mode signal; the function selection mode signal is used to determine the current data bit width that the multiplier can process.

[0009] In one embodiment, the judgment circuit includes: a data input port, a logic signal output port, and a data output port. The data input port is used to receive data for multiplication operations, the logic signal output port is used to output the data gating signal obtained by the judgment circuit based on the judgment result, and the data output port is used to output the data.

[0010] In one embodiment, the corrected encoding circuit includes: a low-order Booth encoding unit, a low-order logic operation unit, a low-order partial product acquisition unit, a selector, a high-order Booth encoding unit, a high-order logic operation unit, a high-order partial product acquisition unit, a low-order selector group unit, and a high-order selector group unit; the first output terminal of the low-order Booth encoding unit is connected to the input terminal of the selector, the second output terminal of the low-order Booth encoding unit is connected to the input terminal of the low-order logic operation unit, the output terminal of the low-order logic operation unit is connected to the first input terminal of the low-order partial product acquisition unit, the output terminal of the selector is connected to the first input terminal of the high-order Booth encoding unit, the output terminal of the high-order Booth encoding unit is connected to the input terminal of the high-order logic operation unit, the output terminal of the high-order logic operation unit is connected to the first input terminal of the high-order partial product acquisition unit, the output terminal of the low-order selector group unit is connected to the second input terminal of the low-order partial product acquisition unit, and the output terminal of the high-order selector group unit is connected to the second input terminal of the high-order partial product acquisition unit.

[0011] The low-order Booth encoding unit is used to perform Booth encoding on the low-order data in the first data input to the data register to obtain a low-order target code. The low-order logic operation unit is used to perform an AND logic operation on the low-order target code to obtain a first logic operation, and determine whether to input the low-order target code to the low-order partial product acquisition unit based on the result of the first logic operation. The low-order partial product acquisition unit is used to obtain the low-order partial product after sign bit extension based on the low-order target code and the second data input to the data register. The selector is used to select the padding value when the high-order data in the first data is processed by Booth encoding. The high-order Booth encoding unit is used to... The high-order data in the first data and the padded value are processed by Booz coding to obtain the high-order target code. The high-order logic operation unit is used to perform an AND logic operation on the high-order target code to obtain a second logic operation, and to determine whether to input the high-order target code to the high-order partial product acquisition unit based on the result of the second logic operation. The high-order partial product acquisition unit is used to obtain the high-order partial product after sign bit extension based on the high-order target code and the second data input from the data register. The low-order selector group unit is used to select the value in the low-order partial product after sign bit extension, and the high-order selector group unit is used to select the value in the high-order partial product after sign bit extension.

[0012] In one embodiment, the low-order Booth coding unit includes: a low-order data input port, a low-order target code output port, and a gating value output port; the low-order data input port is used to receive low-order data in the first data, the low-order target code output port is used to output the low-order target code obtained after Booth coding of the low-order data, and the gating value output port is used to output the highest-order value in the low-order data and input it to the high-order Booth coding unit.

[0013] In one embodiment, the low-order logic operation unit includes a low-order target code input port and a low-order target code output port. The low-order target code input port is used to receive the low-order target code output by the low-order logic operation unit, and the low-order target code output port is used to output a valid low-order target code.

[0014] In one embodiment, the low-order partial product acquisition unit includes: a low-order target code input port, a first strobe value input port, a mode signal input port, a data input port, and a low-order partial product output port; the low-order target code input port is used to receive the low-order target code output by the low-order logic operation unit, the first strobe value input port is used to receive the value contained in the low-order partial product after the sign bit is extended and output by the low-order selector group unit after stroking, the mode signal input port is used to receive the function selection mode signal, the data input port is used to receive the second data, and the low-order partial product output port is used to output the target low-order code partial product.

[0015] In one embodiment, the selector includes: a mode signal input port, a first strobe value input port, a second strobe value input port, and a strobe value output port; the mode signal input port is used to receive the function selection mode signal, the first strobe value input port is used to receive a first strobe value, the second strobe value input port is used to receive a second strobe value, and the strobe value output port is used to output the first strobe value or the second strobe value obtained after strobing.

[0016] In one embodiment, the high-order Booth coding unit includes: a high-order data input port, a high-order target code output port, and a gating value input port; the high-order data input port is used to receive the high-order data in the first data, the high-order target code output port is used to output the high-order target code obtained after Booth coding of the high-order data, and the gating value input port is used to receive the highest bit value or the value 0 in the low-order data output by the selector.

[0017] In one embodiment, the high-order logic operation unit includes a high-order target code input port and a high-order target code output port. The high-order target code input port is used to receive the high-order target code output by the high-order logic operation unit, and the high-order target code output port is used to output a valid high-order target code.

[0018] In one embodiment, the high-order partial product acquisition unit includes: a high-order target code input port, a second strobe value input port, a mode signal input port, a data input port, and a high-order partial product output port; the high-order target code input port is used to receive the high-order target code output by the high-order logic operation unit, the second strobe value input port is used to receive the value contained in the high-order partial product after the sign bit is extended and output by the high-order selector group unit after stroking, the mode signal input port is used to receive the function selection mode signal, the data input port is used to receive the second data, and the high-order partial product output port is used to output the target high-order code partial product.

[0019] In one embodiment, the low-bit selector group unit includes a low-bit selector for selecting the value in the low-bit partial product after the sign bit extension.

[0020] In one embodiment, the high-bit selector group unit includes a high-bit selector for selecting the value in the high-bit partial product after the sign bit extension.

[0021] In one embodiment, the modified compression circuit includes: a modified Wallace tree group unit and an accumulation circuit; the output terminal of the modified Wallace tree group unit is connected to the input terminal of the accumulation circuit; the modified Wallace tree group unit is used to accumulate the values ​​of each column in the target encoded partial product obtained by operating on data with different bit widths to obtain the accumulation operation result, and the accumulation circuit is used to accumulate the real-time accumulation operation result to obtain the multiplication operation result.

[0022] In one embodiment, the modified Wallace tree unit includes: a low-order Wallace tree subunit, a selector, and a high-order Wallace tree subunit. The output of the low-order Wallace tree subunit is connected to the input of the selector, and the output of the selector is connected to the input of the high-order Wallace tree subunit. The low-order Wallace tree subunit is used to perform an accumulation operation on each column of values ​​in the target encoded partial product. The selector is used to select the carry input signal received by the high-order Wallace tree subunit. The high-order Wallace tree subunit is used to perform an accumulation operation on each column of values ​​in the target encoded partial product.

[0023] In one embodiment, the accumulation circuit includes an adder, which is used to perform an addition operation on the accumulation result to obtain the multiplication result.

[0024] In one embodiment, the adder includes: a carry signal input port, a sum signal input port, and a result output port; the carry signal input port is used to receive a carry signal, the sum signal input port is used to receive a sum signal, and the result output port is used to output the multiplication result obtained by accumulating the carry signal and the sum signal.

[0025] This embodiment provides a multiplier that uses a judgment circuit to first determine whether the received data is all zeros. Based on the judgment result, it outputs a data gating signal, and the data register can control the storage of data according to the data gating signal. Then, the data stored in the data register is encoded by a correction encoding circuit to obtain a partial product after sign bit extension. The target encoded partial product is obtained based on the partial product after sign bit extension, and the target encoded partial product is accumulated by a correction compression circuit to obtain the multiplication result. The multiplier can determine whether the received data is all zeros through the judgment circuit. If it is all zeros, it does not need to store the data in the data register, thereby reducing the number of data register flips. Furthermore, this multiplier does not require a complex sparse number selection circuit; it only needs to obtain valid data through the judgment circuit. This allows the multiplier to process only valid data, reducing the amount of invalid operations and thus reducing the power consumption of the multiplier.

[0026] This application provides a data processing method, the method comprising:

[0027] Receive the data to be processed and a function selection mode signal, wherein the function selection mode signal is used to indicate the current data bit width that the multiplier can process;

[0028] When the data to be processed is non-zero, the data to be processed is stored in the data register;

[0029] The signal to be encoded is selected based on the function selection mode signal;

[0030] Encoding processing is performed on the signal to be encoded and the data to be processed to obtain the target encoded partial product;

[0031] The product of the target encoded parts is accumulated to obtain the multiplication result.

[0032] In one embodiment, when the data to be processed is all zeros, the method further includes: using the data 0 as the result of the multiplication operation.

[0033] In one embodiment, selecting the signal to be encoded according to the function selection mode signal includes: selecting a value of 0 as the signal to be encoded according to the function selection mode signal, or selecting the highest bit value corresponding to the low-order data in the data to be processed as the signal to be encoded.

[0034] In one embodiment, the step of performing encoding processing based on the signal to be encoded and the data to be processed to obtain the target encoded partial product includes:

[0035] Based on the signal to be encoded and the data to be processed, the data to be encoded is obtained;

[0036] The data to be encoded is subjected to Booth coding to obtain the target code;

[0037] The target code partial product is obtained based on the target code and the data to be processed.

[0038] In one embodiment, obtaining the data to be encoded based on the signal to be encoded and the data to be processed includes:

[0039] The data to be processed is padded to obtain padded data;

[0040] The data to be encoded is obtained based on the signal to be encoded and the padded data.

[0041] In one embodiment, obtaining the target encoded partial product based on the target code and the data to be processed includes:

[0042] Based on the target encoding and the data to be processed, the partial product after sign bit extension is obtained;

[0043] The target encoded partial product is obtained by calculating the partial product after the sign bit extension.

[0044] In one embodiment, obtaining the target encoded partial product based on the partial product after sign bit extension includes: deleting all partial products with data of 0 from the partial products after sign bit extension to obtain the target encoded partial product.

[0045] In one embodiment, the target coded partial product includes a target low-order coded partial product and a target high-order coded partial product; the step of accumulating the target coded partial products to obtain the multiplication result includes:

[0046] The accumulation operation result is obtained by accumulating the product of the low-order code portion of the target and the product of the high-order code portion of the target by modifying the Wallace tree group unit;

[0047] The accumulation operation result is accumulated by the accumulation circuit to obtain the multiplication operation result.

[0048] In one embodiment, the step of accumulating the target low-order encoded partial product and the target high-order encoded partial product by modifying the Wallace tree group unit to obtain the accumulation result includes:

[0049] The intermediate calculation result is obtained by accumulating the column values ​​in the partial product of all target codes through the low-order Wallace tree sub-unit;

[0050] The intermediate calculation result is selected by a selector to obtain a carry selection signal;

[0051] The accumulation result is obtained by accumulating the values ​​in the column products of the carry gating signal and the partial products of all target codes through the high-order Wallace tree subunit.

[0052] This embodiment provides a data processing method that can process only valid data to reduce the number of valid partial products, thereby reducing the amount of invalid operations and lowering the power consumption of the multiplier.

[0053] This application provides a machine learning computing device, which includes one or more multipliers. The machine learning computing device is used to obtain data to be computed and control information from other processing devices in the machine learning computing device other than the multipliers, and to perform a specified machine learning operation, and to transmit the execution result to other processing devices in the machine learning computing device other than the multipliers through an I / O interface.

[0054] When the machine learning computing device includes multiple multipliers, the multiple multipliers can be linked and transmit data through a preset structure;

[0055] The multiple multipliers are interconnected and transmit data via a PCIe bus to support larger-scale machine learning operations; the multiple multipliers share the same control system or have their own control systems; the multiple multipliers share memory or have their own memory; the interconnection of the multiple multipliers is in any interconnection topology.

[0056] This application provides a combined processing device, which includes a machine learning processing device as described above, a general interconnect interface, and other processing devices in the combined processing device besides the machine learning computing device. The machine learning computing device interacts with the other processing devices in the combined processing device to jointly complete user-specified operations. The combined processing device may further include a storage device, which is connected to the machine learning computing device and the other processing devices in the combined processing device, respectively, for storing data from the machine learning computing device and the other processing devices in the combined processing device.

[0057] This application provides a neural network chip, which includes the multiplier, the machine learning computing device, or the combined processing device described above.

[0058] This application provides a neural network chip packaging structure, which includes the neural network chip described above.

[0059] This application provides a board that includes the neural network chip packaging structure described above.

[0060] This application provides an electronic device that includes the neural network chip or the circuit board described above.

[0061] An embodiment of this application provides a chip including at least one multiplier as described in any of the preceding claims.

[0062] An electronic device provided in this application includes the chip as described above. Attached Figure Description

[0063] Figure 1 A schematic diagram of the structure of a multiplier provided in one embodiment;

[0064] Figure 2 A schematic diagram of the specific circuit structure of the judgment circuit and data register in a multiplier provided for another embodiment;

[0065] Figure 3 A schematic diagram of the specific structure of the correction encoding circuit in the multiplier provided for another embodiment;

[0066] Figure 4 A detailed circuit diagram of the correction compression circuit in a multiplier provided for another embodiment;

[0067] Figure 5A detailed circuit diagram of the 8-bit data operation correction compression circuit is provided for another embodiment;

[0068] Figure 6 A schematic flowchart of a data processing method provided in one embodiment;

[0069] Figure 7 A schematic diagram illustrating the specific process of obtaining the target encoded partial product is provided for another embodiment;

[0070] Figure 8 A flowchart illustrating the process of obtaining the result of a multiplication operation, provided for another embodiment;

[0071] Figure 9 A schematic diagram illustrating the specific process for obtaining the cumulative calculation result is provided for another embodiment;

[0072] Figure 10 A structural diagram of a combined processing apparatus provided in one embodiment;

[0073] Figure 11 A structural diagram of another combined processing apparatus provided in one embodiment;

[0074] Figure 12 This is a schematic diagram of the structure of a circuit board provided in one embodiment. Detailed Implementation

[0075] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.

[0076] The multiplier provided in this application can be used in AI chips, Field-Programmable Gate Array (FPGA) chips, or other hardware circuit devices for multiplication operations. Its specific structural diagram is shown below. Figure 1 As shown.

[0077] like Figure 1 As shown, Figure 1 A structural diagram of a multiplier provided for one embodiment. For example... Figure 1As shown, the multiplier includes: a judgment circuit 11, a data register 12, a correction encoding circuit 13, and a correction compression circuit 14. The output of the judgment circuit 11 is connected to the input of the data register 12, the output of the data register 12 is connected to the input of the correction encoding circuit 13, and the output of the correction encoding circuit 13 is connected to the input of the correction compression circuit 14. The judgment circuit 11 determines whether the received data contains all zeros and outputs a data gating signal based on the determination result. The data register 12 selects and stores the received data based on the data gating signal. Optionally, the correction encoding circuit 13 encodes the data stored in the data register 12 to obtain a partial product with sign bit extension, and obtains a target encoded partial product based on the partial product with sign bit extension. The correction compression circuit 14 accumulates the target encoded partial product to obtain the multiplication result.

[0078] Specifically, the input port of the multiplier can receive N-bit data, where N can be greater than 0. Furthermore, the multiplier can simultaneously receive multiple operational data sets, which can be the data that the judgment circuit 11 needs to judge. Optionally, the judgment circuit 11 can simultaneously receive the multiplier and multiplicand in the multiplication operation; both the multiplier and multiplicand can be fixed-point numbers. Optionally, the judgment circuit 11 can determine whether the received data contains all zeros, and then output a data gating signal based on the judgment result. That is, if the multiplier and / or multiplicand in the multiplication operation are all zeros, the data gating signal output by the judgment circuit 11 can be a low-level signal 0; if both the multiplier and multiplicand in the multiplication operation are non-zero, the data gating signal output by the judgment circuit 11 can be a high-level signal 0. This data gating signal can include a high-level signal 1 and a low-level signal 0. Optionally, the judgment circuit 11 can judge each set of multipliers and multiplicands to obtain a corresponding data gating signal.

[0079] It should be noted that the aforementioned data register 12 can receive the data gating signal output by the judgment circuit 11. Optionally, if the data register 12 receives a low-level data gating signal, the data register 12 can remain closed and does not need to receive data for storage in subsequent calculations; if the data register 12 receives a high-level data gating signal, the data register 12 can remain open and needs to receive data for storage in subsequent calculations. Optionally, the data register 12 can select whether to receive the corresponding input multiplier and multiplicand based on each data gating signal.

[0080] It is understood that the aforementioned correction encoding circuit 13 may include multiple data processing units with different functions, and the data received by the correction encoding circuit 13 can be used as the multiplier or the multiplicand in a multiplication operation. Optionally, the data can be a fixed-point number. Optionally, the correction encoding circuit 13 can receive data with various bit widths, that is, the multiplier provided in this embodiment can handle multiplication operations of data with various bit widths. However, in the same multiplication operation, the multiplier and multiplicand received by the correction encoding circuit 13 can be data with the same bit width, that is, the bit widths of the multiplier and multiplicand are equal. For example, the multiplier provided in this embodiment can handle 8-bit * 8-bit data multiplication operations, 16-bit * 16-bit multiplication operations, 32-bit * 32-bit data multiplication operations, and can also handle 64-bit * 64-bit data multiplication operations, and this embodiment does not impose any limitations on this.

[0081] Optionally, the correction encoding circuit 13 can perform binary encoding processing on the received data, which is equivalent to performing binary encoding processing on the received multiplier and obtaining a partial product with the sign bit extended based on the received multiplicand. The bit width of the partial product with the sign bit extended can be equal to twice the current data bit width that the multiplier can process. For example, if the correction encoding circuit 13 receives 16-bit data, and the multiplier is currently processing 8-bit data for multiplication, the correction encoding circuit 13 needs to divide the 16-bit data into two groups of data, the high 8 bits and the low 8 bits, and perform multiplication operations separately. In this case, the bit width of the obtained partial product with the sign bit extended can be equal to twice the current data bit width that the multiplier can process. If the multiplier is currently processing 16-bit data for multiplication, the correction encoding circuit 13 needs to perform the operation on the entire 16-bit data. In this case, the bit width of the obtained partial product with the sign bit extended can be equal to twice the current data bit width that the multiplier can process.

[0082] Optionally, the correction encoding circuit 13 includes a first input terminal for receiving an input function selection mode signal; the correction compression circuit 14 includes a first input terminal for receiving the input function selection mode signal. Optionally, the function selection mode signal is used to determine the data bit width that the multiplier can currently process.

[0083] It should be noted that there can be multiple function selection mode signals, and different function selection mode signals correspond to multiplication operations with different bit widths that the multiplier can currently process. Optionally, during the same multiplication operation, the function selection mode signals received by the correction encoding circuit 13 and the correction compression circuit 14 can be equal.

[0084] For example, if the correction encoding circuit 13 and the correction compression circuit 14 can receive multiple function selection mode signals, taking three function selection mode signals (i.e., mode signals) as examples, the mode signals can be represented as 00, 01 and 10 respectively. Then, mode = 00 can represent that the current data bit width that the multiplier can process is 8, mode = 01 can represent that the current data bit width that the multiplier can process is 16, and mode = 10 can represent that the current data bit width that the multiplier can process is 32. In addition, mode = 00 can also represent that the current data bit width that the multiplier can process is 16, mode = 01 can also represent that the current data bit width that the multiplier can process is 32, and mode = 10 can represent that the current data bit width that the multiplier can process is 8.

[0085] The multiplier provided in this embodiment can first determine whether the received data is all zeros through a judgment circuit. Based on the judgment result, it outputs a data gating signal, and the data register can control the storage of data according to the data gating signal. Then, the data stored in the data register is encoded by a correction encoding circuit to obtain a partial product after sign bit extension. The target encoded partial product is obtained based on the partial product after sign bit extension, and the target encoded partial product is accumulated by a correction compression circuit to obtain the multiplication result. The multiplier can determine whether the received data is all zeros through the judgment circuit. If it is all zeros, it does not need to store the data in the data register, thereby reducing the number of data register flips. Furthermore, this multiplier does not require complex sparse number selection circuits. It only needs to obtain valid data through the judgment circuit, so that the multiplier only needs to process valid data, reducing the amount of invalid operations and thus reducing the power consumption of the multiplier. At the same time, while ensuring the accuracy of the multiplication result, the multiplier can perform multiplication operations on data with various bit widths, effectively reducing the area occupied by the multiplier on the AI ​​chip.

[0086] Figure 2 A schematic diagram of the specific circuit structure of the judgment circuit and data register in the multiplier provided for another embodiment is shown below. Figure 2 As shown, the judgment circuit 11 includes a data input port 111, a logic signal output port 112, and a data output port 113. The data input port 111 is used to receive data for multiplication operations, the logic signal output port 112 is used to output the data gating signal obtained by the judgment circuit 11 according to the judgment result, and the data output port 113 is used to output the data.

[0087] Specifically, the judgment circuit 11 can simultaneously receive multiple data through the data input port 111, which may include the multiplier and multiplicand in a multiplication operation. Optionally, the judgment circuit 11 can determine whether any of the received multiplier or multiplicand is all zeros. Optionally, if the judgment circuit 11 determines that the received data contains all zeros, the logic signal output port 112 of the judgment circuit 11 can output a low-level signal 0 as a data gating signal; if the judgment circuit 11 determines that all the received data are non-zero, the logic signal output port 112 of the judgment circuit 11 can output a high-level signal 1 as a data gating signal. Optionally, after performing the judgment process on the received data, the judgment circuit 11 can output the original received data through the data output port 113.

[0088] The multiplier provided in this embodiment can first determine whether the received data is all zeros through a judgment circuit. Based on the judgment result, it outputs a data gating signal, which is then input into the data register. The data register controls the reception of all zeros according to the data gating signal, thereby reducing the number of data register toggles. Furthermore, this multiplier does not require a complex sparse number selection circuit; it only needs to obtain valid data through the judgment circuit. This allows the multiplier to process only valid data, reducing the amount of invalid operations and thus lowering the power consumption of the multiplier.

[0089] As one example, see below. Figure 2 As shown, the data register 12 includes a gating signal input port 121, a data input port 122, and a computational data output port 123. The gating signal input port 121 is used to receive the data gating signal output by the judgment circuit 11. The data input port 122 is used to select to receive the first data and the second data output by the judgment circuit 11 according to the data gating signal. The computational data output port 123 is used to output the first data and the second data received by the data register 12.

[0090] Specifically, data register 12 may include a first register unit for storing the multiplication operation and a second register unit for storing the multiplicand in the multiplication operation. Optionally, data register 12 can receive each data gating signal output by judgment circuit 11 through gating signal input port 121, and can input the received data gating signal to the first register unit or the second register unit. Optionally, data register 12 can determine whether to receive the corresponding multiplier and multiplicand based on the received data gating signal, and store the received data in the first register unit and the second register unit. Optionally, if the data gating signal is a high-level signal, data register 12 can receive and store the data corresponding to the data gating signal through data input port 122, and data register 12 can be in the open state; if the data gating signal is a low-level signal, data register 12 can be in the closed state, and the data corresponding to the data gating signal will not be stored by data register 12.

[0091] It should be noted that the multiplier can perform multiplication operations on the data stored in the data register 12, and input the stored data to the correction encoding circuit 13 for subsequent operations through the operation data output port 123 in the data register 12. Optionally, one of the first and second data mentioned above can be the multiplier, and the other data can be the multiplicand.

[0092] In addition, if only one of the multiplier and multiplicand in the multiplication operation is all zero, or if both of them are all zero, then data register 12 can remain closed, and in this case, it is not necessary to store the multiplier and multiplicand; if both the multiplier and multiplicand in the multiplication operation are non-zero, then data register 12 can remain open to store the multiplier and multiplicand.

[0093] The multiplier provided in this embodiment can control the closed state of the data register by judging the data gating signal output by the circuit. When the operation data processed by the multiplier contains all zeros, the number of data register toggles can be reduced. Furthermore, this multiplier does not require complex sparse number selection circuits, but only needs to obtain valid data through the judgment circuit. This allows the multiplier to process only valid data, reducing the amount of invalid operations and thus reducing the power consumption of the multiplier, thereby reducing the power consumption of the AI ​​chip.

[0094] Figure 3 A schematic diagram of the specific structure of the correction encoding circuit 13 in the multiplier provided in another embodiment is shown below. Figure 3As shown, the correction encoding circuit 13 includes: a low-order Booth encoding unit 131, a low-order logic operation unit 132, a low-order partial product acquisition unit 133, a selector 134, a high-order Booth encoding unit 135, a high-order logic operation unit 136, a high-order partial product acquisition unit 137, a low-order selector group unit 138, and a high-order selector group unit 139; the first output terminal of the low-order Booth encoding unit 131 is connected to the input terminal of the selector 134, the second output terminal of the low-order Booth encoding unit 131 is connected to the input terminal of the low-order logic operation unit 132, and the output terminal of the low-order logic operation unit 132 is connected to the input terminal of the selector 134. The first input terminal of the low-order partial product acquisition unit 133 is connected to the first input terminal of the selector 134, the output terminal of the high-order Booth encoding unit 135 is connected to the input terminal of the high-order logic operation unit 136, the output terminal of the high-order logic operation unit 136 is connected to the first input terminal of the high-order partial product acquisition unit 137, the output terminal of the low-order selector group unit 138 is connected to the second input terminal of the low-order partial product acquisition unit 133, and the output terminal of the high-order selector group unit 139 is connected to the second input terminal of the high-order partial product acquisition unit 137.

[0095] The low-order Booth encoding unit 131 is used to perform Booth encoding on the low-order data in the first data input to the data register 12 to obtain the low-order target code. The low-order logic operation unit 132 is used to perform an AND logic operation on the low-order target code to obtain a first logic operation, and determine whether to input the low-order target code to the low-order partial product acquisition unit 133 based on the result of the first logic operation. The low-order partial product acquisition unit 133 is used to obtain the low-order partial product after sign bit extension based on the low-order target code and the second data input to the data register 12. The selector 134 is used to select the padding value when the high-order data in the first data is processed by Booth encoding. The high-order Booth encoding unit 135... The high-order target code is obtained by performing Busch encoding on the high-order data and the padding value in the first data. The high-order logic operation unit 136 is used to perform AND logic operation on the high-order target code to obtain a second logic operation, and determine whether to input the high-order target code to the high-order partial product acquisition unit 137 based on the result of the second logic operation. The high-order partial product acquisition unit 137 is used to obtain the sign-bit extended high-order partial product based on the high-order target code and the second data input from the data register 12. The low-order selector group unit 138 is used to select the value in the sign-bit extended low-order partial product. The high-order selector group unit 139 is used to select the value in the sign-bit extended high-order partial product.

[0096] Specifically, the aforementioned correction encoding circuit 13 can receive first data and second data. The first data can be the multiplier in a multiplication operation, and the second data can be the multiplicand in a multiplication operation. Optionally, the correction encoding circuit 13 can perform Booth encoding on the multiplier to obtain a target code, and obtain a partial product of the target code based on the target code and the received multiplicand. Before the Booth encoding is performed on the low-order bits of the first data, the low-order Booth encoding unit 131 can automatically perform a padding process on the low-order bits of the first data received by the correction encoding circuit 13, and then perform Booth encoding on the padded low-order bits to obtain the low-order target code. Optionally, if the bit width of the multiplier received by the correction encoding circuit 13 is N, the low-order data can be the lower N / 2 bits of data, and the padding process can be characterized as padding a 0 bit at the lower bit position of the lowest bit value of the first data (i.e., the low-order data in the first data). For example, if the multiplier can currently handle 8-bit * 8-bit fixed-point multiplication, and the multiplier is "y7y6y5y4y3y2y1y0", then before performing Booth encoding, the low-order Booth encoding unit 131 can automatically pad the multiplier, converting it into padded data "y7y6y5y4y3y2y1y00". Optionally, the number of low-order target codes can be equal to half the low-order data width, and the number of low-order target codes can be equal to the number of low-order partial products obtained after sign bit extension of the corresponding low-order data. It should be noted that regardless of whether the bit width of the data that the multiplier can currently process is the same as the bit width of the data received by the multiplier, the low-order Booth encoding unit 131 needs to perform a padding process on the low-order data in the first data when implementing Booth encoding. Optionally, the bit width of the low-order partial product after sign bit extension can be equal to twice the bit width of the data that the multiplier can currently process.

[0097] Similarly, if the multiplier can handle N-bit data operations and 2N-bit data operations, and the multiplier determines that it can currently handle N-bit data operations based on the received function selection mode signal, then the multiplier can perform an AND operation on the received low-bit target code and the corresponding high-bit target code obtained when performing 2N-bit data multiplication, through the high-order logic operation unit 136, to obtain the second logic operation result; if the second logic operation result is a low-level signal, then the high-order logic operation unit 136 can input the received high-order target code to the high-order partial product acquisition unit 137. Optionally, if the multiplier determines that it can currently handle 2N-bit data operations based on the received function selection mode signal, then the multiplier can perform an AND operation on the received high-order target code and the corresponding high-order target code obtained when performing N-bit data multiplication, through the high-order logic operation unit 136, to obtain the second logic operation result; if the second logic operation result is a high-level signal, then the high-order logic operation unit 136 can input the received high-order target code to the high-order partial product acquisition unit 137.

[0098] Simultaneously, the high-order Booth coding unit 135 can perform Booth coding on the high-order data in the first data received by the correction coding circuit 13 to obtain the high-order target code. However, before the high-order data undergoes Booth coding, a gating value needs to be obtained through the selector 134. This gating value can be used as the padding value when the high-order data undergoes Booth coding. Then, the high-order data and the padding value are combined to obtain the padded high-order data. The high-order Booth coding unit 135 then performs Booth coding on the padded high-order data to obtain the high-order target code. Optionally, the selector 134 can be a two-way selector, and the two gating values ​​can include the value 0 and the highest-order value corresponding to the low-order data in the first data. For example, if a multiplier receives data with a bit width of 2N and can currently process N-bit data operations, the multiplier can divide the received 2N-bit data into high N bits and low N bits for separate processing. The low-bit Booth encoding unit 131 in the multiplier can automatically pad the low-bit data, and the selector 134 in the multiplier can select the value 0 as the padding value when performing Booth encoding on the high-bit data of the multiplier. If the multiplier can currently process 2N-bit data operations, the low-bit Booth encoding unit 131 in the multiplier can automatically pad the low-bit data, and the selector 134 in the multiplier can select the highest bit value in the low-bit data as the padding value when performing Booth encoding on the high-bit data. In this case, it is equivalent to the multiplier treating the received 2N-bit data as a whole for Booth encoding. Optionally, if the multiplier bit width received by the correction encoding circuit 13 is N, the high-bit data can be high N / 2 bits. In this embodiment, selector 134 can determine the padding value when performing Booth coding on the selected high-order data based on the received different function selection mode signals. Optionally, the bit width of the high-order partial product after the sign bit extension can be equal to twice the current data bit width that the multiplier can process. Optionally, the bit width of the high-order target code can be equal to the bit width of the low-order target code, and can be equal to half the first data bit width.

[0099] Understandably, if the data width received by the multiplier can be 2N, and it can currently process N-bit data multiplication operations, then the low-bit partial product acquisition unit 133 in the multiplier can obtain the partial product after sign bit extension corresponding to the low N / 2 bits of data based on the low-bit target code and the second data received by the correction encoding circuit 13; the aforementioned low-bit selector group unit 138 can select the value in the low-bit partial product after sign bit extension; then, the partial product after sign bit extension is combined with the value in the selected low-bit partial product after sign bit extension to obtain the low-bit partial product after sign bit extension. Optionally, the high-bit partial product acquisition unit 137 can obtain the partial product after sign bit extension corresponding to the high N / 2 bits of data based on the high-bit target code and the second data received by the correction encoding circuit 13; the high-bit selector group unit 139 can select the value in the high-bit partial product after sign bit extension; then, the partial product after sign bit extension is combined with the value in the selected high-bit partial product after sign bit extension to obtain the high-bit partial product after sign bit extension. Optionally, during the Booth coding process, the number of low-order target codes obtained can be equal to the number of high-order target codes obtained, or equal to the number of low-order partial products after sign bit extension corresponding to the low N / 2 bits of data, or the number of high-order partial products after sign bit extension corresponding to the high N / 2 bits of data. Optionally, the correction coding circuit 13 can include N / 4 low-order partial product acquisition units 133 and N / 4 high-order partial product acquisition units 137. Optionally, each low-order partial product acquisition unit 133 and each high-order partial product acquisition unit 137 can include 2N value generation subunits, each of which can acquire one bit of the partial product after sign bit extension. Simultaneously, the low-order partial product acquisition unit 133 can determine the corresponding target low-order code partial product based on the obtained low-order partial product after sign bit extension; the high-order partial product acquisition unit 137 can determine the corresponding target high-order code partial product based on the obtained high-order partial product after sign bit extension.

[0100] It should be noted that the aforementioned low-bit selector group unit 138 can select, based on the received function selection mode signal, a portion of the value in the low-bit partial product after sign bit extension, whether it is the value in the partial product after sign bit extension obtained from N-bit data multiplication or the value in the partial product after sign bit extension obtained from 2N-bit data multiplication; similarly, the high-bit selector group unit 139 can select, based on the received function selection mode signal, a portion of the value in the high-bit partial product after sign bit extension, whether it is the value in the partial product after sign bit extension obtained from N-bit data multiplication or the value in the partial product after sign bit extension obtained from 2N-bit data multiplication.

[0101] This embodiment provides a multiplier in which a correction encoding circuit performs Boozing encoding on the data to obtain a target code. Then, the low-order logic operation unit and the high-order logic operation unit can perform AND logic operations on the target code. Based on the result of the logic operation, it is determined whether to input the target code to other circuits for processing to obtain a valid partial product. Then, the correction compression circuit accumulates the valid partial products to obtain the multiplication result. This process can perform multiplication operations on data with different bit widths while ensuring the accuracy of the multiplier operation result, effectively reducing the area occupied by the multiplier on the AI ​​chip. At the same time, this process can obtain a small number of valid partial products, so that the multiplier only accumulates the valid partial products, thereby reducing the amount of invalid operations and lowering the power consumption of the multiplier.

[0102] In one embodiment, see further. Figure 3 As shown, the low-order Booth encoding unit 131 in the modified encoding circuit 13 includes: a low-order data input port 1311, a low-order target encoding output port 1312, and a gating value output port 1313. The low-order data input port 1311 is used to receive the low-order data in the first data, the low-order target encoding output port 1312 is used to output the low-order target encoding obtained after Booth encoding of the low-order data, and the gating value output port 1313 is used to output the highest-order value in the low-order data and input it to the selector 134.

[0103] Specifically, in the multiplication operation, the correction encoding circuit 13 in the multiplier can perform Booth encoding processing on the multiplier. The low-order Booth encoding unit 131 in the correction encoding circuit 13 can receive three consecutive values ​​corresponding to the low-order data in the multiplier through the low-order data input port 1311. These three values ​​can be used as a set of data to be encoded. After processing the received data to be encoded, the low-order target code obtained by the low-order Booth encoding unit 131 can be output through the low-order target code output port 1114. In addition, the first low-order Booth encoding unit 131 in the correction encoding circuit 13 can receive the automatically padded value 0 and the lower two values ​​of the low-order data through the low-order data input port 1311.

[0104] For example, if the multiplier receives a 16-bit multiplier, i.e., "y 15 y 14 y 13 y 12 y 11 y 10The data y9y8y7y6y5y4y3y2y1y0 has numbers 0, ..., 15 corresponding to the least significant bit and the most significant bit, respectively. The low-bit Booth encoding unit 131 can perform Booth encoding on the low-bit data y7y6y5y4y3y2y1y0. Before Booth encoding, the 8 low-bit data is automatically padded to obtain the 9-bit data y7y6y5y4y3y2y1y00. The low-bit Booth encoding unit 131 can perform Booth encoding on the four groups of data y7y6y5, y5y4y3, y3y2y1, and y1y00 in y7y6y5y4y3y2y1y00 respectively. The low-bit data input port 1311 in the low-bit Booth encoding unit 131 can receive the three adjacent three-bit values ​​in the four groups of data after the 9-bit data is divided.

[0105] It should be noted that during each Booth coding process, the correction coding circuit 13 can divide the data after automatic padding of the low-order data into multiple groups of data to be encoded. The low-order Booth coding unit 131 can simultaneously perform Booth coding on the multiple groups of data to be encoded. Optionally, the method of dividing the data into multiple groups can be characterized by taking every 3 adjacent bits of the padded data as a group of data to be encoded, and the highest bit of each group of data to be encoded can be taken as the lowest bit of the next adjacent group of data to be encoded. Optionally, the encoding method of Booth coding can be referred to Table 1, where y in Table 1... 2i+1 ,y 2i and y 2i-1 This can represent the three values ​​corresponding to each group of data to be encoded. X can represent the multiplicand received by the correction encoding circuit 13. After performing Booth encoding on each group of data to be encoded, the corresponding target code PP is obtained. i (i = 0, 1, 2, ..., n). Optionally, according to Table 1, the target code obtained after Booth coding can include five categories: -2X, 2X, -X, X, and 0. For example, if the multiplicand received by the corrected encoding circuit 13 is "x7x6x5x4x3x2x1x0", then X can be represented as "x7x6x5x4x3x2x1x0".

[0106] Table 1

[0107]

[0108] For example, continuing with the example above, when i = 0, y 2i+1 =y1,y 2i =y0,y 2i-1 =y -1 , then y -1 This can represent the padded value 0 after y0 (i.e., the multiplier after automatic padding is represented as y7y6y5y4y3y2y1y0y).-1 During Booth encoding processing, y can be processed. -1 The four groups of data to be encoded, y0y1, y1y2y3, y3y4y5 and y5y6y7, are encoded respectively to obtain four low-bit target codes. The highest bit value in each group of data to be encoded can be used as the lowest bit value in the next adjacent group of data to be encoded.

[0109] Optional, see below Figure 3 As shown, the high-order Booth encoding unit 135 in the modified encoding circuit 13 includes: a high-order data input port 1351, a high-order target encoding output port 1352, and a gating value input port 1353. The high-order data input port 1351 is used to receive the high-order data in the first data, the high-order target encoding output port 1352 is used to output the high-order target encoding obtained after Booth encoding of the high-order data, and the gating value input port 1353 is used to receive the highest-order value or the value 0 in the low-order data output by the selector 134.

[0110] It is understood that the high-order Booth coding unit 135 can receive the padding value selected by the selector 134, and use it as the padding value when performing Booth coding on the high-order data in the first data, and perform Booth coding on the data after combining the padding value and the high-order value. The padding value can be the highest-order value corresponding to the low-order data in the first data or the value 0. Optionally, the Booth coding method performed by the high-order Booth coding unit 135 is similar to the Booth coding method performed by the low-order Booth coding unit 131, and will not be described further.

[0111] This embodiment provides a multiplier in which a low-order Booth encoding unit performs Booth encoding on low-order data to obtain a low-order target code corresponding to the low-order data. Then, a low-order logic operation unit performs an AND logic operation on the low-order target code to obtain a logic operation result. Based on the logic operation result, it determines whether the low-order target code needs to be input to other operation units for further multiplication to obtain a multiplication result. This process can perform multiplication operations on data with different bit widths while ensuring the accuracy of the multiplier operation result, effectively reducing the area occupied by the multiplier on the AI ​​chip. At the same time, this process can obtain a smaller number of valid partial products, so that the multiplier only accumulates the valid partial products, thereby reducing the amount of invalid operations and lowering the power consumption of the multiplier.

[0112] As one example, see below. Figure 3As shown, the low-order logic operation unit 132 in the correction encoding circuit 13 includes: a low-order target encoding input port 1321 and a low-order target encoding output port 1322. The low-order target encoding input port 1321 is used to receive the low-order target encoding, and the low-order target encoding output port 1322 is used to output a valid low-order target encoding.

[0113] Specifically, if the multiplier can handle N-bit data operations and 2N-bit data operations, and the multiplier determines that it can currently handle N-bit data operations based on the received function selection mode signal, then the multiplier can perform an AND logic operation on the low-bit target code received through the low-bit target code input port 1321 and the corresponding low-bit target code obtained when performing 2N-bit data multiplication, to obtain the first logic operation result. If the first logic operation result is a low-level signal, then the low-bit logic operation unit 132 does not need to input the received low-bit target code through the low-bit target code output port 1322 to the low-bit partial product acquisition unit 133. At this time, these low-bit target codes output by the low-bit target code output port 1322 can be called invalid low-bit target codes, which can be characterized as target codes that do not participate in subsequent calculations. Optionally, the multiplier determines the current processable 2N-bit data operation based on the received function selection mode signal. Then, the multiplier can perform an AND logic operation on the low-bit target code received through the low-bit target code input port 1321 and the corresponding low-bit target code obtained when performing N-bit data multiplication, to obtain the first logic operation result. If the first logic operation result is a high-level signal, the low-bit logic operation unit 132 can input the received low-bit target code to the low-bit partial product acquisition unit 133 through the low-bit target code output port 1322. At this time, these low-bit target codes output by the low-bit target code output port 1322 can be called valid low-bit target codes, which can be characterized as target codes participating in subsequent calculations.

[0114] Optional, see below Figure 3 As shown, the high-order logic operation unit 136 in the correction encoding circuit 13 includes: a high-order target encoding input port 1361 and a high-order target encoding output port 1362. The high-order target encoding input port 1361 is used to receive the high-order target encoding, and the high-order target encoding output port 1362 is used to output a valid high-order target encoding.

[0115] It should be noted that if the multiplier can handle N-bit data operations and 2N-bit data operations, and the multiplier determines that it can currently handle N-bit data operations based on the received function selection mode signal, then the multiplier can perform an AND operation with the high-bit target code received through the high-bit target code input port 1361 and the corresponding high-bit target code obtained when performing 2N-bit data multiplication, to obtain the second logic operation result. If the second logic operation result is a low-level signal, then the high-bit logic operation unit 136 does not need to input the received high-bit target code through the high-bit target code output port 1362 to the high-bit partial product acquisition unit 137. In this case, these high-bit target codes output by the high-bit target code output port 1362 can be called invalid high-bit target codes, which can be characterized as target codes that do not participate in subsequent calculations. Optionally, the multiplier determines the current processable 2N-bit data operation based on the received function selection mode signal. Then, the multiplier can perform an AND operation with the high-bit target code received through the high-bit target code input port 1361 and the corresponding high-bit target code obtained when performing N-bit data multiplication, to obtain the second logic operation result. If the second logic operation result is a high-level signal, the high-bit logic operation unit 136 can input the received high-bit target code to the high-bit partial product acquisition unit 137 through the high-bit target code output port 1362. At this time, these high-bit target codes output by the high-bit target code output port 1362 can be called valid high-bit target codes, which can be characterized as target codes that do not participate in subsequent calculations.

[0116] This embodiment provides a multiplier in which the low-order logic operation unit performs an AND logic operation on the low-order target code to obtain the logic operation result. Based on the logic operation result, it determines whether the low-order target code needs to be input into other operation units to continue the multiplication operation to obtain the multiplication result. This process can perform multiplication operations on data with different bit widths while ensuring the accuracy of the multiplier operation result, effectively reducing the area occupied by the multiplier on the AI ​​chip. At the same time, this process can obtain a smaller number of valid partial products, so that the multiplier only accumulates the valid partial products, thereby reducing the amount of invalid operations and lowering the power consumption of the multiplier.

[0117] In one embodiment, see further. Figure 3As shown, the low-order partial product acquisition unit 133 in the modified encoding circuit 13 includes: a low-order target encoding input port 1331, a first strobe value input port 1332, a mode signal input port 1333, a data input port 1334, and a low-order partial product output port 1335; the low-order target encoding input port 1331 is used to receive the low-order target encoding output by the low-order logic operation unit 132, the first strobe value input port 1332 is used to receive the value contained in the low-order partial product after the sign bit is extended and output by the low-order selector group unit 138 after strobe selection, the mode signal input port 1333 is used to receive the function selection mode signal, the data input port 1334 is used to receive the second data, and the low-order partial product output port 1335 is used to output the target low-order encoding partial product.

[0118] Specifically, the low-bit partial product acquisition unit 133 receives the low-bit target code output by the low-bit Booth encoding unit 131 through the low-bit target code input port 1331, and receives the multiplicand in the multiplication operation through the data input port 1334. Based on the low-bit target code and the multiplicand, it obtains the partial product after sign bit extension corresponding to the low-bit target code. Optionally, if the multiplier corresponding to the function selection mode signal received by the mode signal input port 1333 can process N-bit data operations, the bit width of the partial product after sign bit extension can be equal to 2N. For example, if the multiplier processes N-bit data, and the low-order partial product acquisition unit 133 receives an N-bit multiplicand X, then the low-order partial product acquisition unit 133 can directly obtain the corresponding 2N-bit sign-bit extended partial product based on the multiplicand X and the low-order target code. The lower (N+1) bits of the sign-bit extended partial product can be equal to all the values ​​in the original partial product obtained directly from the low-order target code, and the higher (N-1) bits of the sign-bit extended partial product can be equal to the sign bit value in the original partial product, which is also the highest bit value of the original partial product. When the value in the low-order target code is -1, the original partial product can be -X; when the value in the low-order target code is 1, the original partial product can be X; and when the value in the low-order target code is 0, the original partial product can be 0.

[0119] It should be noted that the low-bit partial product acquisition unit 133 can receive the corresponding bit value in the low-bit partial product obtained after the sign bit extension when the different bit width data selected by the low-bit selector group unit 138 is operated through the first gating value input port 1332; then, it combines the sign bit extension partial product corresponding to the low-bit target code obtained by the multiplier with the gating corresponding bit value to obtain the sign bit extension low-bit partial product.

[0120] Further, the low-order partial product acquisition unit 133 can obtain the corresponding target low-order encoded partial product based on the low-order partial products after all sign bits are extended, and output the target low-order encoded partial product through the low-order partial product output port 1335. Optionally, the low-order partial product acquisition unit 133 can remove the partial products of all sign bit extended low-order partial products that are all zero data, and only retain non-zero data as the target low-order encoded partial product. Optionally, the number of target low-order encoded partial products can be less than or equal to the number of sign bit extended low-order partial products. Optionally, the distribution pattern of all target low-order encoded partial products can be characterized as follows: starting from the second target low-order encoded partial product, the least significant bit value in each target low-order encoded partial product is in the same column as the least significant bit value in the first target low-order encoded partial product; the most significant bit value in each target low-order encoded partial product is in the same column as the most significant bit value in the first target low-order encoded partial product; and the other bit values ​​in each target low-order encoded partial product are also in the same column as the corresponding bit values ​​in the first target low-order encoded partial product.

[0121] Optional, see below Figure 3 As shown, the high-order partial product acquisition unit 137 in the modified encoding circuit 13 includes: a high-order target encoding input port 1371, a second strobe value input port 1372, a mode signal input port 1373, a data input port 1374, and a high-order partial product output port 1375; the high-order target encoding input port 1371 is used to receive the high-order target encoding output by the high-order logic operation unit 136, the second strobe value input port 1372 is used to receive the value contained in the high-order partial product after the sign bit is extended and output by the high-order selector group unit 139, the mode signal input port 1373 is used to receive the function selection mode signal, the data input port 1374 is used to receive the second data, and the high-order partial product output port 1375 is used to output the target high-order encoding partial product.

[0122] Specifically, the high-order partial product acquisition unit 137 receives the high-order target code output by the high-order Booth coding unit 135 through the high-order target code input port 1371, and receives the multiplicand in the multiplication operation through the data input port 1374. Based on the high-order target code and the multiplicand, it obtains the high-order partial product after sign bit extension corresponding to the high-order target code. Optionally, if the function selection mode signal received by the high-order partial product acquisition unit 137 through the mode signal input port 1373 corresponds to a multiplier capable of processing N-bit data operations, then the bit width of the high-order partial product obtained by the high-order partial product acquisition unit 137 after sign bit extension can be equal to 2N. For example, if the multiplier processes N-bit data, and the high-order partial product acquisition unit 137 receives an N-bit multiplicand X, then the high-order partial product acquisition unit 137 can directly obtain the corresponding 2N-bit sign-bit extended partial product based on the multiplicand X and the high-order target code. The lower N bits of the sign-bit extended partial product can be equal to all the values ​​in the original partial product obtained directly from the high-order target code, and the higher N bits of the sign-bit extended partial product can be equal to the sign bit value in the original partial product, which is also the highest bit value of the original partial product. When the value in the high-order target code is -1, the original partial product can be -X; when the value in the high-order target code is 1, the original partial product can be X; and when the value in the high-order target code is 0, the original partial product can be 0.

[0123] It should be noted that the high-bit partial product acquisition unit 137 can receive the corresponding bit value in the high-bit partial product after the sign bit extension when different bit width data are selected by the high-bit selector group unit 139 through the second gating value input port 1372; then, it combines the sign bit extension partial product corresponding to the high-bit target code currently obtained by the multiplier with the corresponding bit value after gating to obtain the sign bit extension high-bit partial product.

[0124] Further, the high-order partial product acquisition unit 137 can obtain the corresponding target high-order encoded partial product based on the high-order partial products after all sign bits are extended, and output the target high-order encoded partial product through the high-order partial product output port 1375. Optionally, the high-order partial product acquisition unit 137 can remove the partial products of all sign bit extended high-order partial products that are all zero data, and only retain non-zero data as the target high-order encoded partial product. Optionally, the number of target high-order encoded partial products can be less than or equal to the number of sign bit extended high-order partial products. Optionally, the distribution pattern of all target high-order encoded partial products can be characterized as follows: starting from the second target high-order encoded partial product, the highest bit value in each target high-order encoded partial product is in the same column as the highest bit value in the first target high-order encoded partial product; the highest bit value in each target high-order encoded partial product is in the same column as the highest bit value in the first target high-order encoded partial product; and the other bit values ​​in each target high-order encoded partial product are also in the same column as the corresponding bit values ​​in the first target high-order encoded partial product.

[0125] This embodiment provides a multiplier in which the low-order partial product acquisition unit can obtain the target low-order code partial product based on the received low-order target code, and then accumulate the target low-order code partial product and the target high-order code partial product to obtain the multiplication result. This process can perform multiplication operations on data with different bit widths while ensuring the accuracy of the multiplier operation result, effectively reducing the area occupied by the multiplier on the AI ​​chip. At the same time, the number of effective partial products that can be obtained by this process is small, so that the multiplier only accumulates the effective partial products, thereby reducing the amount of invalid operations and reducing the power consumption of the multiplier.

[0126] As one example, see below. Figure 3 As shown, the selector 134 in the correction encoding circuit 13 includes: a mode signal input port 1341, a first strobe value input port 1342, a second strobe value input port 1343, and a strobe value output port 1344; the mode signal input port 1341 is used to receive the function selection mode signal, the first strobe value input port 1342 is used to receive the first strobe value, the second strobe value input port 1343 is used to receive the second strobe value, and the strobe value output port 1344 is used to output the first strobe value or the second strobe value obtained after strobe selection.

[0127] Specifically, selector 134 can determine the current data bit width that the multiplier can process through the function selection mode signal received by mode signal input port 1341, and determine whether to output the first strobe value or the second strobe value through strobe value output port 1344 based on the current data bit width that the multiplier can process. Optionally, the first strobe data can be the value 0 or the highest bit value corresponding to the low-order data in the first value, and the second strobe data can be the highest bit value corresponding to the low-order data in the first data or the value 0.

[0128] For example, if the data width received by the multiplier is 16 bits, the multiplier and multiplicand received by the correction encoding circuit 13 in the multiplier are both 16-bit data, and the mode signal input port (mode) 1341 in the selector 134 can receive two different function selection mode signals, namely mode=0 and mode=1. mode=0 indicates that the multiplier can currently process 8 bits of data, and mode=1 indicates that the multiplier can currently process 16 bits of data; when the mode signal input port 1341 (mode) of the selector 134 receives m When ode is 0, the multiplier can currently process 8-bit data operations. At this time, selector 134 can receive the second strobe value through the second strobe value input port 1343, which can be equal to the value 0. When the mode signal input port (mode) 1341 of selector 134 receives mode as 1, the multiplier can currently process 16-bit data operations. At this time, selector 134 can receive the first strobe value through the first strobe value input port 1342, which can be equal to the highest bit value corresponding to the low-order data in the multiplier.

[0129] It should be noted that if the multiplier can currently handle 8-bit data operations, then the multiplier can perform multiplication operations on the 16-bit multiplier and 16-bit multiplicand, corresponding to the high 8 bits and low 8 bits of data respectively. That is, the high 8 bits of the multiplier and high 8 bits of the multiplicand are processed by the high-bit Booth coding unit 135, and the low 8 bits of the multiplier and low 8 bits of the multiplicand are processed by the low-bit Booth coding unit 131. Furthermore, when the multiplier performs 8-bit data multiplication operations, the selector 134 can use the second selector... The strobe value input port 1343 receives the second strobe value 0, which is equivalent to the padded value of 0 after the high 8 bits of data are padded. If the multiplier can currently handle 16-bit data multiplication, the multiplier can directly perform multiplication on the 16-bit multiplier and the 16-bit multiplicand. That is, the correction encoding circuit 13 directly performs Buss encoding on the 16-bit multiplier. At this time, the selector 134 can receive the first strobe value through the first strobe value input port 1342. The first strobe value is the highest bit value in the low 8 bits of data.

[0130] This embodiment provides a multiplier that, through the function selection mode signal received by the selector, can determine the padding value when performing Booth encoding on the high-order data, thereby performing Booth encoding on the padded data. This process can perform multiplication operations on data with various bit widths while ensuring the accuracy of the multiplier's operation results, effectively reducing the area occupied by the multiplier on the AI ​​chip.

[0131] In one embodiment, see further. Figure 3 As shown, the low-bit selector group unit 138 in the correction encoding circuit 13 includes: a low-bit selector 1381, and a plurality of the low-bit selectors 1381 are used to select the value in the low-bit partial product after the sign bit is extended.

[0132] Specifically, the number of low-bit selectors 1381 in the low-bit selector group unit 138 can be equal to 3 / 8 times the square of the multiplicand bit width when the multiplier is currently performing multiplication or multiply-accumulate operations. Each low-bit selector 1381 in the low-bit selector group unit 138 can be a two-way selector, and the internal circuit structure of each low-bit selector 1381 can be the same. Optionally, if the multiplier can currently process N bits of data, then in the corresponding N / 4 low-bit partial product acquisition units 133 connected to the low-bit Booth encoding unit 131 in the multiplier, each low-bit partial product acquisition unit 133 can contain 2N value generation subunits, where the N value generation subunits can be connected to N low-bit selectors 1381, and each of these N value generation subunits can be connected to one low-bit selector 1381. Optionally, the N value generation subunits corresponding to the N low-order selectors 1381 can be value generation subunits corresponding to the high N bits of the low-order partial product after sign bit extension. In addition to the mode signal input port, the external input ports of these N low-order selectors 1381 also include two other input ports. Optionally, if the multiplier can currently handle n different bit-width data operations, and the bit width of the data received by the multiplier is N, then the signals received by the two other input ports of the aforementioned low-order selectors 1381 can be the value 0 and the sign bit value obtained by the low-order partial product acquisition unit 133 when the multiplier performs N-bit data operations, respectively. Among them, N / 4 low-bit partial product acquisition units 133 can be connected to N / 4 groups of N low-bit selectors 1381. The sign bit values ​​received by the N low-bit selectors 1381 in each group can be the same or different. However, the sign bit values ​​received by the N low-bit selectors 1381 in the same group are the same, and the sign bit value can be obtained from the sign bit value in the partial product after the sign bit is extended by the low-bit partial product acquisition unit 133 connected to each group of N low-bit selectors 1381.

[0133] In addition, among the 2N value generation subunits included in each low-order partial product acquisition unit 133, the corresponding N / 2 value generation subunits may not be connected to the low-order selector 1381. In this case, the value obtained by the N / 2 value generation subunits can be the low-order target code obtained by the multiplier with different bit widths, and the corresponding bit value in the low-order partial product after the sign bit extension. Alternatively, the value obtained by the N / 2 value generation subunits can be all the values ​​in the low-order partial product after the sign bit extension, from the least significant bit (i.e., the 1st bit) to the most significant bit, from the 1st bit to the N / 2th bit.

[0134] It should be noted that among the 2N value generation subunits included in each of the aforementioned low-order partial product acquisition units 133, the remaining N / 2 value generation subunits can also be connected to N / 2 low-order selectors 1381. Each value generation subunit can be connected to one low-order selector 1381. In addition to the mode signal input port, the external input ports of these N / 2 low-order selectors 1381 have two other input ports. The signals received by these two other input ports can be used for N / 2-bit data operations by the multiplier to obtain the sign bit value in the corresponding sign bit extended partial product, and then used for N-bit data operations by the multiplier to obtain the corresponding bit value in the corresponding sign bit extended low-order partial product. Alternatively, the values ​​obtained by the N / 2 value generation subunits can be all the values ​​in the corresponding sign bit extended low-order partial product, from the least significant bit (i.e., the first bit) to the most significant bit, from the ((N / 2)+1)th bit to the Nth bit. The N / 2 low-order partial product acquisition units 133 can be connected to N / 4 groups of N / 2 low-order selectors 1381. The sign bit values ​​received by the N / 2 low-order selectors 1381 in each group can be the same or different. However, the sign bit values ​​received by the N / 2 low-order selectors 1381 in the same group are the same. These sign bit values ​​can be obtained from the sign bit value in the partial product of the sign bit extension obtained by the corresponding low-order partial product acquisition unit 133 connected to each group of N / 2 low-order selectors 1381. Furthermore, the corresponding bit values ​​in the partial product of the sign bit extension received by the N / 2 low-order selectors 1381 in each group can be determined from the corresponding bit values ​​in the partial product of the sign bit extension obtained by the low-order partial product acquisition unit 133 connected to that group of low-order selectors 1381. In each group of N / 2 low-order selectors 1381, the corresponding bit values ​​received by each low-order selector 1381 can be the same or different. The distribution of the positions of the 2N numerical generation sub-units in each low-order partial product acquisition unit 133 can be characterized as follows: each of the 2N numerical generation sub-units in each low-order partial product acquisition unit 133 is located in the corresponding column.

[0135] Optional, see below Figure 3 As shown, the high-bit selector group unit 139 in the correction encoding circuit 13 includes: a high-bit selector 1391, and a plurality of the high-bit selectors 1391 are used to select the value in the high-bit partial product after the sign bit is extended.

[0136] Specifically, the number of high-bit selector groups 1391 in the high-bit selector group unit 139 can be equal to 3 / 8 times the square of the multiplicand bit width when the multiplier is currently performing multiplication or multiply-accumulate operations. Each high-bit selector 1391 in the high-bit selector group unit 139 can be a two-way selector, and the internal circuit structure of each high-bit selector 1391 can be the same. Optionally, if the multiplier can currently process N bits of data operations, the high-bit Booth encoding unit 135 in the multiplier is connected to the corresponding N / 4 high-bit partial product acquisition units 137. Each high-bit partial product acquisition unit 137 can contain 2N value generation subunits, where the N value generation subunits can be connected to N high-bit selectors 1391, and each value generation subunit is connected to one high-bit selector 1391. Optionally, the N value generation subunits corresponding to the aforementioned N high-order selectors 1391 can be value generation subunits corresponding to the lower N bits of the high-order partial product after sign bit extension. Besides the mode signal input port, the external input ports of these N high-order selectors 1391 also include two other input ports. Optionally, if the multiplier can handle n different bit-width data operations, and the bit width of the data received by the multiplier is N, then the signals received by the two other input ports of the aforementioned high-order selectors 1391 can be the value 0 and the corresponding bit value in the high-order partial product obtained by the high-order partial product acquisition unit 137 after sign bit extension when the multiplier performs N-bit data operations. The N / 4 high-order partial product acquisition units 137 can be connected to N / 4 groups of N high-order selectors 1391, and the corresponding bit values ​​received by the N high-order selectors 1391 in each group can be the same or different.

[0137] Furthermore, among the 2N value generation subunits included in each high-order partial product acquisition unit 137, N / 2 value generation subunits can be connected to N / 2 high-order selectors 1391, and each value generation subunit can be connected to one high-order selector 1391. The internal circuit structure of these N / 2 high-order selectors 1391 can be the same as that of selector 134. Optionally, the N / 2 value generation subunits corresponding to the aforementioned N / 2 high-order selectors 1391 can be the value generation subunits corresponding to the high N / 2 bits of the high-order partial product after sign bit extension. In addition to the mode signal input port, the external input ports of these N / 2 high-order selectors 1391 also have two other input ports. The signals received by these two other input ports can be the sign bit value in the corresponding sign bit value in the corresponding sign bit extended partial product obtained by multiplying N-bit data operations, and the corresponding bit value in the corresponding sign bit extended partial product obtained by multiplying N-bit data operations. The N / 4 high-order partial product acquisition units 137 can be connected to N / 4 groups of N / 2 high-order selectors 1391. The sign bit values ​​received by the N / 2 high-order selectors 1391 in each group can be the same or different. However, the sign bit values ​​received by the N / 2 high-order selectors 1391 in the same group are the same. These sign bit values ​​can be obtained from the sign bit values ​​in the partial product of the sign bit extension obtained by the high-order partial product acquisition unit 137 connected to each group of N / 2 high-order selectors 1391. Furthermore, the corresponding bit values ​​in the partial product of the sign bit extension received by the N / 2 high-order selectors 1391 in each group can be determined from the sign bit values ​​in the partial product of the sign bit extension obtained by the high-order partial product acquisition unit 137 connected to that group of high-order selectors 1391. The corresponding bit values ​​received by each high-order selector 1391 in each group can be the same or different.

[0138] It should be noted that among the 2N value generation subunits included in each high-order partial product acquisition unit 137, the remaining N / 2 value generation subunits may not be connected to the high-order selector 1391. In this case, the values ​​acquired by these N / 2 value generation subunits can be the corresponding bit values ​​in the partial product after the sign bit extension of the values ​​obtained from the high-order target encoding of the data with different bit widths currently being processed by the multiplier. Alternatively, the values ​​acquired by the N / 2 value generation subunits can be all the values ​​in the high-order partial product after the sign bit extension, from the least significant bit (i.e., the 1st bit) to the most significant bit, from the (N+1)th bit to the 3N / 2th bit. The distribution of the 2N value generation subunits in each high-order partial product acquisition unit 137 can be characterized as follows: each of the 2N value generation subunits in each high-order partial product acquisition unit 137 is located in the corresponding column.

[0139] This embodiment provides a multiplier in which the low-order selector group can select the value in the low-order partial product after the sign bit is extended to obtain the low-order partial product after the sign bit is extended. Based on the low-order partial product after the sign bit is extended, the target low-order encoded partial product is obtained. Then, the target low-order encoded partial product and the obtained target high-order encoded partial product are accumulated by the correction compression circuit to obtain the multiplication results of different modes. This process can perform multiplication operations on data with different bit widths while ensuring the accuracy of the multiplier operation results, effectively reducing the area occupied by the multiplier on the AI ​​chip.

[0140] Figure 4 A detailed circuit diagram of the correction compression circuit 14 in the multiplier provided in another embodiment is shown below. Figure 4 As shown, the modified compression circuit 14 includes: a modified Wallace tree group unit 141 and an accumulation circuit 142; the output terminal of the modified Wallace tree group unit 141 is connected to the input terminal of the accumulation circuit 142; the modified Wallace tree group unit 141 is used to accumulate the values ​​of each column in the partial product of the target encoding obtained by operating on data with different bit widths to obtain the accumulation operation result; the accumulation circuit 142 is used to accumulate the real-time accumulation operation result to obtain the multiplication operation result.

[0141] Specifically, the modified Wallace tree unit 141 can accumulate the values ​​in each column of the target coded partial product obtained by the modified encoding circuit 13, and the accumulation circuit 142 can accumulate the two operation results obtained by the modified Wallace tree unit 141 to obtain the multiplication result. When accumulating through the modified Wallace tree unit 141, the distribution of all target coded partial products can be characterized as follows: the least significant bit of each target coded partial product is located in the same column, the most significant bit of each target coded partial product is located in the same column, and the other bits of each target coded partial product are located in the same column. The modified Wallace tree unit 141 accumulates the values ​​in each column of all target coded partial products according to this distribution. Optionally, the target coded partial product may include a target low-order coded partial product and a target high-order coded partial product, wherein the corresponding bits in the last target low-order coded partial product and the first target high-order coded partial product correspond to different columns. Optionally, the two operation results obtained by the modified Wallace tree group unit 141 may include the sum output signal Sum and the carry output signal Carry.

[0142] This embodiment provides a multiplier that, by modifying the Wallace tree group circuit, accumulates the target low-order encoded partial product and the target high-order encoded partial product to obtain the accumulated result. The accumulated result is then accumulated again by the accumulation circuit to obtain the multiplication result. This process ensures the accuracy of the multiplier's operation while enabling multiplication operations on data with various bit widths, effectively reducing the area occupied by the multiplier on the AI ​​chip. Furthermore, the limited number of valid partial products obtained by this process allows the multiplier to accumulate only the valid partial products, thereby reducing invalid computations and lowering the multiplier's power consumption.

[0143] In one embodiment, see further. Figure 4 The modified Wallace tree group unit 141 in the modified compression circuit 14 includes: a low-order Wallace tree subunit 1411, a selector 1412, and a high-order Wallace tree subunit 1413. The output terminal of the low-order Wallace tree subunit 1411 is connected to the input terminal of the selector 1412, and the output terminal of the selector 1412 is connected to the input terminal of the high-order Wallace tree subunit 1413. The multiple low-order Wallace tree subunits 1411 are used to accumulate the values ​​in each column of the target encoded partial product. The selector 1412 is used to select the carry input signal received by the high-order Wallace tree subunit 1413. The multiple high-order Wallace tree subunits 1413 are used to accumulate the values ​​in each column of the target encoded partial product.

[0144] Specifically, the circuit structure of multiple low-order Wallace tree sub-units 1411 and multiple high-order Wallace tree sub-units 1413 can be implemented by combining full adders and half adders, or by combining 4-2 compressors. Alternatively, it can be understood as a circuit capable of processing multi-bit input signals and adding them together to obtain a two-bit output signal. Optionally, the number of high-order Wallace tree sub-units 1413 in the modified Wallace tree group unit 141 can be equal to the bit width N of the data that the multiplier can currently process, or it can be equal to the number of low-order Wallace tree sub-units 1411. Furthermore, the low-order Wallace tree sub-units 1411 and the high-order Wallace tree sub-units 1413 can be connected in series. Optionally, the output of the last low-order Wallace tree sub-unit 1411 is connected to the input of the selector 1412, and the output of the selector 1412 is connected to the input of the first high-order Wallace tree sub-unit 1211. Optionally, each low-order Wallace tree subunit 1411 in the modified Wallace tree group unit 141 can perform addition processing on each column value of the partial product of all target codes, and each low-order Wallace tree subunit 1411 can output two signals, namely the carry signal Carry. i With a sum bit signal Sum iHere, i can represent the number corresponding to each low-order Wallace tree subunit 1411, with the first low-order Wallace tree subunit 1411 having the number 0. Optionally, the number of input signals received by each low-order Wallace tree subunit 1411 can be equal to the number of target coded partial products. Specifically, the sum of the number of high-order Wallace tree subunits 1413 and low-order Wallace tree subunits 1411 in the modified Wallace tree group unit 141 can be equal to 2N. The total number of columns from the lowest to the highest in all target coded partial products can be equal to 2N. N low-order Wallace tree subunits 1411 can perform an accumulation operation on each column value corresponding to the lower N columns of all target coded partial products, and N high-order Wallace tree subunits 1413 can perform an accumulation operation on each column value corresponding to the higher N columns of all target coded partial products.

[0145] For example, if the multiplier can receive data with a bit width of N, and the multiplier can currently process N bits of data, then the selector 1412 in the multiplier can select the last low-order Wallace tree sub-unit 1411 in the modified Wallace tree group unit 141, and output the carry output signal Cout. N The carry input signal Cin received by the first high-order Wallace tree subunit 1413 in the modified Wallace tree group unit 141 is... N+1 This can also be understood as the multiplier currently treating the received N-bit data as a whole for operation; if the multiplier can currently process N / 2-bit data operations, then the selector 1412 in the multiplier can select the value 0 as the carry input signal Cin received by the first high-order Wallace tree subunit 1413 in the Wallace tree group unit 141. N+1 This can also be understood as the multiplier currently dividing the received N-bit data into high N / 2 bits and low N / 2 bits for multiplication. The corresponding numbers i from the first low-bit Wallace tree subunit 1411 to the last low-bit Wallace tree subunit 1411 are 1, 2, ..., N, respectively, and the corresponding numbers i from the first high-bit Wallace tree subunit 1413 to the last high-bit Wallace tree subunit 1413 are N+1, N+2, ..., 2N, respectively.

[0146] It should be noted that the signals received by each lower-order Wallace tree subunit 1411 and higher-order Wallace tree subunit 1413 in the modified Wallace tree group unit 141 may include the carry input signal Cin. i Partial product value input signal, carry output signal Cout iOptionally, the partial product input signal received by each low-order Wallace tree subunit 1411 and high-order Wallace tree subunit 1413 can be all values ​​in the corresponding column of all target encoded partial products, and the carry signal Cout output by each low-order Wallace tree subunit 1411 and high-order Wallace tree subunit 1413 can be... i The number of bits can be equal to N. Cout =floor((N I +N Cin ) / 2)-1. Where, N I N can represent the number of data input bits for this Wallace tree subunit. Cin N can represent the number of carry-in bits in this Wallace tree subunit. Cout This can represent the minimum number of carry-out output bits for the Wallace tree subunit, and `floor(·)` can represent the floor function. Optionally, the carry input signal received by each lower-order Wallace tree subunit 1411 or higher-order Wallace tree subunit 1413 in the Wallace tree group unit 141 can be the carry output signal output by the previous lower-order Wallace tree subunit 1411 or higher-order Wallace tree subunit 1413, and the carry input signal received by the first lower-order Wallace tree subunit 1411 is a value of 0. The carry input signal received by the first higher-order Wallace tree subunit 1413 can be determined by the current data bit width that the multiplier can process and the data bit width received by the multiplier.

[0147] This embodiment provides a multiplier that, by modifying the Wallace tree group circuit, accumulates the partial product of the target encoded data to obtain two output signals. These two output signals are then accumulated again by an accumulation circuit to obtain the multiplication result. This process ensures the accuracy of the multiplier's operation result while enabling multiplication operations on data with various bit widths, effectively reducing the area occupied by the multiplier on the AI ​​chip. Furthermore, the limited number of valid partial products obtained allows the multiplier to accumulate only the valid partial products, thereby reducing invalid computations and lowering the multiplier's power consumption.

[0148] As one example, see below. Figure 4 As shown, the accumulation circuit 142 in the correction compression circuit 14 includes an adder 1421, which is used to perform an addition operation on the accumulation operation result to obtain the multiplication operation result.

[0149] Specifically, adder 1421 can be a carry adder with different bit widths. Optionally, adder 1421 can receive two signals output from the modified Wallace tree unit 141 and perform addition on these two output signals to obtain the multiplication result. Optionally, the adder 1421 can be a carry-lookahead adder, and the bit width of the carry-lookahead adder can be equal to twice the current data bit width that the multiplier can process.

[0150] Optional, see below Figure 4 As shown, the accumulation circuit 142 in the correction compression circuit 14 includes an adder 1421. The adder 1421 includes a carry signal input port 1421a, a sum signal input port 1421b, and a calculation result output port 1421c. The carry signal input port 1421a is used to receive the carry signal, the sum signal input port 1421b is used to receive the sum signal, and the calculation result output port 1421c is used to output the multiplication result obtained by accumulating the carry signal and the sum signal.

[0151] It should be noted that the adder 1421 can receive the carry signal Carry output by the modified Wallace tree group unit 141 through the carry signal input port 1421a, and receive the sum signal Sum output by the modified Wallace tree group unit 141 through the sum signal input port 1421b. The carry signal Carry and the sum signal Sum are accumulated to obtain the multiplication result, and the multiplication result is output through the operation result output port 1421c.

[0152] Understandably, during multiplication, the multiplier can use adders 1421 of different bit widths to perform addition operations on the carry output signal Carry and the sum output signal Sum output from the modified Wallace tree group unit 141; wherein, the data bit width that the adder 1421 can process can be equal to twice the data bit width N that the multiplier can currently process. Optionally, each low-order Wallace tree subunit 1411 and each high-order Wallace tree subunit 1413 in the modified Wallace tree group unit 141 can output a carry output signal Carry. i With a sum of bits, the output signal Sum i (i = 1, ..., 2N, where i is the corresponding number of each low-order or high-order Wallace tree subunit, starting from 1). Optionally, the Carry received by adder 1421 is {[Carry1: Carry...} 2N-1The carry output signal Carry received by adder 1421 has a bit width of 2N. The first (2N-1) bits of the carry output signal Carry correspond to the carry output signals of the first (2N-1) low-order and high-order Wallace tree sub-units in the modified Wallace tree group unit 141. The last bit of the carry output signal Carry can be replaced by the value 0. Optionally, the sum output signal Sum received by adder 1421 has a bit width of N. The value in the sum output signal Sum can be equal to the sum output signal of each low-order and high-order Wallace tree sub-unit in the modified Wallace tree group unit 141.

[0153] For example, if the multiplier can currently handle 8-bit fixed-point multiplication operations, then the adder 1421 in the multiplier can be a 16-bit carry adder, such as... Figure 5 As shown in the figure, each Wallace tree subunit receives the value of the partial product of 4 target codes. The modified Wallace tree group unit 141 can output the sum output signal Sum and carry output signal Carry of 16 low-order Wallace tree subunits and high-order Wallace tree subunits. However, the sum output signal received by the 16-bit carry adder can be the complete sum signal Sum output by the modified Wallace tree group unit 141, and the received carry output signal can be the carry signal Carry obtained by combining all carry output signals of the modified Wallace tree group unit 141 except for the carry output signal output by the last high-order Wallace tree subunit 1413 with the value 0.

[0154] This embodiment provides a multiplier that, through an accumulation circuit, accumulates two signals output from a modified Wallace tree group circuit to output the multiplication result. This process ensures the accuracy of the multiplier's operation result while enabling multiplication operations on data with various bit widths, effectively reducing the area occupied by the multiplier on the AI ​​chip. Furthermore, the process yields a smaller number of valid partial products, allowing the multiplier to accumulate only the valid partial products, thereby reducing invalid computations and lowering the multiplier's power consumption.

[0155] Figure 6 A flowchart illustrating a data processing method provided in one embodiment, the method can... Figure 1 The multiplier shown in this embodiment processes data, specifically data with different bit widths. Figure 6 As shown, the method includes:

[0156] S101. Receive the data to be processed and the function selection mode signal, wherein the function selection mode signal is used to indicate the current data bit width that the multiplier can process.

[0157] Specifically, the multiplier can receive the data to be processed through a correction encoding circuit, which can be the multiplier and multiplicand in a multiplication operation. During each multiplication operation, both the correction encoding circuit and the correction compression circuit in the multiplier can receive the same function selection mode signal. Optionally, the data to be processed can be a fixed-point number. If the multiplier receives different function selection mode signals, it indicates that the multiplier can handle data operations of different bit widths; furthermore, the correspondence between different function selection mode signals and the data of different bit widths that the multiplier can handle can be flexibly set, and this embodiment does not impose any limitations on this. If the correction encoding circuit and the correction compression circuit can receive multiple different function selection mode signals, taking three function selection mode signals (i.e., mode signals) as examples, the mode signals can be 00, 01 and 10 respectively. Then, mode = 00 can indicate that the multiplier can currently process 16 bits of data, mode = 01 can indicate that the multiplier can currently process 32 bits of data, and mode = 10 can indicate that the multiplier can currently process 64 bits of data. In addition, mode = 00 can also indicate that the multiplier can currently process 64 bits of data, mode = 01 can also indicate that the multiplier can currently process 16 bits of data, and mode = 10 can indicate that the multiplier can currently process 32 bits of data.

[0158] Optionally, the bit width of the multiplier and multiplicand received by the correction encoding circuit in the multiplication operation can be 8 bits, 16 bits, 32 bits, or 64 bits, and this embodiment does not impose any limitation on this. The bit width of the multiplier in the multiplication operation can be equal to the bit width of the multiplicand.

[0159] S102. When the data to be processed is non-zero, the data to be processed is stored in the data register.

[0160] Specifically, the multiplier uses a judgment circuit to determine whether the received data to be processed is non-zero. If it is non-zero, the data to be processed is stored in a data register for multiplication. Optionally, the data to be processed may include the multiplier and multiplicand in the multiplication operation.

[0161] Optionally, after step S101 above, the method may further include: when the data to be processed is all zeros, then the data 0 is taken as the result of the multiplication operation.

[0162] It should be noted that if the data to be processed is determined to be not non-zero, i.e., all zeros, then the multiplier does not need to store the data to be processed in the data register; that is, the multiplier does not need to perform a multiplication operation on the data to be processed. Optionally, all zeros can be invalid data.

[0163] S103. Select the signal to be encoded according to the function selection mode signal.

[0164] Optionally, the step of selecting the signal to be encoded according to the function selection mode signal in S103 above may specifically include: selecting a value of 0 as the signal to be encoded according to the function selection mode signal, or selecting the highest bit value corresponding to the low bit data in the data to be processed as the signal to be encoded.

[0165] Specifically, the selector in the multiplier can determine the output signal to be encoded after gating based on the received function selection mode signal and the bit width of the data to be processed received by the multiplier. Optionally, the signal to be encoded can be the value 0 or the highest bit value corresponding to the low-order data in the data to be processed, which can be the multiplier in the multiplication operation. Wherein, if the bit width of the data to be processed is 2N, then the high N bits can be the high-order data in the data to be processed, and the low N bits can be the low-order data in the data to be processed.

[0166] It should be noted that if the data width received by the multiplier is 2N, and the data width that the multiplier can currently process is also 2N, then the selector in the multiplier selects the highest bit value corresponding to the low-order data in the data to be processed, and uses it as the padding value when encoding the high-order data in the data to be processed. In this case, the multiplier can treat the received 2N bits of data as a whole for multiplication. If the data width that the multiplier can currently process is N, then the multiplier needs to divide the received 2N bits of data to be processed into high-N bits and low-N bits for parallel processing. In this case, the multiplier can select 0 through the selector, and use it as the padding value when encoding the high-order data in the data to be processed.

[0167] S104. Encode the signal to be encoded and the data to be processed to obtain the target encoded partial product.

[0168] Specifically, the above encoding process can be binary encoding. Optionally, the bit width of the target encoded partial product can be equal to twice the current data bit width that the multiplier can process.

[0169] S105. Accumulate the partial product of the target encoding to obtain the multiplication result.

[0170] Specifically, the accumulator circuit in the multiplier can accumulate the values ​​in each column of the partial product of all target codes to obtain the multiplication result. Optionally, the bit width of the multiplication result can be equal to twice the current data bit width that the multiplier can process.

[0171] This embodiment provides a data processing method that receives data to be processed and a function selection mode signal. When the data to be processed is non-zero, it is stored in a data register. An encoding signal is selected based on the function selection mode signal. Encoding processing is performed on the encoding signal and the data to be processed to obtain a target encoded partial product. The target encoded partial product is then accumulated to obtain a multiplication result. This method can perform multiplication operations on data with different bit widths based on the function selection mode signal received by the multiplier, effectively reducing the area occupied by the multiplier on the AI ​​chip. Furthermore, this method can process only valid data, reducing the number of valid partial products and thus reducing invalid computations and lowering the multiplier's power consumption.

[0172] Figure 7 A schematic diagram illustrating the specific process of obtaining the target encoded partial product is provided for another embodiment, as follows: Figure 7 As shown, the step in S104 above, which involves encoding the signal to be encoded and the data to be processed to obtain the target encoded partial product, may include:

[0173] S1041. Obtain the data to be encoded based on the signal to be encoded and the data to be processed.

[0174] Optionally, the step of obtaining the data to be encoded based on the signal to be encoded and the data to be processed in S1041 above may specifically include: performing padding processing on the data to be processed to obtain padded data; and obtaining the data to be encoded based on the signal to be encoded and the padded data.

[0175] Specifically, before performing Booth coding on the data to be processed, the multiplier can first perform automatic padding on the data to be processed, obtaining padded data. Optionally, padding can be characterized as adding a 0 to the lowermost bit of the least significant bit value of the data to be processed (i.e., the least significant bit data in the data to be processed). For example, if the multiplier can currently handle 8-bit fixed-point multiplication operations, and the multiplier is "y7y6y5y4y3y2y1y0", then after the multiplier performs automatic padding on the multiplier, it converts the multiplier into the padded data "y7y6y5y4y3y2y1y00". When i = 0, y 2i+1 =y1,y 2i =y0,y 2i-1 =y -1 , then y -1 This can represent the padded value 0 after y0 (i.e., the multiplier after automatic padding is represented as y7y6y5y4y3y2y1y0y). -1If the current data bit width that the multiplier can process is equal to the data bit width received by the multiplier, then the selector in the multiplier can receive the signal to be encoded as y3. Based on the signal to be encoded and the padded data to be processed, four sets of data to be encoded are obtained, including y3, y4, y5, y6, y7, y8, y9 ... -1 y0y1, y1y2y3, y3y4y5, and y5y6y7; if the current data bit width that the multiplier can process is equal to 1 / 2 of the data bit width received by the multiplier, then the signal to be encoded received by the selector in the multiplier can be the value 0. Based on the signal to be encoded and the padded data to be processed, four sets of data to be encoded are obtained, including y -1 y0y1, y1y2y3, 0y4y5 and y5y6y7; where the highest bit value in each group of data to be encoded can be used as the lowest bit value in the next adjacent group of data to be encoded.

[0176] S1042. Perform Booth coding on the data to be encoded to obtain the target code.

[0177] Specifically, the multiplier can perform Booth coding on each group of data to be encoded according to the Booth coding method shown in Table 1 to obtain the target code. This target code can include five categories: -2X, 2X, -X, X, and 0, where X can represent the multiplicand received by the multiplier. Optionally, the number of target codes can be equal to half the current data bit width that the multiplier can process. Optionally, the target codes can include low-order target codes and high-order target codes.

[0178] S1043. Based on the target code and the data to be processed, obtain the target code partial product. The target code partial product includes the target low-order code partial product and the target high-order code partial product.

[0179] Optionally, the step of obtaining the target code partial product based on the target code and the data to be processed in S1043 above may specifically include: obtaining the sign-bit extended partial product based on the target code and the data to be processed; and obtaining the target code partial product based on the sign-bit extended partial product. Optionally, the step of obtaining the target code partial product based on the sign-bit extended partial product may specifically include: deleting all partial products with data of 0 from all sign-bit extended partial products to obtain the target code partial product.

[0180] Specifically, the multiplier can obtain a partial product with sign bit extension based on a valid target code and the data to be processed, where the data to be processed can be the multiplicand in the multiplication operation. This partial product with sign bit extension can include both the high-order partial product and the partial product with sign bit extension. That is, the multiplier does not need to process invalid target codes. Furthermore, even if the target code is invalid, the partial product obtained by the multiplier can be 0, i.e., invalid data. Optionally, the target code can include low-order target codes and high-order target codes. Optionally, the low-order data in the multiplier can correspond to the low-order target code, and the high-order data in the multiplier can correspond to the high-order target code.

[0181] It should be noted that if the multiplier can handle N-bit data operations and 2N-bit data operations, and the multiplier determines that it can currently handle N-bit data operations based on the received function selection mode signal, then the multiplier can perform an AND operation on the low-bit target code obtained when performing 2N-bit data multiplication with the corresponding low-bit target code through the low-bit logic operation unit to obtain the first logic operation result. If the first logic operation result is a low-level signal, the multiplier can discard the low-bit target code and does not need to perform subsequent processing based on the low-bit target code. In this case, these low-bit target codes can be called invalid low-bit target codes. Optionally, the multiplier determines that it can currently process 2N bits of data based on the received function selection mode signal. Then, the multiplier, through its low-order logic operation unit, performs an AND operation with the corresponding low-order target code obtained during the N-bit data multiplication operation to obtain a first logic operation result. If the first logic operation result is a high-level signal, the multiplier can then perform subsequent processing based on the low-order target code and the multiplicand to obtain a target low-order code partial product. These low-order target codes can be called valid low-order target codes. In this embodiment, the multiplier only uses the obtained valid low-order target codes in subsequent processing to obtain valid partial products, and the number of target codes participating in subsequent processing can be less than or equal to 1 / 2 of the current processable data bit width of the multiplier. Optionally, the number of target code partial products can be less than or equal to the number of target codes.

[0182] Furthermore, if the multiplier can handle N-bit data operations and 2N-bit data operations, and the multiplier determines that it can currently handle N-bit data operations based on the received function selection mode signal, then the multiplier can perform an AND operation on the low-bit target code and the corresponding high-bit target code obtained when performing 2N-bit data multiplication with the high-bit target code through the high-bit logic operation unit to obtain the second logic operation result. If the second logic operation result is a low-level signal, the multiplier can discard the high-bit target code and does not need to perform subsequent processing based on the high-bit target code. In this case, these high-bit target codes can be called invalid high-bit target codes. Optionally, the multiplier determines that it can currently process 2N bits of data based on the received function selection mode signal. Then, the multiplier, through its high-order logic operation unit, performs an AND operation with the corresponding high-order target code obtained during the N-bit data multiplication operation to obtain a second logic operation result. If the second logic operation result is a high-level signal, the multiplier can then perform subsequent processing based on this high-order target code and the multiplicand to obtain a partial product of the target high-order codes. These high-order target codes can be called valid high-order target codes. In this embodiment, the multiplier only uses the obtained valid high-order target codes in subsequent processing to obtain a valid partial product.

[0183] It is understandable that if the target code and the N-bit multiplicand to be processed can yield an (N+1)-bit original partial product. Optionally, when the target code is -2X, the original partial product can be the result of inverting the left and right bits of X and then adding 1; when the target code is 2X, the original partial product can be the result of shifting X left by one bit; when the target code is -X, the original partial product can be the result of inverting the bits of X and then adding 1; when the target code is X, the original partial product can be the result of combining X with the sign bit value of X (i.e., the highest bit value of X); when the target code is... + When the sign bit is 0, the original partial product can be 0, meaning each bit in the original partial product is equal to 0. Optionally, the original partial product can be sign-extended to obtain a sign-extended partial product. The number of sign bits extended can be equal to (N-1) sign bits. Optionally, the above sign-extended process can be represented as supplementing a data with a sign bit, where the supplemented sign bit value is equal to the sign bit value (i.e., the highest bit value) of the original partial product. The high N bits of the sign-extended partial product can be equal, and the low N bits can be equal to all the values ​​in the original partial product. Furthermore, the multiplier can delete all sign-extended partial products containing 0 data, effectively retaining only the partial products containing non-zero data (i.e., the valid partial products) for subsequent operations.

[0184] The distribution of all target coded partial products can be characterized by the fact that the least significant bit of each target coded partial product is located in the same column, the most significant bit of each target coded partial product is located in the same column, and the other bits of each target coded partial product are also located in the same column. Optionally, the target coded partial products may include target low-order coded partial products and target high-order coded partial products, wherein the corresponding bits in the last target low-order coded partial product and the first target high-order coded partial product correspond to different columns.

[0185] This embodiment provides a data processing method that can perform multiplication operations on multiple data with different bit widths while ensuring the accuracy of the multiplier's operation results, effectively reducing the area occupied by the multiplier on the AI ​​chip. In addition, this method can process only the valid data to reduce the number of valid partial products, thereby reducing the amount of invalid operations and lowering the multiplier's power consumption.

[0186] Figure 8 A flowchart illustrating the process of obtaining the result of a multiplication operation is provided for another embodiment, as shown below. Figure 8 As shown, the step in S105 above, which involves accumulating the product of the target encoded parts to obtain the multiplication result, can include the following methods:

[0187] S1051. The cumulative operation result is obtained by performing a cumulative operation on the product of the target low-order code and the product of the target high-order code by modifying the Wallace tree group unit.

[0188] Specifically, the multiplier can accumulate the values ​​in each column by modifying the Wallace tree circuit to perform partial product of all target low-order and high-order codes, according to the distribution pattern, to obtain the accumulation result. Optionally, the accumulation result may include a sum output signal Sum and a carry output signal Carry, wherein the bit widths of the sum output signal Sum and the carry output signal Carry can be the same.

[0189] S1052. The accumulation operation result is accumulated by the accumulation circuit to obtain the multiplication operation result.

[0190] Specifically, the multiplier can accumulate the carry output signal Carry and the sum output signal Sum from the modified Wallace tree group circuit using the adder in the accumulator circuit to obtain the multiplication result. Optionally, each Wallace tree unit in the modified Wallace tree group circuit can output a carry output signal Carry. i With a sum of bits, the output signal Sum i(i = 0, ..., N-1, where i is the corresponding number of each Wallace tree subunit, starting from 0). Optionally, the Carry received by the adder = {[Carry0: Carry...} N-2 In other words, the carry output signal Carry received by the adder has a bit width of N. The first N-1 bits of the carry output signal Carry correspond to the carry output signals of the first N-1 Wallace tree sub-units in the corrected Wallace tree circuit. The last bit of the carry output signal Carry can be replaced by the value 0. Optionally, the sum output signal Sum received by the adder has a bit width of N, and the value in the sum output signal Sum can be equal to the sum output signal of each Wallace tree sub-unit in the corrected Wallace tree circuit.

[0191] For example, if the multiplier can currently handle 8-bit data operations, then the adder can be a 16-bit carry-lookahead adder, such as... Figure 3 As shown, the modified Wallace tree circuit can output the sum output signal Sum and carry output signal Carry of 16 Wallace tree sub-units. However, the sum output signal received by the 16-bit carry-lookahead adder can be the complete sum output signal Sum from the modified Wallace tree circuit, and the received carry output signal can be the carry signal Carry obtained by combining all carry output signals except the carry output signal of the last Wallace tree sub-unit with the value 0 in the modified Wallace tree circuit.

[0192] This embodiment provides a data processing method that accumulates the partial products of all target low-order and high-order codes by modifying the Wallace tree group circuit to obtain the accumulation result. The accumulation result is then accumulated by the accumulation circuit to obtain the multiplication result. This method can perform multiplication operations on data with different bit widths according to the function selection mode signal received by the multiplier, effectively reducing the area occupied by the multiplier on the AI ​​chip. In addition, this method can process only the valid data to reduce the number of valid partial products, thereby reducing the amount of invalid computation and lowering the power consumption of the multiplier.

[0193] Figure 9 A schematic diagram illustrating the specific process for obtaining the cumulative calculation result is provided for another embodiment, as follows: Figure 9 As shown, the step in S1051 above, which involves accumulating the product of the target low-order encoded portion and the product of the target high-order encoded portion using the modified Wallace tree group unit to obtain the accumulation result, may specifically include:

[0194] S1051a: Accumulate the column values ​​in the partial product of all target codes through the low-order Wallace tree sub-unit to obtain the intermediate operation result.

[0195] Specifically, based on the distribution of all target low-order coded partial products and all target high-order coded partial products, the total number of columns corresponding to all target coded partial products is 2N (N is the data bit width that the multiplier can currently process). Starting from the lowest column value, each column value can be numbered 0, ..., 2N-1, where numbers 0 to N-1 can be called the lower N column values. Optionally, the intermediate operation result can be the carry output signal Cout output from the last Wallace tree subunit in the low-order Wallace tree subunit.

[0196] It should be noted that the N Wallace tree sub-units contained in the lower-order Wallace tree sub-units can perform cumulative operations on the values ​​in the lower N columns in numerical order to obtain intermediate operation results. Optionally, the intermediate operation results may include the carry output signals Carry and Sum of each Wallace tree sub-unit, as well as the output signal Cout of the last Wallace tree sub-unit in the lower-order Wallace tree sub-units.

[0197] S1051b: The intermediate operation result is selected by a selector to obtain a carry selection signal.

[0198] Specifically, the selector in the compression circuit can select either the output signal Cout of the last Wallace tree sub-unit in the lower-order Wallace tree sub-unit or 0 based on the received function selection mode signal, thus obtaining the carry strobe signal. Optionally, Cout can be a signal included in the intermediate calculation result.

[0199] S1051c: The high-order Wallace tree subunit performs accumulation processing based on the carry gating signal and the column values ​​in the partial product of all target codes to obtain the accumulation operation result.

[0200] Specifically, according to the distribution of all target coding partial products, the total number of columns corresponding to all target coding partial products is 2N (N is the data bit width that the multiplier can currently process). Starting from the lowest column value, the corresponding number of each column value can be 0, ..., 2N-1. Among them, the numbers N to 2N-1 can be called the high N column values.

[0201] It should be noted that the N Wallace tree sub-units contained in the high-order Wallace tree sub-unit can perform cumulative operations on the values ​​in the high N columns in numerical order and output the cumulative operation result. Among them, the carry input signal received by the first Wallace tree sub-unit in the high-order Wallace tree sub-unit can be the carry strobe signal output by the selector.

[0202] This embodiment provides a data processing method that accumulates the column values ​​in all target encoded partial products using a low-order Wallace tree subunit to obtain an intermediate operation result. A selector then selects the intermediate operation result to obtain a carry-in signal. A high-order Wallace tree subunit accumulates the column values ​​in all target encoded partial products based on the carry-in signal and the accumulated values ​​to obtain an accumulated operation result. This accumulated operation result is then further accumulated to obtain the multiplication result. This method can perform multiplication operations on data of various bit widths based on the function selection mode signal received by the multiplier, effectively reducing the area occupied by the multiplier on the AI ​​chip. Furthermore, this method can process only valid data to reduce the number of valid partial products, thereby reducing invalid computations and lowering the multiplier's power consumption.

[0203] This application also provides a machine learning computing device, which includes one or more multipliers mentioned in this application. These multipliers are used to obtain data to be computed and control information from other processing devices, execute specified machine learning operations, and transmit the execution results to peripheral devices via I / O interfaces. Peripheral devices include, for example, cameras, monitors, mice, keyboards, network cards, Wi-Fi interfaces, and servers. When more than one multiplier is included, the multipliers can be linked and transmit data through a specific structure, such as interconnecting and transmitting data via a PCIe bus, to support larger-scale machine learning operations. In this case, they can share the same control system or have their own independent control systems; they can share memory or each accelerator can have its own memory. Furthermore, the interconnection method can be any interconnection topology.

[0204] This machine learning computing device has high compatibility and can be connected to various types of servers via a PCIe interface.

[0205] This application also provides a combined processing apparatus, which includes the aforementioned machine learning computing device, a general interconnect interface, and other processing devices. The machine learning computing device interacts with the other processing devices to jointly complete the user-specified operation. Figure 10 This is a schematic diagram of the combined processing device.

[0206] Other processing devices include one or more processor types such as central processing unit (CPU), graphics processing unit (GPU), and neural network processor. There is no limit to the number of processors included in other processing devices. These other processing devices serve as interfaces between the machine learning computing device and external data and control, including data transfer and basic control such as starting and stopping the machine learning computing device. Other processing devices can also collaborate with the machine learning computing device to complete computational tasks.

[0207] A general interconnect interface is used for transmitting data and control commands between the machine learning computing device and other processing devices. The machine learning computing device obtains the required input data from other processing devices and writes it to on-chip storage; it can obtain control commands from other processing devices and write them to on-chip control cache; it can also read data from the machine learning computing device's storage module and transmit it to other processing devices.

[0208] Optionally, the structure is as follows: Figure 11 As shown, it may also include a storage device, which is connected to both the machine learning computing device and the other processing devices. The storage device is used to store data in the machine learning computing device and the other processing devices, and is particularly suitable for data that cannot be fully stored in the internal storage of the machine learning computing device or other processing devices, requiring computation.

[0209] This combined processing device can serve as a System-on-a-Chip (SoC) for devices such as mobile phones, robots, drones, and video surveillance equipment, effectively reducing the core area of ​​the control unit, increasing processing speed, and lowering overall power consumption. In this case, the universal interconnect interface of the combined processing device connects to certain components of the device, such as cameras, monitors, mice, keyboards, network cards, and Wi-Fi interfaces.

[0210] In some embodiments, a chip has also been applied for, which includes the aforementioned machine learning computing device or combined processing device.

[0211] In some embodiments, a chip packaging structure including the aforementioned chip is provided.

[0212] In some embodiments, a circuit board is provided that includes the aforementioned chip packaging structure. For example... Figure 12 As shown, Figure 12 A board is provided, which, in addition to the chip 389, may also include other supporting components, including but not limited to: a storage device 390, a receiving device 391, and a control device 392.

[0213] The storage device 390 is connected to the chip within the chip package structure via a bus for storing data. The storage device may include multiple sets of storage cells 393. Each set of storage cells is connected to the chip via a bus. It is understood that each set of storage cells may be DDR SDRAM (Double Data Rate SDRAM).

[0214] DDR can double the speed of SDRAM without increasing the clock frequency. DDR allows data to be read on both the rising and falling edges of the clock pulse. DDR is twice as fast as standard SDRAM. In one embodiment, the storage device may include four groups of storage cells. Each group of storage cells may include multiple DDR4 chips. In one embodiment, the chips may internally include four 72-bit DDR4 controllers, of which 64 bits are used for data transmission and 8 bits are used for ECC verification. It can be understood that when DDR4-3200 chips are used in each group of storage cells, the theoretical data transmission bandwidth can reach 25600MB / s.

[0215] In one embodiment, each group of memory cells includes multiple Double Data Rate (DDR) synchronous dynamic random access memories (DRAMs) arranged in parallel. DDR can transfer data twice within one clock cycle. A controller for controlling the DDR is provided in the chip for controlling the data transfer and data storage of each memory cell.

[0216] The receiving device is electrically connected to the chip within the chip package structure. The receiving device is used to realize data transmission between the chip and external devices (e.g., servers or computers). For example, in one embodiment, the receiving device can be a standard PCIe interface. For instance, data to be processed is transferred from the server to the chip via a standard PCIe interface, realizing data transfer. Preferably, when using a PCIe 3.0 x 16 interface, the theoretical bandwidth can reach 16000 MB / s. In another embodiment, the receiving device can also be other interfaces; this application does not limit the specific form of the other interfaces mentioned above, as long as the interface unit can realize the switching function. Furthermore, the calculation results of the chip are still transmitted back to the external device (e.g., the server) by the receiving device.

[0217] The controller is electrically connected to the chip. The controller monitors the state of the chip. Specifically, the chip and the controller can be electrically connected via an SPI interface. The controller may include a microcontroller (MCU). The chip may include multiple processing chips, multiple processing cores, or multiple processing circuits, capable of driving multiple loads. Therefore, the chip can operate in different states, such as high load and low load. The controller can regulate the operating states of multiple processing chips, multiple processing cores, and / or multiple processing circuits within the chip.

[0218] In some embodiments, an electronic device is claimed that includes the aforementioned board.

[0219] Electronic devices can be data processors, robots, computers, printers, scanners, tablets, smart terminals, mobile phones, dashcams, navigators, sensors, cameras, servers, cloud servers, cameras, camcorders, projectors, watches, headphones, mobile storage, wearable devices, vehicles, home appliances, and / or medical devices.

[0220] The means of transportation include airplanes, ships and / or vehicles; the household appliances include televisions, air conditioners, microwave ovens, refrigerators, rice cookers, humidifiers, washing machines, lights, gas stoves, and range hoods; the medical equipment includes MRI scanners, ultrasound scanners and / or electrocardiographs.

[0221] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of circuit combinations. However, those skilled in the art should understand that this application is not limited to the described circuit combinations, as some circuits can be implemented in other ways or structures according to this application. Secondly, those skilled in the art should also understand that the embodiments described in the specification are all optional embodiments, and the devices and modules involved are not necessarily essential to this application.

[0222] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0223] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present invention, all of which fall within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be determined by the appended claims.

Claims

1. A multiplier, characterized in that: The multiplier comprises: a judgment circuit, a data register, a correction coding circuit and a correction compression circuit; the output end of the judgment circuit is connected to the input end of the data register, the output end of the data register is connected to the input end of the correction coding circuit, and the output end of the correction coding circuit is connected to the input end of the correction compression circuit; the correction coding circuit comprises: a low-order Booth coding unit, a low-order logic operation unit, a low-order partial product acquisition unit, a selector, a high-order Booth coding unit, a high-order logic operation unit, a high-order partial product acquisition unit, a low-order selector group unit and a high-order selector group unit; The first output end of the low-order Booth encoding unit is connected to the input end of the selector, the second output end of the low-order Booth encoding unit is connected to the input end of the low-order logic operation unit, the output end of the low-order logic operation unit is connected to the first input end of the low-order partial product acquisition unit, the output end of the selector is connected to the first input end of the high-order Booth encoding unit, the output end of the high-order Booth encoding unit is connected to the input end of the high-order logic operation unit, the output end of the high-order logic operation unit is connected to the first input end of the high-order partial product acquisition unit, the output end of the low-order selector group unit is connected to the second input end of the low-order partial product acquisition unit, and the output end of the high-order selector group unit is connected to the second input end of the high-order partial product acquisition unit; The judgment circuit is used to judge whether the received data contains all-0 data, and output a data gating signal according to the judgment result; the data register is used to select to receive the data according to the data gating signal, and store the data.

2. The multiplier according to claim 1, characterized in that The correction encoding circuit is used to encode the data stored in the data register to obtain the partial product after sign bit extension, and obtain the target encoding partial product based on the partial product after sign bit extension. The correction compression circuit is used to accumulate the target encoding partial product to obtain the multiplication result.

3. The multiplier according to claim 1 or 2, characterized in that: The correction encoding circuit includes a first input terminal for receiving an input function selection mode signal; the correction compression circuit includes a first input terminal for receiving the input function selection mode signal; the function selection mode signal is used to determine the data bit width that the multiplier can currently process.

4. The multiplier according to claim 1 or 2, characterized in that: The judgment circuit includes: a data input port, a logic signal output port and a data output port, the data input port is used to receive data for multiplication operation, the logic signal output port is used to output the data gating signal obtained by the judgment circuit according to the judgment result, and the data output port is used to output the data.

5. The multiplier according to claim 2, characterized in that: The data includes first data and second data; wherein the low-order Booth encoding unit is used to perform Booth encoding processing on the low-order data in the first data input by the data register to obtain a low-order target code; the low-order logic operation unit is used to perform an AND logic operation according to the low-order target code to obtain a first logic operation result, and determine whether to input the low-order target code to the low-order partial product acquisition unit according to the first logic operation result; the low-order partial product acquisition unit is used to obtain a low-order partial product after sign bit extension according to the low-order target code and the second data input by the data register; the selector is used to select the padding value when the high-order data in the first data is processed by Booth encoding; the high-order The Booth encoding unit is used to perform Booth encoding on the high-order data in the first data and the padding value to obtain a high-order target code; the high-order logic operation unit is used to perform an AND logic operation based on the high-order target code to obtain a second logic operation result, and determine whether to input the high-order target code to the high-order partial product acquisition unit based on the second logic operation result; the high-order partial product acquisition unit is used to obtain the high-order partial product after sign bit extension based on the high-order target code and the second data input by the data register; the low-order selector group unit is used to select the value in the low-order partial product after sign bit extension; the high-order selector group unit is used to select the value in the high-order partial product after sign bit extension.

6. The multiplier according to claim 5, characterized in that The low-order Booth encoding unit includes: a low-order data input port, a low-order target code output port and a selection value output port; the low-order data input port is used to receive the low-order data in the first data, the low-order target code output port is used to output the low-order target code obtained after Booth encoding the low-order data, and the selection value output port is used to output the highest-order value in the low-order data and input it into the high-order Booth encoding unit.

7. The multiplier according to claim 5, characterized in that The low-order logic operation unit includes: a low-order target code input port and a low-order target code output port, the low-order target code input port is used to receive the low-order target code output by the low-order logic operation unit, and the low-order target code output port is used to output a valid low-order target code.

8. The multiplier according to claim 5, characterized in that The low-order partial product acquisition unit includes: a low-order target code input port, a first selection value input port, a mode signal input port, a data input port and a low-order partial product output port; the low-order target code input port is used to receive the low-order target code output by the low-order logic operation unit, the first selection value input port is used to receive the value contained in the low-order partial product after the sign bit is extended and output after the low-order selector group unit is selected, the mode signal input port is used to receive a function selection mode signal, the data input port is used to receive the second data, and the low-order partial product output port is used to output the target low-order coded partial product in the target coded partial product.

9. The multiplier according to claim 5, characterized in that: The selector includes: a mode signal input port, a first selection value input port, a second selection value input port and a selection value output port; the mode signal input port is used to receive a function selection mode signal, the first selection value input port is used to receive a first selection value, the second selection value input port is used to receive a second selection value, and the selection value output port is used to output the first selection value or the second selection value obtained after selection.

10. The multiplier according to claim 5, characterized in that: The high-order Booth encoding unit includes: a high-order data input port, a high-order target code output port and a selection value input port; the high-order data input port is used to receive the high-order data in the first data, the high-order target code output port is used to output the high-order target code obtained after Booth encoding the high-order data, and the selection value input port is used to receive the highest-order value or the value 0 in the low-order data output by the selector.

11. The multiplier according to claim 5, characterized in that: The high-order logic operation unit includes: a high-order target code input port and a high-order target code output port, the high-order target code input port is used to receive the high-order target code output by the high-order logic operation unit, and the high-order target code output port is used to output a valid high-order target code.

12. The multiplier according to claim 5, characterized in that: The high-order partial product acquisition unit includes: a high-order target code input port, a second selection value input port, a mode signal input port, a data input port and a high-order partial product output port; the high-order target code input port is used to receive the high-order target code output by the high-order logic operation unit, the second selection value input port is used to receive the value contained in the high-order partial product after the sign bit is extended and output after the high-order selector group unit is selected, the mode signal input port is used to receive a function selection mode signal, the data input port is used to receive the second data, and the high-order partial product output port is used to output the target high-order coded partial product in the target coded partial product.

13. The multiplier according to claim 5, characterized in that: The low-bit selector group unit comprises: a low-bit selector, and the low-bit selector is used to select the value in the low-bit partial product after the sign bit is extended.

14. The multiplier according to claim 5, characterized in that: The high-order selector group unit comprises: a high-order selector, and the high-order selector is used to select the value in the high-order partial product after the sign bit is extended.

15. The multiplier according to claim 1 or 2, characterized in that: The modified compression circuit includes: a modified Wallace tree group unit and an accumulation circuit; the output end of the modified Wallace tree group unit is connected to the input end of the accumulation circuit; the modified Wallace tree group unit is used to accumulate each column value in the target coding partial product obtained by calculating different bit width data to obtain an accumulation operation result, and the accumulation circuit is used to accumulate the real-time accumulation operation result to obtain a multiplication operation result.

16. The multiplier according to claim 15, characterized in that The modified Wallace tree group unit includes: a low-order Wallace tree subunit, a selector and a high-order Wallace tree subunit, the output end of the low-order Wallace tree subunit is connected to the input end of the selector in the modified Wallace tree group unit, and the output end of the selector in the modified Wallace tree group unit is connected to the input end of the high-order Wallace tree subunit; wherein the low-order Wallace tree subunit is used to perform accumulation operation on each column value in the target coding partial product; the selector in the modified Wallace tree group unit is used to select the carry input signal received by the high-order Wallace tree subunit; the high-order Wallace tree subunit is used to perform accumulation operation on each column value in the target coding partial product.

17. The multiplier according to claim 15, characterized in that: The accumulation circuit includes: an adder, and the adder is used to perform an addition operation on the accumulation operation result to obtain the multiplication operation result.

18. The multiplier according to claim 17, characterized in that: The adder includes: a carry signal input port, a sum signal input port and an operation result output port; the carry signal input port is used to receive a carry signal, the sum signal input port is used to receive a sum signal, and the operation result output port is used to output the multiplication result obtained by accumulating the carry signal and the sum signal.

19. A data processing method, characterized in that: Applied to the multiplier of any one of claims 1 to 18, the method comprising: Receiving data to be processed and a function selection mode signal, wherein the function selection mode signal is used to indicate a data bit width that can be currently processed by the multiplier; When the data to be processed is non-zero data, the data to be processed is stored in the data register; Selecting the signal to be encoded according to the function selection mode signal; Perform encoding processing according to the signal to be encoded and the data to be processed to obtain a target encoded partial product; The target coded partial products are accumulated to obtain a multiplication result.

20. The method according to claim 19, characterized in that When the data to be processed is all 0 data, the method further includes: using data 0 as the multiplication result.

21. The method according to claim 19 or 20, characterized in that The selecting the signal to be encoded according to the function selection mode signal includes: selecting a value of 0 as the signal to be encoded according to the function selection mode signal, or selecting a highest bit value corresponding to low bit data in the data to be processed as the signal to be encoded.

22. The method according to claim 19 or 20, characterized in that The step of performing encoding processing according to the signal to be encoded and the data to be processed to obtain a target encoded partial product includes: Obtaining data to be encoded according to the signal to be encoded and the data to be processed; Performing Booth coding on the data to be coded to obtain a target code; The target code partial product is obtained according to the target code and the data to be processed.

23. The method according to claim 22, characterized in that The step of obtaining the data to be encoded according to the signal to be encoded and the data to be processed comprises: Performing padding processing on the data to be processed to obtain padded data; The data to be encoded are obtained according to the signal to be encoded and the padded data.

24. The method according to claim 22, characterized in that The step of obtaining the target coding partial product according to the target coding and the data to be processed includes: Obtaining a partial product after sign bit extension according to the target code and the data to be processed; The target coded partial product is obtained according to the partial product after the sign bit extension.

25. The method according to claim 24, characterized in that The obtaining the target coded partial product according to the partial product after the sign bit extension includes: deleting the partial products with data of 0 in all the partial products after the sign bit extension to obtain the target coded partial product.

26. The method according to claim 19 or 20, characterized in that The target coding partial product includes a target low-order coding partial product and a target high-order coding partial product; The step of accumulating the target coded partial products to obtain a multiplication result includes: The target low-order coding partial product and the target high-order coding partial product are accumulated by a modified Wallace tree group unit to obtain an accumulation operation result; The accumulation circuit performs accumulation processing on the accumulation operation result to obtain a multiplication operation result.

27. The method according to claim 26, characterized in that The step of performing accumulation processing on the target low-order coding partial product and the target high-order coding partial product by using the modified Wallace tree group unit to obtain an accumulation operation result includes: The column values ​​in all target coding partial products are accumulated by the low-order Wallace tree subunits in the modified Wallace tree group unit to obtain an intermediate operation result; The intermediate operation result is selected by a selector in the modified Wallace tree group unit to obtain a carry selection signal; The accumulation operation result is obtained by performing accumulation processing according to the carry selection signal and the column values ​​in all target coded partial products through the high-order Wallace tree subunit in the modified Wallace tree group unit.

28. A machine learning computing device, characterized in that: The machine learning operation device comprises one or more multipliers according to any one of claims 1 to 18, and is used to obtain input data to be operated and control information from other processing devices in the machine learning operation device except the multiplier, and perform specified machine learning operations, and transmit the execution results to other processing devices in the machine learning operation device except the multiplier through an I / O interface; When the machine learning computing device includes a plurality of the multipliers, the plurality of the multipliers are connected via a preset structure and transmit data; Wherein, a plurality of said multipliers are interconnected and transmit data via a PCIE bus to support larger-scale machine learning operations; The plurality of multipliers share the same control system or have their own control systems; the plurality of multipliers share a memory or have their own memory; the interconnection method of the plurality of multipliers is any interconnection topology.

29. A combined processing device, characterized in that: The combined processing device comprises the machine learning computing device as claimed in claim 28, a universal interconnection interface and other processing devices in the combined processing device except the machine learning computing device; The machine learning operation device interacts with other processing devices in the combined processing device except the machine learning operation device to jointly complete the calculation operation specified by the user.

30. The combined processing device according to claim 29, characterized in that: The combined processing device also includes: a storage device, which is respectively connected to the machine learning operation device and other processing devices in the combined processing device except the machine learning operation device and the storage device, and is used to save data of the machine learning operation device and other processing devices in the combined processing device except the machine learning operation device and the storage device.

31. A neural network chip, characterized in that: The neural network chip includes the machine learning operation device as described in claim 28 or the combined processing device as described in claim 29 or the combined processing device as described in claim 30.

Citation Information

Patent Citations

  • Booth-Wallace tree multiplier

    CN101739231A

  • Structured mixed bit-width multiplying method and structured mixed bit-width multiplying device

    CN102591615A

  • Low-power-consumption multiplier based on 4-Booth coding

    CN110058840A

  • Multiplier, data processing method, chip and electronic equipment

    CN110531954A

  • Data processor, method, chip and electronic equipment

    CN110554854A