0

i'm investigating multiplication algorithms for a design im working on. I'm trying get an implementation of a 128 bit multiplier using the karasuba algorithm, however I'm not getting the results that I expect all the time, so I believe I'm still missing something about the algorithm that the papers are not saying or I'm still not able to see.

These are my main questions:

  1. according to this diagram:

enter image description here

, this is an implementation of a 2 bit karatsuba multiplier, and this is common logic that is explained everywhere. Now if I'm multiplying

3 x 3 = 9

`, with this logic I get

3 x 3 = 5

, so my first question is related to this result, does the karatsuba algorithm have any limitation? How should I interpret this result? when I use the 128 bit multiplier to get 23 x 234, the result is 3126 instead of 5382. 1024 x 187 works correctly, the result is 191488.

  1. second question, also related to this logic, and in general the algorithm. In this case, the middle term is calculated as:

enter image description here

, but in other places it is shown as:

enter image description here

, so i'm wondering what is the difference? I have done the math by hand using the second version, but it requires more bits than expected for a 2 bit multiplier and carry considerations. Again, I'm not sure if I'm missing something of how the algorithm should be applied.

Any help to clarify these question is going to be appreciated.

thanks.

toolic
  • 57,801
  • 17
  • 75
  • 117
  • I suggest you check for overflows. Also, for your second question, your second version is correct, the first is incorrect. It should be (x_L - x_H)(y_H - y_L) + a + b. – Simon Goater Aug 23 '23 at 10:23
  • Karatsuba often needs more than just single carry bit ... – Spektre Aug 26 '23 at 05:57

0 Answers0