Contents
Implementation of a Basic Distributed Arithmetic Architechture for MAC
Operation
-
The Distributed Arithmetic Architechture is based on the assumption that for a given Sum Of Products (SoP) between two arrays
C
andX
that you know the value ofC
at compile time. -
Based on this assumption we can generate a LUT which allows us to transform the SoP to a series of shifts and adds.
-
The File generate_LUT.cpp can be used to generate the LUT values for a given set of input coefficients. If you compile the file it can be run in the command line in the following format:
> generate_LUT [Multiplicand Bit-Width] [C[0]] [C[1]] [C[2]] [C[3]] .... [C[n]]
i.e
generate_LUT 16 -4 -3 1 9
would generate the LUT for the coefficients c[0] = -4, c[1] = -3, c[2] = 1, c[3] = 9, and a 16-bit Bit-Width for your Multiplicand.
The generate multiplication coefficients can be stored as an unpacked array of packed values and should be connected directly to the
multiplication_coefficients
input port.
Example
An Example ModelSim output for the testbench provided, which displays the inner product of
X = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
C = [ [-79 -136 312 654 -1244 -2280 4501 14655 14655 4501 -2280 -1244 654 312 -136 -79]
We can see that after input ready goes high, 17 clock cycles later, output ready goes high with the correct value 278,511