Skip to content
Snippets Groups Projects
Select Git revision
  • d57600f7756e5092fb67fe526781e4f1a25a2dde
  • master default protected
2 results

distributed-arithmetic-mac

jf3g19's avatar
jf3g19 authored
d57600f7
History
Name Last commit Last update
DA.sv
DA_LUT.sv
DA_test.sv
README.md
generate_LUT.cpp

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 and X that you know the value of C 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]

output

We can see that after input ready goes high, 17 clock cycles later, output ready goes high with the correct value 278,511