2 Arithmetic And Logic Unit

Computer Organization and Architecture ยท Unit 2 ยท 8 hrs

Arithmetic and Logic Unit

Arithmetic and Logic Unit in short

The arithmetic and logic unit (ALU) does all the calculation inside the CPU. This unit shows how fast adders are built and how numbers are multiplied and divided. It also shows how real numbers are stored and how one ALU does many operations.

Arithmetic and Logic Unit: full notes

Look ahead carry adders

A full adder adds two bits and a carry-in. A ripple carry adder joins n full adders in a row. The carry of each stage goes to the next stage. The last sum bit must wait for all earlier carries, so the delay grows with n. If each carry stage takes two gate delays, a 4-bit adder needs about 8 gate delays for the final carry.

A look ahead carry adder removes this wait. It works out all carries at the same time from the inputs. For each bit i we define two helper signals.

  • Generate: $G_i = A_i B_i$. This stage makes a carry by itself.
  • Propagate: $P_i = A_i \oplus B_i$. This stage passes an incoming carry forward.

Then the sum and carry of every stage are:

$$S_i = P_i \oplus C_i \qquad C_{i+1} = G_i + P_i C_i$$

If we keep replacing the earlier carry, every carry depends only on the inputs and $C_0$:

$$\begin{aligned} C_1 &= G_0 + P_0 C_0 \ C_2 &= G_1 + P_1 G_0 + P_1 P_0 C_0 \ C_3 &= G_2 + P_2 G_1 + P_2 P_1 G_0 + P_2 P_1 P_0 C_0 \ C_4 &= G_3 + P_3 G_2 + P_3 P_2 G_1 + P_3 P_2 P_1 G_0 + P_3 P_2 P_1 P_0 C_0 \end{aligned}$$

Each of these is a two-level AND-OR circuit, so all carries appear after only two gate delays. One more delay for $P_i$ and $G_i$ and one for the final XOR gives a total of about four gate delays. This does not depend on the number of bits (for a fixed 4-bit block).

Example. Add $A = 1011$ and $B = 0110$ with $C_0 = 0$.

$$\begin{aligned} G &= A \cdot B = 0010 \ P &= A \oplus B = 1101 \ C_1 &= 0,; C_2 = 1,; C_3 = 1,; C_4 = 1 \ S &= P \oplus (C_3 C_2 C_1 C_0) = 1101 \oplus 1100 = 0001 \end{aligned}$$

With the final carry $C_4 = 1$, the answer is $10001 = 17$. This matches $11 + 6 = 17$.

The AND-OR circuit grows large for wide adders. So big adders use 4-bit look ahead blocks and join them. Each block gives a group generate and group propagate signal, and a second look ahead unit combines the blocks. A 16-bit adder is built from four 4-bit blocks this way.

Ripple carry adderLook ahead carry adder
Carry passes stage by stageAll carries found together
Delay grows with nDelay almost fixed
Simple and cheapMore gates, costly
Slow for wide wordsUsed in fast ALUs

Multiplication: signed operand multiplication, Booth's algorithm and array multiplier

Multiplication is repeated shifting and adding. For each 1 in the multiplier, a shifted copy of the multiplicand is added. For each 0, nothing is added.

Signed operand multiplication. The simplest method works on the sign-magnitude form. The sign of the product is the XOR of the two signs. The magnitudes are multiplied as unsigned numbers. For example, $(-5) \times (+3)$ gives sign $1 \oplus 0 = 1$ (negative) and magnitude $5 \times 3 = 15$, so the answer is $-15$. This method needs extra work to convert numbers. For numbers in 2's complement form, a direct method is better, and that is Booth's algorithm.

Booth's algorithm multiplies two signed 2's complement numbers without checking signs. It is based on one idea: a run of 1s in the multiplier, such as 0111100, equals $2^6 - 2^2$. So a long run of 1s can be handled by one subtraction at the start of the run and one addition just after the end. This is fast when the multiplier has long runs of 1s.

The hardware has the registers A (accumulator, starts at 0), Q (multiplier), $Q_{-1}$ (one extra bit, starts at 0) and M (multiplicand). A counter holds the number of bits n. In every cycle we look at the pair $Q_0 Q_{-1}$.

  • 10: start of a run of 1s, so $A \leftarrow A - M$.
  • 01: end of a run of 1s, so $A \leftarrow A + M$.
  • 00 or 11: middle of a run, so do nothing.

Then A, Q and $Q_{-1}$ are shifted right by one place as a single unit. This is an arithmetic shift, where the sign bit of A is copied. After n cycles, the pair A:Q holds the 2n-bit product.

The flowchart above shows the same loop: test $Q_0 Q_{-1}$, add or subtract, arithmetic shift right, decrement the counter, and repeat until it is zero.

Example. Multiply $M = -5$ by $Q = +3$ using 4 bits. Here $M = 1011$, $-M = 0101$ and $Q = 0011$.

Cycle$Q_0 Q_{-1}$OperationAQ$Q_{-1}$
Start000000110
110$A - M$, then shift001010011
211shift only000101001
301$A + M$, then shift111000100
400shift only111100010

In cycle 1, $A = 0000 + 0101 = 0101$. After the shift it becomes 0010, and the bit shifted out of Q becomes $Q_{-1}$. In cycle 3, $A = 0001 + 1011 = 1100$, which becomes 1110 after the shift. The final A:Q is $1111,0001$. This is $-15$ in 2's complement, since $-128 + 64 + 32 + 16 + 1 = -15$. Therefore $(-5) \times 3 = -15$.

A second check: $7 \times (-3)$ with $M = 0111$, $Q = 1101$ gives A:Q = $1110,1011 = -21$.

Array multiplier. A Booth multiplier is sequential and takes n clock cycles. An array multiplier is a combinational circuit that gives the whole product at once. It forms all partial products with AND gates and adds them with rows of adders.

For a multiplicand of j bits and a multiplier of k bits, the product has $j + k$ bits. The circuit needs $j \times k$ AND gates and $(k - 1)$ adders of j bits each. For a $2 \times 2$ multiplier with $a_1 a_0$ and $b_1 b_0$, we need 4 AND gates and 2 half adders:

              a1 a0
            x b1 b0
            --------
            a1b0 a0b0
       a1b1 a0b1
       ----------------
   c3  c2   c1   c0

A $4 \times 3$ multiplier needs $4 \times 3 = 12$ AND gates and two 4-bit adders, and gives a 7-bit product. The array is fast and regular, but the gate count grows with the product of the two sizes. For a $4 \times 4$ unit it uses 16 AND gates and three 4-bit adders.

Division and logic operations

Division gives a quotient and a remainder: $\text{Dividend} = \text{Divisor} \times \text{Quotient} + \text{Remainder}$. Hardware division works like long division on paper. At each place we try to subtract the divisor. If it fits, the quotient bit is 1. If not, it is 0.

The registers are A (remainder, starts at 0), Q (dividend, then quotient) and M (divisor). There are two common methods.

(a) Restoring division. In each of n cycles, shift A:Q left by one bit. Subtract M from A. If A becomes negative (sign bit 1), the subtraction was not possible. So we add M back (restore) and set the new quotient bit $Q_0 = 0$. Otherwise we keep A and set $Q_0 = 1$.

Example. Divide 13 by 3 using 4 bits. Here $Q = 1101$, $M = 00011$ and $-M = 11101$ (5-bit values for A).

CycleAfter shift (A, Q)$A - M$ActionAQ
Start000001101
100001, 101_11110 (negative)restore, $Q_0 = 0$000011010
200011, 010_00000keep, $Q_0 = 1$000000101
300000, 101_11101 (negative)restore, $Q_0 = 0$000001010
400001, 010_11110 (negative)restore, $Q_0 = 0$000010100

The quotient is $Q = 0100 = 4$ and the remainder is $A = 00001 = 1$. Check: $3 \times 4 + 1 = 13$.

(b) Non-restoring division. The restore step wastes time. Non-restoring division avoids it. In each cycle, look at the sign of A. If A is positive, shift left and subtract M. If A is negative, shift left and add M. The new quotient bit is 1 if A is now positive, and 0 if A is negative. If A is negative at the very end, add M once to correct the remainder.

The same example, 13 divided by 3:

CycleSign of A beforeOperation after shiftAQ
Start000001101
1positive$A - M$111101010
2negative$A + M$000000101
3positive$A - M$111011010
4negative$A + M$111100100
FinalA negative$A + M$000010100

The quotient is 4 and the remainder is 1, the same as before. Non-restoring division needs one add or subtract per cycle, so it is faster than restoring division, where a restore can need two.

RestoringNon-restoring
Restores A when result is negativeNever restores inside the loop
Up to two operations per cycleOne operation per cycle
Simple controlSlightly harder control
Remainder always correctFinal correction step may be needed

Logic operations. The ALU also works on bits, one bit position at a time. The main logic micro-operations are:

  • AND ($A \wedge B$): clears chosen bits (masking).
  • OR ($A \vee B$): sets chosen bits.
  • XOR ($A \oplus B$): flips chosen bits, and tests if two words differ.
  • Complement ($\bar{A}$): changes every 0 to 1 and every 1 to 0.

Example with $A = 1100,1010$ and mask $B = 0000,1111$. Then $A \wedge B = 0000,1010$ keeps the low nibble. Also $A \vee B = 1100,1111$ sets the low nibble to all ones.

Shift operations move the bits of a register. A logical shift puts 0 into the empty place. An arithmetic shift keeps the sign bit. Arithmetic shift right copies the sign bit and divides by 2. Arithmetic shift left multiplies by 2, and overflow occurs if the sign bit changes. A circular shift (rotate) feeds the bit that falls out back into the other end.

Floating point arithmetic operation

A floating point number is written as $\pm m \times 2^e$, where m is the mantissa (or significand) and e is the exponent. It can hold very large and very small values in a fixed number of bits. The mantissa is kept normalized, which means the first digit is non-zero (in binary, $1.xxx$).

Addition and subtraction. The exponents must be equal before the mantissas are added. The work goes in this order.

  • Check for zero operands.
  • Compare the exponents and align the mantissas. The number with the smaller exponent is shifted right until the exponents match.
  • Add or subtract the mantissas.
  • Normalize the result. If there is a carry out, shift right once and add 1 to the exponent. If leading zeros appear, shift left and subtract from the exponent.
  • Round the result, and check for overflow or underflow of the exponent.

Example. Add $13 = 1.101 \times 2^3$ and $3 = 1.1 \times 2^1$. The exponent difference is 2, so the smaller number is shifted right by 2 places.

$$\begin{aligned} 1.1 \times 2^1 &= 0.011 \times 2^3 \ 1.101 + 0.011 &= 10.000 \ &= 1.0000 \times 2^4 = 16 \end{aligned}$$

The sum overflowed into the next place, so the mantissa was shifted right once and the exponent rose from 3 to 4. This agrees with $13 + 3 = 16$.

Multiplication. Multiply the mantissas and add the exponents. Then normalize and round. In a biased format, the bias must be subtracted once from the sum of the two biased exponents. For example:

$$(1.1 \times 2^3) \times (1.01 \times 2^2) = (1.1 \times 1.01) \times 2^{3+2} = 1.111 \times 2^5 = 60$$

since $1.5 \times 1.25 = 1.875$ and $1.875 \times 32 = 60$.

Division. Divide the mantissas and subtract the exponents. Add the bias back to the result. Then normalize and round. Dividing by zero must be detected first, because it gives infinity.

OperationExponentMantissa
Add / subtractMust be made equal firstAdd or subtract after aligning
MultiplyAdd (then remove one bias)Multiply
DivideSubtract (then add bias)Divide

Floating point results can overflow (exponent too big) or underflow (exponent too small). Rounding can also lose small digits, so floating point arithmetic is not exact.

Arithmetic and logic unit design

An ALU is a combinational circuit that does many operations on two n-bit inputs. It is built in bit slices, so one slice is designed and then repeated n times. Each slice has an arithmetic circuit and a logic circuit, and a multiplexer chooses between them.

The arithmetic circuit is a parallel adder with a set of multiplexers on the B input. The select lines $S_1 S_0$ decide what is fed as the second operand: 0, B, $\bar{B}$ or all ones. The carry-in $C_{in}$ adds one more control. The result is $F = A + Y + C_{in}$. For a 4-bit slice, the functions are:

$S_1 S_0$$C_{in}$Y inputFunctionOperation
0000$F = A$Transfer A
0010$F = A + 1$Increment A
010B$F = A + B$Add
011B$F = A + B + 1$Add with carry
100$\bar{B}$$F = A + \bar{B}$A plus 1's complement of B
101$\bar{B}$$F = A - B$Subtract
110all 1s$F = A - 1$Decrement A
111all 1s$F = A$Transfer A

Subtraction works because $-B = \bar{B} + 1$ in 2's complement. The last row gives $A + (-1) + 1 = A$.

The logic circuit has gates for AND, OR, XOR and NOT on each bit, and a 4-to-1 multiplexer selects one result. Two select lines $S_1 S_0$ choose among $A \wedge B$, $A \vee B$, $A \oplus B$ and $\bar{A}$. A third select line (the mode) $S_2$ then picks arithmetic or logic output. In this way one unit gives the 8 arithmetic functions above and 4 logic functions.

The ALU also sets status flags in a status register:

  • C (carry): the last carry out of the top bit.
  • S (sign): the top bit of the result.
  • Z (zero): 1 if all result bits are 0.
  • V (overflow): 1 if the carry into the top bit and the carry out of it differ ($V = C_{n-1} \oplus C_n$).

Conditional branch instructions test these flags.

IEEE Standard for Floating Point Numbers

The IEEE 754 standard fixes the floating point format so that all computers give the same results. A number is stored as a sign bit, a biased exponent and a fraction.

FormatTotal bitsSignExponentFractionBias
Single precision321823127
Double precision64111521023

The value of a normal number is:

$$(-1)^S \times 1.F \times 2^{E - \text{bias}}$$

The leading 1 is not stored. It is the hidden bit, and it gives one extra bit of precision. The exponent is stored as $E = e + \text{bias}$, so it is always a positive number. This makes comparing two numbers easy.

Example 1. Convert $85.125$ to single precision.

$$\begin{aligned} 85.125 &= 1010101.001_2 \ &= 1.010101001 \times 2^6 \ E &= 6 + 127 = 133 = 10000101_2 \ F &= 01010100100000000000000 \end{aligned}$$

The number is positive, so S = 0. The 32-bit pattern is 0 10000101 01010100100000000000000, which is 42AA4000 in hexadecimal.

Example 2. Convert $-13.75$ to single precision.

$$\begin{aligned} 13.75 &= 1101.11_2 = 1.10111 \times 2^3 \ E &= 3 + 127 = 130 = 10000010_2 \end{aligned}$$

S = 1, so the pattern is 1 10000010 10111000000000000000000, which is C15C0000. In double precision the exponent is $3 + 1023 = 1026 = 10000000010_2$, and the number is C02B800000000000.

Example 3. Decode C1D80000. In binary it is 1 10000011 10110000000000000000000. The sign is negative. The exponent is $131 - 127 = 4$. The mantissa is $1.1011_2 = 1.6875$. The value is $-1.6875 \times 16 = -27$.

Special values use the extreme exponent codes (single precision shown):

ExponentFractionMeaning
All 0s (0)0Zero (+0 or -0)
All 0s (0)Not 0Denormalized number, value $0.F \times 2^{-126}$
1 to 254AnyNormal number
All 1s (255)0Infinity (+ or -)
All 1s (255)Not 0NaN (not a number), such as $0/0$

Range. The largest single precision number is about $3.4 \times 10^{38}$. The smallest normal number is $2^{-126} \approx 1.18 \times 10^{-38}$. The smallest denormal is $2^{-149} \approx 1.4 \times 10^{-45}$. Double precision reaches about $1.8 \times 10^{308}$. Denormal numbers let values shrink gradually towards zero instead of jumping to zero.

IEEE 754 also defines rounding modes. The default is round to nearest, ties to even. Many decimals, such as 0.1, cannot be stored exactly in binary. So $0.1$ becomes 3DCCCCCD in single precision, which is a very close value but not exact.

Key points to remember

  • A look ahead adder finds all carries at once. It uses $G_i = A_iB_i$, $P_i = A_i \oplus B_i$ and $C_{i+1} = G_i + P_iC_i$.
  • Booth's algorithm tests $Q_0 Q_{-1}$: 10 subtracts M, 01 adds M, then an arithmetic shift right. It works for signed 2's complement numbers.
  • An array multiplier of j by k bits needs $j \times k$ AND gates and $(k-1)$ adders of j bits.
  • Restoring division puts A back after a failed subtraction. Non-restoring division adds M when A is negative and subtracts when positive.
  • Floating point addition: align exponents, add mantissas, normalize, round.
  • Subtraction in the ALU is $A + \bar{B} + 1$.
  • IEEE 754 single: 1, 8, 23 bits with bias 127. Double: 1, 11, 52 bits with bias 1023.
  • Exponent all 1s means infinity or NaN. Exponent all 0s means zero or denormal.

What this unit covers

  • Look ahead carries adders
  • Multiplication: Signed operand multiplication, Booths algorithm and array multiplier
  • Division and logic operations
  • Floating point arithmetic operation
  • Arithmetic & logic unit design
  • IEEE Standard for Floating Point Numbers

Look ahead carries adders

2025-262 marks

Explain the working of carry look-ahead adder with the help of an example.

Show solved answer

A carry look-ahead adder finds all carries at once. It uses $G_i = A_iB_i$ and $P_i = A_i \oplus B_i$, with $C_{i+1} = G_i + P_iC_i$ and $S_i = P_i \oplus C_i$.

Example: add $A = 1011$ and $B = 0110$ with $C_0 = 0$. Here $G = 0010$ and $P = 1101$ (bit 3 to bit 0). The look-ahead equations give $C_1 = 0$, $C_2 = G_1 = 1$, $C_3 = G_2 + P_2G_1 = 1$ and $C_4 = 1$. The sums $P_i \oplus C_i$ are $S_3S_2S_1S_0 = 0001$, so the result is $10001 = 17$, which equals $11 + 6$.

Open this answer on its own page โ†’
2024-257 marks

Explain the concept of look-ahead carry adders in digital arithmetic circuits. Compare and contrast their performance with conventional ripple carry adders, highlighting advantages and disadvantages?

Show solved answer

A look-ahead carry adder finds all carry bits at the same time, directly from the inputs. For each bit $i$ it uses the generate signal $G_i = A_iB_i$ and the propagate signal $P_i = A_i \oplus B_i$. Then:

$$S_i = P_i \oplus C_i \qquad C_{i+1} = G_i + P_iC_i$$

If we replace each carry by the one before it, every carry depends only on $G$, $P$ and $C_0$:

$$C_1 = G_0 + P_0C_0$$

$$C_2 = G_1 + P_1G_0 + P_1P_0C_0$$

$$C_3 = G_2 + P_2G_1 + P_2P_1G_0 + P_2P_1P_0C_0$$

Each of these is a two-level AND-OR circuit. So all carries are ready after two gate delays, and they do not wait for each other.

A ripple carry adder is a chain of full adders. The carry out of each stage is the carry in of the next one. The last sum bit is ready only after the carry has passed through all $n$ stages. For a 4-bit adder with two gate delays per stage, this takes about 8 gate delays.

Comparison

PointRipple carry adderLook-ahead carry adder
Carry calculationone stage after anotherall together
Delaygrows with $n$ (about $2n$ gate delays)almost constant, about 4 gate delays for 4 bits
Hardwarevery simple, $n$ full addersmore gates and a look-ahead unit
Gate fan-in2 or 3 inputsgrows with $n$
Cost and sizelowhigh
Usesmall, cheap circuitsfast processors

Advantages of the look-ahead adder: it is much faster, and the speed is nearly independent of word length for one block.

Disadvantages: it needs many more gates, so it costs more and uses more power. For long words the AND and OR gates need too many inputs, so in practice the adder is built from 4-bit blocks joined by a second level of look-ahead.

Open this answer on its own page โ†’
2023-247 marks

Explain in detail the principle of carry look ahead adder and design 4-bit CLA adder.

Show solved answer

A ripple carry adder is slow, because each stage waits for the carry of the stage before it. A carry look-ahead adder (CLA) finds all the carries at the same time, directly from the inputs.

For each bit $i$ we define two signals. The generate signal $G_i = A_iB_i$ means this stage makes a carry on its own. The propagate signal $P_i = A_i \oplus B_i$ means this stage passes an incoming carry on. Then:

$$S_i = P_i \oplus C_i \qquad C_{i+1} = G_i + P_iC_i$$

Replacing each carry by the equation of the stage before gives the carries of a 4-bit adder in terms of $G$, $P$ and $C_0$ only:

$$C_1 = G_0 + P_0C_0$$

$$C_2 = G_1 + P_1G_0 + P_1P_0C_0$$

$$C_3 = G_2 + P_2G_1 + P_2P_1G_0 + P_2P_1P_0C_0$$

$$C_4 = G_3 + P_3G_2 + P_3P_2G_1 + P_3P_2P_1G_0 + P_3P_2P_1P_0C_0$$

Each carry is a two-level AND-OR circuit. So all four carries are ready after the same two gate delays.

Design of the 4-bit CLA. The circuit has three layers. The first layer has an AND gate and an XOR gate for each bit. They give $G_i$ and $P_i$. The second layer is the look-ahead logic that makes $C_1$ to $C_4$ from the four equations above. The third layer has four XOR gates that give $S_i = P_i \oplus C_i$.

   A3B3   A2B2   A1B1   A0B0
    |      |      |      |
  [AND,XOR] x4  ->  G3..G0, P3..P0
    |      |      |      |
  +--------------------------+
  | look-ahead carry logic   |<-- C0
  | C1  C2  C3  C4           |
  +--------------------------+
    |C3    |C2    |C1    |C0
  [XOR]  [XOR]  [XOR]  [XOR]
    S3     S2     S1     S0

The delay is about 4 gate delays in total (one for $P,G$, two for the carries, one for the XOR). A 4-bit ripple carry adder needs about 8. The price is more gates, and wider AND-OR gates for longer words. So big adders use 4-bit CLA blocks joined together.

Open this answer on its own page โ†’
2022-2310 marks

Describe the derivation procedure of look ahead carry adder by an example with the help of block diagram.

Show solved answer

Deriving the carry equations

A full adder adds the bits $A_i$ and $B_i$ and the carry $C_i$. Its carry out is:

$$C_{i+1} = A_iB_i + (A_i \oplus B_i)C_i$$

We give the two parts names. The generate term $G_i = A_iB_i$ means that the stage creates a carry by itself. The propagate term $P_i = A_i \oplus B_i$ means that the stage passes the carry on. The equations become:

$$C_{i+1} = G_i + P_iC_i \qquad S_i = P_i \oplus C_i$$

Now we replace each carry by the equation of the stage before it, one at a time.

$$C_1 = G_0 + P_0C_0$$

$$C_2 = G_1 + P_1C_1 = G_1 + P_1G_0 + P_1P_0C_0$$

$$C_3 = G_2 + P_2C_2 = G_2 + P_2G_1 + P_2P_1G_0 + P_2P_1P_0C_0$$

$$C_4 = G_3 + P_3G_2 + P_3P_2G_1 + P_3P_2P_1G_0 + P_3P_2P_1P_0C_0$$

After the substitution, no carry depends on another carry. Each one depends only on $G$, $P$ and $C_0$, so all can be built as two-level AND-OR circuits and are ready at the same time.

Block diagram

   A3 B3   A2 B2   A1 B1   A0 B0
    |  |    |  |    |  |    |  |
  [ P/G ] [ P/G ] [ P/G ] [ P/G ]   P = A xor B, G = A.B
    |  |    |  |    |  |    |  |
    |  +----+--+----+--+----+--+--> look-ahead carry unit
    |       |       |       |        (C1, C2, C3, C4 from
    |       |       |       |         all P, G and C0)
  [XOR]   [XOR]   [XOR]   [XOR] <--- C3, C2, C1, C0
    |       |       |       |
    S3      S2      S1      S0          C4 = carry out

Example. Add $A = 0111$ and $B = 0011$ with $C_0 = 1$.

Bit iABG = ABP = A xor B
01110
11110
21001
30000

The look-ahead equations give:

$$C_1 = G_0 + P_0C_0 = 1 + 0 = 1$$

$$C_2 = G_1 + P_1G_0 + P_1P_0C_0 = 1 + 0 + 0 = 1$$

$$C_3 = G_2 + P_2G_1 + P_2P_1G_0 + P_2P_1P_0C_0 = 0 + 1 + 0 + 0 = 1$$

$$C_4 = G_3 + P_3G_2 + \dots = 0$$

The sums are $S_i = P_i \oplus C_i$, so $S_0 = 0 \oplus 1 = 1$, $S_1 = 0 \oplus 1 = 1$, $S_2 = 1 \oplus 1 = 0$ and $S_3 = 0 \oplus 1 = 1$. The result is $S_3S_2S_1S_0 = 1011$ with carry out $0$. Therefore $7 + 3 + 1 = 11 = 1011_2$.

Open this answer on its own page โ†’
2020-2110 marks

Explain in detail the principle of carry look ahead adder and design 4-bit CLA adder.

Show solved answer

A ripple carry adder is slow because each full adder waits for the carry of the stage before it. For $n$ bits, the delay grows with $n$. A carry look-ahead adder (CLA) removes this wait. It calculates every carry directly from the inputs, at the same time.

For each bit position $i$ we define two signals. The generate signal $G_i = A_i B_i$ says that this stage makes a carry on its own. The propagate signal $P_i = A_i \oplus B_i$ says that this stage passes an incoming carry forward. The sum and the next carry are then:

$$S_i = P_i \oplus C_i$$

$$C_{i+1} = G_i + P_i C_i$$

If we keep replacing the earlier carry in this equation, every carry depends only on $G$, $P$ and $C_0$:

$$C_1 = G_0 + P_0 C_0$$

$$C_2 = G_1 + P_1 G_0 + P_1 P_0 C_0$$

$$C_3 = G_2 + P_2 G_1 + P_2 P_1 G_0 + P_2 P_1 P_0 C_0$$

$$C_4 = G_3 + P_3 G_2 + P_3 P_2 G_1 + P_3 P_2 P_1 G_0 + P_3 P_2 P_1 P_0 C_0$$

Each of these is a two-level AND-OR circuit. So all four carries appear after the same two gate delays, no matter which bit it is. The 4-bit CLA is built from these parts: four half-adder style gates that make $P_i$ and $G_i$, one look-ahead logic block that holds the four equations above, and four XOR gates that make the sums.

 A3B3  A2B2  A1B1  A0B0
  |     |     |     |
 [P,G] [P,G] [P,G] [P,G]   (AND gate gives G, XOR gives P)
  |     |     |     |
 +-----------------------+
 |  look-ahead carry     |<-- C0
 |  logic (C1, C2, C3,C4)|--> C4
 +-----------------------+
  |C3   |C2   |C1   |C0
 [XOR] [XOR] [XOR] [XOR]    (S = P xor C)
  |     |     |     |
  S3    S2    S1    S0

Example. Add $A = 1011$ and $B = 0110$ with $C_0 = 0$. The bitwise values, from bit 0 to bit 3, are:

Bit iABG = ABP = A xor B
01001
11110
20101
31001

Using the look-ahead equations with $C_0 = 0$:

$$C_1 = G_0 + P_0 C_0 = 0$$

$$C_2 = G_1 + P_1 G_0 + P_1 P_0 C_0 = 1$$

$$C_3 = G_2 + P_2 G_1 + P_2 P_1 G_0 + P_2 P_1 P_0 C_0 = 0 + 1 + 0 + 0 = 1$$

$$C_4 = G_3 + P_3 G_2 + P_3 P_2 G_1 + \dots = 0 + 0 + 1 + 0 + 0 = 1$$

The sum bits are $S_i = P_i \oplus C_i$. This gives $S_0 = 1 \oplus 0 = 1$, $S_1 = 0 \oplus 0 = 0$, $S_2 = 1 \oplus 1 = 0$ and $S_3 = 1 \oplus 1 = 0$. With the final carry $C_4 = 1$, the result is $10001$. Therefore $11 + 6 = 17$, which matches.

Speed. Making $P$ and $G$ takes one gate delay, the look-ahead block takes two, and the last XOR takes one. The total is about 4 gate delays for any $n$ that fits in one block. A 4-bit ripple adder needs about 8. The cost is more gates, and the AND-OR gates need more inputs as $n$ grows, so large adders use several 4-bit CLA blocks joined in groups.

Open this answer on its own page โ†’
2019-2010 marks

Design a 4-bit Carry-Look ahead Adder and explain its operation with an example.

Show solved answer

A ripple carry adder is slow because each full adder waits for the carry of the stage before it. For $n$ bits, the delay grows with $n$. A carry look-ahead adder (CLA) removes this wait. It calculates every carry directly from the inputs, at the same time.

For each bit position $i$ we define two signals. The generate signal $G_i = A_i B_i$ says that this stage makes a carry on its own. The propagate signal $P_i = A_i \oplus B_i$ says that this stage passes an incoming carry forward. The sum and the next carry are then:

$$S_i = P_i \oplus C_i$$

$$C_{i+1} = G_i + P_i C_i$$

If we keep replacing the earlier carry in this equation, every carry depends only on $G$, $P$ and $C_0$:

$$C_1 = G_0 + P_0 C_0$$

$$C_2 = G_1 + P_1 G_0 + P_1 P_0 C_0$$

$$C_3 = G_2 + P_2 G_1 + P_2 P_1 G_0 + P_2 P_1 P_0 C_0$$

$$C_4 = G_3 + P_3 G_2 + P_3 P_2 G_1 + P_3 P_2 P_1 G_0 + P_3 P_2 P_1 P_0 C_0$$

Each of these is a two-level AND-OR circuit. So all four carries appear after the same two gate delays, no matter which bit it is. The 4-bit CLA is built from these parts: four half-adder style gates that make $P_i$ and $G_i$, one look-ahead logic block that holds the four equations above, and four XOR gates that make the sums.

 A3B3  A2B2  A1B1  A0B0
  |     |     |     |
 [P,G] [P,G] [P,G] [P,G]   (AND gate gives G, XOR gives P)
  |     |     |     |
 +-----------------------+
 |  look-ahead carry     |<-- C0
 |  logic (C1, C2, C3,C4)|--> C4
 +-----------------------+
  |C3   |C2   |C1   |C0
 [XOR] [XOR] [XOR] [XOR]    (S = P xor C)
  |     |     |     |
  S3    S2    S1    S0

Example. Add $A = 1011$ and $B = 0110$ with $C_0 = 0$. The bitwise values, from bit 0 to bit 3, are:

Bit iABG = ABP = A xor B
01001
11110
20101
31001

Using the look-ahead equations with $C_0 = 0$:

$$C_1 = G_0 + P_0 C_0 = 0$$

$$C_2 = G_1 + P_1 G_0 + P_1 P_0 C_0 = 1$$

$$C_3 = G_2 + P_2 G_1 + P_2 P_1 G_0 + P_2 P_1 P_0 C_0 = 0 + 1 + 0 + 0 = 1$$

$$C_4 = G_3 + P_3 G_2 + P_3 P_2 G_1 + \dots = 0 + 0 + 1 + 0 + 0 = 1$$

The sum bits are $S_i = P_i \oplus C_i$. This gives $S_0 = 1 \oplus 0 = 1$, $S_1 = 0 \oplus 0 = 0$, $S_2 = 1 \oplus 1 = 0$ and $S_3 = 1 \oplus 1 = 0$. With the final carry $C_4 = 1$, the result is $10001$. Therefore $11 + 6 = 17$, which matches.

Speed. Making $P$ and $G$ takes one gate delay, the look-ahead block takes two, and the last XOR takes one. The total is about 4 gate delays for any $n$ that fits in one block. A 4-bit ripple adder needs about 8. The cost is more gates, and the AND-OR gates need more inputs as $n$ grows, so large adders use several 4-bit CLA blocks joined in groups.

Open this answer on its own page โ†’

Multiplication

2025-262 marks

Explain signed number multiplication using Booth's Algorithm. Multiply A x B where A= -5 and B=3 using Booth's Algorithm.

Show solved answer

Booth's algorithm multiplies signed 2's complement numbers. For each bit pair $Q_0Q_{-1}$: $10$ subtracts $M$, $01$ adds $M$, otherwise nothing. Then it shifts right (ASR).

Here $M = -5 = 1011$, $-M = 0101$ and $Q = 3 = 0011$.

CycleActionAQQ-1
1A - M001010011
2shift000101001
3A + M111000100
4shift111100010

$AQ = 11110001 = -15$. Therefore $(-5) \times 3 = -15$.

Open this answer on its own page โ†’
2025-267 marks

Multiply the following numbers using Array Multiplier technique: A = 1101, B = 1011

Show solved answer

An array multiplier makes all the partial products at the same time with AND gates, and adds them with a regular array of adders. Here $A = 1101$ ($13$) is the multiplicand and $B = 1011$ ($11$) is the multiplier.

Each bit of $B$ is ANDed with every bit of $A$. If the multiplier bit is 1, the row is a copy of $A$. If it is 0, the row is all zeros. Each row is shifted one place left from the one above it:

RowMultiplier bitPartial product
PP0$b_0 = 1$00001101
PP1$b_1 = 1$00011010
PP2$b_2 = 0$00000000
PP3$b_3 = 1$01101000

Now the rows are added column by column. In hardware, this is done by full adders and half adders arranged in a grid. The carry of each adder goes to the next column, and the sum goes to the adder in the row below.

$$00001101 + 00011010 = 00100111$$

$$00100111 + 00000000 = 00100111$$

$$00100111 + 01101000 = 10001111$$

Therefore $1101 \times 1011 = 10001111_2$, which is $128 + 8 + 4 + 2 + 1 = 143$. Check: $13 \times 11 = 143$.

Structure. For an $n \times n$ multiplier, the array needs $n^2$ AND gates and about $n(n-1)$ adders. For 4 bits this means 16 AND gates and 12 adders (a mix of full adders and half adders). All partial products are formed in one gate delay. The total delay is the time for a carry and a sum to pass through the array, which grows in proportion to $n$.

Advantages. The design is regular and easy to lay out on a chip. It needs no clock or control unit, since it is purely combinational. It is much faster than the shift-and-add method, which needs $n$ clock cycles.

Disadvantage. The hardware grows as $n^2$, so large multipliers need a lot of area.

Open this answer on its own page โ†’
2024-257 marks

Describe Booth's algorithm for signed binary multiplication. Explain how it optimizes the multiplication process and discuss its advantages over traditional methods?

Show solved answer

Booth's algorithm multiplies two signed numbers in 2's complement form. Its idea is that a run of 1s in the multiplier, such as $0111100$, equals a difference of two powers of 2:

$$2^{6} - 2^{2} = 64 - 4 = 60 = 0111100_2$$

So instead of adding $M$ for every 1 bit, we subtract $M$ at the start of the run and add $M$ after its end.

Procedure. The multiplicand is kept in $M$. The multiplier is kept in $Q$, with an extra bit $Q_{-1} = 0$ on its right. $A$ is cleared to 0. We repeat the following $n$ times, once for each bit of the multiplier. If $Q_0Q_{-1}$ is $10$, we do $A = A - M$. If it is $01$, we do $A = A + M$. If it is $00$ or $11$, we do nothing. Then we shift $A$, $Q$ and $Q_{-1}$ right by one place, keeping the sign of $A$ (arithmetic shift right, ASR). At the end, $AQ$ holds the $2n$-bit product.

Example. Multiply $(+7) \times (-3)$ with 4-bit registers. Here $M = 0111$, $-M = 1001$ and $Q = 1101$.

CycleQ0 Q-1OperationAQQ-1
Start-initial000011010
11 0A = A - M, ASR110011101
20 1A = A + M, ASR000111110
31 0A = A - M, ASR110101111
41 1no change, ASR111010111

So $AQ = 11101011$. The leading bit is 1, so the product is negative. Its 2's complement is $00010101 = 21$. Therefore $(+7) \times (-3) = -21$.

How it optimises multiplication. Long runs of equal bits in the multiplier need no additions at all, only shifts. For example, a multiplier with eight 1s in a row needs only one subtraction and one addition, instead of eight additions.

Advantages over the traditional method.

  • It handles positive and negative numbers with the same circuit, so no separate sign logic is needed.
  • It works directly on 2's complement numbers, so no correction step is needed for a negative multiplier.
  • It is faster when the multiplier has long runs of 1s.
  • The control is simple, with one add or subtract and one shift per cycle.

The worst case is a multiplier with alternating bits, like $0101$, where every cycle needs an add or subtract. Then Booth's method is no faster than shift-and-add.

Open this answer on its own page โ†’
2024-257 marks

Discuss the process of signed operand multiplication in digital arithmetic circuits?

Show solved answer

Signed operand multiplication means multiplying numbers that may be positive or negative. There are three common ways.

Sign-magnitude method. The sign and the magnitude are handled separately. The sign of the product is the XOR of the two signs. The magnitudes are multiplied by the shift-and-add method. For example, $5 \times (-3)$: the magnitudes are $101$ and $011$. Adding the shifted copies gives:

$$101 + 1010 = 1111 = 15$$

The signs are $0 \oplus 1 = 1$, so the product is negative. Therefore $5 \times (-3) = -15$.

2's complement method. The numbers are kept in 2's complement form. The multiplicand is first sign-extended to the length of the product. If the multiplier is negative, its leftmost bit has the negative weight $-2^{n-1}$. So the partial product made by that bit is subtracted and not added. For $5 \times (-3)$, the multiplier is $1101$, and the multiplicand is $0101$. The bit weights are $-8, +4, 0, +1$, so:

$$5 \times (-3) = 5 \times 1 + 5 \times 4 - 5 \times 8 = 5 + 20 - 40 = -15$$

This avoids converting the multiplier to a positive number.

Booth's algorithm. It handles signed multipliers in a single uniform procedure. Each cycle checks the pair $Q_0Q_{-1}$. The pair $10$ subtracts the multiplicand, the pair $01$ adds it, and the pairs $00$ and $11$ do nothing. After each cycle $A$, $Q$ and $Q_{-1}$ are shifted right with the sign of $A$ kept. After $n$ cycles, the $2n$-bit product is in $AQ$. It needs no separate sign logic, and it skips runs of equal bits.

Comparison

MethodSign handlingExtra work
Sign-magnitudeXOR of the signssign must be fixed at the end
2's complementnegative weight of the sign bitsubtract the last partial product
Boothautomaticnone

In all methods the product of two $n$-bit numbers needs $2n$ bits. Hardware multipliers usually use Booth's algorithm or its improved form, because it is simple and works for both signs.

Open this answer on its own page โ†’
2023-242 marks

Name the different types of multipliers.

Show solved answer

A multiplier is the circuit or method that multiplies two binary numbers. The main types are:

  • Shift-and-add (sequential) multiplier: it adds the multiplicand to a partial product once for each 1 bit of the multiplier, and shifts after each step.
  • Booth multiplier: it works on signed 2's complement numbers and skips strings of 0s and 1s.
  • Array multiplier: it uses a grid of AND gates and adders to make the product in one pass.
  • Wallace tree multiplier: it adds the partial products with a tree of carry-save adders, which is faster.
Open this answer on its own page โ†’
2023-247 marks

Show the multiplication process using Booth's algorithm when the following numbers are multiplied: (-12) * (-18).

Show solved answer

We use 6-bit registers, because $-18$ needs 6 bits in 2's complement. The numbers are:

$$M = -12 = 110100 \qquad -M = +12 = 001100 \qquad Q = -18 = 101110$$

$A$ and $Q_{-1}$ start at 0. In each cycle we read the pair $Q_0Q_{-1}$. The pair $10$ means $A = A - M$. The pair $01$ means $A = A + M$. The pairs $00$ and $11$ mean no operation. Then $A$, $Q$ and $Q_{-1}$ shift one place right with the sign bit of $A$ copied (arithmetic shift right, ASR). There are 6 cycles.

CycleQ0 Q-1OperationAQQ-1
Start-initial0000001011100
10 0no change, ASR0000000101110
21 0A = A - M, ASR0001100010111
31 1no change, ASR0000110001011
41 1no change, ASR0000011000101
50 1A = A + M, ASR1110101100010
61 0A = A - M, ASR0000110110001

The product is in $AQ$ joined:

$$AQ = 000011011000$$

The leading bit is 0, so the product is positive. Its value is:

$$2^7 + 2^6 + 2^4 + 2^3 = 128 + 64 + 16 + 8 = 216$$

Therefore $(-12) \times (-18) = +216$.

Check: $12 \times 18 = 216$, and two negative numbers give a positive product, so the answer is correct. Booth's algorithm gave the correct sign without any separate sign handling, because it works on 2's complement numbers directly. Cycles 1, 3 and 4 needed no addition or subtraction, so the multiplier $101110$ was handled with only three arithmetic operations instead of four.

Open this answer on its own page โ†’
2022-2310 marks

Show the systematic multiplication process of (-15) x (-16) using Booth's Algorithm.

Show solved answer

Both numbers need 5 bits in 2's complement. The numbers are:

$$M = -15 = 10001 \qquad -M = +15 = 01111 \qquad Q = -16 = 10000$$

$A$ starts at $00000$ and $Q_{-1}$ at 0. In every cycle we look at the pair $Q_0Q_{-1}$. The pair $10$ means $A = A - M$. The pair $01$ means $A = A + M$. The pairs $00$ and $11$ mean no operation. After that, $A$, $Q$ and $Q_{-1}$ shift one place right together, and the sign bit of $A$ is copied (arithmetic shift right, ASR). The loop runs 5 times, once for each bit of the multiplier. After the 5 cycles, the 10-bit product is ready, because two 5-bit numbers give a result of at most 10 bits.

CycleQ0 Q-1OperationAQQ-1
Start-initial00000100000
10 0no change, ASR00000010000
20 0no change, ASR00000001000
30 0no change, ASR00000000100
40 0no change, ASR00000000010
51 0A = A - M, ASR00111100001

The product is in $AQ$ joined:

$$AQ = 0011110000$$

The leading bit is 0, so the result is positive. Its value is:

$$2^7 + 2^6 + 2^5 + 2^4 = 128 + 64 + 32 + 16 = 240$$

Therefore $(-15) \times (-16) = +240$.

This example is short because the multiplier $-16 = 10000$ has four zeros in a row at the right. In the first four cycles the pair is $00$, so only shifts happen. In cycle 5, the pair is $10$, since the lowest 1 has reached $Q_0$ while $Q_{-1}$ is 0. So $M$ is subtracted. Subtracting $M = -15$ means adding $+15$, which gives $A = 01111$. After the last shift, this becomes $00111$.

The multiplier is worth a single signed digit $-1$ at bit position 4, that is $-16$. So the product is $(-15) \times (-16) = +240$, with the factor $2^4$ coming from the shifts. The sign comes out positive on its own, with no separate sign logic. Every cycle of the table works on 2's complement numbers directly, so negative multiplicands and multipliers need no special treatment, unlike sign-magnitude multiplication. If the multiplier is read as $-16$, only one subtraction is needed, so Booth's method is very efficient for such numbers. The check is $15 \times 16 = 240$ and the two negative signs give a positive result, so the answer is correct.

Open this answer on its own page โ†’
2021-2210 marks

Show the multiplication process using Booth algorithm, when the following binary numbers, (+13) x (-15) are multiplied.

Show solved answer

We need 5-bit registers, because $-15$ needs 5 bits in 2's complement. The numbers are:

$$M = +13 = 01101 \qquad -M = 10011 \qquad Q = -15 = 10001$$

$A$ starts at $00000$ and $Q_{-1}$ at 0. In each cycle, we look at $Q_0$ and $Q_{-1}$. The pair $10$ means $A = A - M$ (we add $-M$). The pair $01$ means $A = A + M$. The pairs $00$ and $11$ mean no operation. Then $A$, $Q$ and $Q_{-1}$ shift one place right as a whole, and the sign bit of $A$ is copied (arithmetic shift right, ASR). There are 5 cycles, one for each multiplier bit.

CycleQ0 Q-1OperationAQQ-1
Start-initial00000100010
11 0A = A - M, ASR11001110001
20 1A = A + M, ASR00011011000
30 0no change, ASR00001101100
40 0no change, ASR00000110110
51 0A = A - M, ASR11001111011

The product is in $AQ$ joined:

$$AQ = 1100111101$$

The leading bit is 1, so the result is negative. Take the 2's complement to find its size:

$$\overline{1100111101} + 1 = 0011000010 + 1 = 0011000011 = 195$$

Therefore $(+13) \times (-15) = -195$.

We can also read $AQ$ directly as a 10-bit signed number, where the leftmost bit has the weight $-512$:

$$-512 + 256 + 32 + 16 + 8 + 4 + 1 = -195$$

The shift is an arithmetic shift, so the sign of the partial product is never lost. When $A - M$ makes $A$ negative, the copied sign bit keeps it negative after the shift.

The method works because the pairs of bits turn the multiplier into signed digits. Here $Q = 10001$ becomes the digits $-1$ at bit 0, $+1$ at bit 1 and $-1$ at bit 4, so its value is:

$$-16 + 2 - 1 = -15$$

In the table, cycle 1 subtracts $M$ (digit $-1$), cycle 2 adds $M$ (digit $+1$), and cycle 5 subtracts $M$ again, but now it counts $16$ times as much because of the shifts. The cycles 3 and 4 only shift. Adding these shifted copies of $M$ gives $13 \times (-15)$.

The check is $13 \times 15 = 195$ and the signs differ, so the sign is negative. The result agrees.

Open this answer on its own page โ†’
2020-2110 marks

Show the systemic multiplication process of (20) X (-19) using Booth's algorithm

Show solved answer

We use 6-bit registers, because $-19$ needs 6 bits in 2's complement. The numbers are:

$$M = +20 = 010100 \qquad -M = 101100 \qquad Q = -19 = 101101$$

$A$ starts at $000000$ and $Q_{-1}$ starts at 0. In each cycle we read the pair $Q_0 Q_{-1}$. The pair $10$ means subtract $M$ from $A$. The pair $01$ means add $M$ to $A$. The pairs $00$ and $11$ mean no operation. After that, $A$, $Q$ and $Q_{-1}$ are shifted one place right, and the sign bit of $A$ is copied (arithmetic shift right, ASR). The process runs for 6 cycles, one for each bit of the multiplier.

CycleQ0 Q-1OperationAQQ-1
Start-initial0000001011010
11 0A = A - M, ASR1101100101101
20 1A = A + M, ASR0001010010110
31 0A = A - M, ASR1110001001011
41 1no change, ASR1111000100101
50 1A = A + M, ASR0010000010010
61 0A = A - M, ASR1110100001001

The product is in the joined register $AQ$:

$$AQ = 111010000100$$

The leftmost bit is 1, so the answer is negative. To find its size, take the 2's complement:

$$\overline{111010000100} + 1 = 000101111011 + 1 = 000101111100 = 380$$

Therefore $(+20) \times (-19) = -380$.

The result is correct because $20 \times 19 = 380$, and the signs differ. Booth's method gave the right sign automatically, and we did not need to treat the sign separately. This is the main strength of the algorithm. It works directly on numbers in 2's complement form. It also skips over strings of 0s and 1s in the multiplier, so it uses fewer additions when the multiplier has long runs of equal bits.

In this example the multiplier $101101$ has no long runs, so only the pair $11$ in cycle 4 causes a skip.

The table can be understood in another way. The pairs of bits turn the multiplier into the signed digits $-1, +1, 0, -1, +1, -1$ (from the leftmost bit down). So the multiplier is worth:

$$-32 + 16 + 0 - 4 + 2 - 1 = -19$$

Each digit decides whether we subtract $M$, add $M$, or do nothing at that bit position. Adding up the shifted copies gives $20 \times (-19) = -380$.

Open this answer on its own page โ†’
2019-2010 marks

Using Booth algorithm perform the multiplication on the following 6-bit unsigned integer 10110011 * 11010101

Show solved answer

The numbers are two 8-bit unsigned integers, $10110011 = 179$ and $11010101 = 213$. Booth's algorithm works on signed numbers. So we first add a 0 on the left of each number. That makes them 9-bit non-negative numbers with the same value. The product then needs 18 bits.

The multiplicand is $M = 010110011$ and the multiplier is $Q = 011010101$. We also need $-M$, found by taking the 2's complement of $M$:

$$-M = 101001101$$

Registers $A$ (9 bits) and $Q_{-1}$ start at 0. In each cycle we look at the pair $Q_0 Q_{-1}$. If it is $10$, we do $A = A - M$. If it is $01$, we do $A = A + M$. If it is $00$ or $11$, we do nothing. Then we shift $A$, $Q$ and $Q_{-1}$ one place right, keeping the sign bit of $A$ (arithmetic shift right, ASR). We repeat this 9 times.

CycleQ0 Q-1OperationAQQ-1
Start-initial0000000000110101010
11 0A = A - M, ASR1101001101011010101
20 1A = A + M, ASR0001011001101101010
31 0A = A - M, ASR1101111001110110101
40 1A = A + M, ASR0001101111111011010
51 0A = A - M, ASR1110000100111101101
60 1A = A + M, ASR0001110101011110110
71 0A = A - M, ASR1110000111101111011
81 1no change, ASR1111000011110111101
90 1A = A + M, ASR0010010100111011110

After 9 cycles, the product is held in $A$ and $Q$ joined together:

$$AQ = 001001010,011101111$$

This is the 18-bit number $001001010011101111_2$. Its value is:

$$2^{15} + 2^{12} + 2^{10} + 2^{7} + 2^{6} + 2^{5} + 2^{3} + 2^{2} + 2^{1} + 2^{0} = 38127$$

Therefore $10110011 \times 11010101 = 38127$. Check: $179 \times 213 = 38127$, so the working is correct.

The reason Booth's method helps here is that runs of 1s in the multiplier are handled by one subtraction at the start of the run and one addition after its end. The multiplier $011010101$ has many isolated 1s, so there are many operations. Even so, the answer is correct for every pattern.

Open this answer on its own page โ†’

Floating point arithmetic operation

2025-262 marks

Explain floating-point representation and its components.

Show solved answer

A floating point number stores a real number as a sign, an exponent and a fraction, in the form $(-1)^s \times 1.f \times 2^{e}$.

Its components are:

  • Sign bit: 0 for positive and 1 for negative.
  • Exponent: the power of 2, stored with a bias so it is always positive. IEEE 754 single precision has 8 exponent bits and bias 127.
  • Fraction (mantissa): the digits after the implied leading 1. Single precision has 23 fraction bits.

The exponent sets the range and the fraction sets the accuracy.

Open this answer on its own page โ†’
2025-267 marks

Explain floating point arithmetic operations. Perform floating point addition using IEEE 754 format for (5.75)10 + (-2.5)10.

Show solved answer

Floating point numbers are stored as sign, exponent and mantissa, so their arithmetic needs extra steps on the exponents.

Addition and subtraction. (1) Compare the exponents. (2) Shift the mantissa of the smaller number right, and raise its exponent by 1 for every shift, until the exponents are equal. (3) Add or subtract the mantissas. (4) Normalise the result so it is again in the form $1.f$, and adjust the exponent. (5) Round the result and check for overflow or underflow.

Multiplication. Add the exponents, subtract the bias, multiply the mantissas, and normalise. The sign is the XOR of the signs.

Division. Subtract the exponents, add the bias, divide the mantissas, and normalise.

Example: $5.75 + (-2.5)$ in IEEE 754 single precision

In binary, $5.75 = 101.11_2 = 1.0111_2 \times 2^{2}$ and $2.5 = 10.1_2 = 1.01_2 \times 2^{1}$. The stored exponents are $2 + 127 = 129 = 10000001$ and $1 + 127 = 128 = 10000000$. So:

NumberSignExponentFraction
5.7501000000101110000000000000000000
-2.511000000001000000000000000000000

The exponents differ by 1, so shift the mantissa of $-2.5$ one place right. It becomes $-0.101_2 \times 2^{2}$.

The signs differ, so this is a subtraction of the mantissas:

$$1.0111 - 0.1010 = 0.1101$$

The result is $0.1101_2 \times 2^{2}$. It is not normalised, so shift left by one place and reduce the exponent by 1:

$$0.1101_2 \times 2^{2} = 1.101_2 \times 2^{1}$$

The sign is $0$, the stored exponent is $1 + 127 = 128 = 10000000$, and the fraction is $10100000000000000000000$.

SignExponentFraction
01000000010100000000000000000000

In hexadecimal this is $\text{0x40500000}$. The value is $1.101_2 \times 2 = 11.01_2 = 3.25$. Therefore $5.75 + (-2.5) = 3.25$, which is correct.

Open this answer on its own page โ†’
2024-252 marks

Explain floating point representation?

Show solved answer

Floating point representation stores a real number using a sign, a power of 2 and a fraction, like scientific notation. A number is written as $(-1)^s \times 1.f \times 2^{e}$.

It has three fields: the sign bit $s$, the biased exponent $E = e + \text{bias}$, and the fraction (mantissa) $f$. In IEEE 754 single precision, 32 bits are split as 1, 8 and 23, with bias 127. Moving the binary point changes the exponent, so the same bits can hold very large and very small numbers. For example, $6.5 = 1.101_2 \times 2^2$.

Open this answer on its own page โ†’
2021-2210 marks

A binary floating-point number has seven bits for a biased exponent. The constant used for the bias is 64. I. List the biased representation of all exponents from -64 to +63. II. Show that after addition of two biased exponents, it is necessary to subtract 64 in order to have a biased exponent's sum. III. Show that after subtraction of two biased exponents, it is necessary to add 64 in order to have a biased exponent's difference.

Show solved answer

(I) Biased representation of exponents

A 7-bit exponent field holds $2^7 = 128$ values, from 0 to 127. With bias 64, the stored value is the true exponent plus 64:

$$E = e + 64$$

The true exponents $-64$ to $+63$ are therefore stored as 0 to 127. The list runs in order, so each exponent has the 7-bit binary form of $e + 64$. Some key values:

True exponent $e$Biased $E$7-bit pattern
$-64$00000000
$-63$10000001
$-2$620111110
$-1$630111111
$0$641000000
$+1$651000001
$+62$1261111110
$+63$1271111111

All the other exponents follow the same rule. Negative exponents begin with 0 and non-negative exponents begin with 1.

(II) Addition of exponents

Let the two true exponents be $e_1$ and $e_2$. Their biased forms are $E_1 = e_1 + 64$ and $E_2 = e_2 + 64$. Adding the stored values gives:

$$E_1 + E_2 = e_1 + e_2 + 128$$

The correct biased sum of the exponents must be $(e_1 + e_2) + 64$. The result above is 64 too large. So we subtract 64:

$$E_1 + E_2 - 64 = e_1 + e_2 + 64$$

This is the biased form of $e_1 + e_2$. This is the exponent step in floating point multiplication.

(III) Subtraction of exponents

Subtracting the stored values gives:

$$E_1 - E_2 = (e_1 + 64) - (e_2 + 64) = e_1 - e_2$$

The bias has cancelled out. But the biased form of $e_1 - e_2$ must be $(e_1 - e_2) + 64$. The result is 64 too small, so we add 64:

$$E_1 - E_2 + 64 = (e_1 - e_2) + 64$$

This is the exponent step in floating point division.

Check with numbers. Take $e_1 = 5$ and $e_2 = -3$. Then $E_1 = 69$ and $E_2 = 61$. The sum is $69 + 61 - 64 = 66 = 2 + 64$, which is the biased form of $5 + (-3) = 2$. The difference is $69 - 61 + 64 = 72 = 8 + 64$, which is the biased form of $5 - (-3) = 8$. Both agree. The result is valid only if the true result stays between $-64$ and $+63$. Otherwise there is exponent overflow or underflow.

This is why a biased exponent is useful. All stored exponents are plain positive numbers, so the sign of the exponent never needs special handling. The only extra work is the single correction of 64 after each addition or subtraction, which is a cheap operation for the hardware.

Open this answer on its own page โ†’

Arithmetic & logic unit design

2025-267 marks

Explain the design of an Arithmetic and Logic Unit. Describe various arithmetic and logical operations performed by ALU.

Show solved answer

The ALU is a combinational circuit that performs arithmetic and logic micro-operations on two $n$-bit inputs. The design is made one bit at a time. Each bit has a 1-bit slice, and $n$ slices are joined side by side. The carry of one slice goes to the next.

        A_i        B_i
         |          |
         |   +------+------+
         |   | logic for B  |<-- S1 S0 (select B, B', 0, 1)
         |   +------+------+
         |          |
      +--+----------+--+
      |   full adder    |<-- C_i
      +--+--------------+--> C_i+1
         |
      +--+------------------+
      | logic gates AND,OR, |<-- S3 S2 (select)
      | XOR, NOT on A_i,B_i |
      +--+------------------+
         |
      [4:1 MUX] --> F_i

The arithmetic part is a parallel adder. A set of gates on the $B$ input decides what the adder sees. They can pass $B$, pass $\overline{B}$, or pass all 0s or all 1s. With the carry input $C_0$, this gives the different operations.

Select$C_0$Operation
pass $B$0$F = A + B$ (add)
pass $B$1$F = A + B + 1$ (add with carry)
pass $\overline{B}$1$F = A - B$ (subtract)
pass $\overline{B}$0$F = A - B - 1$
pass 01$F = A + 1$ (increment)
pass all 1s0$F = A - 1$ (decrement)
pass 00$F = A$ (transfer)

The logic part applies a gate to each bit pair separately. It gives AND, OR, XOR and complement (NOT). No carry moves between the bits.

A multiplexer (MUX) in each slice chooses between the arithmetic result and the logic result, using the select lines. The ALU also gives status flags: carry $C$, sign $S$, zero $Z$ and overflow $V$. Overflow is $V = C_n \oplus C_{n-1}$, the XOR of the last two carries.

Operations performed

  • Arithmetic: addition, subtraction, increment, decrement and transfer.
  • Logical: AND, OR, XOR, NOT.
  • Shift: logical shift and arithmetic shift left or right, and rotate.

The control unit gives the select code that picks the operation. The result goes to a register, and the flags are stored in the status register for conditional branches.

Open this answer on its own page โ†’
2024-252 marks

Discuss the role of ALU in a processor?

Show solved answer

The arithmetic and logic unit (ALU) is the part of the processor that does all the calculations and the decisions on data.

It performs arithmetic operations such as add, subtract, increment and compare, and logic operations such as AND, OR, NOT, XOR and shifts. The control unit sends select signals that choose the operation. The ALU takes its operands from registers or the accumulator, produces the result, and sets status flags such as zero, carry, sign and overflow. The program uses these flags for branching.

Open this answer on its own page โ†’
2021-222 marks

Design a 4-bit combinational incremental circuit using four full adder circuits.

Show solved answer

A 4-bit incrementer adds 1 to a 4-bit number $A_3A_2A_1A_0$. We use four full adders in a ripple chain. The second input $B$ of every adder is tied to 0. The carry input of the first adder is tied to 1, and this 1 is what gets added.

 A3     A2     A1     A0
  |      |      |      |
[FA3]<-[FA2]<-[FA1]<-[FA0]<-- C0 = 1   (B inputs = 0)
  |      |      |      |
 S3     S2     S1     S0

The first adder gives $S_0 = \overline{A_0}$ and carry $A_0$, and the carry moves up the chain. The output is $A + 1$. The last carry shows that $A$ was $1111$.

Open this answer on its own page โ†’
2021-222 marks

Register A holds the binary values 10011101. What is the register value after arithmetic shift right? Starting from the initial number 10011101, determine the register value after arithmetic shift left, and state whether there is an overflow.

Show solved answer

The register holds $A = 10011101$. The leftmost bit is the sign bit.

Arithmetic shift right. Every bit moves one place right, the sign bit is kept, and the lowest bit is lost. Therefore:

$$10011101 \rightarrow 11001110$$

This is the value $-99$ halved to $-50$.

Arithmetic shift left. Every bit moves one place left and a 0 enters at the right:

$$10011101 \rightarrow 00111010$$

The sign bit has changed from 1 to 0. This is an overflow, because the true result $-198$ does not fit in 8 bits. The overflow flag is set whenever the sign bit before the shift and the bit that replaces it are different.

Open this answer on its own page โ†’
2019-202 marks

Perform the 2's complement subtraction of smaller number (101011) from larger number (111001).

Show solved answer

To subtract a smaller number from a larger one with 2's complement, we add the 2's complement of the smaller number to the larger number. The final carry out is thrown away.

The 2's complement of $101011$ is found by inverting every bit, which gives $010100$, and then adding 1:

$$010100 + 1 = 010101$$

Now add this to the larger number:

$$111001 + 010101 = 1,001110$$

The extra carry bit $1$ on the left is discarded. Therefore the answer is $001110$, which is $14$. Check: $57 - 43 = 14$.

Open this answer on its own page โ†’

IEEE Standard for Floating Point Numbers

2023-247 marks

Represent the following decimal number in IEEE standard floating-point format in a single precision method (32 bit) representation method. (i) (85.125)10 (ii) (-307.1875)10

Show solved answer

IEEE 754 single precision uses 32 bits: 1 sign bit, 8 exponent bits with bias 127, and 23 fraction bits. A number is stored as $(-1)^s \times 1.f \times 2^{e}$, with the stored exponent $E = e + 127$. The leading 1 is implied, so it is not stored.

The method has three parts. First, convert the number to binary. Second, normalise it to the form $1.f \times 2^e$ by moving the binary point. Third, add the bias to $e$ and write the sign, exponent and fraction in order. The bias of 127 makes the stored exponent a positive number even for small values.

(i) 85.125

The number is positive, so $s = 0$. The integer part is $85 = 1010101_2$, and the fraction is exact, since $0.125 = 0.001_2$. So:

$$85.125 = 1010101.001_2 = 1.010101001_2 \times 2^{6}$$

The stored exponent is:

$$E = 6 + 127 = 133 = 10000101_2$$

The fraction $010101001$ is padded with zeros to 23 bits. Therefore:

SignExponentFraction
01000010101010100100000000000000

In hexadecimal this is $\text{0x42AA4000}$.

(ii) -307.1875

The number is negative, so $s = 1$. The integer part is $307 = 100110011_2$ and $0.1875 = 0.0011_2$. So:

$$307.1875 = 100110011.0011_2 = 1.001100110011_2 \times 2^{8}$$

The stored exponent is:

$$E = 8 + 127 = 135 = 10000111_2$$

The fraction $001100110011$ is padded with zeros to 23 bits. Therefore:

SignExponentFraction
11000011100110011001100000000000

In hexadecimal this is $\text{0xC3999800}$.

Both numbers have short binary fractions, so both are stored exactly with no rounding error.

To check the first answer, decode it: $E = 133$ gives $e = 6$. The value is $1.010101001_2 \times 2^6 = 1010101.001_2 = 85 + 0.125 = 85.125$. The second answer decodes in the same way to $-(256 + 32 + 16 + 2 + 1) - 0.1875 = -307.1875$, which matches.

Open this answer on its own page โ†’
2022-2310 marks

Explain IEEE-754 standard for floating point representation. Express (314.175)10 in all the IEEE-754 models.

Show solved answer

IEEE 754 is the standard format for real numbers in almost every computer. A number is stored as $(-1)^s \times 1.f \times 2^{e}$ in three fields: the sign bit $s$ (0 for positive, 1 for negative), the biased exponent $E = e + \text{bias}$, and the fraction $f$. The leading 1 is implied and not stored.

ModelTotal bitsSignExponentFractionBias
Single precision321823127
Double precision64111521023

The bias keeps the stored exponent positive, so numbers can be compared like integers. The all-0 and all-1 exponent patterns are kept for special values.

ExponentFractionMeaning
all 00zero
all 0not 0denormal number
all 10infinity
all 1not 0NaN (not a number)

Normal numbers use the stored exponents 1 to 254 in single precision and 1 to 2046 in double precision. Rounding to the nearest value is the default way to fit a long fraction into the fraction field, and it keeps the error below half of the last bit.

Representing 314.175

The number is positive, so $s = 0$. The integer part is $314 = 100111010_2$. For the fraction, we double $0.175$ again and again and note the digits:

$$0.175 = 0.001011,0011,0011\ldots_2$$

So the number is $100111010.0010110011\ldots_2$. Move the point 8 places left to normalise:

$$314.175 = 1.001110100010110011\ldots_2 \times 2^{8}$$

The true exponent is $e = 8$. The fraction starts with $00111010$ (from the integer part) and then continues with the digits of $0.175$.

Single precision. The stored exponent is:

$$E = 8 + 127 = 135 = 10000111_2$$

The fraction takes 23 bits. The bits after the 23rd are $0110\ldots$, which are less than half, so we round down. Therefore:

SignExponentFraction
01000011100111010001011001100110

In hexadecimal this is $\text{0x439D1666}$.

Double precision. The stored exponent is:

$$E = 8 + 1023 = 1031 = 10000000111_2$$

The fraction takes 52 bits. The bits after the 52nd are $1100\ldots$, which is more than half, so the last bit is rounded up. Therefore:

SignExponentFraction
0100000001110011101000101100110011001100110011001100110011001101

In hexadecimal this is $\text{0x4073A2CCCCCCCCCD}$.

Neither answer is exact, because $0.175$ has a repeating binary fraction. The error is about $10^{-5}$ in single precision and about $10^{-14}$ in double precision. To check the single answer, decode it: $E = 135$ gives $e = 8$, and the value is $1.00111010001011001100110_2 \times 2^8 \approx 314.17499$.

Open this answer on its own page โ†’
2020-212 marks

Discuss biasing with reference to floating point representation.

Show solved answer

Biasing means adding a fixed constant, called the bias, to the true exponent before storing it. The stored value is then always a positive (unsigned) number, so no sign bit is needed for the exponent. It also lets us compare two floating point numbers using plain integer comparison.

In IEEE 754 single precision the bias is 127, so $E = e + 127$. In double precision the bias is 1023. For example, a true exponent of $-3$ is stored as $-3 + 127 = 124$, and a true exponent of $5$ is stored as $132$.

Open this answer on its own page โ†’
2020-2110 marks

Explain IEEE standard for floating point representation. Represent the number (-1460.125)10 in single precision and double precision format.

Show solved answer

IEEE 754 is the standard way to store real numbers in a computer. A number is written in the form $(-1)^s \times 1.f \times 2^{e}$ and stored in three fields: a sign bit $s$, a biased exponent $E$, and a fraction $f$ (also called the mantissa). The leading 1 is implied, so it is not stored.

FormatTotal bitsSignExponentFractionBias
Single precision321823127
Double precision64111521023

The stored exponent is $E = e + \text{bias}$. The bias lets the exponent field hold negative powers of 2 without its own sign. Single precision covers magnitudes from about $1.2 \times 10^{-38}$ to $3.4 \times 10^{38}$. The all-0 and all-1 exponent patterns are kept for zero, denormal numbers, infinity and NaN.

Representing -1460.125

The number is negative, so the sign bit is $1$. Convert the magnitude to binary. The integer part is $1460 = 10110110100_2$. The fraction is exact, since $0.125 = 0.001_2$. So:

$$1460.125 = 10110110100.001_2$$

Move the binary point 10 places left to normalise:

$$1460.125 = 1.0110110100001_2 \times 2^{10}$$

The fraction is $0110110100001$, and the true exponent is $e = 10$.

Single precision. The stored exponent is:

$$E = 10 + 127 = 137 = 10001001_2$$

The fraction is padded with zeros to 23 bits. Therefore:

SignExponentFraction
11000100101101101000010000000000

In hexadecimal this is $\text{0xC4B68400}$.

Double precision. The stored exponent is:

$$E = 10 + 1023 = 1033 = 10000001001_2$$

The fraction is padded with zeros to 52 bits. Therefore:

SignExponentFraction
1100000010010110110100001 followed by 39 zeros

In hexadecimal this is $\text{0xC096D08000000000}$.

Special values. The reserved exponent patterns give the following meanings:

ExponentFractionMeaning
all 00zero (positive or negative)
all 0not 0denormal number (no implied 1)
all 10infinity (positive or negative)
all 1not 0NaN (not a number, such as $0/0$)

Check. To decode the single precision answer, read $E = 137$, so $e = 137 - 127 = 10$. The value is $-1.0110110100001_2 \times 2^{10}$. Shifting the point 10 places right gives $-10110110100.001_2$, which is $-1460.125$. So the encoding is correct.

Both representations are exact, because the number needs only 13 fraction bits. Double precision stores the same value but has a wider range and about 15 to 16 decimal digits of accuracy, against about 7 for single precision.

Open this answer on its own page โ†’
2019-2010 marks

Represent the following decimal number in IEEE standard floating-point format in a single precision method (32-bit) representation method. i. (65.175)10 ii. (-307.1875)10

Show solved answer

IEEE 754 single precision uses 32 bits: 1 sign bit, 8 exponent bits (bias 127) and 23 fraction bits. A normalised number is written as $(-1)^s \times 1.f \times 2^{e}$. The stored exponent is $E = e + 127$. The leading 1 is not stored, because every normalised number starts with 1, so keeping it would waste a bit.

The bias 127 is added so that the exponent field is always a positive number. This lets two floating point numbers be compared like plain integers. The exponent patterns $00000000$ and $11111111$ are kept for zero, denormal numbers, infinity and NaN (not a number). So normal numbers use stored exponents from 1 to 254.

The method has three parts. First, convert the number to binary. Second, normalise it to the form $1.f \times 2^e$. Third, find $E = e + 127$ and write the sign, exponent and fraction in order.

(i) 65.175

The number is positive, so the sign bit is $0$. Convert the integer and fraction parts separately. The integer part is $65 = 1000001_2$. For the fraction, multiply by 2 again and again and note the integer parts:

$$0.175 = 0.001011,0011,0011\ldots_2$$

The first digits come from $0.175 \times 2 = 0.35$ (digit 0), $0.35 \times 2 = 0.7$ (digit 0), $0.7 \times 2 = 1.4$ (digit 1), then $0.4 \times 2 = 0.8$ (digit 0), and so on. The pattern $0011$ repeats forever, so the fraction never ends.

So the number is $1000001.001011001100\ldots_2$. Move the binary point 6 places left to normalise:

$$65.175 = 1.000001001011001100\ldots_2 \times 2^{6}$$

The stored exponent is:

$$E = 6 + 127 = 133 = 10000101_2$$

The fraction needs 23 bits. We take the digits after the leading 1 and round the last bit, because the next digits are $1001\ldots$, which is more than half. The fraction is $00000100101100110011010$. Therefore:

SignExponentFraction
01000010100000100101100110011010

In hexadecimal this is $\text{0x4282599A}$.

(ii) -307.1875

The number is negative, so the sign bit is $1$. The integer part is $307 = 100110011_2$. The fraction is exact:

$$0.1875 = 0.0011_2$$

So the number is $100110011.0011_2$. Move the point 8 places left:

$$307.1875 = 1.001100110011_2 \times 2^{8}$$

The stored exponent is:

$$E = 8 + 127 = 135 = 10000111_2$$

The fraction is $001100110011$ followed by 11 zeros to fill 23 bits. Therefore:

SignExponentFraction
11000011100110011001100000000000

In hexadecimal this is $\text{0xC3999800}$.

To check, decode the second answer: $-1.001100110011_2 \times 2^{8} = -1.1999\ldots \times 256 = -307.1875$. The first answer is the nearest 32-bit value to $65.175$, so it has a tiny rounding error of the order of $10^{-6}$. This is normal, because $0.175$ cannot be written exactly in binary.

Open this answer on its own page โ†’

Division and logic operations

2021-2210 marks

Explain 2-bit by 2-bit Array multiplier. Draw the flowchart for divide operation of two numbers in signed magnitude form.

Show solved answer

An array multiplier forms all partial products at the same time with AND gates, and then adds them with an array of adders. Let the multiplicand be $A = a_1a_0$ and the multiplier be $B = b_1b_0$. The product $P = p_3p_2p_1p_0$ has 4 bits.

Each partial product bit is one AND gate: $a_0b_0$, $a_1b_0$, $a_0b_1$ and $a_1b_1$. They are arranged like paper multiplication:

Weight$2^3$$2^2$$2^1$$2^0$
Row 1 ($b_0$)$a_1b_0$$a_0b_0$
Row 2 ($b_1$)$a_1b_1$$a_0b_1$

Column $2^0$ has one bit, so $p_0 = a_0b_0$. Column $2^1$ has two bits, which a half adder (HA1) adds: the sum is $p_1$ and the carry $c_1$ goes to the next column. Column $2^2$ has $a_1b_1$ and $c_1$, which a second half adder (HA2) adds: the sum is $p_2$ and the carry is $p_3$.

$$p_0 = a_0b_0 \qquad p_1 = a_1b_0 \oplus a_0b_1$$

$$p_2 = a_1b_1 \oplus (a_1b_0 \cdot a_0b_1) \qquad p_3 = a_1b_1 \cdot a_1b_0 \cdot a_0b_1$$

 a1b0 a0b1        a0b0 ----------------------> p0
   \   /
   [HA1] --sum-----------------------------> p1
     | c1
 a1b1 +--> [HA2] --sum----------------------> p2
              \--carry---------------------> p3

The circuit needs 4 AND gates and 2 half adders. For $A = 11$ and $B = 11$ (that is $3 \times 3$), the four AND outputs are all 1. Then $p_0 = 1$, $p_1 = 0$ with $c_1 = 1$, $p_2 = 1 \oplus 1 = 0$ and $p_3 = 1$. The product is $1001 = 9$.

Flowchart for division of signed magnitude numbers. The sign and the magnitude are handled separately. The dividend is in $A$ and $Q$ joined, the divisor is in $B$, and the sign bits are $A_s$, $B_s$ and $Q_s$.

 START
   |
 Qs = As xor Bs ; SC = n-1
   |
 EA = A + (not B) + 1       (try A - B)
   |
 E = 1 ?--yes--> DIVIDE OVERFLOW (stop)
   | no
 shift left AQ ; EA = A + (not B) + 1
   |
 E = 1 ? --yes--> Qn = 1 ; A = EA
   | no
 Qn = 0   (A stays, so no restore needed)
   |
 SC = SC - 1 ; SC = 0 ? --no--> back to shift
   | yes
 END : Q = quotient, A = remainder

The first subtraction checks that the quotient fits in $n$ bits. If $A \ge B$ already, the divide overflows. After that, each cycle shifts left, subtracts $B$ by adding its 2's complement, and checks the carry $E$. A carry of 1 means the subtraction succeeded, so the quotient bit is 1 and $A$ takes the new value. A carry of 0 means it failed, so the quotient bit is 0 and $A$ keeps its old value. After $n-1$ cycles $Q$ holds the quotient and $A$ the remainder. The quotient sign is $A_s \oplus B_s$, and the remainder takes the sign of the dividend.

Open this answer on its own page โ†’
2020-212 marks

What is restoring method in division algorithm?

Show solved answer

The restoring method is a way of dividing two binary numbers by repeated subtraction and shifting. Register $A$ starts at 0, $Q$ holds the dividend and $M$ holds the divisor.

In each of $n$ cycles, we shift $A$ and $Q$ left by one bit. Then we subtract $M$ from $A$. If the result is negative, the subtraction was too large. So we set $Q_0 = 0$ and add $M$ back to $A$, which restores the old value. If the result is not negative, we set $Q_0 = 1$.

After $n$ cycles, $Q$ holds the quotient and $A$ holds the remainder. For example, $7 \div 3$ gives quotient $2$ and remainder $1$.

Open this answer on its own page โ†’