Managing the MAC
The MAC, or “Multiply And Accumulate”, class of dual-operand DSP instructions are commonly used to perform the main Dot Product operation in Finite Impulse Response or FIR filters, as well as in several other DSP algorithms. The uniqueness of the instructions in this category is that they have a ‘split’ view of the data space, which enables them to access data from the X and Y data spaces simultaneously. The basic MAC operation is A = A + x*y, where A is an accumulator, and x and y are the source operands. The values x and y are obtained directly from two W registers, chosen from the subset W4 through W7. Concurrently, the x and y values, which may be required for a subsequent MAC instruction, can be pre-fetched from X and Y data space respectively, using Indirect Addressing. Either W8 or W9 may be used as a pointer into X data space, and either W10 or W11 may be used as a pointer into Y data space.
MAC = Multiply And Accumulate
- Basic operation is A = A + x*y
- Most fundamental operation used in DSP
- Requires two simultaneous reads from data memory
- Data memory is split into X and Y data memory
- Two reads, one multiply, one add, one write-back all performed in a single cycle
- Uses pre-defined W registers to accomplish this by pre-fetching
Data Memory Organization
The two data spaces, X and Y, are accessed using two Address Generation Units (X AGU and Y AGU) and separate data paths. These two AGUs are used simultaneously in order to facilitate dual-operand fetch for DSP instructions. It is important to keep in mind that the address boundaries of X and Y-spaces are device dependent.
Multiply and Accumulate
As shown in the diagram below, by repeatedly executing a MAC instruction, it is possible to obtain the sum-of-products, or dot product, of 2 arrays, denoted here as X and Y. In this figure, the actions and results of each MAC operation is demarcated by a different color. The X space data can alternatively be pre-fetched from program memory. Thus, it is possible to store some constant data (such as FIR filter coefficients or FFT twiddle factors) in Flash memory, thereby minimizing RAM usage.