Computing device and computing system
By designing multiple multipliers and adders in the calculation device, and optimizing resource allocation using the mode selection unit and switch, the problem of large scale of double-precision multiplication operation circuit and waste of resources in the prior art is solved, and multi-precision multiplication operation is realized efficient execution.
Patent Information
- Application Number
- CN201980024094.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2018-03-30
- Filing Date
- 2019-03-29
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2039-03-29
AI Technical Summary
When the existing computing devices perform double-precision multiplication operations, the circuit scale is large, resulting in low power efficiency and difficulty in effectively performing variable-precision multiplication operations, resulting in waste of resources.
A calculation device is designed, and a multiplication unit and an addition unit are composed of a multiplication unit and an addition unit through multiple multipliers and adders. Resources are divided and allocated according to the operation accuracy mode, and multiplication operations in multiple precision modes are realized, and resources are optimized using the mode selection unit and the switcher. use.
It realizes efficient execution of multiple precision multiplication operations on a small circuit scale, improves power efficiency and avoids waste of resources, and is suitable for various operation modes such as half-precision, single-precision and double-precision.
Smart Images

Figure CN111971649B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a computing device and a computing system, and in particular to a computing device and a computing system for performing multiplication operations with variable precision. Background Art
[0002] Conventionally, there is a known device for performing double-precision multiplication. For example, the computing device described in Patent Document 1 includes two multipliers 12 and 13, an ALU 37, and accumulators 24 and 25. The input portion of the ALU 37 is provided with the multiplication results of the multipliers 12 and 13 and the outputs of the accumulators 24 and 25.
[0003] Prior art literature
[0004] Patent Literature
[0005] Patent Document 1: Japanese Patent Application Laid-Open No. 11-259273 Summary of the invention
[0006] Problem that the invention aims to solve
[0007] However, the device described in Patent Document 1 has a problem in that the circuit scale is large in order to obtain the final multiplication result by the two multipliers 12 and 13, resulting in poor power efficiency.
[0008] Furthermore, in recent years, an operation device is desired that can perform multiplication operations of variable precision with a small circuit scale, rather than performing multiplication operations of only one precision.
[0009] Generally, the number of transistors required for single-precision multiplication is less than 1 / 4 of the number of transistors required for double-precision multiplication, and the number of transistors required for half-precision multiplication is less than 1 / 16 of the number of transistors required for double-precision multiplication. Therefore, for example, a general computing device that switches between single-precision and double-precision has a number of transistors that can perform one double-precision operation or four single-precision operations in terms of circuit scale. In such a general computing device, the transistors used in single-precision operations are less than 1 / 4 of the transistors used in double-precision operations. In addition, it is also considered that one double-precision operation or two single-precision operations can be switched. In this case, the transistors used in single-precision operations are less than 1 / 2 of the transistors used in double-precision operations. In other words, although this computing device has a large circuit scale for double-precision operations, when performing single-precision operations, more than 3 / 4 or 1 / 2 of the transistors in the computing device are not used and become waste.
[0010] Therefore, an object of the present invention is to provide a computing device and a computing system capable of efficiently executing multiplication operations of multiple precisions with a small circuit scale.
[0011] Solutions for solving problems
[0012] In a first aspect of the present invention, a computing device for performing multiplication with variable precision is provided. The computing device may include a multiplication unit, the multiplication unit having a plurality of multipliers, the plurality of multipliers being divided into one or more multipliers according to a computing precision mode and allocated to each of one or more groups, in each group, each multiplier performs multiplication on an individual multiplier and an individual multiplicand according to the computing precision mode, the individual multiplier being the digit range of at least a part of the multiplier corresponding to the group, and the individual multiplicand being the digit range of at least a part of the multiplicand corresponding to the group. The computing device may include an adding unit, the adding unit having a plurality of adders, the plurality of adders being divided into one or more adders according to a computing precision mode and allocated to each of one or more groups, the one or more adders allocated to each group performing addition on each multiplication result obtained by each multiplier allocated to the group, and outputting the product of the multiplier and the multiplicand. The computing device may include a first connection switch which, according to a computing precision mode, inputs each multiplication result obtained by each multiplier into a digit position to which the multiplication result is to be added in one or more adders for each of one or more groups.
[0013] Each of the plurality of multipliers may perform a multiplication operation on an individual multiplier and an individual multiplicand, and output a multiplication result including sum data of each digit and carry data from each digit.
[0014] Each of the plurality of multipliers may perform multiplication operations on a single multiplier and a single multiplicand of a unit bit length, and output a multiplication result of two unit bit lengths. Each of the plurality of adders may perform addition operations on a plurality of input data of two unit bit lengths, and output a sum of two unit bit lengths and a carry to a higher digit according to an operation precision mode.
[0015] In at least one operation precision mode for performing multiplication operation on multipliers and multiplicands with a length of more than 2 unit bits, for each of the one or more groups, one or more multipliers are inputted with individual multipliers of the digit range of the multipliers for which each multiplier is responsible and individual multiplicands of the multiplicands with a length of 1 unit bit selected in order from the higher digit in each cycle in each cycle, and partial products of the individual multipliers and individual multiplicands are outputted as multiplication operation results in each cycle. In each cycle, the first connection switcher may shift the partial products outputted by the one or more multipliers so that the partial products of the individual multipliers and individual multiplicands of the digit range on the least significant digit side of the multipliers correspond to the digit range of the least significant digit in the one or more adders, and input the partial products to the one or more adders, and perform addition operation with the intermediate result. The computing device may further include a second connection switch that shifts the intermediate result by one unit bit length toward the higher order side for each of the one or more groups in each cycle and inputs the shifted intermediate result to one or more adders.
[0016] In at least one operation precision mode with a length of 2 unit bits or more, a plurality of multipliers and a plurality of adders may be allocated to two or more groups. The operation device may calculate the product of the multiplier and the multiplicand using a plurality of cycles for each of the two or more groups.
[0017] It can be that in an operation precision mode for performing multiplication operations on a multiplier and a multiplicand of one unit bit length, a plurality of multipliers are assigned to a plurality of groups each including a multiplier, and the multipliers assigned to each group perform multiplication operations on the multiplier and a multiplicand of one unit bit length assigned to the group.
[0018] The adding unit may include a plurality of intermediate registers, each of which is provided corresponding to each of the plurality of adders and each of which holds a digit range corresponding to each adder in the intermediate result.
[0019] It can be that each of the multiple adders includes a first adding element, and the first adding element outputs an addition operation result including the sum data of each digit and the carry data from each digit. It can be that each of the multiple intermediate registers holds the sum data and the carry data of the digit range output by the corresponding first adding element in the intermediate result. It can be that the adding unit also has a plurality of second adding elements, and the plurality of second adding elements are respectively arranged corresponding to each of the multiple adders, and the plurality of second adding elements are divided into each or every two or more second adding elements according to the operation precision mode and allocated to each of the one or more groups, and the plurality of second adding elements perform addition operation on the sum data and the carry data output by one or more first adding elements in each group and output as the product of the multiplier and the multiplicand.
[0020] In a second aspect of the present invention, a computing device for performing multiplication with variable precision is provided. The computing device may include a multiplication unit, the multiplication unit having a plurality of multipliers, each of the plurality of multipliers multiplying two numbers of a unit bit length and outputting a multiplication result including sum data of each digit and carry data from each digit. The computing device may include an addition unit, the addition unit having a plurality of adders, each of the plurality of adders adding at least two input data including a multiplication result obtained by at least one multiplier among the plurality of multipliers. The computing device may include a mode selection unit, the mode selection unit selecting a division number and a loop number according to a computing precision mode, the division number being a division number for dividing a plurality of multipliers and a plurality of adders into groups, the groups including one or more multipliers and one or more adders, and multiplying mutually different multipliers and multiplicands, and the loop number being used when multiplying the multipliers and multiplicands using one or more multipliers and one or more adders in the group.
[0021] The mode selection unit may divide the plurality of multipliers and the plurality of adders into at least one group each including n multipliers and n adders in a calculation accuracy mode for performing multiplication operations on a multiplier and a multiplicand of n unit bit length (n is a natural number). The n multipliers in each group of at least one group may perform multiplication operations on each individual multiplier of n individual multipliers in each group and each individual multiplicand of n individual multiplicands in a manner of performing n groups of multiplication operations in one cycle during n cycles, wherein each of the n individual multipliers is a digit range of one unit bit length included in the multiplier, and each of the n individual multiplicands is a digit range of one unit bit length included in the multiplicand. The n adders in each group of at least one group may be combined together, and each multiplication result from the n multipliers in the same group in each cycle is added to a digit position corresponding to each multiplication result in an intermediate result of the product of the multiplier and the multiplicand during n cycles.
[0022] In a third embodiment of the present invention, a computing device is provided for performing multiplication operations with variable precision, the computing device comprising: a plurality of multipliers, each of which is configured to output a sum signal and a carry signal of a previous stage of a multiplication result of two input data; a plurality of adders; a plurality of registers, each of which is configured to hold the addition results of the corresponding adders; a plurality of output terminals; a first switch, which is configured to switch the output destination of a plurality of data of a unit bit length constituting a plurality of sum signals and a plurality of carry signals output from the plurality of multipliers to one of a plurality of bit positions of a plurality of inputs of the plurality of adders according to a computing precision mode; and a second switch, which is configured to switch the output destination of a plurality of data of a unit bit length constituting a plurality of addition results held by the plurality of registers to one of a plurality of bit positions of a plurality of inputs of the plurality of adders, or to switch the output destination of the plurality of addition results held by the registers to one of the plurality of output terminals according to the computing precision mode.
[0023] In a fourth aspect of the present invention, there is provided a computing device for performing multiplication operations with variable precision, the computing device comprising: a first multiplier, which is configured to output a first sum signal and a first carry signal of a 2-unit-bit length of the previous stage of the multiplication operation result of two data of 1 unit bit length; a second multiplier, which is configured to output a second sum signal and a second carry signal of a 2-unit-bit length of the previous stage of the multiplication operation result of two data of 1 unit bit length; a first adder and a second adder, the first adder and the second adder are respectively configured to perform addition operations of multiple data of 2 unit bit lengths; a first register and a second register, the first register and the second register are respectively configured to hold a first addition operation result of the first adder and a second addition operation result of the second adder; a first output terminal and a second output terminal; a first connection switch, which is configured to switch the first adder and the second adder from the first adder to the second adder according to the operation precision mode. The output destinations of the first sum signal and the first carry signal output by the first multiplier and the second sum signal and the second carry signal output by the second multiplier, and the multiple data of one unit bit length, are switched to one of the multiple bit positions of the multiple inputs of the first adder and the second adder; and a second connection switcher is configured to switch the output destinations of the multiple data of one unit bit length, which respectively constitute the first addition operation result in the first register and the second addition operation result in the second register, to one of the multiple bit positions of the multiple inputs of the first adder and the second adder, or to switch the output destination of the first addition operation result in the first register to the first output terminal and the output destination of the second addition operation result in the second register to the second output terminal according to the calculation accuracy mode.
[0024] In a fifth aspect of the present invention, there is provided an operation device for performing multiplication operation with variable precision, the operation device comprising: a plurality of multipliers, each of the plurality of multipliers outputting a sum signal and a carry signal of a previous stage of a multiplication operation result of two input data; a plurality of first-stage adders, each of the plurality of first-stage adders being configured to output a sum signal and a carry signal of a previous stage of an addition operation result; a plurality of sum signal holding registers, each of the plurality of sum signal holding registers being configured to hold the sum signal output from the corresponding first-stage adder; a plurality of carry signal holding registers, each of the plurality of carry signal holding registers being configured to hold the carry signal output from the corresponding first-stage adder; a plurality of second-stage adders, each of the plurality of second-stage adders being configured to perform addition operation on the sum signal and the carry signal inputted thereto; and a first connection switch, which is configured to switch the plurality of sum signals and the carry signal outputted from the plurality of multipliers according to an operation precision mode. The output destination of the multiple data of 1 unit bit length of the carry signal is switched to one of the multiple bit positions of the multiple inputs of the multiple first-stage adders, or the output destination of the multiple sum signals and the carry signal output from the multiple multipliers is switched to one of the multiple inputs of the multiple second-stage adders; and a second connection switcher, which is configured to switch the output destination of the multiple data of 1 unit bit length of the multiple sum signals held by the multiple sum signal holding registers and the multiple data of 1 unit bit length of the multiple carry signals held by the multiple carry signal holding registers to one of the multiple bit positions of the multiple inputs of the multiple first-stage adders, or switch the multiple sum signals held by the multiple sum signal holding registers and the multiple carry signals held by the multiple carry signal holding registers to one of the multiple inputs of the multiple second-stage adders according to the operation accuracy mode.
[0025] In a sixth aspect of the present invention, there is provided a computing device for performing multiplication operations with variable precision, the computing device comprising: a first multiplier configured to output a first sum signal and a first carry signal of a 2-unit-bit length of the previous stage of the multiplication operation result of two data of a 1-unit-bit length; a second multiplier configured to output a second sum signal and a second carry signal of a 2-unit-bit length of the previous stage of the multiplication operation result of two data of a 1-unit-bit length; a first adder configured to output a third sum signal and a third carry signal of the previous stage of the addition operation result of a plurality of data of a 2-unit-bit length; a second adder configured to output a third sum signal and a third carry signal of the previous stage of the addition operation result of a plurality of data of a 2-unit-bit length; The fourth sum signal and the fourth carry signal of the previous stage for outputting the addition operation result of multiple data of 2 unit bit lengths; the first register to the fourth register, which are configured to respectively hold the third sum signal, the third carry signal, the fourth sum signal and the fourth carry signal; the third adder and the fourth adder, which are configured to respectively perform addition operation on the input sum signal and carry signal; the first output terminal and the second output terminal, which respectively output the addition operation result of the third adder and the addition operation result of the fourth adder; the first connection switch, which is configured For switching the output destinations of a plurality of data of 1 unit bit length, which respectively constitute the first sum signal and the first carry signal outputted from the first multiplier and the second sum signal and the second carry signal outputted from the second multiplier, to one of a plurality of bit positions of a plurality of inputs of the first adder and the second adder, or for outputting the first sum signal and the first carry signal to the third adder and outputting the second sum signal and the second carry signal to the fourth adder, according to an operation precision mode; and a second connection switch, which is configured to switch the output destinations of the plurality of data of 1 unit bit length, which respectively constitute the first sum signal and the first carry signal outputted from the first multiplier and the second sum signal and the second carry signal outputted from the second multiplier, to one of a plurality of bit positions of a plurality of inputs of the first adder and the second adder, according to an operation precision mode. The output destination of multiple data of one unit bit length, namely, the third sum signal in the first register, the third carry signal in the second register, the fourth sum signal in the third register, and the fourth carry signal in the fourth register, is switched to one of the multiple bit positions of the multiple inputs of the first adder and the second adder, or the third sum signal in the first register and the third carry signal in the second register are output to the third adder, and the fourth sum signal in the third register and the fourth carry signal in the fourth register are output to the fourth adder.
[0026] In a seventh aspect of the present invention, there is provided a computing device for performing multiplication operations with variable precision, the computing device comprising: a first multiplier configured to output a first sum signal and a first carry signal of a 2-unit-bit length of the previous stage of the multiplication operation result of two data of a 1-unit-bit length; a second multiplier configured to output a second sum signal and a second carry signal of a 2-unit-bit length of the previous stage of the multiplication operation result of two data of a 1-unit-bit length; a third multiplier configured to output a third sum signal and a third carry signal of a 2-unit-bit length of the previous stage of the multiplication operation result of two data of a 1-unit-bit length; a fourth multiplier configured to output a first sum signal and a second carry signal of a 2-unit-bit length of the previous stage of the multiplication operation result of two data of a 1-unit-bit length; a fourth sum signal and a fourth carry signal of a 2-unit-bit length of the previous stage of the calculation result; a first adder to a fourth adder, each of the first adder to the fourth adder is configured to perform an addition operation of multiple data of 2 unit bit lengths; a first register to a fourth register, each of the first register to the fourth register is configured to hold a first addition operation result of the first adder, a second addition operation result of the second adder, a third addition operation result of the third adder, and a fourth addition operation result of the fourth adder; a first output terminal to a fourth output terminal; a first connection switch, which is configured to respectively output the first sum signal and the first carry signal from the first multiplier according to the calculation accuracy mode. , the output destination of multiple data of one unit bit length, namely, the second sum signal and the second carry signal outputted from the second multiplier, the third sum signal and the third carry signal outputted from the third multiplier, and the fourth sum signal and the fourth carry signal outputted from the fourth multiplier, is switched to one of the multiple bit positions of multiple inputs of the first adder, the second adder, the third adder, and the fourth adder; and a second connection switch, which is configured to, according to the operation precision mode, respectively configure the first addition operation result in the first register, the second addition operation result in the second register, the third addition operation result in the third register, and The output destination of multiple data of one unit bit length of the fourth addition result in the fourth register is switched to one of the multiple bit positions of the multiple inputs of the first adder, the second adder, the third adder and the fourth adder, or the output destination of the first addition result in the first register is switched to the first output terminal, and the output destination of the second addition result in the second register is switched to the second output terminal, and the output destination of the third addition result in the third register is switched to the third output terminal, and the output destination of the fourth addition result in the fourth register is switched to the fourth output terminal.
[0027] In an eighth aspect of the present invention, there is provided a computing device for performing multiplication operation with variable precision, the computing device comprising: a first multiplier configured to output a first sum signal and a first carry signal of two unit bit lengths of the previous stage of the multiplication operation result of two data of one unit bit length; a second multiplier configured to output a second sum signal and a second carry signal of two unit bit lengths of the previous stage of the multiplication operation result of two data of one unit bit length; a third multiplier configured to output a third sum signal and a third carry signal of two unit bit lengths of the previous stage of the multiplication operation result of two data of one unit bit length; a fourth multiplier configured to output a fourth sum signal and a fourth carry signal of two unit bit lengths of the previous stage of the multiplication operation result of two data of one unit bit length; a first adder configured to output a fifth sum signal and a fifth carry signal of the previous stage of the addition operation result of a plurality of data of two unit bit lengths; a second adder configured to output a fifth sum signal and a fifth carry signal of the previous stage of the addition operation result of a plurality of data of two unit bit lengths; a sixth sum signal and a sixth carry signal of a previous stage; a third adder, which is configured to output the seventh sum signal and the seventh carry signal of the previous stage of the addition operation result of multiple data of 2 unit bit lengths; a fourth adder, which is configured to output the eighth sum signal and the eighth carry signal of the previous stage of the addition operation result of multiple data of 2 unit bit lengths; a first register to an eighth register, wherein the first register to the eighth register are configured to respectively hold the fifth sum signal, the fifth carry signal, the sixth sum signal, the sixth carry signal, the seventh sum signal, the seventh carry signal, the eighth sum signal and the eighth carry signal; a fifth adder to an eighth adder, wherein the fifth adder to the eighth adder are each configured to perform addition operation on the input sum signal and carry signal; a first output terminal to a fourth output terminal, wherein the first output terminal to the fourth output terminal respectively output the addition operation result of the fifth adder, the addition operation result of the sixth adder, the addition operation result of the seventh adder and the addition operation result of the eighth adder;a first connection switch, configured to switch the output destination of a plurality of data of a unit bit length, which respectively constitute the first sum signal and the first carry signal outputted from the first multiplier, the second sum signal and the second carry signal outputted from the second multiplier, the third sum signal and the third carry signal outputted from the third multiplier, and the fourth sum signal and the fourth carry signal outputted from the fourth multiplier, to one of a plurality of bit positions of a plurality of inputs of the first adder, the second adder, the third adder, and the fourth adder, or to output the first sum signal and the first carry signal to the fifth adder, the second sum signal and the second carry signal to the sixth adder, the third sum signal and the third carry signal to the seventh adder, and the fourth sum signal and the fourth carry signal to the eighth adder, according to an operation precision mode; and a second connection switch, configured to switch the output destination of a plurality of data of a unit bit length, which respectively constitute the first sum signal and the second carry signal outputted from the second multiplier, the third sum signal and the third carry signal outputted from the third multiplier, and the fourth sum signal and the fourth carry signal outputted from the fourth multiplier, to one of a plurality of bit positions of a plurality of inputs of the first adder, the second adder, the third adder, and the fourth adder, according to an operation precision mode; and The output destination of a plurality of data of a unit bit length of the fifth carry signal in the register, the sixth sum signal in the third register, the sixth carry signal in the fourth register, the seventh sum signal in the fifth register, the seventh carry signal in the sixth register, the eighth sum signal in the seventh register, and the eighth carry signal in the eighth register is switched to any one of a plurality of bit positions of a plurality of inputs of the first adder, the second adder, the third adder, and the fourth adder, or the fifth sum signal in the first register and the fifth carry signal in the second register are output to the fifth adder, the sixth sum signal in the third register and the sixth carry signal in the fourth register are output to the sixth adder, the seventh sum signal in the fifth register and the seventh carry signal in the sixth register are output to the seventh adder, and the eighth sum signal in the seventh register and the eighth carry signal in the eighth register are output to the eighth adder. ;
[0028] In a ninth aspect of the present invention, there is provided a computing system including: a computing unit including a plurality of the computing devices described above; and a plurality of processors, wherein the plurality of processors share the computing unit. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 The configuration of the computing device 405 according to this embodiment is shown.
[0030] Figure 2 The following shows calculations performed by the calculation device 405 according to the present embodiment in the half-precision calculation mode.
[0031] Figure 3 The multiplication operation of the single-precision multiplier A1 and the multiplicand B1 is shown.
[0032] Figure 4 The following shows calculations performed by the calculation device 405 according to the present embodiment in the single-precision calculation mode.
[0033] Figure 5 The multiplication operation of the double-precision multiplier A1 and the multiplicand B1 is shown.
[0034] Figure 6 The configurations of an adder 540 and an intermediate register 550 according to a first modified example of the present embodiment are shown.
[0035] Figure 7 The configuration of a computing device 1 according to a second modified example of the present embodiment is shown.
[0036] Figure 8 The multiplier Ai, the multiplicand Bi, and their product Ci (i=1 to 4) in the half-precision operation mode are shown.
[0037] Fig. 9 The operation of the arithmetic device 1 according to the second modification example in the half-precision arithmetic mode is shown.
[0038] Fig.10 The input and output of the adder 4 a in the half-precision operation mode of the second modification example are shown.
[0039] Fig.11 The multiplier Ai, the multiplicand Bi, and their product Ci (i=1 to 2) in the single-precision operation mode are shown.
[0040] Fig.12 The operation of the arithmetic device 1 according to the second modification example in the single-precision arithmetic mode is shown.
[0041] Fig.13 Inputs and outputs of adders 4 a to 4 b in the first round in the single-precision operation mode of the second modification are shown.
[0042] Fig.14 Inputs and outputs of the adders 4 a to 4 b in the second round in the single-precision operation mode of the second modification are shown.
[0043] Fig.15 The multiplier A1, the multiplicand B1, and their product C1 in the double-precision operation mode are shown.
[0044] Fig.16 The operation of the arithmetic device 1 according to the second modification example in the single-precision arithmetic mode is shown.
[0045] Fig.17 Inputs and outputs of adders 4 a to 4 d in the first round in the double-precision operation mode of the second modification are shown.
[0046] Fig.18 The input and output of the adders 4 a to 4 d in the second round in the double-precision operation mode of the second modification example are shown.
[0047] Fig.19 The structure of the Wallace tree multiplier 2a is shown.
[0048] Fig. 20 The data generated by the Wallace tree multiplier 2a is shown.
[0049] Fig.21 The configuration of a computing device 101 according to a third modified example of the present embodiment is shown.
[0050] Fig. 22 The operation of the arithmetic device 101 according to the third modification example in the half-precision arithmetic mode is shown.
[0051] Fig.23 The input and output of the adder 4 a in the half-precision operation mode of the third modification example are shown.
[0052] Fig.24 The operation of the arithmetic device 101 according to the third modification example in the single-precision arithmetic mode is shown.
[0053] Fig.25 The input and output of the adders 14 a to 14 b in the first round in the single-precision operation mode of the third modification example are shown.
[0054] Fig.26 The input and output of the adders 14 a to 14 b in the second round in the single-precision operation mode of the third modification example are shown.
[0055] Fig. 27 The operation of the arithmetic device 101 according to the third modification example in the double-precision arithmetic mode is shown.
[0056] Fig.28A Inputs and outputs of the adders 14 a to 14 b in the first round in the double-precision operation mode of the third modification example are shown.
[0057] Fig.28B The input and output of the adders 14 c to 14 d in the first round in the double-precision operation mode of the third modification example are shown.
[0058] Fig.29A The input and output of the adders 14 a to 14 b in the second round in the double-precision operation mode of the third modification example are shown.
[0059] Fig.29B The input and output of the adders 14 c to 14 d in the second round in the double-precision operation mode of the third modification example are shown.
[0060] Fig.30 The structure of the adder 200 that performs carry signal preserving addition operation using 2 CSAs is shown.
[0061] Fig.31 Input data, intermediate data, and output data of the adder 200 are shown.
[0062] Fig.32 The structure of the adder 300 that performs a carry signal preserving addition operation using four CSAs is shown.
[0063] Fig.33 1 is a diagram showing input data, intermediate data, and output data of the adder 300 .
[0064] Fig.34 The structure of the adder 400 is shown for performing carry signal preserving addition operation using 8 CSAs.
[0065] Fig.35 The configuration of a calculation system 1000 according to a fourth modification of the present embodiment is shown. DETAILED DESCRIPTION
[0066] The present invention will be described below by way of the embodiments of the invention, but the following embodiments do not limit the invention as claimed. In addition, the combination of features described in the embodiments is not necessarily all essential to the solution of the invention.
[0067] Figure 1 The structure of the operation device 405 involved in this embodiment is shown. The operation device 405 performs multiplication operations with variable precision. In this embodiment, as an example, the operation device 405 has three operation precision modes: a half-precision operation mode for multiplying a half-precision multiplier and a multiplicand of, for example, 13 bits, a single-precision operation mode for multiplying a single-precision multiplier and a multiplicand of, for example, 26 bits, and a double-precision operation mode for multiplying a double-precision multiplier and a multiplicand of, for example, 52 bits. In addition, for ease of explanation, the two numbers to be multiplied are represented as "multipliers" and "multiplicands", but there is no substantial difference between these numbers. Therefore, the structure after replacing the "multipliers" and "multiplicands" recorded in the claims and the specification also belongs to the scope of protection of the invention involved in the claims, and is a structure disclosed in this specification, etc.
[0068] Here, when the bit length (e.g., 13 bits) for expressing a half-precision number is expressed as "1 unit bit length", the single-precision number is 2 unit bit lengths, and the double-precision number is 4 unit bit lengths. With regard to the multiplication operation of the multiplier and the multiplicand, since the final product is calculated by adding the multiplication results obtained by performing digit multiplication operations on all combinations of the digits of the multiplier and the digits of the multiplicand to the appropriate digit positions, the multiplication operation of the half-precision numbers is 1 multiplication operation of the 1 unit bit length, the multiplication operation of the single-precision numbers is 4 (2×2) multiplication operations of the 1 unit bit length, and the multiplication operation of the double-precision numbers is 16 (4×4) multiplication operations of the 1 unit bit length. Furthermore, the multiplication operation of the n unit bit length numbers is n×n multiplication operations of the 1 unit bit length numbers. In addition, according to the design of the computing device 405, the length of one unit bit can be any length.
[0069] The arithmetic device 405 according to the present embodiment effectively utilizes a plurality of multipliers included in the arithmetic device 405 in each of the arithmetic precision modes of the half-precision arithmetic mode, the single-precision arithmetic mode, and the double-precision arithmetic mode.
[0070] The computing device 405 includes a multiplication unit 410, an addition unit 430, a mode selection unit 460, a first connection switch 470, and a second connection switch 480. The multiplication unit 410 includes a plurality of multipliers 420, that is, for example, four multipliers 420-1 to 420-4 in the present embodiment. Each of the plurality of multipliers 420 receives two numbers of a unit bit length, performs multiplication on the two numbers, and outputs a multiplication result. Each multiplier 420-i (k=1, 2, 3, 4) receives input data INik0 and INi1 of a unit bit length, and outputs a multiplication result of two unit bit lengths.
[0071] The adding section 430 includes a plurality of adders 440 and a plurality of intermediate registers 450. In the present embodiment, as an example, the adding section 430 includes four adders 440-1 to 440-4 and four intermediate registers 450-1 to 450-4.
[0072] Each of the plurality of adders 440 performs addition operation on at least two input data including the multiplication result obtained by at least one multiplier 420 among the plurality of multipliers 420-1 to 420-4. Each adder 440-i (i=1, 2, 3, 4) performs addition operation on a plurality of input data of 2 unit bit lengths, and outputs the sum of the 2 unit bit lengths and the carry to a higher digit according to the operation precision mode. Here, the adders 440 can be provided in the same number as the multipliers 420, and can be input data of the same bit length (e.g., 2 unit bit length) as the output data of the multiplier 420.
[0073] A plurality of intermediate registers 450 - i (i=1, 2, 3, 4) are provided corresponding to the adders 440 - 1 to 440 - 4 , respectively. Each intermediate register 450 holds the addition result output by the corresponding adder 440 .
[0074] The mode selection unit 460 receives the calculation precision mode in which the calculation device 405 is to operate, and controls each unit of the calculation device 405 according to the calculation precision mode. Here, the mode selection unit 460 may receive the designation of the calculation precision mode from a processor connected to the calculation device 405, and dynamically control each unit of the calculation device 405 to operate in the designated calculation precision mode, or may receive the calculation precision mode set by a setting register, and control each unit of the calculation device 405 to operate fixedly in the calculation precision mode.
[0075] The mode selection unit 460 selects the number of divisions for dividing the plurality of multipliers 420 and the plurality of adders 440 into groups including one or more multipliers 420 and one or more adders 440 according to the operation precision mode. These one or more groups are used to perform multiplication operations on mutually different multipliers and multiplicands. By such group division, the plurality of multipliers 420 are divided into each or every two or more multipliers 420 according to the operation precision mode and allocated to each of the one or more groups. Moreover, in each group, each multiplier 420 performs multiplication operations on individual multipliers of at least a part of the digit range (e.g., a digit range of 1 unit bit length) of the multiplier corresponding to the group and individual multiplicands of at least a part of the digit range (e.g., a digit range of 1 unit bit length) of the multiplicand corresponding to the group according to the operation precision mode.
[0076] In addition, the mode selection unit 460 selects the number of cycles used when multiplying the multiplier and the multiplicand using one or more multipliers 420 and one or more adders 440 in the group according to the operation precision mode. Here, through the above-mentioned group division, the multiple adders 440 are divided and allocated to each group in one or more groups according to the operation precision mode according to each or more adders 440. Moreover, the one or more adders 440 allocated to each group perform addition operations on each multiplication result obtained by each multiplier 420 allocated to the group. The one or more adders 440 allocated to each group perform addition operations on each multiplication result during the number of cycles selected according to the operation precision mode. The one or more intermediate registers 450 corresponding to the one or more adders 440 of each group each maintain the addition result of each cycle, that is, the digit range corresponding to each adder 440 in the intermediate result. Thus, one or more adders 440 assigned to each group finally obtain the product of the multiplier and the multiplicand, and output the product.
[0077] In the half-precision operation mode, the mode selection unit 460 involved in this embodiment divides the four multipliers 420 and the four adders 440 into four groups including one multiplier 420 and one adder 440, and performs multiplication operations of four groups of multipliers and multiplicands that may be different from each other in parallel in the four groups.
[0078] In the single-precision operation mode, the mode selection unit 460 divides the four multipliers 420 and the adder 440 into two groups including two multipliers 420 and two adders 440, and performs multiplication operations of multipliers and multiplicands of two groups that may be different from each other in parallel in the two groups. In this case, each group performs two multiplication operations of one unit bit length in one cycle, thereby performing single-precision multiplication operations of one unit bit length four times in two cycles.
[0079] In the double-precision operation mode, the mode selection unit 460 sets four multipliers 420 and adders 440 as one group, and performs a multiplication operation of one group of multipliers and multiplicands in one group. In this case, the group performs four multiplication operations of one unit bit length in one cycle, thereby performing a double-precision multiplication operation of 16 multiplication operations of one unit bit length in four cycles.
[0080] The first connection switch 470 receives control from the mode selection unit 460 and switches, according to the calculation accuracy mode, to which digit position in each input data of each adder 440 each multiplication result outputted by each multiplier 420 is transmitted. According to the calculation accuracy mode, the first connection switch 470 inputs each multiplication result obtained by each multiplier 420 to the digit position to which the multiplication result is to be added in one or more adders 440 in the group for each of the one or more groups.
[0081] The second connection switch 480 receives control from the mode selection unit 460, and according to the operation precision mode, for each of the one or more groups, in each cycle, shifts the intermediate results held by the two or more intermediate registers 450 in the group and inputs them to the two or more adders 440 in the group. Thus, the operation device 405 calculates the multiplication results of each multiplier 420 from the high-order side (or low-order side) to the low-order side (or high-order side) for each group in each cycle, and adds the multiplication results of each multiplier 420 to the low-order side (or high-order side) of the intermediate result of the group in each cycle, and shifts the intermediate result to the high-order side (or low-order side) in the next cycle, thereby adding each multiplication result to an appropriate position in the product of the multiplier and the multiplicand.
[0082] Figure 2 The operation in the half-precision operation mode of the operation device 405 according to the present embodiment is shown. In the half-precision operation mode, the operation device 405 performs multiplication operations on four sets of multipliers Ai and multiplicands Bi (i=1, 2, 3, 4) of half precision, i.e., one unit bit length, respectively, and outputs four sets of products Ci in one cycle.
[0083] In the half-precision operation mode, a plurality of multipliers 420 are allocated to a plurality of groups each including one multiplier 420. In the present embodiment, one multiplier 420-i (i=1, 2, 3, 4) is allocated to each of the four groups. Each multiplier 420-i inputs a multiplier Ai and a multiplicand Bi of a unit bit length allocated to the group as input data INi0 and INi1, performs multiplication operation on them, and outputs a product Ci of two unit bit lengths.
[0084] In the half-precision operation mode, the first connection switch 470 inputs the product Ci, which is the multiplication result of each multiplier 420-i, to the adder 440-i corresponding to each multiplier 420-i. Each adder 440-i stores the product Ci in each intermediate register 450-i without change, for example, by receiving a value 0 as other input data and performing an addition operation on the product Ci. The second connection switch 480 outputs the product Ci stored in each intermediate register 450-i as the final multiplication result OUTi.
[0085] Figure 3 The multiplication operation of the multiplier A1 and the multiplicand B1 of single precision, i.e., 2 unit bit length, is shown. The multiplier A1 can be divided into an individual multiplier A10 on the high side and an individual multiplier A11 on the low side, each of which is a digit range of 1 unit bit length. In addition, the multiplicand B1 can also be divided into an individual multiplier B10 on the high side and an individual multiplier B11 on the low side. Here, the individual multipliers and the individual multiplicands are the numbers obtained by dividing the multipliers and the multiplicands according to the digit range of the bit length that can be input to each multiplier 420.
[0086] The multiplication results of the multiplication of A10 and B10, the multiplication of A11 and B10, the multiplication of A10 and B11, and the multiplication of A11 and B11 can be added to appropriate digit positions as shown in the figure to calculate the multiplication result of the multiplier A1 and the multiplicand B1.
[0087] Figure 4 The operation in the single-precision operation mode of the operation device 405 according to the present embodiment is shown. In the single-precision operation mode, the operation device 405 performs multiplication operations on two sets of single-precision, i.e., two-unit-bit-length multipliers Ai and multiplicands Bi (i=1, 2) in parallel, and outputs two sets of products Ci through two cycles.
[0088] In the single-precision operation mode, a plurality of multipliers 420 and adders 440 are allocated to a plurality of groups each including two multipliers 420 and two adders 440. In the present embodiment, the multipliers 420-1 to 420-2 and the adders 440-1 to 440-2 are allocated to the first group, and the multipliers 420-3 to 420-4 and the adders 440-3 to 440-4 are allocated to the second group. The operation device 405 receives as input the multipliers Ai and multiplicands Bi of two unit bit lengths corresponding to the i-th group, performs multiplication operation on them, and outputs the products Ci of four unit bit lengths corresponding to the i-th group. The operations of the first group and the second group are the same except that the multipliers 420, adders 440 and intermediate registers 450 are allocated to them, so the following description will focus on the operations of the first group.
[0089] In the single-precision operation mode, the operation device 405 implements two cycles in each group. Figure 3 In the first cycle, the operation device 405 performs multiplication operations of the individual multipliers A10 and A11 and the individual multiplicand B10 and the accompanying addition operations.
[0090] In the first cycle, multiplier 420-1 receives A10 as input IN10 and B10 as input IN11, and outputs their product, that is, partial product A10 × B10. Multiplier 420-2 receives A11 as input IN20 and B10 as input IN21, and outputs their product, that is, partial product A11 × B10.
[0091] The adder 440-1 and the adder 440-2 are combined to function as an adder of 4 unit bit length (indicated as "adder Q"). The carry from the adder 440-2 to the adder 440-1 during the addition operation of 4 unit bit length can be generated by, for example, a carry look-ahead circuit and provided to the adder 440-1. The first connection switch 470 shifts the partial product A10×B10 and the partial product A11×B10 on the least significant side of the partial product A10×B10 and the partial product A11×B10 so as to correspond to the digit range on the least significant side of the adder Q, and then inputs them to the adder Q. That is, the first connection switch 470 shifts the partial product A11×B10 to the digit range indicated as 2 and 3 in the figure, and then inputs it to the adder Q. The partial product A10×B10 is located on the higher side by one unit bit length than the partial product A11×B10, so the first connection switch 470 shifts the partial product A10×B10 to the digital range represented by 1 and 2 in the figure and inputs it to the adder Q. As a result, the adder Q receives the digital range of the lower 1 unit bit length of the partial product A11×B10 as input to the digital range 3 of the lowest 1 unit bit length, receives the digital range of the lower 1 unit bit length of the partial product A10×B10 and the digital range of the upper 1 unit bit length of the partial product A11×B10 as input to the digital range 2 of the upper 1 unit bit length from the lowest 1 unit bit length, and receives the digital range of the upper 1 unit bit length of the partial product A10×B10 as input to the digital range 1 of the upper 2 unit bit lengths from the lowest 1 unit bit length, performs addition operation on these, and outputs the digital ranges 1 to 3 as the intermediate results of the partial product A1×B10, which are the products of the multiplier A1 and the respective multiplicand B10. The adder Q stores the partial product A1×B10 in the intermediate registers 450-1 to 450-2.
[0092] In the second loop, the second connection switch 480 shifts the intermediate results stored in the intermediate registers 450-1 to 450-2, that is, the partial products A1×B10, to the higher order by one unit bit length and supplies them to the adder Q. The multipliers 420-1 to 420-2 and the first connection switch 470 calculate the partial products A10×B11 and the partial products A11×B11 in the same manner as in the first loop, and input these partial products to the adder Q in such a manner that the partial product A11×B11 on the least significant order side corresponds to the digit range on the least significant order side of the adder Q. The adder Q receives the partial products A1×B10 shifted by the second connection switch 480 and the partial products A10×B11 and A11×B11 calculated in the second loop in a state where the digit ranges are correctly associated, and performs addition operation, thereby outputting the product A1×B1=C1. The intermediate registers 450 - 1 and 450 - 2 hold the product C1 , and the second connection switch 480 outputs the product C1 held by the intermediate registers 450 - 1 and 450 - 2 as OUT1 and OUT2 in the third and subsequent cycles.
[0093] Figure 5 The multiplication of the multiplier A1 and the multiplicand B1 of double precision, i.e., 4 unit bit length, is shown. The multiplier A1 is divided into individual multipliers A10 to A13 of 1 unit bit length in order from the high-order side. The multiplicand B1 is divided into individual multiplicands B10 to B13 of 1 unit bit length in order from the high-order side.
[0094] The multiplication results of the multiplier A1 and the multiplicand B1 can be calculated by adding the multiplication results of all combinations (16 groups) of the individual multipliers A10 to A13 and the individual multiplicands B10 to B13 to the appropriate digit positions. Here, the multiplication results of the individual multipliers on the high side of the m unit bit lengths higher from the least significant digit and the individual multiplicands on the high side of the n unit bit lengths higher from the least significant digit are added to the intermediate result at the digit position on the high side of the m+n unit bit lengths higher from the least significant digit.
[0095] In the double precision operation mode, the operation device 405 performs a multiplication operation on double precision, ie, 4-bit length multipliers A1 and B1 in four cycles, and outputs a product C1. In the double precision mode, a plurality of multipliers 420 and adders 440 are assigned to one group.
[0096] In the first cycle, multipliers 420-1 to 420-4 are input with A10 to A13 as IN10 to IN40 and with B10 as IN11 to IN41, and output the product of each of A10 to A13 and B10, namely, partial products A10×B10, A11×B10, A12×B10 and A13×B10.
[0097] Adders 440-1 to 440-4 are combined to function as an adder of 8 unit bit lengths (represented as "adder O"). The carry from adder 440-i to adder 440-(i-1) in the addition operation of 2 unit bit lengths can be generated by, for example, a carry look-ahead circuit and provided to adder 440-(i-1). Similar to the single-precision operation mode, the first connection switch 470 shifts the partial products A10×B10 to A13×B10 so that the least significant partial product A13×B10 of the partial products A10×B10 to A13×B10 corresponds to the digit range of the least significant side of adder O and inputs them to adder O. As a result, the adder O receives partial products A13×B10 as input to the digital range 6 to 7 on the least significant bit side, receives partial products A12×B10 as input to the digital range 5 to 6 on the higher bit side by one unit bit length from the least significant bit, receives partial products A11×B10 as input to the digital range 4 to 5 on the higher bit side by two unit bit lengths from the least significant bit, and receives partial products A10×B10 as input to the digital range 3 to 4 on the higher bit side by three unit bit lengths from the least significant bit, and performs addition operation on these, outputting digital ranges 3 to 7 as intermediate results of partial products A1×B10, which are products of multipliers A1 and respective multiplicands B10. The adder O stores the partial products A1×B10 in the intermediate registers 450-1 to 450-4.
[0098] In the second loop, the second connection switch 480 shifts the intermediate results stored in the intermediate registers 450-1 to 450-4 to the higher bit side by one unit bit length and supplies them to the adder O. The multipliers 420-1 to 420-4 and the first connection switch 470 calculate the partial products A10×B11 to A13×B11 in the same manner as in the first loop, and input these partial products to the adder O in such a manner that the partial product A13×B11 on the least significant bit side corresponds to the digit range on the least significant bit side of the adder O. The adder O receives the partial product A1×B10 shifted by the second connection switch 480 and the partial products A10×B11 to A13×B11 calculated in the second loop in a state where the digit ranges are correctly corresponded, performs addition operation, and outputs the intermediate result. The adder O stores the intermediate result in the intermediate registers 450-1 to 450-4.
[0099] In the third to fourth cycles, the operation device 405 also adds the value obtained by shifting the intermediate results stored in the intermediate registers 450-1 to 450-4 to the high-order side by one unit bit length to the partial products A10×B12 to A13×B12 (in the case of the third cycle) or the partial products A10×B13 to A13×B13 (in the case of the fourth cycle) and stores them in the intermediate registers 450-1 to 450-4. Thus, in the fourth cycle, the intermediate registers 450-1 to 450-4 store the product C1. The second connection switch 480 outputs the product C1 stored in the intermediate registers 450-1 to 450-4 as OUT1 to OUT4 in the cycles after the fifth cycle.
[0100] As described above, in at least one operation precision mode such as the single precision operation mode and the double precision operation mode described above, in which multiplication operations are performed on multipliers and multiplicands having a length of two unit bits or more, the operation device 405 divides the plurality of multipliers 420, the plurality of adders 440, and the plurality of intermediate registers 450 into one or more groups, and each group calculates the product of the multipliers and multiplicands of each group in parallel using a plurality of cycles. In each group, individual multipliers of the digit range that each multiplier 420 is responsible for among the input multipliers and individual multiplicands of the multiplicand having a length of one unit bit are selected in order from the higher digit in each cycle, and the partial products of the individual multipliers and the individual multiplicands are output as multiplication operation results in each cycle. In each cycle, the first connection switch 470 shifts each partial product outputted from the one or more multipliers 420 so that the partial product of the individual multiplier and the individual multiplicand on the digit range of the least significant bit in the multiplier corresponds to the digit range of the least significant bit in the one or more adders 440, and inputs the partial product to the one or more adders 440, and performs addition operation with the intermediate result. In each cycle, the second connection switch 480 shifts the intermediate result to the high-order side by 1 unit bit length, and inputs the partial product to the one or more adders 440-1 to 440-4.
[0101] In the operation precision mode of 1 unit bit length such as the above-mentioned half-precision operation mode, the plurality of multipliers 420 are allocated to a plurality of groups each including one multiplier 420. And, the operation device 405 calculates the product of the multiplier and the multiplicand in one cycle for each of the plurality of groups. Thus, the operation device 405 can effectively utilize the plurality of multipliers 420 by performing each multiplication operation by the plurality of multipliers 420 respectively.
[0102] In at least one operation precision mode of more than 2 unit bit lengths such as the above-mentioned single precision operation mode, a plurality of multipliers 420 and a plurality of adders 440 are allocated to two or more groups. Moreover, the operation device 405 uses a plurality of cycles to calculate the product of the multiplier and the multiplicand for each of the two or more groups. Thus, the operation device 405 divides the plurality of multipliers 420 into a plurality of groups, increases the number of cycles to obtain the multiplication operation results of the required number of individual multipliers and individual multiplicands, and thus can effectively use the plurality of multipliers 420 even in a higher precision operation precision mode.
[0103] In at least one operation precision mode of more than 2 unit bit lengths such as the above-mentioned double precision operation mode, a plurality of multipliers 420 and a plurality of adders 440 are allocated to one group. Furthermore, the operation device 405 uses a plurality of loops in one group to calculate the product of the multiplier and the multiplicand. Thus, the operation device 405 gathers a plurality of multipliers 420 into one group, increases the number of loops to obtain the multiplication operation results of the required number of individual multipliers and individual multiplicands, and thus can effectively use a plurality of multipliers 420 even in a higher precision operation precision mode.
[0104] In the present embodiment, the mode selection unit 460 divides the plurality of multipliers 420 and the plurality of adders 440 into at least one group each including n multipliers 420 and n adders 440 in the operation precision mode for performing multiplication operation on a multiplier and a multiplicand of n unit bit length (n is a natural number). For example, in the half-precision operation mode (n=1), the mode selection unit 460 divides the four multipliers 420 (and the four adders 440) into four groups each including one multiplier 420 (and one adder 440). In the single-precision operation mode (n=2), the mode selection unit 460 divides the four multipliers 420 and the four adders 440 into two groups each including two multipliers 420 and two adders 440. In the double-precision operation mode (n=4), the mode selection unit 460 divides (distributes) the four multipliers 420 and the four adders 440 as a whole into one group including the four multipliers 420 and the four adders 440 .
[0105] Furthermore, the n multipliers 420 in each group perform multiplication operations of each individual multiplier of each group and each individual multiplicand of each individual multiplicand in a manner that n groups of multiplication operations are performed in one cycle during n cycles, wherein each of the n individual multipliers is a digit range of one unit bit length included in the multiplicand, and each of the n individual multiplicands is a digit range of one unit bit length included in the multiplicand. The n adders 440 in each group are combined together, and each multiplication result from the n multipliers 420 in the same group in each cycle is added to the digit position corresponding to each multiplication result in the intermediate result of the product of the multiplier and the multiplicand during n cycles.
[0106] Here, in the operation precision mode for performing multiplication operation on multipliers and multiplicands of n unit bit lengths, even if the multipliers 420 less than n are allocated to the group, the adders 440 in the group need to perform addition operation of 2n unit bit lengths by combination, so in order to perform addition operation in one cycle, it is necessary to set n adders 440 in the group. On the contrary, in the operation mode for performing multiplication operation on multipliers and multiplicands of n unit bit lengths, when the multipliers 420 exceeding n are allocated to the group, it is sufficient to set n adders 440 in the group in order to perform addition operation in one cycle, but since it is necessary to perform addition operation on more multiplication results, it is necessary to set more inputs to the adder 440. In contrast, according to the structure of this embodiment, in addition to being able to effectively utilize a plurality of multipliers 420, it is also possible to effectively utilize the adder 440. Furthermore, when effective use of the adder 440 is not important, the mode selection unit 460 may perform other group divisions and operations using different numbers of cycles.
[0107] In addition, in the present embodiment, the first connection switch 470 inputs the multiplication results from each multiplier 420 to the digit range on the low-order side of one or more than two adders 440, and the second connection switch 480 shifts the intermediate result to the high-order side. Alternatively, the following structure may be adopted: the first connection switch 470 inputs the multiplication results from each multiplier 420 to the digit range on the high-order side of one or more than two adders 440, and the second connection switch 480 shifts the intermediate result to the low-order side. In addition, the operation device 405 may also adopt a structure without the second connection switch 480. In this case, it can be set that the first connection switch 470 switches the connection in each cycle so that each multiplication result can be added to the corresponding digit range in the final product.
[0108] In addition, the operation device 405 involved in this embodiment has three operation precision modes, namely, a half-precision operation mode, a single-precision operation mode, and a double-precision operation mode. Alternatively, the operation device 405 may also have any operation precision mode. In addition, the operation device 405 has each operation mode corresponding to a number of bit lengths that is a power of 2 times of a unit bit length. The operation device 405 may also have one or more operation modes corresponding to a number of bit lengths other than a power of 2 times of a unit bit length (e.g., 3 unit bit lengths, etc.). In such an operation mode, the operation device 405 may set a part of the multipliers 420 and the adders 440 to an idle state. In addition, the operation device 405 may also adopt a structure having a number of multipliers 420, adders 440, and intermediate registers 450 that is not a power of 2 (e.g., 6) to replace the multipliers 420, adders 440, and intermediate registers 450 that are a power of 2.
[0109] Figure 6 The structure of the adder 540 and the intermediate register 550 according to the first modified example of the present embodiment is shown. Figures 1 to 5 The illustrated example is an example in which each adder 440 in the arithmetic device 405 is changed to an adder 540 and each intermediate register 450 is changed to an intermediate register 550 , and therefore descriptions other than the differences from the arithmetic device 405 are omitted below.
[0110] In the first modification, the addition is performed by an adder 540 including a carry save adder (CSA: Carry Save Adder, also referred to as a "carry save adder"). Figure 1 The adder 540 includes a first adding element 542 and a second adding element 544.
[0111] The first adding element 542 is a CSA that performs addition operations on input data such as one or more multiplication results from one or more multipliers 420 input via the first connection switch 470 and a digit range corresponding to the adder 540 in an intermediate result input via the second connection switch 480, and outputs an addition operation result including the sum data of each digit and the carry data from each digit.
[0112] The second adding element 544 is provided corresponding to each adder 540. The plurality of adders 540 are divided into each or every two or more adders 540 according to the operation precision mode, and accordingly, the plurality of second adding elements 544 are divided into each or every two or more second adding elements 544 and allocated to each of one or more groups. The second adding element 544 performs addition operation on the sum data and carry data outputted from one or more first adding elements 542 in each group, and outputs the sum data as the product of the multiplier and the multiplicand.
[0113] More specifically, the second adding element 544 adds the sum data and carry data held by the intermediate register 550 and outputs the sum data as OUTx (x=1, 2, 3, 4). The second adding element 544 is an adder such as a carry look-ahead adder and a carry propagation adder that adds the carry from each digit to the higher digit and outputs the sum reflecting the carry. The second adding element 544 receives the carry from the lower digit side of the group and performs the addition operation as needed, and propagates the carry of the addition result to the higher digit side of the group as needed, in accordance with the group division performed by the mode selection unit 460.
[0114] The intermediate register 550 holds the sum data and carry data of the digit range output by the corresponding first adding element 542. The intermediate register 550 outputs the held sum data and carry data to the second adding element 544. In this modification, the intermediate register 550 provides the held sum data and carry data to one or more first adding elements 542 via the second connection switch 480 instead of the second adding element 544. Thus, the operation device 405 according to this modification does not need to calculate the sum reflecting the carry in each cycle until the product of the multiplier and the multiplicand is finally calculated, and thus the circuit delay of the circuit for calculating the intermediate result can be reduced.
[0115] In addition, the operation device 405 may use a multiplier using a Wallace tree that performs multiplication operations on individual multipliers and individual multiplicands and outputs a multiplication result including sum data of each digit and carry data from each digit as each of the plurality of multipliers 420. By using CSA and Wallace tree multipliers as each multiplier 420 and each adder 540, the operation device 405 can reduce circuit delay and shorten the processing time required for one cycle.
[0116] Other modifications are described below with reference to the accompanying drawings. Figure 1 to Figure 6 The illustrated embodiment or its first modified example has the same or similar structure and function, so the description except for the different points may be omitted.
[0117] [Second Modification]
[0118] Figure 7 The structure of the computing device 1 according to the second modification is shown.
[0119] The computing device 1 performs multiplication with variable precision. The computing device 1 includes Wallace tree multipliers 2a to 2d (corresponding to multipliers 420-1 to 420-4), a first connection switch 20 (corresponding to the first connection switch 470), adders 4a to 4d (corresponding to adders 440-1 to 440-4), registers 5a to 5d (corresponding to intermediate registers 450-1 to 450-4), a second connection switch 30 (corresponding to the second connection switch 480), output terminals OP1 to OP4, and switches 9b, 9c, and 9d.
[0120] The computing device 1 receives 8 inputs (IN1 to IN8) and outputs 4 outputs (OUT1 to OUT4). The inputs IN1 to IN8 are data of 1 unit bit length (13 bits), and the outputs OUT1 to OUT4 are data of 2 unit bit length (26 bits).
[0121] The Wallace tree multiplier 2a receives input data IN1 and input data IN2, performs carry-save addition operations multiple times based on the Wallace tree, and outputs a 26-bit sum signal D of the previous stage of the multiplication result of the input data IN1 and the input data IN2 and a carry signal E. The Wallace tree multipliers 2b to 2d are the same as the Wallace tree multiplier 2a except that the input data and the output signals are different from those of the Wallace tree multiplier 2a as shown in this figure.
[0122] Each of the adders 4a to 4d performs addition operation on a plurality of data of 26 bits in length.
[0123] The registers 5a to 5d respectively hold the addition results of the corresponding adders 4a to 4d.
[0124] The first connection switch 20 switches the output destination of the high-order 13-bit data and the low-order 13-bit data constituting the sum signals D, F, H, J and the carry signals E, G, I, K outputted from the Wallace tree multipliers 2a to 2d to one of the multiple bit positions (low-order half bit positions or high-order half bit positions) of the multiple inputs of the adders 4a to 4d according to the calculation accuracy mode. The first connection switch 20 has a switch and a shifter, and performs the above-mentioned switching by controlling them.
[0125] The second connection switch 30 switches the output destination of the high-order 13-bit data and the low-order 13-bit data constituting the multiple addition operation results in the registers 5a to 5d to one of the multiple bit positions (low-order half bit positions or high-order half bit positions) of the multiple inputs of the adders 4a to 4d, or switches the output destination of the addition operation results of the adders 4a to 4d in the registers 5a to 5d to the output terminals OP1 to OP4, according to the operation precision mode. The second connection switch 30 has a switch and a shifter, and performs the above-mentioned switching by controlling them.
[0126] The switch 9b switches whether to send a carry bit from the adder 4b to the adder 4a. The switch 9c switches whether to send a carry bit from the adder 4c to the adder 4b. The switch 9d switches whether to send a carry bit from the adder 4d to the adder 4c.
[0127] The arithmetic device 1 operates in a plurality of arithmetic precision modes, namely, a half-precision arithmetic mode, a single-precision arithmetic mode, and a double-precision arithmetic mode. The operation in each arithmetic mode will be described below.
[0128] (Half-precision operation mode)
[0129] In the half-precision operation mode, the multiplier and the multiplicand are 13 bits, and the product is 26 bits. In the half-precision operation mode, the multiplication operation is performed in one cycle. In the half-precision operation mode, the switches 9b to 9d are open.
[0130] Figure 8 Indicates the i-th multiplier Ai, the i-th multiplicand Bi, and the i-th product Ci (i=1, 2, 3, 4) in the half-precision operation mode. Fig. 9 The operation of the half-precision calculation mode of the calculation device 1 according to the second modification example will be described.
[0131] The operation device 1 multiplies the i-th multiplier Ai by the i-th multiplicand Bi, and outputs the i-th product Ci. When the Wallace tree multiplier 2a receives all 13 bits of the first multiplier A1 and all 13 bits of the first multiplicand B1, it outputs a sum signal D and a carry signal E. The Wallace tree multipliers 2b to 2d operate in the same manner as the Wallace tree multiplier 2a, except that the inputs and outputs are different from those of the Wallace tree multiplier 2a as shown in this figure.
[0132] The outputs of the Wallace tree multipliers 2a to 2d (26-bit sum signals and 26-bit carry signals) are sent to corresponding adders among the adders 4a to 4d via the first connection switch 20.
[0133] Fig.10The figure shows the input and output of the adder 4a in the half-precision operation mode of the second variant. The adder 4a receives all 26 bits {d25-d0} of the sum signal D as all 26 bits of the first input, and receives all 26 bits {e25-e0} of the carry signal E as all 26 bits of the second input. The low-order 26 bits {l25-l0} of the addition result L of the adder 4a are sent to the register 5a. The adders 4b to 4d operate in the same manner as the adder 4a except that the input and output are different from those of the adder 4a as shown in this figure.
[0134] The second connection switch 30 switches the output destination of the data in the registers 5a to 5d to the output terminals OP1 to OP4. Thus, the first to fourth products C1 to C4 are output from the output terminals OP1 to OP4.
[0135] (Single precision operation mode)
[0136] In the single-precision operation mode, the multiplier and multiplicand are 26 bits, and the product is 52 bits. In the single-precision operation mode, the multiplication operation is performed in two cycles. In the single-precision operation mode, switches 9b and 9d are turned on, and switch 9c is turned off.
[0137] Fig.11 Indicates the i-th multiplier Ai, the i-th multiplicand Bi, and the i-th product Ci (i=1, 2) in the single-precision operation mode. Fig.12 The operation of the single-precision operation mode of the arithmetic device 1 of the second modified example will be mainly described with respect to i = 1. The operation with respect to i = 2 is the same as the operation with respect to i = 1 except for the difference in input and output, and thus the description thereof will be omitted.
[0138] The operation device 1 performs multiplication operation on the i-th multiplier Ai and the i-th multiplicand Bi, and outputs the i-th product Ci (=1, 2). The high-order 13 bits of the i-th multiplier Ai are Ai0, and the low-order 13 bits are Ai1. The high-order 13 bits of the i-th multiplicand Bi are Bi0, and the low-order 13 bits are Bi1. The high-order 26 bits of the i-th product Ci are Ci0, and the low-order 26 bits are Ci1.
[0139] First, the calculation process of the first loop in the single-precision operation mode will be described mainly with respect to i=1.
[0140] The Wallace tree multiplier 2a outputs a sum signal D(0) and a carry signal E(0) upon receiving the upper 13 bits A10 of the first multiplier A1 and the upper 13 bits B10 of the first multiplicand B1. The Wallace tree multiplier 2b outputs a sum signal F(0) and a carry signal G(0) upon receiving the lower 13 bits A11 of the first multiplier A1 and the upper 13 bits B10 of the first multiplicand B1.
[0141] The outputs of the Wallace tree multipliers 2a to 2d are sent to the adders 4a to 4d via the first connection switch 20. The data in the registers 5a to 5d are sent to the adders 4a to 4d via the second connection switch 30.
[0142] That is, the upper 13 bits of the sum signal D(0) are sent to the shifter 6a. The shifter 6a shifts the upper 13 bits of the sum signal D(0) by 13 bits to the lower 13 bits and provides them to the lower 13 bits of the first input of the adder 4a. The lower 13 bits of the sum signal D(0) are sent to the upper 13 bits of the first input of the adder 4b. The upper 13 bits of the carry signal E(0) are sent to the shifter 6b. The shifter 6b shifts the upper 13 bits of the carry signal E(0) by 13 bits to the lower 13 bits and provides them to the lower 13 bits of the second input of the adder 4a. The lower 13 bits of the carry signal E(0) are sent to the upper 13 bits of the second input of the adder 4b. All 26 bits of the sum signal F(0) are provided to all 26 bits of the third input of the adder 4b. All 26 bits of the carry signal G(0) are provided to all 26 bit positions of the fourth input of the adder 4b.
[0143] Fig.13 1 is a diagram showing inputs and outputs of adders 4 a to 4 b in the first round in the single-precision operation mode according to the second modification.
[0144] The adder 4a receives the upper 13 bits {d25(0)-d13(0)} of the sum signal D(0) at the lower 13 bits of the first input. The adder 4a receives the upper 13 bits {e25(0)-e13(0)} of the carry signal E(0) at the lower 13 bits of the second input. The adder 4a receives 26 bits (all bits are 0) from the shifter 7a at all 26 bits of the third input. The adder 4a receives the upper 2 bits of the addition result (28 bits) of the adder 4b at the lower 2 bits of the fourth input.
[0145] The lower 26 bits {125(0)-10(0)} of the addition operation result L(0) of the adder 4a are sent to the register 5a.
[0146] The adder 4b receives the lower 13 bits {d12(0)-d0(0)} of the sum signal D(0) at the upper 13 bits of the first input, and receives the lower 13 bits {e12(0)-e0(0)} of the carry signal E(0) at the upper 13 bits of the second input.
[0147] The adder 4b receives all 26 bits {f25(0)-f0(0)} of the sum signal F(0) at all 26 bit positions of the 3rd input. The adder 4b receives all 26 bits {g25(0)-g0(0)} of the carry signal G(0) at all 26 bit positions of the 4th input. The adder 4b receives 26 bits (all bits are 0) from the shifter 7b at all 26 bit positions of the 5th input.
[0148] The lower 26 bits {m25(0)-m0(0)} of the addition result M(0) of the adder 4b are sent to the register 5b as the first output. The upper 2 bits of the addition result M(0) of the adder 4b are sent to the lower 2 bits of the fourth input of the adder 4a as the second output.
[0149] Next, the calculation process of the second loop in the single-precision arithmetic mode will be described.
[0150] The Wallace tree multiplier 2a outputs a sum signal D(1) and a carry signal E(1) upon receiving the high-order 13 bits A10 of the first multiplier A1 and the low-order 13 bits B11 of the first multiplicand B1. The Wallace tree multiplier 2b outputs a sum signal F(1) and a carry signal G(1) upon receiving the low-order 13 bits A11 of the first multiplier A1 and the low-order 13 bits B11 of the first multiplicand B1.
[0151] The outputs of the Wallace tree multipliers 2a to 2d are sent to the adders 4a to 4d via the first connection switch 20. The data in the registers 5a to 5d are sent to the adders 4a to 4d via the second connection switch 30. The first connection switch 20 sends the signals D(1) to G(1) to the adders 4a to 4b in the same manner as the signals D(0) to G(0) of the first cycle.
[0152] Fig.14 The figure shows the inputs and outputs of adders 4a to 4b in the second cycle in the single-precision operation mode of the second variant. The first input to the second input, the fourth input and the output of the adder 4a and the first input to the fourth input and the output of the adder 4b are signals of the second cycle corresponding to the signals provided to the inputs and the signals outputted in the first cycle as shown in the figure, and therefore descriptions other than the differences are omitted.
[0153] Shifter 7a shifts the 26 bits {l25(0)-l0(0)} held by register 5a to the upper 13 bits. Shifter 7b shifts the 26 bits {m25(0)-m0(0)} held by register 5b to the upper 13 bits, and sends the 13 bits {m25(0)-m13(0)} overflowing from shifter 7b to the lower 13 bits of shifter 7a. Adder 4a receives 26 bits {upper 13 bits: l12(0)-l0(0), lower 13 bits: m25(0)-m13(0)} from shifter 7a at all 26 bits of the third input.
[0154] The adder 4b receives 26 bits {upper 13 bits: m12(0)-m0(0), lower 13 bits: all bits are 0} from the shifter 7b at all 26 bit positions of the fifth input.
[0155] After the second cycle is completed, the second connection switch 30 switches the output destination of the data in the registers 5a to 5d to the output terminals OP1 to OP4, thereby outputting the upper 26 bits C10 of the first product, the lower 26 bits C11 of the first product, the upper 26 bits C20 of the second product, and the lower 26 bits C21 of the second product from the output terminals OP1 to OP4.
[0156] (Double precision operation mode)
[0157] In the double-precision operation mode, the multiplier and the multiplicand are 52 bits, and the product is 104 bits. In the double-precision operation mode, the multiplication operation is performed in four cycles. In the double-precision operation mode, the switches 9b, 9c, and 9d are turned on.
[0158] Fig.15 Indicates the multiplier A1, the multiplicand B1, and the product C1 in the double-precision operation mode. Fig.16 The operation of the double-precision calculation mode of the calculation device 1 according to the second modification example will be described.
[0159] like Fig.15 and Fig.16 As shown, the operation device 1 performs multiplication operation on the multiplier A1 and the multiplicand B1 and outputs the product C1. The multiplier A1 is divided into the first bit group (first digit range) A10 to the fourth bit group (fourth digit range) A13 in order from the high bit position. The multiplicand B1 is divided into the first bit group (first digit range) B10 to the fourth bit group (fourth digit range) B13 in order from the high bit position. The product C1 is divided into the first bit group C10 to the fourth bit group C13 in order from the high bit position.
[0160] First, the calculation process of the first loop in the double-precision arithmetic mode is described.
[0161] The Wallace tree multiplier 2a receives the first bit group A10 of the multiplier A1 and the first bit group B10 of the multiplicand B1, and outputs a sum signal D(0) and a carry signal E(0). The Wallace tree multiplier 2b receives the second bit group A11 of the multiplier A1 and the first bit group B10 of the multiplicand B1, and outputs a sum signal F(0) and a carry signal G(0). The Wallace tree multiplier 2c receives the third bit group A12 of the multiplier A1 and the first bit group B10 of the multiplicand B1, and outputs a sum signal H(0) and a carry signal I(0). The Wallace tree multiplier 2d receives the fourth bit group A13 of the multiplier A1 and the first bit group B10 of the multiplicand B1, and outputs a sum signal J(0) and a carry signal K(0).
[0162] The outputs of the Wallace tree multipliers 2a to 2d are sent to the adders 4a to 4d via the first connection switch 20. The data in the registers 5a to 5d are sent to the adders 4a to 4d via the second connection switch 30.
[0163] That is, the high-order 13 bits of the sum signal D(0) are sent to the low-order 13-bit position of the first input of the adder 4b. The low-order 13 bits of the sum signal D(0) are sent to the high-order 13-bit position of the first input of the adder 4c. The high-order 13 bits of the carry signal E(0) are sent to the low-order 13-bit position of the second input of the adder 4b. The low-order 13 bits of the carry signal E(0) are sent to the high-order 13-bit position of the second input of the adder 4c. All 26 bits of the sum signal F(0) are provided to all 26-bit positions of the third input of the adder 4c. All 26 bits of the carry signal G(0) are provided to all 26-bit positions of the fourth input of the adder 4c. The high-order 13 bits of the sum signal H(0) are sent to the low-order 13-bit position of the fifth input of the adder 4c. The low-order 13 bits of the sum signal H(0) are sent to the high-order 13-bit position of the first input of the adder 4d. The high-order 13 bits of the carry signal I(0) are sent to the low-order 13 bits of the 6th input of the adder 4c. The low-order 13 bits of the carry signal I(0) are sent to the high-order 13 bits of the 2nd input of the adder 4d. All 26 bits of the sum signal J(0) are provided to all 26 bits of the 3rd input of the adder 4d. All 26 bits of the carry signal K(0) are provided to all 26 bits of the 4th input of the adder 4d.
[0164] Fig.171 is a diagram showing the input and output of adders 4a to 4d in the first cycle in the double precision operation mode of the second variant. Adder 4a receives 26 bits (all bits are 0) from shifter 7a at all 26 bits of the first input. Adder 4a receives the upper 2 bits of the addition operation result M(0) (28 bits) of adder 4b at the lower 2 bits of the second input.
[0165] The lower 26 bits {125(0)-10(0)} of the addition operation result L(0) of the adder 4a are sent to the register 5a.
[0166] The adder 4b receives the high-order 13 bits {d25(0)-d13(0)} of the sum signal D(0) at the low-order 13 bits of the first input. The adder 4b receives the high-order 13 bits {e25(0)-e13(0)} of the carry signal E(0) at the low-order 13 bits of the second input. The adder 4b receives 26 bits (all bits are 0) from the shifter 7b at all 26 bits of the third input. The adder 4b receives the high-order 2 bits of the addition operation result N(0) (28 bits) of the adder 4c at the low-order 2 bits of the fourth input.
[0167] The lower 26 bits {m25(0)-m0(0)} of the addition result M(0) of the adder 4b are sent to the register 5b as the first output. The upper 2 bits of the addition result M(0) of the adder 2b are sent to the lower 2 bits of the second input of the adder 4a as the second output.
[0168] The adder 4c receives the lower 13 bits {d12(0)-d0(0)} of the sum signal D(0) at the upper 13 bits of the first input. The adder 4c receives the lower 13 bits {e12(0)-e0(0)} of the carry signal E(0) at the upper 13 bits of the second input. The adder 4c receives all 26 bits {f25(0)-f0(0)} of the sum signal F(0) at all 26 bits of the third input. The adder 4c receives all 26 bits {g25(0)-g0(0)} of the carry signal G(0) at all 26 bits of the fourth input. The adder 4c receives the upper 13 bits {h25(0)-h13(0)} of the sum signal H(0) at the lower 13 bits of the fifth input. The adder 4c receives the high-order 13 bits {i25(0)-i13(0)} of the carry signal I(0) at the low-order 13 bits of the sixth input. The adder 4c receives 26 bits (all bits are 0) from the shifter 7c at the 26-bit positions of the seventh input. The adder 4c receives the high-order 2 bits of the addition result O(0) (28 bits) of the adder 4d at the low-order 2 bits of the eighth input.
[0169] The lower 26 bits {n25(0)-n0(0)} of the addition result N(0) of the adder 4c are sent to the register 5c as the first output. The upper 2 bits of the addition result N(0) of the adder 4c are sent to the lower 2 bits of the fourth input of the adder 4b as the second output.
[0170] The adder 4d receives the lower 13 bits {h12(0)-h0(0)} of the sum signal H(0) at the upper 13 bits of the first input. The adder 4d receives the lower 13 bits {i12(0)-i0(0)} of the carry signal I(0) at the upper 13 bits of the second input. The adder 4d receives all 26 bits {j25(0)-j0(0)} of the sum signal J(0) at all 26 bits of the third input. The adder 4d receives all 26 bits {k25(0)-k0(0)} of the carry signal K(0) at all 26 bits of the fourth input. The adder 4d receives 26 bits (all bits are 0) from the shifter 7d at all 26 bits of the fifth input.
[0171] The lower 26 bits {o25(0)-o0(0)} of the addition result O(0) of the adder 4d are sent to the register 5d as the first output. The upper 2 bits of the addition result O(0) of the adder 4d are sent to the lower 2 bits of the 8th input of the adder 4c as the second output.
[0172] Next, the calculation process of the second loop in the double-precision arithmetic mode will be described.
[0173] The Wallace tree multiplier 2a receives the first bit group A10 of the multiplier A1 and the second bit group B11 of the multiplicand B1, and outputs a sum signal D(1) and a carry signal E(1). The Wallace tree multiplier 2b receives the second bit group A11 of the multiplier A1 and the second bit group B11 of the multiplicand B1, and outputs a sum signal F(1) and a carry signal G(1). The Wallace tree multiplier 2c receives the third bit group A12 of the multiplier A1 and the second bit group B11 of the multiplicand B1, and outputs a sum signal H(1) and a carry signal I(1). The Wallace tree multiplier 2d receives the fourth bit group A13 of the multiplier A1 and the second bit group B11 of the multiplicand B1, and outputs a sum signal J(1) and a carry signal K(1).
[0174] The outputs of the Wallace tree multipliers 2a to 2d are sent to the adders 4a to 4d via the first connection switch 20. The data in the registers 5a to 5d are sent to the adders 4a to 4d via the second connection switch 30. The first connection switch 20 sends the signals D(1) to K(1) to the adders 4a to 4d in the same manner as the signals D(0) to K(0) of the first cycle.
[0175] Fig.18 The figure shows the inputs and outputs of adders 4a to 4d in the second cycle in the double-precision operation mode of the second modified example. The output of adder 4a, the first input to the second input, the fourth input and the output of adder 4b, the first input to the sixth input, the eighth input and the output of adder 4c, and the first input to the fourth input and the output of adder 4d are the signals of the second cycle corresponding to the signals provided to the inputs and the signals outputted in the second cycle as shown in the figure, and therefore the description except for the differences is omitted.
[0176] Shifter 7a shifts the 26 bits {l25(0)-l0(0)} held by register 5a to the upper 13 bits. Shifter 7b shifts the 26 bits {m25(0)-m0(0)} held by register 5b to the upper 13 bits, and sends the 13 bits {m25(0)-m13(0)} overflowing from shifter 7b to the lower 13 bits of shifter 7a.
[0177] The adder 4a receives 26 bits {upper 13 bits: l12(0)-l0(0), lower 13 bits: m25(0)-m13(0)} from the shifter 7a at all 26 bit positions of the first input.
[0178] Shifter 7c shifts the 26 bits {n25(0)-n0(0)} held by register 5c toward the upper position by 13 bits, and sends the 13 bits {n25(0)-n13(0)} overflowing from shifter 7c to the lower 13 bits of shifter 7b.
[0179] Adder 4b receives 26 bits {high-order 13 bits: m12(0)-m0(0), low-order 13 bits: n25(0)-n13(0)} from shifter 7b at all 26 bits of input 3. Adder 4b receives high-order 2 bits of addition result N(1) (28 bits) from adder 4c at low-order 2 bits of input 4.
[0180] The shifter 7d shifts the 26 bits {o25(0)-o0(0)} held by the register 5d toward the upper bits by 13 bits, and sends the 13 bits {o25(0)-o13(0)} overflowing from the shifter 7d to the lower 13 bits of the shifter 7c.
[0181] The adder 4c receives 26 bits {upper 13 bits: n12(0)-n0(0), lower 13 bits: o25(0)-o13(0)} from the shifter 7c at all 26 bit positions of the seventh input.
[0182] The adder 4d receives 26 bits {upper 13 bits: o12(0)-o0(0), lower 13 bits: all bits are 0} from the shifter 7d at all 26 bit positions of the fifth input.
[0183] The lower 26 bits {o25(1)-o0(1)} of the addition result O(1) of the adder 4d are sent to the register 5d as the first output. The upper 2 bits of the addition result O(1) of the adder 4d are sent to the lower 2 bits of the 8th input of the adder 4c as the second output.
[0184] The inputs of the Wallace tree multipliers 2a to 2d in the third round in the double-precision operation mode operate as follows.
[0185] The Wallace tree multiplier 2a receives the first bit group A10 of the multiplier A1 and the third bit group B12 of the multiplicand B1, and outputs a sum signal D(2) and a carry signal E(2). The Wallace tree multiplier 2b receives the second bit group A11 of the multiplier A1 and the third bit group B12 of the multiplicand B1, and outputs a sum signal F(2) and a carry signal G(2). The Wallace tree multiplier 2c receives the third bit group A12 of the multiplier A1 and the third bit group B12 of the multiplicand B1, and outputs a sum signal H(2) and a carry signal I(2). The Wallace tree multiplier 2d receives the fourth bit group A13 of the multiplier A1 and the third bit group B12 of the multiplicand B1, and outputs a sum signal J(2) and a carry signal K(2).
[0186] The calculation process after the third cycle is the same as the calculation process of the second cycle, so the description will not be repeated.
[0187] The inputs of the Wallace tree multipliers 2a to 2d in the fourth round in the double-precision operation mode operate as follows.
[0188] The Wallace tree multiplier 2a receives the first bit group A10 of the multiplier A1 and the fourth bit group B13 of the multiplicand B1, and outputs a sum signal D(3) and a carry signal E(3). The Wallace tree multiplier 2b receives the second bit group A11 of the multiplier A1 and the fourth bit group B13 of the multiplicand B1, and outputs a sum signal F(3) and a carry signal G(3). The Wallace tree multiplier 2c receives the third bit group A12 of the multiplier A1 and the fourth bit group B13 of the multiplicand B1, and outputs a sum signal H(3) and a carry signal I(3). The Wallace tree multiplier 2d receives the fourth bit group A13 of the multiplier A1 and the fourth bit group B13 of the multiplicand B1, and outputs a sum signal J(3) and a carry signal K(3).
[0189] The calculation process after the fourth cycle is the same as the calculation process of the second cycle, so the description will not be repeated.
[0190] After the fourth cycle is completed, the second connection switch 30 switches the output destination of the data in the registers 5a to 5d to the output terminals OP1 to OP4. Thus, the first to fourth bit groups C10 to C13 of the product C1 are output from the output terminals OP1 to OP4.
[0191] Fig.19 2a shows the structure of the Wallace tree multiplier 2a. Fig. 20 Represents the data generated by the Wallace tree multiplier 2a.
[0192] The Wallace tree multiplier 2a includes an input generator 79 and CSA (Carry Save Adder) 51 to CSA 61. The input generator 79 generates X0 to X12 of 13 bits each from a 13-bit input IN1 and a 13-bit input IN2.
[0193] X0 is the product of IN1 and the 0th bit (LSB) of IN2. When the 0th bit of IN2 is 0, all bits of X0 are 0. When the 0th bit of IN2 is 1, all bits of X0 are the same as all bits of IN1. Similarly, Xi (i = 1 to 13) is the product of the i-th bit of IN1 and IN2.
[0194] CSA 51 performs a carry signal-preserving addition operation on X1, X2, and X3, and outputs a sum signal 1S and a carry signal 1R. CSA 52 performs a carry signal-preserving addition operation on X3, X4, and X5, and outputs a sum signal 2S and a carry signal 2R. CSA 53 performs a carry signal-preserving addition operation on X6, X7, and X8, and outputs a sum signal 3S and a carry signal 3R. CSA 54 performs a carry signal-preserving addition operation on X9, X10, and X11, and outputs a sum signal 4S and a carry signal 4R. CSA 55 performs a carry signal-preserving addition operation on the sum signal 1S, the carry signal 1R, and the sum signal 2S, and outputs a sum signal 5S and a carry signal 5R. CSA 56 performs a carry signal-preserving addition operation on the carry signal 2R, the sum signal 3S, and the carry signal 3R, and outputs a sum signal 6S and a carry signal 6R. CSA 57 performs a carry-signal-retaining addition operation on the sum signal 4S, the carry signal 4R, and X12, and outputs a sum signal 7S and a carry signal 7R. CSA 58 performs a carry-signal-retaining addition operation on the sum signal 5S, the carry signal 5R, and the sum signal 6S, and outputs a sum signal 8S and a carry signal 8R. CSA 59 performs a carry-signal-retaining addition operation on the carry signal 6R, the sum signal 7S, and the carry signal 7R, and outputs a sum signal 9S and a carry signal 9R. CSA 60 performs a carry-signal-retaining addition operation on the sum signal 8S, the carry signal 8R, and the sum signal 9S, and outputs a sum signal 10S and a carry signal 10R. CSA 61 performs a carry-signal-retaining addition operation on the sum signal 10S, the carry signal 10R, and the carry signal 9R, and outputs a sum signal 11S and a carry signal 11R. The sum signal 11S is the sum signal D output from the Wallace tree multiplier 2a, and the carry signal 11R is the carry signal E output from the Wallace tree multiplier 2a.
[0195] The adders 4a to 4d may include a plurality of CSAs and perform addition operations based on the Wallace tree.
[0196] As described above, according to this modification, half-precision calculation, single-precision calculation, or double-precision calculation can be executed with a small circuit scale.
[0197] [Third Modification]
[0198] Fig.21 The structure of the computing device 101 according to the third modification is shown.
[0199] The computing device 101 includes Wallace tree multipliers 2a to 2d, a first connection switch 120, adders 14a to 14d, registers 15a to 15d, registers 25a to 25d, a second connection switch 130, adders 16a to 16d, output terminals OP1 to OP4, and switches 161b to 161d, 151b to 151d. The computing device 1 receives eight inputs (IN1 to IN8) and outputs four computation results (OUT1 to OUT4) in the same manner as the second variant.
[0200] The computing device 101 of the third variation is a carry-save adder (CSA) that is used to apply the carry-save adder (CSA) to the computing device 1 of the second variation. Figure 1 The implementation method is Figure 6 The first modification is obtained by the same modification as the modification of the first modification. That is, the registers 5a to 5d in the operation device 1 are divided into registers 15a to 15d and registers 25a to 25d so that they can each hold a sum signal and a carry signal. In addition, in order to perform addition operation on the sum signal and the carry signal held by the registers 15a to 15d and the registers 25a to 25d to calculate the final product, adders 16a to 16d corresponding to the second adding element 544 of the first modification are provided. In addition, along with the adders 4a to 4d being set as CSA, the switches 9b to 9d that switch whether to send the carry bit from the adders 4b to 4d to the high-order side are divided into switches 161b to 161d for the sum signal and switches 151b to 151d for the carry signal. Next, the structure and operation of the operation device 101 are described with the focus on the changes in the operation device 1 of the second modification.
[0201] The Wallace tree multipliers 2a to 2d are the same as those in the second variation.
[0202] The adders 14a to 14d output a sum signal and a carry signal of the previous stage of the addition operation results of a plurality of data of two unit bit lengths based on the Wallace tree.
[0203] The registers 15a to 15d each hold the sum signal output from the corresponding adder 14a to 14d.
[0204] The registers 25a to 25d respectively hold carry signals output from the corresponding adders 14a to 14d.
[0205] Each of the adders 16a to 16d performs addition operation on the input sum signal and carry signal.
[0206] Output terminals OP1 to OP4 output the addition results of adders 16 a to 16 d , respectively.
[0207] The first connection switch 120 is the same as that in the second modification.
[0208] Similar to the second variant, the second connection switch 130 switches the output destinations of the groups of sum signals and carry signals of registers 15a and 25a, the groups of sum signals and carry signals of registers 15b and 25b, the groups of sum signals and carry signals of registers 15c and 25c, and the groups of sum signals and carry signals of registers 15d and 25d instead of switching the output destinations of the addition operation results of registers 5a to 5d.
[0209] The switch 161b switches whether the carry bit of the sum signal is sent from the adder 14b to the adder 14a. The switch 161c switches whether the carry bit of the sum signal is sent from the adder 14c to the adder 14b. The switch 161d switches whether the carry bit of the sum signal is sent from the adder 14d to the adder 14c. The switch 151b switches whether the carry bit of the carry signal is sent from the adder 14b to the adder 14a. The switch 151c switches whether the carry bit of the carry signal is sent from the adder 14c to the adder 14b. The switch 151d switches whether the carry bit of the carry signal is sent from the adder 14d to the adder 14c.
[0210] The computing device 101 operates in the half-precision computing mode, the single-precision computing mode, and the double-precision computing mode similarly to the second modification. The operation of each computing mode will be described below, centering on the differences from the operation of the computing device 1 of the second modification.
[0211] (Half-precision operation mode)
[0212] Fig. 22 The operation of the half-precision operation mode of the arithmetic device 101 according to the third modification will be described. In the half-precision operation mode, the outputs of the Wallace tree multipliers 2a to 2d are sent to the adders 16a to 16d via the first connection switch 120 .
[0213] That is, for example, all 26 bits of the sum signal D are supplied to all 26 bit positions of the first input of the adder 16a, and all 26 bits of the carry signal E are supplied to all 26 bit positions of the second input of the adder 16a.
[0214] Fig.23 1 and 2 show the input of the adder 16 a in the half-precision operation mode of the third modification example.
[0215] The adder 16a receives all 26 bits {d25-d0} of the sum signal D at all 26 bit positions of the first input. The adder 16a receives all 26 bits {e25-e0} of the carry signal E at all 26 bit positions of the second input. The adder 16a adds all 26 bits of the sum signal D and all 26 bits of the carry signal E, and outputs the lower 26 bits as the first product C1. In addition to the input and output of the adders 16b to 16d, Fig. 22 Except for the difference from the adder 16a, the other parts operate in the same manner as the adder 16a.
[0216] (Single precision operation mode)
[0217] Fig.24 The operation in the single-precision operation mode of the arithmetic device 101 of the third modification will be described mainly with a focus on the differences from the second modification in the operation of calculating the product C1 of the multiplier A1 and the multiplicand B1 . Fig.16 The shifters 7a to 7d are divided into shifters 17a to 17d and shifters 27a to 27d in order to shift the sum signal and the carry signal.
[0218] Fig.25 The figure shows the input and output of the adders 14 a to 14 b in the first round in the single-precision operation mode of the third modification example.
[0219] The input and output of the adder 14a are similar to those of the adder 4a in the second variant, with the third input being divided into the third input of the sum signal and the fourth input of the carry signal, the fourth input being divided into the fifth input of the sum signal and the sixth input of the carry signal, and the output being divided into the first output of the sum signal and the second output of the carry signal. The adder 14a receives 26 bits (all bits are 0) from the shifter 17a at all 26 bit positions of the third input. The adder 14a receives 26 bits (all bits are 0) from the shifter 27a at all 26 bit positions of the fourth input. The adder 14a receives the upper 2 bits of the sum signal SM (28 bits) as the addition result of the adder 14b at the lower 2 bit position of the fifth input. The adder 14a receives the upper 3 bits of the carry signal RM (29 bits) as the addition result of the adder 14b at the lower 3 bit position of the sixth input.
[0220] The lower 26 bits {S125(0)-S10(0)} of the sum signal SL(0) as the addition result of the adder 14a are sent to the register 15a as the first output. The lower 26 bits {R125(0)-R10(0)} of the carry signal RL(0) as the addition result of the adder 14a are sent to the register 25a as the second output.
[0221] The input and output of the adder 14b are similar to those of the adder 4b in the second modified example, and the fifth input is divided into the fifth input of the sum signal and the sixth input of the carry signal, the first output is divided into the first output of the sum signal and the second output of the carry signal, and the second output is divided into the third output of the sum signal and the fourth output of the carry signal. The adder 14b receives 26 bits (all bits are 0) from the shifter 17b at all 26 bit positions of the fifth input. The adder 14b receives 26 bits (all bits are 0) from the shifter 27b at all 26 bit positions of the sixth input.
[0222] The lower 26 bits {Sm25(0)-Sm0(0)} of the sum signal SM(0) as the addition result of the adder 14b are sent to the register 15b as the first output. The upper 2 bits of the sum signal SM(0) as the addition result of the adder 14b are sent to the lower 2 bits of the fifth input of the adder 14a as the third output. The lower 26 bits {Rm25(0)-Rm0(0)} of the carry signal RM(0) as the addition result of the adder 14b are sent to the register 25b as the second output. The upper 3 bits of the carry signal RM(0) as the addition result of the adder 14b are sent to the lower 3 bits of the sixth input of the adder 14a as the fourth output.
[0223] Fig.26 The figure shows the input and output of the adders 14a to 14b in the second round in the single-precision operation mode of the third modification. The input sources of the signals to the adders 14a to 14b are the same as those in the first round.
[0224] Shifter 17a shifts the 26 bits {Sl25(0)-Sl0(0)} held by register 15a to the upper 13 bits. Shifter 17b shifts the 26 bits {Sm25(0)-Sm0(0)} held by register 15b to the upper 13 bits, and sends the 13 bits {Sm25(0)-Sm13(0)} overflowing from shifter 17b to the lower 13 bits of shifter 17a. Shifter 27a shifts the 26 bits {Rl25(0)-Rl0(0)} held by register 25a to the upper 13 bits. Shifter 27b shifts the 26 bits {Rm25(0)-Rm0(0)} held by register 25b toward the upper 13 bits, and sends the 13 bits {Rm25(0)-Rm13(0)} overflowing from shifter 27b to the lower 13 bits of shifter 27a.
[0225] The adder 14a receives 26 bits {upper 13 bits: Sl12(0)-Sl0(0), lower 13 bits: Sm25(0)-Sm13(0)} from the shifter 17a at all 26 bit positions of the third input. The adder 14a receives 26 bits {upper 13 bits: Rl12(0)-Rl0(0), lower 13 bits: Rm25(0)-Rm13(0)} from the shifter 27a at all 26 bit positions of the fourth input.
[0226] The adder 14a receives the upper 2 bits of the sum signal SM(1) (28 bits) as the addition result of the adder 14b at the lower 2 bits of the fifth input. The adder 14a receives the upper 3 bits of the carry signal RM(1) (29 bits) as the addition result of the adder 14b at the lower 3 bits of the sixth input.
[0227] The lower 26 bits {S125(1)-S10(1)} of the sum signal SL(1) as the addition result of the adder 14a are sent to the register 15a. The lower 26 bits {R125(1)-R10(1)} of the carry signal RL(1) as the addition result of the adder 14a are sent to the register 25a.
[0228] The adder 14b receives 26 bits {upper 13 bits: Sm12(0)-Sm0(0), lower 13 bits: all bits are 0} from the shifter 17b at all 26 bit positions of the fifth input. The adder 14b receives 26 bits {upper 13 bits: Rm12(0)-Rm0(0), lower 13 bits: all bits are 0} from the shifter 27b at all 26 bit positions of the sixth input.
[0229] The lower 26 bits {Sm25(1)-Sm0(1)} of the sum signal SM(1) as the addition result of the adder 14b are sent to the register 15b as the first output. The upper 2 bits of the sum signal SM(1) as the addition result of the adder 14b are sent to the lower 2 bits of the fifth input of the adder 14a as the third output. The lower 26 bits {Rm25(1)-Rm0(1)} of the carry signal RM(1) as the addition result of the adder 14b are sent to the register 25b as the second output. The upper 3 bits of the carry signal RM(1) as the addition result of the adder 14b are sent to the lower 3 bits of the sixth input of the adder 14a as the fourth output.
[0230] After the second cycle is completed, the second connection switch 130 outputs the data in the registers 15a to 15d and 25a to 25d to any one of the adders 16a to 16d.
[0231] The sum signal {S125(1)-S10(1)} held by the register 15a and the carry signal {R125(1)-R10(1)} held by the register 25a are sent to the adder 16a. The adder 16a performs the addition operation and outputs the upper 26 bits C10 of the first product C1 to the output terminal OP1. The adder 16b similarly outputs the lower 26 bits C11 of the first product C1 to the output terminal OP2. Here, the adder 16b may provide the carry accompanying the addition operation to the adder 16a, and the adder 16a may perform the above-mentioned addition operation including the carry.
[0232] (Double precision operation mode)
[0233] Fig. 27 The operation of the double-precision operation mode of the arithmetic device 101 according to the third modification will be described mainly focusing on the differences from the second modification.
[0234] Fig.28A and Fig.28B The figure shows the input and output of the adders 14 a to 14 d in the first round in the double-precision operation mode of the third modification example.
[0235] Along with the division of registers 5a to 5d of the second variant into registers 15a to 15d for sum signals and registers 25a to 25d for carry signals, the input from shifters 7a to 7d to adders 4a to 4d in the second variant is divided into input of sum signals from shifters 17a to 17d to adders 14a to 14d and input of carry signals from shifters 27a to 27d to adders 14a to 14d. In addition, along with setting adders 14a to 14d as CSA, the carry from the lower digit is divided into the carry from the sum signal and the carry from the carry signal. In addition, the output of adders 4a to 4d is divided into the sum signal and the carry signal. In addition to these differences, Figure 28A to Figure 28B The input and output of adders 14a to 14d are shown in FIG. Fig.17 The input and output of the adders 4a to 4d shown are the same.
[0236] The adder 14a receives 26 bits (all bits are 0) from the shifter 17a at all 26 bit positions of the first input. The adder 14a receives 26 bits (all bits are 0) from the shifter 27a at all 26 bit positions of the second input. The adder 14a receives the upper 2 bits of the sum signal SM(0) (28 bits) as the addition result of the adder 14b at the lower 2 bit position of the third input. The adder 14a receives the upper 3 bits of the carry signal RM(0) (29 bits) as the addition result of the adder 14b at the lower 3 bit position of the fourth input.
[0237] The lower 26 bits {S125(0)-S10(0)} of the sum signal SL(0) as the addition result of the adder 14a are sent to the register 15a. The lower 26 bits {R125(0)-R10(0)} of the carry signal RL(0) as the addition result of the adder 14a are sent to the register 25a.
[0238] The adder 14b receives 26 bits (all bits are 0) from the shifter 17b at all 26 bit positions of the third input. The adder 14b receives 26 bits (all bits are 0) from the shifter 27b at all 26 bit positions of the fourth input. The adder 14b receives the upper 3 bits of the sum signal SN(0) (29 bits) as the addition result of the adder 14c at the lower 3 bit position of the fifth input. The adder 14b receives the upper 4 bits of the carry signal RN(0) (30 bits) as the addition result of the adder 14c at the lower 4 bit position of the sixth input.
[0239] The lower 26 bits {Sm25(0)-Sm0(0)} of the sum signal SM(0) as the addition result of the adder 14b are sent to the register 15b as the first output. The upper 2 bits of the sum signal SM(0) as the addition result of the adder 14b are sent to the lower 2 bits of the third input of the adder 14a as the third output. The lower 26 bits {Rm25(0)-Rm0(0)} of the carry signal RM(0) as the addition result of the adder 14b are sent to the register 15b as the second output. The upper 3 bits of the carry signal RM(0) as the addition result of the adder 14b are sent to the lower 3 bits of the fourth input of the adder 14a as the fourth output.
[0240] The adder 14c receives 26 bits (all bits are 0) from the shifter 17c at all 26 bit positions of the 7th input. The adder 14c receives 26 bits (all bits are 0) from the shifter 27c at all 26 bit positions of the 8th input. The adder 14c receives the upper 2 bits of the sum signal SO(0) (28 bits) as the addition result of the adder 14d at the lower 2 bit position of the 9th input. The adder 14c receives the upper 3 bits of the carry signal RO(0) (29 bits) as the addition result of the adder 14d at the lower 3 bit position of the 10th input.
[0241] The lower 26 bits {Sn25(0)-Sn0(0)} of the sum signal SN(0) as the addition result of the adder 14c are sent to the register 15c as the first output. The upper 3 bits of the sum signal SN(0) as the addition result of the adder 14c are sent to the lower 3 bits of the fifth input of the adder 14b as the third output. The lower 26 bits {Rn25(0)-Rn0(0)} of the carry signal RN(0) as the addition result of the adder 14c are sent to the register 25c as the second output. The upper 4 bits of the carry signal RN(0) as the addition result of the adder 14c are sent to the lower 4 bits of the sixth input of the adder 14b as the fourth output.
[0242] The adder 14d receives 26 bits (all bits are 0) from the shifter 17d at all 26 bit positions of the fifth input. The adder 14d receives 26 bits (all bits are 0) from the shifter 27d at all 26 bit positions of the fifth input.
[0243] The lower 26 bits {So25(0)-So0(0)} of the sum signal SO(0) as the addition result of the adder 14d are sent to the register 15d as the first output. The upper 2 bits of the sum signal SO(0) as the addition result of the adder 14d are sent to the lower 2 bits of the 9th input of the adder 14c as the third output. The lower 26 bits {Ro25(0)-Ro0(0)} of the carry signal RO(0) as the addition result of the adder 14d are sent to the register 25d as the second output. The upper 3 bits of the carry signal RO(0) as the addition result of the adder 14d are sent to the lower 3 bits of the 10th input of the adder 14c as the fourth output.
[0244] Figure 29A to Figure 29B 1 is a diagram showing input and output of adders 14a to 14d in the second round in the double precision operation mode of the third modification. The input sources of signals to adders 14a to 14d are the same as those in the second round.
[0245] Shifter 17a shifts the 26 bits {Sl25(0)-Sl0(0)} held by register 15a to the upper 13 bits. Shifter 17b shifts the 26 bits {Sm25(0)-Sm0(0)} held by register 15b to the upper 13 bits, and sends the 13 bits {Sm25(0)-Sm13(0)} overflowing from shifter 17b to the lower 13 bits of shifter 17a. Shifter 27a shifts the 26 bits {Rl25(0)-Rl0(0)} held by register 25a to the upper 13 bits. Shifter 27b shifts the 26 bits {Rm25(0)-Rm0(0)} held by register 25b toward the upper 13 bits, and sends the 13 bits {Rm25(0)-Rm13(0)} overflowing from shifter 27b to the lower 13 bits of shifter 27a.
[0246] The adder 14a receives 26 bits {upper 13 bits: Sl12(0)-Sl0(0), lower 13 bits: Sm25(0)-Sm13(0)} from the shifter 17a at all 26 bit positions of the first input. The adder 14a receives 26 bits {upper 13 bits: Rl12(0)-Rl0(0), lower 13 bits: Rm25(0)-Rm13(0)} from the shifter 27a at all 26 bit positions of the second input. The adder 14a receives the upper 2 bits of the sum signal SM(1) (28 bits) as the addition result of the adder 14b at the lower 2 bit position of the third input. The adder 14a receives the upper 3 bits of the carry signal RM(1) (29 bits) as the addition result of the adder 14b at the lower 3 bit position of the fourth input.
[0247] The lower 26 bits {S125(1)-S10(1)} of the sum signal SL(1) as the addition result of the adder 14a are sent to the register 15a. The lower 26 bits {R125(1)-R10(1)} of the carry signal RL(1) as the addition result of the adder 14a are sent to the register 25a.
[0248] Shifter 17c shifts the 26 bits {Sn25(0)-Sn0(0)} held by register 15c to the upper 13 bits, and sends the 13 bits {Sn25(0)-Sn13(0)} overflowing from shifter 17c to the lower 13 bits of shifter 17b. Shifter 27c shifts the 26 bits {Rn25(0)-Rn0(0)} held by register 25c to the upper 13 bits, and sends the 13 bits {Rn25(0)-Rn13(0)} overflowing from shifter 27c to the lower 13 bits of shifter 27b.
[0249] The adder 14b receives 26 bits {upper 13 bits: Sm12(0)-Sm0(0), lower 13 bits: Sn25(0)-Sn13(0)} from the shifter 17b at all 26 bit positions of the third input. The adder 14b receives 26 bits {upper 13 bits: Rm12(0)-Rm0(0), lower 13 bits: Rn25(0)-Rn13(0)} from the shifter 27b at all 26 bit positions of the fourth input. The adder 14b receives the upper 3 bits of the sum signal SN(1) (29 bits) as the addition result of the adder 14c at the lower 3 bit position of the fifth input. The adder 14b receives the upper 4 bits of the carry signal RN(1) (30 bits) as the addition result of the adder 14c at the lower 4 bit position of the sixth input.
[0250] The lower 26 bits {Sm25(1)-Sm0(1)} of the sum signal SM(1) as the addition result of the adder 14b are sent to the register 15b as the first output. The upper 2 bits of the sum signal SM(1) as the addition result of the adder 14b are sent to the lower 2 bits of the third input of the adder 14a as the third output. The lower 26 bits {Rm25(1)-Rm0(1)} of the carry signal RM(1) as the addition result of the adder 14b are sent to the register 25b as the second output. The upper 3 bits of the carry signal RM(1) as the addition result of the adder 14b are sent to the lower 3 bits of the fourth input of the adder 14a as the fourth output.
[0251] Shifter 17d shifts the 26 bits {So25(0)-So0(0)} held by register 15d toward the upper bits by 13 bits, and sends the 13 bits {So25(0)-So13(0)} overflowing from shifter 17d to the lower 13 bits of shifter 17c. Shifter 27d shifts the 26 bits {Ro25(0)-Ro0(0)} held by register 25d toward the upper bits by 13 bits, and sends the 13 bits {Ro25(0)-Ro13(0)} overflowing from shifter 27d to the lower 13 bits of shifter 27c.
[0252] The adder 14c receives 26 bits {upper 13 bits: Sn12(0)-Sn0(0), lower 13 bits: So25(0)-So13(0)} from the shifter 17c at all 26 bit positions of the 7th input. The adder 14c receives 26 bits {upper 13 bits: Rn12(0)-Rn0(0), lower 13 bits: Ro25(0)-Ro13(0)} from the shifter 27c at all 26 bit positions of the 8th input. The adder 14c receives the upper 2 bits of the sum signal SO(1) (28 bits) as the addition result of the adder 14d at the lower 2 bit position of the 9th input. The adder 14c receives the upper 3 bits of the carry signal RO(1) (29 bits) as the addition result of the adder 14d at the lower 3 bit position of the 10th input.
[0253] The lower 26 bits {Sn25(1)-Sn0(1)} of the sum signal SN(1) as the addition result of the adder 14c are sent to the register 15c as the first output. The upper 3 bits of the sum signal SN(1) as the addition result of the adder 14c are sent to the lower 3 bits of the fifth input of the adder 14b as the third output. The lower 26 bits {Rn25(1)-Rn0(1)} of the carry signal RN(1) as the addition result of the adder 14c are sent to the register 25c as the second output. The upper 4 bits of the carry signal RN(1) as the addition result of the adder 14c are sent to the lower 4 bits of the sixth input of the adder 14b as the fourth output.
[0254] The adder 14d receives 26 bits {upper 13 bits: So12(0)-So0(0), lower 13 bits: all bits are 0} from the shifter 17d at all 26 bit positions of the fifth input. The adder 14d receives 26 bits {upper 13 bits: Ro12(0)-Ro0(0), lower 13 bits: all bits are 0} from the shifter 27d at all 26 bit positions of the sixth input.
[0255] The lower 26 bits {So25(1)-So0(1)} of the sum signal SO(1) as the addition result of the adder 14d are sent to the register 15d as the first output. The upper 2 bits of the sum signal SO(1) as the addition result of the adder 14d are sent to the lower 2 bits of the 9th input of the adder 14c as the third output. The lower 26 bits {Ro25(1)-Ro0(1)} of the carry signal RO(1) as the addition result of the adder 14d are sent to the register 25d as the second output. The upper 3 bits of the carry signal RO(1) as the addition result of the adder 14d are sent to the lower 3 bits of the 10th input of the adder 14c as the fourth output.
[0256] The inputs of the Wallace tree multipliers 2a to 2d in the third to fourth rounds in the double precision operation mode are the same as those in the second modification. The calculation process after the third to fourth rounds is the same as that of the second round, so the description will not be repeated.
[0257] After the fourth cycle is completed, the second connection switch 130 outputs the data in the registers 15a to 15d and 25a to 25d to any one of the adders 16a to 16d.
[0258] The sum signal {S125(3)-S10(3)} held by register 15a and the carry signal {R125(3)-R10(3)} held by register 25a are sent to adder 16a. Adder 16a performs the addition operation and outputs the first bit group C10 of product C1 to output terminal OP1. Adders 16b to 16d similarly output the second bit group C11 to the fourth bit group C13 of product C1 to output terminals OP2 to OP4. Here, adders 16b to 16d may provide the carry accompanying the addition operation to adders 16a to 16c on the higher order side, and adders 16a to 16c on the higher order side may include the carry and perform the above-mentioned addition operation.
[0259] Next, a specific configuration example of the adders 14a to 14d will be described.
[0260] In the half-precision operation mode, no data is input to the adders 14a to 14d. That is, the sum signals D, F, H, and J and the carry signals E, G, I, and K output from the Wallace tree multipliers 2a to 2d bypass the adders 14a to 14d and are sent to the adders 16a to 16d. In the single-precision operation mode, the adders 14a to 14d sequentially perform carry-preserving addition operations of 6 inputs and 2 outputs, 6 inputs and 2 outputs + 2 carry signal outputs, 6 inputs and 2 outputs, and 6 inputs and 2 outputs + 2 carry signal outputs. In the double-precision operation mode, the adders 14a to 14d sequentially perform carry-preserving addition operations of 4 inputs and 2 outputs, 6 inputs and 2 outputs + 2 carry signal outputs, 10 inputs and 2 outputs + 2 carry signal outputs, and 6 inputs and 2 outputs + 2 carry signal outputs.
[0261] The adder 14 a includes four CSAs and performs carry-save addition using four CSAs in the single-precision operation mode and performs carry-save addition using two CSAs in the double-precision operation mode.
[0262] The adder 14b includes four CSAs and performs carry-signal-preserving addition operations using the four CSAs in the single-precision operation mode and the double-precision operation mode.
[0263] The adder 14c includes eight CSAs and performs carry-save addition operations using four CSAs in the single-precision operation mode and performs carry-save addition operations using eight CSAs in the double-precision operation mode.
[0264] The adder 14d includes four CSAs and performs carry-signal-preserving addition operations using the four CSAs in the single-precision operation mode and the double-precision operation mode.
[0265] Fig.30 FIG. 2 shows a configuration of an adder 200 that performs carry signal-preserving addition using two CSAs. The configuration of the adder 200 is the configuration of the adder 14a in double-precision operation mode. Fig.31 Indicates input data, intermediate data, and output data of the adder 200.
[0266] Four data Y0, Y1, Y2, and Y3 are input to the adder 200.
[0267] CSA 111 performs carry-signal-preserving addition operation on Y0, Y1 and Y2, and outputs sum signal 1S and carry signal 1R. CSA 112 performs carry-signal-preserving addition operation on Y3, sum signal 1S and carry signal 1R, and outputs sum signal 2S and carry signal 2R.
[0268] The lower 26 bits of the sum signal 2S are output to one register, and the lower 26 bits of the carry signal 2R are output to another register.
[0269] Fig.32 1 is a diagram showing the structure of an adder 300 that performs carry-signal-preserving addition using four CSAs. The structure of the adder 300 is the structure of the adders 14a to 14d in single-precision operation mode and the structure of the adders 14b and 14d in double-precision operation mode. Fig.33 1 is a diagram showing input data, intermediate data, and output data of the adder 300 .
[0270] Six data Y0, Y1, Y2, Y3, Y4, and Y5 are input to the adder 300.
[0271] CSA 121 performs a carry-signal-preserving addition operation on Y0, Y1, and Y2, and outputs a sum signal 1S and a carry signal 1R. CSA 122 performs a carry-signal-preserving addition operation on Y3, Y4, and Y5, and outputs a sum signal 2S and a carry signal 2R. CSA 123 performs a carry-signal-preserving addition operation on the sum signal 1S, the carry signal 1R, and the sum signal 2S, and outputs a sum signal 3S and a carry signal 3R. CSA 124 performs a carry-signal-preserving addition operation on the sum signal 3S, the carry signal 3R, and the carry signal 2R, and outputs a sum signal 4S and a carry signal 4R.
[0272] The lower 26 bits of the sum signal 4S are output to one register, and the lower 26 bits of the carry signal 4R are output to another register. When the carry signal is output, the upper 2 bits of the sum signal 4S are output to another adder as a carry signal, and the upper 3 bits of the carry signal 4R are output to another adder as a carry signal.
[0273] Alternatively, when the sum signals 1S, 2S and the carry signals 1R, 2R are generated, 2-bit or 3-bit carry bits may be generated according to their patterns and output from the adder 300 to other adders.
[0274] Fig.34 1 is a diagram showing the structure of an adder 400 that performs carry signal-preserving addition using 8 CSAs. The structure of the adder 400 is the structure of the adder 14 c in the double-precision operation mode. The adder 400 receives 10 data Y0 to Y9.
[0275] CSA 131 performs carry signal-preserving addition operation on Y0, Y1 and Y2, and outputs sum signal 1S and carry signal 1R. CSA 132 performs carry signal-preserving addition operation on Y3, Y4 and Y5, and outputs sum signal 2S and carry signal 2R. CSA133 performs carry signal-preserving addition operation on Y6, Y7 and Y8, and outputs sum signal 3S and carry signal 3R.
[0276] CSA 134 performs a carry-signal-preserving addition operation on the sum signal 1S, the carry signal 1R, and the sum signal 2S, and outputs a sum signal 4S and a carry signal 4R. CSA 135 performs a carry-signal-preserving addition operation on Y9, the carry signal 2R, and the sum signal 3S, and outputs a sum signal 5S and a carry signal 5R. CSA 136 performs a carry-signal-preserving addition operation on the sum signal 4S, the carry signal 4R, and the sum signal 5S, and outputs a sum signal 6S and a carry signal 6R. CSA 137 performs a carry-signal-preserving addition operation on the sum signal 6S, the carry signal 3R, and the carry signal 5R, and outputs a sum signal 7S and a carry signal 7R. CSA 138 performs a carry-signal-preserving addition operation on the carry signal 6R, the sum signal 7S, and the carry signal 7R, and outputs a sum signal 8S and a carry signal 8R.
[0277] The lower 26 bits of the sum signal 8S are output to one register, and the lower 26 bits of the carry signal 8R are output to another register. In addition, the upper 3 bits of the sum signal 8S are output as a carry signal to another adder, and the upper 4 bits of the carry signal 8R are output as a carry signal to another adder.
[0278] According to the computing device of this embodiment, the adders 14a to 14d output the sum signal and carry signal of the previous stage of the addition result, and the adders 16a to 16d perform only one addition operation in two cycles in single-precision computing and only one addition operation in four cycles in double-precision computing. Therefore, in this embodiment, the operation speed and power efficiency of the computing device as a whole can be increased compared with the second variant.
[0279] [Fourth Modification]
[0280] Fig.35 The configuration of a computing system 1000 according to a fourth modification is shown. The computing system 100 includes a computing unit 900 and a plurality of element processors PE1 to PE4.
[0281] A plurality of element processors PE1 to PE4 share the computing unit 900. When the computing system 1000 performs matrix operations, the element processors PE1 to PE4 act as a processor in cooperation, and when performing operations other than matrix operations, the element processors PE1 to PE4 act as independent processors. When the computing system 1000 performs operations other than matrix operations, the element processors PE1 to PE4 may act as a processor. When the element processors PE1 to PE4 act as a processor, the element processors PE1 to PE4 act by one instruction, so the element processors PE1 to PE4 can be regarded as performing SIMD operations.
[0282] Element processors PE1 to PE4 are chained. Specifically, element processor PE1 is connected to element processor PE2 via a data bus, element processor PE2 is connected to element processor PE3 via a data bus, element processor PE3 is connected to element processor PE4 via a data bus, and element processor PE4 is connected to element processor PE1 via a data bus. Processor IDs (00, 01, 10, 11) that can uniquely identify element processors are set for element processors PE1 to PE4.
[0283] A storage space is set in the operation system 1000. The storage address of the storage space includes a processor ID. For example, the lower 2 bits of the storage address may correspond to the processor ID. For example, a storage space corresponding to a 10-bit address is allocated to each of the element processors PE1 to PE4. Thus, the storage space of the operation system 1000 is expanded to 12 bits. In other words, the storage space of the operation system 1000 is divided into four equal parts, and the storage area represented by the storage address is accessed by the element processor represented by the processor ID included in each storage address.
[0284] Each of the element processors PE1 to PE4 can access a storage area (responsible area) represented by a storage address containing the processor ID of the element processor, but cannot access a storage area (non-responsible area) represented by a storage address containing a processor ID different from the processor ID of the element processor. Each of the element processors PE1 to PE4 sequentially transfers data to other element processors via a chain connection (circular shift). Thus, each of the element processors PE1 to PE4 can read data from a non-responsible area or write data to a non-responsible area. Each of the element processors PE1 to PE4 maintains the operation object of the operation unit 900, that is, the input data, and the operation result of the operation unit 900, that is, the output data, in the area represented by the storage address.
[0285] The operation unit 900 can, for example, execute a plurality of floating-point operations in parallel. The operation unit 900 can, for example, execute operations for a deep neural network (DNN: Deep Neural Network) and a convolutional neural network (CNN: Convolutional Network).
[0286] The calculation unit 900 includes a plurality of calculation devices 1A to 1D. The calculation devices 1A to 1D are respectively the calculation device 405 described in the embodiment, the calculation device 405 described in the first modification, the calculation device 1 described in the second modification, or the calculation device 101 described in the third modification.
[0287] The computing devices 1A to 1D are devices that perform a part of the computing unit 900. The element processor PE1 can access the register of the computing device 1A. The element processor PE2 can access the register of the computing device 1B. The element processor PE3 can access the register of the computing device 1C. The element processor PE4 can access the register of the computing device 1D.
[0288] (Other Modifications)
[0289] The present invention is not limited to the above-described embodiment, and includes the following modified examples.
[0290] (1) In the above-mentioned embodiment, the operation device performs a multiplication operation (A*B), but it is also possible to perform A*B+C. To this end, in the case of single-precision operation, the initial value of the third input of the adder 4a, 4c, 14a, 14c is changed from 0 to C, and in the case of double-precision operation, the initial value of the first input of the adder 4a, 14a is changed from 0 to C. In the case of half-precision operation, C is also provided to the unused input port of the adder 4a to 4d, 14a to 14d.
[0291] (2) In the above-mentioned embodiment, the operation circuit for the significant digit part of the floating-point data is shown, but the operation circuit for the fixed-point data and the block floating-point data can also be applied. In addition, the operation circuit for the data in which these operation data (floating-point format, fixed-point format and block floating-point format) exist in a mixture can also be applied.
[0292] The embodiments disclosed this time should be considered as illustrative in all points and not restrictive. The scope of the present invention is indicated by the claims rather than the above description, and is intended to include all modifications within the meaning and scope equivalent to the claims.
[0293] Description of Reference Numerals
[0294] 1, 1A-1D, 101: operation device; 2a-2d: Wallace tree multiplier; 4a-4d, 14a-14d, 16a-16d, 200, 300, 400: adder; 5a-5d, 15a-15d, 25a-25d: register; 6a-6d, 7a-7d, 17a-17d, 27a-27d: shifter; 9b-9d, 151b-151d, 161b-161d: switch; 20, 120: first connection switch; 30, 130: second connection switch; 51-61, 111, 112, 121-124, 13 1~138: CSA; 79: input generator; 900: operation unit; 1000: operation system; PE1~PE4: element processor; OP1~OP4: output terminal; 405: operation device; 410: multiplication unit; 420-1~420-4: multiplier; 430: addition unit; 440-1~440-4: adder; 450-1~450-4: intermediate register; 460: mode selection unit; 470: first connection switch; 480: second connection switch; 540: adder; 542: first addition element; 544: second addition element; 550: intermediate register.
Claims
1. A computing device for performing multiplication operations with variable precision, the computing device comprising: A multiplication unit, comprising a plurality of multipliers, wherein the plurality of multipliers are divided into one or more multipliers according to an operation precision mode and allocated to each of one or more groups, wherein each multiplier in each group performs a multiplication operation on an individual multiplier and an individual multiplicand according to the operation precision mode, wherein the individual multiplier is a digit range of at least a part of the multiplier corresponding to the group, and the individual multiplicand is a digit range of at least a part of the multiplicand corresponding to the group; an adding unit including a plurality of adders, wherein the plurality of adders are divided into one or more adders according to the operation precision mode and allocated to each of the one or more groups, wherein the one or more adders allocated to each group perform addition operations on each multiplication operation result obtained by each multiplier allocated to the group, and output the product of the multiplier and the multiplicand; a first connection switch for inputting, for each of the one or more groups, the multiplication results obtained by each multiplier into the digit position to which the multiplication result is to be added in the one or more adders according to the operation precision mode; as well as A mode selection unit is input with the calculation accuracy mode, and controls the multiplication unit, the addition unit, and the first connection switch according to the calculation accuracy mode so that the plurality of multipliers and the plurality of adders can be effectively used.
2. The computing device according to claim 1, wherein: Each of the plurality of multipliers performs a multiplication operation on the individual multiplier and the individual multiplicand, and outputs the multiplication result including sum data of each digit and carry data from each digit.
3. The computing device according to claim 1 or 2, wherein: Each of the plurality of multipliers performs a multiplication operation on the individual multiplier and the individual multiplicand of one unit bit length, and outputs the multiplication operation result of two unit bit lengths. Each of the plurality of adders performs an addition operation on a plurality of input data of 2 unit bit lengths, and outputs a sum of the 2 unit bit lengths and a carry to a higher digit according to the operation precision mode.
4. The computing device according to claim 1 or 2, wherein: In at least one operation precision mode for performing a multiplication operation on the multiplier and the multiplicand having a length of more than 2 unit bits, With respect to each of the one or more groups, The one or more multipliers are inputted with the individual multipliers of the digit range of the multipliers and the individual multiplicands of the multiplicands of the length of one unit bit in order from the higher digits in each cycle in each cycle, and the partial products of the individual multipliers and the individual multiplicands are outputted as the multiplication results in each cycle. In each cycle, the first connection switch shifts each of the partial products output by the one or more multipliers so that the partial products of the individual multipliers and the individual multiplicands on the digit range of the least significant bit in the multipliers correspond to the digit range of the least significant bit in the one or more adders, and then inputs the partial products to the one or more adders to perform addition operation with the intermediate results. The computing device further includes a second connection switch that shifts the intermediate result by one unit bit length toward the higher order side for each of the one or more groups in each cycle and inputs the shifted intermediate result to the one or more adders.
5. The computing device according to claim 4, wherein: In at least one operation precision mode having a length of 2 unit bits or more, the plurality of multipliers and the plurality of adders are allocated to two or more groups, The calculation device calculates the product of the multiplier and the multiplicand using a plurality of cycles for each of the two or more groups.
6. The computing device according to claim 4, wherein: In the calculation precision mode for performing a multiplication operation on the multiplier and the multiplicand of 1 unit bit length, The plurality of multipliers are assigned to the plurality of groups each including one multiplier, The multiplier assigned to each group performs a multiplication operation on the multiplier and the multiplicand of one unit bit length assigned to the group.
7. The computing device according to claim 4, wherein: The adding unit includes a plurality of intermediate registers, each of which is provided corresponding to each of the plurality of adders and each of which holds a digit range corresponding to each adder in the intermediate result.
8. The computing device according to claim 7, wherein: Each of the plurality of adders includes a first adding element, the first adding element outputting an addition operation result including sum data of each digit and carry data from each digit, Each of the plurality of intermediate registers holds the sum data and carry data of the digit range output by the corresponding first adding element in the intermediate result. The adding unit also has a plurality of second adding elements, and the plurality of second adding elements are respectively arranged corresponding to each of the plurality of adders, and the plurality of second adding elements are divided into each or every two or more second adding elements according to an operation accuracy mode and allocated to each of the one or more groups, and the plurality of second adding elements perform addition operations on the sum data and carry data output by one or more of the first adding elements in each group and output the sum data as the product of the multiplier and the multiplicand.
9. The computing device according to claim 1, wherein: Each of the plurality of multipliers is a multiplier using a Wallace tree that performs multiplication on an individual multiplicand and an individual multiplicand and outputs a multiplication result including sum data of each digit and carry data from each digit.
10. A computing device for performing multiplication operations with variable precision, the computing device comprising: a multiplication unit including a plurality of multipliers, each of which performs a multiplication operation on two numbers of one unit bit length and outputs a multiplication operation result including sum data of each digit and carry data from each digit; an adding unit including a plurality of adders, each of the plurality of adders performing an addition operation on at least two input data including the multiplication result obtained by at least one of the plurality of multipliers; as well as A mode selection unit selects a division number and a loop number according to an operation accuracy mode so that the plurality of multipliers and the plurality of adders can be effectively utilized, wherein the division number is a division number for dividing the plurality of multipliers and the plurality of adders into groups, wherein the group includes one or more multipliers and one or more adders, and multiplication operations are performed on mutually different multipliers and multiplicands, and the loop number is used when multiplication operations are performed on the multipliers and the multiplicands using the one or more multipliers and the one or more adders in the group.
11. The computing device according to claim 10, wherein: The mode selection unit divides the plurality of multipliers and the plurality of adders into at least one group each including n multipliers and n adders in a calculation accuracy mode for performing a multiplication operation on the multiplier and the multiplicand of n unit bit lengths, wherein n is a natural number, The n multipliers in each of at least one of the groups perform multiplication operations of each of the n individual multipliers of each of the groups with each of the n individual multiplicands in a manner of performing n groups of multiplication operations in one cycle during n cycles, wherein each of the n individual multipliers is a digit range of one unit bit length included in the multiplier, and each of the n individual multiplicands is a digit range of one unit bit length included in the multiplicand, The n adders in each group of at least one of the groups are combined together, and during n cycles, the multiplication results from the n multipliers in the same group in each cycle are added to the digital positions corresponding to the multiplication results in the intermediate result of the product of the multiplier and the multiplicand.
12. A computing system comprising: A computing unit comprising a plurality of computing devices according to any one of claims 1 to 11; and A plurality of processors share the computing unit.
