Need help creating A>=B signal in ALU.

Thread Starter

Max McKinley

Joined Mar 10, 2015
4
I am working on a lab where we created a basic ALU that adds/subtracts or does an AND operation. It does this using a standard 4-bit ripple carry adder that can decide when to subtract using 2's complement based on the initial cin. Now I have a problem that says:

If we wanted to extend our ALU design with a signal that is HIGH when A ≥ B, what
changes could we make to the design to do so? Include a gate-level schematic with your suggested
modifications. Hint: Think about the sign bit of the result when performing a subtraction.

I realize I could just do the truth table/k-map thing, but with this having 8 inputs that would be huge and overly complex. I currently know how to output how when A=B by just doing A1 (XOR) B1 with each of the bits and ANDing them together. I'm not sure how to incorporate the > part though.

Also I realize you could just invert the most significant bit, and this would work when you are subtracting, but when you add a number where A<B then it wouldn't work properly. Any kind of help would be appreciated.

(I would upload pictures of my circuits but don't know how to attach a photo from my computer onto this post.)
 

Thread Starter

Max McKinley

Joined Mar 10, 2015
4
ya i mean like i said you can invert that, which will give you the correct output when subtracting. But this doesnt help when adding. I've been on this for hours and I just have a mental block on it right now.
 

djsfantasi

Joined Apr 11, 2010
9,163
Why would you want to invert that bit?
I think it might provide you with some information as is.

Why are you worried about adding? It was my understanding that your current circuit works.

We'd still like to see your schematic...
 

Thread Starter

Max McKinley

Joined Mar 10, 2015
4
Ok here is my original circuit.
Figure 7.PNG
Here is what I have just come up with. The line coming from off the screen feeding into not5 is from the carry out of the a2 and b2 (coming from Or2). Basically I'm just trying to force this circuit to subtraction on A and B, so I can see which one is bigger. Now, the only thing I am worried about is if that carry in value will be correct. If you add then the carry in will be off by one since the original c1 wasn't 1 like it would be if you were subtracting right? That's why I added the not5, but now I am unsure if this will work for if the user chooses subtraction. I believe this is the right line of thinking just unsure if my exact implementation is correct.
Capture.PNG
 

Thread Starter

Max McKinley

Joined Mar 10, 2015
4
Ok here is my original circuit.
View attachment 81905
Here is what I have just come up with. The line coming from off the screen feeding into not5 is from the carry out of the a2 and b2 (coming from Or2). Basically I'm just trying to force this circuit to subtraction on A and B, so I can see which one is bigger. Now, the only thing I am worried about is if that carry in value will be correct. If you add then the carry in will be off by one since the original c1 wasn't 1 like it would be if you were subtracting right? That's why I added the not5, but now I am unsure if this will work for if the user chooses subtraction. I believe this is the right line of thinking just unsure if my exact implementation is correct.
View attachment 81906
I believe I figured it out. In case any one is curious about my solution I removed not 5 and then XNORed c0 with that same line. This effectively inverts the carry-in if you add and maintains it if you subtract, fixing the off-by-one error.
 

WBahn

Joined Mar 31, 2012
30,058
Your original ALU performs the following function when Cin = 1: Y = A-B. So ask what the sign bit is when A>B, A=B, and A<B.
 
Top