# Patent

## Title
Efficient FIR filters

## Abstract

A processor for calculating a convolution of a first input sequence of numbers with a second input sequence of numbers to generate an output sequence is provided. The processor includes multipliers, each multiplying two real numbers to generate an output; multiplexers to direct the numbers in the first and second input sequences or parts of the numbers to the multipliers; and control circuitry to control the multiplexers to direct the first and second input sequences of numbers to the multipliers dependent on whether the numbers are complex or real. An accumulator adds partial products from multiplications performed by the multipliers to calculate the convolution.

## Background
BACKGROUND
The present disclosure relates to efficient finite impulse response filters.
A digital signal processor (DSP) can perform many types of signal processing, such as processing audio and/or video signals, using algorithms that involve a large number of mathematical operations performed on a large set of data. Compared to general-purpose microprocessors, digital signal processors can perform a narrower range of tasks, but can execute signal processing algorithms more efficiently with a lower latency and lower power consumption. This makes digital signal processors suitable for use in portable devices, such as mobile phones. A digital signal processor may include program memory that stores programs, data memory that stores the information to be processed, and one or more computing engines that perform math processing based on the program from the program memory and the data from the data memory. Examples of signal processing that can be efficiently performed by digital signal processors include audio compression and decompression, image compression and decompression, video compression and decompression, filtering of signals, spectrum analysis, modulation, pattern recognition and correlation analysis.
SUMMARY
In general, in one aspect, an apparatus includes a processor to calculate a convolution of a first input sequence of numbers with a second input sequence of numbers to generate an output sequence. The processor includes multipliers, each multiplying two real numbers to generate an output; multiplexers to direct the numbers in the first and second input sequences or parts of the numbers to the multipliers; and control circuitry to control the multiplexers to direct the first and second input sequences of numbers to the multipliers dependent on whether the numbers are complex or real. When each of the first sequence of numbers is a complex number and each of the second sequence of numbers is a real number, the control circuitry controls the multiplexers to direct the first and second input sequences of numbers to the multipliers to enable a first multiplication and a second multiplication to be performed in parallel. The first multiplication includes a first complex number in the first input sequence multiplied by a real number in the second input sequence, and the second multiplication includes a second complex number in the first input sequence multiplied by the real number in the second input sequence. An accumulator is provided to add partial products from the multiplications to calculate the convolution.
Implementations of the apparatus may include one or more of the following features. The processor can include a first register to store the first complex number in the first input sequence, a second register to store the second complex number in the first input sequence, and a third register to store the real number in the second input sequence. The control circuitry can control the multiplexers to direct the real number to each of a first multiplier, a second multiplier, a third multiplier, and a fourth multiplier, and control the multiplexers to direct a real part of the first complex number to the first multiplier, direct an imaginary part of the first complex number to the second multiplier, direct a real part of the second complex number to the third multiplier, and direct an imaginary part of the second complex number to the fourth multiplier. When each of the first sequence of numbers is a real number and each of the second sequence of numbers is a real number, the control circuitry can control the multiplexers to direct the first and second input sequences of numbers to the multipliers to enable a first multiplication of a first real number in the first input sequence with a real number in the second input sequence, a second multiplication of a second real number in the first input sequence with the real number in the second input sequence, a third multiplication of a third real number in the first input sequence with the real number in the second input sequence, and a fourth multiplication of a fourth real number in the first input sequence with the real number in the second input sequence, the first, second, third, and fourth multiplications being performed in parallel. The processor can include pipeline stages for calculating the convolution, and for a portion of the time the pipeline generate a partial product per operating cycle. The processor can include registers to store some of the first and second input sequences of numbers, and the control circuitry can control the multiplexers to direct the numbers stored in the registers to the multipliers. When each of the first and second sequences of numbers is a complex number, the control circuitry can control loading of one or more of the first and second input sequences of numbers into the registers and control the multiplexers to direct the first and second input sequences of numbers to the multipliers to enable outputting a product of a complex number in the first input sequence and a complex number in the second input sequence every cycle for a period of time. The first input sequence of numbers can include input samples to a digital filter, the second input sequence of numbers can include filter coefficients, and the output sequence can include an output of the digital filter in response to the input samples.
In general, in another aspect, a method of calculating a convolution of a first input sequence of numbers with a second input sequence of numbers to generate an output sequence is provided. The method includes identifying a first input sequence of numbers and a second input sequence of numbers; and directing the first and second input sequences of numbers to a plurality of multipliers according to whether the numbers are complex or real, each multiplier capable of multiplying two real numbers to generate an output. The method includes, when each of the first sequence of numbers is a complex number and each of the second sequence of numbers is a real number, directing a first complex number in the first input sequence of numbers, a second complex number in the first input sequence of numbers, and a real number in the second input sequence of numbers to the multipliers, and performing a first multiplication and a second multiplication in parallel, the first multiplication including multiplying the first complex number in the first input sequence with the real number in the second input sequence, the second multiplication including multiplying the second complex number in the first input sequence with the real number in the second input sequence. The method includes accumulating partial products to calculate a convolution of the first input sequence and the second input sequence.
Implementations of the method may include one or more of the following features. The first input sequence of numbers can include input samples to a digital filter, the second input sequence of numbers can include filter coefficients, and the convolution can represent an output of the digital filter in response to the input samples.
In general, in another aspect, a method of multiplying numbers includes identifying a first input sequence of numbers and a second input sequence of numbers; and directing the numbers in the first and second input sequences or parts of the numbers to a plurality of multipliers according to whether the numbers are complex or real, each multiplier capable of multiplying two real numbers to generate an output. The method includes, when each of the first sequence of numbers is a complex number and each of the second sequence of numbers is a real number, directing a first complex number in the first input sequence of numbers, a second complex number in the first input sequence of numbers, and a real number in the second input sequence of numbers to the multipliers, and performing a first multiplication and a second multiplication in parallel, the first multiplication including multiplying the first complex number in the first input sequence with the real number in the second input sequence, the second multiplication including multiplying the second complex number in the first input sequence with the real number in the second input sequence.
Implementations of the method may include one or more of the following features. The first input sequence of numbers can include input samples to a digital filter, the second input sequence of numbers can include filter coefficients. The method can include accumulating partial products to calculate a convolution of the first input sequence and the second input sequence, the convolution representing an output of the digital filter in response to the input samples.
In general, in another aspect, an apparatus includes a processor to calculate a convolution of input samples with filter coefficients to generate a filter output response, the processor including a multiplier-accumulator unit that includes multipliers, each to multiply a first input number and a second input number to generate a product; and multiplexers to receive the input samples and the filter coefficients and to direct the input samples and filter coefficients to the multipliers according to instruction codes specifying a computation mode. The processor is capable of executing instructions to perform computation in at least two computation modes. In a first computation mode, each input sample is a complex number and each filter coefficient is a complex number, and the multiplexers direct the input samples and filter coefficients to the multipliers to enable multiplication of a complex input sample with a complex filter coefficient. In a second computation mode, each input sample is a complex number and each filter coefficient is a real number, and the multiplexers direct the input samples and filter coefficients to the multipliers to enable a first multiplication of a first complex input sample with a real filter coefficient, and a second multiplication of a second complex input sample with the real filter coefficient, the first and second multiplications being performed in parallel.
Implementations of the apparatus may include one or more of the following features. The processor can execute instructions to perform computation in a third computation mode in which each input sample is a real number and each filter coefficient is a real number, and the multiplexers can direct the input samples and filter coefficients to the multipliers to enable a first multiplication of a first real input sample with a real filter coefficient, a second multiplication of a second real input sample with the real filter coefficient, a third multiplication of a third real input sample with the real filter coefficient, and a fourth multiplication of a fourth real input sample with the real filter coefficient, the first, second, third, and fourth multiplications being performed in parallel. The multiplier-accumulator unit can include four multipliers, and in the third computation mode, the multiplexers can direct the real filter coefficient to each of the four multipliers, direct the first real input sample to a first one of the four multipliers, direct the second real input sample to a second one of the four multipliers, direct the third real input sample to a third one of the four multipliers, and direct the fourth real input sample to a fourth one of the four multipliers. The multiplier-accumulator unit can include registers to store operands, and the multiplexers can direct the operands or parts of the operands to the multipliers. In the first computation mode, one of the registers can store one complex input sample, and in the third computation mode, the register can store two real input samples. The multiplier-accumulator unit can include at least four multipliers. In the second computation mode, the multiplexers can direct the real filter coefficient to each of the four multipliers, direct a real part of the first complex input sample to a first one of the four multipliers, direct an imaginary part of the first complex input sample to a second one of the four multipliers, direct a real part of the second complex input sample to a third one of the four multipliers, and direct an imaginary part of the second complex input sample to a fourth one of the four multipliers. The multiplier-accumulator unit can include registers to store operands, and the multiplexers can direct the operands or parts of the operands to the multipliers. In the second computation mode, one of the registers can store one complex input sample and another one of the registers can store two real filter coefficients. The multiplier-accumulator unit can include pipeline stages. The multiplier-accumulator unit can use an input sample to calculate an intermediate product of a first term of the filter output response in a first cycle, and reuse the same input sample to calculate an intermediate product of a second term of the filter output response in a second cycle.
These and other objectives of the present invention will no doubt become obvious to those of ordinary skill in the art after reading the following detailed description of the preferred embodiment that is illustrated in the various figures and drawings.



BRIEF DESCRIPTION OF THE DRAWINGS
FIG. 1 is a block diagram of an example complex multiplier-accumulator (CMAC) unit.
FIG. 2 is a schematic diagram of an example implementation of a MAC unit.
FIG. 3 is a diagram of a digital filter.
FIGS. 4 and 5 are diagrams of matrices having elements representing components of convolution computations.



DETAILED DESCRIPTION
Referring to FIG. 1, in some implementations, a digital signal processor has a complex multiplier-accumulator (CMAC) unit 100 that includes at least four multipliers 102 for performing multiplication operations on complex and real numbers. A complex number has real and imaginary parts. When performing a multiplication of two complex numbers, four multipliers are used to calculate the product terms of the real and imaginary parts of the two complex numbers. When performing a multiplication of two real numbers, one multiplier is used. When performing a multiplication of a real number and a complex number, two multipliers are used to calculate the products of the real number by the real and imaginary parts of the complex number.
In order to more fully utilize the multipliers 102 when calculating real by complex multiplications, the CMAC unit 100 can be configured to use the four multipliers to perform two multiplication operations in parallel, in which each multiplication involves a complex number multiplied by a real number. The CMAC unit 100 can also be configured to use the four multipliers to perform four multiplication operations in parallel, in which each multiplication involves a real number multiplied by a real number. This is useful if the digital signal processor performs a series of multiplications, and some of the operands are real numbers, and some of the operands are used more than once. Examples of such operations include using the digital signal processor to implement a digital finite impulse response (FIR) filter, in which either input samples to the filter are real numbers, or the filter coefficients are real numbers or both. To more fully utilize the multipliers, the calculations for implementing the FIR filter are arranged to allow two or more multiplications of input samples and filter coefficients to be performed in parallel.
In some examples, the CMAC unit 100 includes a register file 104 that stores operands to be processed by the CMAC unit 100. The operands are stored in registers 106 and sent to multiplexers 108, which direct the real and imaginary parts of the complex numbers to the appropriate multipliers 102. The multiplexers 108 are controlled by control circuitry 114, based on the instruction being executed. The control circuitry 114 may control the multiplexers 108 differently depending on whether the operands are complex or real numbers. Each multiplier 102 can multiply two real numbers and send the product to an accumulator 110, which have adders that sum up the products and generate an output 112. In some implementations, the CMAC unit 100 has pipeline stages such that during some periods of time (e.g., when the pipeline is full), the CMAC unit 100 processes one complex by complex, two complex by real, or four real by real multiplications per clock cycle.
Referring to FIG. 2, as an example, one implementation of the CMAC unit 100 is CMAC unit 140, which can perform calculations on 32-bit operands. The CMAC unit 140 includes a register file 142 that has eight entries for storing 32-bit operands, or sixteen entries for storing 16-bit operands. Registers 144a, 144b, and 144c store three operands, e.g., operand A, operand B, and operand C, respectively. Two pipelines 152a and 152b operate on the operands in parallel. In the pipeline 152a, two multiplexers 146a and 146b multiplex the operands or parts of the operands and direct them to the inputs of multipliers 148a and 148b. In the pipeline 152b, two multiplexers 146c and 146d multiplex the operands or parts of the operands and direct them to the inputs of multipliers 148c and 148d. Each multiplier 148 can receive two 16-bit numbers. As an example, for a multiplication of a first complex number xr+xi·i (xr being the real part and xi being the imaginary part) and a second complex number yr+yi·i (yr being the real part and yi being the imaginary part), the multiplexers can send xr and yr to the multiplier 148a, xi and yi to the multiplier 148b, xr and yi to the multiplier 148c, and xi and yr to the multiplier 148d. 
The multipliers 148a to 148d multiply the numbers provided by the multiplexers 146a to 146d to generate partial products. In the example above, the multiplier 148a calculates xr*yr, the multiplier 148b calculates xi*yi, the multiplier 148c calculates xr*yi, and the multiplier 148d calculates xi*yr.
Logic circuit 154a, which includes partial products compressors 156a, 156b and a 48-bit configurable adder 158a, processes the partial products in the pipeline 152a in a more compact format to generate outputs 160a and 160b that are provided to an accumulator 150a, which generates a 48-bit output 162a, representing the real part of the product (xr+xi)*(yr+yi). A0.H, which is the upper 24 bits in the accumulator 150a, stores the partial product xr*yr. A0.L, which is the lower 24 bits in the accumulator 150a, stores the partial product xi*yi.
Logic circuit 154b, which includes partial products compressors 156c, 156d and a 48-bit configurable adder 158b, processes the partial products in the pipeline 152b in a more compact format to generate outputs 160c and 160d that are provided to an accumulator 150b, which generates a 48-bit output 162b, representing the imaginary part of the product (xr+xi)*(yr+yi). A1.H, which is the upper 24 bits in the accumulator 150b, stores the partial product xr*yi. A1.L, which is the lower 24 bits in the accumulator 150b, stores the partial product xi*yr.
A feature of the CMAC unit 140 is that the four multipliers 148a to 148d can calculate the multiplication of a real number and a first complex number, and the multiplication of the same real number and a second complex number in parallel. For example, register 144a can store a first complex number x=xr+xi, register 144b can store a second complex number y=yr+yi, and half of register 144c can store a real number c. The multiplexers 146a to 146d can multiplex x, y, and c such that the multiplier 148a receives xr and c, the multiplier 148b receives xi and c, the multiplier 148c receives yr and c, and the multiplier 148d receives yi and c. The accumulator 150a provides the product x*c, in which A0.H=xr*c and A0.L=xi*c. The accumulator 150b provides the product y*c, in which A1.H=yr*c and A1.L=yi*c.
In some examples, the first and second complex numbers x and y are input samples to an FIR filter, the real number c is a coefficient of the FIR filter, and the products x*c and y*c are terms of the filter response.
Another feature of the CMAC unit 140 is that the four multipliers 148a to 148d can calculate the multiplication of a first real number, a second real number, a third real number and a fourth real number, by a fifth real number in parallel. For example, register 144a can store real numbers x0 and x1, register 144b can store real numbers x2 and x3 and register 144c can store real number c. The multiplexers 146a to 146d can multiplex x0, x1, x2, x3, and c such that the multiplier 148a receives x0 and c, the multiplier 148b receives x1 and c, the multiplier 148c receives x2 and c, and the multiplier 148d receives x3 and c. The accumulator 150a provides the products x0*c and x1*c, in which A0.H=x0*c and A0.L=x1*c. The accumulator 150b provides the products x2*c and x3*c, in which A1.H=x2*c and A1.L=x3*c.
In some examples, the real numbers x0, x1, x2 and x3 are input samples to an FIR filter, the real number c is a coefficient of the FIR filter, and the products x0*c, x1*c, x2*c, and x3*c are terms of the filter response.
In some implementations, the digital signal processor is configured to execute a set of instructions that specify how the operands or parts of the operands stored in the registers 144a to 144c are multiplexed and provided to the multipliers 146a to 146d. As described below, by carefully designing the instructions, the CMAC unit 140 can efficiently implement a finite impulse response (FIR) filter by reusing operands and more fully utilizing all four multipliers 148a to 148d in the calculations. The instructions optimize the hardware resources for different scenarios (e.g., real or complex number filter inputs, and real or complex number filter coefficients), leading to lower power consumption while achieving higher throughput.
Case0: Complex Input with Complex Coefficients
The instructions allow the digital signal processor to perform a regular complex multiplication:

C=A·BCr=Ar·Br−Ai·Bi,Ci=Ar·Bi+Ai·Br 

The instructions also provide options to allow the digital signal processor to perform complex multiplication with conjugation of any operand when the appropriate option is selected:

C=A·B*Cr=Ar·Br+Ai·Bi,Ci=Ai·Br−Ar·Bi 

C=A*·BCr=Ar·Br+Ai·Bi,Ci=Ar·Bi−Ai·Br 

C=A*·B*Cr=Ar·Br−Ai·Bi,Ci=−Ar·Bi−Ai·Br 

Referring to FIG. 3, in some implementations, an FIR filter 170 receives an input signal x(n) and calculates the convolution of the input signal x(n) with filter coefficients c(k) representing the impulse response of the FIR filter, producing a filtered output signal y(n). For example, the convolution may be defined by:

y(n)=Σk=0K−1x(n−k)·c(k),

where c(k) are the coefficients of the FIR filter. As an example, in order to calculate y(8, . . . , 11) for k=6, we need to calculate the following sum of products:





  
    
      
        
          
            
              
                
                  
                    
                      y
                      ⁡
                      
                        (
                        8
                        )
                      
                    
                    =
                    
                    ⁢
                    
                      
                        ∑
                        
                          k
                          =
                          0
                        
                        5
                      
                      ⁢
                      
                        
                      
                      ⁢
                      
                        
                          x
                          ⁡
                          
                            (
                            
                              8
                              -
                              k
                            
                            )
                          
                        
                        ·
                        
                          c
                          ⁡
                          
                            (
                            k
                            )
                          
                        
                      
                    
                  
                
              
              
                
                  
                    =
                    
                    ⁢
                    
                      
                        
                          x
                          8
                        
                        ·
                        
                          c
                          0
                        
                      
                      +
                      
                        
                          x
                          7
                        
                        ·
                        
                          c
                          1
                        
                      
                      +
                      
                        
                          x
                          6
                        
                        ·
                        
                          c
                          2
                        
                      
                      +
                      
                        
                          x
                          5
                        
                        ·
                        
                          c
                          3
                        
                      
                      +
                      
                        
                          x
                          4
                        
                        ·
                        
                          c
                          4
                        
                      
                      +
                      
                        
                          x
                          3
                        
                        ·
                        
                          c
                          5
                        
                      
                    
                  
                
              
            
          
        
        
          
            
              
                
                  
                    
                      y
                      ⁡
                      
                        (
                        9
                        )
                      
                    
                    =
                    
                    ⁢
                    
                      
                        ∑
                        
                          k
                          =
                          0
                        
                        5
                      
                      ⁢
                      
                        
                      
                      ⁢
                      
                        
                          x
                          ⁡
                          
                            (
                            
                              9
                              -
                              k
                            
                            )
                          
                        
                        ·
                        
                          c
                          ⁡
                          
                            (
                            k
                            )
                          
                        
                      
                    
                  
                
              
              
                
                  
                    =
                    
                    ⁢
                    
                      
                        
                          x
                          9
                        
                        ·
                        
                          c
                          0
                        
                      
                      +
                      
                        
                          x
                          8
                        
                        ·
                        
                          c
                          1
                        
                      
                      +
                      
                        
                          x
                          7
                        
                        ·
                        
                          c
                          2
                        
                      
                      +
                      
                        
                          x
                          6
                        
                        ·
                        
                          c
                          3
                        
                      
                      +
                      
                        
                          x
                          5
                        
                        ·
                        
                          c
                          4
                        
                      
                      +
                      
                        
                          x
                          4
                        
                        ·
                        
                          c
                          5
                        
                      
                    
                  
                
              
            
          
        
        
          
            
              
                
                  
                    
                      y
                      ⁡
                      
                        (
                        10
                        )
                      
                    
                    =
                    
                    ⁢
                    
                      
                        ∑
                        
                          k
                          =
                          0
                        
                        5
                      
                      ⁢
                      
                        
                      
                      ⁢
                      
                        
                          x
                          ⁡
                          
                            (
                            
                              10
                              -
                              k
                            
                            )
                          
                        
                        ·
                        
                          c
                          ⁡
                          
                            (
                            k
                            )
                          
                        
                      
                    
                  
                
              
              
                
                  
                    =
                    
                    ⁢
                    
                      
                        
                          x
                          10
                        
                        ·
                        
                          c
                          0
                        
                      
                      +
                      
                        
                          x
                          9
                        
                        ·
                        
                          c
                          1
                        
                      
                      +
                      
                        
                          x
                          8
                        
                        ·
                        
                          c
                          2
                        
                      
                      +
                      
                        
                          x
                          7
                        
                        ·
                        
                          c
                          3
                        
                      
                      +
                      
                        
                          x
                          6
                        
                        ·
                        
                          c
                          4
                        
                      
                      +
                      
                        
                          x
                          5
                        
                        ·
                        
                          c
                          5
                        
                      
                    
                  
                
              
            
          
        
        
          
            
              
                
                  
                    
                      y
                      ⁡
                      
                        (
                        11
                        )
                      
                    
                    =
                    
                    ⁢
                    
                      
                        ∑
                        
                          k
                          =
                          0
                        
                        5
                      
                      ⁢
                      
                        
                      
                      ⁢
                      
                        
                          x
                          ⁡
                          
                            (
                            
                              11
                              -
                              k
                            
                            )
                          
                        
                        ·
                        
                          c
                          ⁡
                          
                            (
                            k
                            )
                          
                        
                      
                    
                  
                
              
              
                
                  
                    =
                    
                    ⁢
                    
                      
                        
                          x
                          11
                        
                        ·
                        
                          c
                          0
                        
                      
                      +
                      
                        
                          x
                          10
                        
                        ·
                        
                          c
                          1
                        
                      
                      +
                      
                        
                          x
                          9
                        
                        ·
                        
                          c
                          2
                        
                      
                      +
                      
                        
                          x
                          8
                        
                        ·
                        
                          c
                          3
                        
                      
                      +
                      
                        
                          x
                          7
                        
                        ·
                        
                          c
                          4
                        
                      
                      +
                      
                        
                          x
                          6
                        
                        ·
                        
                          c
                          5
                        
                      
                    
                  
                
              
            
          
        
      
    
    
      
        (
        
          Equ
          .
          
            
          
          ⁢
          1
        
        )
      
    
  




The filter inputs and coefficients can be complex or a combination of real and complex numbers. When the inputs and coefficients are both complex, the sum of products term appear as follows:

yr=xr*cr−xi*ci,yi=xr*ci+xi*cr.

Such computations can be performed by loading one of the registers 144 with a complex filter input, and loading another one of the registers 144 with a complex filter coefficient. The multiplexers 146 direct real and imaginary parts of the filter input and the filter coefficient to the multipliers 148 to calculate xr*cr, xi*ci, xr*ci, and xi*cr.
One way to calculate y8, . . . , 11 for K=6 is to calculate y8=x8·c0+x7·c1+x6·c2+x5·c3+x4·c4+x3·c5, which involves calculating x8*c0, x7*c1, x6*c2, x5*c3, x4*c4, and x3*c5 using the multipliers 148, then adding x8*c0, x7*c1, x6*c2, x5*c3, x4*c4, and x3*c5 using the accumulator. After completing the calculation of y8, y9=x9*c0+x8*c1+x7·c2+x6·c3+x5·c4+x4·c5 is calculated in a similar manner. The terms y10=x10·c0+x9·c1+x8·c2+x7·c3+x6·c4+x5·c5 and y11=x11·c0+x10·c1+x9·c2+x8·c3+x7·c4+x6·c5 are then calculated.
The inventors realized that some of the operands are used in calculating both yn and yn+1, n=8 to 10. Thus, for all real valued inputs instead of calculating y8, y9, y10, and y11 one after the other, it is more efficient to calculate y8 to y11 in parallel and reuse the operands in the calculations. Also, for complex valued inputs and real filter coefficients instead of calculating y8, y9, y10, and y11 one after the other, it is more efficient to calculate y8 to y11 in pairs and reuse the operands in the calculations.
Referring to FIG. 4, to illustrate how the calculations for the convolution can be performed efficiently by calculating the output terms y8 and y9 in parallel as a pair and then calculating y10 and y11 in parallel as a second pair, a matrix 120 is presented having columns representing filter inputs (xi, i=4 to 12) and rows representing filter coefficients (ci, i=0 to 5). Each dot (e.g., 122) at an intersection of a column of filter input (e.g., 124) and a row of filter coefficient (e.g., 126) represents a product of a filter input and a filter coefficient. In this example, the dot 122 represents x10·c0. The term y10 can be determined by calculating the sum of the products represented by the dots along a diagonal line 128, and the term y11 can be determined by calculating the sum of the products represented by the dots along a diagonal line 130.
For example, y10 includes the term x10*c0, and y11 includes the term x10*c1. Thus, the operand x10 can be used in both calculations. Similarly, y10 includes the term x9*c1, and y11 includes the term x10*c1, so the operand c1 can be used in both calculations. By calculating the components of y10 and y11 in parallel, and using the operands in the registers 144 in multiple calculations, the multipliers 148 can be more fully utilized, and less time is needed to load the operands into the registers 144.
The multipliers 148a to 148d in the CMAC unit 140 are paired so that the accumulators 150a and 150b add up partial products from each pair, allowing a single-cycle complex multiplication to be performed. The term “single-cycle complex multiplication” means that when the pipelines 152a and 152b are full, one output term is generated and accumulated at the output of the pipelines each cycle. The term “cycle” can mean a clock cycle or an operation cycle that includes more than one clock cycle.
A 32-bit operand has a 16-bit real term and a 16-bit imaginary term in the lower and upper halves, respectively, of the operand. The order of usage of operands in a complex math instruction is fixed. The instruction specifies the address for the two 32-bit operands, one for the filter input and the other for the filter coefficient. The address of an operand in the 8 deep register file 142 can be specified using 3 bits, and hence 6 bits can be used to specify the addresses of the two 32-bit operands. An additional 2 bits are used to specify one of the four conjugate operations described above. In this example, a total of 8 bits are used in the complex math instruction to specify the 32-bit operands and the conjugate operation.
The four 16-bit times 16-bit multipliers 148a to 148d calculate the intermediate terms of the multiplication operation, and two 48-bit adders 158a, 158b calculate the sum of the intermediate terms. The CMAC unit 140 adds the intermediate terms and loads operands from memory to fetch the next filter coefficient and filter input in parallel. The CMAC unit 140 has a pipeline structure so that in each cycle (e.g., clock cycle or operation cycle), new operands are loaded and a new output is generated and accumulated.
By comparison, in a conventional design, when the filter input and filter coefficient are both real numbers, only one multiplier 148 is typically used to multiply the two real numbers, and the other three multipliers 148 are idle. In the conventional design, when the filter input and filter coefficient include one real number and one complex number, only two multipliers 148 are typically used to multiply the real number and the real and imaginary parts of the complex number, and the other two multipliers 148 are idle. Thus, the CMAC unit 140 in FIG. 2 more fully utilizes the multipliers 148 than the conventional design.
The following describes a “quad scale” instruction set that allows the use of all four multipliers 148 when one or both of the filter input and filter coefficient are real numbers. The basic functionality of the quad scale instruction set is defined by the following operation:

Y0=X0·c,Y1=X1·c,Y2=X2·c,Y3=X3·c 

where x0, . . . , x3 conceptually are four independent variables and cis a common scalar. The four multiplications x0*c, x1*c, x2*c, and x3*c are calculated by the four multipliers 148a to 148d in parallel. The variables x0 to x3 and the scalar c are specified as operands of the quad scale instruction. The goal is to arrange calculations into a series of parallel multiplications in the format above that can be performed by the four multipliers 148.

In some implementations, the quad scale multiplication instruction has two modes for specifying two allowed combinations of input registers. The syntax for the first mode of the multiplication instruction is:

A0.L+=Rx.L*Rz.[H|L]∥A0.H+=Rx.H*Rz.[H|L]∥

A1.L+=Ry.L*Rz.[H|L]∥A1.H+=Ry.H*Rz.[H|L]∥; 

where A0.L represents the lower half of the output A0, A0.H represents the upper half of the output A0, A1.L represents the lower half of the output A1, A1.H represents the upper half of the output A1, Rx.L represents the lower half of the operand Rx, Rx.H represents the upper half of the operand Rx, Ry.L represents the lower half of the operand Ry, Ry.H represents the upper half of the operand Ry, Rz.L represents the lower half of the operand Rz, and Rz.H represents the upper half of the operand Rz.

The syntax for the second mode of the multiplication instruction is:

A0.L+=Rx.H*Rz.[L|H]∥A0.H+=Rx.L*Rz.[L|H]∥

A1.L+=Ry.H*Rz.[L|H]∥A1.H+=Ry.L*Rz.[L|H]. 

As will be described later, the second mode is useful in performing a series of multiplications in which the operands are stored in two registers, such as Rx and Ry above, and during each cycle only one-half of the register is updated. For example, during a first cycle, the operands stored in Rx.H, Rx.L, Ry.H, and Ry.L are used. Also in the first cycle, a new number is loaded into Rx.H. In a second cycle, the operands stored in Rx.L, Ry.H, Ry.L, and Rx.H are used. A new number is loaded and is updated, in parallel, in which each multiplication involves a real number multiplied by a real number.
If each 16-bit operand is selected from the register file of 16 half-words, combined with a scalar operand, the total source selection payload will be 20 opcode-bits. The register file has 16 entries of 16-bit numbers, so each 16-bit operand has a 4-bit address. Four 16-bit operands need 16 bits for the addresses. The scalar also has a 4-bit address. Thus, 4×5=20 bits are needed for the selection of the four 16-bit operands and the 16-bit scalar in the register file 142.
If the operands are loaded into the register file 142 in a way such that the variables x0 to x4 are stored at consecutive addresses in the register file 142, then the number of bits needed for address decode can be reduced from 20 to 8 bits. The register file 142 can have eight 32-bit values, so each 32-bit value has a 3-bit address. By assuming that the variables x0 to x4 are stored at consecutive addresses in the register file 142, three bits can be used for the selection of (X0, X1, X2, X3) by specifying the address of the first 32-bit value in the register file 142. That address stores x0 and x1, and the following address stores x2 and x3. One bit is used for the selection between two modes of the quad scale instruction, and four bits are used for the selection of the scalar operand. Thus, a total of 3+1+4=8 bits are needed. Each of the two accumulators, A0 and A1, includes two halves (A0.L, A0.H, A1.L and A1.H), each half containing 24 bits representing a 9.15 fractional integer.
Case 1: Complex Input with Real Coefficients
The following describes the calculation of the convolution of Equation 1 using the CMAC unit 140, in which the filter inputs are complex numbers and the filter coefficients are real numbers. An instruction set is provided to allow two 32-bit complex filter inputs and one 16-bit scalar filter coefficient to be processed per clock cycle. In this example, two of the 32-bit registers 144 store two 32-bit complex filter inputs, and one of the 32-bit registers 144 stores two 16-bit real filter coefficients. When updating the contents of the registers 144, the real filter coefficients are loaded in pairs into the register, while the complex filter inputs are loaded into the registers one at a time (i.e., one filter input is updated in one clock cycle, another filter input is updated in the following clock cycle, and so forth). This design allows y(10) and y(11) to be calculated in parallel by using all four multipliers 148a to 148d. Some operands are reused, meaning that the same operand is used in more than one cycle. For example, an operand may be used in a multiplication in a first cycle, and used again in another multiplication in a second cycle.
Expressed in pseudo-assembly code, the code for the traversal of the matrix 120 in FIG. 4 can be modeled as follows:

R0=[x11r,x11i]//X11 and x10 contain the complex filter inputs

R1=[x10r,x10i]∥R2=[c1,c0];

Here, register R0 stores the complex filter input x11, including the real part x11r and the imaginary part x11i. Register R1 stores the complex filter input x10, including the real part x10r and the imaginary part x10i. Register R2 stores the real filter coefficients c0 and c1. The registers R0, R1, and R2 in the pseudo-code above can correspond to, e.g., registers 144a, 144b, and 144c of the CMAC unit 140. The notation “//” indicates that the text after it are comments, while the notation “∥” indicates parallel execution of instructions. Thus, register R2 is loaded with c1 and c0 at the same time that the register R1 is loaded with x10r and x10i.
A software loop having the following instructions 1 and 2 can be executed:
Instruction 1:

A0.H+=R0.H*R2.L,A0.L+=R0.L*R2.L, 

A1.H+=R1.H*R2.L,A1.L+=R1.L*R2.L 

∥R0=[x9r,x9i];

// Uses (R0,R1) contents.
Instruction 2:

A0.H+=R1.H*R2.H,A0.L+=R1.L*R2.H, 

A1.H+=R0.H*R2.H,A1.L+=R0.L*R2.H 

∥R1=[x8r,x8i]∥R2=[c2,c3];

// Uses (R1,R0) contents.
The instructions 1 and 2 above show that x11, x10, x9, x8, c0, c1, c2, and c3 are processed. The actual program code is written in a way such that different values are loaded into the registers during different loop iterations.
Instruction 1 provides the calculation of R0*R2.L and R1*R2.L and loading register R0 in parallel. Instruction 2 provides the calculation of R1*R2.H and R0*R2.H, loading register R1, and loading of c2 and c3 into register R2 in parallel.
In both instructions 1 and 2, the filter coefficient (a scalar operand) is specified with a unique address that requires 4 bits. The filter inputs (e.g., x11 and x10) are fetched from a 32 bit register pair. This pair can be decoded using a 3 bit address. In the first instruction above, the filter input data x11 and x10 are stored in registers R0 and R1, respectively. At the same time that x11*c0 and x10*c0 are calculated, the filter input x9=x9r+x9i is loaded into the register R0. In the second instruction, the filter input data x10 and x9 are stored in registers R1 and R0, respectively. At the same time that x10*c1 and x9*c1 are calculated, the filter input x8=x8r+x8i is loaded into the register R1, and the filter coefficients c2 and c3 are loaded into the register R2.
In this example, the second register storing the second operand is implied, thus reducing the address payload to 3 bits from 6 bits. In the two instructions above, the mode bit is set to “0” indicating that the first mode of the multiplication instruction is used. When a complex number x11 is stored in the register, the real part is stored in the higher half of the register, and the imaginary part is stored in the lower part of the register. Thus, the first mode of the multiplication instruction results in A0.H+=x11r*c0, A0.L=x11i*c0.
The software loop allows the calculation of y11 and y10 to be performed in an iterative process in which pairs of terms (x9*c2, x8*c2), (x8*c3, x7*c3), (x7*c4, x6*c4), (x6*c5, x5*c5) are calculated similarly as described above. At the end of the computation, when we finish traversing the matrix along the diagonal lines 128 and 130, (A0.H, A0.L) will store the complex sum of the product y11=x11*c0+x10*c1+x9*c2+x8*c3+x7*c4+x6*c5 (in which A0.H stores the real part and A0.L stores the imaginary part), and (A1.H, A1.L) will store the complex sum of the product y10=x10*c0+x9*c1+x8*c2+x7*c3+x6*c4+x5*c5 (in which A1.H stores the real part and A1.L stores the imaginary part).
Case2: Real Input with Real Coefficients
When the filter inputs and the filter coefficients are all real numbers, the inventors realized that some of the operands are used in calculating y8, y9, y10, and y11. Thus, instead of calculating y8, y9, y10, and y11 one after the other, it is more efficient to calculate y8 to y11 in parallel and reuse the operands in the calculations.
Referring to FIG. 5, to illustrate how the calculations for the convolution can be performed efficiently by calculating the components of four output terms y8 to y11 in parallel, a matrix 180 is presented, similar to the matrix 120 of FIG. 4. The terms y8, y9, y10, and y11 can be determined by calculating the sum of the products represented by the dots along diagonal line 182, 184, 186, and 188, respectively.
It is efficient to calculate the components of y11, y10, y9, and y8 in parallel because some operands are common to the computation of y11 to y9, and four multipliers 148 are available to perform the multiplications. For example, y11 includes the term x8*c3, y10 includes the term x8*c2, y9 includes the term x8*c1, and y8 includes the term x8*c0. Thus, the operand x8 can be used in all four calculations. Similarly, y11 includes the term x8*c3, y10 includes the term x7*c3, y9 includes the term x6*c3, and y8 includes the term x5*c3, so the operand c3 can be used in all four calculations. By calculating the components of y11 to y8 in parallel, and loading an operand in the register for use in four multiplications, the multipliers 148 can be more fully utilized, and less time is needed to load the operands into the registers 144.
The following describes calculation of the convolution of Equation 1 using the CMAC unit 140, in which both the filter inputs and the filter coefficients are real numbers. An instruction set is provided to allow four 16-bit real filter inputs and one 16-bit scalar filter coefficient to be processed per clock cycle. In this example, two of the 32-bit registers 144 store two 16-bit real filter inputs, and one of the 32-bit registers 144 stores two 16-bit filter coefficients. When updating the contents of the registers 144, the real number filter coefficients are loaded in pairs into the register. This design allows y8 to y11 to be calculated in parallel by using all four multipliers 148a to 148d, with reuse of operands.
Expressed in pseudo-assembly code, the code for the traversal of the matrix 180 in FIG. 5 can be modeled as follows:

R0=[x11,x10];

R1=[x9,x8]∥R2=[c1,c0];

A software loop having the following instructions can be executed:

A0.H+=R0.H*R2.L,A0.L+=R0.L*R2.L, 

A1.H+=R1.H*R2.L,A1.L+=R1.L*R2.L 

∥R0.H=[x7];

// Mode bit=0, reg pair used (R0,R1)
// Traverses row1 of Matrix

A0.H+=R0.L*R2.H,A0.L+=R1.H*R2.H, 

A1.H+=R1.L*R2.H,A1.L+=R0.H*R2.H 

∥R0.L=[x6]∥R2=[c3,c2];

// Mode bit=1, reg pair used (R0,R1)
// Traverses row2 of Matrix

A0.H+=R1.H*R2.L,A0.L+=R1.L*R2.L, 

A1.H+=R0.H*R2.L,A1.L+=R0.L*R2.L 

∥R1.H=[x5];

// Mode bit=0, reg pair used (R1,R0)
// Traverses row3 of Matrix

A0.H+=R1.L*R2.H,A0.L+=R0.H*R2.H, 

A1.H+=R0.L*R2.H,A1.L+=R1.H*R2.H 

∥R1.L=[x4]∥R2=[c5,c4];

// Mode bit=1, reg pair used (R1,R0)
// Traverses row4 of Matrix
The instructions above show that x11, x10, x9, x8, x7, c0, c1, c2, and c3 are processed. The actual program code is written in a way such that different values are loaded into the registers during different loop iterations.
The first two instructions will traverse the first two rows of the matrix. The first instruction uses the first mode of the quad scale instruction, and the second instruction uses the second mode of the quad scale instruction. The subsequent instructions work on implied pair (R1, R0) and use the mode bit in a similar manner. In this example, 8 bits are used to decode the bits for register mapping.
At the end of the computation:

A0.H stores y11=x11*c0+x10*c1+x9*c2+x8*c3+x7*c4+x6*c5,

A0.L stores y10=x10*c0+x9*c1+x8*c2+x7*c3+x6*c4+x5*c5,

A1.H stores y9=x9*c0+x8*c1+x7*c2+x6*c3+x5*c4+x4*c5, and

A1.L stores y8=x8*c0+x7*c1+x6*c2+x5*c3+x4*c4+x3*c5.

Thus the complex math and quad scale instructions allow for a uniform implementation for all three cases of FIR filter convolution (i.e., complex filter inputs and complex filter coefficients, complex filter inputs and real filter coefficients, and real filter inputs and real filter coefficients). The pseudo-assembly code for complex filter input times complex filter coefficient is as follows:

A0.H+=R0.H*R2.H,A0.L+=R0.L*R2.L, 

A1.H+=R0.H*R2.L,A1.L+=R0.L*R2.H 

∥R0=[xrxi]|R2=[crci]

Mode switches can be used to differentiate between the different instructions. The software loops are similar in all cases and use all 4 multipliers in every cycle. At a programming level, the new instructions still use 8 bits for specifying all input operand combinations.
The examples above show that a digital FIR filter can be implemented using a MAC unit having four multipliers (each capable of multiplying two 16-bit numbers) and three 32-bit registers. By carefully designing how the operands are loaded into the registers and arranging the sequence of multiplications, it is possible to fully use the four multipliers for the following three cases: (1) complex filter inputs and complex filter coefficients, (2) complex filter inputs and real filter coefficients, and (3) real filter inputs and real filter coefficients.
A number of implementations have been described. Nevertheless, it will be understood that various modifications may be made. For example, elements of one or more implementations may be combined, deleted, modified, or supplemented to form further implementations. As yet another example, the logic flows depicted in the figures do not require the particular order shown, or sequential order, to achieve desirable results. In addition, other steps may be provided, or steps may be eliminated, from the described flows, and other components may be added to, or removed from, the described systems.
For example, the number of bits for each entry in the register file 142, the number of bits of the registers 144, the number of bits that can be handled by the multipliers 148, the number of bits of the adders 158, and the number of bits of the accumulators 162 can be different from those described above. The multiplier-accumulator unit can be used in computations other than convolution.
Accordingly, other implementations are within the scope of the following claims.
Those skilled in the art will readily observe that numerous modifications and alterations of the device and method may be made while retaining the teachings of the invention. Accordingly, the above disclosure should be construed as limited only by the metes and bounds of the appended claims.

## Claims

1. An apparatus comprising:
a processor to calculate a convolution of a first input sequence of numbers with a second input sequence of numbers to generate an output sequence, the processor comprising:
multipliers, each multiplying two numbers to generate an output;
multiplexers to direct the numbers in the first and second input sequences or parts of the numbers to the multipliers;
control circuitry to control the multiplexers to direct the first and second input sequences of numbers to the multipliers dependent on whether the numbers are complex or real,
in which when each of the first sequence of numbers is a complex number and each of the second sequence of numbers is a real number, the control circuitry controls the multiplexers to direct the first and second input sequences of numbers to the multipliers to enable a first multiplication and a second multiplication to be performed in parallel, the first multiplication comprising a first complex number in the first input sequence multiplied by a real number in the second input sequence, and the second multiplication comprising a second complex number in the first input sequence multiplied by the real number in the second input sequence; and

an accumulator to add partial products from the multiplications to calculate the convolution.

2. The apparatus of claim 1 in which the processor further comprises a first register to store the first complex number in the first input sequence, a second register to store the second complex number in the first input sequence, and a third register to store the real number in the second input sequence.

3. The apparatus of claim 2 in which the control circuitry controls the multiplexers to direct the real number to each of a first multiplier, a second multiplier, a third multiplier, and a fourth multiplier, and controls the multiplexers to direct a real part of the first complex number to the first multiplier, direct an imaginary part of the first complex number to the second multiplier, direct a real part of the second complex number to the third multiplier, and direct an imaginary part of the second complex number to the fourth multiplier.

4. The apparatus of claim 1 in which when each of the first sequence of numbers is a real number and each of the second sequence of numbers is a real number, the control circuitry controls the multiplexers to direct the first and second input sequences of numbers to the multipliers to enable a first multiplication of a first real number in the first input sequence with a real number in the second input sequence, a second multiplication of a second real number in the first input sequence with the real number in the second input sequence, a third multiplication of a third real number in the first input sequence with the real number in the second input sequence, and a fourth multiplication of a fourth real number in the first input sequence with the real number in the second input sequence, the first, second, third, and fourth multiplications being performed in parallel.

5. The apparatus of claim 1 in which the processor further comprises pipeline stages for calculating the convolution, and each of the pipeline stages comprises one multiplier of the multipliers and one multiplexer of the multiplexers such that for a portion of the time each of the pipeline stage generates a partial product per operating cycle.

6. The apparatus of claim 5 in which the processor further comprises registers to store some of the first and second input sequences of numbers, and the control circuitry controls the multiplexers to direct the numbers stored in the registers to the multipliers.

7. The apparatus of claim 6 in which when each of the first and second sequences of numbers is a complex number, the control circuitry controls loading of one or more of the first and second input sequences of numbers into the registers and controls the multiplexers to direct the first and second input sequences of numbers to the multipliers to enable outputting a product of a complex number in the first input sequence and a complex number in the second input sequence every cycle for a period of time.

8. The apparatus of claim 1 in which the first input sequence of numbers comprise input samples to a digital filter, the second input sequence of numbers comprise filter coefficients, and the output sequence comprises an output of the digital filter in response to the input samples.

9. A method of calculating a convolution of a first input sequence of numbers with a second input sequence of numbers to generate an output sequence, the method comprising:
identifying a first input sequence of numbers and a second input sequence of numbers;
directing the first and second input sequences of numbers to a plurality of multipliers according to whether the numbers are complex or real, each multiplier capable of multiplying two numbers to generate an output;
when each of the first sequence of numbers is a complex number and each of the second sequence of numbers is a real number,
directing a first complex number in the first input sequence of numbers, a second complex number in the first input sequence of numbers, and a real number in the second input sequence of numbers to the multipliers, and
performing a first multiplication and a second multiplication in parallel, the first multiplication comprising multiplying the first complex number in the first input sequence with the real number in the second input sequence, the second multiplication comprising multiplying the second complex number in the first input sequence with the real number in the second input sequence; and

accumulating partial products to calculate a convolution of the first input sequence and the second input sequence.

10. The method of claim 9 in which the first input sequence of numbers comprise input samples to a digital filter, the second input sequence of numbers comprise filter coefficients, and the convolution represents an output of the digital filter in response to the input samples.

11. A method of multiplying numbers, the method comprising:
identifying a first input sequence of numbers and a second input sequence of numbers;
directing the numbers in the first and second input sequences or parts of the numbers to a plurality of multipliers according to whether the numbers are complex or real, each multiplier capable of multiplying two numbers to generate an output;
when each of the first sequence of numbers is a complex number and each of the second sequence of numbers is a real number,
directing a first complex number in the first input sequence of numbers, a second complex number in the first input sequence of numbers, and a real number in the second input sequence of numbers to the multipliers, and
performing a first multiplication and a second multiplication in parallel, the first multiplication comprising multiplying the first complex number in the first input sequence with the real number in the second input sequence, the second multiplication comprising multiplying the second complex number in the first input sequence with the real number in the second input sequence.

12. The method of claim 11 in which the first input sequence of numbers comprise input samples to a digital filter, the second input sequence of numbers comprise filter coefficients.

13. The method of claim 12, further comprising accumulating partial products to calculate a convolution of the first input sequence and the second input sequence, the convolution representing an output of the digital filter in response to the input samples.

14. An apparatus comprising:
a processor to calculate a convolution of input samples with filter coefficients to generate a filter output response, the processor comprising a multiplier-accumulator unit that comprises:
multipliers, each to multiply a first input number and a second input number to generate a product;
multiplexers to receive the input samples and the filter coefficients and to direct the input samples and filter coefficients to the multipliers according to instruction codes specifying a computation mode, in which the processor is capable of executing instructions to perform computation in at least two computation modes:
in a first computation mode, each input sample is a complex number and each filter coefficient is a complex number, and the multiplexers direct the input samples and filter coefficients to the multipliers to enable multiplication of a complex input sample with a complex filter coefficient;
in a second computation mode, each input sample is a complex number and each filter coefficient is a real number, and the multiplexers direct the input samples and filter coefficients to the multipliers to enable a first multiplication of a first complex input sample with a real filter coefficient, and a second multiplication of a second complex input sample with the real filter coefficient, the first and second multiplications performed in parallel.

15. The apparatus of claim 14 in which the processor is capable of executing instructions to perform computation in a third computation mode in which each input sample is a real number and each filter coefficient is a real number, and the multiplexers direct the input samples and filter coefficients to the multipliers to enable a first multiplication of a first real input sample with a real filter coefficient, a second multiplication of a second real input sample with the real filter coefficient, a third multiplication of a third real input sample with the real filter coefficient, and a fourth multiplication of a fourth real input sample with the real filter coefficient, the first, second, third, and fourth multiplications performed in parallel.

16. The apparatus of claim 15 in which the multiplier-accumulator unit further comprises four multipliers, and in the third computation mode, the multiplexers direct the real filter coefficient to each of the four multipliers, direct the first real input sample to a first one of the four multipliers, direct the second real input sample to a second one of the four multipliers, direct the third real input sample to a third one of the four multipliers, and direct the fourth real input sample to a fourth one of the four multipliers.

17. The apparatus of claim 15 in which the multiplier-accumulator unit further comprises registers to store operands, and the multiplexers direct the operands or parts of the operands to the multipliers.

18. The apparatus of claim 17 in which in the first computation mode, one of the registers stores one complex input sample, and in the third computation mode, the register stores two real input samples.

19. The apparatus of claim 14 in which the multiplier-accumulator unit further comprises at least four multipliers.

20. The apparatus of claim 19 in which in the second computation mode, the multiplexers direct the real filter coefficient to each of the four multipliers, direct a real part of the first complex input sample to a first one of the four multipliers, direct an imaginary part of the first complex input sample to a second one of the four multipliers, direct a real part of the second complex input sample to a third one of the four multipliers, and direct an imaginary part of the second complex input sample to a fourth one of the four multipliers.

21. The apparatus of claim 14 in which the multiplier-accumulator unit further comprises registers to store operands, and the multiplexers direct the operands or parts of the operands to the multipliers.

22. The apparatus of claim 21 in which in the second computation mode, one of the registers stores one complex input sample and another one of the registers stores two real filter coefficients.

23. The apparatus of claim 14 in which the multiplier-accumulator unit further comprises pipeline stages, and each of the pipeline stages comprises one multiplier of the multipliers and one multiplexer of the multiplexers.

24. The apparatus of claim 14 in which the multiplier-accumulator unit uses an input sample to calculate an intermediate product of a first term of the filter output response in a first cycle, and reuses the same input sample to calculate an intermediate product of a second term of the filter output response in a second cycle.