2078 3

CSC213 ยท 2078 ยท 10 marks

Explain the non-restoring division algorithm with flow chart, and hardware implementation diagram. Divide 10/3 using restoring division.

Explain the non-restoring division algorithm with flow chart, and hardware implementation diagram. Divide 10/3 using restoring division.[10]

Computer ArchitectureChapter 7: Computer ArithmeticDivision of Signed magnitude DataNumerical: non-restoring division algorithm

Non-Restoring Division Algorithm and Restoring Division Example


1. Non-Restoring Division Algorithm

In restoring division, after subtracting the divisor, if the partial remainder becomes negative, the divisor is added back (restored). This wastes an operation.

In non-restoring division, we do NOT restore. Instead, we keep the negative remainder and adjust in the next step:

  • If A is positive (or zero): shift left, then subtract B.
  • If A is negative: shift left, then add B.

The quotient bit is set based on the sign of A after the operation.

Algorithm Steps

Let A = accumulator (initially 0), Q = dividend, B = divisor, SC = n.

  1. Initialize A = 0, load Q with dividend, B with divisor, SC = n.
  2. If sign of A = 0: Shift left AQ, then A = A - B. If sign of A = 1: Shift left AQ, then A = A + B.
  3. If sign of A = 0: set Q[0] = 1. Else set Q[0] = 0.
  4. Decrement SC. If SC โ‰  0, go to step 2.
  5. At end, if A is negative, restore once: A = A + B.
  6. Quotient in Q, Remainder in A.

2. Flowchart

                 START
                   |
        A=0, load Q=Dividend,
        B=Divisor, SC=n
                   |
        +------> Shift left AQ
        |          |
        |    sign of A = 0 ?
        |      /          \
        |    YES           NO
        |     |             |
        |  A = A - B     A = A + B
        |     \           /
        |      sign of A = 0 ?
        |      /          \
        |    YES           NO
        |  Q[0]=1        Q[0]=0
        |      \          /
        |     SC = SC - 1
        |          |
        |      SC = 0 ?
        |      /      \
        +----NO       YES
                       |
                 sign of A = 1 ?
                  /        \
                YES         NO
             A = A + B       |
                  \         /
              Quotient=Q, Remainder=A
                       |
                     STOP

3. Hardware Implementation Diagram

        +-----------+   +-----------+
        |  B Register|   | Complementer/
        |  (Divisor) |-->| Adder      |
        +-----------+   +------+-----+
                               |
              +----------------+
              v
        +-----------+-----------+     shift left
        |   A (acc) |   Q (Qtnt)|  <-------------
        +-----+-----+-----------+
              |
        sign bit (MSB of A)
              |
              v
        +-----------------+     +-------------+
        | Control Logic   |<--->| Sequence    |
        | (Add / Subtract)|     | Counter SC  |
        +-----------------+     +-------------+

Components: A register (n+1 bits, partial remainder), Q register (holds dividend then quotient), B register (divisor), parallel adder/subtractor with complementer, sign flip-flop, sequence counter SC, and control logic that selects add or subtract based on the sign of A.


4. Divide 10 / 3 using Restoring Division

Given data:

  • Dividend = 10
  • Divisor = 3

Binary representation (4 bits):

  • Dividend $Q = 1010$ (10)
  • Divisor $B = 0011$ (3)
  • $n = 4$
  • $A = 00000$ (initially 0, using 5-bit A to hold sign)
  • $-B = 11101$ (2's complement of 00011)

The restoring method: shift left AQ, subtract B. If A < 0, set Q[0]=0 and restore (add B back); else set Q[0]=1.

StepOperationAQAction
Init000001010SC = 4
1Shift left AQ00001010_
A = A - B111100100A<0, restore: Q[0]=0
Restore A=A+B000010100
2Shift left AQ00010100_
A = A - B111111000A<0, restore: Q[0]=0
Restore A=A+B000101000
3Shift left AQ00101000_
A = A - B000100001Aโ‰ฅ0, Q[0]=1
4Shift left AQ00100010_
A = A - B000010011Aโ‰ฅ0, Q[0]=1

After 4 iterations:

  • Quotient $Q = 0011 = 3$
  • Remainder $A = 00001 = 1$

Verification: $10 = 3 \times 3 + 1$ โœ“

Final Result

$$\boxed{\text{Quotient} = 3, \quad \text{Remainder} = 1}$$

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.