Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
CS 2600
The Two's Complement Representation
Range of numbers in twos complement method:
n-1 n-1
2
-2 X 2 - 1
There is a un
unique
qu representation
p n n f
for 0
0011 3 0101 5
+ 1011 -5 + 1101 -3
1111 0000 0001
1110 2
-2 1 0010 2
0010
1110
1
-1 0 +1
-2 +2 0011
1101
-4 +3
-3
3 +4
1100 0100
-5
+5
1011
-6 +6 0101
-7 -8 +7
1010
0001 1 0111 0110 0111 7
1001 1000
+ 1111 -1 + 1101 -3
1 0000 0 1 0100
0100 44
Example (twoscomplement)
010019
01001 9
110017
1000102
Carryoutdiscarded doesnot
indicateoverflow
Ingeneral,ifX andYhave
opposite signs nooverflow
oppositesigns no overflow
canoccurregardlessof
whetherthereisacarryoutor
h th th i t
not
If X and Y have the same sign and result has
different sign - overflow occurs
Examples - (two
(twoss complement)
10111 -9
10111 -9
1 01110 14 = -18 mod 32
Carry-out and overflow
01001 9
00111 7
C
Condition for
f overflow
f (f
(for logic implementation):
)
A
Assume 3 i/ XOR gate
3-i/p t for
f Si and
d SOP fform for
f Ci+1
Ripple-Carry
Ripple Carry Adder
c4
O Cn Cn 1; TD/C = 2N;
TD/S = 2N-1;
TD/O = 2N+2
O xn 1 yn 1 S n 1 x n 1 y n 1S n1
Subtraction
CascadeofKNbitRCAsalsopossible butdelayislarge
LookAheadAdder
Let Pi xi yi , Gi xi yi ;
Pi
Si Pi Ci xi
yi + + Si
ci 1 Gi Pi Ci
Ci 1
Ci Gi +
C1 G0 P0C0
C2 G1 P1G0 P1P0C0
74283 contd.
hsi xi yi ( xi yi )( xi . yi ) pi g i
Substituting
ci Gi 1 ci 1Pi 1; ci 1 Gi Gi 1Pi ci 1Pi 1Pi
Further substitutions -
A4
B4
+ P4
C5 C5
G4
A3 P4
B3 + P4
C4 + S4
G4
A2 P3
B2
+ P4 C3 + S3
G4
A1 P2
B1
+ P4 C2 + S2
G4
P1 + S1
C1 C1
Example - 4-bit Adder
- Draw Ckt.
Ckt
F RCA:
For RCA TD/RCA = 8;
8
SN-1 S1 S0
YN-1 X N-1 Y1 X1 Y0 X0
FA C0
PL PL
CN-1 C2 C1
GN-1 PN-1 G1 P1 G0 P0
CN
Carry lookahead logic
S KN..(KN-1)
KN (KN-1) S N..(2N-1) S 0..(N-1)
CascadeofKNbitLACFAsalsopossible
Let:
Po*
P3 P2 P1P0 ; *
Go G 3 P3G 2 P3 P2G1 P3 P2 P1G0 ;
Then, C 4 *
Go *
Po C0
If:
P1*
P7 P6 P5 P4 ; *
G1 G 7 P7G 6 P7 P6G5 P7 P6 P5G4 ;
Then, C8 *
G1 *
P1 C4 *
G1 * *
P1 G0 * *
P1 P0 C0
Similarly , C12 *
G2 *
P2 C8 ; C16 *
G3 *
P3 C12
16-bit 2-level Carry-look-ahead Adder
n=16 - 4 groups
Outputs: Go* , G1* , G2* , G3* , P0* , P1* , P2* , P3* ;
Inputs to a carry-look-ahead
carry look ahead generator with
outputs c4,c8,c12
C 4 Go
*
*
Po C0 ; C8 *
G1 *
P1 C4 *
G1 * *
P1 G0 * *
P1 P0 C4
Similarly , C12 *
G2 *
P2 C8
*
G2 * *
P2 G1 * * *
P2 P1 G0 * * *
P2 P1 P0 C0
C16 *
G3 *
P3 C12
*
G3 * *
P3 G2 * * *
P3 P2 G1 * * * *
P3 P2 P1 Go * * * *
P3 P2 P1 P0 C0
Expression/Output Implementation Total Delay
(4-stage block) Delay C12 C15 :
Gi ; Pi 1 1 5 2 7;
Gi* ; Pi* 2; 1 3; 2
Ci = 4, 8, 12, 16 2 5 S15 :
Si 2 + 1 = 3 8
7 1 8
For LAC-L1, delays are: C16 -> 9, S15 -> 10
YKN..(KN-1) X KN..(KN-1) YN..(2N-1) X N..(2N-1) Y0..(N-1) X 0..(N-1)
((K=2)C
) 28 >C31 7+2=9 (K=4)C60,C64 9+2=11
(K=2)S31 9+1=10 (K=4)C60 >C63 11+2=13
(K=4)S63 13+1=14
Comparison of the Delay of different systems
Adder C4 C8 C16 S15 C32 S31 C64 S63
RCA 8 16 32 31 64 63 128 127
LAC-FA 3 5 9 10 17 18 33 34
HLG&P
HLG&P - - 5 8 7 10 11 14
CA
??
C16 *
G3 *
P3 C12 L2 HLG&P CA
*
G3 * *
P3 G2 * * *
P3 P2 G1 * * * *
P3 P2 P1 Go * * * *
P3 P2 P1 P0 C0
**
Go **
P0 C0 ;
where,
**
Go *
G3 * *
P3 G2 * * *
P3 P2 G1 * * * *
P3 P2 P1 Go ;
P0**
* * * *
P3 P2 P1 P0
C 16 G 3* P3* C 12
G 3* P3* G 2* P3* P2* G 1* P3* P2* P1* G o* P3* P2* P1* P0* C 0
Delay for C16: 5
G o* * P0* * C 0 ;
Delay for S63: 12
where , Delay for C64: 7
- Pipelined
- Manchester Adder
- Carry-Skip/Carry Select
- Parallel Prefix
- Carry-save
C adders
dd Wallace
W ll ttree
-
1101
x1011
MULTIPLIER UNIT ---------------------
1101
1101
0000
1101
_____________
11 00 00 0
111111 111
Three types of high-speed multipliers:
Sequential multiplier - generates partial products
sequentially and adds each newly generated
product to previously accumulated partial product
qi qi
Cout Cin
PPi,j
Multiplixer to decide:
Result to be held in 2
2-K
K bit SR.
Unsigned Binary Multiplication
Flowchart for Unsigned Binary
p
Multiplication
Execution of Example
p
Booths Algorithm for unsigned
p
multiplication
Thus
h M(
(Multiplicand)
l i li d) X 14 = M X 24 = M X 21 ;
y
Obtain result by:
M << 4 - M << 1 // view as C-code.
Take a example: multiplier = 30; Multiplicand = 45
(30) -->
> 32 2 => Change Multiplier to:
0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 0 ..
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
Mult 0 0 1 0 1 1 0 0 1 1 1 0 1 0 1 1 0 0
Coded
0 +1 -1 +1 0 -1 0 +1 0 0 -1 +1 -1 +1 0 -1 0 0
Mult.
Three rules for Booths algm. implementation with
operation on the multiplicand:
0 1 1 0 1
0 -1 +1 -1 0
- - - - - - - - -
0 0 0 0 0 0 0
1 1 1 1 1 1 0 0 1 1
0 0 0 1 1 0 1
1 1 1 1 0 0 1 1
0 0 0 0 0 0 0
- - - - - - - - - - - -
1 1 1 1 1 0 1 1 0 0 1 0
Fast Multiplication done by:
- Bit-pair recoding
- + F
Fastt L
Look
k ahead
h d Carry
C (with
( ith both
b th above)
b )
- etc.
BIT-PAIR RECODING OF MULTIPLIERS
Observe this:
-6 11010 0 -1 +1 -1 0
-6 1 1 1 0 1 0
0 0 -1 +1 -1 0
0 0 -1 0 -2
Execution of Example
Booths Recoded Multiplier
+13 01101
-6 11010 0 -1 +1 -1 0 0 0 -1 0 -2
0 1 1 0 1
0 0 -1 0 -2
- - - - - - - - -
1 1 1 1 1 1 0 0 1 1 0
0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 0 0 1 1
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0
- - - - - - - - - - - -
1 1 1 1 1 0 1 1 0 0 1 0
Unsigned Binary Division
03 +13 1101 DIVISOR;
63 243
274 100010010 DIVIDEND
189
54 1 0 1 0 1
1 1 0 1 1 0 0 0 1 0 0 1 0
- 1 1 0 1
_ _ _ _ _
21 1 0 0 0 0
13 274 - 1 1 0 1
26 _ _ _ _ _
1 1 1 0
14 - 1 1 0 1
- 13 _ _ _ _ _
1
01
Unsigned
g Binary
y Division
Divisor M
Subtract
or
Add
Shift Left
Dividend Q
Flowchart for Unsigned Binary Division
ALGO. for RESTORING DIVISION
Load Divisor in Reg. M;
Load Dividend in Reg. Q;
Set Reg. A = 0;
Repeat n times:
A = A M;
If sgn(A) == 1 ((-ve
ve A)
o Set Q0 = 0;
o A = A + M;
Else
o Set Q0 = 1; ANS:
- Rem.
R is
i in
i Reg.
R A.
A
OPN. REG. A REG. Q
INIT. 0 0 0 0 0 1 0 0 0
Dividend,
Dividend
S. L. 0 0 0 0 1 0 0 0
Q = 1000;
I SUB 1 1 1 1 0
Divisor,
Divisor Rstr 0 0 0 0 1 0 0 0 0
M = 11. S. L. 0 0 0 1 0 0 0 0
II SUB 1 1 1 1 1
Rstr 0 0 0 1 0 0 0 0 0
-M=
11101
S. L. 0 0 1 0 0 0 0 0
III SUB 0 0 0 0 1
Set-Q0 0 0 0 0 1 0 0 0 1
Result, in
decimal ?? S. L. 0 0 0 1 0 0 0 1
IV SUB 1 1 1 1 1
Quotient Rstr 0 0 0 1 0 0
= 02 ;
Final
0 0 0 1 0 0 0 1 0
Rem = 02. Result
REM Q
How to improve the Algo. ??
Repeat n times:
If A is +ve, If A is -ve,
ve
Opns. : Opns. :
2
2. If sgn(A)
(A) == 0 Repeat n times:
i
o Set Q0 = 1;
o else Q0 = 0; Shift (left) A & Q (1 bit posn.)
End
A = A M;
Step
p 2: If sgn(A)
g ( ) == 1
A = A + M; If sgn(A) == 1 (-ve A)
o Set Q0 = 0;
o A = A + M;
NON_RESTORING
Else
DIVISION
o Set Q0 = 1;
End
OPN. REG. A REG. Q
INIT. 0 0 0 0 0 1 0 0 0
Dividend,
Dividend S L
S. L. 0 0 0 0 1 0 0 0
Q = 1000; I SUB 1 1 1 1 0
Set Q0 1 1 1 1 0 0 0 0 0
Divisor,
M = 11. S. L. 1 1 1 0 0 0 0 0
II ADD 1 1 1 1 1
Set Q0 1 1 1 1 1 0 0 0 0
-M= S L.
S. 1 1 1 1 0 0 0 0
11101 III ADD 0 0 0 0 1
Set-Q
Set Q0 0 0 0 0 1 0 0 0 1
S. L. 0 0 0 1 0 0 0 1
IV SUB 1 1 1 1 1
Set-Q0 1 1 1 1 1 0 0 1 0
ADD 0 0 0 1 0 0 0 1 0
Final Result 0 0 0 1 0 0 0 1 0
REM Q
Floating Point Numbers
IEEE 32
32-bit
bit single precision
E
S M
(excess-127 Rep.)
0/1 8 23
Value of (S,E,M) :
((-1)0 =1 ; (-1)1 =-1)
E is a signed
signed exponent,
exponent , E
E is in excess
excess-127
127 Representation
E ' E 127; The end values are reserved for special use:
0 E ' 255
2 1 E ' 254; E E '127;
127 E 128; 126 E 127;
Range,
for Exponent:
p For Mantissa:
126 127 38 23 7
[2 ....2 ] 10 [2 ] 10
In IEEE 64-bit single precision;
E ' E 1023 ; 1 E ' 2046
Range, 1022 E 1023 ;
for Exponent: For Mantissa:
1022 1023 308 53 16
[2 ....2 ] 10 [2 ] 10
Floating-Point
g Formats of Three Machines
Binary Normalized Mantissa (IEEE):
0 10001000 .0010110 .
Numerical Value (unnormalized): = +0.0010110. x 29
0 10000101 .0110 .
1 00101000 .001010 .
q
Inexact Result that requires rounding
g in order to be
represented in one of the normal formats;