Sunteți pe pagina 1din 10

Experiment 4: Comparators

Brief overview of the experiment: In this experiment performed on 4 October 2012 in the electronics laboratory, we shall use ICs to design and implement circuits which use comparators. Objective: 1. Question 1: A truth table of a 1 bit comparator was given and we were told to design and implement a circuit using only AND, NOT and NOR gates for this 1 bit comparator. 2. Question 2: A truth table of a 2 bits binary comparator was given and we were told to design and implement a circuit using 2 one-bit comparator and gates available that will give outputs of the table. 3. Question 3: An unsigned 4 bit binary number is given and a circuit is to be designed and implemented to show if the number is less than 5(low), between 5 and 10 inclusive (neutral) and more than 10(high). 4. Question 4: Design and implement a 4 bit equality comparator circuit which has two 4 bit binary number inputs. Apparatus used: 1) Integrated circuits: 74LS02, 74LS04, 74LS08. 2) Instruments Feedback intikit CK353 Gwinstek GPS-3303. 3) DC power supply. Theory: The basic function of a comparator is to compare the magnitudes of 2 binary numbers and return one of the 3 possible outcomes: (i) A=B (ii)A>B (iii) A<B When A=B for a 1-bit comparator A B Output X 0 0 1

Experiment 4: Comparators
0 1 1 1 0 1 0 0 1 The table shows the output of a XNOR gate. That is, when the inputs are the same the output is high whereas when the inputs are different the output is low.

When A=B for a 2-bit comparator To compare two equal numbers, 2 XNOR gates are used and 1 NAND gate.

Hence to compare 2 equal n-bit numbers, n XNOR gates are used. When AB. When AB either A>B or A<B. For 1-bit binary number, if A=1 and B=0, then obviously A >B. In order to compare two 2-bit binary number and determine if A>B or A<B, we should compare the binary numbers bit by bit. E.g A1A0=01 and B1B0=00The most significant bit i.e A1 and B1 is compared and since A1=B1 we now compare the next least significant bit i.e A0 and B0. A0>B0 hence binary number A is greater than binary number B. Procedure: Question 1 A truth table for a 1-bit comparator is given below and a circuit with AND, NOT and NOR gates must be designed and implemented using the given truth table. A B A<B A=B A>B

Experiment 4: Comparators
0 0 1 1 0 1 0 1 0 1 0 0 1 0 0 1 0 0 1 0

Truth table for 1 bit comparator

B A 1 0

A K-map is drawn 0 1

Boolean expression:

for A=B : A`B` + AB For A>B: AB` For A<B: A`B

The figure above shows the circuit for 1-bit comparator. 1) The circuit above is implemented using the ICs provided 2) A<B ,A=B,A>B is connected to lamp L1,L2,L3 respectively. Results:

Experiment 4: Comparators

A 0 0 1 1

B 0 1 0 1

A<B 0 1 0 0

A=B 1 0 0 1

A>B 0 0 1 0

Procedure: Question 2 A truth table for a 2-bit comparator is given. A circuit which has two 1-bit comparator is designed and implemented. input A1 B1 A1>B1 A1<B1 A1=B1 A1=B1 A1=B1 A0 X X A0>B0 A0<B0 A0=B0 input B0 output A>B 1 0 1 0 0 output A<B 0 1 0 1 0 output A=B 0 0 0 0 1

Truth table for 2-bit binary comparator k-Maps for A<B,A=B,A>B are designed from the truth table B1B0 0 1 1 1 0 0 1 1 0 0 0 0 0 0 1 0 =A1B1+( A1B1 + A1`B1`)(A0B0`) For A>B Boolean expression derived: A1B1' + A1A0B1B0 + A1A0B1B0

A1A0

Let A1B1 + A1`B1`= x1 =A1B1` + x1A0B0`

Experiment 4: Comparators
B1B0 A1A0 0 0 0 0 Boolean expression derived: A1`B1 + A1A0`B1B0+ A1`A0`B1`B0 =A1`B1 + (A1B1+A1`B1`)(A0`B0) Let A1B1 + A1`B1`= x1 =A1`B1 + x1 A0`B0 B1B0 A1A0 1 0 0 0 0 1 0 0 K-map Boolean expression derived: F=A1A0B1B0 + A1`A0`B1`B0` + A1`A0B1`B0 + A1A0`B1B0` =A0B0 (A1`B1`) + A0`B0`(A1B1) = (A0B0 + A0`B0`)(A1B1 + A1`B1`) =x0x1 0 0 1 0 0 0 0 1 For A=B 1 0 0 0 1 1 0 1 1 1 0 0 For A<B

Experiment 4: Comparators

The circuit shown above is a 2-bit binary comparator Results obtained: input A1 B1 A1>B1 A1<B1 A1=B1 A1=B1 A1=B1 A0 X X A0>B0 A0<B0 A0=B0 input B0 output A>B 1 0 1 0 0 output A<B 0 1 0 1 0 output A=B 0 0 0 0 1

Procedure: Question 3 An unsigned 4 bit binary number X: X1, X2, X3, X4. is given. A circuit that would detect if 1) Number X is low(<5) 2) Number X is high (>10) 3) Number X is neutral (between 5 and 10 inclusive)

Experiment 4: Comparators
X4 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 X3 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 X2 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 X1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 low 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 neutral 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 high 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1

A truth table is designed and K-Maps for low, high and neutral will be drawn.

K-Map for low(<5) X2X1 X4X3 1 1 0 1 0 0 1 0 0 1 0 0

F=X4`X3` + X4`X2`X1`

Experiment 4: Comparators
K-Map for high (>10) X2X1 X4X3 0 0 1 0 0 0 1 0 0 0 1 1 0 0 1 0

G = X4X3 + X4X2X1 K-Map for neutral X2X1 X4X3 0 0 0 1 0 1 0 1 0 1 0 0 0 1 0 1 B B=X4`X3X1 + X4`X3X2 + X4X3`X2` + X4X3`X1`

Experiment 4: Comparators
Implementation:

Procedure: Experiment 4 A 4-bit equality comparator circuit has two 4 bit binary numbers as inputs, A(A3,A2,A1,A0) and B(B3,B2,B1,B0).A and B are unsigned integers .The output F of the comparator is `1` if A=B; otherwise F is `0`. A circuit which contains a 4 bit equality comparator must be designed and implemented. Boolean expression: F= x3x2x1x0 =(A3B3+ A3`B3`)(A2B2+A2`B2`)(A1B1+ A1`B1`)(A0B0+A0`B0`)

Experiment 4: Comparators

Conclusion: Comparators are mostly used to compare the magnitude of 2 binary numbers and XNOR gates are used to compare if the 2 binary numbers are equal. Also, comparators are commonly used in devices such as analog to digital convertors.

S-ar putea să vă placă și