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
ceil(log2(K * 2^M * 2^N)) = ceil(log2(K)) + M + N
For a 5x9x8 MAC unit, ceil(log2(5)) + 8 + 9 = 20 bits.
First, to perform a signed multiplication, the modified Baugh-Wooley form on slide 64 of
https://web.ece.ucsb.edu/~parhami/pres_folder/f31-book-arith-pres-pt3.pdf was used. A more clear representation of this method is shown at https://en.wikipedia.org/wiki/Binary_multiplier#Signed_integers with the exception of a missing 1 in the MSB of the last partial sum.
A corrected form for a 9-bit input `a` and an 8-bit input `b`: