











































































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 21 Square-Rooting Methods
Chapter 22 The CORDIC Algorithms
Chapter 23 Variation in Function Evaluation
Chapter 24 Arithmetic by Table Lookup
Learn hardware algorithms for evaluating useful functions
Square-Rooting Methods: Topics
Topics in This Chapter
21.1 The Pencil-and-Paper Algorithm
21.2 Restoring Shift / Subtract Algorithm
21.3 Binary Nonrestoring Algorithm
21.4 High-Radix Square-Rooting
21.5 Square-Rooting by Convergence
21.6 Fast Hardware Square-Rooters
21.1 The Pencil-and-Paper Algorithm
Notation for our discussion of division algorithms:
z Radicand z 2 k – 1 z 2 k – 2... z 3 z 2 z 1 z 0 q Square root qk – 1 qk – 2... q 1 q 0 s Remainder, z – q^2 sksk – 1 sk – 2... s 1 s 0
Remainder range, 0 s 2 q ( k + 1 digits) Justification: s 2 q + 1 would lead to z = q^2 + s ( q + 1)^2
Fig. 21.3 Binary square-rooting in dot notation.
2
0
3
Radicand
Subtracted bit-matrix
z
s Remainder
q Root
( q
( q
( q (1)
(0)
(2) (3)
0 0 0 0
2
0
q 3 q q (^) 1 q
) ) ) )
Root Digit Selection Rule
The root thus far is denoted by q ( i )^ = ( qk – 1 qk – 2... qk – i )ten
Attaching the next digit qk – i – 1 , partial root becomes q ( i +1)^ = 10 q ( i )^ + qk – i – 1
The square of q ( i +1)^ is 100( q ( i ))^2 + 20 q ( i )^ qk – i – 1 + ( qk – i – 1 )^2
100( q ( i ))^2 = (10 q ( i ))^2 subtracted from partial remainder in previous steps
Must subtract (10(2 q ( i )) + qk – i – 1 ) qk – i – 1 to get the new partial remainder
More generally, in radix r , must subtract ( r (2 q ( i )) + qk – i – 1 ) qk – i – 1
In radix 2, must subtract (4 q ( i )^ + qk – i – 1 ) qk – i – 1 , which is
4 q ( i )^ + 1 for qk – i – 1 = 1, and 0 otherwise Thus, we use ( qk – 1 qk – 2... qk – I 0 1)two in a trial subtraction
Example of Binary Square-Rooting
Fig. 21.2 Extracting the square root of a binary integer using the pencil-and-paper algorithm.
Root digit q 3 q 2 q 1 q 0 q q (0)^ = 0 0 11 10 11 0 01? Yes q 3 = 1 q (1)^ = 1 0 1 0 0 1 1 101? No q 2 = 0 q (2)^ = 10 0 0 0 0 1 1 0 1 1001? Yes q 1 = 1 q (3)^ = 101 1 0 0 1 0 1 0 0 1 0 10101? No q 0 = 0 q (4)^ = 1010 ^ 0 0 0 0 0 1 0 0 1 0 s = (18)ten q = (1010)two = (10)ten
Check: 10^2 + 18 = 118 = (0111 0110)two^ Partial root
Finding the Sq. Root of
z = 1.
via the Restoring Algorithm
================================ z (radicand = 118/64) 0 1. 1 1 0 1 1 0 ================================ s (0)^ = z – 1 0 0 0. 1 1 0 1 1 0 q 0 = 1 1. 2 s (0)^ 0 0 1. 1 0 1 1 0 0
Fig. 21. Example of sequential binary square-rooting using the restoring algorithm.
Root digit Partial root
q – 7 = 1, so round up
Hardware for Restoring Square-Rooting
Fig. 21.5 Sequential shift/subtract restoring square-rooter.
Partial Remainder
Square-Root
Load
sub
(l+2)-bit adder
Trial Difference
l+
Complement
2s (j–1)
MSB of
Put z – 1 here at the outset
Select Root Digit
l+
Quotient q
Mux
c out Adder
0 1
Partial remainder s (initial value z )
Divisor d
Shift
Shift
Load
c in^1
( j )
Quotientdigit selector
qk – j
MSB of 2 s ( j – 1) k k
k
Trial difference
Fig. 13.5 Shift/subtract sequential restoring divider (for comparison).
21.3 Binary Nonrestoring Algorithm
As in nonrestoring division, nonrestoring square-rooting implies:
Root digits in {1, 1} On-the-fly conversion to binary Possible final correction
The case q – j = 1 (nonnegative partial remainder), is handled as in the restoring algorithm; i.e., it leads to the trial subtraction of
q – j [2 q ( j – 1)^ + 2– j^ q – j ] = 2 q ( j – 1)^ + 2– j
For q – j = 1, we must subtract
q – j [2 q ( j – 1)^ + 2– j^ q – j ] = – [2 q ( j – 1)^ – 2 – j^ ]
which is equivalent to adding 2 q ( j – 1)^ – 2 – j
Slight complication, compared with nonrestoring division
This term cannot be formed by concatenation
Finding the Sq. Root of z = 1. via the
Nonrestoring
Algorithm
================================ z (radicand = 118/64) 0 1. 1 1 0 1 1 0 ================================ s (0)^ = z – 1 0 0 0. 1 1 0 1 1 0 q 0 = 1 1. 2 s (0)^ 0 0 1. 1 0 1 1 0 0 q – 1 = 1 1.
Fig. 21. Example of nonrestoring binary square-rooting.
Root digit Partial root
21.4 High-Radix Square-Rooting
Basic recurrence for fractional radix- r square-rooting:
s ( j )^ = rs ( j – 1)^ – q – j (2 q ( j – 1)^ + r – j^ q – j )
As in radix-2 nonrestoring algorithm, we can use two registers Q and Q* to hold q ( j – 1)^ and its diminished version q ( j – 1)^ – r – j +1, respectively, suitably updating them in each step
2
0
3
Radicand
Subtracted bit-matrix
z
s Remainder
q Root
( q
( q
( q (1)
(0)
(2) (3)
0 0 0 0
2
0
q 3 q q (^) 1 q
) ) ) )
Fig. 21.3 Radix-4 square-rooting in dot notation
An Implementation of Radix-4 Square-Rooting
r = 4, root digit set [–2, 2]
Q* holds q ( j – 1)^ – 4 – j +1^ = q ( j – 1)^ – 2 –^2 j +2. Then, one of the following values must be subtracted from, or added to, the shifted partial remainder rs ( j – 1)
q – j = 2 Subtract 4 q ( j – 1)^ + 2–^2 j +2^ double-shift Q 010 q – j = 1 Subtract 2 q ( j – 1)^ + 2–^2 j^ shift Q 001 q – j = 1 Add 2 q ( j – 1)^ – 2 –^2 j^ shift Q* q – j = 2 Add 4 q ( j – 1)^ – 2 –^2 j +2^ double-shift Q*
Updating rules for Q and Q* registers:
q – j = 2 Q := Q 10 Q* := Q 01 q – j = 1 Q := Q 01 Q* := Q 00 q – j = 0 Q := Q 00 Q* := Q* q – j = 1 Q := Q11 Q := Q* q – j = 2 Q := Q10 Q := Q*
Note that the root is obtained in binary form (no conversion needed!)
s ( j )^ = rs ( j – 1)^ – q – j (2 q ( j – 1)^ + r – j^ q – j )
21.5 Square-Rooting by Convergence
x
f ( x )
z
z
Newton-Raphson method
Choose f ( x ) = x^2 – z with a root at x = z
x ( i +1)^ = x ( i )^ – f ( x ( i )) / f ( x ( i )) x ( i +1)^ = 0.5( x ( i )^ + z / x ( i ))
Each iteration: division, addition, 1-bit shift Convergence is quadratic
For 0.5 z < 1, a good starting approximation is (1 + z )/
This approximation needs no arithmetic
The error is 0 at z = 1 and has a max of 6.07% at z = 0.
The hardware approximation method of Schwarz and Flynn, using the tree circuit of a fast multiplier, can provide a much better approximation (e.g., to 16 bits, needing only two iterations for 64 bits of precision)
Initial Approximation Using Table Lookup
Table-lookup can yield a better starting estimate x (0)^ for z
For example, with an initial estimate accurate to within 2–^8 , three iterations suffice to increase the accuracy of the root to 64 bits
x ( i +1)^ = 0.5( x ( i )^ + z / x ( i ))
Example 21.1: Compute the square root of z = (2.4)ten
x (0)^ read out from table = 1.5 accurate to 10–^1 x (1)^ = 0.5( x (0)^ + 2.4 / x (0)) = 1.550 000 000 accurate to 10–^2 x (2)^ = 0.5( x (1)^ + 2.4 / x (1)) = 1.549 193 548 accurate to 10–^4 x (3)^ = 0.5( x (2)^ + 2.4 / x (2)) = 1.549 193 338 accurate to 10–^8
Check: (1.549 193 338)^2 = 2.399 999 999