3Bit Comparator Problem

Thread Starter

Giorgos Alexakis

Joined Feb 8, 2019
17
Hi guys,
I want to draw a circuit with input two unsigned binary 3bit binary numbers A=A2 A1 A0 and B=B2 B1 B0 and one output F which result is 1 when A<2B otherwise is 0.

Any help ??
 

WBahn

Joined Mar 31, 2012
29,979
Hi guys,
I want to draw a circuit with input two unsigned binary 3bit binary numbers A=A2 A1 A0 and B=B2 B1 B0 and one output F which result is 1 when A<2B otherwise is 0.

Any help ??
Any attempt ??

You need to show YOUR best attempt (doesn't have to be right or very far along) to solve YOUR homework problem. Then we can help YOU identify and fix any problems you are having so that you can proceed from there.

What would you do if just asked to output a 1 when A < B (not 2B)?
 

Thread Starter

Giorgos Alexakis

Joined Feb 8, 2019
17
Any attempt ??

You need to show YOUR best attempt (doesn't have to be right or very far along) to solve YOUR homework problem. Then we can help YOU identify and fix any problems you are having so that you can proceed from there.

What would you do if just asked to output a 1 when A < B (not 2B)?
Thanks for your reply,
At first i was thinking of doing the truth table with 64 combinations and a 6 variable K-map but I 've never done something like that at my courses. I know the 4bit comparator function when A<B is F=Α3’ B3 + x3 A2’ B2+ x3 x2 A1’ B1 + x3 x2 x1 A0’ B0 where xi = AiΒi+Ai’Βi’ right?
But I don't know ..will it be something like: A2'B2+x2 A1'B1+ x2 x1 A0'B0+x2 x1 x0 ??

It is a problem i will probably have in my final exams its not for homework.
 

WBahn

Joined Mar 31, 2012
29,979
Thanks for your reply,
At first i was thinking of doing the truth table with 64 combinations and a 6 variable K-map but I 've never done something like that at my courses. I know the 4bit comparator function when A<B is F=Α3’ B3 + x3 A2’ B2+ x3 x2 A1’ B1 + x3 x2 x1 A0’ B0 where xi = AiΒi+Ai’Βi’ right?
But I don't know ..will it be something like: A2'B2+x2 A1'B1+ x2 x1 A0'B0+x2 x1 x0 ??

It is a problem i will probably have in my final exams its not for homework.
You're in the ballpark.

Do you understand what each of the terms in the 4-bit function does?

Then compare that carefully to your proposed 3-bit function. Do you see the difference?
 

Thread Starter

Giorgos Alexakis

Joined Feb 8, 2019
17
You're in the ballpark.

Do you understand what each of the terms in the 4-bit function does?

Then compare that carefully to your proposed 3-bit function. Do you see the difference?

I'm not quite sure what each of the terms in the 4-bit does .
Seeing it again I'm thinking 3bit function would be just : A2'B2+x2 A1'B1+ x2 x1 A0'B0 ???
 

WBahn

Joined Mar 31, 2012
29,979
I'm not quite sure what each of the terms in the 4-bit does .
Seeing it again I'm thinking 3bit function would be just : A2'B2+x2 A1'B1+ x2 x1 A0'B0 ???
That's correct, but to take the next step and solve the problem you are actually trying to solve, you really do need to understand how that function works.

Think of how you would do it by hand for ordinary base-10 numbers. If asked to determine which is larger, 58329 or 58361, how would you do it if you could only look at one digit from each number at a time?
 

Thread Starter

Giorgos Alexakis

Joined Feb 8, 2019
17
That's correct, but to take the next step and solve the problem you are actually trying to solve, you really do need to understand how that function works.

Think of how you would do it by hand for ordinary base-10 numbers. If asked to determine which is larger, 58329 or 58361, how would you do it if you could only look at one digit from each number at a time?

If i understand correctly I have to compare each digit from MSB to LSB so should I split the comperator or something but how ??
Also, the function also works for unsigned numbers ?
 

WBahn

Joined Mar 31, 2012
29,979
If i understand correctly I have to compare each digit from MSB to LSB so should I split the comperator or something but how ??
Look at that first term. A2'B2. That's TRUE when?

Now, if that's FALSE, look at the second term. x2 A1'B1. That's TRUE when? What role does the x2 play?

Also, the function also works for unsigned numbers ?
What "also"? We are only talking about unsigned numbers.
 

Thread Starter

Giorgos Alexakis

Joined Feb 8, 2019
17
Look at that first term. A2'B2. That's TRUE when?

Now, if that's FALSE, look at the second term. x2 A1'B1. That's TRUE when? What role does the x2 play?
A2'B2 is TRUE when both A2' , B2 are 1

if it's FALSE then x2A1'B1 is TRUE if all of them are 1 ...(A2B2+A2'B2')=1 , A1'B1=1 ???

What "also"? We are only talking about unsigned numbers.
Forget about this...
 

WBahn

Joined Mar 31, 2012
29,979
A2'B2 is TRUE when both A2' , B2 are 1
That's a pretty useless statement. Of course A2'B2 is TRUE when both A2' and B2 are 1. That's merely the definition of the AND function.

But what is the significance of A2' and B2 both being TRUE? What does that tell you about the question of whether A<B?
 

Thread Starter

Giorgos Alexakis

Joined Feb 8, 2019
17
That's a pretty useless statement. Of course A2'B2 is TRUE when both A2' and B2 are 1. That's merely the definition of the AND function.

But what is the significance of A2' and B2 both being TRUE? What does that tell you about the question of whether A<B?
If both are TRUE then A2=0 ,B2=1 so at first A is less than B
 

WBahn

Joined Mar 31, 2012
29,979
Then x2(=A2B2+A2'B2') will be TRUE so I'll have to check A1,B1.
Yes. So do you see how that logic cascades from bit to bit?

Now, how can you get 2·A from A without using any gates at all?

What is the practical implication of multiplying a binary number by two?

Hint: What is the practical implication of multiplying a decimal number by ten?
 

Thread Starter

Giorgos Alexakis

Joined Feb 8, 2019
17
Yes. So do you see how that logic cascades from bit to bit?

Now, how can you get 2·A from A without using any gates at all?

What is the practical implication of multiplying a binary number by two?

Hint: What is the practical implication of multiplying a decimal number by ten?
You just add another 0 at the end (LSB)...Does that mean that the number of bits increases ?
 

WBahn

Joined Mar 31, 2012
29,979
You just add another 0 at the end (LSB)...Does that mean that the number of bits increases ?
Another way of saying that you just add 0 to the end is to say that you shift all of the bits one place to the left (and make the lsb zero). THIS is the useful tidbit that you need to understand and be able to exploit.

If I want to multiply a binary value by two, all I have to do is shift the bits one place to the left. If I want to multiply it by eight, I just shift it three places to the left.

If I want to produce Y = 5·A from a binary number, I can write that as Y = 4·A + A. I get the 4·A for free just by tapping off and shifting wires two places to the right. If A is just a two-bit number, then the resulting wires don't overlap and so I don't need any logic at all.

But what if Y is a 3-bit number? How might you deal with the overlapping signals?

Yes, the number of bits increases, just as the number of digits in a decimal number increases if we multiply it by ten.
 
Top