Multiplier and method of operating the same

By detecting the zero value or small value of the operand in the neural network multiplier and dynamically disabling or segmenting the multiplier, the power waste problem when the weight and activation values ​​are close to zero is solved, and the power optimization of the multiplication operation is realized.

CN111176609BActive Publication Date: 2024-11-26SAMSUNG ELECTRONICS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201911099085.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2019-02-14
Filing Date
2019-11-12
Publication Date
2024-11-26
Estimated Expiration
2039-11-12

AI Technical Summary

Technical Problem

Multiplication operations with weights and activation values ​​close to zero in neural network models lead to power waste, and existing multipliers are difficult to effectively save power.

Method used

An unsigned multiplier is designed to dynamically disable or split the multiplier to reduce power consumption by detecting whether the operand is equal to zero or the absolute value is less than a certain threshold, and to optimize the multiplication operation using multiplexers and shift circuits.

Benefits of technology

Effectively reduces power consumption during multiplication operation, especially when the weight and activation values ​​are less than a specific threshold, significantly reduces the power use of the multiplier.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111176609B_ABST
    Figure CN111176609B_ABST
Patent Text Reader

Abstract

A multiplier and a method for operating the same are disclosed. An N×N multiplier may include: an N / 2×N first multiplier, an N / 2×N / 2 second multiplier, and an N / 2×N / 2 third multiplier. The N×N multiplier receives two operands for multiplication. If the operands are equal to zero or have small values, the first multiplier, the second multiplier, and / or the third multiplier are selectively disabled. If both operands are less than 2 N / 2 , then the second or third multiplier is used to multiply the operands. If one operand is less than 2 N / 2 and the other operand is equal to or greater than 2 N / 2 , then the first multiplier is used to multiply the operands, or the second and third multipliers are used to multiply the operands. If the two operands are equal to or greater than 2 N / 2 , then the first multiplier, the second multiplier and the third multiplier are used to multiply the operands.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This patent application claims the benefit of priority to U.S. Provisional Patent Application No. 62 / 760,028, filed on November 12, 2018, and U.S. Application No. 16 / 276,582, filed on February 14, 2019, the disclosures of which are incorporated herein by reference in their entirety. Technical Field

[0002] The subject matter disclosed herein generally relates to computing circuits. More specifically, the subject matter disclosed herein relates to an unsigned multiplier that performs signed multiplication and unsigned multiplication. Background Art

[0003] A neural network model typically has many (e.g., 50%) weights that are zero, and many (e.g., 50% to 90%) activations that are zero. Therefore, power can be saved by not performing any multiply-by-zero operations. In addition, the absolute values ​​of the weights, abs(w), and the absolute values ​​of the activations, abs(a), of the neural network model are typically close to zero. For example, typically 95% of the non-zero 8-bit multiplication operations include at least one operand with abs(w)≤15 or abs(a)≤15. Power can also be saved by taking advantage of the absolute values ​​of the weights and the absolute values ​​of the activations being close to zero. Summary of the invention

[0004] An example embodiment provides a multiplier that may include an N-bit×N-bit multiplier and a control circuit. The N-bit×N-bit multiplier may receive a first operand that may include N bits and a second operand that may include N bits, and the N-bit×N-bit multiplier may include a first multiplier and a second multiplier. The first multiplier may include an N / 2-bit×N-bit multiplier, and the second multiplier may include an N / 2-bit×N-bit multiplier. The control circuit may be coupled to the first operand and the second operand, and if a value of the first operand or a value of the second operand is equal to zero, the control circuit may disable the first multiplier and the second multiplier. If an absolute value of the first operand or an absolute value of the second operand is less than 2 N / 2 , the control circuit can also control the second multiplier to multiply the first operand and the second operand. If the absolute value of the first operand and the absolute value of the second operand are both equal to or greater than 2 N / 2 , the control circuit may also control the first multiplier to multiply the first operand and the second operand, and control the second multiplier to multiply the first operand and the second operand. In one embodiment, the second multiplier may include a third multiplier and a fourth multiplier, wherein the third multiplier may be an N / 2-bit × N / 2-bit multiplier, and the fourth multiplier may be an N / 2-bit × N / 2-bit multiplier. If the absolute value of the first operand and the absolute value of the second operand are both less than 2 N / 2, the control circuit can also control the third multiplier or the fourth multiplier to multiply the first operand and the second operand, if the absolute value of one of the first operand and the second operand is less than 2 N / 2 , and the absolute value of the other of the first operand and the second operand is equal to or greater than 2 N / 2 , the control circuit can also control the first multiplier to multiply the first operand and the second operand, and control the third multiplier and the fourth multiplier to multiply the first operand and the second operand. In addition, a smaller multiplier (such as the third multiplier or the fourth multiplier) can be further recursively subdivided into a pair of multipliers according to the same steps as above.

[0005] Another example embodiment provides a method for multiplying a first operand and a second operand, the method may include: receiving the first operand and the second operand at an N-bit×N-bit multiplier, the first operand including N bits, the second operand including N bits, the N-bit×N-bit multiplier including a first multiplier and a second multiplier, the first multiplier including an N / 2-bit×N-bit multiplier, and the second multiplier including an N / 2-bit×N-bit multiplier; determining whether the value of the first operand is equal to zero, is less than 2 N / 2 , or whether it is equal to or greater than 2 N / 2 ; Determine whether the value of the second operand is equal to zero or less than 2 N / 2 , or whether it is equal to or greater than 2 N / 2 ; If the value of the first operand or the value of the second operand is equal to zero, the first multiplier and the second multiplier are disabled; If the absolute value of the first operand or the absolute value of the second operand is less than 2 N / 2 , the second multiplier is controlled to multiply the first operand and the second operand; and if the absolute value of the first operand and the absolute value of the second operand are both equal to or greater than 2 N / 2 , then the first multiplier is controlled and the second multiplier is controlled to multiply the first operand and the second operand.

[0006] Another example embodiment provides a multiplier, which may include: an N-bit×N-bit multiplier and a controller. The N-bit×N-bit multiplier may receive a first operand including N bits and a second operand including N bits. The N-bit×N-bit multiplier may include a first multiplier and a second multiplier, wherein the first multiplier may include a P-bit×N-bit multiplier and the second multiplier may include a Q-bit×N-bit multiplier, wherein P and Q are integers, P+Q=N and P>Q. A control circuit may be coupled to the first operand and the second operand, and if the value of the first operand or the value of the second operand is equal to zero, the circuit may disable the first multiplier and the second multiplier. If the absolute value of the first operand or the absolute value of the second operand is less than 2 Q, the control circuit can also control the second multiplier to multiply the first operand and the second operand. If the absolute value of the first operand and the absolute value of the second operand are both equal to or greater than 2 Q , the control circuit may control the first multiplier to multiply the first operand and the second operand, and may control the second multiplier to multiply the first operand and the second operand. In one embodiment, the second multiplier may include a third multiplier and a fourth multiplier, wherein the third multiplier may include an R-bit × Q-bit multiplier, and the fourth multiplier may include an S-bit × Q-bit multiplier, wherein R and S are integers, R+S=Q and R>S. If the absolute value of the first operand and the absolute value of the second operand are both less than 2 S , the control circuit may further control the third multiplier or the fourth multiplier to multiply the first operand and the second operand, and if the absolute value of one of the first operand and the second operand is less than 2 S , and the absolute value of the other of the first operand and the second operand is equal to or greater than 2 S , the control circuit can also control the first multiplier to multiply the first operand and the second operand, or can control the third multiplier and the fourth multiplier to multiply the first operand and the second operand. BRIEF DESCRIPTION OF THE DRAWINGS

[0007] In the following sections, various aspects of the subject matter disclosed herein will be described with reference to exemplary embodiments shown in the accompanying drawings, in which:

[0008] Figure 1 depicts a functional block diagram of an example embodiment of a multiplier according to the subject matter disclosed herein;

[0009] Figure 2 depicts an example embodiment of a multiplier configured as two 4-bit x 8-bit multipliers in accordance with the subject matter disclosed herein;

[0010] Figure 3 depicts a functional block diagram of an example embodiment of a multiplier when configured and operated as an 8-bit x 8-bit multiplier using two 4-bit x 8-bit multipliers in accordance with the subject matter disclosed herein;

[0011] Figure 4 depicts a functional block diagram of an example embodiment of a multiplier when one operand is small and the other operand is large in accordance with the subject matter disclosed herein;

[0012] Figure 5 depicts a functional block diagram of an example embodiment of a multiplier that has been configured to operate as a 5-bit x 8-bit multiplier in accordance with the subject matter disclosed herein;

[0013] Figure 6depicts a functional block diagram of an example embodiment of a multiplier when configured to shift bits of operand a[7:0] down or right so that the operands can be multiplied by a 5-bit x 8-bit multiplier in accordance with the subject matter disclosed herein;

[0014] Figure 7 depicts a functional block diagram of an example embodiment of a multiplier when configured and operated as two 4-bit x 4-bit multipliers in accordance with the subject matter disclosed herein;

[0015] Figure 8 depicts a functional block diagram of an example embodiment of a multiplier when configured to operate as a 4-bit x 5-bit multiplier in accordance with the subject matter disclosed herein;

[0016] Fig. 9 depicts a functional block diagram of an example embodiment of a multiplier when configured to shift bits of operand b[7:0] down or right so that the operands can be multiplied by a 4-bit x 5-bit multiplier in accordance with the subject matter disclosed herein;

[0017] Fig.10 Depicted is a functional block diagram of an example embodiment of an operand-isolation-enabled (OI) multiplier having a zero detection circuit operable to control the multiplier to be disabled if an operand input to the multiplier is detected as zero in accordance with the subject matter disclosed herein. DETAILED DESCRIPTION

[0018] In the detailed description below, numerous specific details are set forth to provide a comprehensive understanding of the present disclosure. However, those skilled in the art will appreciate that the disclosed aspects may be practiced without these specific details. In other instances, well-known methods, processes, components, and circuits are not described in detail to avoid obscuring the subject matter disclosed herein.

[0019] References throughout this specification to "one embodiment" or "embodiment" indicate that a particular feature, structure or characteristic described in conjunction with the embodiment may be included in at least one embodiment disclosed herein. Therefore, the appearance of the phrase "in one embodiment" or "in an embodiment" or "according to an embodiment" (or other phrases with similar meanings) in various locations throughout this specification may not necessarily all represent the same embodiment. In addition, in one or more embodiments, the particular features, structures or characteristics may be combined in any suitable manner. In this regard, as used herein, the word "exemplary" means "used as an example, instance or illustration". Any embodiment described herein as "exemplary" will not be interpreted as necessarily preferred or superior to other embodiments. In addition, depending on the context discussed herein, a singular term may include a corresponding plural form, and a plural term may include a corresponding singular form. It is also noted that the various drawings (including component diagrams) shown and discussed herein are for illustrative purposes only and are not drawn to scale. Similarly, various waveform diagrams and timing diagrams are shown for illustrative purposes only. For example, the size of some of the elements may be exaggerated relative to other elements for clarity. Further, where considered appropriate, reference numerals have been repeated among the figures to indicate corresponding and / or analogous elements.

[0020] The terms used herein are only for the purpose of describing specific exemplary embodiments and are not intended to limit the subject matter claimed. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. It will also be understood that the terms "include" and / or "comprise" when used in this specification specify the presence of narrated features, wholes, steps, operations, elements, components and / or their groups, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or their groups. The terms "first", "second", etc., as used herein, are used as labels for the nouns after them, and unless so clearly defined, do not imply any type of ordering (e.g., space, time, logic, etc.). In addition, the same reference numerals may be used in two or more figures to represent parts, components, blocks, circuits, units or modules with the same or similar functions. However, such use is only for the simplicity of explanation and ease of discussion; it does not imply that the structure or construction details of such components or units are the same in all embodiments, or that such commonly referenced components / modules are the only way to implement the teachings of the specific embodiments disclosed herein.

[0021] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by those of ordinary skill in the art to which the subject matter belongs. It will also be understood that, unless expressly so defined herein, terms (such as those defined in common dictionaries) should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and will not be interpreted in an idealized or overly formal sense.

[0022] The term "module" as used herein refers to any combination of software, firmware, and / or hardware configured to provide the functionality described herein in conjunction with the module. Software may be implemented as a software package, code, and / or instruction set or instructions, and the term "hardware" as used in any embodiment described herein may include, for example, hard-wired circuits, programmable circuits, state machine circuits, and / or firmware storing instructions executed by programmable circuits, either individually or in any combination. Modules may be implemented collectively or individually as circuits that form part of a larger system (e.g., but not limited to, an integrated circuit (IC), a system on a chip (SoC), etc.).

[0023] The subject matter disclosed herein provides an unsigned multiplier for performing signed and unsigned multiplications. In addition, the subject matter disclosed herein provides a multiplier in which portions of the multiplier can be disabled or powered down in the event that a multiply-by-fraction condition or a multiply-by-zero condition is detected, thereby reducing the amount of power used during the multiplication operation. Thus, the subject matter disclosed herein can take advantage of the fact that the weights and activations of a neural network can be small or zero in order to reduce the power used by the multiplier when multiplying the weights and activations.

[0024] Although some multiplier embodiments disclosed herein are configured as N×N multipliers, the subject matter disclosed herein is not so limited.Some multiplier embodiments according to the subject matter disclosed herein may be configured as N×M multipliers, where N=M or N≠M.

[0025] Figure 1A functional block diagram of an example embodiment of a multiplier 100 according to the subject matter disclosed herein is depicted. The multiplier 100 calculates the product po of ain and bin, where ain can be signed or unsigned, bin can be signed or unsigned, and the product po can be signed or unsigned. If the generated product is negative, the output po is signed. The multiplier 100 includes an input converter 101, an 8-bit×8-bit unsigned multiplier 102, and an output converter 103. The input converter 101 receives two 8-bit operands ain[7:0] and bin[7:0] and 1-bit type signals ain_type and bin_type for each operand. The 1-bit type signal indicates the sign of the operand. If the operand is an unsigned operand, the 1-bit type signal is equal to 0, and if the operand is a signed operand, the 1-bit type signal indicates the sign of the operand. The input converter 101 outputs two operands as unsigned ai[7:0]:=abs(ain[7:0]) and unsigned bi[7:0]:=abs(bin[7:0]) to the unsigned multiplier 102. The input converter 101 also outputs a p_sign signal indicating the sign of the generated product: p_sign:=sign(ain)xor sign(bin). If ain is signed and negative, sign(ain) is 1, otherwise it is 0. If bin is signed and negative, sign(bin) is 1, otherwise it is 0. The unsigned multiplier 102 multiplies the two unsigned input operands ai[7:0] and bi[7:0] and outputs a 16-bit product signal p[15:0]. The output converter 103 converts the 16-bit unsigned product signal p[15:0] into an output signal po[15:0] which may be signed or unsigned according to the p_sign signal. Specifically, if p_sign == 1, then po:=-p, otherwise po:=p.

[0026] In one embodiment, input converter 101, multiplier 102, and / or output converter 103 may be or may include one or more modules that provide the functionality of the device. For example, in one embodiment, input converter 101, multiplier 102, and / or output converter 103 may include hardware logic circuits for performing some or all of the functionality of the device. As another example, another embodiment may include a processor (not shown) that executes software and / or firmware that can provide the functionality provided by input converter 101, multiplier 102, and / or output converter 103.

[0027] Although multiplier 102 is depicted as an 8-bit×8-bit multiplier, the subject matter disclosed herein is not limited to 8-bit×8-bit multipliers. In other embodiments, multiplier 102 may be implemented as a signed or unsigned 16-bit×16-bit multiplier, as a signed or unsigned 16-bit×8-bit multiplier, as a signed or unsigned 8-bit×8-bit multiplier, which may use multiple cycles (i.e., use multiple clock cycles) to generate and accumulate partial products, such as using two clock cycles to complete a 16-bit×8-bit or 8-bit×16-bit signed or unsigned multiplication, or using four clock cycles to complete a 16-bit×16-bit signed or unsigned multiplication. In one embodiment, multiplier 102 may be configured as two 4-bit×8-bit multipliers, wherein one of the two 4-bit×8-bit multipliers may be configured as two 4-bit×4-bit multipliers. In another embodiment, the multiplier 102 may be recursively subdivided into two halves, for example, a 16-bit×16-bit multiplier may be divided into two 16-bit×8-bit multipliers, wherein a 16-bit×8-bit multiplier may be further divided into two 8-bit×8-bit multipliers, wherein one 8-bit×8-bit multiplier of the two 8-bit×8-bit multipliers may be divided into two 4-bit×8-bit multipliers. In addition, the multiplier may be divided in an uneven manner to form, for example, an 8-bit×5-bit multiplier and an 8-bit×3-bit multiplier from an 8-bit×8-bit multiplier.

[0028] Figure 2 An example embodiment of multiplier 102 configured as two 4-bit×8-bit multipliers 201 and 202 is depicted in accordance with the subject matter disclosed herein. Additionally, multiplier 202 may be configured as two 4-bit×4-bit multipliers 203 and 204. Figure 2 The configuration depicted in allows multiplier 102 to receive two 8-bit operands and perform a multiplication operation using the two 8-bit operands. If one of the two 8-bit operands has an absolute value less than or equal to 15, the operand can be treated as a 4-bit operand, and if the other of the two 8-bit operands has an absolute value greater than 15, the operand is treated as an 8-bit operand, and then multiplier 201 can be controlled to receive the two operands and perform a 4-bit×8-bit multiplication. In this case, multiplier 202 (i.e., multipliers 203 and 204) can be disabled by, for example, fixing or "freezing" the input of one or more multipliers to prevent the logic triggering (toggling) of the multiplier, or can be disabled by powering off one or more multipliers, thereby reducing the amount of power used during the multiplication operation. In an optional configuration, multiplier 202 can be used to perform a 4-bit×8-bit multiplication operation, and multiplier 201 can be powered off or not operated during the multiplication operation. In another embodiment, each of the multiplier 201 and the multiplier 202 may be formed of two 4-bit×4-bit multipliers.

[0029] If both operands are 4-bit operands (i.e., the absolute values ​​of both 8-bit inputs are less than or equal to 15), then one of the 4-bit×4-bit multipliers 203 or 204 may be controlled to receive the operand, while the unused 4-bit×4-bit multiplier and multiplier 201 may be powered down or not operated during the multiplication operation.

[0030] As described in more detail below, if both operands are zero, then multiplier 102 may be disabled or powered down during the multiplication operation.

[0031] Figure 3 Depicted is a method for implementing an 8-bit x 8-bit multiplier ( FIG. 1 ) using two 4-bit x 8-bit multipliers as an 8-bit x 8-bit multiplier ( FIG. 1 ) according to the subject matter disclosed herein. Figure 2 ) is configured and operated. The 4-bit x 8-bit multiplier 201 and the 4-bit x 8-bit multiplier 202 receive a first 8-bit operand ai[7:0] and a second 8-bit operand bi[7:0], respectively. The multiplier 201 also receives the lower 4 bits ai[3:0] of the input ai[7:0], and the multiplier 202 also receives the upper 4 bits ai[7:4] of the input ai[7:0]. For example, the operand ai[7:0] may represent the value of the weight, and the operand bi[7:0] may represent the value of the activation. The multiplier 201 outputs the product p1[11:0], and the multiplier 202 outputs the product p2[11:0]. The product p2[11:0] is shifted up by 4 bits (i.e., shifted to the left by 4 bits) by the shift circuit 301. The adder 302 adds the output p1[11:0] of the multiplier 201 and the output {p2[11:0], 0000} of the shift circuit 301 to form an output p[15:0]. The output p[15:0] may correspond to Figure 1 Output p[15:0] in.

[0032] In the case where ain has a small value representable by a 4-bit unsigned number (i.e., ai≤15) and bin has a large value (i.e., bi≥15), multiplier 201 alone is sufficient to compute the product, and multiplier 202 may be disabled and its output set to zero. This may occur in the case where the neural network uses a rectified linear unit (ReLU) activation function.

[0033] In the case where bin has a small value representable by a 4-bit unsigned number (i.e., bi≤15) and the weight ain has a large value (i.e., ai≥15), the operands may be swapped so that the small value bin operand is again input to the 4-bit input of multiplier 201, while multiplier 202 remains disabled and its output is set to zero. This may occur in the case where the neural network uses a hyperbolic tangent (tanh) activation function instead of a rectified linear unit (ReLU) activation function.

[0034] Figure 4 1 depicts a functional block diagram of an example embodiment of a multiplier 102 when one operand is small and the other operand is large in accordance with the subject matter disclosed herein. Figure 4 As depicted in FIG. 1 , the multiplier 102 includes a swap operand circuit 400. The swap operand circuit 400 includes a first multiplexer 401, a second multiplexer 402, and a swap operand detection circuit 403. The swap operand detection circuit 403 receives input operands ai[7:0] and bi[7:0], and detects whether the two operands should be swapped based on the sizes of the two operands.

[0035] For example, if the activation input bi[7:0] has a small value that fits into 4 bits (i.e., bi≤15), and the weight input ai[7:0] has a large value (i.e., ai≥15), the swap operand detection circuit 403 controls the first multiplexer 401 and the second multiplexer 402 so that the activation input bi[7:0] is output as a[3:0] from the first multiplexer 401, and the weight input ai[7:0] is output as b[7:0] from the second multiplexer 402. The multiplier 201 multiplies the activation a[3:0] and the weight b[7:0]. As described in more detail below, one input of the multiplier 202 is an operand equal to 0 (i.e., a[7:4]=0), and therefore, the multiplier 202 can be controlled to be disabled or powered off.

[0036] As another example, if the weight input ai[7:0] is small and the activation input bi[7:0] is large, the swap operand detection circuit 403 controls the first multiplexer 401 and the second multiplexer 402 so that the weight input ai[7:0] is output as a[3:0] from the first multiplexer 401 and the activation input bi[7:0] is output as b[7:0] from the second multiplexer 402. The multiplier 201 multiplies the weight a[3:0] and the activation b[7:0]. As described in more detail below, one input of the multiplier 202 is an operand equal to 0 (i.e., a[7:4]=0), and therefore, the multiplier 202 can be controlled to be disabled or powered off.

[0037] Table 1 illustrates a truth table that may be used by the swap operand circuit 400, where "x" represents "any" and "!" represents "not". In one embodiment, when the swap operand = 0 or 1 (not x), power may be saved by disabling the multiplier 202 and setting its output to zero. When the swap operand = x, it is recommended to keep the value of the swap operand from the previous clock cycle to reduce power consumption.

[0038] Table 1. Swap operand detection truth table

[0039] ai[7:4] ai[3:0] bi[7:4] bi[3:0] Swap operands x x 0 0 x 0 0 x x x 0 !=0 0 !=0 x 0 !=0 !=0 0 x 0 !=0 !=0 !=0 0 !=0 0 0 !=0 x !=0 0 !=0 0 x !=0 0 !=0 !=0 0 !=0 !=0 0 !=0 1 !=0 !=0 !=0 0 1 !=0 !=0 !=0 !=0 x

[0040] When the multiplier 202 has been disabled or is idle and its output is set to zero, the adder 302 performs a simple operation of adding zero. The multiplier 102 can be configured to perform a 5-bit × 8-bit multiplication using the adder 302 instead of a 4-bit × 8-bit multiplication. In addition, if the operand a is actually 5 bits or less, instead of 4 bits or less, the logic of the swap operand circuit 400 can be configured not to swap the operands.

[0041] Figure 5 1 depicts a functional block diagram of an example embodiment of a multiplier 102 that has been configured to operate as a 5-bit x 8-bit multiplier in accordance with the subject matter disclosed herein. Figure 5 As depicted in , a multiplexer 501 and a NAND gate 502 may be added to the multiplier 102. One input to the multiplexer 501 is the 12-bit {0000, b[7:0]}, where the four most significant bits are 0 and the eight least significant bits (LSBs) are b[7:0]. Another input to the multiplexer 501 is the output of the multiplier 202. The output of the multiplexer 501 is bp2[11:0]. The output bp2[11:0] is shifted up by 4 bits (i.e., shifted to the left by 4 bits) by the shift circuit 301, and the shift circuit 301 outputs {p2[11:0], 0000}. Bit a[4] is applied to one input of the NAND gate 502, and another input of the NAND gate 502 receives the isIdle signal that may be output from the multiplier 202 when the multiplier 202 has been disabled or idle. In alternative embodiments, the isIdle signal may be generated elsewhere if multiplier 202 has been disabled. The isIdle signal is 1 when multiplier 202 is expected to perform a multiply-by-zero operation (ie, when a[7:5]=0 or b[7:0]=0).

[0042] When operand a[7:0] has a five-bit value (i.e., a[4]=1 and a[7:5]=0), because operand a[7:5]=0, multiplier 202 is disabled, and NAND gate 502 controls multiplexer 501 to select 12-bit input {0000, b[7:0]}. If operand a[7:5]≠0, multiplier 202 is not disabled, and the output of multiplier 202 is selected by multiplexer 501.

[0043] If operand a[7:0] is non-zero but includes an LSB equal to zero, the operand can be shifted down or right so that the operand can be used Figure 5 For example, if operand a[7:0] = "01010100", then operand a[7:5] ≠ 0 and Figure 5The 5-bit by 8-bit multiplier shown in cannot be used. However, operand a[7:0] can be shifted down by 2 bits to a value "00010101" multiplied using a 5-bit by 8-bit multiplier, and the resulting product can be shifted back up by 2 bits to compensate for the input shift. In this case, multiplier 201 can be used when multiplier 202 is idle to calculate the product in some cases even if input a is greater than 5 bits (i.e., ai>31).

[0044] Figure 6 1 depicts a functional block diagram of an example embodiment of a multiplier 102 when configured to shift bits of operand a[7:0] down or right so that the operands can be multiplied by a 5-bit×8-bit multiplier in accordance with the subject matter disclosed herein. Figure 6 As depicted in , a shift detection circuit 601, a down-shift circuit 602, and an up-shift circuit 603 are added to the multiplier 102. The shift detection circuit 601 detects whether the LSB of the operand a[7:0] is zero. In one embodiment, up to four LSBs may be detected as zero, however, because values ​​with large absolute magnitudes tend to be rare in neural network calculations, the amount by which the input is shifted down may be limited to 1 or 2 bits to reduce the hardware area without significant power efficiency loss. If the LSB of the operand a[7:0] is detected as zero, the shift detection circuit 601 controls the down-shift circuit 602 and the up-shift circuit 603 to be operational. The bit ad[4] of the shifted operand a is input to the NAND gate 502. When a[7:5]=0 and the shift amount is 0 bits, or a[7:6]=0 and the shift amount is 1 bit, or a[7]=0 and the shift amount is 2 bits, the isIdle signal in multiplier 202 will be valid (ie, equal to 1).

[0045] In one embodiment, a 4-bit x 8-bit multiplier (ie, Figure 3 The multiplier 201 and / or the multiplier 202 in FIG. 1 can be further subdivided and configured as two halves of each 4-bit×4-bit multiplier in a manner similar to how an 8-bit×8-bit multiplier is subdivided into two halves of each 4-bit×8-bit multiplier. For example, the 4-bit×8-bit multiplier 201 can be configured as two 4-bit×4-bit multipliers.

[0046] Figure 7 2 depicts a functional block diagram of an example embodiment of multiplier 201 when configured and operated as two 4-bit×4-bit multipliers 701 and 702 in accordance with the subject matter disclosed herein. Figure 7As depicted in , multiplier 201 receives a 4-bit operand ai[3:0] and an 8-bit operand bi[7:0]. Multiplier 701 receives the 4-bit operand ai[3:0] and the lower 4 bits bi[3:0] of the 8-bit operand bi[7:0]. Multiplier 702 receives the 4-bit operand ai[3:0] and the upper 4 bits bi[7:4] of the 8-bit operand bi[7:0]. For example, operand ai[3:0] may represent a weight and operand bi[7:0] may represent an activation. Multiplier 701 outputs a product p1[7:0] and multiplier 702 outputs a product p2[7:0]. The product p2[7:0] is shifted up by 4 bits by the shift circuit 703, and the adder 704 adds the output p1[7:0] of the multiplier 701 and the output {p2[7:0], 0000} of the shift circuit 703 to form the output p[11:0]. It should be understood that in an alternative embodiment, the multiplier 202 ( Figure 2 ) can be configured as two 4-bit×4-bit multipliers 701 and 702.

[0047] Figure 7 The multiplier configuration depicted in can be configured to operate as a 4-bit×5-bit multiplier, while one of the 4-bit×4-bit multipliers remains idle for power reduction purposes.

[0048] Figure 8 2 depicts a functional block diagram of an example embodiment of a multiplier 201 when configured to operate as a 4-bit x 5-bit multiplier in accordance with the subject matter disclosed herein. Figure 8 As depicted in , multiplexer 801 and NAND gate 802 may be added to multiplier 201. One input to multiplexer 801 is 8 bits {0000, a[3:0]}, where the four most significant bits are 0 and the four least significant bits (LSBs) are operand a[3:0]. Another input to multiplexer 801 is the output of multiplier 702. The output of multiplexer 801 is bp2[7:0]. The output bp2[7:0] is shifted up by 4 bits (i.e., shifted to the left by 4 bits) by shift circuit 703, and shift circuit 703 outputs {p2[7:0], 0000}. Bit b[4] is applied to one input of NAND gate 802, and another input of NAND gate 802 receives the isIdle signal output from multiplier 702 when multiplier 702 has been inoperable or idle. In an alternative embodiment, the isIdle signal may be generated at other locations. The isIdle signal is 1 when the multiplier 702 is expected to perform a multiply-by-zero operation (ie, when a[3:0]=0 or b[7:5]=0).

[0049] If operand b[7:0] is non-zero but includes an LSB equal to zero, the operand can be shifted down or right so that the operand can be used Figure 8The 4-bit×5-bit multiplier depicted in FIG. 7 is configured to multiply, while the partial product p1 is shifted up to compensate for the input down shift and the multiplier 702 remains idle.

[0050] Fig. 9 2 depicts a functional block diagram of an example embodiment of a multiplier 201 when configured to shift bits of operand b[7:0] down or right so that the operands can be multiplied by a 4-bit x 5-bit multiplier in accordance with the subject matter disclosed herein. Fig. 9 As depicted in , a shift detection circuit 901, a down-shift circuit 902, and an up-shift circuit 903 are added to the multiplier 201. The shift detection circuit 901 detects whether the LSB of the operand b[7:0] is zero. In one embodiment, up to four LSBs may be detected as zero, however, because values ​​with large absolute magnitudes tend to be rare in neural network calculations, the amount by which the input is shifted down may be limited to 1 or 2 bits to reduce the hardware area without significant loss of power efficiency. If the LSB of the operand b[7:0] is detected as zero, the shift detection circuit 901 controls the down-shift circuit 902 and the up-shift circuit 903 to be operational. The bit bd[4] of the shifted operand b is input to the NAND gate 802. When bd[7:5]=0 and the shift amount is 0 bits, or bd[7:6]=0 and the shift amount is 1 bit, or bd[7]=0 and the shift amount is 2 bits, the isIdle signal in multiplier 702 will be valid (ie, equal to 1).

[0051] Fig.10 Depicted is a functional block diagram of an example embodiment of an operand isolation enabled (OI) multiplier such as 102, 201 to 204, and 701 with a zero detection circuit 1000 that can be used to control the multiplier MULT to be disabled if an operand input to the multiplier is detected as zero in accordance with the subject matter disclosed herein. The multiplier MULT can be any of a variety of architectures known in the art.

[0052] The zero detection circuit 1000 may include three NOR gates 1001 to 1003, an AND gate 1004, three registers 1005 to 1007, and an output AND gate 1008. All bits of the first operand a (or ai) are input to the first NOR gate 1001 and to the input of the first register 1005. All bits of the second operand b (or bi) are input to the second NOR gate 1002 and to the input of the second register 1006. Fig.10As depicted in , the first operand a and the second operand b both represent the entire operand, that is, all bits of the operand. If operand a is equal to zero, the first NOR gate 1001 outputs a logic high signal. Similarly, if operand b is equal to zero, the second NOR gate 1002 outputs a logic high signal. The output ai_zero of the first NOR gate 1001 and the output bi_zero of the second NOR gate 1002 are input to the third NOR gate 1003. If operand a or operand b is equal to zero, the output mult_by_zero of the third NOR gate 1003 is logic low. The logic low output from the third NOR gate 1003 forces the output ce_iso of the output AND gate 1004 to be low, that is, the ce signal of the first register 1005 is low and the ce signal of the second register 1006 is low, thereby prohibiting the first operand a and the second operand b from being registered in the first register 1005 and the second register 1006, respectively. In Fig.10 In the figure, clk is the clock signal of the three registers 1005 to 1007, DI is the input terminal of the three registers 1005 to 1007, DO is the output terminal of the three registers 1005 to 1007, and the third register 1007 outputs the signal mult_out_zero.

[0053] If one or both of the operands a and b are equal to zero, the output ai_iso of the first register 1005 and the output bi_iso of the second register 1006 do not change, and the input of the multiplier MULT is fixed or frozen, so no dynamic power is consumed. The third register 1007 also registers the logic low that has been output from the third NOR gate 1003, which disables the output p from the output AND gate 1008. Therefore, the logic of the multiplier MULT has been prohibited from triggering, thereby reducing the amount of power used during the multiplication operation. In another embodiment, the zero detection circuit 1000 alternatively or additionally controls the power applied to the multiplier MULT.

[0054] If both the first operand a and the second operand b are not equal to zero, the AND gate 1004 allows the ce signals of the first register 1005 and the second register 1006 to be high, so as to enable the first operand a and the second operand b to be stored in the first register 1005 and the second register 1006, respectively. The multiplier MULT performs a multiplication operation using the first operand a and the second operand b. The third register 1007 also registers the logic high output from the third NOR gate 1003 and outputs a signal mult_out_zero, thereby enabling the output AND gate 1008 to pass the output signal mult_out from the multiplier MULT.

[0055] In addition, in the case where the multiplier is divided in an uneven manner, the multiplier may include an N-bit×N-bit multiplier and a controller. The N-bit×N-bit multiplier may receive a first operand including N bits and a second operand including N bits. The N-bit×N-bit multiplier may include a first multiplier and a second multiplier, wherein the first multiplier may include a P-bit×N-bit multiplier and the second multiplier may include a Q-bit×N-bit multiplier, wherein P and Q are integers, P+Q=N and P>Q. A control circuit may be coupled to the first operand and the second operand, and if the value of the first operand or the value of the second operand is equal to zero, the circuit may disable the first multiplier and the second multiplier. If the absolute value of the first operand or the absolute value of the second operand is less than 2 Q , the control circuit can also control the second multiplier to multiply the first operand and the second operand. If the absolute value of the first operand and the absolute value of the second operand are both equal to or greater than 2 Q , the control circuit may control the first multiplier to multiply the first operand and the second operand, and may control the second multiplier to multiply the first operand and the second operand. In one embodiment, the second multiplier may include a third multiplier and a fourth multiplier, wherein the third multiplier may include an R-bit × Q-bit multiplier, and the fourth multiplier may include an S-bit × Q-bit multiplier, wherein R and S are integers, R+S=Q and R>S. If the absolute value of the first operand and the absolute value of the second operand are both less than 2 S , the control circuit may further control the third multiplier or the fourth multiplier to multiply the first operand and the second operand, and if the absolute value of one of the first operand and the second operand is less than 2 S , and the absolute value of the other of the first operand and the second operand is equal to or greater than 2 S , the control circuit can also control the first multiplier to multiply the first operand and the second operand, or can control the third multiplier and the fourth multiplier to multiply the first operand and the second operand.

[0056] If the absolute value of the first operand and the absolute value of the second operand are both less than 2 S , the control circuit may also disable the first multiplier and the fourth multiplier, and control the first operand to be input to the R-bit operand input of the third multiplier, and control the second operand to be input to the Q-bit operand input of the third multiplier.

[0057] If the absolute value of the first operand and the absolute value of the second operand are both less than 2 S , the control circuit may also disable the first multiplier and the third multiplier, and control the first operand to be input to the S-bit operand input of the fourth multiplier, and control the second operand to be input to the Q-bit operand input of the fourth multiplier.

[0058] If the absolute value of one of the first and second operands is less than 2 S , and the absolute value of the other of the first operand and the second operand is equal to or greater than 2 S , the control circuit can also disable the first multiplier and control the multiplier with less than 2 S The absolute value operand is input to the Q-bit operand input of the third multiplier and input to the Q-bit operand input of the fourth multiplier, and can be controlled to have a value equal to or greater than 2 S The S least significant bits of the absolute value operand are input to the S-bit operand input of the fourth multiplier, and control the S-bit operand input having a value equal to or greater than 2 S The RS most significant bits of the absolute value operand are input to the R-bit operand input of the third multiplier.

[0059] If the absolute value of one of the first and second operands is less than 2 P , and the absolute value of the other of the first operand and the second operand is equal to or greater than 2 P , the control circuit can also disable the second multiplier and control the P The absolute value of the operand is input to the P-bit operand input of the first multiplier, and the control has a value equal to or greater than 2 P The absolute value operand is input to the N-bit operand input of the first multiplier.

[0060] In addition, in the above embodiment, the multiplier may further include a control circuit. In response to a predetermined condition being satisfied, the control circuit may control the subdivided multiplier in the multiplier to multiply two operands and disable the subdivided multiplier in the multiplier.

[0061] As those skilled in the art will recognize, the inventive concepts described herein are susceptible to modification and variation over a wide range of applications. Accordingly, the scope of the claimed subject matter should not be limited to any of the specific exemplary teachings discussed above, but rather is defined by the claims.

Claims

1. A multiplier, include: An N-bit×N-bit multiplier receives a first operand including N bits and a second operand including N bits, the N-bit×N-bit multiplier includes a first multiplier and a second multiplier, the first multiplier includes an N / 2-bit×N-bit multiplier, and the second multiplier includes an N / 2-bit×N-bit multiplier; as well as a control circuit that disables the first multiplier and the second multiplier if the value of the first operand or the value of the second operand is equal to zero, If the absolute value of the first operand or the absolute value of the second operand is less than 2 N / 2 , the control circuit controls the second multiplier to multiply the first operand and the second operand, and If the absolute value of the first operand and the absolute value of the second operand are both equal to or greater than 2 N / 2 , the control circuit controls the first multiplier to multiply the first operand and the second operand, and controls the second multiplier to multiply the first operand and the second operand.

2. The multiplier as claimed in claim 1, in, the second multiplier includes a third multiplier and a fourth multiplier, the third multiplier includes an N / 2-bit×N / 2-bit multiplier, and the fourth multiplier includes an N / 2-bit×N / 2-bit multiplier, If both the absolute value of the first operand and the absolute value of the second operand are less than 2 N / 2 , the control circuit further controls the third multiplier or the fourth multiplier to multiply the first operand and the second operand, and If the absolute value of one of the first and second operands is less than 2 N / 2 , and the absolute value of the other of the first operand and the second operand is equal to or greater than 2 N / 2 , the control circuit further controls the first multiplier to multiply the first operand and the second operand, or controls the third multiplier and the fourth multiplier to multiply the first operand and the second operand.

3. The multiplier as claimed in claim 2, in, If the absolute value of the first operand and the absolute value of the second operand are both less than 2 N / 2 , The control circuit also disables the first multiplier and the fourth multiplier, and controls the first operand input to the first N / 2-bit operand input of the third multiplier, and controls the second operand input to the second N / 2-bit operand input of the third multiplier.

4. The multiplier as claimed in claim 2, in, If the absolute value of the first operand and the absolute value of the second operand are both less than 2 N / 2 , The control circuit also disables the first multiplier and the third multiplier, and controls the first operand input to the first N / 2-bit operand input of the fourth multiplier, and controls the second operand input to the second N / 2-bit operand input of the fourth multiplier.

5. The multiplier as claimed in claim 2, in, If the absolute value of one of the first and second operands is less than 2 N / 2 , and the absolute value of the other of the first operand and the second operand is equal to or greater than 2 N / 2 , The control circuit also disables the first multiplier and controls the N / 2 The absolute value operand is input to the first N / 2-bit operand input of the third multiplier and input to the first N / 2-bit operand input of the fourth multiplier, and the control has a value equal to or greater than 2 N / 2 The four least significant bits of the absolute value operand are input to the second N / 2-bit operand input of the third multiplier, and control the absolute value of the operand to be equal to or greater than 2. N / 2 The four most significant bits of the absolute value operand are input to the second N / 2-bit operand input of the fourth multiplier.

6. The multiplier as claimed in claim 2, in, If the absolute value of one of the first and second operands is less than 2 N / 2 , and the absolute value of the other of the first operand and the second operand is equal to or greater than 2 N / 2 , The control circuit also disables the second multiplier and controls the N / 2 The absolute value of the operand is input to the N / 2-bit operand input of the first multiplier, and the control has an operand equal to or greater than 2 N / 2 The absolute value operand is input to the N-bit operand input of the first multiplier.

7. The multiplier as claimed in claim 1, in, The first and second operands are unsigned operands. The multiplier also includes: a conversion input circuit receiving a third operand corresponding to the first operand and receiving a fourth operand corresponding to the second operand, and outputting a negative-sign signal if one of the third operand and the fourth operand is a negative value; and The output conversion circuit converts the output of the multiplier into a negative value based on the negative sign signal.

8. The multiplier as claimed in claim 1, in, N is equal to 8.

9. A method of multiplying a first operand and a second operand, the method include: receiving a first operand and a second operand at an N-bit×N-bit multiplier, the first operand comprising N bits, the second operand comprising N bits, the N-bit×N-bit multiplier comprising a first multiplier and a second multiplier, the first multiplier comprising an N / 2-bit×N-bit multiplier, the second multiplier comprising an N / 2-bit×N-bit multiplier; Determines whether the absolute value of the first operand is equal to zero and is less than 2 N / 2 , or whether it is equal to or greater than 2 N / 2 ; Determines whether the absolute value of the second operand is equal to zero or is less than 2. N / 2 , or whether the absolute value of the second operand is equal to or greater than 2 N / 2 ; If the value of the first operand or the value of the second operand is equal to zero, disabling the first multiplier and the second multiplier; If the absolute value of the first operand or the absolute value of the second operand is less than 2 N / 2 , then controlling the second multiplier to multiply the first operand and the second operand; as well as If the absolute value of the first operand and the absolute value of the second operand are both equal to or greater than 2 N / 2 , then the first multiplier is controlled and the second multiplier is controlled to multiply the first operand and the second operand.

10. The method according to claim 9, in, the second multiplier includes a third multiplier and a fourth multiplier, the third multiplier includes an N / 2-bit×N / 2-bit multiplier, and the fourth multiplier includes an N / 2-bit×N / 2-bit multiplier, The method further comprises: If the absolute value of the first operand and the absolute value of the second operand are both less than 2 N / 2 , then the third multiplier or the fourth multiplier is controlled to multiply the first operand and the second operand, and If the absolute value of one of the first and second operands is less than 2 N / 2 , and the absolute value of the other of the first operand and the second operand is equal to or greater than 2 N / 2 , then the first multiplier is controlled to multiply the first operand and the second operand, or the third multiplier and the fourth multiplier are controlled to multiply the first operand and the second operand.

11. The method according to claim 10, in, If the absolute value of the first operand and the absolute value of the second operand are both less than 2 N / 2 , The method further comprises: controlling the first operand input to a first N / 2-bit operand input of a third multiplier and controlling the second operand input to a second N / 2-bit operand input of the third multiplier, or The first operand is controlled to be input to a first N / 2-bit operand input of a fourth multiplier, and the second operand is controlled to be input to a second N / 2-bit operand input of the fourth multiplier.

12. The method according to claim 10, in, If the absolute value of one of the first and second operands is less than 2 N / 2 , and the absolute value of the other of the first operand and the second operand is equal to or greater than 2 N / 2 , Then the method further includes: controlling the N / 2 The absolute value operand is input to the first N / 2-bit operand input of the third multiplier and input to the first N / 2-bit operand input of the fourth multiplier, and the control has a value equal to or greater than 2 N / 2 The four least significant bits of the absolute value operand are input to the second N / 2-bit operand input of the third multiplier, and control the absolute value of the operand to be equal to or greater than 2. N / 2 The four most significant bits of the absolute value operand are input to the second N / 2-bit operand input of the fourth multiplier.

13. The method according to claim 10, in, If the absolute value of one of the first and second operands is less than 2 N / 2 , and the absolute value of the other of the first operand and the second operand is equal to or greater than 2 N / 2 , Then the method further includes: controlling the N / 2 The absolute value of the operand is input to the N / 2-bit operand input of the first multiplier, and the control has an operand equal to or greater than 2 N / 2 The absolute value operand is input to the N-bit operand input of the first multiplier.

14. The method of claim 9, in, If the first and second operands are unsigned operands, The method further comprises: receiving a third operand and a fourth operand, the third operand corresponding to the first operand and the fourth operand corresponding to the second operand; and If one of the third operand and the fourth operand is a negative value, the output of the N-bit×N-bit multiplier is converted to a negative value.

15. The method of claim 9, in, N is equal to 8.

16. A multiplier, include: an N-bit×N-bit multiplier receiving a first operand including N bits and a second operand including N bits, the N-bit×N-bit multiplier including a first multiplier and a second multiplier, the first multiplier including a P-bit×N-bit multiplier, the second multiplier including a Q-bit×N-bit multiplier, wherein P and Q are integers, P+Q=N and P>Q; and a control circuit coupled to the first operand and the second operand, the control circuit disabling the first multiplier and the second multiplier if the value of the first operand or the value of the second operand is equal to zero, If the absolute value of the first operand or the absolute value of the second operand is less than 2 Q , the control circuit controls the second multiplier to multiply the first operand and the second operand, and If the absolute value of the first operand and the absolute value of the second operand are both equal to or greater than 2 Q , the control circuit controls the first multiplier to multiply the first operand and the second operand, and controls the second multiplier to multiply the first operand and the second operand.

17. The multiplier as claimed in claim 16, in, The second multiplier includes a third multiplier and a fourth multiplier, the third multiplier includes an R-bit×Q-bit multiplier, and the fourth multiplier includes an S-bit×Q-bit multiplier, wherein R and S are integers, R+S=Q and R>S, and If both the absolute value of the first operand and the absolute value of the second operand are less than 2 S , the control circuit further controls the third multiplier or the fourth multiplier to multiply the first operand and the second operand, and If the absolute value of one of the first and second operands is less than 2 S , and the absolute value of the other of the first operand and the second operand is equal to or greater than 2 S , the control circuit further controls the first multiplier to multiply the first operand and the second operand, or controls the third multiplier and the fourth multiplier to multiply the first operand and the second operand.

18. The multiplier as claimed in claim 17, in, If the absolute value of the first operand and the absolute value of the second operand are both less than 2 S , The control circuit also disables the first multiplier and the fourth multiplier, and controls the first operand to be input to the R-bit operand input of the third multiplier, and controls the second operand to be input to the Q-bit operand input of the third multiplier.

19. The multiplier of claim 17, in, If the absolute value of the first operand and the absolute value of the second operand are both less than 2 S , The control circuit also disables the first multiplier and the third multiplier, and controls the first operand to be input to the S-bit operand input of the fourth multiplier, and controls the second operand to be input to the Q-bit operand input of the fourth multiplier.

20. The multiplier of claim 17, in, If the absolute value of one of the first and second operands is less than 2 S , and the absolute value of the other of the first operand and the second operand is equal to or greater than 2 S , The control circuit also disables the first multiplier and controls the S The absolute value operand is input to the Q-bit operand input of the third multiplier and input to the Q-bit operand input of the fourth multiplier, and the control has a value equal to or greater than 2 S The S least significant bits of the absolute value operand are input to the S-bit operand input of the fourth multiplier, and control the S-bit operand input having a value equal to or greater than 2 S The RS most significant bits of the absolute value operand are input to the R-bit operand input of the third multiplier.

21. The multiplier of claim 17, in, If the absolute value of one of the first and second operands is less than 2 P , and the absolute value of the other of the first operand and the second operand is equal to or greater than 2 P , The control circuit also disables the second multiplier and controls the P The absolute value of the operand is input to the P-bit operand input of the first multiplier, and the control has a value equal to or greater than 2 P The absolute value operand is input to the N-bit operand input of the first multiplier.

22. The multiplier of claim 16, in, The first and second operands are unsigned operands. The multiplier also includes: a conversion input circuit receiving a third operand corresponding to the first operand and receiving a fourth operand corresponding to the second operand, and outputting a negative-sign signal if one of the third operand and the fourth operand is a negative value; and The output conversion circuit converts the output of the multiplier into a negative value based on the negative sign signal.