Eri Prasetyo
Overview
Binary Number Representation Sign & Magnitude, Ones Complement, Twos Complement Binary Addition Full Adder Revisited A ! "esign BC" Cir#uits Combinational Multiplier Cir#uit "esign Case Study$ % Bit Multiplier Se&uential Multiplier Cir#uit
Number Systems
Representation of Negative Numbers
Representation o' positive numbers same in most systems Ma(or di''eren#es are in )ow negative numbers are represented T)ree ma(or s#)emes$ sign and magnitude ones #omplement twos #omplement Assumptions$ we*ll assume a + bit ma#)ine word ,- di''erent values #an be represented roug)ly )al' are positive, )al' are negative
Number Systems
Sign and Magnitude Representation
-7 -6 -5 -4 -3 -2
1111 1110
+0
0000 0001 0010
+1 +2 +3 +4 +5
+ 0 100 = + 4 1 100 = - 4 -
1101
-1
+6
-0
+7
High order bit is sign: 0 = positive (or zero), Number range for n bits = %&'(n' Representations for 0 '
= negative )
= 0000
+0
0000 0001 0010
+1 +2 +3 +4 +5
+ 0 100 = + 4 1 011 = - 4 -
1101
-6
+6
-7
+7
Subtra#tion implemented by addition & ,*s #omplement Still two representations o' /0 T)is #auses some problems Some #omple1ities in addition
+0 +1
0001 0010
+2 +3 +4 +5
+ 0 100 = + 4 1 100 = - 4 -
-4 -5 -6
-7
+6
-8
+7
Only one representation 'or / One more negative number t)an positive number
2 ( = sub '$ =
0000 00 0 = repr/ of $
Short,ut method: !#os ,omp"ement = bit#ise ,omp"ement % 0 '1 000 % '1 00 (representation of '$) '1 0 (representation of $) 00 '1 0 0 %
#hen signs differ, operation is subtra,t, sign of resu"t depends on sign of number #ith the "arger magnitude
2 '6
0 00 0 000
'2 %6 '
00 00 00
(M 1 N) M%N?( n'
' (M % N)
Simp"er addition s,heme ma9es t#os ,omp"ement the most ,ommon ,hoi,e for integer number s0stems #ithin digita" s0stems
Number 4ddition and Subtra,tion of 7inar0 Numbers Systems !#os *omp"ement *a",u"ations
8h0 ,an the ,arr0'out be ignored: 'M % N #hen N 1 M: n n M3 % N = (( ' M) % N = ( % (N ' M) n ;gnoring ,arr0'out is Aust "i9e subtra,ting ( 'M % 'N #here N % M ? or = ( n'
n n 'M % ('N) = M3 % N3 = (( ' M) % (( ' N) n n = ( ' (M % N) % ( 4fter ignoring the ,arr0, this is Aust the right t#os ,omp"/ representation for '(M % N)@
4dd t#o positive numbers to get a negative number or t#o negative numbers to get a positive number +0
0000 0001 0010 0011 0100 0101 1000 0110 0111
-1 +1 +2 +3 +4 +5 -4 -5 -6 -7 -8 -7 - 2 = +7! -3 -2
1111 1110
+0
0000 0001 0010 0011 0100 0101
+1 +2 +3 +4 +5
+6
0110 0111
+6
+7 5 + 3 = -8!
+7
B ( $
0 000
No overf"o#
Multiplication
Multiplication is a complex operation, w et er per!orme" in ar"ware or so!tware # e multiplication o! two$n bit binary integers results in a pro"uct o! up to %n bits in lengt & e'g', ((x(( ) (**(+
(*(( x ((*( (*(( **** (*(( (*(( (***(((( multiplican" &((+ multiplier &(,+
Partial Pro"uct
Pro"uct &(-,+
S i!t rig t
Ao
2*
Example
3 * * * A **** (*(( *(*( 2 ((*( ((*( (((* M (*(( (*(( (*(( /nitial 4alues A"" s i!t 5irst 3ycle secon" 3ycle Pro"uct in A, 2 * * ((*( *((* (((( (((( (*(( (*(( A"" S i!t # ir" 3ycle 5ourt 3ycle
**(*
((((
(*((
S i!t
( *
***( (***
(((( ((((
(*(( (*((
A"" S i!t
No
2*)(6
yes
3,A A 7 M
No
3ount )*6
yes
en"
Pro"uct /n A,2
)(*
2*,2$(
)*(
AA$M
)(( )**
Arit metic S i!t rig t A,2,2$( 3ount count$(
AA7M
No
3ount )*6
yes
en"
Example
A **** (**( ((** 2 **(( **(( (**( 2$( * * ( M *((( *((( *((( /nitial 4alues A a$M s i!t 5irst 3ycle secon" 3ycle # ir" 3ycle 5ourt 3ycle
(((*
*(**
*(((
S i!t
*(*( **(*
*(** (*(*
( *
*((( *(((
A A7M S i!t
***(
*(*(
*(((
S i!t
Sum = Ai Bi + Ai Bi = Ai + Bi
Carry = Ai Bi
Ai 1i
Sum
Ha"f'adder S,hemati,
3arry
S 3 C 3 S 2 C 2 S 1 C 1 S 0
usua""0 interested in adding more than t#o bits this motivates the need for the fu"" adder
Du"" 4dder
A 0 0 0 0 1 1 1 1
A B CI 00 01 11 10 CO 0 1 0 0 0 1 1 1 0 1
S = *; .or 4 .or 7 *) = 7 *; % 4 *; % 4 7 = *; (4 % 7) % 4 7
A B CI
Half Adder CO A B
A+B
Half AdderCO CI A + B!
+
A + B + CI
CO
4 7 % *; (4 .or 7) = 4 7 % 7 *; % 4 *;
A 3O 7 S
1 3/
A 3O 7 S
1 3/
A 3O 7 S
1 3/
A 3O 7 S
1 3/ A"";Subtract
S,
S%
S(
S*
Over!low
4 ' 7 = 4 % ('7) = 4 % 7 %
*riti,a" de"a0: the propagation of ,arr0 from "o# to high order stages
2 stage adder
1*
*riti,a" de"a0: the propagation of ,arr0 from "o# to high order stages
S 0 , C 1 V a lid S 1 , C 2 V a lid S 2 , C 3 V a lid S 3 , C 4 V a lid
T 0
T 2
T 4
T 6
T 8
!0: ;nputs to the adder are va"id !(: Stage 0 ,arr0 out (* ) !2: Stage ,arr0 out (*() !5: Stage ( ,arr0 out (*6) !C: Stage 6 ,arr0 out (*2) ( de"a0s to ,ompute sum but "ast ,arr0 not read0 unti" 5 de"a0s "ater
Sum and *arr0 ,an be ree.pressed in terms of generate&propagate: Si = 4i .or 7i .or *i = Gi .or *i *i% = 4i 7i % 4i *i % 7i *i = 4i 7i % *i (4i % 7i) = 4i 7i % *i (4i .or 7i) = Ei % *i Gi
3* P* @*
3(
3* P* P( P% @* P( P% @( P% @% 3,
3* P* P( P% P, @* P( P% P, @( P% P, @% P, @,
3* P* P( @* P( @( 3%
3-
2 bit adders #ith interna" ,arr0 "oo9ahead se,ond "eve" ,arr0 "oo9ahead unit, e.tends "oo9ahead to 5 bits Eroup G = G6 G( G G0 Eroup E = E6 % G6 E( % G6 G( E % G6 G( G E0
3-
3?
A""er .ig
-D %9( Mux
( * ( * ( *
( *
3-
3*
3?
S>
S=
S:
S-
S,
S%
S(
S*
,ompute the high order sums in para""e" one addition assumes ,arr0 in = 0 the other assumes ,arr0 in =
Subtractor
As we saw be!ore, one o! t e !eatures o! t e %8s complement system was t at t e a""ition an" subtraction processes were very muc t e same' Ee can per!orm subtraction by simply inverting t e bits o! one operan" an" setting t e carry in bit o! t e operation to ('
b, a, b% a% b( a( b* a*
a b = a + (b) = a + (b + 1)
adder
Subtractor &continue"F+
/n or"er to be able to use one package !or bot a""ition an" subtraction, we can use GOR gates as controllable inverters' # ese packages ave t e !ollowing structure9
a"";sub
b,
b% a%
b( a(
b* a* cin
a,
adder
Subtractor &continue"F+
Cet8s now "esign a structure t at can give us t e an" result o! t e two inputs or t e a"";sub result base" on a select line'
b, a"";sub b% b( b* a, a% a( a*
adder
S,
S%
S(
S*
* (
* (
*( An" select
Subtractor &continue"F+
As you can see in t e last example, !our %$to$( multiplexers wit a common select are use" to give us t e nee"e" result base" on t e value o! t e select line'
CO#(+O) SI,#A)S
* Si-1 % S0
A)'
C$ C0
-$-1 % -0
O'(&'(S
Not all operations appear useful, but "fall out" of internal logic
* 0
S1 0 0 1
S0 0 1 0
.i 6 .o 2 .ilb m .ob fi .p 23 111101 110111 1-0100 1-1110 1001010111-10001 010-01 -11011 011-11 --1000 0-1-00 --0010 0-0-10 -0100001-0-0001000-1-1-1-1 --1-01 --0-11 --110--011.e
s1 s0 ci ai bi co 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 01 01 01 01 01
0 0 1
0 1 0
0 0 1
0 1 0
Ci . . . . . . . . . . . . 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1
Ai 0 1 0 1 0 0 1 1 0 0 1 1 0 1 0 1 0 0 1 1 0 0 1 1 0 1 0 1 0 0 1 1 0 0 1 1
Bi . . . . 0 1 0 1 0 1 0 1 . . . . 0 1 0 1 0 1 0 1 . . . . 0 1 0 1 0 1 0 1
-i 0 1 1 0 0 1 1 0 1 0 0 1 0 1 1 0 0 1 1 0 1 0 0 1 1 0 0 1 1 0 0 1 0 1 1 0
Ci+1 . . . . . . . . . . . . . . . . 0 0 0 1 0 1 0 0 0 1 1 0 0 1 1 1 1 1 0 1
A, : B
3i A, , B A, * B A, , B M 3i A, * B 3o
A, , B
A, * B
M 3i I3 o 3i A, * B A, , B I3 o A, * B A, : B I3 o IA, * B IA, : B
5i
( Eates
S = 0 b"o,9s 7i Happens #hen operations invo"ve 4i on"0 Same is true for *i #hen M = 0 4ddition happens #hen M = 7i, *i to Lor gates L(, L6
G%
S0 = 0, L passes 4 S0 = , L passes 4
A,
A-
4rithmeti, Mode:
G, 5i
O( 3i7(
)r gate inputs are 4i *i and 7i (4i .or *i) Fogi, Mode: *as,aded L)Rs form output from 4i and 7i
$2 C
S3 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 Sele12i/$ S2 S1 S0 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1
$2 C
181
5, 5% 5( 5*
(, (( (* J
> 3n ? M
= (: % : (( ,
S, S% S( S* , - : =
P, P% P( P* @, @% @( @*
182
P @ > (*
(, 3n
Dortunate"0, ,arr0 "oo9ahead generator maintains the ,orre,t sense of the signa"s
Arit metic Cogic 0nit Hesign 5'bit 4FI #ith *arr0 Foo9ahead
(J A, %( A% 181 5, %, A( 5% % A* 5( (? 1, 5* %* 1% A)1 %% 1( 3n7( 1* @ > 3n P ?M S,S%S(S* , - : = (J %( %, % (? %* %% ( > ? A, A% A( A* 1, 1% 1( 1* 3n M (, (( (* J ((= (> (: 3(=
181
5, 5% 5( 5* A)1 3n7@ P
(, (( (* J ((= (> (:
S,S%S(S* , - : = (J A, %( A% %, A( % A* (? 1, %* 1% %% 1( ( 1* > 3n ?M
181
5, 5% 5( 5* A)1 3n7@ P
(, (( (* J ((= (> (:
> (* J (( (%
S, S%S(S* , - : = (J %( %, % (? %* %% ( > ? A, A% A( A* 1, 1% 1( 1* 3n M
181
3*
5, 5% 5( 5* A)1 3n7@ P
(, (( (* J ((= (> (:
S,S%S(S* , - : =