nbit comparator using 1 bit comparator Our focus
n-bit comparator using 1 -bit comparator • Our focus is on making n-bit circuit using 1 -bit building block • Comparing two n-bit numbers for their equality – – A ----> An-1 An-2 …………A 0 B ----> Bn-1 Bn-2…………. B 0 • First, we shall compare the two numbers for equality • Start with MSB and compare one bit at a time • If the bit of one number is greater than the corresponding bit of the other number, then the number is greater. This becomes the solution • Else, i. e if the two bits are equal, then compare the next bit. • Repeat the last two steps 1
Basic building block for n-bit comparator • 1 -bit comparator forms the building block for comparing two -bit numbers. • E is the cascading signal • Ei+1 is the Cascading input, Ei is the cascading output • Ei+1 = 1 implies that the two numbers are not equal so far • Ei+1 = 0 implies that the two numbers are equal so far • If Ei+1 = 1, then Ei = 1 • Else, Ei = Ei+1 + (Ai XOR Bi ) Ai Ei+1 n Bi Ei 2
Using 1 -bit building blocks to make n-bit circuit • Using the building block, we can build an n-bit comparator circuit • What is the value of input En ? • The final result is, if E 0 = 0, then A = B and if E 0 = 1, then A != B An-1 En Bn-1 An-2 En-1 Bn-2 A 0 E 1 B 0 E 0 3
1 -bit complex comparator • Next, we compare the two numbers for A > B, A = B or A < B • The basic building block for the purpose is as shown – The primary inputs are Ai and Bi – Cascading inputs are (A>B)in, (A=B)in and (A<B)in, and – Cascading outputs are (A>B)out, (A=B)out and (A<B)out • The equations can be directly written as Ai Bi • (A>B)out = (A>B)in + (A=B)in. (Ai. Bi’) • (A<B)out = (A<B)in + (A=B)in. (Ai’. Bi ) • (A=B)out = (A=B)in. (Ai Bi + Ai’. Bi’) (A>B)in (A>B)out (A=B)in (A=B)out (A<B)in 4
1 -bit simplified complex comparator • The 1 -bit complex comparator block is modified to have fewer cascading signals • It has two primary inputs, two cascading inputs, and two cascading outputs • The equations for the outputs are • (A>B)out = (A>B)in + (A<B)in’. ( Ai Bi’ ) • (A<B)out = (A<B)in + (A>B)in’. ( Ai’ Bi ) • If both (A>B)out and (A<B)out are 0 then the two bits are equal Ai Bi (A>B)in (A>B)out (A<B)in (A<B)out 5
1 -bit maximizer building block • The 1 -bit maximizer block is similar to the simplified complex comparator • It has two primary inputs, one primary output, two cascading inputs, and two cascading outputs • The primary output M is 1 if depending on which input is greater • The equations for the outputs are – (A>B)out = (A>B)in + (A<B)in’. ( Ai Bi’ ) – (A<B)out = (A<B)in + (A>B)in’. ( Ai’ Bi ) – M = (A>B)in. A + (A<B)in. B + (A>B)in’. (A<B)in’. (Ai + Bi) Ai Bi (A>B)in (A>B)out (A<B)in (A<B)out M 6
- Slides: 6