Electronic – Need help figuring out simple multiplication hardware

alu

As a part of my Computer Organization course, I need write to write a simple program (in C) that mics the work of "refined multiplication hardware" just like one shown in "Computer Organization and Design", by D. A. Patterson and J. L. Hennessy. Picture is attached.
enter image description here

I have a hard time understanding how this multiplier works (book has very little explanation) and and if it works with signed numbers(2's complement)

Best Answer

That looks like a classic shift-and-add type multiplier. A proper explanation would require a lot of diagrams, which sadly I can't provide at the moment. In a nutshell, if you are multiplying A times B, you start with an 'accumulator' register set to zero. Then you put A in a shift register and iteratively do the following: shift A left one place and look at the bit that falls out; if it's a '1', then add B to the accumulator, otherwise, don't add B. If there are any more bits remaining in A, you shift the accumulator left one place and repeat. If A and B are 32 bit values, there will be 32 iterations of this shifting and accumulating. Note also that since 32 shifts will be involved, the accumulator has to be 64 bits, to accommodate the result.

An optimization that you sometimes see is to use the high 32 bits of the accumulator to hold the value of A; by the time any given bit in the accumulated product is needed, the remaining piece of the value of A will have been shifted out of the way. This just cuts down on the storage needed in implementation, but conceptually the same math is carried out.

I may have flubbed a detail in that hasty explanation, but the basic gist of it should be there.

Related Topic