Multiplier, data processing method, device and chip

By improving the regular signed number encoding circuit and compression circuit, multiplication operations on data with different bit widths are realized, which solves the problem of low versatility of existing multipliers, improves the versatility and efficiency of the multiplier, and reduces the occupied area.

CN113031916BActive Publication Date: 2024-10-18SHANGHAI CAMBRICON INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN201911351197.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-12-24
Publication Date
2024-10-18
Estimated Expiration
2040-04-06

AI Technical Summary

Technical Problem

Existing multipliers have low versatility when processing data with different bit widths, which results in occupying a large area of ​​the AI ​​​​chip and cannot effectively perform multiplication operations on low bit width data.

Method used

A multiplier is designed, including an improved regular signed number encoding circuit, an intermediate data register and a compression circuit. Through regular signed number encoding processing and accumulation processing, multiplication operations on a variety of data with different bit widths are realized, and the multiplier is improved. of versatility.

Benefits of technology

The multiplier can accurately perform a variety of data multiplication operations with different bit widths, reducing the area occupied by the multiplier on the AI ​​chip, and improving the computing efficiency and the reusability of the multiplier.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113031916B_ABST
    Figure CN113031916B_ABST
Patent Text Reader

Abstract

The present application provides a multiplier, a data processing method, an apparatus and a chip, wherein the multiplier comprises: an improved regular signed number encoding circuit, an intermediate data register, a compression circuit and an output data register; the compression circuit comprises a 4‑2 compressor, and the 4‑2 compressor comprises a full adder and a selection circuit; the output end of the improved regular signed number encoding circuit is connected to the input end of the intermediate data register, the output end of the intermediate data register is connected to the input end of the compression circuit, and the output end of the compression circuit is connected to the input end of the output data register. Under the premise of ensuring the accuracy of the multiplication result, the process can perform multiplication operations on data of various different bit widths, thereby improving the versatility of the multiplier and effectively reducing the area of ​​the AI ​​chip occupied by the multiplier.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a multiplier, a data processing method, a device and a chip. Background Art

[0002] With the continuous development of digital electronic technology, the rapid development of various artificial intelligence (AI) chips has put higher and higher requirements on high-performance digital multipliers. As one of the widely used algorithms in smart chips, neural network algorithms use multipliers for multiplication, which is a common operation in neural network algorithms.

[0003] Generally, when multiplying data of different bit widths, it is necessary to use existing multipliers of the corresponding bit widths for the operation. However, for low-bit-width data operations, existing multipliers that can process high-bit-width data cannot be used for multiplication operations. The versatility of the multiplier is low, resulting in the multiplier occupying a larger area of ​​the AI ​​chip. Summary of the invention

[0004] Based on this, it is necessary to provide a multiplier, a data processing method, a device and a chip to address the above technical problems.

[0005] An embodiment of the present application provides a multiplier, which includes: an improved regular signed number encoding circuit, an intermediate data register, a compression circuit and an output data register; the output end of the improved regular signed number encoding circuit is connected to the input end of the intermediate data register, the output end of the intermediate data register is connected to the input end of the compression circuit, and the output end of the compression circuit is connected to the input end of the output data register; the improved regular signed number encoding circuit is used to perform regular signed number encoding processing on the received data to obtain a target code, and obtain an initial coding partial product according to the target code, the intermediate data register is used to select and access the initial coding partial product, and obtain a target coding partial product according to the accessed initial coding partial product, the compression circuit is used to accumulate the received target coding partial product to obtain a multiplication result, the output data register is used to store the multiplication result, and determine the output target operation result according to the function mode selection signal and the multiplication result.

[0006] In one embodiment, the improved regular signed number encoding circuit, the intermediate data register, the compression circuit and the output data register all include a first input terminal for receiving a functional mode selection signal, and the functional mode selection signal is used to determine the data bit width that the multiplier can currently process.

[0007] In one embodiment, the improved regular signed number encoding circuit comprises: a low-order regular signed number encoding processing unit, a low-order partial product acquisition unit, a selector, a high-order regular signed number encoding processing unit and a high-order partial product acquisition unit; the first output end of the low-order regular signed number encoding processing unit is connected to the input end of the selector, the second output end of the low-order regular signed number encoding processing unit is connected to the 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 regular signed number encoding processing unit, and the output end of the high-order regular signed number encoding processing unit is connected to the input end of the high-order partial product acquisition unit;

[0008] Among them, the low-order regular signed number encoding processing unit is used to perform regular signed number encoding processing on the low-order data in the received first data to obtain the low-order target code, the low-order partial product acquisition unit is used to obtain the initial encoded low-order partial product according to the low-order target code and the received second data, the selector is used to select the padding value when the high-order data in the first data is subjected to regular signed number encoding processing, the high-order regular signed number encoding processing unit is used to perform regular signed number encoding processing on the received high-order data and the padding value to obtain the high-order target code, and the high-order partial product acquisition unit is used to obtain the initial encoded high-order partial product according to the high-order target code and the received second data.

[0009] In one embodiment, the low-order regular signed number encoding processing unit includes: a low-order data input port and a low-order target code output port; the low-order data input port is used to receive the low-order data in the first data to be processed by regular signed number encoding, and the low-order target code output port is used to output the low-order target code obtained after the regular signed number encoding processing is performed on the low-order data.

[0010] In one embodiment, the low-order partial product acquisition unit includes: a low-order target code input port, a second mode selection signal input port, a second 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, the second mode selection signal input port is used to receive the functional mode selection signal, the second data input port is used to receive the second data, and the low-order partial product output port is used to input the initial code low-order partial product into the intermediate data register.

[0011] In one embodiment, the selector includes: a mode selection signal input port, a first selection value input port, a second selection value input port and a selection value output port; the mode selection signal input port is used to receive a functional mode selection signal corresponding to data of different bit widths that the multiplier needs to process, 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 after selection.

[0012] In one of the embodiments, the high-order regular signed number encoding processing unit includes: a high-order data input port and a high-order target code output port; the high-order data input port is used to receive the high-order data in the first data to be subjected to regular signed number encoding processing, and the high-order target code output port is used to output the high-order target code obtained after the regular signed number encoding processing is performed on the high-order data.

[0013] In one embodiment, the high-order partial product acquisition unit includes: a high-order target code input port, a second data input port and a high-order partial product output port; a high-order target code input port, a second mode selection signal input port, a second 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 regular signed number encoding unit, the second mode selection signal input port is used to receive the functional mode selection signal, the second data input port is used to receive data for multiplication operation, and the high-order partial product output port is used to input the initial encoded high-order partial product into the intermediate data register.

[0014] In one embodiment, the intermediate data register includes an intermediate low-order data register and an intermediate high-order data register; the intermediate low-order data register is used to store the value in the initial coding low-order partial product according to the functional mode selection signal to obtain the target coding low-order partial product, and the intermediate high-order data register is used to store the value in the initial coding high-order partial product according to the functional mode selection signal to obtain the target coding high-order partial product.

[0015] In one embodiment, the intermediate low-order data register includes: a mode selection signal input port, a low-order partial product input port, and a target low-order partial product output port, the mode selection signal input port is used to receive the functional mode selection signal, the low-order partial product input port is used to receive the value of the initial encoded low-order partial product according to the functional mode selection signal, and the target low-order partial product output port is used to output the value of the initial encoded low-order partial product received by the intermediate low-order data register according to the functional mode selection signal; the intermediate high-order data register includes: a mode selection signal input port, a high-order partial product input port, and a target high-order partial product output port, the mode selection signal input port is used to receive the functional mode selection signal, the high-order partial product input port is used to receive the value of the initial encoded high-order partial product according to the functional mode selection signal, and the target high-order partial product output port is used to output the value of the initial encoded high-order partial product received by the intermediate high-order data register according to the functional mode selection signal.

[0016] In one embodiment, the compression circuit includes: a Wallace tree group circuit and an accumulation circuit; the output end of the Wallace tree group circuit is connected to the input end of the accumulation circuit, the Wallace tree group circuit is used to accumulate each column value in all target coding partial products obtained when performing operations on data of different bit widths to obtain an accumulation operation result, and the accumulation circuit is used to accumulate the accumulation operation results to obtain the multiplication operation result.

[0017] In one embodiment, the Wallace tree group circuit includes: a Wallace tree unit; wherein the Wallace tree unit 1 is used to perform an accumulation operation on each column value in the target coding partial product to obtain an accumulation operation result.

[0018] In one embodiment, the Wallace tree unit includes a 4-2 compressor and a mode selection unit, the output end of the mode selection unit is connected to the input end of the 4-2 compressor; the 4-2 compressor is used to accumulate each column value in all target coding partial products, and the mode selection unit is used to select the value in the target coding partial product received by the 4-2 compressor; wherein the mode selection unit includes a first input end for receiving the functional mode selection signal.

[0019] In one embodiment, the accumulation circuit includes: an adder, and the adder is used to perform an addition operation on the accumulation operation result.

[0020] In one embodiment, the adder includes: a carry signal input port, a sum signal input port, an operation result output port and a mode selection signal input 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, the operation result output port is used to output the multiplication result obtained by accumulating the carry signal and the sum signal; the mode selection signal input port is used to receive the functional mode selection signal.

[0021] In one embodiment, the output data register includes: a mode selection signal input port, an operation result input port and a target result output port; the mode selection signal input port is used to receive the functional mode selection signal, the operation result input port is used to receive the numerical value in the multiplication operation result according to the functional mode selection signal, and the target result output port is used to output the numerical value in the multiplication operation result received according to the functional mode selection signal as the target operation result.

[0022] A multiplier provided in this embodiment performs regular signed number encoding processing on received data by improving a regular signed number encoding circuit to obtain a partial product after sign bit expansion, obtains an initial encoded partial product based on the partial product after sign bit expansion, accesses the initial encoded partial product through a compression circuit, obtains a target encoded partial product based on the accessed initial encoded partial product, accumulates the received target encoded partial product through the compression circuit to obtain a multiplication result, then stores the multiplication result through an output data register, and determines the output target result based on a function mode selection signal and the multiplication result; the multiplier can perform multiplication operations on data of various bit widths while ensuring the accuracy of the multiplication result, thereby improving the versatility of the multiplier and effectively reducing the area of ​​the AI ​​chip occupied by the multiplier.

[0023] The present application provides a data processing method, the method comprising:

[0024] Receiving data to be processed and a function mode selection signal, wherein the function mode selection signal is used to indicate a data bit width that can be currently processed by the multiplier;

[0025] Selecting the signal to be encoded according to the function mode selection signal, and performing regular signed number encoding processing on the data to be processed according to the signal to be encoded to obtain a target code;

[0026] Obtaining a target code partial product according to the target code and the data to be processed;

[0027] Accumulating the target coded partial products to obtain a multiplication result;

[0028] The multiplication result is stored according to the functional mode selection signal to obtain a target operation result.

[0029] In one embodiment, the step of selecting the signal to be encoded according to the functional mode selection signal, and performing regular signed number encoding processing on the data to be processed according to the signal to be encoded to obtain a target code includes:

[0030] Selecting the signal to be encoded according to the function mode selection signal, and obtaining low-order data to be encoded and high-order data to be encoded according to the signal to be encoded and the data to be processed;

[0031] Regular signed number encoding is performed on the low-order data to be encoded and the high-order data to be encoded to obtain a low-order target code and a high-order target code.

[0032] In one embodiment, obtaining a target code partial product according to the target code and the data to be processed includes:

[0033] According to the low-order target code and the data to be processed, a low-order partial product of the target code is obtained;

[0034] According to the high-order target code and the data to be processed, a high-order partial product of the target code is obtained.

[0035] In one embodiment, obtaining a target code partial product according to the target code and the data to be processed includes:

[0036] Obtaining an original partial product according to the target code and the data to be processed;

[0037] Performing sign bit extension processing on the original partial product to obtain a sign bit extended partial product;

[0038] Obtaining the initial coded partial product according to the input port bit width of the multiplier and the partial product after the sign bit is extended;

[0039] A target coding partial product is obtained according to the functional mode selection signal and the initial coding partial product.

[0040] In one embodiment, performing sign bit extension processing on the original partial product to obtain the sign bit extended partial product includes:

[0041] Performing sign bit extension processing on the original partial products to obtain intermediate partial products;

[0042] The intermediate partial products are subjected to sign bit extension processing to obtain sign bit extended partial products.

[0043] In one embodiment, obtaining the initial coded partial product according to the input port bit width of the multiplier and the partial product after the sign bit is extended includes:

[0044] According to the bit width of the input port of the multiplier, determining whether it is necessary to perform zero padding processing on the partial product after the sign bit extension to obtain the initial coded partial product;

[0045] If necessary, the partial product after the sign bit extension is padded with zeros to obtain the initial encoded partial product.

[0046] In one embodiment, the method further comprises: if it is not necessary to perform zero padding processing on the partial product after the sign bit extension, using the partial product after the sign bit extension as the initial encoded partial product.

[0047] In one embodiment, the step of accumulating the target coded partial products to obtain a multiplication result includes:

[0048] The target code low-order partial product and / or the target code high-order partial product are accumulated by a Wallace tree group circuit to obtain an intermediate operation result;

[0049] The intermediate operation results are accumulated by an accumulation circuit to obtain the multiplication result.

[0050] In one embodiment, storing the multiplication result according to the functional mode selection signal to obtain the target operation result includes: storing the multiplication result or a numerical value in the multiplication result according to the functional mode selection signal to obtain the target operation result.

[0051] A data processing method provided in this embodiment can receive data to be processed and a function mode selection signal, and determine whether the data to be processed needs to be split according to the function mode selection signal. If the data to be processed needs to be split, the data to be processed is split to obtain the split data, and the split data is encoded with a regular signed number to obtain a target code, and a partial product of the target code is obtained according to the target code and the split data, and the partial product of the target code is accumulated to obtain a multiplication result. The method can perform multiplication operations on data of various different bit widths according to the function mode selection signal received by the multiplier, thereby improving the versatility of the multiplier and effectively reducing the area of ​​the AI ​​chip occupied by the multiplier.

[0052] The embodiment of the present application provides a machine learning operation device, which includes one or more multipliers as described above; the machine learning operation device is used to obtain 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;

[0053] 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;

[0054] Among them, multiple multipliers are interconnected and transmit data through a PCIE bus to support larger-scale machine learning operations; multiple multipliers share the same control system or have their own control systems; multiple multipliers share memory or have their own memory; the interconnection method of multiple multipliers is any interconnection topology.

[0055] An embodiment of the present application provides a combined processing device, which includes a machine learning processing device as described above, a universal interconnection interface, and other processing devices in the combined processing device except the machine learning operation 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 user-specified operations; the combined processing device may also include 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.

[0056] An embodiment of the present application provides a neural network chip, which includes the multiplier mentioned above, the machine learning operation device mentioned above, or the combined processing device mentioned above.

[0057] An embodiment of the present application provides a neural network chip packaging structure, which includes the neural network chip described above.

[0058] An embodiment of the present application provides a board card, which includes the neural network chip packaging structure described above.

[0059] An embodiment of the present application provides an electronic device, which includes the neural network chip or the board mentioned above.

[0060] A chip provided in an embodiment of the present application includes at least one multiplier as described in any one of the above items.

[0061] An electronic device provided in an embodiment of the present application includes the chip as described above. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] Figure 1 A schematic diagram of the structure of a multiplier provided by an embodiment;

[0063] Figure 2 A schematic diagram of a specific structure of a multiplier provided in another embodiment;

[0064] Figure 3 A schematic diagram of the specific structure of an improved regular signed number encoding circuit and an intermediate data register provided by another embodiment;

[0065] Figure 4 A schematic diagram of the distribution of the initial code high-order partial product and the initial code low-order partial product obtained by a 4-bit data multiplication operation provided by another embodiment;

[0066] Figure 5 A schematic diagram of the distribution of the initial code high-order partial product and the initial code low-order partial product obtained by a specific 8-bit data multiplication operation of a compression circuit during 8-bit data operation provided by another embodiment;

[0067] Figure 6 A specific circuit structure diagram of a compression circuit and an output data register provided by another embodiment;

[0068] Figure 7 A schematic diagram of a circuit structure of a Wallace tree unit provided in another embodiment;

[0069] Figure 8 A schematic diagram of a specific circuit structure of a compression circuit provided in another embodiment;

[0070] Fig. 9 A schematic diagram of a data processing method flow chart provided by an embodiment;

[0071] Fig.10 A schematic diagram of a specific flow chart for obtaining a target code provided by another embodiment;

[0072] Fig.11 A schematic diagram of a specific flow chart of obtaining a target coding partial product provided by another embodiment;

[0073] Fig.12 A schematic diagram of a specific process of obtaining a multiplication result provided in another embodiment;

[0074] Fig.13 A structural diagram of a combined processing device provided for another embodiment;

[0075] Fig.14 A structural diagram of another combined processing device provided for another embodiment;

[0076] Fig.15 A schematic diagram of the structure of a board provided in another embodiment. DETAILED DESCRIPTION

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

[0078] The multiplier provided in the present application can be applied to an AI chip, a field programmable gate array FPGA (Field-Programmable Gate Array, FPGA) chip, or other hardware circuit devices for multiplication processing. The specific structural diagram is shown in FIG. Figure 1 shown.

[0079] like Figure 1 As shown, Figure 1 FIG. 1 is a structural diagram of a multiplier provided in an embodiment. Figure 1 As shown, the multiplier includes: an improved regular signed number encoding circuit 11, an intermediate data register 12, a compression circuit 13 and an output data register 14; the output end of the improved regular signed number encoding circuit 11 is connected to the input end of the intermediate data register 12, the output end of the intermediate data register 12 is connected to the input end of the compression circuit 13, and the output end of the compression circuit 13 is connected to the input end of the output data register 14; the improved regular signed number encoding circuit 11, the intermediate data register 12, the compression circuit 13 and the output data register 14 all include a first input end for receiving a function mode selection signal. Optionally, the function mode selection signal is used to determine the data bit width that the multiplier can currently process.

[0080] Among them, the improved regular signed number encoding circuit 11 is used to perform regular signed number encoding processing on the received data to obtain the target code, and obtain the initial coding partial product according to the target code, the intermediate data register 12 is used to select and access the initial coding partial product, and obtain the target coding partial product according to the accessed initial coding partial product, the compression circuit 13 is used to accumulate the received target coding partial product to obtain the multiplication result, the output data register 14 is used to store the multiplication result, and determine the output target operation result according to the functional mode selection signal and the multiplication result.

[0081] Optional, continue to see Figure 1 As shown, the improved regular signed number encoding circuit 11 in the multiplier includes an encoding processing branch 111 and a partial product acquisition branch 112; the encoding processing branch 111 is used to perform regular signed number encoding processing on the received data to obtain a target code; the partial product acquisition branch 112 is used to obtain an initial encoded partial product according to the target code.

[0082] Specifically, the above-mentioned improved regular signed number encoding circuit 11 may include two data processing units with different functions, namely, the encoding processing branch 111 and the partial product acquisition branch 112, and the data received by the improved regular signed number encoding circuit 11 can all be fixed-point numbers, and the data can be used as a multiplier in a multiplication operation, and can also be used as a multiplicand in a multiplication operation. Optionally, the encoding processing branch 111 may include a unit with a regular signed number encoding processing function, and the partial product acquisition branch 112 may include a data processing unit with multiple different functions. Optionally, the improved regular signed number encoding circuit 11 can receive data with multiple different bit widths, that is, the multiplier provided in this embodiment can asynchronously process multiplication operations of multiple different bit widths of data. However, during the same multiplication operation, the multiplier and multiplicand received by the improved regular signed number encoding circuit 11 can be data with the same bit width, that is, the bit widths of the multiplier and multiplicand are equal. Illustratively, the multiplier provided in this embodiment can process multiplication operations of data with a bit width of 2 bits, 4 bits, 8 bits, 16 bits, etc., and this embodiment does not impose any limitation on this.

[0083] It should be noted that the above-mentioned improved regular signed number encoding circuit 11 can receive the multiplier and multiplicand in the multiplication operation, and perform regular signed number encoding on the multiplier to obtain the target code, and obtain the initial coding partial product according to the target code and the received multiplicand. The bit width of the initial coding partial product can be equal to twice the bit width of the data currently processed by the multiplier. Exemplarily, a multiplier receives data with a width of 8 bits, and the multiplier can currently process 4-bit data multiplication operations, then the improved regular signed number encoding circuit 11 in the multiplier needs to divide the 8-bit data into two data with a high 4 bits and a low 4 bits, respectively, and perform regular signed number encoding processing, and the bit width of the initial encoded partial product obtained can be equal to twice the bit width of the data received by the multiplier, and the number of initial encoded partial products obtained by the two groups of data with high 4 bits and low 4 bits can be equal to 5, that is, the bit width of the data currently processed by the multiplier plus 1; if the multiplier can currently process 8-bit data multiplication operations, then the improved regular signed number encoding circuit 11 in the multiplier needs to operate on the entire 8-bit data, at this time, the bit width of the initial encoded partial product obtained can be 16 bits, and the number of initial encoded partial products obtained can be equal to 10, that is, the bit width of the data currently processed by the multiplier plus 2. In this embodiment, the above-mentioned regular signed number encoding processing can be characterized as a data processing process encoded by values ​​0, -1 and 1.

[0084] It is understandable that there may be multiple functional mode selection signals (mode signals) mentioned above, and different functional mode selection signals correspond to multiplication operations of different bit width data that the multiplier can currently process. Optionally, during the same multiplication operation, the functional mode selection signals received by the improved regular signed number encoding circuit 11, the intermediate data register 12, the compression circuit 13, and the output data register 14 may all be equal. Optionally, the mode signal and the data bit width that the multiplier can currently process may correspond arbitrarily one-to-one, and this embodiment does not impose any limitation on this. Exemplarily, if the mode signal that the multiplier can receive may be equal to 0 or 1; however, in this embodiment, a mode signal of 0 may indicate that the multiplier can process 4-bit data, and a mode signal of 1 may indicate that the multiplier can process 8-bit data. Exemplarily, if the improved regular signed number encoding circuit 11, intermediate data register 12, compression circuit 13 and output data register 14 are capable of receiving multiple functional mode selection signals, taking three functional mode selection signals as an example, they can be mode=00, mode=01, and mode=10 respectively, then mode=00 can represent that the multiplier can currently process 4-bit data operations, mode=01 can represent that the multiplier can currently process 8-bit data operations, and mode=10 can represent that the multiplier can currently process 16-bit data operations. In addition, mode=00 can also represent that the multiplier can currently process 16-bit data operations, mode=01 can also represent that the multiplier can currently process 4-bit data operations, and mode=10 can represent that the multiplier can currently process 8-bit data operations.

[0085] It should be noted that the improved regular signed number encoding circuit 11 can perform regular signed number encoding processing on the multiplier to obtain the original partial product, then perform sign bit extension processing on the original partial product to obtain the intermediate partial product, then perform sign bit extension processing on the intermediate partial product to obtain the partial product after the sign bit extension, and obtain the initial encoded partial product according to the partial product after the sign bit extension. Optionally, the bit width of the above-mentioned original partial product can be equal to N, and the bit width of the intermediate partial product can be equal to 2 times the bit width N of the data currently processed by the multiplier; the above-mentioned sign bit extension processing can be characterized as a complement sign bit processing of a data, and the complement sign bit value is equal to the highest bit value of the data, that is, the sign bit value; wherein, the high N-bit values ​​of the intermediate partial product can be equal, and the low N-bit values ​​can be equal to the values ​​in the original partial product obtained by the target code and the multiplicand. If the target code and the N-bit multiplicand can obtain the N-bit original partial product, the high N-bit values ​​of the intermediate partial product can be equal to the highest bit value of the original partial product, and the low N-bit values ​​of the intermediate partial product can be equal to the N-bit values ​​of the original partial product.

[0086] It can also be understood that the above-mentioned method of regular signed number encoding processing can be characterized in the following manner: if the data bit width received by the multiplier is 2N, N-bit data can be processed at present, and for an N-bit multiplier, processing is performed from low-bit values ​​to high-bit values. If there are continuous l (l>=2)-bit values ​​1, then the continuous n-bit values ​​1 can be converted and processed into data "1 (0) l-1 (-1)", and the remaining corresponding (Nl)-bit values ​​are combined with the converted (l+1)-bit value to obtain a new data; then the new data is used as the initial data for the next level of conversion processing until there are no continuous l (l>=2)-bit values ​​of 1 in the new data obtained after the conversion processing; wherein, the N-bit multiplier is subjected to regular signed number encoding processing, and the bit width of the obtained target code can be equal to the data bit width 2N plus 2 received by the multiplier). Further, during the regular signed number encoding processing, data 11 can be converted to (100-001), that is, data 11 can be equivalently converted to 10(-1); data 111 can be converted to (1000-0001), that is, data 111 can be equivalently converted to 100(-1); and so on, the conversion processing method of other continuous l (l>=2)-bit values ​​of 1 is similar.

[0087] For example, the multiplier received by the encoding processing branch 111 is "001010101101110", and the first new data obtained after the first level conversion processing on the multiplier is "0010101011100(-1)0", and the second new data obtained after the second level conversion processing on the first new data is "0010101100(-1)00(-1)0", and the third new data obtained after the third level conversion processing on the second new data is "0010110(-1)00(-1)00(-1)0", and the fourth level conversion processing on the third new data is performed. The fourth new data obtained after processing is "00110(-1)0(-1)00(-1)00(-1)00(-1)0", and the fifth new data obtained after continuing to perform the fifth-level conversion processing on the fourth new data is "010(-1)0(-1)0(-1)00(-1)00(-1)00(-1)0". There are no consecutive l (l>=2)-bit values ​​1 in the fifth new data. At this time, the fifth new data can be called the initial code, and after a bit-filling processing is performed on the initial code, the intermediate code representing the regular signed number encoding processing is completed, wherein the bit width of the initial code can be equal to the bit width of the multiplier. Optionally, the encoding processing branch 111 performs regular signed number encoding processing on the multiplier to obtain new data (i.e., initial code); if the highest bit value and the second highest bit value in the new data are "10" or "01", the encoding processing branch 111 can fill the highest bit value of the new data with a single value of 0, and obtain the corresponding intermediate code high three bits of values ​​"010" or "001" respectively. Optionally, the bit width of the above intermediate code can be equal to the bit width of the data currently processed by the multiplier plus 1. In addition, if the data bit width received by the current multiplier is 2N, and the multiplier can currently process N-bit data operations, the encoding processing branch 111 in the multiplier can split the 2N-bit data into two groups of N-bit data for separate data operations. At this time, the two groups of (N+1)-bit intermediate codes obtained can be combined and used as the target code; if the multiplier can currently process 2N-bit data operations, the encoding processing branch 111 in the multiplier can complement the highest bit value of the obtained (2N+1)-bit intermediate code with a single-bit value of 0 (i.e., complement processing), and use the (2N+2)-bit data after complement processing as the target code. Optionally, the target code may include three values, namely -1, 0 and 1. When the value in the target code is -1, the original partial product may be -X, when the value in the target code is 1, the original partial product may be X, and when the value in the target code is 0, the original partial product may be 0, that is, each bit value in the original partial product is equal to 0; wherein X is the multiplicand received by the multiplier, and each value in the target code may obtain a corresponding original partial product.In addition, when all the intermediate partial products are added, the accumulated result may overflow, wherein the overflow bit width m may be greater than or equal to 0; the bit width of the partial product after the sign bit is extended may be equal to the sum of the bit width of the intermediate partial product and the overflow bit width m of all the intermediate partial products when they are added. Optionally, the initial coded partial product may be equal to the partial product after the sign bit is extended, or may be equal to the data obtained by combining the partial product after the sign bit is extended with a multi-bit value of 0. Optionally, the bit width of the initial coded partial product may be equal to twice the bit width of the data received by the multiplier; if the bit width of the partial product after the sign bit is extended is not equal to the bit width of the initial coded partial product, then the partial product after the sign bit is extended is padded with zeros; wherein the zero padding process may be characterized as extending the high bits of the partial product after the sign bit is extended with a value of 0.

[0088] It can also be understood that the intermediate data register 12 can access the initial coding partial product and determine the partial product bit value in the output initial coding partial product, i.e., the target coding partial product, according to the received function mode selection signal. Optionally, the target coding partial product can be equal to the partial product after the sign bit is extended.

[0089] In this embodiment, the compression circuit 13 can be composed of a 4-2 compressor. Optionally, a 4-2 compressor can include multiple full adders and a selection circuit. Under certain conditions, the selection circuit in the 4-2 compressor can control the full adder to be in an off state to improve the efficiency of the Wallace tree group circuit and reduce the delay. Optionally, the selection circuit can be a circuit composed of multiple selectors, the selector can be a two-way selector, and the selection circuit can receive a functional mode selection signal and control the off state of the full adder according to the received functional mode selection signal. Optionally, the bit width of the multiplication result obtained by the above-mentioned compression circuit 13 can be equal to twice the bit width of the data that the multiplier can currently process.

[0090] In addition, the output data register 14 can store the multiplication result obtained by the compression circuit 13, and determine the value in the output multiplication result according to the received function mode selection signal as the target operation result. Optionally, the bit width of the target operation result can be equal to the sum of the bit width of the intermediate partial product and the overflow bit width m of all the intermediate partial products when performing accumulation operation.

[0091] The multiplier provided in this embodiment performs regular signed number encoding processing on received data by improving the regular signed number encoding circuit to obtain the partial product after the sign bit is extended, and obtains the initial encoded partial product according to the partial product after the sign bit is extended, accesses the initial encoded partial product through the compression circuit, and obtains the target encoded partial product according to the accessed initial encoded partial product, accumulates the received target encoded partial product through the compression circuit to obtain the multiplication result, then stores the multiplication result through the output data register, and determines the output target operation result according to the function mode selection signal and the multiplication result; this process can ensure the accuracy of the multiplication result, and can perform multiplication on data of various bit widths. The multiplication operation is performed in rows, which improves the versatility of the multiplier and effectively reduces the area occupied by the multiplier on the AI ​​chip; at the same time, the multiplier can perform regular signed number encoding on the received data by improving the regular signed number encoding circuit, and can obtain a smaller number of effective partial products, thereby reducing the complexity of the multiplier to implement the multiplication operation, improving the operational efficiency of the multiplication operation, and effectively reducing the power consumption of the multiplier; in addition, the above-mentioned multiplier can also store the effective partial products through the intermediate data register to compress the effective partial products to obtain the multiplication result, and then control the output of part of the data in the multiplication result through the output data register to obtain the target operation result, realizing the function of multiplier multiplexing, thereby reducing the power consumption of the multiplier.

[0092] Figure 2 A specific structural diagram of a multiplier is provided for another embodiment, wherein the multiplier includes a coding processing branch 111, the coding processing branch 111 includes a regular signed number coding unit 1111, the partial product acquisition branch 112 includes a low-order partial product acquisition unit 1121 and a high-order partial product acquisition unit 1122; the output end of the regular signed number coding unit 1111 is connected to the input ends of the low-order partial product acquisition unit 1121 and the high-order partial product acquisition unit 1122.

[0093] Among them, the regular signed number encoding unit 1111 is used to determine the bit width of the data that can be processed by the multiplier according to the received functional mode selection signal, and perform regular signed number encoding on the received first data to obtain a high-order target code and a low-order target code, the low-order partial product acquisition unit 1121 is used to obtain the low-order partial product after sign bit extension according to the low-order target code in the received target code and the second data, and obtain the initial encoded low-order partial product according to the low-order partial product after sign bit extension, the high-order partial product acquisition unit 1122 is used to obtain the high-order partial product after sign bit extension according to the high-order target code in the received target code and the second data, and obtain the initial encoded high-order partial product according to the high-order partial product after sign bit extension.

[0094] Specifically, the regular signed number encoding unit 1111 can receive the first data, and perform regular signed number encoding on the first data to obtain the target code, and the first data can be the multiplier in the multiplication operation. Optionally, the low-order partial product acquisition unit 1121 can obtain the low-order target code according to the regular signed number encoding unit 1111, and obtain the low-order partial product after the sign bit is extended by receiving the second data, and obtain the initial coded low-order partial product according to the low-order partial product after the sign bit is extended; the high-order partial product acquisition unit 1122 can obtain the high-order target code according to the regular signed number encoding unit 1111, and obtain the high-order partial product after the sign bit is extended by receiving the second data, and then obtain the initial coded high-order partial product according to the high-order partial product after the sign bit is extended; the second data can be the multiplicand in the multiplication operation. Optionally, if the data bit width received by the regular signed number encoding unit 1111 is 2N, and the data bit width that the multiplier can currently process is N bits, the regular signed number encoding unit 1111 can automatically split the received 2N-bit data into high-N-bit data and low-N-bit data, and perform regular signed number encoding processing on the high-N-bit data and the low-N-bit data respectively. The bit width of the obtained high-order target code is equal to N plus 1, and the bit width of the obtained low-order target code can also be equal to N plus 1; at the same time, the number of high-order partial products of the corresponding sign bit after the high-order target code is expanded can be equal to (N+1), and the number of low-order partial products of the corresponding sign bit after the low-order target code is expanded can be equal to (N+1); if the regular signed number in the multiplier The data bit width received by the signed number encoding unit 1111 is 2N, and the data bit width that the multiplier can currently process is also 2N bits. The improved regular signed number encoding unit 111 can perform regular signed number encoding on the received 2N-bit data to obtain a (2N+1)-bit intermediate code, and it is necessary to complement the value 0 at the upper bit of the highest bit value of the intermediate code, and use this (2N+2)-bit code as the target code, that is, the highest bit value in the target code is 0, and the values ​​contained in the partial products after the sign bit corresponding to the signal 0 is expanded are all 0; among which, the high (N+1)-bit value in the (2N+2)-bit target code can be called the high-bit target code, and the low (N+1)-bit value can be called the low-bit target code.

[0095] It should be noted that the low-order partial product acquisition unit 1121 can obtain the initial coding partial product corresponding to the low-order data according to each low-order target code and the received second data (i.e., the multiplicand). Optionally, the high-order partial product acquisition unit 1122 can obtain the initial coding partial product corresponding to the high-order data according to each high-order target code and the received second data. Optionally, during the regular signed number encoding process, the bit width of the obtained low-order target code can be equal to the bit width of the obtained high-order target code, and can also be equal to the number of initial coding partial products corresponding to the low-order data, and the number of initial coding partial products corresponding to the high-order data. Optionally, the partial product acquisition branch 112 can include (N+1) low-order partial product acquisition units 1121, and can also include (N+1) high-order partial product acquisition units 1122. Optionally, each of the above-mentioned low-order partial product acquisition units 1121 and each high-order partial product acquisition unit 1122 can include 2N value generation subunits, and each value generation subunit can obtain a value in the initial coding partial product. The above N may represent the bit width of data currently processed by the multiplier.

[0096] A multiplier provided in the present embodiment performs regular signed number encoding processing on received data to obtain a target code by improving an improved regular signed number encoding unit in a regular signed number encoding circuit, and obtains an initial coding partial product according to a low-order target code and a high-order target code in the target code by a low-order partial product acquisition unit and a high-order partial product acquisition unit, and then obtains a target coding partial product after accessing the initial coding partial product through an intermediate data register, and then accumulates the target coding partial product to obtain a multiplication result, and finally obtains the multiplication result to obtain a target result. This process can perform multiplication operations on data of various different bit widths under the premise of ensuring the accuracy of the multiplication result, thereby improving the versatility of the multiplier and effectively reducing the area of ​​the AI ​​chip occupied by the multiplier.

[0097] In one embodiment, if Figure 3In order to improve the specific structural diagram of the regular signed number encoding circuit 11 and the intermediate data register 12, the improved regular signed number encoding circuit 11 includes an encoding processing branch 111, the encoding processing branch 111 includes a regular signed number encoding unit 1111, and the regular signed number encoding unit 1111 includes: a first data input port 1111a, a first mode selection signal input port 1111b, a low-order target code output port 1111c and a high-order target code output port 1111d; the first data input port 1111a is used to receive the first data, the first mode selection signal input port 1111b is used to receive the functional mode selection signal, the low-order target code output port 1111c is used to output the low-order target code obtained after the regular signed number encoding processing is performed on the first data, and the high-order target code output port 1111d is used to output the high-order target code obtained after the regular signed number encoding processing is performed on the first data.

[0098] Specifically, during the multiplication operation, the regular signed number encoding unit 1111 can receive the first data through the first data input port 1111a, receive the functional mode selection signal through the first mode selection signal input port 1111b, perform regular signed number encoding processing on the first data to obtain an intermediate code, and determine whether it is necessary to perform complement processing on the intermediate code to obtain a target code according to the received functional mode selection signal, and then output the low-order target code in the target code through the low-order target code output port 1111c, and output the high-order target code in the target code through the high-order target code output port 1111d. It should be noted that the above-mentioned complement processing can be to complement the value 0 at the higher bit of the highest bit value of the intermediate code.

[0099] A multiplier provided in this embodiment can use a regular signed number encoding unit to perform regular signed number encoding processing on received data to reduce the number of effective partial products obtained during the multiplication operation, thereby reducing the complexity of the multiplication operation implemented by the multiplier, improving the operational efficiency of the multiplication operation, and effectively reducing the power consumption of the multiplier; at the same time, the above-mentioned multiplier can perform multiplication operations on data of various different bit widths, thereby improving the versatility of the multiplier and effectively reducing the area occupied by the multiplier on the AI ​​chip.

[0100] As one of the embodiments, Figure 3In order to improve the specific structural diagram of the regular signed number encoding circuit 11 and the intermediate data register 12, the partial product acquisition branch 112 in the improved regular signed number encoding circuit 11 includes a low-order partial product acquisition unit 1121, and the low-order partial product acquisition unit 1121 includes: a low-order target code input port 1121a, a second mode selection signal input port 1121b, a second data input port 1121c and a low-order partial product output port 1121d; the low-order target code input port 1121a is used to receive the low-order target code, the second mode selection signal input port 1121b is used to receive the functional mode selection signal, the second data input port 1121c is used to receive the second data, and the low-order partial product output port 1121d is used to input the initial code low-order partial product to the intermediate data register 12.

[0101] Specifically, the low-order partial product acquisition unit 1121 can receive the low-order target code output by the regular signed number encoding unit 1111 through the low-order target code input port 1121a, and receive the multiplicand in the multiplication operation through the second data input port 1121c. Optionally, the low-order partial product acquisition unit 1121 can obtain the original low-order partial product corresponding to the low-order data according to the received low-order target code and the multiplicand, perform a first sign bit extension process on the original low-order partial product to obtain an intermediate low-order partial product, then perform a second sign bit extension process on the intermediate low-order partial product to obtain a low-order partial product after sign bit extension, and finally determine whether it is necessary to perform zero padding on the low-order partial product after sign bit extension; if the bit width of the low-order partial product after sign bit extension is equal to the bit width of the low-order partial product of the initial code, the low-order partial product acquisition unit 1121 does not need to automatically perform zero padding on the low-order partial product after sign bit extension; if the bit width of the low-order partial product after sign bit extension is smaller than the bit width of the low-order partial product of the initial code, the low-order partial product acquisition unit 1121 needs to automatically perform zero padding on the low-order partial product after sign bit extension, and the number of zero padding bits can be equal to the bit width of the low-order partial product of the initial code minus the bit width of the low-order partial product after sign bit extension. Optionally, the zero padding bit widths corresponding to the first sign bit extension process and the second sign bit extension process may not be equal. Optionally, the low-order partial product acquisition unit 1121 may include 2N value acquisition subunits, each of which may obtain a single-bit value in the initial encoded low-order partial product, where N may represent the data bit width currently processed by the multiplier.

[0102] It should be noted that if the bit width of the multiplicand received by the second data input port 1121c in the low-order partial product acquisition unit 1121 is N, the bit width of the intermediate low-order partial product can be equal to 2N, and the high N-bit values ​​in the intermediate low-order partial product are all the sign bit values ​​in the original low-order partial product, that is, the highest bit value. Optionally, the low-order partial product after the sign bit is extended can be equal to the intermediate low-order partial product, and can also be equal to the data after the intermediate low-order partial product and the sign bit value in the intermediate low-order partial product are combined. Optionally, the bit width of the low-order partial product after the sign bit is extended can be equal to the sum of the bit width of the intermediate low-order partial product and the overflow bit width m of all intermediate partial products when performing accumulation operations; wherein all intermediate partial products can include intermediate low-order partial products and intermediate high-order partial products. Optionally, the bit width of the initial coded low-order partial product can be equal to twice the data bit width L that the multiplier can receive (L>=N). Optionally, if the bit width (i.e., k) of the low-order partial product after the sign bit extension is not equal to 2L, the high bit of the highest bit value in the low-order partial product after the sign bit extension is supplemented with a (2L-k)-bit value of 0, and the initial coded low-order partial product is obtained by combining the value 0 with the low-order partial product after the sign bit extension. Exemplarily, if the low-order partial product acquisition unit 1121 receives a multiplicand X with a bit width of N bits, the low-order partial product acquisition unit 1121 can directly obtain the corresponding intermediate low-order partial product according to the multiplicand X and five types of target codes -2X, 2X, -X, X and 0.

[0103] In this embodiment, the data bit width that the multiplier can receive (i.e., the input port bit width of the multiplier) is equal to 16 bits, and the multiplier can currently process 16-bit data, then the bit width of the initial coded low-order partial product obtained by the low-order partial product acquisition unit 1121 in the multiplier can be equal to 32, and the bit width of the low-order partial product after the sign bit expansion can be equal to 32, and the overflow bit width can be equal to 0 at this time; if the multiplier can currently process 8-bit data, then the sign bit obtained by the low-order partial product acquisition unit 1121 in the multiplier is equal to 0. The bit width of the low-order partial product after the sign bit expansion can be equal to 17, and the overflow bit width can be equal to 1 at this time; if the multiplier can currently process 4-bit data, the bit width of the low-order partial product after the sign bit expansion obtained by the low-order partial product acquisition unit 1121 in the multiplier can be equal to 10, and the overflow bit width can be equal to 2 at this time; if the multiplier can currently process 2-bit data, the bit width of the low-order partial product after the sign bit expansion obtained by the low-order partial product acquisition unit 1121 in the multiplier can be equal to 7, and the overflow bit width can be equal to 3 at this time.

[0104] A multiplier provided in this embodiment, a low-order partial product acquisition unit in the multiplier can obtain an initial code low-order partial product according to each low-order target code, and then process the initial code low-order partial product and the initial code high-order partial product to obtain a multiplication result, and store the multiplication result through an output data register, and obtain a target operation result according to a received functional mode selection signal. This process can ensure the accuracy of the multiplication result and can perform multiplication operations on data of various different bit widths, thereby improving the versatility of the multiplier and effectively reducing the area of ​​the AI ​​chip occupied by the multiplier.

[0105] In one embodiment, if Figure 3 In order to improve the specific structural diagram of the regular signed number encoding circuit 11 and the intermediate data register 12, the improved regular signed number encoding circuit 11 includes a partial product acquisition branch 112, and the high-order partial product acquisition unit 1122 in the partial product acquisition branch 112 includes: a high-order target code input port 1122a, a second mode selection signal input port 1121b, a second data input port 1122c and a high-order partial product output port 1122d; the high-order target code input port 1122a is used to receive the high-order target code output by the regular signed number encoding unit 1111, the second mode selection signal input port 1122b is used to receive the functional mode selection signal, the second data input port 1122c is used to receive data for multiplication operation, and the high-order partial product output port 1122d is used to input the high-order partial product of the initial code to the intermediate data register 12.

[0106] Specifically, the above-mentioned target code may include a low-order target code and a high-order target code; the above-mentioned original partial product may include an original high-order partial product and an original low-order partial product; the above-mentioned intermediate partial product may include an intermediate high-order partial product and an intermediate low-order partial product; the above-mentioned partial product after sign bit extension may include a high-order partial product after sign bit extension and a partial product after sign bit extension; the above-mentioned initial coding partial product may include an initial coding high-order partial product and an initial coding low-order partial product.

[0107] In this embodiment, the high-order partial product acquisition unit 1122 can receive the high-order target code output by the regular signed number encoding unit 1111 through the high-order target code input port 1122a, and can receive the multiplicand in the multiplication operation through the second data input port 1122d. Optionally, the high-order partial product acquisition unit 1122 can obtain the original high-order partial product corresponding to the high-order data according to the received high-order target code and the received multiplicand in the multiplication operation, perform a first sign bit extension process on the original high-order partial product to obtain an intermediate high-order partial product, and then perform a second sign bit extension process on the intermediate high-order partial product to obtain the high-order partial product after sign bit extension, and finally determine whether it is necessary to perform zero padding on the high-order partial product after sign bit extension; if the bit width of the high-order partial product after sign bit extension is equal to the bit width of the high-order partial product of the initial code, the high-order partial product acquisition unit 1122 does not need to automatically perform zero padding on the high-order partial product after sign bit extension; if the bit width of the low-order partial product after sign bit extension is smaller than the bit width of the high-order partial product of the initial code, the high-order partial product acquisition unit 1122 needs to automatically perform zero padding on the high-order partial product after sign bit extension, and the number of zero padding bits can be equal to the bit width of the high-order partial product of the initial code minus the bit width of the high-order partial product after sign bit extension. Optionally, the zero padding bit widths corresponding to the first sign bit extension process and the second sign bit extension process may not be equal. Optionally, the high-order partial product acquisition unit 1122 may include 2N value acquisition subunits, each of which may obtain a single-bit value in the initial encoded high-order partial product, where N may represent the data bit width currently processed by the multiplier.

[0108] Exemplarily, if the multiplier can receive 8-bit data and the multiplier can currently process 4-bit data multiplication, then the current multiplier can process 4-bit*4-bit high-order data multiplication and 4-bit*4-bit low-order data multiplication. The multiplier obtains 5 initial coded high-order partial products and 5 initial coded low-order partial products by improving the regular signed number encoding circuit 11 as follows: Figure 4 As shown, "○" represents the invalid bit value in the initial coding partial product, that is, the value 0, represents the value of each bit in the initial code high-order partial product, and "●" represents the value of each bit in the initial code low-order partial product; if the multiplier can currently process 8-bit*8-bit data multiplication operations, the multiplier obtains 5 initial code low-order partial products and 5 initial code high-order partial products by improving the regular signed number encoding circuit 11 as follows: Figure 5 As shown, "●" represents the value of each bit in the initial code high-order partial product, and "●" represents the value of each bit in the initial code low-order partial product.

[0109] A multiplier provided in this embodiment, wherein a high-order partial product acquisition unit in the multiplier can obtain a high-order partial product of a target code according to each high-order target code, and the high-order partial product acquisition unit can obtain a high-order partial product of an initial code according to the high-order target code, and then process the high-order partial product of the initial code and the low-order partial product of the initial code to obtain a target operation result. This process can perform multiplication operations on data of various different bit widths while ensuring the accuracy of the multiplication operation result, thereby improving the versatility of the multiplier and effectively reducing the area of ​​the AI ​​chip occupied by the multiplier.

[0110] As one of the embodiments, Figure 3 In order to improve the specific structural diagram of the regular signed number encoding circuit 11 and the intermediate data register 12, the intermediate data register 12 includes an intermediate low-order data register 121 and an intermediate high-order data register 122; the intermediate low-order data register 121 is used to store the value in the initial encoding low-order partial product according to the functional mode selection signal to obtain the target encoding low-order partial product, and the intermediate high-order data register 122 is used to store the value in the initial encoding high-order partial product according to the functional mode selection signal to obtain the target encoding high-order partial product.

[0111] Continue to see Figure 3 , wherein the intermediate low-order data register 121 includes: a mode selection signal input port 1211, a low-order partial product input port 1212, and a target low-order partial product output port 1213, wherein the mode selection signal input port 1211 is used to receive the functional mode selection signal; the low-order partial product input port 1212 is used to receive the value of the initial coded low-order partial product according to the functional mode selection signal; the target low-order partial product output port 1213 is used to output the value of the initial coded low-order partial product received by the intermediate low-order data register 121 according to the functional mode selection signal. Optionally, continue to refer to Figure 3 As shown, the intermediate high-order data register 122 includes: a mode selection signal input port 1221, a high-order partial product input port 1222 and a target high-order partial product output port 1223, wherein the mode selection signal input port 1221 is used to receive the functional mode selection signal; the high-order partial product input port 1222 is used to receive the value of the initial coded high-order partial product according to the functional mode selection signal; the target high-order partial product output port 1223 is used to output the value of the initial coded high-order partial product received by the intermediate high-order data register 122 according to the functional mode selection signal.

[0112] Specifically, the intermediate data register 12 may include N / 4 intermediate low-order data registers 121, where N is the data bit width that the multiplier can receive. Optionally, the intermediate low-order data register 121 may include 2N consecutive low-order register units, each of which may store a single-bit value in the initial coded low-order partial product, and the consecutive 2N low-order register units may store 2N-bit initial coded low-order partial products. Optionally, the 2N low-order register units may all receive a function mode selection signal; if the function mode selection signal received by the low-order register unit in the multiplier determines that the multiplier can currently process N-bit data operations, the intermediate low-order data register 121 may receive the initial coded low-order partial product through the low-order partial product input port 1212, and store the 2N-bit initial coded low-order partial product as the target coded low-order partial product through the consecutive 2N low-order register units, and the target coded low-order partial product may be output through the target low-order partial product output port 1213, which is equivalent to the 2N low-order register units being in the on state. ; If the function mode selection signal received by the low-order register unit in the multiplier determines that the multiplier can currently process N / 2-bit data operations, then some of the 2N low-order register units can receive partial bit values ​​in the initial coded low-order partial product as the target coded low-order partial product, and the partial product value can be the low-order partial product after the sign bit is extended. At this time, it is equivalent to that some of the 2N low-order register units are in the turned-on state; the number of all low-order register units in the turned-on state can be equal to the bit width of the low-order partial product after the sign bit is extended, and the remaining low-order register units in the 2N low-order register units are in the turned-off state.

[0113] It should be noted that the intermediate data register 12 may include N / 4 intermediate high-order data registers 122, where N is the data bit width that the multiplier can receive. Optionally, the intermediate high-order data register 122 may include 2N consecutive high-order register units, each of which may store a single-bit value in the initial coded high-order partial product, and the consecutive 2N high-order register units may store a 2N-bit initial coded high-order partial product. Optionally, the 2N high-order register units may all receive a function mode selection signal; if the function mode selection signal received by the high-order register unit in the multiplier determines that the multiplier can currently process N-bit data operations, the intermediate high-order data register 122 may receive the initial coded high-order partial product through the high-order partial product input port 1212, and store the 2N-bit initial coded high-order partial product as the target coded high-order partial product through the consecutive 2N high-order register units, and the target coded high-order partial product may be output through the target high-order partial product output port 1213, which is equivalent to the 2N high-order register units being all in the open state. state; if the function mode selection signal received by the high-order register unit in the multiplier determines that the multiplier can process N / 2-bit data operations, then some of the 2N high-order register units can receive the partial bit value in the initial coded high-order partial product as the target coded high-order partial product, and the partial product value can be the high-order partial product after the sign bit is extended, which is equivalent to some of the 2N high-order register units being in the open state; the number of all open high-order register units can be equal to the bit width of the high-order partial product after the sign bit is extended, and the remaining high-order register units in the 2N high-order register units are in the closed state. Optionally, the register unit can automatically control its own closed state according to the received function mode selection signal.

[0114] In the present embodiment, the distribution mode of all target coding low-order partial products can be characterized as follows: starting from the second target coding low-order partial product, the highest bit value in each target coding low-order partial product is located in the same column as the highest bit value in the first target coding low-order partial product, that is, the value in each target coding low-order partial product is located in the same column as the corresponding bit value in the first target coding low-order partial product, and each column of values ​​in all target coding low-order partial products participates in subsequent operations. Optionally, the distribution mode of all target coding high-order partial products is the same as the distribution mode of all target coding low-order partial products, which will not be described in detail. In addition, after all target coding low-order partial products are combined with all target coding high-order partial products, the target coding partial products can be obtained.

[0115] A multiplier provided in this embodiment, wherein an intermediate register in the multiplier can store part of the numerical value in the initial coding partial product as the target coding partial product, and then perform subsequent processing on the target coding partial product to obtain a target operation result; this process can control the shutdown state of part of the register units in the intermediate register according to the received functional mode selection signal, thereby reducing the power consumption of the multiplier.

[0116] As one of the embodiments, Figure 6 The specific structural diagram of the compression circuit 13 and the output data register 14 is shown, wherein the compression circuit 13 includes: a Wallace tree group circuit 131 and an accumulation circuit 132, the output end of the Wallace tree group circuit 131 is connected to the input end of the accumulation circuit 132; the Wallace tree group circuit 131 is used to accumulate each column value in all target coding partial products obtained when performing operations on data of different bit widths to obtain an accumulation operation result, and the accumulation circuit 132 is used to accumulate the accumulation operation result to obtain the multiplication operation result.

[0117] Specifically, the above-mentioned Wallace tree group circuit 131 can perform accumulation processing on each column value in the target coding partial product obtained by the improved regular signed number encoding circuit 11, and accumulate the two operation results obtained by the Wallace tree group circuit 131 through the accumulation circuit 132 to obtain the multiplication result. It should be noted that the number of columns of all target coding partial products can be equal to the bit width of the partial product after the sign bit is extended. Optionally, if the data bit width that the multiplier can receive is N, and the data bit width that the multiplier can currently process is N, then the Wallace tree group circuit 131 can use the target coding low-order partial product and the target coding high-order partial product as the target coding partial product for accumulation operation; and if the data bit width that the multiplier can currently process is N / 2, then the multiplier can asynchronously obtain two groups of target coding partial products, and then the multiplier can perform accumulation operation on the two groups of target coding partial products respectively through the Wallace tree group circuit 131.

[0118] A multiplier provided in this embodiment can perform accumulation processing on target coded partial products through a Wallace tree group circuit, and perform accumulation processing on the accumulation result again through an accumulation circuit to obtain a multiplication operation result, and then obtain a target operation result according to the multiplication operation result; this process can perform multiplication operations on data of various different bit widths, thereby improving the versatility of the multiplier and 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 the multiplier is small, thereby reducing the complexity of the multiplier to implement multiplication operations, improving the operation efficiency of the multiplication operations, and effectively reducing the power consumption of the multiplier.

[0119] In one embodiment, if Figure 6The specific structural diagram of the compression circuit 13 and the output data register 14 is shown, wherein the compression circuit 13 includes a Wallace tree group circuit 131, and the Wallace tree group circuit 131 includes: a plurality of Wallace tree units 1311; wherein the plurality of Wallace tree units 1311 are used to perform accumulation operation on each column value in the target coding partial product to obtain an accumulation operation result.

[0120] Optionally, the Wallace tree unit 1311 includes a 4-2 compressor and a selection mode unit, the output end of the selection mode unit is connected to the input end of the 4-2 compressor; the 4-2 compressor is used to accumulate each column value in all target coding partial products, and the selection mode unit is used to select the value in the target coding partial product received by the 4-2 compressor; wherein the selection mode unit includes a first input end for receiving the function selection mode signal.

[0121] Specifically, each Wallace tree unit 1311 can be implemented by a combination of multiple 4-2 compressors and a selection mode circuit; in addition, it can also be understood that the multiple 4-2 compressors in each Wallace tree unit 1311 can process multi-bit input signals and add the multi-bit input signals to obtain a circuit with two output signals; at the same time, the circuit structure of each 4-2 compressor can be implemented by a combination of two full adders. Optionally, the Wallace tree group circuit 131 may include multiple low-order Wallace tree units and multiple high-order Wallace tree units; wherein the number of high-order Wallace tree units may be equal to the data bit width N currently received by the multiplier, and may also be equal to the number of low-order Wallace tree units, and each low-order Wallace tree unit may be connected in series, and each high-order Wallace tree unit may also be connected in series. Optionally, the output end of the last low-order Wallace tree unit is connected to the input end of the first high-order Wallace tree unit. It is understandable that each Wallace tree unit 1311 in the Wallace tree group circuit 131 can receive a function selection mode signal. Optionally, the number of Wallace tree units 1311 in the Wallace tree group circuit 131 can be equal to twice the data bit width that the multiplier can receive, and each Wallace tree unit 1311 can be connected in series. Optionally, each Wallace tree unit 1311 in the Wallace tree group circuit 131 can perform an addition operation on one column of values ​​in all target coding partial products; each Wallace tree unit 1311 can output two signals, namely, a carry signal Carry. i and a sum signal Sum i; Wherein, i may represent the number corresponding to each Wallace tree unit 1311, and the number of the first Wallace tree unit 1311 is 0. Optionally, the number of input signals received by each Wallace tree unit 1311 may be equal to the number of target coding partial products. Optionally, each Wallace tree unit 1311 may automatically control its own opening state according to the received function selection mode signal.

[0122] Exemplarily, if the data bit width that the multiplier can receive is N, and the multiplier can currently process N-bit data multiplication operations, at this time, the bit width of the target coding partial product obtained by the multiplier can be equal to 2N, the number of Wallace tree units 1311 in the Wallace tree group circuit 131 can be equal to 2N, and each Wallace tree unit 1311 can perform accumulation operations on the corresponding column values ​​in all target coding partial products; the lowest column value in all target coding partial products corresponds to number 0, and the highest column value corresponds to number 2N-1; the corresponding numbers i from the first Wallace tree unit 1311 to the last Wallace tree unit 1311 can be expressed as 0, 1, ..., 2N-1 respectively; the first Wallace tree unit 1311 numbered 0 among the 2N Wallace tree units 1311 can perform accumulation operations on the lowest column values ​​in all target coding partial products, The other column values ​​in all target coding partial products can be sequentially accumulated through the corresponding Wallace tree units 1311. In this case, the 2N Wallace tree units 1311 in the Wallace tree group circuit 131 are all in the on state; if the multiplier can currently process N / 2-bit data multiplication operations, some of the 2N Wallace tree units 1311 are in the on state, and some of the Wallace tree units 1311 starting from the Wallace tree unit 1311 corresponding to number 0 are in the on state, and the number of Wallace tree units 1311 that remain in the on state can be equal to the bit width of the target coding partial product, and the remaining Wallace tree units 1311 in the 2N Wallace tree units 1311 are in the off state. At this time, the result output by the Wallace tree group circuit 131 is the result output by the last Wallace tree unit 1311 that is in the on state.

[0123] It should be noted that the signal received by each Wallace tree unit 1311 in the Wallace tree group circuit 131 may include the carry input signal Cin i , partial product value input signal, carry output signal Cout i Optionally, the partial product value input signal received by each Wallace tree unit 1311 may be the value of the corresponding column in all target coded partial products; the carry signal Cout output by each Wallace tree unit 1311 i The number of digits can be N Cout =floor((N I +N Cin) / 2)-1. Among them, N I The number of partial product value input signals that can represent this Wallace tree unit, N Cin It can represent the number of carry input signals of the Wallace tree unit, N Cout can represent the minimum number of carry output signals of the Wallace tree unit, and floor(·) can represent a floor function. Optionally, the carry input signal received by each Wallace tree unit 1311 in the Wallace tree group circuit 131 can be the carry output signal output by the previous Wallace tree unit 1311, and the carry number input signal received by the first Wallace tree unit 1311 is a value of 0.

[0124] In addition, each Wallace tree unit can select one of the bit values ​​in the corresponding column of all target coding partial products through the selection mode circuit in the circuit structure, and input the bit value to the full adder in the 4-2 compressor to select the low-level signal, so that the input signal of the full adder is a low-level signal, which is equivalent to turning off the full adder.

[0125] For example, in neural network operations, there are relatively many data that are zero or close to zero in the neural network operation data, and after being sparsely processed and / or compressed, there are more data that are zero or close to zero. After a large amount of data in the neural network operation data is converted into binary data, a multiplier can perform two data operations with different bit widths on the converted binary data, namely 8-bit bit width data (corresponding to mode=00) and 16-bit bit width data (corresponding to mode=11), and the multiplier and multiplicand received by the multiplier are both 8-bit bit width data. The circuit structure diagrams of multiple Wallace tree units in the multiplier can be found in Figure 7 As shown in the figure, ~mode represents the inversion of the mode signal. For example, if mode is a high-level signal, ~mode is a low-level signal, and if mode is a low-level signal, ~mode is a high-level signal. In addition, whether the multiplier performs 8-bit wide data operation or 16-bit wide data operation, 18 target coding partial products can be obtained. One column of the values ​​in all target coding partial products is I0, I1, I2, I3, I4, I5, I6, I7, I8, I9, I 10 , I 11 , I 12 , I 13 , I 14 , I 15 , I 16 , I 17 In this example, the multiplier can determine whether the value of the target coded partial product received by the first selection mode circuit in the Wallace tree unit is I7 or I through the received mode signal. 13, to ensure that the signal input to the sixth full adder by the first selection mode circuit is a low level signal; in addition, the multiplier can also determine whether the value of the target coded partial product received by the second selection mode circuit in the Wallace tree unit is I6 or I through the received mode signal. 12 , to ensure that the signal input to the eighth full adder by the second selection mode circuit is a low level signal. In the example, the multiplier can determine the selection signal I7 or I8 that the first selection mode circuit can receive according to the received mode signal. 13 , if mode=00, the first selection mode circuit can select I 13 As the input of the sixth full adder, I7 is selected as the input of the fifth full adder; if mode = 11, the first selection mode circuit can select I7 as the input of the sixth full adder, select I 13 As the input of the fifth full adder; in addition, the multiplier can also determine the selection signal I6 or I that the second selection mode circuit can receive according to the received mode signal 12 , if mode=00, the second selection mode circuit can select I 12 As the input of the eighth full adder, I6 is selected as the input of the seventh full adder; if mode = 11, the second selection mode circuit can select I6 as the input of the eighth full adder, select I 12 As the input of the seventh full adder.

[0126] A multiplier provided in this embodiment can accumulate target coded partial products through a Wallace tree group circuit to obtain two output signals, and accumulate the two output signals again through an accumulation circuit to obtain a multiplication result, and then obtain a target operation result based on the multiplication result. This process can perform multiplication operations on data of various different bit widths, thereby improving the versatility of the multiplier and effectively reducing the area of ​​the AI ​​chip occupied by the multiplier; at the same time, the multiplier can also accumulate fewer effective partial products to reduce the complexity of the multiplication operation.

[0127] Continue to see Figure 6 As shown, Figure 6 Detailed circuit diagram of the compression circuit 13 and the output data register 14, wherein the accumulation circuit 132 in the compression circuit 13 comprises: an adder 1321, and the adder 1321 is used to perform an addition operation on the accumulation operation result.

[0128] Specifically, the adder 1321 may be a carry adder with different bit widths. Optionally, the adder 1321 may receive two signals output by the Wallace tree group circuit 131, perform addition operations on the two output signals, and output a multiplication operation result. In this embodiment, the adder 1321 may be a Z-bit carry-lookahead adder, where Z may be equal to twice the data bit width that the multiplier can receive. Optionally, if the bit width of the cumulative operation result is equal to Z, the adder 1321 may directly perform an addition operation on the cumulative operation result; if the bit width of the cumulative operation result is less than Z, the adder 1321 may automatically perform zero padding on the cumulative operation result, and the zero padding position may be a higher bit of the highest bit value in the cumulative operation result, and the number of zero padding bits may be equal to Z minus the bit width of the cumulative operation result.

[0129] A multiplier provided in this embodiment can perform accumulation processing on two signals output by a Wallace tree group circuit through an accumulation circuit to obtain a multiplication result, and then the output data register in the multiplier receives a partial bit value in the multiplication result according to a function selection mode signal to obtain a target operation result; this process can perform multiplication operations on data of various different bit widths, thereby improving the versatility of the multiplier and effectively reducing the area of ​​the AI ​​chip occupied by the multiplier.

[0130] In one embodiment, see Figure 6 As shown, Figure 6 It is a specific circuit structure diagram of the compression circuit 13 and the output data register 14, wherein the adder 1321 in the compression circuit 13 includes: a carry signal input port 1321a, a sum signal input port 1321b, an operation result output port 1321c and a selection mode signal input port 1321d; the carry signal input port 1321a is used to receive a carry signal, the sum signal input port 1321b is used to receive a sum signal, and the operation result output port 1321c is used to output the multiplication result obtained by accumulating the carry signal and the sum signal; the selection mode signal input port 1321d is used to receive the function selection mode signal.

[0131] Specifically, the adder 1321 can receive the carry signal Carry output by the Wallace tree group circuit 131 through the carry signal input port 1321a, receive the sum signal Sum output by the Wallace array circuit 131 through the sum signal input port 1321b, and accumulate the carry signal Carry and the sum signal Sum, and output the result through the operation result output port 1321c.

[0132] It should be noted that, during the multiplication operation, the data bit width that the multiplier can receive is N, the data bit width that can be processed currently is N, and the multiplier can use adders 1321 with different bit widths to perform addition operation on the carry output signal Carry and the sum output signal Sum output by the Wallace tree group circuit 131. Optionally, each Wallace tree unit 1311 in the Wallace tree group circuit 131 can output a carry output signal Carry. i , and a sum output signal Sum i (i=1, ..., 2N, i is the corresponding number of each Wallace tree unit 1311, and the numbering starts from 1). Optionally, the Carry received by the adder 1321 is 2N-1 ], 0}, that is, the bit width of the carry output signal Carry received by the adder 1321 is 2N, and the first 2N-1 bits of the carry output signal Carry correspond to the carry output signals of the first 2N-1 Wallace tree units 1311 in the Wallace tree group circuit 131, and the last bit of the carry output signal Carry can be replaced by the value 0. Optionally, the bit width of the sum output signal Sum received by the adder 1321 is 2N, and the value in the sum output signal Sum can be equal to the sum output signal of each Wallace tree unit 1311 in the Wallace tree group circuit 131. If the multiplier can currently process N / 2 bits of data, the Carry received by the adder 1321 = {[Carry1: Carry N -1], 0}; however, since the adder 1321 operates on 2N-bit data, at this time, the adder 1321 also needs to fill the higher bits of the carry output signal Carry with zeros to satisfy the data bit width after the zero-filling process of 2N.

[0133] For example, if the data bit width that the multiplier can receive is 8, and the multiplier can currently process 8-bit*8-bit fixed-point multiplication operations, then the adder 1321 can be a 16-bit carry-lookahead adder, such as Figure 8 As shown is a specific structural schematic diagram, in which the Wallace tree group circuit 131 in the compression circuit 13 can output the sum output signal Sum and the carry output signal Carry of 16 Wallace tree units 1311, but the sum output signal received by the 16-bit carry adder can be the complete sum signal Sum output by the Wallace tree group circuit 131, and the received carry output signal can be all carry output signals in the Wallace tree group circuit 131 except the carry output signal output by the last Wallace tree unit 1311, and the carry signal Carry after being combined with the value 0.

[0134] A multiplier provided in this embodiment can perform accumulation operation on two signals output by the Wallace tree group circuit through an accumulation circuit to obtain a multiplication result, and then the output data register in the multiplier receives part of the bit values ​​in the multiplication result according to the function selection mode signal to obtain the target operation result; this process can perform multiplication operation on data of various different bit widths, thereby improving the versatility of the multiplier and effectively reducing the area of ​​the AI ​​chip occupied by the multiplier.

[0135] As one of the embodiments, Figure 6 The figure shows a specific circuit structure diagram of the compression circuit 13 and the output data register 14, wherein the output data register 14 includes: a mode selection signal input port 141, an operation result input port 142 and a target result output port 143, the mode selection signal input port 141 is used to receive the functional mode selection signal, the operation result input port 142 is used to receive the numerical value in the multiplication operation result according to the functional mode selection signal, and the target result output port 143 is used to output the numerical value in the multiplication operation result received according to the functional mode selection signal as the target operation result.

[0136] Specifically, the output data register 14 may include 2N consecutive register units, where N is the data bit width that the multiplier can receive. Optionally, each register unit may store a single-bit value in the multiplication result, and the consecutive 2N register units may store a 2N-bit multiplication result. Optionally, all 2N register units can receive a function mode selection signal; if the function mode selection signal received by the register unit in the multiplier determines that the multiplier can currently process N-bit data operations, the output data register 14 can receive the multiplication result through the operation result input port 142, and store the 2N-bit multiplication result as the target operation result through 2N consecutive register units therein, and the target operation result can be output through the target result output port 143, which is equivalent to that all 2N register units are in an open state; if the function mode selection signal received by the register unit in the multiplier determines that the multiplier can currently process N / 2-bit data operations, some of the N register units can receive partial bit values ​​in the multiplication result as the target operation result, and the bit width of the partial product value can be the low n bit values ​​in the multiplication result, and n can be equal to the sum of N and the overflow bit width m of all intermediate partial products during the accumulation operation, which is equivalent to that the corresponding n register units in the 2N low-order register units are in an open state, and the remaining register units in the 2N register units are in a closed state.

[0137] This embodiment provides a multiplier, in which an output data register receives a partial bit value in a multiplication result according to a function mode selection signal to obtain a target operation result, so as to realize the function of multiplexing the multiplier, thereby reducing the power consumption of the multiplier.

[0138] Fig. 9 A flowchart of a data processing method provided by an embodiment, the method can be Figure 1 and Figure 2 The multiplier shown in FIG. 1 is used for processing. This embodiment relates to the process of performing multiplication operations on data of different bit widths. Fig. 9 As shown, the method includes:

[0139] S101. Receive data to be processed and a function mode selection signal, wherein the function mode selection signal is used to indicate a bit width of currently processable data.

[0140] Specifically, the multiplier can receive the data to be processed by improving the regular signed number encoding circuit, and the data to be processed can be the multiplier and the multiplicand in the multiplication operation. During each multiplication operation, the multiplier can also receive different functional mode selection signals through the improved regular signed number encoding circuit, the intermediate data register, the compression circuit, and the output data register; however, during the same operation, the functional mode selection signals received by the improved regular signed number encoding circuit, the intermediate data register, the compression circuit, and the output data register can be the same. If the multiplier receives different functional mode selection signals, the multiplier can process data operations with different bit widths.

[0141] It should be noted that if the bit width of the to-be-processed multiplier and the to-be-processed multiplicand received by the improved regular signed number encoding circuit is not equal to the data bit width that can be processed corresponding to the function mode selection signal received by the multiplier, then the multiplier can divide the received data to be processed into multiple groups of data equal to the data bit width that can be processed by the multiplier according to the data bit width that can be processed by the multiplier at present for asynchronous processing; wherein, the bit width of the to-be-processed data received by the improved regular signed number encoding circuit can be greater than the data bit width that can be processed by the multiplier at present. Optionally, the above-mentioned asynchronous processing can be characterized as processing each group of to-be-processed data after division in sequence. If the bit width of the to-be-processed data received by the improved regular signed number encoding circuit is equal to the data bit width that can be processed corresponding to the function mode selection signal received by the multiplier, then the multiplier directly processes the received data to be processed. Optionally, the above-mentioned data to be processed can include high-order data to be processed and low-order data to be processed. If the bit width of the data to be processed is 2N, the upper N bits of data may be referred to as the high-bit data to be processed, and the lower N bits of data may be referred to as the high-bit data to be processed.

[0142] Optionally, the bit widths of the to-be-processed multiplier and the to-be-processed multiplicand received by the improved regular signed number encoding circuit may be 4 bits, 8 bits, 16 bits, 32 bits, or 64 bits, which are not limited in this embodiment. The bit width of the to-be-processed multiplier may be equal to the bit width of the to-be-processed multiplicand.

[0143] Exemplarily, if the functional mode selection signals received by the improved regular signed number encoding circuit, the intermediate data register, the compression circuit, and the output data register can be equal to 0 and 1, they can also be expressed in other forms; however, in this embodiment, a mode signal of 0 can represent that the multiplier can currently process 4-bit data operations, and a mode signal of 1 can represent that the multiplier can currently process 8-bit data operations.

[0144] S102: judging whether the data to be processed needs to be split according to the function mode selection signal.

[0145] Specifically, the multiplier can determine the data bit width that can be processed by the current multiplier according to the received function mode selection signal to determine whether the data to be processed needs to be split. The splitting process can be characterized as dividing the data to be processed into multiple groups of data with the same bit width.

[0146] Optionally, the step of determining whether the data to be processed needs to be split according to the functional mode selection signal in the above S102 may include: determining whether the bit width of the data to be processed is equal to the data bit width that can be processed by the multiplier according to the functional mode selection signal.

[0147] It should be noted that the above-mentioned determination of whether the data to be processed needs to be split according to the functional mode selection signal can actually be understood as determining whether the bit width of the data to be processed is equal to the data bit width that can be processed by the multiplier according to the functional mode selection signal; if they are equal, the data to be processed does not need to be split, otherwise, the data to be processed needs to be split.

[0148] S103: If the data to be processed needs to be split, split the data to be processed to obtain split data.

[0149] Optionally, after the step S102 of determining whether the data to be processed needs to be split according to the functional mode selection signal, the method further includes: if the data to be processed does not need to be split, continuing to perform regular signed number encoding processing on the data to be processed to obtain the target code.

[0150] Specifically, if the bit widths of the multiplier and the multiplicand in the multiplication operation received by the improved regular signed number encoding circuit in the multiplier are not equal to the bit width of the data that can be processed corresponding to the function mode selection signal received by the multiplier, then the multiplier can automatically divide the received data to be processed into multiple groups of data equal to the bit width of the data that can be processed by the multiplier according to the bit width of the data that can be processed currently by the multiplier for asynchronous processing; wherein the bit width of the data to be processed received by the improved regular signed number encoding circuit can be greater than the bit width of the data that can be processed currently by the multiplier. If the bit width of the data to be processed received by the improved regular signed number encoding circuit is equal to the bit width of the data that can be processed corresponding to the function mode selection signal received by the multiplier, then the multiplier directly performs subsequent processing on the complete data to be processed, and there is no need to split the data to be processed before performing subsequent processing.

[0151] It should be noted that if the bit width of the data to be processed received by the multiplier is 2N, and the bit width of the currently processable data is 2N, the regular signed number encoding unit in the multiplier can perform regular signed number encoding processing on the complete 2N-bit data to obtain the corresponding target code. The above-mentioned regular signed number encoding processing can be characterized as a data processing process encoded by the values ​​0, -1 and 1.

[0152] At the same time, if the complete 2N-bit data is directly processed by regular signed number encoding, the high N-bit data can be called high-order data, and the low N-bit data can be called low-order data; in this embodiment, the split data can include the high-order data and the low-order data in the data to be processed.

[0153] S104, performing regular signed number encoding processing on the split data to obtain a target code.

[0154] Specifically, if the bit width of the data to be processed received by the multiplier is 2N, and the bit width of the data that the multiplier can currently process is N, the regular signed number encoding unit in the multiplier can automatically split the 2N-bit data into high-N-bit data and low-N-bit data, and then perform regular signed number encoding processing on the high-N-bit data and the low-N-bit data respectively to obtain the corresponding high-order target code and low-order target code. Optionally, the above-mentioned data to be processed can include high-N-bit data to be processed and low-N-bit data to be processed after splitting. Among them, if the bit width of the data to be processed is 2N, the high N bits can be called the high-order data to be processed, and the low N bits can be called the high-order data to be processed.

[0155] S105. Obtain a target code partial product according to the target code and the split data.

[0156] Specifically, the target code may be a low-order target code and a high-order target code. Optionally, the bit width of the target code partial product may be equal to twice the bit width of the input port of the multiplier, or may be less than twice the bit width of the input port of the multiplier. Optionally, the number of the target code partial products may be equal to the bit width of the target code.

[0157] Optionally, the step of obtaining the target code partial product according to the target code and the data to be processed in the above S105 may include: obtaining the target code low-order partial product according to the low-order target code and the data to be processed; and obtaining the target code high-order partial product according to the high-order target code and the data to be processed.

[0158] It should be noted that the improved regular signed number encoding circuit in the multiplier can obtain the low-order partial product of the target code according to the low-order target code and the multiplicand to be processed, and can also obtain the high-order partial product of the target code according to the high-order target code and the multiplicand to be processed.

[0159] S106: Accumulate the target coded partial products to obtain a multiplication result.

[0160] Specifically, the multiplier can perform accumulation processing on the target coded partial products through the compression circuit and obtain a multiplication result. Optionally, the bit width of the multiplication result can be equal to twice the bit width of the input port of the multiplier.

[0161] S107. Store the multiplication result according to the function mode selection signal to obtain a target operation result.

[0162] Optionally, the step of storing the multiplication result according to the functional mode selection signal in the above S107 to obtain the target operation result may specifically include: storing the multiplication result or a numerical value in the multiplication result according to the functional mode selection signal to obtain the target operation result.

[0163] Specifically, if the function mode selection signal received by the multiplier determines that the data bit width that the multiplier can process is equal to the bit width of the input port of the multiplier, then the output data register in the multiplier can store the multiplication result, and the multiplication result is used as the target operation result; if the function mode selection signal received by the multiplier determines that the data bit width that the multiplier can process is smaller than the bit width of the input port of the multiplier, then the output data register in the multiplier can store some low-order values ​​in the multiplication result, and these values ​​are used as the target operation result.

[0164] The present embodiment provides a data processing method, which can receive data to be processed and a function mode selection signal, and judge whether the data to be processed needs to be split according to the function mode selection signal. If the data to be processed needs to be split, the data to be processed is split to obtain the split data, and the split data is encoded with a regular signed number to obtain a target code, and a partial product of the target code is obtained according to the target code and the split data, and the partial product of the target code is accumulated to obtain a multiplication result; the method can multiply data of multiple different bit widths according to the function mode selection signal received by the multiplier The method can improve the versatility of the multiplier and effectively reduce the area of ​​the AI ​​chip occupied by the multiplier; at the same time, the method can perform regular signed number encoding processing on the received data to obtain a smaller number of effective partial products, thereby reducing the complexity of implementing the multiplication operation, improving the operational efficiency of the multiplication operation, and effectively reducing the power consumption of the multiplier; in addition, the above method can also store the effective partial products through the intermediate data register to compress the effective partial products to obtain the multiplication result, and then control the output of part of the data in the multiplication result through the output data register to obtain the target operation result, thereby realizing the function of multiplexing the multiplier and reducing the power consumption of the multiplier.

[0165] Fig.10 A specific flow chart of obtaining the target code provided by another embodiment is shown in FIG. Fig.10 As shown, the step of performing regular signed number encoding processing on the data to be processed to obtain the target code may include: converting the continuous l-bit value 1 in the data to be processed into (l+1)-bit highest bit value 1, the lowest bit value -1, and the remaining bits into the value 0, to obtain the target code, wherein l is greater than or equal to 2. Optionally, the step of performing regular signed number encoding processing on the data to be processed to obtain the target code may specifically include:

[0166] S1041. Perform regular signed number encoding processing on the data to be processed to obtain an intermediate code.

[0167] Specifically, the data to be processed for regular signed number encoding processing may be a multiplier in a multiplication operation.

[0168] S1042. Obtain the target code according to the intermediate code and the functional mode selection signal.

[0169] Specifically, the above-mentioned regular signed number encoding processing method can be characterized in the following manner: for an N-bit multiplier, processing is performed from the lower-order value to the higher-order value. If there are consecutive l (l>=2)-bit values ​​1, the consecutive n-bit values ​​1 can be converted into data "1 (0) l-1(-1)", and the remaining corresponding (Nl)-bit values ​​are combined with the converted (l+1)-bit value to obtain a new data; then the new data is used as the initial data for the next level of conversion processing until there are no continuous l (l>=2)-bit values ​​of 1 in the new data obtained after the conversion processing; wherein, the N-bit multiplier is subjected to regular signed number encoding processing, and the bit width of the obtained target code can be equal to (N+1). Further, during the regular signed number encoding processing, data 11 can be converted to (100-001), that is, data 11 can be equivalently converted to 10(-1); data 111 can be converted to (1000-0001), that is, data 111 can be equivalently converted to 100(-1); and so on, the conversion processing method of other continuous l (l>=2)-bit values ​​of 1 is similar.

[0170] For example, the multiplier received by the regular signed number encoding unit in the multiplier is "001010101101110", and the first new data obtained after the first level conversion processing of the multiplier is "0010101011100(-1)0", and the second new data obtained after the second level conversion processing of the first new data is "0010101100(-1)00(-1)0", and the third new data obtained after the third level conversion processing of the second new data is "0010110(-1)00(-1)00(-1)0", and the fourth level conversion processing of the third new data is performed on the third new data. The fourth new data obtained after the first-level conversion processing is "00110(-1)0(-1)00(-1)00(-1)00(-1)0", and the fifth new data obtained after continuing to perform the fifth-level conversion processing on the fourth new data is "010(-1)0(-1)0(-1)00(-1)00(-1)00(-1)0". There are no consecutive l (l>=2)-bit values ​​1 in the fifth new data. At this time, the fifth new data can be called the initial code, and after a bit-filling processing is performed on the initial code, the intermediate code representing the completion of the regular signed number encoding processing is obtained, wherein the bit width of the initial code can be equal to the bit width of the multiplier. Optionally, after the regular signed number encoding unit performs regular signed number encoding on the multiplier, the new data (i.e., the initial code) obtained, if the highest bit value and the second highest bit value in the new data are "10" or "01", the regular signed number encoding unit can fill the highest bit value of the new data with a single bit value of 0, and obtain the corresponding intermediate code The high three bits are "010" or "001" respectively. Optionally, the bit width of the above intermediate code can be equal to the bit width of the data currently processed by the multiplier plus 1.

[0171] In addition, if the data bit width received by the multiplier is 2N, and it can currently process N-bit data operations, the regular signed number encoding unit in the multiplier can split the 2N-bit data into two groups of N-bit data for separate data operations; at this time, the two groups of (N+1)-bit intermediate codes obtained are combined and can be used as target codes; if the multiplier can currently process 2N-bit data operations, the regular signed number encoding unit in the multiplier can complement the highest bit value of the obtained (2N+1)-bit intermediate code with a single-bit value of 0 (i.e., complement processing) and use the (2N+2)-bit data after complement processing as the target code.

[0172] A data processing method provided in this embodiment performs regular signed number encoding processing on the data to be processed to obtain an intermediate code, and obtains a target code according to the intermediate code and a function mode selection signal; the method can perform multiplication operations on data of various different bit widths, thereby improving the versatility of the multiplier and effectively reducing the area occupied by the multiplier on the AI ​​chip; at the same time, the method can perform regular signed number encoding processing on the received data, reducing the number of effective partial products obtained during the multiplication operation, thereby reducing the complexity of the multiplication operation and improving the operational efficiency of the multiplication operation.

[0173] Fig.11 A specific flow chart of obtaining a target coding partial product provided by another embodiment is as follows: Fig.11 As shown, the step of obtaining the target code partial product according to the target code and the split data in the above S105 may specifically include:

[0174] S1051. Obtain original partial products according to the target code and the split data.

[0175] Specifically, if the target code and the N-bit multiplicand after splitting can obtain an (N+1)-bit 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, that is, each bit value in the original partial product is equal to 0.

[0176] S1052: Perform sign bit extension processing on the original partial product to obtain a partial product after sign bit extension.

[0177] Optionally, the step of performing sign bit extension processing on the original partial product to obtain the sign bit extended partial product in the above S1052 may specifically include: performing sign bit extension processing on the original partial product to obtain an intermediate partial product; performing sign bit extension processing on the intermediate partial product to obtain the sign bit extended partial product.

[0178] Specifically, the multiplier performs sign bit extension processing on the original partial products in the same manner as the sign bit extension processing on the intermediate partial products, but the number of extended sign bits may be unequal or equal.

[0179] It should be noted that the bit width of the above-mentioned intermediate partial product can be equal to twice the data bit width N that the multiplier can currently process; the above-mentioned sign bit extension processing can be characterized as a sign bit complement processing of a data, and the value of the complement sign bit is equal to the sign bit value of the original partial product (i.e., the highest bit value); wherein, the high N-bit values ​​of the intermediate partial product can be equal, and the low N-bit values ​​can be equal to all the values ​​in the original partial product obtained by the target code and the multiplicand. If the target code and the N-bit multiplicand can obtain the N-bit original partial product, then the high N-bit values ​​of the intermediate partial product can all be equal to the sign bit value in the original partial product, and the low N-bit values ​​of the intermediate partial product can be equal to the N-bit value of the original partial product.

[0180] In this embodiment, when the multiplier performs sign bit extension processing on the original partial product, the number of sign bits that can be supplemented can be equal to the bit width of the intermediate partial product minus the bit width of the original partial product; when the multiplier performs sign bit extension processing on the intermediate partial product, the number of sign bits that can be supplemented can be equal to the overflow bit width m of the accumulation result when all the intermediate partial products are accumulated, where the overflow bit width m can be greater than or equal to 0. Optionally, the bit width of the partial product after the sign bit extension can be equal to the sum of the bit width of the intermediate partial product and the overflow bit width m.

[0181] S1053. Obtain the initial coded partial product according to the input port bit width of the multiplier and the partial product after the sign bit is extended.

[0182] Optionally, the step of obtaining the initial coded partial product according to the input port bit width of the multiplier and the partial product after the sign bit extension in the above S1053 may specifically include: judging whether it is necessary to perform zero padding processing on the partial product after the sign bit extension according to the input port bit width of the multiplier to obtain the initial coded partial product; if necessary, performing zero padding processing on the partial product after the sign bit extension to obtain the initial coded partial product. Optionally, if it is not necessary to perform zero padding processing on the partial product after the sign bit extension, the partial product after the sign bit extension is used as the initial coded partial product.

[0183] Specifically, the multiplier can automatically determine whether twice the bit width of the input port of the multiplier is equal to the bit width of the partial product after the sign bit is extended; if they are equal, the partial product after the sign bit is extended can be used as the initial coded partial product; if they are not equal, the multiplier can fill the higher bits of the highest bit value in the partial product after the sign bit is extended with zeros to obtain the initial coded partial product. Optionally, the bit width of the initial coded partial product can be equal to twice the bit width of the input port of the multiplier. Optionally, the amount of zero padding for the partial product after the sign bit is extended can be equal to the bit width of the initial coded partial product minus the bit width of the partial product after the sign bit is extended.

[0184] S1054. Obtain a target coding partial product according to the functional mode selection signal and the initial coding partial product.

[0185] Specifically, the intermediate data register in the multiplier can determine whether the bit width of the initial coding partial product is equal to twice the bit width of the input port of the multiplier based on the received functional mode selection signal. If they are equal, the intermediate data register can receive the complete initial coding partial product and output the initial coding partial product as the target coding partial product; if they are not equal, the intermediate data register can receive a partial value in the initial coding partial product and output the partial product bit value as the target coding partial product.

[0186] The present embodiment provides a data processing method, which obtains original partial products according to target coding and split data, performs sign bit extension processing on the original partial products to obtain partial products after sign bit extension, obtains initial coding partial products according to the bit width of the input port of the multiplier and the partial products after sign bit extension, obtains target coding partial products according to a function mode selection signal and the initial coding partial products, and then performs accumulation processing on the target coding partial products to obtain multiplication results, and stores the multiplication results according to the function mode selection signal to obtain the target operation results; the method can adapt to reduce the bit width of the partial products according to the function mode selection signal, thereby reducing the operation power consumption of the multiplier; in addition, the method can perform multiplication operations on data of various different bit widths under the premise of ensuring the accuracy of the multiplication results, thereby improving the versatility of the multiplier and effectively reducing the area occupied by the multiplier on the AI ​​chip.

[0187] Fig.12 A specific flow chart of obtaining a multiplication result provided in another embodiment is as follows: Fig.12 As shown, the step of accumulating the target coding partial products in S106 to obtain the multiplication result may specifically include:

[0188] S1061. Accumulate the target coded partial products through the Wallace tree group circuit to obtain an intermediate operation result.

[0189] Specifically, if the bit width of the input port of the multiplier is N, and the data bit width that the multiplier can currently process is also N, then the multiplier can perform accumulation operations on each column of values ​​in the target coding partial product through the Wallace tree group circuit to obtain an intermediate operation result; if the data bit width that the multiplier can currently process is also N / 2, then the multiplier can perform accumulation operations on each column of values ​​in the target coding partial product through the Wallace tree group circuit to obtain an intermediate operation result.

[0190] It should be noted that the target coding partial product may include the target coding low-order partial product and the target coding high-order partial product. Optionally, the bit widths of the above target coding low-order partial product and the target coding high-order partial product are the same; in the distribution mode of all target coding low-order partial products, the lowest bit value of each target coding low-order partial product is located in the same column as the lowest bit value of the first target coding low-order partial product, the highest bit value of each target coding low-order partial product is located in the same column as the highest bit value of the first target coding low-order partial product, and the other bit values ​​of each target coding low-order partial product are located in the same corresponding column as the corresponding bit values ​​of the first target coding low-order partial product. Optionally, the distribution mode of the target coding high-order partial product is similar to the distribution mode of the target coding low-order partial product, which will not be repeated. Optionally, if the Wallace tree group circuit in the multiplier performs an accumulation operation on the target coding low-order partial product and the target coding high-order partial product, at this time, the lowest bit value of the last target coding low-order partial product is located in the same column as the lowest bit value of the first target coding high-order partial product, and the other bit values ​​are also located in the same column in sequence.

[0191] S1062. Accumulate the intermediate operation results through an accumulation circuit to obtain the multiplication result.

[0192] Specifically, the data bit width that can be processed by the accumulation circuit can be equal to twice the bit width of the input port of the multiplier; if the bit width of the intermediate operation result is not equal to the data bit width that can be processed by the accumulation circuit, at this time, the accumulation circuit can automatically fill the higher bits of the highest bit value in the intermediate operation result with zeros, so that the bit width of the intermediate operation result after zero filling can be equal to the data bit width that can be processed by the accumulation circuit, and the accumulation circuit in the multiplier accumulates the intermediate operation result after zero filling to obtain the multiplication result. Optionally, the bit width of the multiplication result can be equal to twice the bit width of the input port of the multiplier.

[0193] A data processing method provided in this embodiment performs accumulation processing on target coded partial products through a Wallace tree group circuit to obtain an intermediate operation result, performs accumulation processing on the intermediate operation result through an accumulation circuit to obtain a multiplication operation result, and then stores and processes the numerical value in the multiplication operation result according to a functional mode selection signal to obtain a target operation result; the method can perform multiplication operations on data of various different bit widths according to the functional mode selection signal received by the multiplier, thereby improving the versatility of the multiplier and effectively reducing the area of ​​the AI ​​chip occupied by the multiplier; at the same time, the method can adapt to reduce the bit width of the partial product according to the functional mode selection signal to reduce the operation power consumption of the multiplier.

[0194] The embodiment of the present application also provides a machine learning operation device, which includes one or more multipliers mentioned in the present application, which are used to obtain data to be calculated and control information from other processing devices, perform specified machine learning operations, and pass the execution results to peripheral devices through I / O interfaces. Peripheral devices include cameras, displays, mice, keyboards, network cards, wifi interfaces, and servers. When more than one multiplier is included, the multipliers can be linked and data can be transmitted through a specific structure, for example, interconnected and data can be transmitted through a PCIE bus to support larger-scale machine learning operations. At this time, the same control system can be shared, or each independent control system can be provided; memory can be shared, or each accelerator can have its own memory. In addition, the interconnection method can be any interconnection topology.

[0195] The machine learning computing device has high compatibility and can be connected to various types of servers through a PCIE interface.

[0196] The embodiment of the present application also provides a combined processing device, which includes the above-mentioned machine learning computing device, a universal interconnection interface, and other processing devices. The machine learning computing device interacts with other processing devices to jointly complete the operation specified by the user. Fig.13 A schematic diagram of a combined processing device.

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

[0198] A universal interconnection interface is used to transmit data and control instructions between the machine learning computing device and other processing devices. The machine learning computing device can obtain the required input data from other processing devices and write it into the storage device on the machine learning computing device chip; it can obtain control instructions from other processing devices and write them into the control cache on the machine learning computing device chip; it can also read data in the storage module of the machine learning computing device and transmit it to other processing devices.

[0199] Optionally, the structure is as follows Fig.14 As shown, a storage device may also be included, and the storage device is connected to the machine learning operation device and the other processing device respectively. The storage device is used to store data in the machine learning operation device and the other processing device, and is particularly suitable for data that cannot be fully stored in the internal storage of the machine learning operation device or other processing devices.

[0200] The combined processing device can be used as a SOC chip system for mobile phones, robots, drones, video surveillance equipment and other devices, effectively reducing the core area of ​​the control part, improving the processing speed, and reducing the overall power consumption. In this case, the universal interconnection interface of the combined processing device is connected to certain components of the device. Certain components include cameras, displays, mice, keyboards, network cards, and wifi interfaces.

[0201] In some embodiments, a chip is also applied for, which includes the above-mentioned machine learning computing device or combined processing device.

[0202] In some embodiments, a chip packaging structure is applied for, which includes the above-mentioned chip.

[0203] In some embodiments, a board is applied for, which includes the above chip packaging structure. Fig.15 As shown, Fig.15 A board is provided. In addition to the chip 389, the board may also include other supporting components, including but not limited to: a storage device 390, a receiving device 391 and a control device 392;

[0204] The memory device 390 is connected to the chip in the chip package structure via a bus for storing data. The memory device may include multiple groups of storage units 393. Each group of storage units is connected to the chip via a bus. It is understood that each group of storage units may be DDR SDRAM (English: Double Data Rate SDRAM, double rate synchronous dynamic random access memory).

[0205] DDR can double the speed of SDRAM without increasing the clock frequency. DDR allows data to be read out on the rising and falling edges of the clock pulse. The speed of DDR is twice that of standard SDRAM. In one embodiment, the storage device may include 4 groups of storage units. Each group of storage units may include multiple DDR4 particles (chips). In one embodiment, the chip may include 4 72-bit DDR4 controllers, 64 bits of the above 72-bit DDR4 controllers are used to transmit data, and 8 bits are used for ECC verification. It can be understood that when DDR4-3200 particles are used in each group of storage units, the theoretical bandwidth of data transmission can reach 25600MB / s.

[0206] In one embodiment, each group of the storage units includes a plurality of double rate synchronous dynamic random access memories arranged in parallel. DDR can transmit data twice in one clock cycle. A controller for controlling DDR is arranged in the chip to control the data transmission and data storage of each of the storage units.

[0207] The receiving device is electrically connected to the chip in the chip packaging structure. The receiving device is used to realize data transmission between the chip and an external device (such as a server or a computer). For example, in one embodiment, the receiving device can be a standard PCIE interface. For example, the data to be processed is transmitted to the chip by the server through the standard PCIE interface to realize data transfer. Preferably, when the PCIE 3.0X 16 interface is used for transmission, the theoretical bandwidth can reach 16000MB / s. In another embodiment, the receiving device can also be other interfaces. This application does not limit the specific manifestations of the above-mentioned other interfaces. The interface unit can realize the switching function. In addition, the calculation results of the chip are still transmitted back to the external device (such as a server) by the receiving device.

[0208] The control device is electrically connected to the chip. The control device is used to monitor the state of the chip. Specifically, the chip and the control device can be electrically connected via an SPI interface. The control device may include a single-chip microcomputer (Micro Controller Unit, MCU). For example, the chip may include multiple processing chips, multiple processing cores or multiple processing circuits, which can drive multiple loads. Therefore, the chip can be in different working states such as multi-load and light load. The control device can realize the regulation of the working states of multiple processing chips, multiple processing and / or multiple processing circuits in the chip.

[0209] In some embodiments, an electronic device is applied for, which includes the above-mentioned board.

[0210] The electronic device may be a multiplier, a robot, a computer, a printer, a scanner, a tablet computer, a smart terminal, a mobile phone, a driving recorder, a navigator, a sensor, a camera, a server, a cloud server, a camera, a camcorder, a projector, a watch, a headset, a mobile storage, a wearable device, a vehicle, a household appliance, and / or a medical device.

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

[0212] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all expressed as a series of circuit combinations, but those skilled in the art should be aware that the present application is not limited by the described circuit combination method, because according to the present application, some circuits can be implemented in other ways or structures. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the devices and modules involved are not necessarily required by the present application.

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

[0214] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A multiplier, characterized in that: The multiplier comprises: an improved regular signed number encoding circuit, an intermediate data register, a compression circuit and an output data register; the output end of the improved regular signed number encoding circuit is connected to the input end of the intermediate data register, the output end of the intermediate data register is connected to the input end of the compression circuit, and the output end of the compression circuit is connected to the input end of the output data register; the improved regular signed number encoding circuit, the intermediate data register, the compression circuit and the output data register all comprise a first input end for receiving a function mode selection signal, the function mode selection signal being used to determine the data bit width that the multiplier can currently process; Among them, the improved regular signed number encoding circuit is used to perform regular signed number encoding processing on the received data to obtain the target code, and obtain the initial coding partial product according to the target code; the intermediate data register is used to select and store the initial coding partial product according to the functional mode selection signal, and use the stored initial coding partial product as the target coding partial product; the compression circuit is used to accumulate the received target coding partial product to obtain the multiplication result; the output data register is used to select and store the multiplication result according to the functional mode selection signal, and use the stored multiplication result as the target operation result.

2. The multiplier according to claim 1, characterized in that The improved regular signed number encoding circuit comprises an encoding processing branch and a partial product acquisition branch; the encoding processing branch is used to perform regular signed number encoding processing on the received data to obtain a target code; The partial product acquisition branch is used to obtain an initial coding partial product according to the target coding.

3. The multiplier according to claim 2, characterized in that The encoding processing branch includes a regular signed number encoding unit, and the partial product acquisition branch includes a low-order partial product acquisition unit and a high-order partial product acquisition unit; the output end of the regular signed number encoding unit is connected to the input ends of the low-order partial product acquisition unit and the high-order partial product acquisition unit; Among them, the regular signed number encoding unit is used to determine the bit width of the data that can be processed by the multiplier according to the received functional mode selection signal, and perform regular signed number encoding on the received first data to obtain a high-order target code and a low-order target code. The low-order partial product acquisition unit is used to obtain the low-order partial product after sign bit extension according to the low-order target code in the received target code and the second data, and obtain the initial encoded low-order partial product according to the low-order partial product after sign bit extension. The high-order partial product acquisition unit is used to obtain the high-order partial product after sign bit extension according to the high-order target code in the received target code and the second data, and obtain the initial encoded high-order partial product according to the high-order partial product after sign bit extension.

4. The multiplier according to claim 3, characterized in that: The regular signed number encoding unit includes: a first data input port, a first mode selection signal input port, a low-order target code output port and a high-order target code output port; the first data input port is used to receive the first data, the first mode selection signal input port is used to receive the functional mode selection signal, the low-order target code output port is used to output the low-order target code obtained after regular signed number encoding processing is performed on the first data, and the high-order target code output port is used to output the high-order target code obtained after regular signed number encoding processing is performed on the first data.

5. The multiplier according to any one of claims 3 to 4, characterized in that: The low-order partial product acquisition unit includes: a low-order target code input port, a second mode selection signal input port, a second 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, the second mode selection signal input port is used to receive the functional mode selection signal, the second data input port is used to receive the second data, and the low-order partial product output port is used to input the initial code low-order partial product into the intermediate data register.

6. The multiplier according to any one of claims 3 to 4, characterized in that: The high-order partial product acquisition unit includes: a high-order target code input port, a second data input port, a second mode selection signal 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 regular signed number encoding unit, the second mode selection signal input port is used to receive the functional mode selection signal, the second data input port is used to receive data for multiplication operation, and the high-order partial product output port is used to input the initial encoded high-order partial product into the intermediate data register.

7. The multiplier according to any one of claims 1 to 3, characterized in that: The intermediate data register includes an intermediate low-order data register and an intermediate high-order data register; the intermediate low-order data register is used to store the value in the initial coding low-order partial product according to the functional mode selection signal to obtain the target coding low-order partial product, and the intermediate high-order data register is used to store the value in the initial coding high-order partial product according to the functional mode selection signal to obtain the target coding high-order partial product.

8. The multiplier according to claim 7, characterized in that: The intermediate low-order data register includes: a mode selection signal input port, a low-order partial product input port and a target low-order partial product output port, the mode selection signal input port is used to receive the functional mode selection signal; the low-order partial product input port is used to receive the value of the initial encoded low-order partial product according to the functional mode selection signal; the target low-order partial product output port is used to output the value of the initial encoded low-order partial product received by the intermediate low-order data register according to the functional mode selection signal.

9. The multiplier according to claim 7, characterized in that: The intermediate high-order data register includes: a mode selection signal input port, a high-order partial product input port and a target high-order partial product output port, the mode selection signal input port is used to receive the functional mode selection signal; the high-order partial product input port is used to receive the value of the initial encoded high-order partial product according to the functional mode selection signal; the target high-order partial product output port is used to output the value of the initial encoded high-order partial product received by the intermediate high-order data register according to the functional mode selection signal.

10. The multiplier according to any one of claims 1 to 3, characterized in that: The compression circuit includes: a Wallace tree group circuit and an accumulation circuit, wherein the output end of the Wallace tree group circuit is connected to the input end of the accumulation circuit; the Wallace tree group circuit is used to accumulate the values ​​of each column in all target coding partial products obtained when performing operations on data of different bit widths to obtain an accumulation operation result, and the accumulation circuit is used to accumulate the accumulation operation results to obtain the multiplication operation result.

11. The multiplier according to claim 10, characterized in that: The Wallace tree group circuit includes: a Wallace tree unit; wherein the Wallace tree unit is used to perform an accumulation operation on each column value in the target coding partial product to obtain an accumulation operation result.

12. The multiplier according to claim 11, characterized in that The Wallace tree unit includes a 4-2 compressor and a mode selection unit, wherein the output end of the mode selection unit is connected to the input end of the 4-2 compressor; the 4-2 compressor is used to perform accumulation processing on each column value in all target coding partial products, and the mode selection unit is used to select the value in the target coding partial product received by the 4-2 compressor; wherein the mode selection unit includes a first input end for receiving the functional mode selection signal.

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

14. The multiplier according to claim 13, characterized in that: The adder includes: a carry signal input port, a sum signal input port, an operation result output port and a mode selection signal input 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; the mode selection signal input port is used to receive the functional mode selection signal.

15. The multiplier according to any one of claims 1 to 3, characterized in that: The output data register includes: a mode selection signal input port, an operation result input port and a target result output port; the mode selection signal input port is used to receive the functional mode selection signal, the operation result input port is used to receive the numerical value in the multiplication operation result according to the functional mode selection signal, and the target result output port is used to output the numerical value in the multiplication operation result received according to the functional mode selection signal as the target operation result.

16. A data processing method, characterized in that: Applied to a multiplier according to any one of claims 1 to 15, the method comprising: Receiving data to be processed and a function mode selection signal, wherein the function mode selection signal is used to indicate a bit width of currently processable data; According to the function mode selection signal, determining whether the data to be processed needs to be split and processed; If the data to be processed needs to be split, the data to be processed is split to obtain split data; Performing regular signed number encoding processing on the split data to obtain a target code; Obtaining a target code partial product according to the target code and the split data; Accumulating the target coded partial products to obtain a multiplication result; The multiplication result is stored according to the functional mode selection signal to obtain a target operation result.

17. The method according to claim 16, characterized in that The determining, based on the functional mode selection signal, whether the data to be processed needs to be split and processed comprises: determining, based on the functional mode selection signal, whether the bit width of the data to be processed is equal to the bit width of data that can be processed by the multiplier.

18. The method according to claim 16 or 17, characterized in that The method further includes: if the data to be processed does not need to be split, then continuing to perform regular signed number encoding processing on the data to be processed to obtain the target code.

19. The method according to claim 18, characterized in that The processing of the data to be processed by regular signed number encoding to obtain the target code includes: converting the continuous l A bit value of 1 converts to ( l +1) the highest digit value is 1, the lowest digit value is -1, and the remaining digits are 0, the target code is obtained, wherein, l Greater than or equal to 2.

20. The method according to claim 18, characterized in that The step of performing regular signed number encoding processing on the data to be processed to obtain a target code includes: Performing regular signed number encoding processing on the data to be processed to obtain an intermediate code; The target code is obtained according to the intermediate code and the functional mode selection signal.

21. The method according to claim 16 or 17, characterized in that The step of obtaining a target code partial product according to the target code and the split data includes: Obtaining an original partial product according to the target code and the split data; Performing sign bit extension processing on the original partial product to obtain a sign bit extended partial product; Obtaining an initial coded partial product according to the input port bit width of the multiplier and the partial product after the sign bit is extended; A target coding partial product is obtained according to the functional mode selection signal and the initial coding partial product.

22. The method according to claim 21, characterized in that The step of performing sign bit extension processing on the original partial product to obtain a partial product after sign bit extension includes: Performing sign bit extension processing on the original partial products to obtain intermediate partial products; The intermediate partial products are subjected to sign bit extension processing to obtain sign bit extended partial products.

23. The method according to claim 21, characterized in that The obtaining the initial coded partial product according to the input port bit width of the multiplier and the partial product after the sign bit is extended comprises: According to the bit width of the input port of the multiplier, determining whether it is necessary to perform zero padding processing on the partial product after the sign bit extension to obtain the initial coded partial product; If necessary, the partial product after the sign bit extension is padded with zeros to obtain the initial encoded partial product.

24. The method according to claim 23, characterized in that The method further includes: if it is not necessary to perform zero padding processing on the partial product after the sign bit extension, using the partial product after the sign bit extension as the initial encoding partial product.

25. The method according to claim 16 or 17, characterized in that The step of accumulating the target coded partial products to obtain a multiplication result includes: The target coding partial product is accumulated through the Wallace tree group circuit to obtain the intermediate operation result; The intermediate operation results are accumulated by an accumulation circuit to obtain the multiplication result.

26. The method according to claim 16 or 17, characterized in that The storing the multiplication result according to the functional mode selection signal to obtain the target operation result includes: storing the multiplication result or a numerical value in the multiplication result according to the functional mode selection signal to obtain the target operation result.

27. 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 15, 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.

28. A combined processing device, characterized in that: The combined processing device includes the machine learning computing device as claimed in claim 27, 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.

29. The combined processing device according to claim 28, 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.

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

Citation Information

Patent Citations

  • Reconfigurable multiplier

    CN101625634A

  • Multiplying device, data processing method, chip and electronic equipment

    CN110362293A