Update mac_5x9x8 Revised authored by gling's avatar gling
We have defined a KxMxN MAC unit as a device which takes K signed M-bit numbers ($a_0, a_1, ..., a_{K-1}$) and K signed N-bit numbers ($b_0, b_1, ..., b_{K-1}$), and computes
$$ a_0*b_0 + a_1*b_1 + ... + a_{K-1}*b_{K-1} $$
For making an KxMxN MAC unit, the number of output bits will be
$$\lceil\log_2(K * 2^M * 2^N)\rceil = \lceil\log_2 K\rceil + M + N$$
For our specialized case of a 5x9x8 MAC unit, $\lceil\log_2 5\rceil + 9 + 8 = 20$ bits.
First, to perform a signed multiplication, we use the modified Baugh-Wooley form on slide 64 of
\url{https://web.ece.ucsb.edu/~parhami/pres_folder/f31-book-arith-pres-pt3.pdf}. A more clear representation of this method is shown at \url{https://en.wikipedia.org/wiki/Binary_multiplier#Signed_integers} with the exception of a missing 1 in the MSB of the last partial sum.
Using an example calculation with a 4-bit by 5-bit signed multiply with multiplicands `a` and `b`:
\begin{verbatim}
p0[4:0] = a[4:0] * b[0]
p1[4:0] = a[4:0] * b[1]
p2[4:0] = a[4:0] * b[2]
p3[4:0] = a[4:0] * b[3]
~p0[4] + p0[3] + p0[2] + p0[1] + p0[0]
~p0[4] + p0[3] + p0[2] + p0[1] + p0[0]
~p0[4] + p0[3] + p0[2] + p0[1] + p0[0]
~p0[4] + p0[3] + p0[2] + p0[1] + p0[0]
-----------------------------------------------------------------------
\end{verbatim}
We have defined a 5x9x8 MAC unit as a device which takes 5 signed 9-bit numbers (a0, ..., a4) and 5 signed 8-bit numbers (b0, ..., b4), and computes a0*b0 + a1*b1 + a2*b2 + a3*b3 + a4*b4. We have defined a 5x9x8 MAC unit as a device which takes 5 signed 9-bit numbers (a0, ..., a4) and 5 signed 8-bit numbers (b0, ..., b4), and computes a0*b0 + a1*b1 + a2*b2 + a3*b3 + a4*b4.
For making an KxMxN MAC unit, the number of output bits will be For making an KxMxN MAC unit, the number of output bits will be
... ...
......