Professional Documents
Culture Documents
Comparator Operation
Comparator Operation
1
Procedure How to compare two 4-bit numbers
A = A3A2A1A0 and B=B3B2B1B0
1. Compare the most significant bits A3 and B3 of the numbers. If
A3 is a 1 and B3 is a 0, then A is greater than B regardless of
how the remaining bits compare. Similarly, if A3 is a 0 and B3 is
a 1, then B is greater than A. If and only if, A3 and B3 coincide,
then go to step 2.
2. Compare the next significant bits, A2 and B2 of the numbers. If
A2 is a l and B2 is a 0, then A is greater than B regardless of how
the remaining bits compare. Similarly, if A2 is a 0 and B2 is a 1,
then B is greater than A. If and only if, A2 and B2 coincide, then
go to step 3.
3. If A1 is a 1 and B1 is a 0, then A is greater than B regardless of
how the remaining bits compare. If A1 is a 0 and B1 is a 1, then
B is greater than A. If and only if, A1 and B1 coincide, then go to
step 4.
4. If A0 is a 1 and B0 is a 0, then A is greater than B. If A0 is a 0
and B0 is a l, then B is greater than A. If A0 and B0 are equal,
then the numbers A and B are equal
2
Condition for EQUALITY i.e. A=B
Two binary numbers are equal, if and only if
all their corresponding bits coincide
A3 = B3 ,
A2 = B2,
A1 = B1 and
A=B
A0 = B0
( )( )( )(
Equalty = A 3 ⊕ B3 A 2 ⊕ B2 A1 ⊕ B1 A 0 ⊕ B0 )
3
Logic diagram of an equality Comparator
(A 3
)( )( )(
⊕ B 3 A 2 ⊕ B 2 A 1 ⊕ B1 A 0 ⊕ B 0 )
4
Condition For A>B
1. If A3 = 1 and B3 = 0, A 3
B 3
then A > B. or
2. If A3 and B3 coincide,
and if A2 = 1 and B2 = (A 3
)
⊕ B3 A 2 B2
0, then A > B. or
3. If A3 and B3 coincide,
and if A2 and B2 (A 3
)(
⊕ B3 A 2 ⊕ B2 A1 B1 )
coincide, and if A1 = 1
and B1=0, then A>B. or
4. If A3 and B3 coincide,
and if A2 and B2
coincide, and if A1 and (A 3
)(
⊕ B3 A 2 ⊕ B2 A1 ⊕ B1 A 0 B0)( )
B1 coincide, and if A0=1
and B0= 0, then A > B.
( ) ( )( ) ( )(
A > B = A3B3 + A3 ⊕B3 A2B2 + A3 ⊕B3 A2 ⊕B2 A1B1 + A3 ⊕B3 A2 ⊕B2 A1 ⊕B1 A0B0 )( ) 5
Similarly, the expression for B > A can be written as
( ) ( )( ) ( )( )( )
B > A = A3B3 + A3 ⊕ B3 A2 B2 + A3 ⊕ B3 A2 ⊕ B2 A1B1 + A3 ⊕ B3 A2 ⊕ B2 A1 ⊕ B1 A0 B0
6
B3
B 2
B 1
B 0
A≥B
A3
B 3
B A2
2
A1
B 1
B A0
0
7
Pin Diagram of the 7485 4-bit comparator
8
Cascading two 7485 4-bit comparator to create an
8-bit comparator
9
PARITY BIT GENERATORS/CHECKERS
11
Error Detection
9 At the receiving end, if the word received has an
even number of 1s in the odd parity system or an
odd number of 1s in the even Parity system, it
implies that an error has occurred
12
Even Parity generator
•To generate an even parity bit, the four data bits are
added using three X-OR gates
13
Odd Parity generator
•To generate an odd parity bit, the four data bits are
added using three X-OR gates and the sum bit is
inverted
14
Even Parity checker
0
1
0
0
1 1
0
0
1
0
0
1
15
Odd Parity checker
0 0
0 0
1
0
1
1
0 1
0
1
16