Write Booths algorithm. Also explain floating point arithmetic operation. Describe signal addition and subtraction in detail.


Q.) Write Booths algorithm. Also explain floating point arithmetic operation. Describe signal addition and subtraction in detail.

Subject: Computer Organization and Architecture

Booth's Algorithm

Booth's algorithm is a multiplication algorithm that multiplies two signed binary numbers in two's complement notation. The algorithm is efficient because it reduces the number of additions required to calculate the product. Here is the step-by-step approach to Booth's algorithm:

  1. Initialization: Let's consider two numbers, a multiplicand M and a multiplier Q. Also, let A be an accumulator initialized to zero, and Q-1 be a bit used for the Booth's algorithm, initialized to 0. The number of bits in A, Q, and M should be the same. Let count be initialized to the number of bits in Q.

  2. Examine Q0 and Q-1: Look at the least significant bit of Q (denoted as Q0) and the extra bit Q-1. There are four possible combinations: 00, 01, 10, and 11.

  3. Operation Decision: Depending on the combination of Q0 and Q-1, perform the following operations:

    • If Q0 Q-1 is 01, add M to A.
    • If Q0 Q-1 is 10, subtract M from A.
    • If Q0 Q-1 is 00 or 11, do nothing (these represent the same sign for two consecutive bits in Q).
  4. Arithmetic Shift: Perform an arithmetic right shift on the combined A, Q, and Q-1 bits. This means that A, Q, and Q-1 are treated as a single number, and they are all shifted to the right by one bit. The sign bit of A is retained.

  5. Decrement Counter: Decrease the count by 1.

  6. Loop or Terminate: If count is not zero, go back to step 2. Otherwise, terminate the algorithm. The result is in A and Q combined, with A holding the most significant bits and Q the least significant bits.

Example:

Let's multiply 3 (multiplicand) by -4 (multiplier) using Booth's algorithm.

Binary representations:
M = 0011 (3)
Q = 1100 (-4, in two's complement)
A = 0000 (initialized to zero)
Q-1 = 0 (initialized to zero)
count = 4 (since we're using 4-bit numbers)
Step A Q Q-1 Operation Comment
0 0000 1100 0 Initial values
1 0000 1100 0 Check Q0 Q-1 00 - do nothing
2 0000 0110 0 Shift right
3 0000 0110 0 Check Q0 Q-1 00 - do nothing
4 0000 0011 0 Shift right
5 0000 0011 0 Check Q0 Q-1 01 - add M to A
6 0011 0011 0 Shift right
7 0001 1001 1 Check Q0 Q-1 10 - subtract M from A
8 1110 1001 1 Shift right
9 1111 0100 1 Check Q0 Q-1 01 - add M to A
10 0010 0100 0 Shift right Final result (A and Q combined)

The final product is 00100100, which is -12 in decimal, as expected (since 3 * -4 = -12).

Floating Point Arithmetic Operation

Floating point arithmetic operations are used to perform calculations on real numbers that have a decimal point and can have a very wide range of values. The most common standard for representing floating point numbers is the IEEE 754 standard.

Floating point numbers are represented in three parts:

  1. Sign bit (S): Determines whether the number is positive or negative.
  2. Exponent (E): Encodes the magnitude of the number.
  3. Mantissa or Significand (M): Encodes the precision of the number.

The value of a floating point number is determined by the following formula:

[ V = (-1)^S \times 1.M \times 2^{(E - \text{bias})} ]

where bias is a fixed value determined by the format (for example, in IEEE 754 single precision, the bias is 127).

Example:

Consider the IEEE 754 single-precision floating point representation of the number 5.75:

S = 0 (positive)
E = 128 (with a bias of 127, so the actual exponent is 1)
M = 1.11 (in binary, which is 1.75 in decimal)

So, the value is:

[ V = (-1)^0 \times 1.11_2 \times 2^{(128 - 127)} = 1.75 \times 2^1 = 5.75 ]

Signal Addition and Subtraction

Signal addition and subtraction are fundamental operations in signal processing. They involve combining or removing signal amplitudes at corresponding points in time or space.

Signal Addition

To add two signals, you simply add their amplitudes point by point. If x(t) and y(t) are two signals, their sum z(t) is given by:

[ z(t) = x(t) + y(t) ]

Signal Subtraction

Similarly, to subtract one signal from another, you subtract their amplitudes point by point. If x(t) and y(t) are two signals, the result of subtracting y(t) from x(t) is z(t):

[ z(t) = x(t) - y(t) ]

Example:

Let's say we have two discrete-time signals:

x[n] = {1, 2, 3}
y[n] = {4, 5, 6}

The addition of x[n] and y[n] is:

z[n] = x[n] + y[n] = {1+4, 2+5, 3+6} = {5, 7, 9}

The subtraction of y[n] from x[n] is:

z[n] = x[n] - y[n] = {1-4, 2-5, 3-6} = {-3, -3, -3}

In both cases, the operations are performed element-wise.