SIGNED MULTIPLIER

Abstract: Disclosed is a signed multiplier for use in a data processing system that handles 2's complement operands. The signed multiplier operates to form a preliminary product independently of the signs of the multiplier and multiplicand. While the multiplication is in progress, the signs of the multiplier and multiplicand are checked. For multiplications where either one of the operands (multiplier or multiplicand) is negative, the preliminary product is modified by one or two correction factors. The correction factors are multiples of the 2's complements of the operands. The correction factor or factors are added to the preliminary product to form the final product.

Description: The present invention relates to 2's complement signed multipliers for use in data processing systems. Low performance computers frequently perform multiplication by a sequence of additions using an adder. Such an approach takes many cycles of operation and thus is slow. High performance computers cannot tolerate long routines for multiplication. Therefore, high performance data processing systems generally include special functional units and/or special high speed routines to handle multiplication. In multiplication, multipliers and multiplicands can both be positive and negative. Frequently, 2's complement form is employed to accommodate negative numbers. There are many ways to design multipliers to handle 2's complement multipliers and multiplicands. In one approach, the signs of both operands (multiplier and multiplicand) can be checked prior to commencing the multiplication. Depending upon the signs of the operands, the appropriate multiplication routine is executed to give the correct, final product. While such a method is satisfactory for many applications, it has the detriment that the multiplication routine cannot commence until after the signs have been checked. Such a procedure always requires a delay before the multiplication commences and such a delay is wasteful of processing time. In another approach, sign extension hardware is used which operates in parallel with other multiplication hardware thereby avoiding extra processing time. The sign extension hardware, however, has the detriment of adding extra cost and complexity to the computer. A number of algorithms for the execution of binary multiplication is disclosed in Y. Chu: "Digital Computer Design Fundamentals", pp.24-35, McGraw-Hill (1962). A first approach to binary multiplication disclosed is repeated addition. This approach is subdivided into six methods, one of the methods being the Burks-Goldstine-Von Neumann Method. This method multiplies binary numbers in signed-2s-complement representation. In this method, both the multiplier X and the multiplier Y are represented by an unsigned number (X*,Y*) plus a sign bit (X o , Y o ). The method forms a product of the unsigned numbers X*Y* = (X+X o )(Y+Y o )= XY+XoY+YoX+XoYo . The desired product XY is obtained by applying a correction (-YoX,-XoY or - [ XoY+YoX+XoYo ]) depending on the values of Xo and Yo - i.e. whether the multiplier, multiplicand, or both, are negative. There is no correction if both X and Y are positive. In accordance with the above background, there is a need for an improved multiplier and method of multiplication in a data processing system which avoids the extra cost required with sign extension hardware and which avoids the delays required for sign checking prior to the time that multiplication begins. It is a feature of the present invention that the adjustment process occurs as part of the multiplication process and adds only a single cycle to the processing time. According to the prior art, the adjustment process was carried out as an independent arithmetic operation after completion of the multiplication. In general, multipliers for high-performance systems must be able to multiply relatively large operands. For example, a typical multiplier should be large enough to multiply 32-bit signed operands to form a 64-bit signed product, and to multiply 56-bit unsigned operands to form 112-bit unsigned products. However, the physical size of the multiplier must be minimized, by taking advantage, for example, of hardware provided for other purposes. The present invention provides an apparatus for multiplying a first operand having a sign by a second operand having a sign, in 2's complement form, to provide a final product, comprising: a first register for storing the first and second operands; a second register for storing the second operand; means, coupled to the first register, for generating complements of said operands; means, coupled to the first register and the second register to receive the first operand and an increment of the second operand, for multiplying the first operand by the increment of the second operand to generate a partial sum output and a partial carry output; third register means, coupled to the means for multiplying, for storing the partial sum output and the partial carry output; a result register; three port adder means having a first port, a second port and a third port, for adding data received at the first, second and third ports to generate a resulting sum and supplying the resulting sum to the result register, the first port, second port and third port connected to receive in any given machine cycle up to three of the following data: the partial sum output from the third register, the partial carry output of the third register, the first operand, the complement of the first operand, the second operand, the complement of the second operand, the contents of the result register or zero; control means, coupled to the means for multiplying and the three port adder means, for controlling the means for multiplying and the three port adder means to successively generate partial sum and carry outputs and to add the partial sum and carry outputs to the contents of the result register to generate preliminary products in said result register, to which preliminary products adjustments may be added to form partial products in said result register,until a final partial product is generated; and adjustment means, responsive to the sign of the first operand and of the second operand for generating an adjustment while multiplication is in progress, said adjustment being determined by a first condition (C2) in which the first operand is positive and the second operand is negative, a second condition (C3) in which the first operand is negative and the second operand is positive, and a third condition (C4) in which both the first and second operands are negative, said adjustment being added to a said preliminary product in the result register to form a said partial product; wherein said adjustment means includes, means, responsive to the first condition (C2), for controlling the adder means to add the complement of the first operand to the high order bits of said preliminary product, means, responsive to the second condition (C3), for controlling the adder means to add a multiple of the complement of the second operand to said preliminary product, and means, responsive to the third condition (C4), for controlling the adder means to add a multiple of the complement of the second operand to said preliminary product and to add the complement of the first operand to the high order bits of said preliminary product. In the present invention a three-port adder is employed to add simultaneously three terms as part of the multiplication. When both operands are negative, the three-port adder simultaneously adds two correction factors to the preliminary product in order to form the final product. The present invention achieves the objective of providing an improved multiplier and method for multiplying which has improved speed of multiplication and which does not require sign extension hardware. The foregoing and other objects, features and advantages of the invention will be apparent from the following detailed description set forth in conjunction with the accompanying drawings. FIG. 1 depicts a block diagram of the signed multiplier of the present invention. FIG. 2 depicts a control unit comprising a dual microprogram control store which forms part of the FIG 1 apparatus. FIG. 3 depicts a block diagram of the operand processing unit of FIG. 1. FIG. 4 depicts a detailed block diagram of the signed multiplier unit of FIG. 1. Detailed Description Signed Multiplier - FIG. 1 In FIG. 1, a signed multiplier for use in a data processing system is shown. The signed multiplier includes the operand processing unit 2, the multiplier unit 3 and a control unit 4. The control unit 4 can be any conventional control unit for controlling operations of hardware in a data processing system. Typically, control unit 4 is a microprogram unit which operates to control multiplication by microprogram routines. In FIG. 1, the operands to be multiplied are supplied by the operand processing unit 2 to the multiplier unit 3. In one embodiment described, the multiplier unit 3 includes a high-speed multiplier 5 and a three-port adder 6. Control Unit - FIG. 2 In FIG. 2, the control unit 4 of FIG. 1 is shown. Typically unit 4 has two or more control stores including the E CONTROL STORE A (ECSA) 21 and the E CONTROL STORE B (ECSB) 22. The control stores 21 and 22 each store microinstructions and are initiated and controlled by a common control 20. Microinstructions are selected by a common output 23 for controlling units in a data processing system. The units 24 and 25 in FIG. 2 are typical units and, for example, can be the processing unit 2 and the multiplying unit 3 of FIG. 1. The control unit of FIG. 2, in one typical embodiment, is like that described in the application entitled, MULTIPLE MODULE CONTROL STORE FOR USE IN A DATA PROCESSING SYSTEM, Serial No. 184,126, filed on September 4, 1980 and assigned to the assignee of the present invention. In FIG. 2, the A control store 21 provides microinstruction control words on bus 51 to the common output 23. Similarly, the B control store 22 provides microinstruction control words on bus 52 to the common output 23. The common output 23 selects a control word from either bus 51 or from bus 52 for controlling the units 24 and 25. The A control store 21 and the B control store 22 each provide control words on buses 51 and 52 for each machine cycle. Each cycle, the A control store 21 also provides a branch address on bus 35 to the B control store 22. Similarly, each cycle, the B control store 22 provides a branch address on bus 45 to the A control store 21. Each cycle, the common control 20 determines for both the A and B control stores 21 and 22 whether the branch address from the other control store or the sequential address is to be selected. The sequential address is the address of the next instruction in sequence. The common control 20 receives on lines 59 an indication from the common output 23 whether or not a branch is specified by the current control word. Common control 20 senses via lines 18 and 19 the state of branch conditions within the controlled units 24 and 25 and decides whether or not any branch is to be taken. The common control 20, via lines 17, controls the common output 23 to select the microinstruction control word from the A or B control stores 21 or 22. This selected control word controls the state of the units 24 and 25. In one embodiment, the common control contains latches which control the signed multiplier (not shown) and these latches include SIGN1-TRIGGER, SIGN2-TRIGGER, and ZERO-TRIGGER. The outputs of these latches assist in the determination of whether or not a branch should be taken. Common output 23 sends signals along lines 59 to common control 20 to determine which, if any, of these latches should be tested. Operand Processing Unit - FIG. 3 In FIG. 3, apparatus useful in carrying out a fixed-point multiply operation within a data processing system is shown. In FIG. 3, four 32-bit operand word registers 101, 102, 103 and 104 are provided for storing operands which are to be processed in accordance with instructions from microprogram control stores. Registers 101 and 102 provide input to the operand word register selector 105 and registers 103 and 104 provide inputs to the operand word register selector 106. Selector 105 selects an input for the LUCKH selector 107 and selector 106 provides an input to the LUCKL selector 108. The LUCKH SIGN2 line from selector 107 indicates the sign of the operand 2 selected by the selector 107. The LUCKL SIGN1 line from selector 108 indicates the sign of the operand 1 selected by the selector 108. Selectors 107 and 108 select the operands to provide inputs to the LUCK unit 109, to the A register (AR) 110 and to the B register (BR) 111. Both the AR and BR are 32 bits wide. In FIG. 3, operands 1 and 2 from the selectors 108 and 107 are operated upon by unit 109 which performs logical, compare, compact, expand, and status operations. While such operations are conventional, they are not all required for the particular example being described. For the purpose of the present invention, unit 109 detects whether or not either the operand 1 from the LUCKL selector 108 or the operand 2 from the LUCKH selector 107 is equal to ZERO to provide a branch condition indication on the (LUCKH) v (LUCKL) = 0 line 15. In FIG. 3, a byte mover 112 selects one byte (8 bits) from the selectors 107 or 108 and moves it to appropriate locations in the data processing system. To perform additions, the byte adder 113 receives inputs from the selectors 107 and 108, shift amount register (SAR) 116, or the byte adder register (BAR) 117. The decrementor 115 is provided to decrement the contents of SAR register 116. None of the units of this paragraph except SAR are necessary for a signed multiply operation and hence can be ignored. The SAR register 116 is loaded with a shift amount to control shifter 134 and 135 of FIG. 4. Multiply Unit - FIG. 4 In FIG. 4, selector 126 is provided for selecting the recoded copies of the operand from the AR register 110 and the BR register 111 from FIG. 3 under the control of the recode unit 140. The recoded copies of the operands are input to a carry-save adder tree 127. Outputs from the carry-save adder tree 127 are stored in a 64-bit SR register 128 and a 64-bit CR register 129. The output of the SR register 128 forms one input to a carry propagate adder (CPA) 130. The output from the CR register 129 provides a second input to the carry propagate adder 130. A shifter 134 shifts the contents of the result register 132/133 to form a third input to the carry propagate adder 130. In FIG. 4, the registers 128, 129, and 141, the recoder 140, the selector 126 and the CSA tree 127 constitute the multiplier 5 of FIG. 1. The multiplier works together with the 3-port adder and the other hardware shown in FIG. 4 to perform multiplications. The quotient register 136/137 is loaded by a quotient shifter 135. The quotient shifter shifts inputs from the AR register 110 and the BR register 111 of FIG. 3, or from the quotient register 136/137. Hardware also exists in FIG. 4 to perform functions not related to multiplication. Various other control and data are indicated in connection with the FIG. 3 and FIG. 4 apparatus. Registers are represented by boxes with heavy bars at the top and such registers are clocked at the end of each machine cycle by a clock signal. Description of the Unsigned Multiplication Process The basic hardware in FIGS. 3 and 4 includes a 56 x 8 bit multiplier 5, a 64-bit 3-port adder 130, a pair of registers (AR 110 and BR 111) to hold the multiplicand, a pair of registers (SR 128 and CR 129) to hold the output of the multiplier, a RR register (RRH 132 and RRL 133) to hold the partial product and the final result, and a QR register (QRH 136 and QRL 137) to hold the multiplier operand and the low-order part of a product that is longer than 64 bits. RR and QR also hold the adjustment terms if the operands are negative numbers. The multiplier hardware uses the entire multiplicand (56 bits) along with the low-order 8 bits of the multiplier operand to form a 64-bit partial sum and a 64-bit partial carry which when added together form a partial product. While this operation is going on, QR is shifted 8 bits to the right so that the next 8 bits of the multiplier operand will be available for the next multiplication. While the second multiplication is taking place, the partial sum and partial carry from the first multiplication are added together to form the first partial product. While the third multiplication is taking place, the partial product of the first multiplication is shifted to the right by 8 bits with the least significant 8 bits being shifted into QR and the remaining 56 bits being added together with the partial sum and partial carry of the second multiplication. This process continues until the partial sum and partial carry of the final multiplication are added together with the partial product of the previous multiplications. In TABLE 1, a 56 x 56 unsigned multiplication is described. In TABLE 1 and TABLE 2, the symbol "-:" has the same meaning as the symbol "->" in TABLE 3 and they mean that the operand location on the right receives the data from the operand location on the left. Mathematics of Signed 32 x 32 Multiplication Multiplication of signed numbers with negative numbers in 2's complement form consists of unsigned multiplication to form a preliminary product followed by an adjustment to form the final product. There are four cases C1, C2, C3 and C4 in which C2, C3 and C4 require adjustment. C1. Multiplicand positive, multiplier positive (No adjustment) C2. Multiplicand positive, multiplier negative C3. Multiplicand negative, multiplier positive C4. Multiplicand negative, multiplier negative In 2's complement notation, the highest-order bit for negative numbers is "1" and that for positive numbers is "0". For a 32-bit number, the positive numbers range from 0 to (2³¹-1). For a 32-bit number, the absolute value of the negative numbers range from 1 to (2³¹). For 32-bit operands, a negative number (-Q), where Q is positive between 1 and 2³¹, is represented by the 2's complement notation [2³² - Q]. If a negative number in 2's complement form, [2³² - Q], is again 2's complemented, the positive value Q = 2³² - [2³² - Q] is obtained. C2. Adjustment for Multiplicand (OP1] Positive And Multiplier (OP2) Negative Let the positive multiplicand equal [A]. Let the negative multiplier equal [2³² -Q] where A and Q are greater than 0. The desired 64-bit final product is -(A)(Q) which in 2's complement notation is [2⁶⁴ - AQ]. The preliminary product obtained from unsigned multiplication of the negative multiplier [2³² - Q] and the positive multiplicand, A, is (2³²) (A) - (A)(Q). The adjustment which must be added to the preliminary product to form the final product is the quantity [2⁶⁴ - (2³²) (A)] or (2³²) [2³² - A]. This adjustment is achieved by adding the 2's complement, [2³² - A], of the 32-bit operand A, in register AR, to the high-order bits 0:31 of the preliminary product in RR. Since [2³² - A] is added to the high-order bits, it is effectively multiplied by 2³² so that the added value is the desired adjustment, (2³² )[2³² - A]. C3. Adjustment for Multiplicand Negative, Multiplier Positive Let the negative multiplicand equal [2³² - A]. Let the positive multiplier equal Q where A and Q are greater than 0. The desired product is [2⁶⁴ - (A)(Q)]. The preliminary product obtained from unsigned multiplication is (2³²)(Q) - (A)(Q). The adjustment which must be added to the preliminary product to form the final product is the quantity [2⁶⁴ - (2³²) (Q)] or (2³²) [2³² - Q]. This adjustment is achieved by loading the 2's complement, [2³² - Q], of Q into the low-order bits of register RR (32:63) at the start of the multiplication. At the same time, zero is loaded into the high-order bits of QR (0:31). As the multiplication proceeds, the 2's complement of Q, [2³² - Q], shifts right until it ends up in the high-order bits of QR (0:31) thereby multiplying [2³² - Q] by 2³² and forming the adjustment [2⁶⁴ - (2³²)Q] in register QR. At this time, zero is in the low-order bits QR (32:63). The adjustment is completed by adding the adjustment in QR to the preliminary product in RR. C4. Adjustment for Multiplicand Negative, Multiplier Negative Let the negative multiplicand equal [2³² - A]. Let the negative multiplier equal [2³² - Q] where A and Q are greater than 0. The desired product is (A)(Q). The product obtained from unsigned multiplication is [2³² - A] [2³² - Q] or [2⁶⁴ - (2³²) (A)] - (2³²) (Q) + (AQ) The adjustment which must be added to the preliminary product to form the final product is the quantity (2³² )(A) + (2³²)(Q). This adjustment is achieved by loading the 2's complement of [(2³² -Q)], the multiplier, into RR (32:63) at the start of the multiplication. At the same time, zero is loaded into QR (0:31), and multiplicand [2³² -A] is loaded into AR. As the multiplication proceeds, Q shifts right until it ends up in QR (0:31) thereby forming (2³²)(Q). At this time, zero is in QR (32:63] and [2³² -A] is still in AR. The adjustment is completed by adding QR to RR and by subtracting [2³² - A) in AR from RR (0:31]. The subtraction is implemented by gating the 1's complement of [2³²-A] in AR into the adder and adding +1 to form the 2's complement, +A. The 2's complement, +A, is added to the high-order bits RR (0:31] and hence is effectively (2³²](A). This adjustment is done in one step with the three-port adder. The apparatus of FIGS. 3 and 4 is typically used to perform a high-speed multiply. In a fixed-point multiplication, the product of the multiplier (the second operand) and the multiplicand (the first operand) is found and replaces the original multiplicand. The multiplicand and the multiplier typically are x-bit operands and the product is a 2x-bit operand. The final product is formed in each case by adding one or two adjustment factors to an unsigned preliminary product. The adjustment for each negative operand is equal to 2 X times the other operand. A 32 x 32 fixed-point multiply operation is carried out in accordance with the microprogram summarized in the following TABLE 2. A detailed microprogram for implementing the TABLE 2 summary is set forth in the following TABLE 3.

Claims: An apparatus for multiplying a first operand having a sign by a second operand having a sign, in 2's complement form, to provide a final product, comprising: a first register (110, 111 ) for storing the first and second operands; a second register (136, 137) for storing the second operand; means (I), coupled to the first register, for generating complements of said operands; means (127), coupled to the first register and the second register to receive the first operand and an increment of the second operand, for multiplying the first operand by the increment of the second operand to generate a partial sum output and a partial carry output; third register means (128, 129), coupled to the means for multiplying (127), for storing the partial sum output and the partial carry output; a result register (132, 133); three port adder means (130) having a first port, a second port and a third port, for adding data received at the first, second and third ports to generate a resulting sum and supplying the resulting sum to the result register (132, 133), the first port, second port and third port connected to receive in any given machine cycle up to three of the following data: the partial sum output from the third register (128), the partial carry output of the third register (129), the first operand, the complement of the first operand, the second operand, the complement of the second operand, the contents of the result register (132, 133) or zero; control means (4), coupled to the means for multiplying (127) and the three port adder means (130), for controlling the means for multiplying (127) and the three port adder means (130) to successively generate partial sum and carry outputs and to add the partial sum and carry outputs to the contents of the result register (132, 133) to generate preliminary products in said result register, to which preliminary products adjustments may be added to form partial products in said result register, until a final partial product is generated; and adjustment means, responsive to the sign of the first operand and of the second operand for generating an adjustment while multiplication is in progress, said adjustment being determined by a first condition (C2) in which the first operand is positive and the second operand is negative, a second condition (C3) in which the first operand is negative and the second operand is positive, and a third condition (C4) in which both the first and second operands are negative, said adjustment being added to a said preliminary product in the result register (132, 133) to form a said partial product; wherein said adjustment means includes, means, responsive to the first condition (C2), for controlling the adder means (130) to add the complement of the first operand to the high order bits of said preliminary product, means, responsive to the second condition (C3), for controlling the adder means (130) to add a multiple of the complement of the second operand to said preliminary product, and means, responsive to the third condition (C4), for controlling the adder means (130) to add a multiple of the complement of the second operand to said preliminary product and to add the complement of the first operand to the high order bits of said preliminary product. An apparatus according to claim 1, wherein the adjustment means generates the adjustment in a single cycle.

Inventors: LEE, HSIAO-PENG SHERMAN, ONETO, JOHN CLARENCE, RAWLINSON, STEPHEN JOHN
Applicants: AMDAHL CORPORATION
Application year: 1984
Main classification: G06F7
IPC codes: G06F7