This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: © Mark Redekopp, All rights reserved Introduction to Digital Logic Lecture 15: Comparators © Mark Redekopp, All rights reserved Comparators • Compare two numbers and produce relational conditions A<B, A=B, A>B, A ≤ B, and A ≥ B © Mark Redekopp, All rights reserved Greater Than & Less Than & Equal • The only way one bit, A, can be greater than another bit, B, is if A=1 and B=0 • The only way one bit, A, can be less than another bit, B, is if A=0 and B=1 • A and B are equal when they are the same 1 1 A=B 1 A<B 1 1 A 1 1 1 A>B B XNOR A•B A•B A B A=B A B A>B A B A<B © Mark Redekopp, All rights reserved Equality Check • XNOR gate outputs 1 when two bits are equal • To check whether two 4 bit numbers are equal – use 4 XNOR gates to XNOR each pair of bits – only if all the pairs are equal, are the 2 numbers equal (i.e. AND the outputs together) 1 1 A 1 1 1 1 XNOR B A B A=B A B A 1 B 1 A 2 B 2 A 3 B 3 A =B A=B A 1 =B 1 A 2 =B 2 A 3 =B 3 © Mark Redekopp, All rights reserved GreaterThan, LessThan, Equal • Find an algorithm to check whether one decimal number is greater than, less than, or equal to another – 837 > 756 • Start with the MSD, 8 > 7 and you’re done…any number with 8 in the 100’s place is greater than a number with 7 in the 100’s place – 621 < 649 • Start with the MSD, 6 = 6…you can’t tell yet which is greater or less than so move to the next digit • 2 < 4 and you’re done 62x is always less than 64x • Algorithm: Start with the MSD and keep comparing digits to the right. Once any digit of A is > or < corresponding digit of B then you know the whole number A > B or A < B, respectively. If all digits are equal then both number are equal. © Mark Redekopp, All rights reserved...
View
Full Document
 Fall '06
 Redekopp
 Comparator, Mark Redekopp

Click to edit the document details