Puneet Varma (Editor)

Wallace tree

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit
Wallace tree

A Wallace tree is an efficient hardware implementation of a digital circuit that multiplies two integers, devised by Australian Computer Scientist Chris Wallace in 1964.

Contents

The Wallace tree has three steps:

  1. Multiply (that is – AND) each bit of one of the arguments, by each bit of the other, yielding n 2 results. Depending on position of the multiplied bits, the wires carry different weights, for example wire of bit carrying result of a 2 b 3 is 32 (see explanation of weights below).
  2. Reduce the number of partial products to two by layers of full and half adders.
  3. Group the wires in two numbers, and add them with a conventional adder.

The second phase works as follows. As long as there are three or more wires with the same weight add a following layer:

  • Take any three wires with the same weights and input them into a full adder. The result will be an output wire of the same weight and an output wire with a higher weight for each three input wires.
  • If there are two wires of the same weight left, input them into a half adder.
  • If there is just one wire left, connect it to the next layer.
  • The benefit of the Wallace tree is that there are only O ( log n ) reduction layers, and each layer has O ( 1 ) propagation delay. As making the partial products is O ( 1 ) and the final addition is O ( log n ) , the multiplication is only O ( log n ) , not much slower than addition (however, much more expensive in the gate count). Naively adding partial products with regular adders would require O ( log 2 n ) time. From a complexity theoretic perspective, the Wallace tree algorithm puts multiplication in the class NC1.

    These computations only consider gate delays and don't deal with wire delays, which can also be very substantial.

    The Wallace tree can be also represented by a tree of 3/2 or 4/2 adders.

    It is sometimes combined with Booth encoding.

    Weights explained

    The weight of a wire is the radix (to base 2) of the digit that the wire carries. In general, a n b m – have indexes of n and m ; and since 2 n 2 m = 2 n + m the weight of a n b m is 2 n + m .

    Example

    n = 4 , multiplying a 3 a 2 a 1 a 0 by b 3 b 2 b 1 b 0 :

    1. First we multiply every bit by every bit:
    2. weight 1 – a 0 b 0
    3. weight 2 – a 0 b 1 , a 1 b 0
    4. weight 4 – a 0 b 2 , a 1 b 1 , a 2 b 0
    5. weight 8 – a 0 b 3 , a 1 b 2 , a 2 b 1 , a 3 b 0
    6. weight 16 – a 1 b 3 , a 2 b 2 , a 3 b 1
    7. weight 32 – a 2 b 3 , a 3 b 2
    8. weight 64 – a 3 b 3
    9. Reduction layer 1:
    10. Pass the only weight-1 wire through, output: 1 weight-1 wire
    11. Add a half adder for weight 2, outputs: 1 weight-2 wire, 1 weight-4 wire
    12. Add a full adder for weight 4, outputs: 1 weight-4 wire, 1 weight-8 wire
    13. Add a full adder for weight 8, and pass the remaining wire through, outputs: 2 weight-8 wires, 1 weight-16 wire
    14. Add a full adder for weight 16, outputs: 1 weight-16 wire, 1 weight-32 wire
    15. Add a half adder for weight 32, outputs: 1 weight-32 wire, 1 weight-64 wire
    16. Pass the only weight-64 wire through, output: 1 weight-64 wire
    17. Wires at the output of reduction layer 1:
    18. weight 1 – 1
    19. weight 2 – 1
    20. weight 4 – 2
    21. weight 8 – 3
    22. weight 16 – 2
    23. weight 32 – 2
    24. weight 64 – 2
    25. Reduction layer 2:
    26. Add a full adder for weight 8, and half adders for weights 4, 16, 32, 64
    27. Outputs:
    28. weight 1 – 1
    29. weight 2 – 1
    30. weight 4 – 1
    31. weight 8 – 2
    32. weight 16 – 2
    33. weight 32 – 2
    34. weight 64 – 2
    35. weight 128 – 1
    36. Group the wires into a pair of integers and an adder to add them.

    References

    Wallace tree Wikipedia