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]
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.
- Initialize
A = 0, load Q with dividend, B with divisor,SC = n. - If sign of A = 0: Shift left AQ, then
A = A - B. If sign of A = 1: Shift left AQ, thenA = A + B. - If sign of A = 0: set
Q[0] = 1. Else setQ[0] = 0. - Decrement SC. If SC โ 0, go to step 2.
- At end, if A is negative, restore once:
A = A + B. - 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.
| Step | Operation | A | Q | Action |
|---|---|---|---|---|
| Init | 00000 | 1010 | SC = 4 | |
| 1 | Shift left AQ | 00001 | 010_ | |
| A = A - B | 11110 | 0100 | A<0, restore: Q[0]=0 | |
| Restore A=A+B | 00001 | 0100 | ||
| 2 | Shift left AQ | 00010 | 100_ | |
| A = A - B | 11111 | 1000 | A<0, restore: Q[0]=0 | |
| Restore A=A+B | 00010 | 1000 | ||
| 3 | Shift left AQ | 00101 | 000_ | |
| A = A - B | 00010 | 0001 | Aโฅ0, Q[0]=1 | |
| 4 | Shift left AQ | 00100 | 010_ | |
| A = A - B | 00001 | 0011 | Aโฅ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.