Low power adder circuit
By designing dynamically switching low-power and high-power adder modes in the calculation circuit, the existing adder circuit solves the problems of large area occupation and high power consumption, achieves more efficient floating-point number addition operations, and improves neural network calculations. power utilization.
Patent Information
- Application Number
- CN202410824175.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2018-10-12
- Filing Date
- 2019-10-11
- Publication Date
- 2024-09-10
AI Technical Summary
The adder circuit used for addition operations in existing computing circuits occupies a large area and consumes high power, and has no advantage in computing throughput. Especially in neural network calculations, the design of multi-layer adder circuits is difficult to adjust efficiently. Improve power utilization.
Design a dedicated hardware circuit that determines the relationship between inputs through the input processor and dynamically switches between low-power mode and high-power mode. The low-power mode is selected in most cases and only switches to the high-power mode under specific conditions. Utilize a dual-path adder circuit to add floating-point numbers, reducing circuit switching and power consumption.
The power consumption of addition operations is significantly reduced and the power utilization rate is improved. The low-power mode performs calculations in most cases, and the high-power mode is only switched when necessary, achieving a more efficient floating-point number addition operation.
Smart Images

Figure CN118626045A
Abstract
Description
[0001] Description of the case
[0002] This application is a divisional application of Chinese invention patent application No. 201980036415.5, with an application date of October 11, 2019. Technical Field
[0003] This specification relates to hardware circuits for performing mathematical calculations. Background Art
[0004] Computational circuits can include multiple adder circuits for adding numerical inputs such as integers and floating point numbers. Adder circuits can be expensive to produce and integrate into existing computational circuits, and some adder circuits are not efficiently sized for certain applications. These circuits can consume considerable area of the circuit die, but have no advantage in computational throughput despite their large size. Over-sizing adder circuits for certain computational applications can result in low power consumption and utilization.
[0005] The hardware circuit can be used to implement a neural network. A neural network having multiple layers can be used to compute inferences using computational circuitry including multiple adder circuits. The computational circuitry of the hardware circuit can also represent a computational unit for performing neural network computations for a given layer. For example, given an input, the neural network can compute inferences for the input by performing a dot product operation using one or more of the multiple adders in the computational unit of the hardware circuit. Summary of the invention
[0006] A dedicated hardware circuit for adding a plurality of inputs is described herein. The hardware circuit includes a first adder portion that receives a first input and a second input and generates a first sum in response to adding the inputs. The circuit also includes a second adder portion that is capable of receiving a first input and a second input and using the inputs to generate a second sum. An input processor of the hardware circuit receives a first input and a second input, determines whether a relationship between the first input and the second input satisfies a condition set, and selects a low power mode of the adder circuit or a high power mode of the adder circuit based on the determined relationship between the first input and the second input.
[0007] The circuit is configured to exploit certain sign and exponent properties of the inputs so that a low power mode is selected more frequently and at a much higher rate for adding the inputs than a high power mode. The high power mode is only occasionally selected when a specific set of conditions is met. Thus, the first input and the second input are routed to the second adder portion when the relationship between the first input and the second input meets the set of conditions, otherwise the input processor selects the low power mode of the adder circuit.
[0008] One aspect of the subject matter described in this specification can be implemented as an adder circuit for adding a plurality of inputs. The adder circuit includes an input processor configured to: receive a first input and a second input; determine whether a relationship between the first input and the second input satisfies a condition set; when the relationship between the first input and the second input satisfies the condition set, select a high power mode of the adder circuit and route the first input and the second input to a first high power adder portion; and when the relationship between the first input and the second input does not satisfy the condition set, select a low power mode of the adder circuit and route the first input and the second input to a second low power adder portion.
[0009] These and other embodiments can each optionally include one or more of the following features. For example, in some embodiments, a first high-power adder portion is configured to receive a first input and a second input and generate a first sum of the first input and the second input; and a second low-power adder portion is configured to receive a first input and a second input and generate a second sum of the first input and the second input.
[0010] In some embodiments, the adder circuit further comprises: a selection multiplexer configured to: pass the first sum as an output of the adder circuit when the input processor selects a low power mode of the adder circuit; and pass the second sum as an output of the adder circuit when the input processor selects a high power mode of the adder circuit.
[0011] In some embodiments, when the low power mode is selected, the adder circuit uses only the second low power adder section to add the first input and the second input; and when the high power mode is selected, the adder circuit switches both the first high power adder section and the second low power adder section when adding the first input and the second input.
[0012] In some embodiments, when the low power mode is selected and the adder circuit uses only the second low power adder section to add the first input and the second input, the adder circuit consumes less power than when the high power mode is selected because less circuit switching is required to add the first input and the second input using only the second low power adder section than to switch both the first high power adder section and the second low power adder section to add the first input and the second input.
[0013] In some embodiments, the input processor is further configured to generate a first parameter signal indicative of a selected mode of the adder circuit based on the determined relationship between the first input and the second input.
[0014] In some implementations, the adder circuit further includes: a mode detector configured to: detect a specific mode of the adder circuit; and generate a control signal to control the second low-power adder portion based on the detected mode of the adder circuit.
[0015] In some embodiments, the adder circuit further includes an input routing engine included at the input processor, the input routing engine being configured to: determine that the first input is larger in magnitude than the second input before the input processor determines whether the relationship between the first input and the second input satisfies the condition set; and in response to determining that the first input is larger in magnitude than the second input, convert the first input from a second input port routed to the adder circuit for receiving the smaller of the two inputs to a first input port routed to the adder circuit for receiving the larger of the two inputs.
[0016] In some embodiments, the set of conditions is satisfied in response to the input processor determining that: the sign of the first input is not the same as the sign of the second input; and the calculated difference between the exponent value of the first input and the exponent value of the second input is less than or equal to 1.
[0017] In some embodiments, the input processor is also configured to: determine whether the sign of the first input is different from the sign of the second input; and in response to determining that the sign of the first input is different from the sign of the second input, use a second low-power adder portion to perform a complement operation on the first input or the second input.
[0018] In some implementations, the adder circuit further includes a zero input generator configured to provide a plurality of zero inputs to the first high power adder portion in response to determining that the relationship between the first input and the second input does not satisfy the set of conditions.
[0019] In some embodiments, the second low-power adder portion: (i) is located along a second data path of the adder circuit; (ii) is coupled to an input processor along the second data path of the adder circuit; and (iii) is coupled to a selection multiplexer along the second data path of the adder circuit.
[0020] In some embodiments, the first high power adder portion: (i) is located along a first data path of the adder circuit; (ii) is coupled to an input processor along the first data path of the adder circuit; and (iii) is coupled to a selection multiplexer along the first data path of the adder circuit.
[0021] One aspect of the subject matter described in this specification can be implemented as a method for adding inputs using an adder circuit. The method includes: receiving a first input and a second input by an input processor of the adder circuit; determining by the input processor that a relationship between the first input and the second input does not satisfy a condition set; selecting a low-power mode of the adder circuit for adding the inputs using the input processor and based on the determined relationship between the first input and the second input; providing the first input and the second input to a first low-power adder section of the adder circuit corresponding to the low-power mode by the input processor and based on the selected mode of the adder circuit; and generating a first sum of the first input and the second input by the first low-power adder section using the low-power mode of the adder circuit selected when the relationship between the first input and the second input does not satisfy the condition set.
[0022] These and other embodiments can each optionally include one or more of the following features. For example, in some embodiments, the method further includes: when the input processor selects a low power mode of the adder circuit, the selection multiplexer of the adder circuit transmits the first sum as the output of the adder circuit; and when the input processor selects a high power mode of the adder circuit, the selection multiplexer transmits the second sum as the output of the adder circuit.
[0023] In some embodiments, when the low power mode is selected, the adder circuit uses only the first low power adder section to add the first input and the second input; and when the high power mode of the adder circuit is selected, the adder circuit switches both the first low power adder section and the second high power adder section when adding the first input and the second input.
[0024] In some embodiments, selecting a low power mode and using only the first low power adder section to add the first input and the second input causes the adder circuit to consume less power than when a high power mode is selected and the adder circuit switches both the first low power adder section and the second high power adder section when adding the first input and the second input.
[0025] In some implementations, the method further includes generating, by the input processor, a first parameter signal based on the determined relationship between the first input and the second input, the first parameter signal indicating a selected mode of the adder circuit.
[0026] In some implementations, the method further includes: detecting, by a mode detector of the adder circuit, a specific mode of the adder circuit; and generating, by the mode detector, a control signal to control the first low-power adder section based on the detected mode of the adder circuit.
[0027] In some embodiments, the method further includes: determining, using an input routing engine included at the input processor, that the first input is larger in magnitude than the second input before the input processor determines whether the relationship between the first input and the second input satisfies the set of conditions; and in response to determining that the first input is larger in magnitude than the second input, using the input routing engine to convert the first input from a second input port routed to the adder circuit for receiving the smaller of the two inputs to a first input port routed to the adder circuit for receiving the larger of the two inputs.
[0028] In some embodiments, the set of conditions is satisfied in response to the input processor determining that: the sign of the first input is the same as the sign of the second input; and the calculated difference between the exponent value of the first input and the exponent value of the second input is not less than or equal to 1.
[0029] In some embodiments, the method further includes: using an input processor to determine whether the sign of the first input is different from the sign of the second input; and in response to determining that the sign of the first input is different from the sign of the second input, using a first low-power adder portion to perform a complement operation on the first input or the second input.
[0030] In some implementations, the method further includes generating, by a second high power adder portion, a second sum of the first input and the second input using a high power mode of the adder circuit selected when the input processor determines that the relationship between the first input and the second input satisfies the condition set.
[0031] Other embodiments of this and other aspects include corresponding systems, devices, and computer programs configured to perform the actions of the method, the computer programs being encoded on a computer storage device (e.g., a non-transitory machine-readable storage medium). A computing system that can configure one or more computers or hardware circuits by means of software, firmware, hardware, or a combination thereof installed on the computing system so that the software, firmware, hardware, or a combination thereof causes the system to perform the actions in operation. One or more computer programs can be configured by means of instructions that, when executed by a data processing device, cause the device to perform the actions.
[0032] The subject matter described in this specification can be implemented in certain embodiments to achieve one or more of the following advantages. The described techniques can be used to implement a dedicated hardware circuit for adding multiple inputs while requiring less power than conventional circuits for adding inputs. The components of the hardware circuits described herein can form a low-power adder circuit that efficiently adds multiple inputs (e.g., floating-point inputs) based on a dual-path hardware configuration.
[0033] When the low power mode is selected, the first data path of the circuit is used to add the inputs, and when the high power mode is selected, the second data path of the circuit is used to add the inputs. The hardware adder circuit is configured so that the low power mode is selected to add the inputs at a significantly higher rate, i.e., more frequently, than the high power mode. This feature of the adder circuit results in reduced power consumption at the circuit relative to conventional circuits for adding inputs, i.e., because most additions are done in the low power mode which consumes much less power than conventional adder circuits.
[0034] The dedicated hardware circuit can be configured as a low-power floating-point adder circuit. Such a low-power adder circuit can be optimized for adding two floating-point inputs at reduced power requirements based on at least a split data path configuration, the split data path utilizing a first data path in a low-power mode to generate a sum of the two floating-point inputs. In some embodiments, the floating-point inputs are each a 32-bit floating-point input (standard precision) or a 16-bit floating-point input using a reduced-precision floating-point format.
[0035] The details of one or more implementations of the subject matter described in this specification are set forth in the drawings and description below. Other potential features, aspects, and advantages of the subject matter will become apparent from the description, drawings, and claims. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 A diagram showing an example hardware circuit for performing the calculations.
[0037] Figure 2 A diagram is shown with hardware circuit components arranged to form an example low-power adder circuit.
[0038] Figure 3 Shown for use Figure 2 Flowchart of an example process for an example low power adder circuit to perform an addition operation.
[0039] Figure 4 A flow chart showing an example process for adding two floating point inputs.
[0040] Throughout the various drawings, like reference numbers and designations refer to like elements. DETAILED DESCRIPTION
[0041] In one example implementation, a multi-layer neural network can be implemented using hardware circuitry and computations (e.g., neural network computations) can be performed by processing inputs by each layer of the neural network. In particular, each layer of the neural network can each have a corresponding set of parameters. Each layer receives an input and processes the input in accordance with the parameter set for the layer to generate an output based on computations performed using one or more adder circuits of an example computation unit. For example, the neural network layer can sum multiple inputs as part of computing a matrix multiplication of an input array and a parameter array or as part of computing a convolution between an input array and a parameter kernel array.
[0042] Typically, processing inputs through the layers of a neural network is accomplished by performing mathematical operations such as multiplication and addition. The hardware circuit can include a plurality of adder circuits for performing mathematical calculations. The adder circuits can be grouped to form computational units, such as matrix or vector processing units, of the hardware circuit. The computational units are used to add numerical inputs, such as integers and floating point numbers, when the hardware circuit is part of performing a neural network computation (e.g., matrix-vector multiplication) associated with processing inputs through the layers of a neural network.
[0043] Techniques for implementing a dedicated hardware adder circuit that is configured to add inputs while consuming less power relative to conventional adder circuits are described herein. The adder circuit is configured as a two-mode dual-path adder circuit and includes an input processor that selects a particular mode of the circuit in response to determining whether a relationship between a first input and a second input satisfies a set of conditions. The set of conditions is satisfied in response to the input processor determining that: i) the sign of the first input is different from the sign of the second input; and ii) a calculated difference between an exponent value of the first input and an exponent value of the second input is less than or equal to one.
[0044] Figure 1A diagram of an example hardware circuit 100 for performing a calculation is shown. The hardware circuit 100 can represent a circuit for adding two inputs, a first input 102a and a second input 102b. In some embodiments, the inputs are each a floating point number represented in software as a 32-bit data structure. The scaling engine 106 corresponds to a component that uses incremental logic to determine the difference between the scale of the first input 102a and the scale of the second input 102b. In some embodiments, the respective scale of each input is represented by an exponent value of each input. For example, the first input 102a can have an exponent value of 3.35 (2×10 7 ), where the exponent value 7 corresponds to the scale of the input 102a. Similarly, the second input 102b can have an exponent of 1.65 (2×10 3 ), where the exponent value 3 corresponds to the scaling of the input 102b. The scaling engine 106 is configured to receive a first exponent 104a of the first input 102a and a second exponent 104b of the second input 102b, and determine an increment or difference between the corresponding exponent values 104a and 104b.
[0045] Significand swap 108 corresponds to input swap logic that is used to swap or route the corresponding input to a specific input port A or B of the example hardware adder 112 included at the circuit 100. Significand swap 108 routes the input to a specific input port of the circuit 100 based on the size of the input (as indicated by the magnitude or scale) as indicated by the data value of the input. For example, significand swap 108 can analyze the 32-bit data structure of each input 102a, 102b to determine which input is the larger input. In some embodiments, significand swap 108 determines that the numerical data value of one input is greater than the numerical data value of another input based on the corresponding exponent value of each input.
[0046] The control signal 109 generated by the scaling engine 106 can be used by the significand exchange 108 to determine that the corresponding exponent value 104a of the input 102a is greater than the corresponding exponent value 104b of the input 102b. Based on this determination, the significand exchange 108 causes the input 102a (e.g., the larger input) to be routed to input port A, and causes the input 102b (e.g., the smaller input) to be routed to input port B. Typically, the input 102a represents an input with a larger data value, while the input 102b represents an input with a smaller data value. Routing the input to a particular input port (A or B) of the hardware adder 112 can include swapping the input from input port A to input port B, and vice versa.
[0047] In some cases, routing the inputs 102a, 102b to respective input ports A, B of the adder 112 can include using the shift logic 110 to perform a shift operation on an input determined to be a smaller input, e.g., the smaller input determined based on the respective exponent value 104b of the input 102b. For example, the shift operation can be triggered in response to the shift logic 110 receiving a control signal 109 provided by the scaling engine 106. The control signal 109 can be used to trigger a shift operation on the input 102b to perform a right shift (e.g., a wide right shift) before the circuit 100 uses the adder 112 to add the inputs 102a, 102b. In some embodiments, because input 102 b has an exponent value 104 b (e.g., 3) that is less than the exponent value 104 a (e.g., 7) of input 102 a, a wide right shift can be performed to align the respective decimal points of each input before circuit 100 uses adder 112 to add inputs 102 a, 102 b.
[0048] The hardware adder 112 includes a plurality of logic blocks, each logic block representing a corresponding logic function of the adder 112. In general, one or more of the corresponding logic functions may be used to add the inputs 102a, 102b. For example, the complement logic 114 is used to generate a two's complement version of the input 102b using binary data of a data structure (e.g., a 32-bit data structure) representing the data value of the input 102b. The complement logic 114 is used to generate a two's complement version of the input 102b in response to determining that the sign of the input 102b is different from the sign of the input 102a.
[0049] For example, each of the inputs 102a, 102b can be a corresponding floating point number, and the sign bit of each input indicates the sign of the input (e.g., positive or negative) and identifies the value of the floating point number as being greater than zero or less than zero. Typically, each numerical input such as a floating point number has at least one sign bit in the data structure, and the at least one sign bit indicates whether the number is greater than zero (e.g., a positive number) or less than zero (e.g., a negative number). In some cases, the data structure uses one or more zero bits ("0") to indicate a numerical input of zero.
[0050] In some embodiments, a subtraction operation occurs when a positive input 102a with a larger data value is added to a negative input 102b with a smaller data value. In this way, a binary complement version of negative input 102b is used to perform the addition operation, which involves adding the binary complement form of input 102a to input 102b to generate a preliminary sum or preliminary result. Adder 112 performs the addition operation by using adder logic 116 to add inputs 102a, 102b and generate a preliminary sum as the output of adder logic 116. In some cases, input addition can include using rounding logic 118 to perform rounding operations on the preliminary sum. For example, rounding logic 118 can be used to round the preliminary sum to the nearest decimal or integer value.
[0051] Normalization logic 120 can be used to perform one or more normalization operations on the preliminary result. In some embodiments, normalization logic 120 can be used to adjust the data format of the preliminary sum before generating intermediate sum 124. For example, when a wide right shift is performed on input 102b to align the decimal point of the input with the decimal point of input 102a, a subsequent left shift (e.g., wide left shift) operation can be applied to the preliminary sum. This shift operation of normalization logic 120 makes the decimal point of the final result or sum 130 adjusted to an appropriate position based on at least the scale of the corresponding input 102a, 102b. In some cases, normalization logic 120 uses leading zero detector 121 to determine the amount of left shift based on the number of leading zeros detected associated with the data value of each input 102a, 102b. For example, the leading zero detector 121 can count the number of zero bits starting from the leftmost position of the respective input 102a, 102b until the first non-zero bit is reached and determine the amount of the left shift 122 based at least on the number of zero bits.
[0052] Special logic 126 can be used to propagate specific data values generated by certain special operations 128 that may occur during addition operations. For example, special operations 128 can involve operands identified as infinite operands or NaN (non-number) operands. These operations 128 can correspond to certain overflow or underflow conditions. In other embodiments, addition operations can generate preliminary sums, which are negative numbers as indicated by the sign bit of the preliminary sum. In this case, additional binary complement operations can be performed on the preliminary sum based on the sign bit of the preliminary sum. Circuit 100 generates a final result or sum 130 based on logic 126, which is used to process intermediate sums 124 to illustrate one or more special operations 128 that may occur during addition operations.
[0053] Figure 2A diagram of an example dedicated hardware circuit 200 is shown. The components of the circuit 200 can be arranged to form an example low-power adder circuit that is configured to add inputs while consuming less power relative to conventional adder circuits. In some embodiments, the hardware circuit 200 is configured as a low-power floating-point adder circuit. The low-power adder circuit 200 can be optimized based on a two-mode dual-path circuit configuration for adding two floating-point inputs with reduced power requirements.
[0054] The circuit 200 includes an input processor 202 that generates a parameter signal 204 to indicate a selected mode of the circuit 200. The input processor 202 is configured to select a mode of the adder circuit 200 in response to determining whether a relationship between a first input and a second input satisfies a set of conditions. The set of conditions (described below) is satisfied in response to the input processor determining that: i) the sign of the first input is different from the sign of the second input; and ii) the calculated difference between the exponent value 104a of the first input 102a and the exponent value 104b of the second input 102a is less than or equal to one.
[0055] The parameter signal 204 is generated based on the determined relationship between the first input and the second input. The parameter signal 204 is provided to a mode detector 206, which uses the parameter signal 204 to generate one or more controls based on the selected mode of the circuit 200. The mode detector 206 uses the parameter signal 204 to generate a multiplexer control signal 215 and adder control signals 217a and 217b. In some embodiments, the mode detector 206 is configured to detect a particular mode of the adder circuit based on the value indicated by the parameter signal 204. The control signals 215, 217a, 217b are described in more detail below.
[0056] The adder circuit 200 is configured as a two-mode dual-path adder circuit having a low power mode and a high power mode. When the low power mode is selected, the circuit 200 uses the adder logic 210 along the data path 211 to generate the first sum 220. When the high power mode is selected, the circuit 200 uses the adder logic 212 along the data path 213 to generate the second sum 222. Generally, the data path 211 can correspond to the low power adder portion of the circuit 200 including the adder logic 210. Similarly, the data path 213 can correspond to the high power adder portion of the circuit 200 including the adder logic 212.
[0057] In particular, when the high power mode is selected, the circuit 200 uses the components of the adder logic 212 along the data path 213 to add the inputs, but still switches the components of the adder logic 210 along the data path 211. For example, when the condition set is met so that the high power mode is selected and the inputs are routed along the data path 213 for addition, the circuit 200 still switches the components of the adder logic 210 while simultaneously using the adder logic 212 to add the inputs. As used herein, switching, circuit switching, or switching of a circuit component can correspond to activating or switching a component (e.g., a transistor) of the circuit to route an input or control signal at the circuit. Typically, activating, switching, or switching the circuit component causes a certain amount of power to be consumed at the circuit.
[0058] Circuit 200 can be formed by splitting a conventional adder circuit to form two different adder sections, namely a first adder section corresponding to a low power mode and a second adder section corresponding to a high power mode. The first adder section is described as a low power adder section because, when the low power mode is selected, circuit 200 is configured to use only this low power section to add inputs 102a and 102b at more than 90% (e.g., 99%) of the time. Specifically, when this low power adder section is used, the second adder section substantially experiences little or no circuit switching because only zeros are routed along the section when the low power section is used to add inputs. Therefore, this first adder section of data path 211 represents the low power adder section of circuit 200.
[0059] However, the second adder section is described as a high power section because, when the high power mode is selected, the circuit 200 is configured to use the second adder section to add the inputs, but components of the first adder section are still switched. Therefore, the selection of the high power mode causes both adder logic 212 and 210 to undergo circuit switching, thereby increasing power consumption at the circuit 200. Therefore, because two adder sections (e.g., the entire circuit 200) are switched, the data path 213 is used to add the inputs, and the total power consumed at the circuit 200 is higher than when only the data path 211 is used to add the inputs. However, the circuit 200 is configured so that the high power adder section is rarely used to add the inputs.
[0060] The mode detector can generate an adder control signal 217a or 217b using the parameter signal 204. For example, when the low power mode is selected, the adder control signal 217a is used to control the hardware or logic components of the low power adder portion of the circuit 200 based on the detected mode of the adder circuit. Similarly, for example, when the high power mode is selected, the adder control signal 217b is used to control the hardware or logic components of the high power adder portion of the circuit 200 based on the detected mode of the adder circuit.
[0061] The hardware adder circuit 200 can include a selection multiplexer 224 configured to: i) deliver the first sum 220 as an output 226 of the adder circuit 200 when the input processor 202 selects a low power mode of the adder circuit 200; and ii) deliver the second sum 222 as an output 226 of the adder circuit 200 when the input processor 202 selects a high power mode of the adder circuit 200. As noted above, the mode detector 206 uses the parameter signal 204 to generate a multiplexer control signal 215. The multiplexer control signal 215 is used to control the selection multiplexer 224 so that a particular sum 220 or 222 is delivered as an output 226 of the adder circuit 200 based on a particular mode selected by the input processor 202.
[0062] The selection multiplexer 224 may be a 2:1 multiplexer that receives two inputs, such as a first sum 220 and a second sum 222, and delivers a particular sum as an output 226 of the adder circuit 200 based on the parameter value of the multiplexer control signal 215. The circuit 200 generates a final result or sum 230 based on example special logic 126 for processing the output 226 to account for one or more special operations 128 that may occur during the addition operation.
[0063] Referring again to the set of conditions, given two input numbers 102a and 102b, the circuit 200 will need to perform a wide left shift 122 operation only under the following conditions: i) the signs of 102a and 102b are not the same; and ii) the difference between the exponents of the inputs 102a and 102b is less than or equal to 1. When these conditions are met, they will require a wide left shift 122 operation at the circuit 200. This is because the circuit will be required to perform a two's complement operation to add the inputs 102a, 102b based on the sign bit being different between the two inputs. In this case, the circuit 200 is not required to shift the given input 102 right by more than one, such as more than the decimal value of 1.
[0064] Typically, based on the properties of the inputs processed at the circuit 200, a wide right shift operation 110 will not occur at the circuit 200 as a concurrent operation with a wide left shift operation 122. Based on this, the circuit 200 can be configured to split the adder logic 116 so that the wide right shift operation 110 occurs at a separate adder logic 210 along the data path 211 and the wide left shift operation 122 occurs at another separate adder logic 212 along the data path 213. The adder logic 212 can be configured to use an adder 216 that is substantially similar to the adder 116, except that the adder 216 is configured to perform certain small shift operations associated with adding one input 102a / b to a two's complement version of the other input 102a / b. As used herein, the sign of an input 102 and the corresponding exponent value 104 of the input can each correspond to a respective property of the input 102.
[0065] In some embodiments, the sign of the exponent value 104 and / or the difference of the exponent value 104 between the two inputs / operands 102 can be used to determine which of the two operands 102a, 102b is the larger or greater operand. As discussed above, the circuit 200 is configured to exchange or route the inputs 102a, 102b so that the smaller operand 102b is always subtracted from the larger operand 102a, wherein the data size of the operand is represented by the corresponding exponent of the operand. For example, the input processor 202 can be configured to include computational logic for the effective number exchange 108, such as an input routing or exchange engine. The input processor 202 can use the effective number exchange 108 to: i) route the input 102a that is larger in scale or amplitude relative to the input 102b to the input port A; and ii) route the input 102b that is smaller in scale or amplitude relative to the input 102a to the input port B.
[0066] For example, the input routing engine of the circuit 200 can be configured to determine that the first input 102a is greater than the second input 102b. In response to determining that the input 102a is greater than the second input 102b, the input routing engine can be configured to swap or convert the first input from being routed to the second input port (e.g., input port B) of the adder circuit configured to receive the smaller of the two inputs to the first input port (e.g., input port A) of the adder circuit configured to receive the larger of the two inputs.
[0067] In some embodiments, the input routing engine determines that the first input is greater than the second input before the adder circuit 200 determines whether the relationship between the first input and the second input satisfies the condition set. In other embodiments, determining that the first input is greater than the second input is performed simultaneously with or as part of determining whether the relationship between the first input and the second input satisfies the condition set. In this manner, the adder circuit 200 can be configured to effectively utilize the relationship between the inputs 102a / b to select a low power mode of the circuit 200 based on the scale and sign of the respective inputs.
[0068] For example, when the circuit 200 is configured such that input port A of the example significand adder has a larger operand, the circuit ensures that the sign of the adder output (e.g., the sum or result of adding the inputs) is always positive. In this way, two's complement operations can be avoided. Therefore, power savings can be achieved by eliminating the need for circuit switching that typically occurs when using two's complement logic to perform, for example, subtraction operations involving positive and negative numbers. Therefore, at least one data path 211 of the dual-path circuit 200 that does not require two's complement logic can be configured to include only the adder logic 210 required to add two numbers with the same sign, or can be configured to perform one's complement operations when the two numbers do not have the same sign (see below). Figure 4 This data path 211 can correspond to a low power mode of the circuit 200 because using the adder logic 210 along this data path 211 requires less switching, resulting in power savings at the hardware circuit 200 .
[0069] As described in more detail below, input processor 202 selects a low power mode of circuit 200 to add inputs (e.g., two floating point inputs) and generate first sum 220. In some implementations, certain properties of inputs 102a, 102b received at circuit 200 cause input processor 202 to select the low power mode at a higher rate (e.g., a significantly higher rate) than circuit 200 selects the high power mode.
[0070] In some cases, because the input processor 202 selects the low power mode at a higher rate, the circuit 200 can include a zero input generator 208 that is configured to provide or feed a plurality of zero inputs to a hardware or logic component of a high power adder portion of the circuit 200 in response to the input processor 202 having determined that the relationship between the first input 102a and the second input 102b does not satisfy the set of conditions discussed above. For example, the zero input generator 208 is configured to feed a plurality of zero inputs to the high power adder portion of the circuit 200 when the low power mode is selected.
[0071] Typically, feeding multiple zero inputs to the high power adder portion of the circuit 200 results in a negligible amount of switching at this portion of the circuit, which translates into power savings. Additionally, the combination of the higher selection ratio of the low power mode of the circuit and the zero inputs contributes to the overall power savings that can be achieved by using the dedicated adder circuit 200. In this way, the circuit 200 can be configured as a dedicated low power hardware adder circuit that requires much less power relative to conventional circuits to add floating point inputs.
[0072] For example, assuming a uniform distribution of the numeric inputs 102a, 102b, the probability that a left shift operation 122 associated with the two's complement logic 114 needs to be performed corresponds to the probability that: a) the exponent 104a of the input 102a is the same as the exponent 104b of the input 102b OR the difference between the exponent 104a of the input 102a and the exponent 104b of the input 102b is exactly equal to 1; and b) the sign bit of the input 102a is different from the sign bit of the input 102b. Here, the OR corresponds to a logical operation used by the input processor 202 to determine whether the properties of the inputs 102a, 102b satisfy a set of conditions representing the probability that a left shift operation needs to be performed.
[0073] like Figure 2 As shown in FIG. 1 , the dedicated adder circuit 200 can include two separate integer adders 116, 216 at the corresponding portion of the circuit 200, rather than Figure 1 Thus, circuit 200 uses split data paths 211, 213 so that once a decision is made as to which data path to use, only a single wide shifter 110 or 122 and adder 116 or 216 are present in the critical path. Additionally, there is a single rounding operation 118 or leading zero detection 121 along a particular data path 211, 213, rather than both as shown in circuit 100.
[0074] Compared to the rate at which the low-power data path 211 is used, the data path 213 is used very infrequently. In some embodiments, the data path 213 may not have switching in more than 99% of the processor cycles that may occur for a given calculation sequence. In addition, during this sequence, the zero generator 208 is forced to zero at this high-power adder portion during these processor cycles that correspond to no (or minimal) switching occurring during the processor cycle. For these reasons, the adder circuit 200 may consume significantly less power when compared to a typical adder architecture. For example, for comparable addition operations involving 32-bit floating point numbers, the low-power adder circuit 200 can achieve up to a 50% reduction in power consumption relative to conventional circuits.
[0075] Figure 3 A flow chart of an example process 300 for adding at least two inputs is shown. The inputs may be numerical inputs, such as floating point numbers represented as a data structure of multiple bits, such as 16 bits or 32 bits. Process 300 can be performed using at least circuit 200 in conjunction with other circuits, components, and systems described herein.
[0076] Referring now to process 300, circuit 200 receives a first input and a second input, wherein the first input and the second input are routed at circuit 200 based on the first input being larger in magnitude than the second input (302). For example, an input processor 202 of low power adder circuit 200 receives inputs 102a, 102b for routing and adding at circuit 200 to generate a result 230, for example, a sum of the inputs added. Input processor 202 can use significand swap 108 to route and / or swap the first input and the second input so that the input that is larger in scale or magnitude is routed to a specific input port of the adder in circuit 200. In some embodiments, dedicated circuit 200 receives multiple inputs from an external source. The inputs can each be a numerical input (e.g., a floating point number or another data type including a sign bit), wherein each input is represented by a data structure of multiple bits. For example, adder circuit 200 can typically be fed from a multiplier or from a register file in an example computation unit.
[0077] The input processor 202 determines whether the relationship between the first input and the second input satisfies a set of conditions 304. For example, the set of conditions is satisfied in response to the input processor 202 determining that: i) the sign of the input 102a is different from the sign of the input 102b; and ii) the calculated difference between the exponent value 104a of the input 102a and the exponent value 104b of the input 102b is less than or equal to 1.
[0078] Based on the determined relationship between the first input and the second input, the input processor 202 selects a low power mode of the adder circuit 200 for adding the first input and the second input or a high power mode of the adder circuit 200 for adding the inputs (306). In some implementations, the input processor 202 selects the low power mode in response to determining that the set of conditions is not satisfied. For example, the input processor 202 can select the low power mode in response to determining that the sign of the input 102a is the same as the sign of the input 102b.
[0079] Based on the determined relationship between the first input and the second input, the input processor 202 provides the first input and the second input to at least one of a first adder section corresponding to the low power mode of the adder circuit 200 or a second adder section corresponding to the high power mode of the adder circuit 200 (308). For example, the input processor 202 provides the inputs 102a, 102b to the low power adder section along at least the data path 211 when the low power mode is selected, or provides the inputs 102a, 102b to the high power adder section when the high power mode is selected.
[0080] In the first embodiment, as described above, when the low power mode is selected, the adder circuit 200 uses only the adder logic 210 of the low power adder section to add the inputs 102a, 102b. In this first embodiment, the multiplexer 224 is selected to pass the first sum 220 as the output 226 of the adder circuit 200. In the second embodiment, when the high power mode is selected, the adder circuit 200 uses the adder logic 212 of the second adder section to add the first input and the second input, but still switches the components of the adder logic 210 at the first adder section. Because the circuit 200 switches the components of the two adder sections, this second embodiment defines the high power mode of the adder circuit 200. In this second embodiment, the multiplexer 224 is selected to pass the second sum 222 as the output 226 of the adder circuit 200.
[0081] The first adder section receives the first input and the second input provided by the input processor 202 to generate a first sum (310) using the low power mode of the adder circuit. For example, the low power adder section receives the inputs 102a, 102b, adds the inputs 102a, 102b using the adder 116 of the adder logic 210, and generates a first sum 220. Based on the multiplexer control signal 215 indicating that the input processor 202 has selected the low power mode, the sum 220 is delivered by the selection multiplexer 224 as the output 226.
[0082] Similarly, when the input processor 202 determines that the relationship between the first input and the second input satisfies the condition set, the second adder section receives the first input and the second input provided by the input processor 202 to generate a second sum 222 (312). For example, when properties such as the respective sign and exponent values of the inputs 102a, 102b satisfy the condition set, the high power adder section receives the inputs 102a, 102b, adds the inputs 102a, 102b using the adder 216 of the adder logic 212, and generates the second sum 222. Based on the multiplexer control signal 215 indicating that the input processor 202 has selected the high power mode, the sum 222 is delivered by the selection multiplexer 224 as the output 226.
[0083] In some implementations, the low power adder portion: (i) is located along the first data path 211 of the adder circuit 200; (ii) is communicatively coupled to the input processor 202 along the first data path 211 of the adder circuit 200; and (iii) is communicatively coupled to the selection multiplexer 224 along the first data path 211 of the adder circuit 200. Similarly, the high power adder portion: (i) is located along the second data path 213 of the adder circuit 200; (ii) is coupled to the input processor 202 along the second data path 213 of the adder circuit 200; and (iii) is coupled to the selection multiplexer 224 along the second data path 213 of the adder circuit 200.
[0084] Typically, the adder circuit 200 can be configured to position the compare and swap logic before the inputs are registered for addition at the circuit. The adder circuit 200 can be fed from a multiplier or from a register in an example computational unit. In some cases, the circuit 200 is configured so that certain logic used when adding inputs (e.g., registering the inputs) is pushed or moved out of the critical path of the adder and into the multiplier that feeds the adder circuit 200.
[0085] Two separate data paths are used, each corresponding to a corresponding low power mode or high power mode in which the adder can operate. For the example addition operation, a decision about which data path to use may occur very early in the calculation cycle. In some embodiments, this decision can even be moved to a previous pipeline stage, such as at a previous multiplier, ALU, or bypass circuit of the computing unit, but will cause adjustments or modifications to the interface of the adder circuit. Unless a decision to use this mode (high power mode) is made based on meeting the condition set, such as at least when inputs 102a and 102b are very close in amplitude or scale, otherwise the zero input generator 208 is used to feed zero to the low probability mode data path 213 of the circuit 200.
[0086] Figure 4 A flow chart of an example process 400 for adding two floating point inputs is shown. Process 400 can be performed using at least circuit 200 in conjunction with other circuits, components, and systems described herein.
[0087] In one example implementation, circuit 200 includes a significand adder that calculates Z.fraction=X.fraction+Y.fraction, where X and Y are respective inputs 102a and 102b and Z is the output of circuit 200. X.fraction and Y.fraction can each correspond to respective numerical fractions of a 32-bit floating point number after appropriate shifting. In some cases, adder logic 210 (e.g., adder circuit 116) receives another input invert_output as a control signal. This invert_output control signal corresponds to an operation for inverting Z.fraction, which can be the result of an example significand adder such as adder 116, and then circuit 200 generates an example final output Z.result, which corresponds to the actual floating point addition result of circuit 200.
[0088] For ease of description, and as Figure 2 As shown, data path 211 can generally represent the right hand side (RHS) of circuit 200, while data path 213 can generally represent the left hand side (LHS) of circuit 200. Based on the above description, and using input processor 202, the value of X (input 102a) is always greater than the value of Y (input 102b) at the input of adder logic 210 on the RHS. Because the LHS of circuit 200 is separated from the RHS, the relationship that X is greater than Y can be guaranteed at the RHS. Because Y is less than X, Y will be right shifted before the fractional addition involving X and Y is performed. As discussed above, before circuit 200 uses the significand adder to add inputs X and Y, the right shift or wide right shift is performed to align the corresponding decimal points of each input. Therefore, Y is less than X.
[0089] This example implementation involves the following two cases: case a) the respective signs of inputs X and Y are the same; or case b) the respective signs of inputs X and Y are different (e.g., inversion case). As discussed below, case b) is the inversion case where the control signal invert_output will be used to invert the output Z.fraction. Figure 4As shown, in case a), when the respective signs of X and Y are the same (402), the significand adder 116 at the RHS of the adder circuit 200 is used to perform normal addition on X.fraction and Y.fraction. Because Y is less than X, Y will be right-shifted (404) before the fractional addition involving X and Y is performed. Therefore, no negation operation is required because the addition operation performed by the circuit 200 involves simply adding the magnitudes of the fractions of X and Y to generate the sum or final floating point output Z.result (406). The sign of the final floating point output Z.result of the adder circuit 200 will be the same as the sign of the input X (408).
[0090] like Figure 4 As shown, in case b), the respective signs of X and Y are different (410). However, X always has a greater value than the value of Y on the RHS at the input of adder logic 210. As described above, input processor 202 can route inputs X and Y to the LHS of circuit 200 in response to determining that the relationship between X and Y satisfies a set of conditions. For example, the relationship between X and Y satisfies the set of conditions when the respective signs of X and Y are different AND the exponent delta between the exponent of X and the exponent of Y is 0 or 1. Here, the AND corresponds to a logical operation used by input processor 202 to determine whether the properties of X and Y satisfy the set of conditions.
[0091] Thus, for the RHS of circuit 200, when the respective signs of X and Y are different, X will always be greater than Y because the difference between the respective exponents of X and Y will be at least 2. As noted above for case a), because Y is less than X, Y will be right-shifted before the fractional addition involving X and Y is performed. Adding additional two's complement logic to perform this operation on the Y operand when Y has already been right-shifted may affect certain timing constraints of the addition operation. In view of this, adder logic (or circuit) 210 is configured to perform a two's complement operation on the X input (412).
[0092] However, rather than generating the output Z.fraction using the calculation Z.fraction=X.fraction-Y.fraction, which would require another two's complement of the output and Z.fraction to obtain the final floating point output Z.result, the adder logic 210 of the circuit 200 is configured to generate the output based on the calculation Z.fraction=(-(-X.fraction-1+Y.fraction)-1). This calculation is the same as Z.fraction=(X.fraction'+Y.fraction)', which corresponds to Z.fraction=(one's complement of X.fraction+Y.fraction)' (414). Therefore, when the respective signs of X and Y are different, the circuit 200 is configured to: i) negate the X.fraction input, ii) hold the Y.fraction input after the shift, iii) perform integer addition using the negated X.fraction input and the Y.fraction input, and iv) then negate the output Z.fraction of the adder logic 210 (e.g., adder 116) to generate the final floating point result Z.result.
[0093] In some embodiments, the adder circuit 116 of the adder logic 210 includes an additional input port for receiving a signal indicating when the output Z.fraction is inverted. For example, if X.fraction is inverted, an external controller for controlling the operation of the adder logic (or circuit) 210 can detect that an inversion operation has been performed on the X.fraction input and determine that the output Z.fraction will also need to be inverted. Based on this, an additional input port of the adder 116 of the adder logic 210 can receive another input corresponding to the control signal invert_output (416). This control signal can be used by the adder logic / circuit 210 to invert the output Z.fraction and generate a final floating point output Z.result (418). The sign of the final floating point output Z.result will be the same as the sign of the input X for the RHS of the circuit 200.
[0094] Many embodiments have been described. However, it should be understood that various modifications may be made without departing from the scope of the invention. For example, various forms of the processes shown above may be used, with steps reordered, added, or removed. Therefore, other embodiments are within the scope of the following claims. Although this specification contains many specific implementation details, these should not be interpreted as limiting the scope of what may be claimed, but rather as descriptions of features that may be specific to a particular embodiment. Certain features described in this specification in the context of separate embodiments can also be implemented in a single embodiment in combination.
[0095] Conversely, various features described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination. Furthermore, although features may be described above as functioning in certain combinations and even initially claimed as such, one or more features from the claimed combination can be removed from the combination in some cases, and the claimed combination may be directed to subcombinations or variations of subcombinations.
[0096] Similarly, although operations are depicted in the accompanying drawings in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in a sequential order, or that all illustrated operations be performed to achieve the desired results. In some cases, multitasking and parallel processing can be advantageous. In addition, the separation of various system modules and components in the above-described embodiments should not be understood as requiring such separation in all embodiments, and it should be understood that the described program components and systems can generally be integrated into a single software product or system or packaged into multiple software products.
[0097] Specific embodiments of the subject matter have been described. Other embodiments are within the scope of the following claims. For example, the actions recited in the claims can be performed in a different order and still achieve the desired results. As an example, the processes depicted in the accompanying drawings do not necessarily require the particular order or sequential order shown to achieve the desired results. In some cases, multitasking and parallel processing can be advantageous.
Claims
1. An integrated adder circuit, comprising: a first adder section configured to generate a sum of two inputs based on a first condition corresponding to respective signs of the two inputs; a second adder section configured to generate a sum of the two inputs based on a second condition corresponding to the respective signs and respective scales of the two inputs; as well as an input processor configured to generate a parameter signal, the parameter signal: controlling selection of circuits in the first adder section to generate a sum of the two inputs when a first condition is satisfied; as well as Selection of circuits in the second adder section is controlled to generate a sum of the two inputs when a second condition is satisfied.
2. The integrated adder circuit according to claim 1, wherein: The integrated adder circuit is configured such that a low power mode corresponding to the first adder portion is selected to add the two inputs at a significantly higher ratio than a high power mode corresponding to the second adder portion.
3. The integrated adder circuit according to claim 1, wherein: The circuit is a two-mode dual-path integrated adder circuit including a split data path configuration; and Each datapath of the split datapath configuration includes respective circuitry configured to generate a sum of two or more floating point inputs.
4. The integrated adder circuit according to claim 3, wherein: the first adder section being a low power section, and the parameter signal generated by the input processor causing the low power section to generate a sum of the two inputs when the first condition is met; as well as The second adder section is a high power section, and the parameter signal generated by the input processor causes the high power section to generate a sum of the two inputs when the second condition is met.
5. The integrated adder circuit according to claim 4, wherein: a first datapath of the split datapath configuration being in the low power portion and comprising adder logic corresponding to circuitry in the low power portion; as well as When the first condition is met, the adder logic in the low power portion is used to generate a sum of the two inputs.
6. The integrated adder circuit according to claim 5, wherein: a second datapath of the split datapath configuration being in the high power section and comprising adder logic corresponding to circuitry in the high power section; as well as When the second condition is met, the adder logic in the high power section is used to generate a sum of the two inputs.
7. The integrated adder circuit according to claim 6, wherein: When the first condition is met, the adder logic in the low power portion performs a wide right shift operation to generate a sum of the two inputs; as well as When the second condition is met, the adder logic in the high power section performs a wide left shift operation to generate a sum of the two inputs.
8. The integrated adder circuit according to claim 6, wherein: When the first condition is met and the low power section generates a sum of the two inputs, the circuitry in the high power section undergoes a negligible amount of circuit switching.
9. The integrated adder circuit according to claim 8, wherein: Because only zeros are routed along the second data path, the circuits in the high power section experience a negligible amount of circuit switching.
10. The integrated adder circuit according to claim 1, wherein: The first condition corresponds to at least one of the following: a match between corresponding symbols of the two inputs; or The difference between the corresponding exponents of the two inputs is greater than 1.
11. The integrated adder circuit according to claim 10, wherein: The scale is represented by an exponential value, and the second condition corresponds to: the difference between corresponding signs of the two inputs; and The difference between the respective exponents of the two inputs is less than or equal to 1.
12. A method performed using an integrated adder circuit, the method comprising: The parameter signal is generated by the input processor, and the parameter signal: controlling selection of a first adder portion of the integrated adder circuit when a first condition corresponding to respective signs of the two inputs is satisfied; as well as controlling selection of a second adder portion of the integrated adder circuit when a second condition corresponding to the respective signs and the respective scales of the two inputs is satisfied; generating, by the first adder section, a sum of the two inputs based on the parameter signal generated by the input processor when the first condition is satisfied; as well as When the second condition is met, a sum of the two inputs is generated by the second adder section based on the parameter signal generated by the input processor.
13. The method according to claim 12, further comprising: When the first condition is met, selecting a low power mode corresponding to the first adder section by the input processor to calculate the sum of the two inputs, and Therein, the integrated adder circuit is configured such that the low power mode is selected to add the two inputs at a significantly higher ratio than a high power mode corresponding to the second adder portion.
14. The method of claim 12, wherein: The circuit is a two-mode dual-path integrated adder circuit including a split data path configuration; and Each datapath of the split datapath configuration includes respective circuitry configured to generate a sum of two or more floating point inputs.
15. The method according to claim 14, wherein: The first adder section is a low power section and the second adder section is a high power section; a first datapath of the split datapath configuration being in the low power portion and comprising adder logic corresponding to circuitry in the low power portion; as well as The method includes generating a sum of the two inputs using the adder logic in the low power portion when the first condition is met.
16. The method of claim 15, wherein: a second datapath of the split datapath configuration being in the high power section and comprising adder logic corresponding to circuitry in the high power section; as well as The method includes generating a sum of the two inputs using the adder logic in the high power section when the second condition is met.
17. The method of claim 16, wherein: When the first condition is met, performing a wide right shift operation by the adder logic in the low power portion to generate a sum of the two inputs; as well as When the second condition is met, a wide left shift operation is performed by the adder logic in the high power section to generate a sum of the two inputs.
18. The method of claim 16, wherein: When the first condition is satisfied and the low power section generates a sum of the two inputs, the circuitry in the high power section undergoes a negligible amount of circuit switching; as well as Because only zeros are routed along the second data path, the circuits in the high power section experience a negligible amount of circuit switching.
19. The method according to claim 12, wherein: Determining whether the first condition is met is based on at least one of the following: a match between corresponding symbols of the two inputs; or The difference between the corresponding exponents of the two inputs is greater than 1.
20. A non-transitory machine-readable storage device for storing instructions for adding inputs using an integrated adder circuit, the instructions being executable by a processing device to cause operations comprising: The parameter signal is generated by the input processor, and the parameter signal: controlling selection of a first adder portion of the integrated adder circuit when a first condition corresponding to respective signs of the two inputs is satisfied; as well as controlling selection of a second adder portion of the integrated adder circuit when a second condition corresponding to the respective signs and the respective scales of the two inputs is satisfied; generating, by the first adder section, a sum of the two inputs based on the parameter signal generated by the input processor when the first condition is satisfied; as well as When the second condition is met, a sum of the two inputs is generated by the second adder section based on the parameter signal generated by the input processor.
