MULTIPLYING TWO INTEGERS

14.4 MULTIPLYING TWO INTEGERS

We now turn to the problem of multiplying two b-bit integers x =

and y =

By the definition of multiplication, the product is obtained as follows: -

Figure Addition mesh.

368 The Bit Complexity of Parallel Computations Chap. 14

where

x In other words x y = where is a binary number given by

Note that has exactly i zeros to the right of Since the product is expressed as the sum of a collection of binary integers, we can use our addition tree or addition mesh to perform the multiplication.

14.4.1 Multiplication Tree

We begin by considering the network in Fig. 14.6. For input integers arriving bit serially at a and g, the network behaves as follows:

and

This means that bit d at time i is the result of computing the and of two bits ( h and g) available at time i 1. One of these two bits (bit g) propagates down (as e ) while the other (bit h) cycles back (as f). The or of a and f is now computed to produce a new value for h. If input a is at all times, except for a single time unit where it is 1, then the left-hand side of the network serves to capture that 1 bit and maintain it as input to the right-hand side as long as needed. For simplicity, we represent the network of Fig.

14.6 as shown in Fig. 14.7 and refer to it as the A-box.

A multiplication tree for computing x y consists of an array of A-boxes A,,

Figure

14.6 Special-purpose network for capturing I-bit input.

14.4 Multiplying Two Integers

Figure 14.7 An A-box.

A,, .. . ,

followed by an addition tree with leaves. This is illustrated in Fig.

14.8 for b = 8. Initially, all inputs are set to zero. Integer x is now fed into the g input of the top A-box, one bit per time unit; thus, bit

is made available to box A, at time i. Similarly, integer y is fed into the a inputs of all A-boxes one bit per box such that is made available to

at time i. The first bit of the product emerges from the root after 1 + log b time units. Therefore, for the multiplication tree we have

14.4.2 Multiplication Mesh

Given that the two integers x and y to be multiplied arrive bit serially, we must ensure (as we did for the tree) that the strings

whose sum gives the product, are properly formed and fed into the mesh at correct times. Let us reexamine the addition mesh. In Fig. 14.5, SA-boxes with the same starting time fall on the same diagonal. We can say

that on diagonal j, the numbers to be added have to be fed into the network at time j. Now recall that

If is the input to an SA-box on diagonal j, then bit

must arrive at time i + j (since

has i zeros to the right of In Fig. 14.9, the pair of indices (i, m) below the boxes are interpreted as follows: bit

of must arrive at SA-box (i, m) on diagonal j

at time m = + j.

We are now ready to describe the multiplication mesh. It uses the A-box presented in the previous section as well as a delay network shown in Fig. 14.10. This

14.4 Multiplying Two

Figure 14.9 Transforming addition mesh into multiplication mesh.

Figure 14.10 A D-box.

network, which we call a D-box, has the following behavior:

that is, the output at time i is equal to the input at time i - 1. A D-box may be built using an and gate (or an or gate) both of whose inputs equal the bit to be delayed.

A multiplication mesh for b = 21 is shown in Fig. 14.11. It consists of the addition mesh of Fig. 14.5 augmented with A- and D-boxes. The bits of are fed, least significant bit first, into the top left corner. They circulate around the mesh in a snakelike fashion along the dashed lines. Bit

of y, on the other hand, is given as input to the A-box associated with SA-box (i, m) at time m - 1 when

reaches that box]. For the network of Fig. 14.1 1, both

are This means that the multiplication mesh has exactly the same requirements as the multiplication tree

and

14.5 Computing Prefix Sums 373

under the constant wire delay assumption. The multiplication mesh is, of course, faster when the signal propagation time along a wire grows as a function of the wire length.

We conclude this section by pointing out that the assumption made at the outset regarding the number of bits of x is really unnecessary. A b-bit multiplication tree or

mesh will operate correctly for an x with any bit size provided y has b bits. Thus, if x

has 1 bits, then

and

for both multipliers.