magnitude comparator

19
Magnitude Comparator Module M5.2 Section 6.1

Upload: nevina

Post on 22-Mar-2016

189 views

Category:

Documents


6 download

DESCRIPTION

Magnitude Comparator. Module M5.2 Section 6.1. 4-Bit Equality Detector. A[3..0]. Equality Detector. A_EQ_B. B[3..0]. Magnitude Comparator. A_LT_B. A[3..0]. Magnitude Detector. A_EQ_B. B[3..0]. A_GT_B. Magnitude Comparator. How can we find A_GT_B?. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Magnitude Comparator

Magnitude Comparator

Module M5.2Section 6.1

Page 2: Magnitude Comparator

4-Bit Equality Detector

EqualityDetector

A[3..0]

B[3..0]A_EQ_B

Page 3: Magnitude Comparator

Magnitude Comparator

MagnitudeDetector

A[3..0]

B[3..0]A_EQ_B

A_LT_B

A_GT_B

Page 4: Magnitude Comparator

Magnitude Comparator

How can we find A_GT_B?

How many rows would a truth table have?

28 = 256!

A0

A1

A2

A3

B0

B1

B2

B3

A_EQ_B

C0

C1

C3

C2

Page 5: Magnitude Comparator

Magnitude Comparator

If A = 1001 and B = 0111is A > B?Why?

Because A3 > B3i.e. A3 & !B3 = 1

Therefore, one term in thelogic equation for A_GT_B isA3 & !B3

Find A_GT_BA0

A1

A2

A3

B0

B1

B2

B3

A_EQ_B

C0

C1

C3

C2

Page 6: Magnitude Comparator

Magnitude Comparator

If A = 1101 and B = 1011is A > B?Why?

Because A3 = B3 and A2 > B2i.e. C3 = 1 and A2 & !B2 = 1

Therefore, the next term in thelogic equation for A_GT_B isC3 & A2 & !B2

A_GT_B = A3 & !B3 # …..

A0

A1

A2

A3

B0

B1

B2

B3

A_EQ_B

C0

C1

C3

C2

Page 7: Magnitude Comparator

Magnitude Comparator

If A = 1010 and B = 1001is A > B?Why?

Because A3 = B3 and A2 = B2 and A1 > B1i.e. C3 = 1 and C2 = 1 and A1 & !B1 = 1

Therefore, the next term in thelogic equation for A_GT_B isC3 & C2 & A1 & !B1

A_GT_B = A3 & !B3 # C3 & A2 & !B2 # …..

A0

A1

A2

A3

B0

B1

B2

B3

A_EQ_B

C0

C1

C3

C2

Page 8: Magnitude Comparator

Magnitude Comparator

If A = 1011 and B = 1010is A > B?Why?

Because A3 = B3 and A2 = B2 and A1 = B1 and A0 > B0i.e. C3 = 1 and C2 = 1 and C1 = 1 and A0 & !B0 = 1

Therefore, the last term in thelogic equation for A_GT_B isC3 & C2 & C1 & A0 & !B0

A_GT_B = A3 & !B3 # C3 & A2 & !B2 # C3 & C2 & A1 & !B1 # …..

A0

A1

A2

A3

B0

B1

B2

B3

A_EQ_B

C0

C1

C3

C2

Page 9: Magnitude Comparator

Magnitude Comparator

A_GT_B = A3 & !B3 # C3 & A2 & !B2 # C3 & C2 & A1 & !B1 # C3 & C2 & C1 & A0 & !B0

A0

A1

A2

A3

B0

B1

B2

B3

A_EQ_B

C0

C1

C3

C2

Page 10: Magnitude Comparator

Magnitude Comparator

A_LT_B = !A3 & B3 # C3 & !A2 & B2 # C3 & C2 & !A1 & B1 # C3 & C2 & C1 & !A0 & B0

Find A_LT_BA0

A1

A2

A3

B0

B1

B2

B3

A_EQ_B

C0

C1

C3

C2

Page 11: Magnitude Comparator

ABEL ProgramMODULE magcomp4

TITLE '4-BIT COMPARATOR, R. Haskell, 9/21/02‘

DECLARATIONS

" INPUT PINS "

A3..A0 PIN 6,7, 11, 5;

A = [A3..A0];

B3..B0 PIN 72, 71, 66, 70;

B = [B3..B0];

" OUTPUT PINS "

A_EQ_B PIN 36;

A_LT_B PIN 37;

A_GT_B PIN 35;

C3..C0 NODE;

C = [C3..C0];

A0

A1

A2

A3

B0

B1

B2

B3

A_EQ_B

C0

C1

C3

C2

Page 12: Magnitude Comparator

ABEL Program (cont.)EQUATIONS

C = !(A $ B);

A_EQ_B = C0 & C1 & C2 & C3;

A_GT_B = A3 & !B3

# C3 & A2 & !B2

# C3 & C2 & A1 & !B1

# C3 & C2 & C1 & A0 & !B0;

A_LT_B = !A3 & B3

# C3 & !A2 & B2

# C3 & C2 & !A1 & B1

# C3 & C2 & C1 & !A0 & B0;

Page 13: Magnitude Comparator

ABEL Program (cont.)test_vectors ([A, B] -> [A_EQ_B, A_LT_B, A_GT_B])

[0, 0] -> [1, 0, 0];

[2, 5] -> [0, 1, 0];

[10, 12] -> [0, 1, 0];

[7, 8] -> [0, 1, 0];

[4, 2] -> [0, 0, 1];

[6, 6] -> [1, 0, 0];

[1, 7] -> [0, 1, 0];

[5, 13] -> [0, 1, 0];

[12, 0] -> [0, 0, 1];

[6, 3] -> [0, 0, 1];

[9, 9] -> [1, 0, 0];

[12, 13] -> [0, 1, 0];

[7, 0] -> [0, 0, 1];

[4, 1] -> [0, 0, 1];

[3, 2] -> [0, 0, 1];

[15, 15] -> [1, 0, 0];

END

Page 14: Magnitude Comparator
Page 15: Magnitude Comparator
Page 16: Magnitude Comparator
Page 17: Magnitude Comparator

TTL Comparators1 2 3 4 5 6 7

9 10 11

128

1920

1718

1516

1314

GND

Vcc P>Q P0Q0P1Q1P2Q2P3Q3

P=Q Q7P7Q6P6Q5P5Q4P4

74LS682

1 2 3 4 5 6 7 8 9

10111213141516

GND

Vcc B3A<Bin A=Bin A>Bin A>BoutA=BoutA<Bout

A3B2A2A1B1A0B0

74LS85

Page 18: Magnitude Comparator

Cascading two 74LS85s

13

1

3 6

9

14

2

10

11

7

4

15

12

5

P0P1P2P3

Q0Q1Q2Q3

< = >

P<Q

P=Q

P>Q

13

1

3 6

9

14

2

10

11

7

4

15

12

5

P0P1P2P3

Q0Q1Q2Q3

< = >

P<Q

P=Q

P>Q

A3 A2 A1 A0 A7 A6 A5 A4

B3 B2 B1 B0 B7 B6 B5 B4

+5V A<B A=B A>B

Page 19: Magnitude Comparator

Question

1 2 3 4 5 6 7

9 10 11

128

1920

1718

1516

1314

GND

Vcc P>Q P0Q0P1Q1P2Q2P3Q3

P=Q Q7P7Q6P6Q5P5Q4P4

74LS682

P_GT_QP_EQ_QP_LT_Q

Draw a logic circuit forwhat is in the green box.