Patent Publication Number: US-5835393-A

Title: Integrated pre-adder for a multiplier

Description:
BACKGROUND OF THE INVENTION 
     1. Field of the Invention 
     The present invention relates to an integrated pre-adder for a multiplier device. 
     2. Description of the Prior Art 
     In Digital Signal Processing (DSP) applications, there are many uses for an unit that would produce the result x=(a+b)*c+d, called here a pre-add multiplication accumulation unit (PMAC). In digital signal processors, the operation x=a*b+c is usually supported, and is called a multiply accumulate (MAC). Many applications are known for a PMAC, but there has been no efficient implementation. 
     In order to appreciate how useful a PMAC would be, consider the following examples. Linear phase FIR (fine impulse response) filters are important in signal processing. As an example an 8th order filter would take the form: 
     
         y.sub.n =a0*x.sub.n +a1*x.sub.n-1 +a2*x.sub.n-2 +a3*x.sub.n-3 +a3*x.sub.n-4 +a2*x.sub.n-5 +a1*x.sub.n-6 +a0*x.sub.n-7 
    
     This would require 8 MAC operations, but could be done in 4 PMAC operations, as follows: 
     
         y.sub.n =a0*(x.sub.n +x.sub.n-7)+a1*(x.sub.n-1 +x.sub.n-6)+a2*(x.sub.n-2 +x.sub.n-5)+a3*(x.sub.n-3 +x.sub.n-4) 
    
     This halving of cycles would yield important performance advantages and power savings, as for example in a DSP based hearing aid. 
     A complex multiplication is an important ingredient to many signal processing applications. Two numbers, a+bi and c+di, form the product 
     
         (a+bi)*(c+di)=(ac-bd)+(ad+bc)i 
    
     This requires four MAC operations. 
     With a PMAC, the following formulation can be used. 
     
         (a+bi)*(c+di)=(p1+p2)+(p1+p3)i 
    
     where 
     p1=(a+b)*c=ac+bc 
     p2=(c+d)*-b=-bc-bd 
     p3=(d-c)*a=ad-ac 
     Thus, 3 PMAC operations could be used, resulting in a 4/3 speed increase ratio, or approximately a 25% reduction in power used. 
     A third example is the all-pass filter. These filters have been shown to be a very effective implementation of other types of filters (see, for example, &#34;Multirate Systems and Filter Banks,&#34; by P. P. Vaidyanathan, PTR Prentice-Hall 1993). An example is the formula for a second order all pass section: 
     
         y.sub.n =a0*(x.sub.n -y.sub.n-2)+a1*(x.sub.n-1 -y.sub.n-1)+x.sub.n-2 
    
     This evaluation requires 4 MAC operations, but only 2 PMAC operations. 
     The problem with the pre-adder is that, with a straight forward implementation, the delay caused by the adder before the multiplier will significantly increase the delay of the entire system, negating much of the advantage of the gains in computation by requiring the system to run slower. In a low power system, connecting the output of an adder to the input of a multiplier will increase power dissipation, as there will be more transitions due to the changes in carries. This again will negate the potential power savings. 
     The simplest conventional multiplier structure is call an array multiplier (See Principles of CMOS VLSI Design, by Weste et al., Addison-Wesley 1993, page 545). As an example, to multiply the 6 bit numbers 010011 (19 base 10) and 011100 (28 base 10), the following partial products would be added: 
     
         ______________________________________                                    
           010011                                                         
                 (multiplicand)                                           
           011100                                                         
                 (multiplier)                                             
           000000                                                         
                 (partial products)                                       
           000000                                                         
          010011                                                          
          010011                                                          
         010011                                                           
         000000                                                           
        001000010100                                                      
                 (product)                                                
        (532 base 10)                                                     
______________________________________                                    
 
    
     This required 6*6 cells, each with an AND gate (the one bit binary multiplier), and an adder. Often a modification to this scheme is used, where two rows of the partial products are handled together. 
     This requires selecting 0, 1, 2 or 3 times the multiplicand with every 2 bits of the multiplier. These partial factors are generated as follows. The bits of the multiplier are grouped into sets of two bits, starting from the left. Each set of two bits thus has a value of 0, 1, 2, or 3 (base 10). These values are essentially a code, allowing half as many partial products to ultimately be combined. The code is as follows: 
     Code=0 result is 0 
     Code=1 result is multiplicand 
     Code=2 result is multiplicand shifted left one bit( times 2) 
     Code=3 result is multiplicand, plus multiplicand shifted left one bit 
     For the above example of 19*28, 
     
         ______________________________________                                    
   010011   (multiplicand)                                                
  01 11 00  (multiplier)                                                  
   1 3 0    (code, from sets of two bits of multiplier)                   
            (combined partial products)                                   
   0000000  (multiplicand times 0)                                        
  0111001   (multiplicand times 3)                                        
 0010011    (multiplicand times 1)                                        
001000010100                                                              
            (product)                                                     
(532 base 10)                                                             
______________________________________                                    
 
    
     The code=0, 1, or 2 cases can all be handled with a simple multiplexer, in only a few gates. The code=3 case requires additional complex logic, (another complete adder) and therefore this approach is rarely used. 
     Instead, an approach called Booth Coding is used. The use of Booth coding is prevalent in multiplier design for digital circuits. The logic for the encoder is as follows, where xn+1 and xn are a set of two bits of the multiplier: 
     
         ______________________________________                                    
x.sub.n+1                                                                 
     x.sub.n cin   code   cout                                            
______________________________________                                    
0    0       0     0      0    (0 replaced with 0 * 4 + 0)                
0    1       0     1      0    (1 replaced with 0 * 4 + 1)                
1    0       0     -2     1    (2 replaced with 1 * 4 - 2)                
1    1       0     -1     1    (3 replaced with 1 * 4 - 1)                
0    0       1     1      0    (1 replaced with 0 * 4 + 1)                
0    1       1     2      0    (2 replaced with 0 * 4 + 2)                
1    0       1     -1     1    (3 replaced with 1 * 4 - 1)                
1    1       1     0      1    (4 replaced with 1 * 4 + 0)                
______________________________________                                    
 
    
     cout (carry out) is an output from every 2 bit stage which is connected to the cin (carry in) of the next most significant stage. Therefore carry in has a bit weight of 1, and carry out has a bit weight of 4. 
     The carry in of the least significant Booth encoding stage is useful for negation. &#34;-a*b&#34; can be produced by complementing all bits on the input to the Booth encoder, and setting the carry in of the least significant stage to a 1. 
     In base two, two&#39;s complement arithmetic, the negative of a number is generated by complementing the number, and adding one. This complementing must be done with enough bits to extend the number far enough left to fill the entire desired result. As it is the sign bit of the operation that is used to fill the extra bits, this operation is referred to as &#34;sign extend&#34;. 
     It is easy to generate codes of -1 and -2, and Booth coding takes advantage of this fact. Five codes are used: 
     code=-2 result is multiplicand shifted left, complemented, a carry in added 
     code=-1 result is multiplicand complemented, and a carry in added 
     code=0 result is 0 
     code=1 result is multiplicand 
     code=2 result is multiplicand shifted left one bit 
     In the case shown above, instead of 1, 3, 0 being the code factors, 2, -1, 0 are used. It is easy to see that the results are the same. 
     
         ______________________________________                                    
   010011    (multiplicand)                                               
  01 11 00   (multiplier)                                                 
   2 -1 0    (Booth coding of multiplier)                                 
000000000000 (multiplicand times 0)                                       
      0      (carry in for positive)                                      
1111101100   (multiplicand times 1 complemented)                          
     1       (carry in for negative)                                      
00100110     (multiplicand times 2)                                       
    0        (carry in for positive)                                      
001000010100 (product)                                                    
(532 base 10)                                                             
______________________________________                                    
 
    
     In order to create a PMAC using a booth encoder in a straight forward manner, to produce &#34;x=(a+b)*c+d&#34;, &#34;a&#34; and &#34;b&#34; would need to be added prior to Booth encoding the result &#34;(a+b)&#34; and multiplying it by &#34;c.&#34; The delay caused by implementing an adder prior to the Booth encoding and multiplying step slows down the system so much, it negates the power gains of reducing steps. 
     A need remains in the art for an integrated pre-adder with a Booth encoder. 
     SUMMARY OF THE INVENTION 
     An object of the present invention is to provide an integrated pre-adder and Booth encoder. 
     An integrated adder and Booth encoder stage combines n bits of a binary number x, n bits of a binary number y, a first carry in signal, and a second carry in signal to generate the Booth code of the sum of the n bits of x, the n bits of y, and the first and second carry in signals. The stage includes a first carry generation block for receiving the n bits of x and the n bits of y, and operating to generate a first set of intermediate signals and a first carry out signal based upon the n bits of x and the n bits of y, a second carry generation block for receiving the first set of intermediate signals and the first carry in signal, and operating to generate a second set of intermediate signals and a second carry out signal based upon the first set of intermediate signals and the first carry in signal, and an output code generation block for receiving the second set of intermediate signals and the second carry in signal, and operating to generate a Booth code based upon the second set of intermediate signals and the second carry in signal. 
     An integrated adder and booth encoder for combining n+m bits of a binary number x, n+m bits of a binary number y, a first carry in signal, and a second carry in signal to generate Booth codes based on the n+m bits of x, the n+m bits of y, and the first and second carry in signals, includes a lower significant stage and a higher significant stage. 
     The lower significant stage includes a lower significant first carry generation block, a lower significant second carry generation block, and a lower significant output code generation block. The higher significant stage includes a higher significant first carry generation block, a higher significant second carry generation block for receiving the higher significant first set of intermediate signals and the lower significant first carry out signal, and operating to generate a higher significant second set of intermediate signals and a higher significant second carry out signal, and a higher significant output code generation block for receiving the higher significant second set of intermediate signals and the lower significant second carry out signal, and operating to generate a higher significant Booth code. 
     As an example, apparatus for receiving input binary numbers x, y, and z and generating the quantity (x+y)*z comprises the integrated adder and booth encoder above, and a Booth multiplier connected to the integrated adder and booth encoder, for receiving z and the Booth code of x+y from the integrated adder and booth encoder, and Booth multiplying z with the Booth code of x+y. 
     Similarly, apparatus for receiving input binary numbers x, y, z, and xx and generating the quantity (x+y)*z+zz comprises the integrated adder and booth encoder above for receiving x and y and generating the Booth code of x+y, a Booth multiplier connected to the integrated adder and booth encoder, for receiving z and the Booth code of x+y from the integrated adder and booth encoder, and Booth multiplying z with the Booth code of x+y to produce (x+y)*z, and an adder connected to the Booth multiplier, for receiving zz and the quantity (x+y)*z from the Booth encoder, and adding zz to the quantity (x+y)*z to produce the quantity (x+y)*z+zz. 
     A digital signal processor of the type including a Central Processing Unit (CPU), random access memory connected to the CPU, and read only memory connected to the CPU, is improved by adding a Pre-Add Multiplication Accumulation unit (PMAC) connected to the CPU The PMAC includes the integrated adder and booth encoder above for receiving x and y, and generating the Booth code of x+y, a Booth multiplier connected to the integrated adder and booth encoder, for receiving z and the Booth code of x+y from the integrated adder and Booth encoder, and Booth multiplying z with the Booth code of x+y to produce (x+y)*z, and an adder connected to the Booth multiplier, for receiving zz and the quantity (x+y)*z from the Booth encoder, and adding zz to the quantity (x+y)*z to produce the quantity (x+y)*z+zz. 
     A hearing aid of the type including an audio receiver to receive ambient sound, an analog to digital (A/D) converter to convert the sound to a high resolution, low rate digital signal, digital processing circuitry to modify the quality of the high resolution, low rate digital signal, interpolator circuitry for converting the high resolution, medium rate digital signal to a medium rate, high resolution signal, a digital to analog (D/A) converter for converting the modified high resolution, medium rate digital signal back into analog sound, has improved digital processing circuitry comprising a Central Processing Unit (CPU), random access memory connected to the CPU, read only memory connected to the CPU, and a Pre-Add Multiplication Accumulation unit (PMAC), as described above, connected to the CPU. 
     One integrated adder and Booth encoder stage for combining a more significant bit xn+1 and a less significant bit xn of a binary number x with a more significant bit yn+1 and a less significant bit yn of a binary number y and with a first carry in signal and a second carry in signal to generate the Booth code for bit positions n and n+1, comprises a first carry generation block for receiving xn, yn, xn+1 and yn+1, and operating to generate a first carry out signal and a first set of intermediate signals, a second carry generation block for receiving the first set of intermediate signals and the first carry in signal, and operating to generate a second carry out signal and a second set of intermediate signals, and an output code generation block for receiving the second set of intermediate signals and the second carry in signal, and operating to generate a Booth code based upon the second set of intermediate signals and the second carry in signal. 
     This integrated adder and Booth encoder stage may also have the first carry generation block including means for providing yn+1 as the first carry out and means for providing yn+1, xn+1 inverted, yn, and xn as the first set of intermediate signals, and the second carry generator including a least significant adder for adding xn, yn, and the first carry in; and providing sum and carry inverted outputs, and a most significant adder for adding yn+1, xn+1 inverted, and the carry from the least significant adder and providing sum and carry inverted outputs, and the carry inverted output of the most significant adder is the second carry out, and the sum outputs from the most significant adder and the least significant adder are the second set of intermediate signals. 
     Alternatively, this integrated adder and Booth encoder stage might have the first carry generation block including means for providing xn+1 AND yn+1 as the first carry out and means for providing yn+1, xn+1, yn, and xn as the first set of intermediate signals, and the second carry generator including an adder for adding xn, yn, and the first carry in; and providing sum and carry outputs, and a first XOR gate connected to the first carry generation block for providing the logical XOR of xn+1 and yn+1, a second XNOR gate connected to the first XOR gate and the adder for providing the logical XOR of the output of the first XOR gate and the carry output of the adder, and an OR gate connected to the first XOR gate and the adder for providing the logical OR of the output of the first XOR gate and the carry output of the adder, and the output of the OR gate is the second carry out, and the sum output from the adder and output of the second XOR are the second set of intermediate signals. 
     Alternatively, this integrated adder and Booth encoder stage might have the first carry generation block including means for providing xn+1 OR yn+1 as the first carry out and means for providing yn+1, xn+1, yn, and xn as the first set of intermediate signals, and the second carry generator including an adder for adding xn, yn, and the first carry in; and providing sum and carry outputs, and a first XNOR gate connected to the first carry generation block for providing the logical XNOR of xn+1 and yn+1, a second XNOR gate connected to the first XNOR gate and the adder for providing the logical XNOR of the output of the first XNOR gate and the carry output of the adder, and an AND gate connected to the first XNOR gate and the adder for providing the logical AND of the output of the first XNOR gate and the carry output of the adder, and wherein the output of the AND gate is the second carry out, and the sum output from the adder and the output of the second XNOR are the second set of intermediate signals. 
     A multiple stage adder and booth encoder for adding a multiple bit number x and a multiple bit number y comprises a plurality of any of the stages described above, and is structured so that a first of the stages, designated the lowest significant stage receives x0, x1, y0, y1, the first carry in and the second carry in, this lowest significant stage operating to generate a lowest significant Booth code, and a second of the stages, designated the second lowest significant stage receives x2, x3, y2, y3, the lowest significant first carry out and the lowest significant second carry out, this second lowest significant stage operating to generate a lowest significant Booth code, and each succeeding stage receives the next two lowest significant bits available of x and y and the first and second carry out from the previous stage, and operates to generate a Booth code based on the next two bits of x and y and the first and second carry outs from the previous stage, and to generate a first carry out and a second carry. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIG. 1 (prior art) shows a block diagram of a PMAC which provides an adder prior to a Booth encoder. 
     FIG. 2 s a block diagram of a PMAC according to the present invention which integrates an adder with a Booth encoder. 
     FIG. 3 (prior art) shows a circuit diagram of a conventional full adder, with a true sum output and a complemented carry output. 
     FIG. 4A shows a block diagram of a single stage of a combined adder and Booth encoder according to the present invention. 
     FIG. 4B shows a circuit diagram of the first preferred embodiment of a single stage of the combined adder and Booth encoder of FIG. 4A. 
     FIG. 4C shows the relationship between 4A and 4B. 
     FIG. 5 shows a six bit combined adder and Booth encoder in accordance with the present invention. 
     FIG. 6 shows a six-bit adder/Booth encoder/Booth multiplier using conventional blocks. 
     FIG. 7 shows a six-bit combined adder/Booth encoder/Booth multiplier in accordance with the present invention. 
     FIG. 8A shows a circuit diagram of the second preferred embodiment of a single stage of the combined adder and Booth encoder of FIG. 4A. 
     FIG. 8B is a block diagram representation of FIG. 8A. 
     FIG. 9A shows a circuit diagram of the third preferred embodiment of a single stage of the combined adder and Booth encoder of FIG. 4A. 
     FIG. 9B is a block diagram representation of FIG. 9A. 
     FIG. 10 shows a chip-based digital signal processor including the PMAC of FIG. 2. 
     FIG. 11 shows a hearing aid including the digital signal processor of FIG. 10. 
    
    
     DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENT 
     FIG. 1 (prior art) shows a block diagram of a pre-add multiplication accumulation unit (PMAC) 100 which provides an adder 102 prior to a Booth encoder 104, in a conventional manner. Recall that a PMAC returns the result x=(a+b)*c+d. PMAC 100 operates as follows. If &#34;a&#34; and &#34;b&#34; are input into adder 102, &#34;a+b&#34; is the output. Booth encoder 104 Booth encodes &#34;a+b&#34;, and Booth multiplier 106 Booth multiplies the Booth code for &#34;a+b&#34; together with input &#34;c&#34;, resulting in &#34;(a+b)*c&#34;. Finally, adder 108 adds input &#34;d&#34;, producing the final result of (a+b)*c+d. 
     FIG. 2 shows a block diagram of a PMAC 200, according to the present invention which provides an integrated adder and Booth encoder 202. Identical reference numbers indicate identical functions. Integrated adder and Booth encoder 202 provides the Booth code for the sum of &#34;a+b&#34; to Booth multiplier 106, which Booth multiplies the Booth code with input c, producing &#34;(a+b)*c&#34;. Adder 108 adds input &#34;d&#34;, resulting in the final result of (a+b)*c+d. Three preferred embodiments of integrated adder and Booth encoder 202 are shown in FIGS. 4, 8 and 9. 
     FIG. 3 (prior art) shows a circuit diagram of a conventional full adder 302. An understanding of this device is helpful in understanding the structure and operation of combined adder and Booth encoder 202 of FIG. 2, shown in more detail in FIG. 4B. Adder 302 may be replaced with a variety of other adders, but must be composed of purely combinatorial elements. Adder 302 has three inputs 314, 315, and 316, and outputs a sum bit s, 312 and a complemented carry bit c bar, 310. This carry out is the complement of the carry out of a standard full adder. As shown in FIG. 3, the sum bit 312 is one only when an odd number of the inputs are one, since it the output of a three input exclusive or (XOR) gate 308. The carry not (or carry bar, in typical notation) bit is one only if either none or only one of the inputs is 1, since if the outputs of any of the AND gates 304 is one, then the output of the NOR gate 310 is zero. Thus, the truth table of full adder 302 is as follows (where carry c is shown for convenience): 
     
         ______________________________________                                    
inputs     c             s     c                                          
______________________________________                                    
0 0 0      1             0     0                                          
0 0 1      1             1     0                                          
0 1 0      1             1     0                                          
0 1 1      0             0     1                                          
1 0 0      1             1     0                                          
1 0 1      0             0     1                                          
1 1 0      0             0     1                                          
1 1 1      0             1     1                                          
______________________________________                                    
 
    
     FIG. 4A shows a block diagram of a single stage 450 of a combined adder and Booth encoder 202 according to the present invention. Stage 450 comprises three blocks, a first carry generation block 452, a second carry generation block 454, and an output code generation block 456. x input bits 462 and y input bits 472 are multiple bits (generally two bits) of numbers x and y which are input into first carry block 452. Block 452 generates first carry out c0out 463 and multibit signal 482, which generally comprises x inputs 462 and y inputs 472 carried straight through, or only slightly modified. 
     Multibit signal 482 and first carry in signal c0in 476 are inputs to second carry generation block 454. Generally, c0in 476 is the c0out signal 463 of another stage 450 which is adding less significant bits than the present stage. If the present stage 450 is adding the least significant bits, c0in 463 might represent a sign bit or other information. Block 454 generates second carry out bit c1out 468 and multibit signal 478. Multibit signal 478 generally comprises bits of x input 462 added, or otherwise combined with bits of y input 472. 
     Multibit signal 478 and second carry in signal c1in 480 are inputs to code generation block 456. Generally, c1in 480 is the c1out signal 468 of another stage 450 which is adding less significant bits. If the present stage 450 is adding the least significant bits, c1in 480 might represent sign bits or other information. Block 456 generates the Booth code 490 of multibit signal 478, or x input 462 added to y input 472, accounting for carry ins 476 and 480. Block 456, like all of stage 450, comprises unclocked, combinatorial logic, and x input bits 462 and y input bits 472 are input all at once in parallel. 
     The most important feature of stage 450 is that the first carry, c0out 463, is only dependent upon x input 462 and y input 472. It is not dependent upon c0in 476 or c1in 480. Similarly, c1out 468 is only dependent upon x input 462, y input 472, and c0in 476. It is not dependent upon c1in. This is important because it means that the worst case delay of combined adder/Booth encoder 202 is small, and does not depend upon the number of stages 450. This will be seen more clearly by considering multistage adder/Booth encoder 500, shown in FIG. 5. 
     FIG. 4B shows a circuit diagram 400 of the first preferred embodiment of one stage 450 of combined adder and Booth encoder 202. Other preferred embodiments are shown in FIGS. 8 and 9. 
     The function table of adder/Booth encoder stage 400 is shown below. Binary numbers x and y are to be Booth encoded and added by adder/encoder 202, of which circuit 400 is a stage handling two bits each of x and y. Thus, stage 400 is a special case of stage 450 of FIG. 4A. xn 414 and yn 412 are the least significant bits of the two bits handled by this stage. xn+1 404 and yn+1 402 are the most significant bits. c0in 416 and c1in 420 are carry in inputs as shown in FIG. 4A. FIG. 4C further illustrates the relationship between FIG. 4A and FIG. 4B. 
     For every two bits of x and y, the following function tables define the code which is generated. The signal t0 is used to explain the connection of the first table to the second table; otherwise a very large (64 line) table must be used to describe the logical operation. Such a signal as t0 may, or may not, be created in the actual circuit implementation: 
     
         ______________________________________                                    
404        402    416              402                                    
x.sub.n+1  y.sub.n+1                                                      
                  c0in         t0  c0out                                  
______________________________________                                    
0          0      0            0   0                                      
1          0      0            2   0                                      
0          1      0            -2  1                                      
1          1      0            0   1                                      
0          0      1            1   0                                      
1          0      1            3   0                                      
0          1      1            -1  1                                      
1          1      1            1   1                                      
______________________________________                                    
            420                 408                                       
t0 + x.sub.n + y.sub.n                                                    
            c1in         code   c1out                                     
______________________________________                                    
-2          0            -2     0                                         
-1          0            -1     0                                         
0           0            0      0                                         
1           0            1      0                                         
2           0            -2     1                                         
3           0            -1     1                                         
4           0            0      1                                         
5           0            1      1                                         
-2          1            -1     0                                         
-1          1            0      0                                         
0           1            1      0                                         
1           1            2      0                                         
2           1            -1     1                                         
3           1            0      1                                         
4           1            1      1                                         
5           1            2      1                                         
______________________________________                                    
 
    
     As an example, if x n+1  =0, x n  =1, y n+1  =1, y n  =0, c0in=0, c1in=0, we would find t0=-2 from the first table, t0+x n  +y n  =-1, and the code is -1 from the second table. 
     FIG. 4B shows the preferred embodiment of circuitry to implement this logic function. The two sum outputs of the full adders, 410 (from high order adder 302a) and 418 (from low order adder 302b) encode the following value. The value allows a numeric description of the logical operation: ##EQU1## The value created can be mathematically described as: 
     
         value=-2*(410)+1*(418) 
    
     By the logic function described, the following equations are satisfied: ##EQU2## This last equation is the one that guarantees that the proper code is generated, and shows the equivalence of the values generated by this encoder to the select sum of x and y. 
     The function of the inverters and the two full adders can be enumerated as follows: 
     (406 is the carry not out of adder 302b feeding adder 302a) 
     
         __________________________________________________________________________
404 402 414                                                               
           412 416    410                                                 
                         418 402                                          
                                408                                       
xn + 1                                                                    
    yn + 1                                                                
        xn yn  c0in                                                       
                  406 s1 s2  c0out                                        
                                c1out                                     
                                    total                                 
__________________________________________________________________________
0   0   0  0   0  1   0  0   0  0   0                                     
0   0   0  0   1  1   0  1   0  0   1                                     
0   0   0  1   0  1   0  1   0  0   1                                     
0   0   0  1   1  0   1  0   0  1   2                                     
0   0   1  0   0  1   0  1   0  0   1                                     
0   0   1  0   1  0   1  0   0  1   2                                     
0   0   1  1   0  0   1  0   0  1   2                                     
0   0   1  1   1  0   1  1   0  1   3                                     
0   1   0  0   0  1   1  0   1  0   2                                     
0   1   0  0   1  1   1  1   1  0   3                                     
0   1   0  1   0  1   1  1   1  0   3                                     
0   1   0  1   1  0   0  0   1  0   4                                     
0   1   1  0   0  1   1  1   1  0   3                                     
0   1   1  0   1  0   0  0   1  0   4                                     
0   1   1  1   0  0   0  0   1  0   4                                     
0   1   1  1   1  0   0  1   1  0   5                                     
1   0   0  0   0  1   1  0   0  1   2                                     
1   0   0  0   1  1   1  1   0  1   3                                     
1   0   0  1   0  1   1  1   0  1   3                                     
1   0   0  1   1  0   0  0   0  1   4                                     
1   0   1  0   0  1   1  1   0  1   3                                     
1   0   1  0   1  0   0  0   0  1   4                                     
1   0   1  1   0  0   0  0   0  1   4                                     
1   0   1  1   1  0   0  1   0  1   5                                     
1   1   0  0   0  1   0  0   1  0   4                                     
1   1   0  0   1  1   0  1   1  0   5                                     
1   1   0  1   0  1   0  1   1  0   5                                     
1   1   0  1   1  0   1  0   1  1   6                                     
1   1   1  0   0  1   0  1   1  0   5                                     
1   1   1  0   1  0   1  0   1  1   6                                     
1   1   1  1   0  0   1  0   1  1   6                                     
1   1   1  1   1  0   1  1   1  1   7                                     
__________________________________________________________________________
 
    
     total is the value from above equation (3), which is a sum of the equivalent input values. 
     The output and/or stage, comprising ANDs 422-429 with selected inputs inverted as shown and ORs 432, 434 and 436, implements the following functions: 
     
         __________________________________________________________________________
(inputs)  (outputs)                                                       
      420 438                                                             
             440 442                                                      
                    444 446                                               
410                                                                       
   418                                                                    
      c1in                                                                
          -2 -1  0  1   2  (value)                                        
                                (value + c1in)                            
__________________________________________________________________________
1  0  0   1  0   0  0   0  -2   -2                                        
1  0  1   0  1   0  0   0  -2   -1                                        
1  1  0   0  1   0  0   0  -1   -1                                        
1  1  1   0  0   1  0   0  -1   0                                         
0  0  0   0  0   1  0   0  0    0                                         
0  0  1   0  0   0  1   0  0    1                                         
0  1  0   0  0   0  1   0  1    1                                         
0  1  1   0  0   0  0   1  1    2                                         
__________________________________________________________________________
 
    
     It can be seen that value+c1in matches the coding of the output. 
     Depending upon the design of the multiplier structure of block 106, other output codes may be more desirable, such as a +/- flag and a 0, 1, 2 indicator. This can easily be accomplished by re-arrangement of the and/or stage, as one familiar with logic will see. 
     It is often necessary to form negative products, or use a difference instead of an add. This proposed structure easily allows for the negation of input terms, as there are two carry inputs to the least significant stage. (a+b)*c, (a-b)*c, (-a+b)*c, and (-a-b)*c can be all created by appropriately complementing the a and b inputs, and setting one each of the carry ins to the least significant stage for each of the Booth encoder, for any input which should be treated as a negative. (One of the carry inputs is allocated to use for x negation, the other for y negations) 
     An integrated adder/Booth encoder 202 will be built out of stages like 400, normally one for every two bits, as shown in FIG. 5. It is possible to extend the concept to more than two bits, but because of the complexity of the multiplier array created, this is not normally a good tradeoff. The construction of each of the two bit stages may be as shown in FIG. 4B, FIG. 8A, or FIG. 9A, or many other variations. The key concept to this invention is that each two bit stage is connected to the next greater significant stage with two carry signals, and that each of the carry outputs is not dependent on the corresponding carry input. This condition insures that carry propagation does not occur, and that the input adder will not significantly increase delay or power dissipation. 
     FIG. 4C shows the relationship between the block diagram of FIG. 4A and the circuitry of FIG. 4B. Thus, block 452a merely carries through xn 414 and yn 412, carries through yn+1 402, while also using it as c0out 402, and inverts xn+1 404. Block 454a adds xn 414 to yn 412 and c0in 416 in adder 302b, adds inverted xn+1 404 to yn+1 402 and carry bar 406 from 302b in adder 302a, provides sum1 410 and sum2 418 to block 456, and provides the carry bar signal from adder 302a as c1out 408. Block 456a comprises ANDs 422-429 and ORs 432, 434, and 436 as shown in FIG. 4B, and outputs the Booth code on lines 438, 440, 442, 444, and 446. 
     FIG. 5 shows a preferred embodiment of an integrated adder and Booth encoder 202, for adding and Booth encoding 6 digit binary numbers. It comprises three stages, 400a, 400b, and 400c, of adding and Booth encoding. 400a adds and Booth encodes x0 and x1 with y0 and y1. 400b adds and Booth encodes x2 and x3 with y2 and y3. 400c adds and Booth encodes x4 and x5 with y4 and y5. As shown, the inputs to 400a are x0 414a, x1 404a, y0 412a and y1 402a. c0in 416a and c1in 420a are available to negate the operands, as previously described. 400b has as its inputs x2 414b, x3 404b, y2 412b and y3 402b. c0in 416b is c0out 402a from stage 400a. c1in 420b is c1out 408a from stage 400a. 400c has as its inputs x4 414c, x5 404c, y4 412c and y5 402c. c0in 416c is c0out 402b from stage 400b. c0in 420c is c1out 408b from stage 400b. c0out 402c and c1out 408c are normally not used. 
     There are several ways to build adder/encoder stages equivalent to stages 400; two more are shown in FIGS. 8A and 9A. The implementations differ in how the generation of carries is shared between the two carry outputs. Key to all the designs is that the generation of a carry out is not dependent on the corresponding carry in. It is this fact that allows us to solve the problem of the separate adder I encoder, that of a propagation of a carry signal. To illustrate this concept, compare FIG. 6, showing an adder/Booth encoder/Booth multiplier made up of conventional blocks, with a combined adder and Booth encoder/multiplier as shown in FIG. 7. 
     In FIG. 6, conventional two bit adder 102 comprises adder 602a, which adds binary digits y5, x5, y4, x4 (signals 601a). Similarly, adders 602b and 602c add bits y3, x3, y2, x2 (signals 601b) and y1, x1, y0, x0 (signals 601c) respectively. Note that carry 612, generated by the addition performed by adder 602c, must be passed to adder 602b before 602b can add its digits. Similarly, 602b must complete its addition and generate carry 610 before adder 602a can add its digits. Thus, a delay is produced which increases with each new stage of addition. 
     The results from adders 602a, 602b, and 602c are signals 603a, 603b, and 603c, which are passed on to conventional Booth encoder 104, comprising encoder blocks 604a, 604b, and 604c, respectively. The Booth code of each encoder is indicated to Booth multiplier 106 on lines 608a, 608b and 608c. Booth multiplier 106, Booth multiplies the Booth code for &#34;x+y&#34; by z (input 618) to produce output 620 (&#34;(x+y)*z&#34;). 
     FIG. 7 shows the combination of a Booth adder and encoder 202 comprising three combined adder and Booth encoders 702a, 702b, and 702c, with conventional Booth multiplier 106. Combined adder and Booth encoders 702a, 702b, and 702c could be the combined adder and Booth encoders 400 shown in FIG. 4, or other combined adder and Booth encoders according to the present invention. Combined adder and Booth encoders 702a, 702b, and 702c have as their inputs 701a, 701b, and 701c, comprising y5, x5, y4, x4, and y3, x3, y2, x2, and y1, x1, y0, x0 respectively. Carries 710 and 712 are passed from 702c to 702b, and carries 706 and 708 are passed from 702b to 702a. Note, however, that carry 706 (c0out of block 702b/c0in of block 702a) is not dependent on carry 710 (c0out of block 702c/c0in of block 702b) or 712 (c1out of block 702c/c1in of block 702b). Carry 708 (c1out of block 702b/c1in of block 702a) is dependent only on carry 710. 
     The outputs of combined adder and Booth encoders 702a, 702b, and 702c are Booth codes for the additions indicated by lines 704a, 704b and 704c. Booth multiplier 106 Booth multiplies the Booth code for &#34;x+y&#34; by z (input 718) to produce output 714 (&#34;(x+y)*z&#34;). 
     FIG. 8A shows a second embodiment of a combined adder/Booth encoder stage 800. The function table is as given below. Assume again that we are adding and Booth encoding x and y. For every two bits of x and y, the following coding will be done. In this embodiment, a carry 0 out (c0out 803) will be generated if both of the high order input bits (yn+1 802 and xn+1 804) is one. Adder 862 is similar to adder 302, except that the carry is not inverted. The circuitry comprising XORs 854 and 856 and OR 852 replaces adder 302a. AND 850 has been added to the first carry generation block 452b, as shown in FIG. 8B. Coding block 456B, comprising ANDs 822-827 and ORs 832, 834, and 836 is identical to coding block 456a of FIG. 4B. Again, the signal t0 is a parameter that is used to explain the connection of the first table to the second table: 
     
         ______________________________________                                    
804        802    816              803                                    
x.sub.n+1  y.sub.n+1                                                      
                  c0in         t0  c0out                                  
______________________________________                                    
0          0      0            0   0                                      
1          0      0            2   0                                      
0          1      0            2   1                                      
1          1      0            0   1                                      
0          0      1            1   0                                      
1          0      1            3   0                                      
0          1      1            3   0                                      
1          1      1            1   1                                      
______________________________________                                    
            820                 808                                       
t0 + x.sub.n + y.sub.n                                                    
            c1in         code   c1out                                     
______________________________________                                    
0           0            0      0                                         
1           0            1      0                                         
2           0            -2     1                                         
3           0            -1     1                                         
4           0            0      1                                         
5           0            1      1                                         
0           1            1      0                                         
1           1            2      0                                         
2           1            -1     1                                         
3           1            0      1                                         
4           1            1      1                                         
5           1            2      1                                         
______________________________________                                    
 
    
     Again, in order to form a multiple bit adder/Booth encoder 202, several stages 800 are strung together. The c0out 803 of each stage is connected to the c0in 816 of the next stage, and the c1out 808 is connected to the c1in 820 of the next stage. 
     This effectively integrates the two operations. The carry out signals are not dependent on the corresponding carry in signals. This guarantees that no carry propagation will happen, and that the delay due to the pre adder will be small and independent of the size of the PMAC unit. This property is the key to the invention, in effect, the encoding stage is used to &#34;soak up&#34; and eliminate the carry propagation. 
     FIG. 8B shows the circuitry of FIG. 8A in block diagram form, in the format of FIG. 4A. First carry generation block 452b passes xn 814, yn 812, xn+1 804 and yn+1 802 unchanged to second carry generation block 452b. xn+1 804 and yn+1 802 are ANDed to form c0out 803. 
     Second carry generation block 452b adds xn 814 and yn 812 to form sum2 818 and carry2 806. XORs 856 and 854 combine xn+1 804 and yn+1 802 with carry2 806 from adder 862 to form sum1 810. XOR 856 and OR 852 combine xn+1 804 and yn+1 802 with carry2 806 from adder 862 to form c1out 808. 
     Output code generation block 456b is identical to coding block 456a of FIG. 4C. Coding block 456b combines sum1 810, sum2 818 and c1in 820 and determines the Booth code of sum1 810 and sum2 818, taking into account carry c1in 820. 
     FIG. 9A shows a third embodiment of combined adder and Booth encoder stage, 900. This embodiment generates c0 when either xn+1 or yn+1 is true. 
     
         ______________________________________                                    
904        902    916              903                                    
x.sub.n+1  y.sub.n+1                                                      
                  c0in         t0  c0out                                  
______________________________________                                    
0          0      0            0   0                                      
1          0      0            -2  0                                      
0          1      0            -2  1                                      
1          1      0            0   1                                      
0          0      1            1   0                                      
1          0      1            -1  0                                      
0          1      1            -1  1                                      
1          1      1            1   1                                      
______________________________________                                    
            920                 908                                       
t0 + x.sub.n + y.sub.n                                                    
            c1in         code   c1out                                     
______________________________________                                    
-2          0            -2     0                                         
-1          0            -1     0                                         
0           0            0      0                                         
1           0            1      0                                         
2           0            -2     1                                         
3           0            -1     1                                         
-2          1            -1     0                                         
-1          1            0      0                                         
0           1            1      0                                         
1           1            2      0                                         
2           1            -1     1                                         
3           1            0      1                                         
______________________________________                                    
 
    
     Again, in order to form a multiple bit adder/Booth encoder 202, several stages 900 are strung together. The c0out 903 of each stage is connected to the c0in 916 of the next stage, and the c1out 908 is connected to the c1in 920 of the next stage. 
     FIG. 9B shows the circuitry of FIG. 9A in block diagram form, in the format of FIG. 4A. First carry generation block 452c passes xn 914, yn 912, xn+1 904 and yn+1 902 unchanged to second carry generation block 452b. xn+1 904 and yn+1 902 are ORed to form c0out 903. 
     Second carry generation block 452c adds xn 914 and yn 912 to form sum2 918 and carry2 906. XNORs 957 and 955 combine xn+1 904 and yn+1 902 with carry2 906 from adder 962 to form sum1 910. XNOR 957 and AND 953 combine xn+1 904 and yn+1 902 with carry2 906 from adder 962 to form c1out 908. 
     Output code generation block 456c is identical to coding block 456a of FIG. 4C. Coding block 456c combines sum1 910, sum2 918 and c1in 920 and determines the Booth code of sum1 910 and sum2 918, taking into account carry c1in 920. 
     Many other variations of this circuitry are possible. The key is the concept of the integration of the add/carry and the Booth encoding. It will be obvious to one versed in logic design that many equivalent gate implementations can be used. 
     FIG. 10 shows that a PMAC may be used as the arithmetic unit of a computer, forming digital signal processor 1000. This is especially valuable if the target processor is to be used for Digital Signal Processing (DSP). CPU 1006 communicates with RAM 1002 and ROM 1004 in a conventional manner. PMAC 200 is connected to CPU 1006, and acts as an arithmetic unit. 
     FIG. 11 shows a hearing aid utilizing the digital signal processor of FIG. 10. FIG. 11 shows hearing aid 1100 comprising a microphone 1102, an A/D conversion system 1104, Digital Signal Processor (DSP) 1106, a D/A conversion system 1108, and a speaker 1110. The components of the hearing aid of FIG. 11 are conventional and well understood, except that DSP 1106 has been modified in accordance with the present invention. In the preferred embodiment, DSP 1106 is similar to DSP 1000 of FIG. 10. 
     The attached appendix is a vhdl description of the pre-add circuit and a test program for it. 
     While the exemplary preferred embodiments of the present invention are described herein with particularity, those skilled in the art will appreciate various changes, additions, and applications other than those specifically mentioned, which are within the spirit of this invention. 
     
                       APPENDIX                                                    
______________________________________                                    
Here is a vhdl description of the pre add circuit, and a test program     
for                                                                       
it.                                                                       
pmac.vhd is the circuit, and pmac.sub.-- t the tester                     
library ieee;                                                             
library arithmetic;                                                       
use ieee.std.sub.-- logic.sub.-- 1164.all;                                
use arithmetic.std.sub.-- logic.sub.-- arith.all;                         
entity pmac is                                                            
 generic (N: in Natural := 16); -- Must be even                           
 port (x, y: in std.sub.-- logic.sub.-- vector (N-1 downto 0);            
  Two, One, Sign: out std.sub.-- logic.sub.-- vector (N/2 downto 0));     
end pmac;                                                                 
architecture behavior1 of pmac is                                         
 signal x1, y1: std.sub.-- logic.sub.-- vector(N+1 downto 0);             
begin                                                                     
 x1 &lt;= &#34;00&#34; &amp; x;                                                          
 y1 &lt;= &#34;00&#34; &amp; y;                                                          
add: process(x1 ,y1)                                                      
 variable sel: std.sub.-- logic.sub.-- vector(2 downto 0);                
 variable c0, c1: std.sub.-- logic:=`0`;                                  
 variable s1, t1, t2: std.sub.-- logic:=`0`;                              
begin                                                                     
 c0:=`0`;                                                                 
 c1:=`0`;                                                                 
 L1: for i in 0 to (N/2)loop                                              
- sum in adderx1(i*2) xor y1(i*2);                                        
 t1 := (c0 and x1(i*2)) or (c0 and y1(i*2))                               
- carry1(i*2) and y1(i*2));                                               
 t2 := x1(i*2+1) xor y1(i*2+1);                                           
 c0 := x1(i*2+1) and y1(i*2+1);                                           
 sel(2 downto 0) := t1 &amp; t2 &amp; s1; -- Weight 2, 2, 1;                      
 if c1=`0` then                                                           
 case sel is                                                              
 when &#34;000&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`0`; Sign(i)&lt;=`0`; -- 0              
 when &#34;001&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`1`; Sign(i)&lt;=`0`; -- 1              
 when &#34;010&#34; =&gt; Two(i) &lt;=`1`; One(i)&lt;=`0`; Sign(i)&lt;=`1`; -- 4-2            
 when &#34;011&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`1`; Sign(i)&lt;=`1`; -- 4-1            
 when &#34;100&#34; =&gt; Two(i) &lt;=`1`; One(i)&lt;=`0`; Sign(i)&lt;=`1`; -- 4-2            
 when &#34;101&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`1`; Sign(i)&lt;=`1`; -- 4-1            
 when &#34;110&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`0`; Sign(i)&lt;=`0`; -- 4-0            
 when &#34;111&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`1`; Sign(i)&lt;=`0`; -- 4+1            
 when others =&gt; Two(i) &lt;=`0`; One(i)&lt;=`1`; Sign(i)&lt;=`0`;                  
 end case;                                                                
else                                                                      
 case sel is                                                              
 when &#34;000&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`1`; Sign(i)&lt;=`0`; -- 1              
 when &#34;001&#34; =&gt; Two(i) &lt;=`1`; One(i)&lt;=`0`; Sign(i)&lt;=`0`; -- 2              
 when &#34;010&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`1`; Sign(i)&lt;=`1`; -- 4-1            
 when &#34;011&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`0`; Sign(i)&lt;=`0`; -- 4-0            
 when &#34;100&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`1`; Sign(i)&lt;=`1`; -- 4-1            
 when &#34;101&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`0`; Sign(i)&lt;=`0`; -- 4-0            
 when &#34;110&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`1`; Sign(i)&lt;=`0`; -- 4+1            
 when &#34;111&#34; =&gt; Two(i) &lt;=`1`; One(i)&lt;=`0`; Sign(i)&lt;=`0`; -- 4+2            
 when others =&gt; Two(i) &lt;=`1`; One(i)&lt;=`0`; Sign(i)&lt;=`0`;                  
 end case;                                                                
 end if;                                                                  
 c1 :=t1 or t2;                                                           
 end loop;                                                                
 end process;                                                             
end behavior1;                                                            
architecture behavior2 of pmac is                                         
 signal x1, y1: std.sub.-- logic.sub.-- vector(N+1 downto 0);             
begin                                                                     
 x1 &lt;= &#34;00&#34; &amp; x;                                                          
 y1 &lt;= &#34;00&#34; &amp; y;                                                          
 add: process(x1 ,y1)                                                     
 variable sel: std.sub.-- logic.sub.-- vector(2 downto 0);                
 variable c0, c1: std.sub.-- logic:=`0`;                                  
 variable s1, t1, t2: std.sub.-- logic:=`0`;                              
begin                                                                     
 c0:=`0`;                                                                 
 c1:=`0`;                                                                 
 L1: for i in 0 to (N/2) loop                                             
- sum in adderx1(i*2) xor y1(i*2);                                        
 t1 := (c0 and x1(i*2)) or (c0 and y1(i*2))                               
-carry1i*2) and y1(i*2));                                                 
 t2 := x1(i*2+1) xor y1(i*2+1);                                           
 c0 := x1(i*2+1) or y1(i*2+1);                                            
 sel(2 downto 0) := t1 &amp; t2 &amp; s1; -- Weight 2, -2, 1;                     
 it c1=`0` then                                                           
- t0+xn+ynis                                                              
 when &#34;000&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`0`; Sign(i)&lt;=`0`; -- 0              
 when &#34;001&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`1`; Sign(i)&lt;=`0`; -- 1              
 when &#34;010&#34; =&gt; Two(i) &lt;=`1`; One(i)&lt;=`0`; Sign(i)&lt;=`1`; -- -2             
 when &#34;011&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`1`; Sign(i)&lt;=`1`; -- -1             
 when &#34;100&#34; =&gt; Two(i) &lt;=`1`; One(i)&lt;=`0`; Sign(i)&lt;=`1`; -- 2              
 when &#34;101&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`1`; Sign(i)&lt;=`1`; -- 3              
 when &#34;110&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`0`; Sign(i)&lt;=`0`; -- 0              
 when &#34;111&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`1`; Sign(i)&lt;=`0`; -- 1              
 when others =&gt; Two(i) &lt;=`0`; One(i)&lt;=`1`; Sign(i)&lt;=`0`;                  
 end case;                                                                
else                                                                      
 case sel is                                                              
 when &#34;000&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`1`; Sign(i)&lt;=`0`; -- 0              
 when &#34;001&#34; =&gt; Two(i) &lt;=`1`; One(i)&lt;=`0`; Sign(i)&lt;=`0`; -- 1              
 when &#34;010&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`1`; Sign(i)&lt;=`1`; -- -2             
 when &#34;011&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`0`; Sign(i)&lt;=`1`; -- -1             
 when &#34;100&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`1`; Sign(i)&lt;=`1`; -- 2              
 when &#34;101&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`0`; Sign(i)&lt;=`1`; -- 3              
 when &#34;110&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`1`; Sign(i)&lt;=`1`; -- 0              
 when &#34;111&#34; =&gt; Two(i) &lt;=`1`; One(i)&lt;=`0`; Sign(i)&lt;=`0`; -- 1              
 when others =&gt; Two(i) &lt;=`1`; One(i)&lt;=`0`; Sign(i)&lt;=`0`;                  
 end case;                                                                
 end if;                                                                  
 c1 :=t1 and not(t2);                                                     
 end loop;                                                                
 end process;                                                             
end behavior2;                                                            
architecture behavior3 of pmac is                                         
 signal x1, y1: std.sub.-- logic.sub.-- vector(N+1 downto 0);             
begin                                                                     
 x1 &lt;= &#34;00&#34; &amp; x;                                                          
 y1 &lt;= &#34;00&#34; &amp; y;                                                          
add: process(x1 ,y1)                                                      
 variable sel: std.sub.-- logic.sub.-- vector(2 downto 0);                
 variable c0, c1: std.sub.-- logic:=`0`;                                  
 variable s1, t1, t2: std.sub.-- logic:=`0`;                              
begin                                                                     
 c0:=`0`;                                                                 
 c1:=`0`;                                                                 
 L1:for i in 0 to (N/2) loop                                              
- sum in adderx1(i*2) xor y1(i*2);                                        
 t1 := (c0 and x1(i*2)) or (c0 and y1(i*2))                               
- carry1(i*2) and y1(i*2));                                               
 t2 := not(x1(i*2+1) xor not(y1(i*2+1)) xor t1); - sum in subtract.       
 c0 := y1(i*2+1);                                                         
 sel(2 downto 0) := t2 &amp; s1 &amp; c1;-- Weight -2, 1, 1;                      
 case sel is                                                              
 when &#34;000&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`0`; Sign(i)&lt;=`0`;                   
 when &#34;001&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`1`; Sign(i)&lt;=`0`;                   
 when &#34;010&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`1`; Sign(i)&lt;=`0`;                   
 when &#34;011&#34; =&gt; Two(i) &lt;=`1`; One(i)&lt;=`0`; Sign(i)&lt;=`0`;                   
 when &#34;100&#34; =&gt; Two(i) &lt;=`1`; One(i)&lt;=`0`; Sign(i)&lt;=`1`;                   
 when &#34;101&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`1`; Sign(i)&lt;=`1`;                   
 when &#34;110&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`1`; Sign(i)&lt;=`1`;                   
 when &#34;111&#34; =&gt; Two(i) &lt;=`0`; One(i)&lt;=`0`; Sign(i)&lt;=`1`;                   
 when others =&gt; Two(i) &lt;=`0`; One(i)&lt;=`0`; Sign(i)&lt;=`1`;                  
 end case;                                                                
 c1 :=(t1 and x1(i*2+1)) or (t1 and not(y1(i*2+1)))                       
 or (x1(i*2+1) and not(y1(i*2+1)));                                       
 end loop;                                                                
 end process;                                                             
end behavior3;                                                            
library ieee, arithmetic, std;                                            
 use ieee.std.sub.-- logic.sub.-- 1164.all;                               
 use ieee.math.sub.-- real.all;                                           
 use arithmetic.std.sub.-- logic.sub.-- arith.all;                        
 use std.textio.all;                                                      
entity pmac.sub.-- t is                                                   
 generic (N: in Natural:=16);                                             
 port (error: inout std.sub.-- logic);                                    
end pmac.sub.-- t;                                                        
architecture behavior of pmac.sub.-- t is                                 
 component pmac                                                           
 generic (N: in Natural := 16);                                           
 port (x, y: in std.sub.-- logic.sub.-- vector (N-1 downto 0);            
 Two, One, Sign: out std.sub.-- logic.sub.-- vector (N/2 downto 0));      
 end component;                                                           
 for all:pmac use entity work.pmac(behavior3);                            
 signal Two, One, Sign: std.sub.-- logic.sub.-- vector (N/2 downto 0);    
 signal a, b: std.sub.-- logic.sub.-- vector(N-1 downto 0);               
begin                                                                     
 mydec: pmac generic map(N) port map (a, b, Two, One, Sign);              
 test: process                                                            
 variable s1: std.sub.-- logic.sub.-- vector(N downto 0);                 
 variable ai, bi, aiplusbi, booth.sub.-- res: integer;                    
 variable seed1, seed2: integer:= 678;                                    
 variable myreal: real;                                                   
begin                                                                     
 uniform(seed1, seed2, myreal);                                           
 a &lt;= std.sub.-- logic.sub.-- vector(to.sub.-- stdlogicvector             
(integer(myreal*65536.0), N));                                            
 uniform(seed1, seed2, myreal);                                           
 b &lt;= std.sub.-- logic.sub.-- vector(to.sub.-- stdlogicvector             
(integer(myreal*65536.0), N));                                            
 wait for 10 ns;                                                          
 s1:=(`0` &amp; a) + (`0` &amp; b);                                               
 ai:=to.sub.-- integer(std.sub.-- logic.sub.-- vector(`0` &amp; a));          
 bi:=to.sub.-- integer(std.sub.-- logic.sub.-- vector(`0` &amp; b));          
 aiplusbi := to.sub.-- integer(`0` &amp; s1);                                 
 booth.sub.-- res:= 0;                                                    
 for I in N/2 downto 0 loop                                               
 if Sign(I)=`1` then                                                      
 booth.sub.-- res :=booth.sub.-- res*4-2*to.sub.-- integer(Two(I))-to.sub.
-- integer(One(I));                                                       
 end if;                                                                  
 if Sign(I)=`0` then                                                      
 booth.sub.-- res :=booth.sub.-- res*4+2*to.sub.-- integer(Two(I))+to.sub.
-- integer(One(I));                                                       
 end if;                                                                  
 end loop;                                                                
 wait for 10 ns;                                                          
 if aiplusbi=booth.sub.-- res then                                        
 error &lt;= `0`;                                                            
 else                                                                     
 error &lt;= `1`;                                                            
 end if;                                                                  
 wait for 80 ns;                                                          
 assert (error=`0`) report &#34;beregningsfeji&#34;;                              
 end process;                                                             
end behavior;                                                             
______________________________________