

























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


























































































Number Representation
Numbers and ArithmeticRepresenting Signed Numbers Redundant Number SystemsResidue Number Systems
Addition / Subtraction
Basic Addition and CountingCarry-Look ahead Adders Variations in Fast AddersMultioperand Addition
Multiplication
Basic Multiplication SchemesHigh-Radix Multipliers Tree and Array MultipliersVariations in Multipliers
Division
Basic Division SchemesHigh-Radix Dividers Variations in DividersDivision by Convergence
Real Arithmetic
Floating-Point ReperesentationsFloating-Point Operations Errors and Error ControlPrecise and Certifiable Arithmetic
Function Evaluation
Square-Rooting MethodsThe CORDIC Algorithms Variations in Function EvaluationArithmetic by Table Lookup
Implementation Topics
High-Throughput ArithmeticLow-Power Arithmetic Fault-Tolerant ArithmeticPast, Present, and Future
Parts Chapters I.
II.
III.
IV.
V.
VI.
VII.
1.2. 3.4. 5.6. 7.8.
10.9. 11.12.
25.26. 27.28.
21.22. 23.24.
17.18. 19.20.
13.14. Elementary Operations 15.16.
Chapter 13 Basic Division Schemes
Chapter 14 High-Radix Dividers
Chapter 15 Variations in Dividers
Chapter 16 Division by Convergence
Review Division schemes and various speedup methods
Basic Division Schemes: Topics
Topics in This Chapter
13.1 Shift/Subtract Division Algorithms
13.2 Programmed Division
13.3 Restoring Hardware Dividers
13.4 Nonrestoring and Signed Division
13.5 Division by Constants
13.6 Radix-2 SRT Division
13.1 Shift/Subtract Division Algorithms
Notation for our discussion of division algorithms: z Dividend z 2 k – 1 z 2 k – 2... z 3 z 2 z 1 z 0 d Divisor dk – 1 dk – 2... d 1 d 0 q Quotient qk – 1 qk – 2... q 1 q 0 s Remainder, z – ( d q ) sk – 1 sk – 2... s 1 s 0 Initially, we assume unsigned operands
Fig. 13.1 Division of an 8-bit number by a 4-bit number in dot notation.
Dividend
Subtracted bit-matrix
z
s Remainder
d Divisor q Quotient
Division Recurrence
Division with left shifts
s ( j )^ = 2 s ( j – 1)^ – qk – j (2 k^ d ) with s (0)^ = z and |–shift–| s ( k )^ = 2 ks |––– subtract –––|
(There is no corresponding right-shift algorithm)
Fig. 13.
Dividend Subtracted bit-matrix
z
s Remainder
d Divisor q Quotient
Integer division is characterized by z = d q + s
2 –^2 kz = (2– kd ) ( 2 – kq ) + 2–^2 ks z frac = d frac q frac + 2– k^ s frac
Divide fractions like integers; adjust the remainder
No-overflow condition for fractions is: z frac < d frac
k bits k bits
2 z
2 k^ d
0
Examples of Basic Division
Fig. 13. Examples of sequential division with integer and fractional operands.
Integer division Fractional division ====================== ===================== z 0 1 1 1 0 1 0 1 z frac. 0 1 1 1 0 1 0 1 24 d 1 0 1 0 d frac. 1 0 1 0 ====================== ===================== s (0)^ 0 1 1 1 0 1 0 1 s (0)^. 0 1 1 1 0 1 0 1 2 s (0)^ 0 1 1 1 0 1 0 1 2 s (0)^ 0. 1 1 1 0 1 0 1
Decimal
Assembly Language Program for Division
Fig. 13. Programmed division using left shifts.
{Using left shifts, divide unsigned 2k-bit dividend, z_high|z_low, storing the k-bit quotient and remainder. Registers: R0 holds 0 Rc for counter Rd for divisor Rs for z_high & remainder Rq for z_low & quotient} {Load operands into registers Rd, Rs, and Rq} div: load Rd with divisor load Rs with z_high load Rq with z_low {Check for exceptions} branch d_by_0 if Rd = R branch d_ovfl if Rs > Rd {Initialize counter} load k into Rc {Begin division loop} d_loop: shift Rq left 1 {zero to LSB, MSB to carry} rotate Rs left 1 {carry to LSB, MSB to carry} skip if carry = 1 branch no_sub if Rs < Rd sub Rd from Rs incr Rq {set quotient digit to 1} no_sub: decr Rc {decrement counter by 1} branch d_loop if Rc 0 {Store the quotient and remainder} store Rq into quotient store Rs into remainder d_by_0: ... d_ovfl: ... d_done: ...
Rs Rq
Rd 0 0... 0 0 0 0 2 kd
CarryFlag
Shifted PartialRemainder Shifted PartialQuotient
Partial Remainder (2k – j Bits) Partial Quotient(j Bits)
Nextquotient digitinserted here
Divisor d
Fig. 13. Register usage for programmed division.
Time Complexity of Programmed Division
Assume k -bit words
k iterations of the main loop 6-8 instructions per iteration, depending on the quotient bit
Thus, 6 k + 3 to 8 k + 3 machine instructions, ignoring operand loads and result store
k = 32 implies 220+^ instructions on average
This is too slow for many modern applications!
Microprogrammed division would be somewhat better
Example of Restoring Unsigned Division
Fig. 13.6 Example of restoring unsigned division.
======================= z 0 1 1 1 0 1 0 1 24 d 0 1 0 1 0
No overflow, because (0111)two < (1010)two
Indirect Signed Division
In division with signed operands, q and s are defined by
z = d q + s sign( s ) = sign( z ) | s | < | d |
Examples of division with signed operands
z = 5 d = 3 q = 1 s = 2 z = 5 d = – 3 q = – 1 s = 2 z = – 5 d = 3 q = – 1 s = – 2 z = – 5 d = – 3 q = 1 s = – 2
Magnitudes of q and s are unaffected by input signs Signs of q and s are derivable from signs of z and d
Will discuss direct signed division later
(not q = – 2, s = – 1)
Justification for Nonrestoring Division
Why it is acceptable to store an incorrect value in the partial-remainder register?
Shifted partial remainder at start of the cycle is u
Suppose subtraction yields the negative result u – 2 kd
Option 1: Restore the partial remainder to correct value u , shift left, and subtract to get 2 u – 2 kd
Option 2: Keep the incorrect partial remainder u – 2 kd , shift left, and add to get 2( u – 2 kd ) + 2 kd = 2 u – 2 kd
Example of Nonrestoring Unsigned Division
Fig. 13.7 Example of nonrestoring unsigned division.
======================= z 0 1 1 1 0 1 0 1 24 d 0 1 0 1 0
No overflow: (0111)two < (1010)two
Decimal
Convergence of the Partial Quotient to q
In restoring division, the partial quotient converges to q from below
Example
(0 1 1 1 0 1 0 1)two / (1 0 1 0)two
(117)ten/(10)ten = (11)ten = (1011)two
In nonrestoring division, the partial quotient may overshoot q , but converges to it after some oscillations (^0000)
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111 Partial quotient
Iteration 0 1 2 3 4
q
q (1)^ q (2)
q (3)
q (4)
q (2)
Restoring
Nonrestoring
q (0)
Nonrestoring Division with Signed Operands
Restoring division
qk – j = 0 means no subtraction (or subtraction of 0) qk – j = 1 means subtraction of d
Nonrestoring division
We always subtract or add It is as if quotient digits are selected from the set {1, - 1}: 1 corresponds to subtraction - 1 corresponds to addition Our goal is to end up with a remainder that matches the sign of the dividend
This idea of trying to match the sign of s with the sign of z , leads to a direct signed division algorithm
if sign( s ) = sign( d ) then qk – j = 1 else qk – j = - 1
Example: q =... 0 0 0 1...
... 1 - 1 - 1 - 1...